From 34027a834907ec144400e4e8910b5cd3b7e0d0b3 Mon Sep 17 00:00:00 2001 From: disaerna Date: Wed, 21 Aug 2024 09:52:56 +0000 Subject: [PATCH 01/11] fix: resolver naming and logic --- .../src/lib/health-directorate.resolver.ts | 59 ++++++------ .../src/lib/health-directorate.service.ts | 92 ++++++++----------- .../src/lib/models/organ-donation.model.ts | 77 ++++++++-------- .../src/lib/models/vaccinations.model.ts | 64 +++++++------ libs/clients/health-directorate/src/index.ts | 1 + .../clients/organ-donation/clientConfig.json | 10 +- .../organ-donation/organDonation.config.ts | 2 +- .../organ-donation/organDonation.provider.ts | 6 +- .../organ-donation/organDonation.service.ts | 8 +- .../clients/vaccinations/clientConfig.json | 49 +++++----- .../vaccinations/vaccinations.config.ts | 2 +- .../vaccinations/vaccinations.service.ts | 4 +- .../OrganDonation/OrganDonation.graphql | 32 ++++--- .../screens/OrganDonation/OrganDonation.tsx | 16 ++-- .../OrganDonationRegistration/Limitations.tsx | 15 ++- .../RegistrationForm.tsx | 39 ++++---- .../screens/Vaccinations/Vaccinations.graphql | 35 +++---- .../Vaccinations/VaccinationsGeneral.tsx | 10 +- .../Vaccinations/VaccinationsOther.tsx | 10 +- .../tables/SortedVaccinationsTable.tsx | 29 +++--- .../health/src/utils/tagSelector.ts | 9 ++ 21 files changed, 290 insertions(+), 279 deletions(-) diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts index acd7c72f406c..dc5a8eb53c68 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts @@ -1,4 +1,11 @@ -import { Args, Mutation, Query, Resolver } from '@nestjs/graphql' +import { + Args, + Mutation, + Parent, + Query, + ResolveField, + Resolver, +} from '@nestjs/graphql' import { UseGuards } from '@nestjs/common' @@ -11,11 +18,7 @@ import { import type { User } from '@island.is/auth-nest-tools' import { ApiScope } from '@island.is/auth/scopes' import { Audit } from '@island.is/nest/audit' -import { - DonationException, - DonorStatus, - DonorStatusInput, -} from './models/organ-donation.model' +import { DonorInput, Organ, OrganDonation } from './models/organ-donation.model' import type { Locale } from '@island.is/shared/types' import { Vaccinations } from './models/vaccinations.model' import { HealthDirectorateService } from './health-directorate.service' @@ -23,29 +26,31 @@ import { HealthDirectorateService } from './health-directorate.service' @UseGuards(IdsUserGuard, ScopesGuard) @Scopes(ApiScope.internal) @Audit({ namespace: '@island.is/api/health-directorate' }) -@Resolver() +@Resolver(() => OrganDonation) export class HealthDirectorateResolver { constructor(private api: HealthDirectorateService) {} /* Organ Donation */ - @Query(() => DonorStatus, { - name: 'HealthDirectorateOrganDonationGetDonorStatus', + @Query(() => OrganDonation, { + name: 'HealthDirectorateOrganDonation', }) @Audit() - getDonorStatus(@CurrentUser() user: User): Promise { - return this.api.getDonorStatus(user) - } - - @Query(() => DonationException, { - name: 'HealthDirectorateOrganDonationGetDonationExceptions', - }) - @Audit() - getDonationExceptions( + async getDonorStatus( @Args('locale', { type: () => String, nullable: true }) locale: Locale = 'is', @CurrentUser() user: User, - ): Promise { - return this.api.getDonationExceptions(user, locale) + ): Promise { + const data = await this.api.getDonorStatus(user) + return { donor: data, locale: locale } + } + @ResolveField('organList', () => [Organ], { + nullable: true, + }) + async resolveOrganList( + @Parent() organDonation: OrganDonation, + @CurrentUser() user: User, + ): Promise> { + return this.api.getDonationExceptions(user, organDonation.locale ?? 'is') } @Mutation(() => Boolean, { @@ -54,22 +59,18 @@ export class HealthDirectorateResolver { }) @Audit() async updateDonorStatus( - @Args('input') input: DonorStatusInput, + @Args('input') input: DonorInput, @CurrentUser() user: User, ): Promise { return this.api.updateDonorStatus(user, input) } /* Vaccinations */ - @Query(() => [Vaccinations], { - name: 'HealthDirectorateVaccinationsGetVaccinations', + @Query(() => Vaccinations, { + name: 'HealthDirectorateVaccinations', }) @Audit() - getVaccinations( - @Args('locale', { type: () => String, nullable: true }) - locale: Locale = 'is', - @CurrentUser() user: User, - ): Promise> { - return this.api.getVaccinations(user, locale) + getVaccinations(@CurrentUser() user: User): Promise { + return this.api.getVaccinations(user) } } diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts index 3390b5b24216..cc42d73d2b56 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts @@ -8,13 +8,9 @@ import { } from '@island.is/clients/health-directorate' import { Auth } from '@island.is/auth-nest-tools' import type { Locale } from '@island.is/shared/types' -import { - DonationException, - DonorStatus, - DonorStatusInput, -} from './models/organ-donation.model' +import { Donor, DonorInput, Organ } from './models/organ-donation.model' -import { Vaccinations } from './models/vaccinations.model' +import { Info, Vaccination, Vaccinations } from './models/vaccinations.model' @Injectable() export class HealthDirectorateService { @@ -24,15 +20,18 @@ export class HealthDirectorateService { ) {} /* Organ Donation */ - async getDonorStatus(auth: Auth): Promise { + async getDonorStatus(auth: Auth): Promise { const data: OrganDonorDto | null = await this.organDonationApi.getOrganDonation(auth) - const donorStatus: DonorStatus = { + const donorStatus: Donor = { isDonor: data?.isDonor || false, - registrationDate: data?.registrationDate, - exceptions: data?.exceptions, - exceptionComment: data?.exceptionComment, + limitations: { + hasLimitations: + ((data?.exceptions?.length ?? 0) > 0 && data?.isDonor) ?? false, + organList: data?.exceptions, + comment: data?.exceptionComment, + }, } return donorStatus } @@ -40,11 +39,10 @@ export class HealthDirectorateService { async getDonationExceptions( auth: Auth, locale: Locale, - ): Promise { + ): Promise> { const lang: organLocale = locale === 'is' ? organLocale.Is : organLocale.En const data = await this.organDonationApi.getDonationExceptions(auth, lang) - const exceptions: DonationException = { values: [] } - exceptions.values = + const limitations: Array = data?.map((item) => { return { id: item.id, @@ -52,56 +50,46 @@ export class HealthDirectorateService { } }) ?? [] - return exceptions + return limitations } - async updateDonorStatus(auth: Auth, input: DonorStatusInput): Promise { - await this.organDonationApi - .updateOrganDonation(auth, { - exceptionComment: input.exceptionComment ?? '', - isDonor: input.isDonor, - exceptions: input.exceptions ?? [], - registrationDate: new Date(), - }) - .then(() => { - return true - }) - .catch(() => { - return false - }) + async updateDonorStatus(auth: Auth, input: DonorInput): Promise { + return await this.organDonationApi.updateOrganDonation(auth, { + exceptionComment: '', + isDonor: input.isDonor, + exceptions: input.organLimitations ?? [], + registrationDate: new Date(), + }) } /* Vaccinations */ - async getVaccinations( - auth: Auth, - locale: Locale, - ): Promise> { - const data = await this.vaccinationApi.getVaccinationDiseaseDetail(auth, { - locale, - }) - const vaccinations: Array = + async getVaccinations(auth: Auth): Promise { + const data = await this.vaccinationApi.getVaccinationDiseaseDetail(auth) + const vaccinations: Array = data?.map((item) => { return { - diseaseId: item.diseaseId, - diseaseName: item.diseaseName, - diseaseDescription: item.diseaseDescription, - vaccinationStatus: item.vaccinationStatus, - vaccinationsStatusName: item.vaccinationStatusName, + id: item.diseaseId, + name: item.diseaseName, + description: item.diseaseDescription, + isFeatured: item.isFeatured, + status: item.vaccinationStatus, + statusName: item.vaccinationStatusName, lastVaccinationDate: item.lastVaccinationDate, - vaccinations: - item.vaccinations?.map((vaccination: VaccinationDto) => { + vaccinationsInfo: item.vaccinations?.map( + (vaccination: VaccinationDto) => { return { id: vaccination.id, - nationalId: vaccination.nationalId, - code: vaccination.code, - vaccinationDate: vaccination.vaccinationDate, - vaccinationsAge: vaccination.vaccinationAge, - generalComment: vaccination.generalComment.toString(), + name: vaccination.vaccineName, + date: vaccination.vaccinationDate, + age: vaccination.vaccinationAge, + url: vaccination.vaccineUrl, + comment: vaccination.generalComment, rejected: vaccination.rejected, - } - }) ?? [], + } as Info + }, + ), } }) ?? [] - return vaccinations + return { vaccinations } } } diff --git a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts index a26a7ffacac7..e91ac43ca72d 100644 --- a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts @@ -1,34 +1,34 @@ -import { ObjectType, Field, Int, InputType } from '@nestjs/graphql' +import { ObjectType, Field, InputType } from '@nestjs/graphql' -@ObjectType('HealthDirectorateOrganDonorStatus') -export class DonorStatus { +@ObjectType('HealthDirectorateOrganDonationLimitations') +export class Limitations { @Field(() => Boolean) - isDonor!: boolean - - @Field(() => [String], { nullable: true }) - exceptions?: string[] - - @Field({ nullable: true }) - exceptionComment?: string - - @Field(() => Date, { nullable: true }) - registrationDate?: Date + hasLimitations!: boolean + + @Field(() => [String], { + nullable: true, + description: 'List of organs NOT to donate', + }) + organList?: string[] + + @Field({ + nullable: true, + description: 'Text to display if user does not want to donate all organs', + }) + comment?: string } -@InputType('HealthDirectorateOrganDonorStatusInput') -export class DonorStatusInput { +@ObjectType('HealthDirectorateOrganDonor') +export class Donor { @Field(() => Boolean) isDonor!: boolean - @Field(() => [String], { nullable: true }) - exceptions?: string[] - - @Field({ nullable: true }) - exceptionComment?: string + @Field(() => Limitations, { nullable: true }) + limitations?: Limitations } -@ObjectType('HealthDirectorateOrganDonationExceptionObject') -export class DonationExceptionObject { +@ObjectType('HealthDirectorateOrganDonationOrgan') +export class Organ { @Field({ nullable: true }) id?: string @@ -36,26 +36,23 @@ export class DonationExceptionObject { name?: string } -@ObjectType('HealthDirectorateOrganDonationException') -export class DonationException { - @Field(() => [DonationExceptionObject], { nullable: true }) - values?: DonationExceptionObject[] -} +@ObjectType('HealthDirectorateOrganDonation') +export class OrganDonation { + @Field(() => Donor, { nullable: true }) + donor?: Donor -@ObjectType('HealthDirectorateError') -export class HealthDirectorateError { - @Field({ nullable: true }) - type?: string - - @Field({ nullable: true }) - title?: string + @Field(() => [Organ], { nullable: true }) + organList?: Array - @Field(() => Int, { nullable: true }) - status?: number + @Field(() => String, { nullable: true }) + locale?: 'is' | 'en' +} - @Field({ nullable: true }) - detail?: string +@InputType('HealthDirectorateOrganDonorInput') +export class DonorInput { + @Field(() => Boolean) + isDonor!: boolean - @Field({ nullable: true }) - instance?: string + @Field(() => [String], { nullable: true }) + organLimitations?: string[] } diff --git a/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts b/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts index 95f4c70c8cf3..4ec9d7c271dc 100644 --- a/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts @@ -1,7 +1,12 @@ -import { Field, ObjectType } from '@nestjs/graphql' +import { DiseaseVaccinationDtoVaccinationStatusEnum } from '@island.is/clients/health-directorate' +import { Field, ObjectType, registerEnumType } from '@nestjs/graphql' + +registerEnumType(DiseaseVaccinationDtoVaccinationStatusEnum, { + name: 'HealthDirectorateVaccinationsStatus', +}) @ObjectType('HealthDirectorateVaccinationsAge') -export class VaccinationsAge { +export class Age { @Field(() => Number, { nullable: true }) years?: number @@ -9,61 +14,62 @@ export class VaccinationsAge { months?: number } -@ObjectType('HealthDirectorateVaccinationsDetail') -export class VaccinationsDetail { +@ObjectType('HealthDirectorateVaccinationsInfo') +export class Info { @Field(() => Number) id!: number @Field({ nullable: true }) - nationalId?: string - - @Field({ nullable: true }) - code?: string + name?: string @Field(() => Date, { nullable: true }) - vaccinationDate?: Date + date?: Date - @Field(() => VaccinationsAge, { nullable: true }) - vaccinationsAge?: VaccinationsAge + @Field(() => Age, { nullable: true }) + age?: Age @Field({ nullable: true }) - generalComment?: string + url?: string + + @Field({ nullable: true }) + comment?: string @Field(() => Boolean, { nullable: true }) rejected?: boolean } -@ObjectType('HealthDirectorateVaccinations') -export class Vaccinations { +@ObjectType('HealthDirectorateVaccination') +export class Vaccination { @Field() - diseaseId!: string + id!: string @Field({ nullable: true }) - diseaseName?: string + name?: string @Field({ nullable: true }) - diseaseDescription?: string + description?: string + + @Field(() => Boolean, { nullable: true }) + isFeatured?: boolean @Field() - vaccinationStatus!: - | 'valid' - | 'expired' - | 'complete' - | 'incomplete' - | 'undocumented' - | 'unvaccinated' - | 'rejected' - | 'undetermined' + status!: string @Field({ nullable: true }) - vaccinationsStatusName?: string + statusName?: string @Field(() => Date, { nullable: true }) lastVaccinationDate?: Date - @Field(() => [VaccinationsDetail], { nullable: true }) - vaccinations?: VaccinationsDetail[] + @Field(() => [Info], { nullable: true }) + vaccinationsInfo?: Info[] @Field(() => [String], { nullable: true }) comments?: string[] } + +@ObjectType('HealthDirectorateVaccinations') +export class Vaccinations { + @Field(() => [Vaccination]) + vaccinations!: Vaccination[] +} diff --git a/libs/clients/health-directorate/src/index.ts b/libs/clients/health-directorate/src/index.ts index 2ec0bfdbc768..0ce3077b2353 100644 --- a/libs/clients/health-directorate/src/index.ts +++ b/libs/clients/health-directorate/src/index.ts @@ -12,4 +12,5 @@ export { Locale, organLocale, VaccinationDto, + DiseaseVaccinationDtoVaccinationStatusEnum, } from './lib/clients' diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json b/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json index b95e62cdb6a8..83c3aaf415a0 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "paths": { - "/v1/me/donor-status": { + "/v1/me/organ-donor-status": { "get": { "operationId": "MeDonorStatusController_getOrganDonorStatus", "description": "Get user's donation-exception donor status", @@ -48,7 +48,7 @@ } } }, - "tags": ["me/donor-status"] + "tags": ["me/organ-donor-status"] }, "post": { "operationId": "MeDonorStatusController_updateOrganDonorStatus", @@ -97,7 +97,7 @@ } } }, - "tags": ["me/donor-status"] + "tags": ["me/organ-donor-status"] } }, "/v1/donation-exceptions": { @@ -180,7 +180,7 @@ "tokenUrl": "https://identity-server.dev01.devland.is/connect/token", "scopes": { "openid": "openid", - "@landlaeknir.is/organ-donations": "Get and update donation-exception donation status for a user" + "@landlaeknir.is/organ-donations": "Get and update donation status for a user" } } } @@ -206,7 +206,7 @@ "type": "object", "properties": { "type": { - "type": "string", + "type": "object", "description": "A URI reference that identifies the problem type" }, "title": { diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts index 6d6e400e89d1..f604c698b5ab 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts @@ -17,7 +17,7 @@ export const HealthDirectorateOrganDonationClientConfig = defineConfig< 'XROAD_HEALTH_DIRECTORATE_PATH', 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir', ), - scope: [], + scope: ['@landlaeknir.is/organ-donations'], } }, }) diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.provider.ts b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.provider.ts index 28a50d3c1657..23c07598c250 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.provider.ts +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.provider.ts @@ -8,19 +8,19 @@ import { import { HealthDirectorateOrganDonationClientConfig } from './organDonation.config' import { Configuration, - MeDonorStatusApi, + MeOrganDonorStatusApi, DonationExceptionsApi, } from './gen/fetch' export const OrganDonorApiProvider = { - provide: MeDonorStatusApi, + provide: MeOrganDonorStatusApi, scope: LazyDuringDevScope, useFactory: ( xRoadConfig: ConfigType, config: ConfigType, idsClientConfig: ConfigType, ) => { - return new MeDonorStatusApi( + return new MeOrganDonorStatusApi( new Configuration({ fetchApi: createEnhancedFetch({ name: 'clients-health-directorate-organ-donation', diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts index b794307b59db..9a980f3de07f 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts @@ -4,7 +4,7 @@ import { Inject, Injectable } from '@nestjs/common' import { DonationExceptionsApi, Locale, - MeDonorStatusApi, + MeOrganDonorStatusApi, OrganDonorDto, OrganDto, } from './gen/fetch' @@ -16,7 +16,7 @@ const LOG_CATEGORY = 'health-directorate-organ-donation-api' export class HealthDirectorateOrganDonationService { constructor( @Inject(LOGGER_PROVIDER) private readonly logger: Logger, - private readonly organDonationApi: MeDonorStatusApi, + private readonly organDonationApi: MeOrganDonorStatusApi, private readonly donationExceptionsApi: DonationExceptionsApi, ) {} @@ -47,9 +47,9 @@ export class HealthDirectorateOrganDonationService { .meDonorStatusControllerUpdateOrganDonorStatus({ updateOrganDonorDto: input, }) - .catch((error) => { + .catch((error: Error) => { throw new Error( - `health-directorate-organ-donation-client: upload organ donation status failed ${error.type}`, + `health-directorate-organ-donation-client: update organ donation status failed ${error.message}`, ) }) } diff --git a/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json b/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json index 797800fb2f17..302d9c1606a9 100644 --- a/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json +++ b/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json @@ -58,14 +58,7 @@ "get": { "operationId": "MeVaccinationController_getVaccinationsForDiseases", "description": "Get overview of vaccinations for a user", - "parameters": [ - { - "name": "locale", - "required": true, - "in": "query", - "schema": { "type": "string" } - } - ], + "parameters": [], "responses": { "200": { "description": "", @@ -127,12 +120,6 @@ "in": "path", "description": "id of the disease", "schema": { "type": "string" } - }, - { - "name": "locale", - "required": true, - "in": "query", - "schema": { "type": "string" } } ], "responses": { @@ -673,7 +660,8 @@ "scopes": { "openid": "openid", "vaccination": "vaccination", - "@landlaeknir.is/vaccinations:admin": "Get vaccination data for a user" + "@landlaeknir.is/vaccinations:admin": "Manage vaccination data", + "@landlaeknir.is/vaccinations": "Get vaccination data for a user" } } } @@ -689,6 +677,7 @@ "codingSystem": { "type": "string", "example": "ATC" }, "codeDescription": { "type": "string", "example": "ATC" }, "vaccineName": { "type": "string", "example": "ATC" }, + "vaccineUrl": { "type": "string" }, "vaccinationDate": { "format": "date-time", "type": "string", @@ -698,7 +687,7 @@ "type": "object", "example": { "years": 1, "months": 2 } }, - "generalComment": { "type": "object", "example": "ATC" }, + "generalComment": { "type": "string" }, "rejected": { "type": "boolean", "example": false } }, "required": [ @@ -708,6 +697,7 @@ "codingSystem", "codeDescription", "vaccineName", + "vaccineUrl", "vaccinationDate", "vaccinationAge", "generalComment", @@ -718,7 +708,7 @@ "type": "object", "properties": { "type": { - "type": "string", + "type": "object", "description": "A URI reference that identifies the problem type" }, "title": { @@ -737,12 +727,20 @@ }, "required": ["type", "title"] }, + "VaccinationStatusColor": { + "type": "string", + "enum": ["green", "yellow", "red"] + }, "DiseaseVaccinationDto": { "type": "object", "properties": { "diseaseId": { "type": "string", "example": "tetanus" }, "diseaseName": { "type": "string", "example": "Stífkrampi" }, "diseaseDescription": { "type": "string" }, + "isFeatured": { + "type": "boolean", + "description": "Is the vaccination scheduled as in \"almenn bólusetning\"" + }, "vaccinationStatus": { "type": "string", "example": "vaccinated", @@ -758,6 +756,9 @@ ] }, "vaccinationStatusName": { "type": "string", "example": "Í gildi" }, + "vaccinationStatusColor": { + "$ref": "#/components/schemas/VaccinationStatusColor" + }, "lastVaccinationDate": { "format": "date-time", "type": "string" }, "vaccinations": { "type": "array", @@ -769,8 +770,10 @@ "diseaseId", "diseaseName", "diseaseDescription", + "isFeatured", "vaccinationStatus", "vaccinationStatusName", + "vaccinationStatusColor", "lastVaccinationDate", "vaccinations", "comments" @@ -801,7 +804,7 @@ "id": { "type": "number" }, "diseaseId": { "type": "string" }, "order": { "type": "number" }, - "type": { "type": "string" }, + "type": { "type": "object" }, "cond1Type": { "type": "string" }, "cond1Min": { "type": "number" }, "cond1Max": { "type": "number" }, @@ -865,7 +868,7 @@ "items": { "type": "number" } }, "isFeatured": { "type": "boolean" }, - "isScheduled": { "type": "boolean" }, + "isVisible": { "type": "boolean" }, "vaccines": { "type": "array", "items": { "$ref": "#/components/schemas/VaccineDto" } @@ -885,7 +888,7 @@ "description", "doseSchedule", "isFeatured", - "isScheduled", + "isVisible", "vaccines", "rules", "translations" @@ -904,7 +907,7 @@ "items": { "type": "number" } }, "isFeatured": { "type": "boolean" }, - "isScheduled": { "type": "boolean" }, + "isVisible": { "type": "boolean" }, "rules": { "type": "array", "items": { "$ref": "#/components/schemas/DiseaseRuleDto" } @@ -919,7 +922,7 @@ "type": "object", "properties": { "order": { "type": "number" }, - "type": { "type": "string" }, + "type": { "type": "object" }, "cond1Type": { "type": "string" }, "cond1Min": { "type": "number" }, "cond1Max": { "type": "number" }, @@ -965,7 +968,7 @@ "id": { "type": "number" }, "diseaseId": { "type": "string" }, "order": { "type": "number" }, - "type": { "type": "string" }, + "type": { "type": "object" }, "cond1Type": { "type": "string" }, "cond1Min": { "type": "number" }, "cond1Max": { "type": "number" }, diff --git a/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts b/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts index 98b99dca5f3f..bd42b1a018b5 100644 --- a/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts +++ b/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts @@ -17,7 +17,7 @@ export const HealthDirectorateVaccinationsClientConfig = defineConfig< 'XROAD_HEALTH_DIRECTORATE_PATH', 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir', ), - scope: [], + scope: ['@landlaeknir.is/vaccinations'], } }, }) diff --git a/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts b/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts index e494367fbff1..84acba873821 100644 --- a/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts +++ b/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts @@ -3,7 +3,6 @@ import { handle404 } from '@island.is/clients/middlewares' import { Inject, Injectable } from '@nestjs/common' import { DiseaseVaccinationDto, - MeVaccinationControllerGetVaccinationsForDiseasesRequest, MeVaccinationsApi, VaccinationDto, } from './gen/fetch' @@ -41,10 +40,9 @@ export class HealthDirectorateVaccinationsService { public async getVaccinationDiseaseDetail( auth: Auth, - input: MeVaccinationControllerGetVaccinationsForDiseasesRequest, ): Promise | null> { const disease = await this.vaccinationsApiWithAuth(auth) - .meVaccinationControllerGetVaccinationsForDiseases(input) + .meVaccinationControllerGetVaccinationsForDiseases() .catch(handle404) if (!disease) { diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql index 17dd93a23a84..5df5af51e398 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql @@ -1,23 +1,31 @@ -query getDonorStatus { - HealthDirectorateOrganDonationGetDonorStatus { - isDonor - exceptions - exceptionComment - registrationDate +query getDonorStatus($locale: String) { + HealthDirectorateOrganDonation(locale: $locale) { + donor { + isDonor + limitations { + hasLimitations + organList + comment + } + } } } -query getOrganDonationExceptions($locale: String) { - HealthDirectorateOrganDonationGetDonationExceptions(locale: $locale) { - values { +query getOrgansList($locale: String) { + HealthDirectorateOrganDonation(locale: $locale) { + donor { + isDonor + limitations { + hasLimitations + } + } + organList { id name } } } -mutation updateOrganDonationInfo( - $input: HealthDirectorateOrganDonorStatusInput! -) { +mutation updateOrganDonationInfo($input: HealthDirectorateOrganDonorInput!) { HealthDirectorateOrganDonationUpdateDonorStatus(input: $input) } diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx index 58cf1d6ac945..6a43a5be68b9 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx @@ -14,16 +14,14 @@ const OrganDonation = () => { const { formatMessage } = useLocale() const { data, loading, error } = useGetDonorStatusQuery() - const donorStatus = data?.HealthDirectorateOrganDonationGetDonorStatus + const donorStatus = data?.HealthDirectorateOrganDonation.donor - const exceptionText: string = - donorStatus?.exceptions?.length && donorStatus.exceptions.length > 0 - ? [ - donorStatus?.exceptionComment, - - donorStatus?.exceptions?.join(', '), - ].join(':') ?? '' - : donorStatus?.exceptionComment ?? '' + const exceptionText: string = donorStatus?.limitations?.hasLimitations + ? [ + donorStatus?.limitations.comment, + donorStatus?.limitations.organList?.join(', '), + ].join(':') ?? '' + : donorStatus?.limitations?.comment ?? '' return ( { @@ -45,15 +45,12 @@ const Limitations = ({ data }: LimitationsProps) => { marginY="smallGutter" > - handleCheckboxChange( - y.name?.toLowerCase() ?? '', - e.target.checked, - ) + handleCheckboxChange(y.id ?? '', e.target.checked) } /> diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx index 92eeedf3f847..a639956746e9 100644 --- a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx @@ -20,8 +20,7 @@ import * as styles from './OrganDonationRegistration.css' import Limitations from './Limitations' import { useNavigate } from 'react-router-dom' import { - useGetDonorStatusQuery, - useGetOrganDonationExceptionsQuery, + useGetOrgansListQuery, useUpdateOrganDonationInfoMutation, } from '../OrganDonation/OrganDonation.generated' @@ -34,10 +33,19 @@ export const Form2 = () => { const OPT_IN_EXCEPTIONS = 'opt-in-exceptions' const OPT_OUT = 'opt-out' - const { data, loading } = useGetOrganDonationExceptionsQuery({ + const { data, loading } = useGetOrgansListQuery({ variables: { locale: lang }, }) + const isDonor = data?.HealthDirectorateOrganDonation.donor?.isDonor + const hasLimitations = + data?.HealthDirectorateOrganDonation.donor?.limitations?.hasLimitations + const donorStatus = isDonor + ? hasLimitations + ? OPT_IN_EXCEPTIONS + : OPT_IN + : OPT_OUT + const [updateDonorStatus] = useUpdateOrganDonationInfoMutation({ onCompleted: () => { toast.success(formatMessage(messages.registrationComplete)) @@ -47,24 +55,14 @@ export const Form2 = () => { toast.error(formatMessage(messages.registrationFailed)) }, }) - const { data: status } = useGetDonorStatusQuery() - - const exceptions = - data?.HealthDirectorateOrganDonationGetDonationExceptions.values + const limitations = data?.HealthDirectorateOrganDonation.organList const [radioValue, setRadioValue] = useState() useEffect(() => { if (radioValue === undefined) { - setRadioValue( - status?.HealthDirectorateOrganDonationGetDonorStatus.isDonor - ? OPT_IN - : (status?.HealthDirectorateOrganDonationGetDonorStatus - ?.exceptionComment?.length ?? 0) > 0 - ? OPT_IN_EXCEPTIONS - : OPT_OUT, - ) + setRadioValue(donorStatus) } - }, [status]) + }, [data]) const onSubmit = async (e: React.FormEvent) => { e.preventDefault() @@ -75,11 +73,12 @@ export const Form2 = () => { const limitations = Object.keys(data) .filter((key) => key.includes(idKey)) .map((key) => key.replace(idKey, '').toLowerCase()) + await updateDonorStatus({ variables: { input: { isDonor: radioValue === OPT_IN || radioValue === OPT_IN_EXCEPTIONS, - exceptions: radioValue === OPT_IN_EXCEPTIONS ? limitations : [], + organLimitations: radioValue === OPT_IN_EXCEPTIONS ? limitations : [], }, }, }) @@ -128,10 +127,10 @@ export const Form2 = () => { checked={radioValue === OPT_IN_EXCEPTIONS} onChange={() => setRadioValue(OPT_IN_EXCEPTIONS)} /> - {exceptions && - exceptions.length > 0 && + {limitations && + limitations.length > 0 && radioValue === OPT_IN_EXCEPTIONS && ( - + )} { const { data, loading, error } = useGetVaccinationsQuery() - const vaccinations = data?.HealthDirectorateVaccinationsGetVaccinations + const vaccinations = data?.HealthDirectorateVaccinations.vaccinations + const general = vaccinations?.filter((x) => x.isFeatured) + return ( @@ -25,11 +27,11 @@ export const VaccinationsGeneral = () => { borderRadius="standard" /> )} - {!error && vaccinations?.length === 0 && ( + {!error && general?.length === 0 && ( )} - {!error && !loading && vaccinations !== undefined && ( - + {!error && !loading && general !== undefined && ( + )} {!loading && error && } diff --git a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx index 4ef397b65f64..60483c2b3f8a 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx +++ b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx @@ -11,7 +11,9 @@ import { Problem } from '@island.is/react-spa/shared' export const VaccinationsOther = () => { const { formatMessage } = useLocale() const { data, loading, error } = useGetVaccinationsQuery() - const vaccinations = data?.HealthDirectorateVaccinationsGetVaccinations + const vaccinations = data?.HealthDirectorateVaccinations.vaccinations + const other = vaccinations?.filter((x) => !x.isFeatured) + return ( @@ -23,11 +25,11 @@ export const VaccinationsOther = () => { borderRadius="standard" /> )} - {!error && vaccinations?.length === 0 && ( + {!error && other?.length === 0 && ( )} - {!error && !loading && vaccinations !== undefined && ( - + {!error && !loading && other !== undefined && ( + )} {!loading && error && } diff --git a/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx b/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx index babe324efcbf..aa901e821924 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx +++ b/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx @@ -6,10 +6,10 @@ import { tagSelector } from '../../../utils/tagSelector' import { VaccinationsDetailTable } from './VaccinationsDetailTable' import { DetailHeader, DetailRow } from '../../../utils/types' import { ATC_URL_BASE } from '../../../utils/constants' -import { HealthDirectorateVaccinations } from '@island.is/api/schema' +import { HealthDirectorateVaccination } from '@island.is/api/schema' interface Props { - data: Array + data: Array } export const SortedVaccinationsTable = ({ data }: Props) => { useNamespaces('sp.health') @@ -44,41 +44,40 @@ export const SortedVaccinationsTable = ({ data }: Props) => { defaultSortByKey="vaccine" items={ data?.map((item, i) => ({ - id: item?.diseaseId ?? `${i}`, - name: item?.diseaseName ?? '', - vaccine: item?.diseaseName ?? '', + id: item?.id ?? `${i}`, + name: item?.name ?? '', + vaccine: item?.name ?? '', date: formatDate(item?.lastVaccinationDate) ?? '', children: ( => { return [ { value: (i + 1).toString(), }, { - value: - vaccination.vaccinationDate.toLocaleDateString('is-IS'), + value: vaccination.date.toLocaleDateString('is-IS'), }, { value: [ - vaccination.vaccinationsAge?.years, + vaccination.age?.years, formatMessage(messages.years), - vaccination.vaccinationsAge?.months, + vaccination.age?.months, formatMessage(messages.months), ] .filter(Boolean) .join(' '), }, { - value: vaccination.code ?? '', + value: vaccination.name ?? '', type: 'link', - url: ATC_URL_BASE + vaccination.code, + url: vaccination.url ?? '', }, { - value: vaccination.generalComment, + value: vaccination.comment, }, ] }, @@ -86,8 +85,8 @@ export const SortedVaccinationsTable = ({ data }: Props) => { footerText={item.comments ?? []} /> ), - status: item?.vaccinationsStatusName ?? '', - tag: tagSelector(item?.vaccinationStatus ?? ''), + status: item?.statusName ?? '', + tag: tagSelector(item?.status ?? ''), })) ?? [] } /> diff --git a/libs/service-portal/health/src/utils/tagSelector.ts b/libs/service-portal/health/src/utils/tagSelector.ts index e4a913841f7a..026597b4d1d4 100644 --- a/libs/service-portal/health/src/utils/tagSelector.ts +++ b/libs/service-portal/health/src/utils/tagSelector.ts @@ -8,3 +8,12 @@ export const tagSelector = (str: string) => { return (obj as any)?.[str] || 'blue' } + +// Valid = 'valid', +// Expired = 'expired', +// Complete = 'complete', +// Incomplete = 'incomplete', +// Undocumented = 'undocumented', +// Unvaccinated = 'unvaccinated', +// Rejected = 'rejected', +// Undetermined = 'undetermined' From 67863b09c80481f13d37590c7270073207fd614e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Fri, 30 Aug 2024 15:22:13 +0000 Subject: [PATCH 02/11] health fixes --- .../src/lib/health-directorate.service.ts | 2 +- .../clients/vaccinations/clientConfig.json | 50 ++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts index cc42d73d2b56..cc9f272e8f73 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts @@ -79,7 +79,7 @@ export class HealthDirectorateService { (vaccination: VaccinationDto) => { return { id: vaccination.id, - name: vaccination.vaccineName, + name: vaccination.vaccineCodeDescriptionShort, date: vaccination.vaccinationDate, age: vaccination.vaccinationAge, url: vaccination.vaccineUrl, diff --git a/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json b/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json index 302d9c1606a9..1b4baf76c0db 100644 --- a/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json +++ b/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json @@ -572,6 +572,29 @@ "tags": ["diseases"] } }, + "/v1/vaccines": { + "get": { + "operationId": "VaccineController_getVaccines", + "parameters": [], + "responses": { "200": { "description": "" } }, + "tags": ["vaccines"] + } + }, + "/v1/vaccines/{vaccineId}": { + "get": { + "operationId": "VaccineController_getVaccineById", + "parameters": [ + { + "name": "vaccineId", + "required": true, + "in": "path", + "schema": { "type": "number" } + } + ], + "responses": { "200": { "description": "" } }, + "tags": ["vaccines"] + } + }, "/v1/visualizer/diseases/{diseaseId}": { "get": { "operationId": "VisualizerController_getStatus", @@ -636,8 +659,14 @@ } } } - }, - "tags": ["visualizer"] + } + } + }, + "/*": { + "get": { + "operationId": "VisualizerController_getVisualizer", + "parameters": [], + "responses": { "200": { "description": "" } } } } }, @@ -655,8 +684,8 @@ "type": "oauth2", "flows": { "authorizationCode": { - "authorizationUrl": "https://identity-server.dev01.devland.is/connect/authorize", - "tokenUrl": "https://identity-server.dev01.devland.is/connect/token", + "authorizationUrl": "undefined/connect/authorize", + "tokenUrl": "undefined/connect/token", "scopes": { "openid": "openid", "vaccination": "vaccination", @@ -782,12 +811,21 @@ "VaccineDto": { "type": "object", "properties": { + "id": { "type": "number" }, "code": { "type": "string" }, "codingSystem": { "type": "string", "example": "ATC" }, "name": { "type": "string" }, - "description": { "type": "string" } + "description": { "type": "string" }, + "diseases": { "type": "array", "items": { "type": "string" } } }, - "required": ["code", "codingSystem", "name", "description"] + "required": [ + "id", + "code", + "codingSystem", + "name", + "description", + "diseases" + ] }, "Locale": { "type": "string", "enum": ["en", "is"] }, "DiseaseRuleTranslationDto": { From 654c8910cd9d222b679a08c589df7c886da9a14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Mon, 2 Sep 2024 15:15:19 +0000 Subject: [PATCH 03/11] refactor: after service added --- apps/api/infra/api.ts | 4 + charts/islandis/values.dev.yaml | 2 + charts/islandis/values.prod.yaml | 2 + charts/islandis/values.staging.yaml | 2 + infra/src/dsl/xroad.ts | 22 +++ .../src/lib/health-directorate.resolver.ts | 2 +- .../src/lib/health-directorate.service.ts | 23 ++- .../src/lib/models/organ-donation.model.ts | 6 + .../src/lib/models/vaccinations.model.ts | 11 +- .../clients/organ-donation/clientConfig.json | 9 +- .../organ-donation/organDonation.config.ts | 4 +- .../clients/vaccinations/clientConfig.json | 30 ++- .../vaccinations/vaccinations.config.ts | 4 +- libs/service-portal/core/src/index.ts | 1 + .../service-portal/health/src/lib/messages.ts | 16 ++ libs/service-portal/health/src/module.tsx | 24 +-- .../OrganDonation/OrganDonation.graphql | 1 + .../screens/OrganDonation/OrganDonation.tsx | 13 +- .../OrganDonationRegistration/Limitations.tsx | 24 +-- .../RegistrationForm.tsx | 179 ++++++++++-------- .../screens/Vaccinations/Vaccinations.graphql | 1 + .../Vaccinations/VaccinationsGeneral.tsx | 42 ---- .../Vaccinations/VaccinationsOther.tsx | 40 ---- .../Vaccinations/VaccinationsWrapper.tsx | 93 +++++++++ .../tables/SortedVaccinationsTable.tsx | 144 +++++++------- .../tables/VaccinationsDetailTable.tsx | 6 +- .../wrapper/VaccinationsWrapper.tsx | 63 ------ .../health/src/utils/tagSelector.ts | 3 +- 28 files changed, 395 insertions(+), 376 deletions(-) delete mode 100644 libs/service-portal/health/src/screens/Vaccinations/VaccinationsGeneral.tsx delete mode 100644 libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx create mode 100644 libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx delete mode 100644 libs/service-portal/health/src/screens/Vaccinations/wrapper/VaccinationsWrapper.tsx diff --git a/apps/api/infra/api.ts b/apps/api/infra/api.ts index 7591d0b17acb..57e7f8ae7c01 100644 --- a/apps/api/infra/api.ts +++ b/apps/api/infra/api.ts @@ -47,6 +47,8 @@ import { OfficialJournalOfIceland, OfficialJournalOfIcelandApplication, Frigg, + HealthDirectorateOrganDonation, + HealthDirectorateVaccination, } from '../../../infra/src/dsl/xroad' export const serviceSetup = (services: { @@ -427,6 +429,8 @@ export const serviceSetup = (services: { OfficialJournalOfIceland, OfficialJournalOfIcelandApplication, Frigg, + HealthDirectorateOrganDonation, + HealthDirectorateVaccination, ) .files({ filename: 'islyklar.p12', env: 'ISLYKILL_CERT' }) .ingress({ diff --git a/charts/islandis/values.dev.yaml b/charts/islandis/values.dev.yaml index 143b87b8a515..4e2edd0f38a8 100644 --- a/charts/islandis/values.dev.yaml +++ b/charts/islandis/values.dev.yaml @@ -352,7 +352,9 @@ api: XROAD_FINANCES_V2_PATH: 'IS-DEV/GOV/10021/FJS-Public/financeServicesFJS_v2' XROAD_FINANCIAL_AID_BACKEND_PATH: 'IS-DEV/MUN/10023/samband-sveitarfelaga/financial-aid-backend' XROAD_FIREARM_LICENSE_PATH: 'IS-DEV/GOV/10005/Logreglan-Protected/island-api-v1' + XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1' XROAD_HEALTH_DIRECTORATE_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir' + XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1' XROAD_HEALTH_INSURANCE_ID: 'IS-DEV/GOV/10007/SJUKRA-Protected' XROAD_HEALTH_INSURANCE_MY_PAGES_PATH: 'IS-DEV/GOV/10007/SJUKRA-Protected/minarsidur' XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' diff --git a/charts/islandis/values.prod.yaml b/charts/islandis/values.prod.yaml index 2a3d984973fe..ab04e6ca97f2 100644 --- a/charts/islandis/values.prod.yaml +++ b/charts/islandis/values.prod.yaml @@ -342,7 +342,9 @@ api: XROAD_FINANCES_V2_PATH: 'IS/GOV/5402697509/FJS-Public/financeServicesFJS_v2' XROAD_FINANCIAL_AID_BACKEND_PATH: 'IS/MUN/5502694739/samband-sveitarfelaga/financial-aid-backend' XROAD_FIREARM_LICENSE_PATH: 'IS/GOV/5309672079/Logreglan-Protected/island-api-v1' + XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/organ-donation-v1' XROAD_HEALTH_DIRECTORATE_PATH: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/landlaeknir' + XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/vaccination-v1' XROAD_HEALTH_INSURANCE_ID: 'IS/GOV/4804080550/SJUKRA-Protected' XROAD_HEALTH_INSURANCE_MY_PAGES_PATH: 'IS/GOV/4804080550/SJUKRA-Protected/minarsidur' XROAD_HEALTH_INSURANCE_WSDLURL: 'https://huld.sjukra.is/islandrg?wsdl' diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index 04ce486ef46f..eb9df4d0b7ec 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -352,7 +352,9 @@ api: XROAD_FINANCES_V2_PATH: 'IS-DEV/GOV/10021/FJS-Public/financeServicesFJS_v2' XROAD_FINANCIAL_AID_BACKEND_PATH: 'IS-TEST/MUN/5502694739/samband-sveitarfelaga/financial-aid-backend' XROAD_FIREARM_LICENSE_PATH: 'IS/GOV/5309672079/Logreglan-Protected/island-api-v1' + XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1' XROAD_HEALTH_DIRECTORATE_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir' + XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1' XROAD_HEALTH_INSURANCE_ID: 'IS-TEST/GOV/4804080550/SJUKRA-Protected' XROAD_HEALTH_INSURANCE_MY_PAGES_PATH: 'IS-TEST/GOV/4804080550/SJUKRA-Protected/minarsidur' XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' diff --git a/infra/src/dsl/xroad.ts b/infra/src/dsl/xroad.ts index 6bc6fc0750ac..abad4648fae0 100644 --- a/infra/src/dsl/xroad.ts +++ b/infra/src/dsl/xroad.ts @@ -889,3 +889,25 @@ export const Frigg = new XroadConf({ }, }, }) + + +export const HealthDirectorateOrganDonation = new XroadConf({ + env: { + XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: { + dev: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', + staging: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', + prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/organ-donation-v1', + }, + }, +}) + + +export const HealthDirectorateVaccination = new XroadConf({ + env: { + XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: { + dev: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', + staging: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', + prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/vaccination-v1', + } + }, +}) \ No newline at end of file diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts index dc5a8eb53c68..1b9d1e907e86 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts @@ -40,7 +40,7 @@ export class HealthDirectorateResolver { locale: Locale = 'is', @CurrentUser() user: User, ): Promise { - const data = await this.api.getDonorStatus(user) + const data = await this.api.getDonorStatus(user, locale) return { donor: data, locale: locale } } @ResolveField('organList', () => [Organ], { diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts index cc9f272e8f73..d46aa4c98332 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts @@ -20,16 +20,27 @@ export class HealthDirectorateService { ) {} /* Organ Donation */ - async getDonorStatus(auth: Auth): Promise { + async getDonorStatus(auth: Auth, locale: Locale): Promise { const data: OrganDonorDto | null = await this.organDonationApi.getOrganDonation(auth) - + // Fetch organ list to get all names in correct language to sort out the names of the organs the user has limitations for + const organLang: organLocale = + locale === 'is' ? organLocale.Is : organLocale.En + const limitations = await this.organDonationApi.getDonationExceptions( + auth, + organLang, + ) + // Filter organ list to get the names + const organList = + limitations?.filter((item) => data?.exceptions?.includes(item.id)) ?? [] + const organListNames: string[] = organList.map((item) => item.name) const donorStatus: Donor = { - isDonor: data?.isDonor || false, + isDonor: data?.isDonor ?? true, limitations: { hasLimitations: ((data?.exceptions?.length ?? 0) > 0 && data?.isDonor) ?? false, - organList: data?.exceptions, + organList: organListNames, + organIds: data?.exceptions, comment: data?.exceptionComment, }, } @@ -74,7 +85,9 @@ export class HealthDirectorateService { isFeatured: item.isFeatured, status: item.vaccinationStatus, statusName: item.vaccinationStatusName, - lastVaccinationDate: item.lastVaccinationDate, + statusColor: item.vaccinationStatusColor, + lastVaccinationDate: item.lastVaccinationDate ?? null, + comments: item.comments, vaccinationsInfo: item.vaccinations?.map( (vaccination: VaccinationDto) => { return { diff --git a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts index e91ac43ca72d..4db138c55000 100644 --- a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts @@ -11,6 +11,12 @@ export class Limitations { }) organList?: string[] + @Field(() => [String], { + nullable: true, + description: 'List of organ IDs NOT to donate', + }) + organIds?: string[] + @Field({ nullable: true, description: 'Text to display if user does not want to donate all organs', diff --git a/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts b/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts index 4ec9d7c271dc..54a747707083 100644 --- a/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts @@ -23,7 +23,7 @@ export class Info { name?: string @Field(() => Date, { nullable: true }) - date?: Date + date?: Date | null @Field(() => Age, { nullable: true }) age?: Age @@ -52,14 +52,17 @@ export class Vaccination { @Field(() => Boolean, { nullable: true }) isFeatured?: boolean - @Field() - status!: string + @Field({ nullable: true }) + status?: string @Field({ nullable: true }) statusName?: string + @Field({ nullable: true }) + statusColor?: string + @Field(() => Date, { nullable: true }) - lastVaccinationDate?: Date + lastVaccinationDate?: Date | null @Field(() => [Info], { nullable: true }) vaccinationsInfo?: Info[] diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json b/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json index 83c3aaf415a0..79f3519e37e0 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json @@ -195,12 +195,7 @@ "exceptionComment": { "type": "string" }, "registrationDate": { "format": "date-time", "type": "string" } }, - "required": [ - "isDonor", - "exceptions", - "exceptionComment", - "registrationDate" - ] + "required": ["isDonor", "exceptions"] }, "HttpProblemResponse": { "type": "object", @@ -232,7 +227,7 @@ "exceptions": { "type": "array", "items": { "type": "string" } }, "exceptionComment": { "type": "string" } }, - "required": ["isDonor", "exceptions", "exceptionComment"] + "required": ["isDonor", "exceptions"] }, "Locale": { "type": "string", "enum": ["en", "is"] }, "OrganDto": { diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts index f604c698b5ab..bfc0d54aa840 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts @@ -14,8 +14,8 @@ export const HealthDirectorateOrganDonationClientConfig = defineConfig< load(env) { return { xroadPath: env.required( - 'XROAD_HEALTH_DIRECTORATE_PATH', - 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir', + 'XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH', + 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', ), scope: ['@landlaeknir.is/organ-donations'], } diff --git a/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json b/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json index 1b4baf76c0db..28fcdb7b9ec0 100644 --- a/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json +++ b/libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json @@ -684,13 +684,14 @@ "type": "oauth2", "flows": { "authorizationCode": { - "authorizationUrl": "undefined/connect/authorize", - "tokenUrl": "undefined/connect/token", + "authorizationUrl": "https://identity-server.dev01.devland.is/connect/authorize", + "tokenUrl": "https://identity-server.dev01.devland.is/connect/token", "scopes": { "openid": "openid", "vaccination": "vaccination", - "@landlaeknir.is/vaccinations:admin": "Manage vaccination data", - "@landlaeknir.is/vaccinations": "Get vaccination data for a user" + "@landlaeknir.is/vaccinations:admin": "Manage disease- and vaccine data", + "@landlaeknir.is/vaccinations": "Get vaccination data for a user", + "@landlaeknir.is/vaccinations:read": "Get disease- and vaccine data" } } } @@ -702,10 +703,10 @@ "properties": { "id": { "type": "number" }, "nationalId": { "type": "string", "example": "1234567890" }, - "code": { "type": "string", "example": "J07BJ51" }, - "codingSystem": { "type": "string", "example": "ATC" }, - "codeDescription": { "type": "string", "example": "ATC" }, - "vaccineName": { "type": "string", "example": "ATC" }, + "vaccineCode": { "type": "string", "example": "J07BJ51" }, + "vaccineCodingSystem": { "type": "string", "example": "ATC" }, + "vaccineCodeDescription": { "type": "string" }, + "vaccineCodeDescriptionShort": { "type": "string" }, "vaccineUrl": { "type": "string" }, "vaccinationDate": { "format": "date-time", @@ -722,10 +723,10 @@ "required": [ "id", "nationalId", - "code", - "codingSystem", - "codeDescription", - "vaccineName", + "vaccineCode", + "vaccineCodingSystem", + "vaccineCodeDescription", + "vaccineCodeDescriptionShort", "vaccineUrl", "vaccinationDate", "vaccinationAge", @@ -798,12 +799,7 @@ "required": [ "diseaseId", "diseaseName", - "diseaseDescription", "isFeatured", - "vaccinationStatus", - "vaccinationStatusName", - "vaccinationStatusColor", - "lastVaccinationDate", "vaccinations", "comments" ] diff --git a/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts b/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts index bd42b1a018b5..c82aa75c2dd0 100644 --- a/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts +++ b/libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts @@ -14,8 +14,8 @@ export const HealthDirectorateVaccinationsClientConfig = defineConfig< load(env) { return { xroadPath: env.required( - 'XROAD_HEALTH_DIRECTORATE_PATH', - 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir', + 'XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH', + 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', ), scope: ['@landlaeknir.is/vaccinations'], } diff --git a/libs/service-portal/core/src/index.ts b/libs/service-portal/core/src/index.ts index be2a0f215437..9f528d7f1c1f 100644 --- a/libs/service-portal/core/src/index.ts +++ b/libs/service-portal/core/src/index.ts @@ -29,6 +29,7 @@ export * from './components/ToolTip/ToolTip' export * from './components/LinkButton/LinkButton' export * from './components/GoBack/GoBack' export * from './components/TabNavigation/TabNavigation' +export * from './components/TabNavigation/TabBar' export * from './components/ProgressBar/ProgressBar' export * from './components/ScrollableMiddleTable/ScrollableMiddleTable' export * from './components/Gallery/Gallery' diff --git a/libs/service-portal/health/src/lib/messages.ts b/libs/service-portal/health/src/lib/messages.ts index 2c58f91532bf..020d76cd887d 100644 --- a/libs/service-portal/health/src/lib/messages.ts +++ b/libs/service-portal/health/src/lib/messages.ts @@ -998,6 +998,10 @@ export const messages = defineMessages({ id: 'sp.health:i-am-organ-donor', defaultMessage: 'Ég er líffæragjafi.', }, + iAmOrganDonorWithExceptions: { + id: 'sp.health:i-am-organ-donor-w-exceptions', + defaultMessage: 'Ég heimila líffæragjöf, með takmörkunum.', + }, iAmNotOrganDonor: { id: 'sp.health:i-am-not-organ-donor', defaultMessage: 'Ég banna líffæragjöf.', @@ -1107,4 +1111,16 @@ export const messages = defineMessages({ defaultMessage: 'Ekki tókst að sækja gögn frá Embætti Landlæknis. Vinsamlegast reynið aftur síðar', }, + medicinePrescriptions: { + id: 'sp.health:medicine-prescriptions', + defaultMessage: 'Lyfjaávísanir', + }, + medicineDelegation: { + id: 'sp.health:medicine-delegation', + defaultMessage: 'Lyfjaumboð', + }, + medicinePaymentParticipation: { + id: 'sp.health:medicine-payment-participation', + defaultMessage: 'Greiðsluþátttaka', + }, }) diff --git a/libs/service-portal/health/src/module.tsx b/libs/service-portal/health/src/module.tsx index a69c0c4efcda..3889342cefed 100644 --- a/libs/service-portal/health/src/module.tsx +++ b/libs/service-portal/health/src/module.tsx @@ -62,12 +62,8 @@ const OrganDonationRegistration = lazy(() => import('./screens/OrganDonationRegistration/RegistrationForm'), ) -const VaccinationsGeneral = lazy(() => - import('./screens/Vaccinations/VaccinationsGeneral'), -) - -const VaccinationsOther = lazy(() => - import('./screens/Vaccinations/VaccinationsOther'), +const Vaccinations = lazy(() => + import('./screens/Vaccinations/VaccinationsWrapper'), ) export const healthModule: PortalModule = { @@ -224,21 +220,7 @@ export const healthModule: PortalModule = { path: HealthPaths.HealthVaccinations, key: 'HealthVaccinations', enabled: userInfo.scopes.includes(ApiScope.healthVaccinations), - element: , - }, - { - name: hm.generalVaccinations, - path: HealthPaths.HealthVaccinationsGeneral, - key: 'HealthVaccinations', - enabled: userInfo.scopes.includes(ApiScope.healthVaccinations), - element: , - }, - { - name: hm.otherVaccinations, - path: HealthPaths.HealthVaccinationsOther, - key: 'HealthVaccinations', - enabled: userInfo.scopes.includes(ApiScope.healthVaccinations), - element: , + element: , }, ], } diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql index 5df5af51e398..3960bab3f7cb 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql @@ -17,6 +17,7 @@ query getOrgansList($locale: String) { isDonor limitations { hasLimitations + organIds } } organList { diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx index 6a43a5be68b9..e9a5a6b97e72 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx @@ -13,15 +13,19 @@ const OrganDonation = () => { useNamespaces('sp.health') const { formatMessage } = useLocale() - const { data, loading, error } = useGetDonorStatusQuery() + const { data, loading, error } = useGetDonorStatusQuery({ + fetchPolicy: 'no-cache', + }) const donorStatus = data?.HealthDirectorateOrganDonation.donor + //TODO: Move this to service const exceptionText: string = donorStatus?.limitations?.hasLimitations ? [ donorStatus?.limitations.comment, donorStatus?.limitations.organList?.join(', '), - ].join(':') ?? '' + ].join(':') + '.' ?? '' : donorStatus?.limitations?.comment ?? '' + return ( { { url: HealthPaths.HealthOrganDonationRegistration, label: formatMessage(m.changeTake), centered: true, + variant: 'text', }} /> diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx index e1acceccc3da..e625cdf7a3a4 100644 --- a/libs/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx @@ -1,28 +1,16 @@ -import { - Box, - Checkbox, - Divider, - GridColumn, - GridContainer, - GridRow, - Input, - Stack, -} from '@island.is/island-ui/core' +import { Box, Checkbox, Divider, Stack } from '@island.is/island-ui/core' import React, { useState } from 'react' -import { OptionsLimitations } from '../../utils/OrganDonationMock' -import { messages } from '../..' -import { useLocale, useNamespaces } from '@island.is/localization' +import { useNamespaces } from '@island.is/localization' import { HealthDirectorateOrganDonationOrgan } from '@island.is/api/schema' interface LimitationsProps { data: HealthDirectorateOrganDonationOrgan[] + selected?: string[] | null } -const Limitations = ({ data }: LimitationsProps) => { +const Limitations = ({ data, selected }: LimitationsProps) => { useNamespaces('sp.health') - const { formatMessage } = useLocale() - const [checked, setChecked] = useState>([]) - + const [checked, setChecked] = useState>(selected ?? []) const handleCheckboxChange = (id: string, isChecked: boolean) => { setChecked((prevState) => isChecked ? [...prevState, id] : prevState.filter((item) => item !== id), @@ -39,6 +27,7 @@ const Limitations = ({ data }: LimitationsProps) => { {data?.map( (y, yi) => ( // y.type === 'checkbox' && ( + { onChange={(e) => handleCheckboxChange(y.id ?? '', e.target.checked) } + checked={checked.includes(y.id ?? '')} /> ), diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx index a639956746e9..4888d98d59c9 100644 --- a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx @@ -5,6 +5,7 @@ import { Text, Button, toast, + LoadingDots, } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' import { @@ -24,15 +25,15 @@ import { useUpdateOrganDonationInfoMutation, } from '../OrganDonation/OrganDonation.generated' +const OPT_IN = 'opt-in' +const OPT_IN_EXCEPTIONS = 'opt-in-exceptions' +const OPT_OUT = 'opt-out' + export const Form2 = () => { useNamespaces('sp.health') const { formatMessage, lang } = useLocale() const navigate = useNavigate() - const OPT_IN = 'opt-in' - const OPT_IN_EXCEPTIONS = 'opt-in-exceptions' - const OPT_OUT = 'opt-out' - const { data, loading } = useGetOrgansListQuery({ variables: { locale: lang }, }) @@ -40,11 +41,15 @@ export const Form2 = () => { const isDonor = data?.HealthDirectorateOrganDonation.donor?.isDonor const hasLimitations = data?.HealthDirectorateOrganDonation.donor?.limitations?.hasLimitations + const limitations = data?.HealthDirectorateOrganDonation.organList + const selectedLimitations = + data?.HealthDirectorateOrganDonation.donor?.limitations?.organIds const donorStatus = isDonor ? hasLimitations ? OPT_IN_EXCEPTIONS : OPT_IN : OPT_OUT + const [radioValue, setRadioValue] = useState(donorStatus) const [updateDonorStatus] = useUpdateOrganDonationInfoMutation({ onCompleted: () => { @@ -55,21 +60,19 @@ export const Form2 = () => { toast.error(formatMessage(messages.registrationFailed)) }, }) - const limitations = data?.HealthDirectorateOrganDonation.organList - const [radioValue, setRadioValue] = useState() useEffect(() => { - if (radioValue === undefined) { + if (radioValue !== donorStatus) { setRadioValue(donorStatus) } - }, [data]) + }, [donorStatus]) const onSubmit = async (e: React.FormEvent) => { e.preventDefault() const formData = new FormData(e.currentTarget) const data = Object.fromEntries(formData.entries()) - const idKey = 'organ-donation-limitation-' + const idKey = 'selected-limitations-' const limitations = Object.keys(data) .filter((key) => key.includes(idKey)) .map((key) => key.replace(idKey, '').toLowerCase()) @@ -93,84 +96,92 @@ export const Form2 = () => { {formatMessage(messages.changeTake)} - -
- - - setRadioValue(OPT_IN)} - /> - - - setRadioValue(OPT_IN_EXCEPTIONS)} - /> - {limitations && - limitations.length > 0 && - radioValue === OPT_IN_EXCEPTIONS && ( - - )} - + {/* TODO: Better loading state */} + {loading && } + {!loading && ( + + + + setRadioValue(OPT_IN)} + /> + + + setRadioValue(OPT_IN_EXCEPTIONS)} + /> + {limitations && + limitations.length > 0 && + radioValue === OPT_IN_EXCEPTIONS && ( + + )} + + + setRadioValue(OPT_OUT)} + /> + + - setRadioValue(OPT_OUT)} - /> - - - - - + + - - - -
+
+ + )} ) } diff --git a/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql b/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql index ca477d9430aa..f3612deae59a 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql +++ b/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql @@ -7,6 +7,7 @@ query getVaccinations { isFeatured status statusName + statusColor lastVaccinationDate vaccinationsInfo { id diff --git a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsGeneral.tsx b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsGeneral.tsx deleted file mode 100644 index b843041f6e9d..000000000000 --- a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsGeneral.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { Box, SkeletonLoader } from '@island.is/island-ui/core' -import { HealthPaths } from '../../lib/paths' -import { VaccinationsWrapper } from './wrapper/VaccinationsWrapper' -import { SortedVaccinationsTable } from './tables/SortedVaccinationsTable' -import { useGetVaccinationsQuery } from './Vaccinations.generated' -import { EmptyTable } from '@island.is/service-portal/core' -import { useLocale } from '@island.is/localization' -import { messages as m } from '../../lib/messages' -import { Problem } from '@island.is/react-spa/shared' - -export const VaccinationsGeneral = () => { - const { formatMessage } = useLocale() - - const { data, loading, error } = useGetVaccinationsQuery() - - const vaccinations = data?.HealthDirectorateVaccinations.vaccinations - const general = vaccinations?.filter((x) => x.isFeatured) - - return ( - - - {loading && ( - - )} - {!error && general?.length === 0 && ( - - )} - {!error && !loading && general !== undefined && ( - - )} - {!loading && error && } - - - ) -} - -export default VaccinationsGeneral diff --git a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx deleted file mode 100644 index 60483c2b3f8a..000000000000 --- a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsOther.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { Box, SkeletonLoader } from '@island.is/island-ui/core' -import { HealthPaths } from '../../lib/paths' -import { VaccinationsWrapper } from './wrapper/VaccinationsWrapper' -import { SortedVaccinationsTable } from './tables/SortedVaccinationsTable' -import { useGetVaccinationsQuery } from './Vaccinations.generated' -import { EmptyTable } from '@island.is/service-portal/core' -import { useLocale } from '@island.is/localization' -import { messages as m } from '../../lib/messages' -import { Problem } from '@island.is/react-spa/shared' - -export const VaccinationsOther = () => { - const { formatMessage } = useLocale() - const { data, loading, error } = useGetVaccinationsQuery() - const vaccinations = data?.HealthDirectorateVaccinations.vaccinations - const other = vaccinations?.filter((x) => !x.isFeatured) - - return ( - - - {loading && ( - - )} - {!error && other?.length === 0 && ( - - )} - {!error && !loading && other !== undefined && ( - - )} - {!loading && error && } - - - ) -} - -export default VaccinationsOther diff --git a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx new file mode 100644 index 000000000000..9e2000e553b0 --- /dev/null +++ b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx @@ -0,0 +1,93 @@ +import { useLocale, useNamespaces } from '@island.is/localization' +import { Box, SkeletonLoader, Tabs } from '@island.is/island-ui/core' +import { + HEALTH_DIRECTORATE_SLUG, + IntroHeader, + LinkButton, + EmptyTable, +} from '@island.is/service-portal/core' +import { messages as m } from '../../lib/messages' +import { SECTION_GAP } from '../../utils/constants' +import { useGetVaccinationsQuery } from './Vaccinations.generated' +import { SortedVaccinationsTable } from './tables/SortedVaccinationsTable' +import { isDefined } from '@island.is/shared/utils' +import { Problem } from '@island.is/react-spa/shared' + +export const VaccinationsWrapper = () => { + useNamespaces('sp.health') + const { formatMessage } = useLocale() + const { data, loading, error } = useGetVaccinationsQuery() + + const vaccinations = data?.HealthDirectorateVaccinations.vaccinations + + const general = vaccinations?.filter((x) => x.isFeatured) + const other = vaccinations?.filter((x) => !x.isFeatured) + + const tabs = [ + { + label: formatMessage(m.generalVaccinations), + content: , + }, + { + label: formatMessage(m.otherVaccinations), + content: , + }, + ].filter(isDefined) + + return ( + + + {/* Buttons */} + + + + + + + + + {loading && ( + + )} + {!error && vaccinations?.length === 0 && ( + + )} + + {!loading && error && } + + {/* Tabs content */} + {!loading && !error && ( + + + + )} + + ) +} +export default VaccinationsWrapper diff --git a/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx b/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx index aa901e821924..39cf4ea001e8 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx +++ b/libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx @@ -1,94 +1,106 @@ import { useLocale, useNamespaces } from '@island.is/localization' -import { SortableTable, formatDate } from '@island.is/service-portal/core' +import { + EmptyTable, + SortableTable, + formatDate, +} from '@island.is/service-portal/core' import { messages } from '../../../lib/messages' -import { Vaccine } from '../dataStructure' import { tagSelector } from '../../../utils/tagSelector' import { VaccinationsDetailTable } from './VaccinationsDetailTable' import { DetailHeader, DetailRow } from '../../../utils/types' -import { ATC_URL_BASE } from '../../../utils/constants' import { HealthDirectorateVaccination } from '@island.is/api/schema' +import { Box } from '@island.is/island-ui/core' interface Props { - data: Array + data?: Array } export const SortedVaccinationsTable = ({ data }: Props) => { useNamespaces('sp.health') const { formatMessage } = useLocale() const headerDataDetail: Array = [ { - value: 'Nr.', + value: formatMessage(messages.vaccinesTableHeaderNr), }, { - value: 'Dags.', + value: formatMessage(messages.vaccinesTableHeaderDate), }, { - value: 'Aldur', + value: formatMessage(messages.vaccinesTableHeaderAge), }, { - value: 'Bóluefni', + value: formatMessage(messages.vaccinesTableHeaderVaccine), }, { - value: 'Staður', + value: formatMessage(messages.vaccinesTableHeaderLocation), }, ] + if (data?.length === 0) + return + return ( - ({ - id: item?.id ?? `${i}`, - name: item?.name ?? '', - vaccine: item?.name ?? '', - date: formatDate(item?.lastVaccinationDate) ?? '', + + ({ + id: item?.id ?? `${i}`, + name: item?.name ?? '', + vaccine: item?.name ?? '', + date: formatDate(item?.lastVaccinationDate) ?? '', - children: ( - => { - return [ - { - value: (i + 1).toString(), - }, - { - value: vaccination.date.toLocaleDateString('is-IS'), - }, - { - value: [ - vaccination.age?.years, - formatMessage(messages.years), - vaccination.age?.months, - formatMessage(messages.months), - ] - .filter(Boolean) - .join(' '), - }, - { - value: vaccination.name ?? '', - type: 'link', - url: vaccination.url ?? '', - }, - { - value: vaccination.comment, - }, - ] - }, - )} - footerText={item.comments ?? []} - /> - ), - status: item?.statusName ?? '', - tag: tagSelector(item?.status ?? ''), - })) ?? [] - } - /> + children: ( + => { + return [ + { + value: (i + 1).toString(), + }, + { + value: new Date(vaccination.date).toLocaleDateString( + 'is-IS', + ), + }, + { + value: [ + vaccination.age?.years, + vaccination.age?.years + ? formatMessage(messages.years) + : undefined, + vaccination.age?.months, + formatMessage(messages.months), + ] + .filter(Boolean) + .join(' '), + }, + { + value: vaccination.name ?? '', + type: 'link', + url: vaccination.url ?? '', + }, + { + value: vaccination.comment ?? '', + }, + ] + }, + )} + footerText={item.comments ?? []} + /> + ), + status: item?.statusName ?? '', + tag: tagSelector(item?.status), + })) ?? [] + } + /> + ) } diff --git a/libs/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx b/libs/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx index 5120ed6382eb..31f8b999cfb5 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx +++ b/libs/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx @@ -49,7 +49,11 @@ export const VaccinationsDetailTable = ({ )} - {rowData === undefined && } + {(rowData === undefined || rowData.length === 0) && ( + + + + )}
    {footerText.map((item, i) => ( diff --git a/libs/service-portal/health/src/screens/Vaccinations/wrapper/VaccinationsWrapper.tsx b/libs/service-portal/health/src/screens/Vaccinations/wrapper/VaccinationsWrapper.tsx deleted file mode 100644 index bed64757288f..000000000000 --- a/libs/service-portal/health/src/screens/Vaccinations/wrapper/VaccinationsWrapper.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { useLocale, useNamespaces } from '@island.is/localization' -import { Box, Hidden } from '@island.is/island-ui/core' -import { - HEALTH_DIRECTORATE_SLUG, - IntroHeader, - LinkButton, - TabNavigation, -} from '@island.is/service-portal/core' -import { messages as m } from '../../../lib/messages' -import { healthNavigation } from '../../../lib/navigation' -import { SECTION_GAP } from '../../../utils/constants' - -export const VaccinationsWrapper = ({ - children, - pathname, -}: { - children: React.ReactNode - pathname?: string -}) => { - useNamespaces('sp.health') - const { formatMessage } = useLocale() - - return ( - - - {/* Buttons */} - - - - - - - {/* Tabs content */} - - itm.name === m.vaccinations, - )?.children ?? [] - } - /> - - {children} - - ) -} diff --git a/libs/service-portal/health/src/utils/tagSelector.ts b/libs/service-portal/health/src/utils/tagSelector.ts index 026597b4d1d4..212a3f1c2d35 100644 --- a/libs/service-portal/health/src/utils/tagSelector.ts +++ b/libs/service-portal/health/src/utils/tagSelector.ts @@ -2,8 +2,9 @@ export const tagSelector = (str: string) => { const obj = { expired: 'blue', - vaccinated: 'mint', unvaccinated: 'red', + undetermined: 'purple', + valid: 'mint', } return (obj as any)?.[str] || 'blue' From 23f32b76d1c37d07cf0b7ee7dd4170102e2227cd Mon Sep 17 00:00:00 2001 From: andes-it Date: Mon, 2 Sep 2024 15:27:15 +0000 Subject: [PATCH 04/11] chore: nx format:write update dirty files --- infra/src/dsl/xroad.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/infra/src/dsl/xroad.ts b/infra/src/dsl/xroad.ts index abad4648fae0..262d90fed2c8 100644 --- a/infra/src/dsl/xroad.ts +++ b/infra/src/dsl/xroad.ts @@ -890,24 +890,23 @@ export const Frigg = new XroadConf({ }, }) - export const HealthDirectorateOrganDonation = new XroadConf({ env: { XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: { dev: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', - staging: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', + staging: + 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/organ-donation-v1', }, }, }) - export const HealthDirectorateVaccination = new XroadConf({ env: { XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: { dev: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', staging: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/vaccination-v1', - } + }, }, -}) \ No newline at end of file +}) From bd53c63c7c830afab0dd296a082a3785dcf27b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Tue, 3 Sep 2024 11:21:50 +0000 Subject: [PATCH 05/11] refactor: service update --- .../src/lib/health-directorate.service.ts | 19 ++----- .../src/lib/models/organ-donation.model.ts | 27 ++++------ .../clients/organ-donation/clientConfig.json | 54 ++++++++++++++----- .../organ-donation/organDonation.service.ts | 10 ++-- .../service-portal/health/src/lib/messages.ts | 12 +++++ .../OrganDonation/OrganDonation.graphql | 10 +++- .../screens/OrganDonation/OrganDonation.tsx | 21 ++++---- .../RegistrationForm.tsx | 12 +++-- .../health/src/utils/tagSelector.ts | 8 ++- 9 files changed, 106 insertions(+), 67 deletions(-) diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts index d46aa4c98332..07461b360f42 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts @@ -21,26 +21,17 @@ export class HealthDirectorateService { /* Organ Donation */ async getDonorStatus(auth: Auth, locale: Locale): Promise { + const lang: organLocale = locale === 'is' ? organLocale.Is : organLocale.En const data: OrganDonorDto | null = - await this.organDonationApi.getOrganDonation(auth) + await this.organDonationApi.getOrganDonation(auth, lang) // Fetch organ list to get all names in correct language to sort out the names of the organs the user has limitations for - const organLang: organLocale = - locale === 'is' ? organLocale.Is : organLocale.En - const limitations = await this.organDonationApi.getDonationExceptions( - auth, - organLang, - ) - // Filter organ list to get the names - const organList = - limitations?.filter((item) => data?.exceptions?.includes(item.id)) ?? [] - const organListNames: string[] = organList.map((item) => item.name) + const donorStatus: Donor = { isDonor: data?.isDonor ?? true, limitations: { hasLimitations: ((data?.exceptions?.length ?? 0) > 0 && data?.isDonor) ?? false, - organList: organListNames, - organIds: data?.exceptions, + limitedOrgansList: data?.exceptions, comment: data?.exceptionComment, }, } @@ -66,10 +57,8 @@ export class HealthDirectorateService { async updateDonorStatus(auth: Auth, input: DonorInput): Promise { return await this.organDonationApi.updateOrganDonation(auth, { - exceptionComment: '', isDonor: input.isDonor, exceptions: input.organLimitations ?? [], - registrationDate: new Date(), }) } diff --git a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts index 4db138c55000..fd47431acb9a 100644 --- a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts @@ -1,21 +1,23 @@ import { ObjectType, Field, InputType } from '@nestjs/graphql' +@ObjectType('HealthDirectorateOrganDonationOrgan') +export class Organ { + @Field() + id!: string + + @Field() + name!: string +} @ObjectType('HealthDirectorateOrganDonationLimitations') export class Limitations { @Field(() => Boolean) hasLimitations!: boolean - @Field(() => [String], { + @Field(() => [Organ], { nullable: true, description: 'List of organs NOT to donate', }) - organList?: string[] - - @Field(() => [String], { - nullable: true, - description: 'List of organ IDs NOT to donate', - }) - organIds?: string[] + limitedOrgansList?: Organ[] @Field({ nullable: true, @@ -33,15 +35,6 @@ export class Donor { limitations?: Limitations } -@ObjectType('HealthDirectorateOrganDonationOrgan') -export class Organ { - @Field({ nullable: true }) - id?: string - - @Field({ nullable: true }) - name?: string -} - @ObjectType('HealthDirectorateOrganDonation') export class OrganDonation { @Field(() => Donor, { nullable: true }) diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json b/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json index 79f3519e37e0..3f2b4e84bf09 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json @@ -5,7 +5,22 @@ "get": { "operationId": "MeDonorStatusController_getOrganDonorStatus", "description": "Get user's donation-exception donor status", - "parameters": [], + "parameters": [ + { + "name": "ip", + "required": false, + "in": "query", + "description": "The IP address of the user", + "schema": { "type": "string" } + }, + { + "name": "locale", + "required": false, + "in": "query", + "description": "The locale to use for the response", + "schema": { "$ref": "#/components/schemas/Locale" } + } + ], "responses": { "200": { "description": "", @@ -53,7 +68,15 @@ "post": { "operationId": "MeDonorStatusController_updateOrganDonorStatus", "description": "Update user's donation-exception donor status", - "parameters": [], + "parameters": [ + { + "name": "ip", + "required": false, + "in": "query", + "description": "The IP address of the user", + "schema": { "type": "string" } + } + ], "requestBody": { "required": true, "content": { @@ -164,7 +187,7 @@ }, "info": { "title": "Organ donor API", - "description": "The api provides access to information about individuals' donation-exception donation status.", + "description": "The api provides access to information about individuals' donation status.", "version": "1.0", "contact": {} }, @@ -187,11 +210,23 @@ } }, "schemas": { + "Locale": { "type": "string", "enum": ["en", "is"] }, + "OrganDto": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "name": { "type": "string" } + }, + "required": ["id", "name"] + }, "OrganDonorDto": { "type": "object", "properties": { "isDonor": { "type": "boolean" }, - "exceptions": { "type": "array", "items": { "type": "string" } }, + "exceptions": { + "type": "array", + "items": { "$ref": "#/components/schemas/OrganDto" } + }, "exceptionComment": { "type": "string" }, "registrationDate": { "format": "date-time", "type": "string" } }, @@ -225,18 +260,9 @@ "properties": { "isDonor": { "type": "boolean" }, "exceptions": { "type": "array", "items": { "type": "string" } }, - "exceptionComment": { "type": "string" } + "exceptionComment": { "type": "object" } }, "required": ["isDonor", "exceptions"] - }, - "Locale": { "type": "string", "enum": ["en", "is"] }, - "OrganDto": { - "type": "object", - "properties": { - "id": { "type": "string" }, - "name": { "type": "string" } - }, - "required": ["id", "name"] } } } diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts index 9a980f3de07f..ad2a9b7bceca 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts @@ -7,6 +7,7 @@ import { MeOrganDonorStatusApi, OrganDonorDto, OrganDto, + UpdateOrganDonorDto, } from './gen/fetch' import { LOGGER_PROVIDER } from '@island.is/logging' import type { Logger } from '@island.is/logging' @@ -24,9 +25,12 @@ export class HealthDirectorateOrganDonationService { return this.organDonationApi.withMiddleware(new AuthMiddleware(auth)) } - public async getOrganDonation(auth: Auth): Promise { + public async getOrganDonation( + auth: Auth, + input: Locale, + ): Promise { const organDonation = await this.organDonationApiWithAuth(auth) - .meDonorStatusControllerGetOrganDonorStatus() + .meDonorStatusControllerGetOrganDonorStatus({ locale: input }) .catch(handle404) if (!organDonation) { @@ -41,7 +45,7 @@ export class HealthDirectorateOrganDonationService { public async updateOrganDonation( auth: Auth, - input: OrganDonorDto, + input: UpdateOrganDonorDto, ): Promise { await this.organDonationApiWithAuth(auth) .meDonorStatusControllerUpdateOrganDonorStatus({ diff --git a/libs/service-portal/health/src/lib/messages.ts b/libs/service-portal/health/src/lib/messages.ts index 020d76cd887d..6ea14565057b 100644 --- a/libs/service-portal/health/src/lib/messages.ts +++ b/libs/service-portal/health/src/lib/messages.ts @@ -998,14 +998,26 @@ export const messages = defineMessages({ id: 'sp.health:i-am-organ-donor', defaultMessage: 'Ég er líffæragjafi.', }, + iAmOrganDonorText: { + id: 'sp.health:i-am-organ-donor-text', + defaultMessage: 'Öll líffærin mín má nota til ígræðslu.', + }, iAmOrganDonorWithExceptions: { id: 'sp.health:i-am-organ-donor-w-exceptions', defaultMessage: 'Ég heimila líffæragjöf, með takmörkunum.', }, + iAmOrganDonorWithExceptionsText: { + id: 'sp.health:i-am-organ-donor-w-exceptions-text', + defaultMessage: 'Öll líffæri má nota til ígræðslu fyrir utan:', + }, iAmNotOrganDonor: { id: 'sp.health:i-am-not-organ-donor', defaultMessage: 'Ég banna líffæragjöf.', }, + iAmNotOrganDonorText: { + id: 'sp.health:i-am-not-organ-donor-text', + defaultMessage: 'Engin líffæri má nota til ígræðslu', + }, organDonationRegistrationOptIn: { id: 'sp.health:organ-donation-registration-opt-in', defaultMessage: 'Við andlát mitt má nota líffæri mín til líffæragjafa.', diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql index 3960bab3f7cb..be4a07980ac3 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql @@ -4,7 +4,10 @@ query getDonorStatus($locale: String) { isDonor limitations { hasLimitations - organList + limitedOrgansList { + id + name + } comment } } @@ -17,7 +20,10 @@ query getOrgansList($locale: String) { isDonor limitations { hasLimitations - organIds + limitedOrgansList { + id + name + } } } organList { diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx index e9a5a6b97e72..749af473ad42 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx @@ -9,6 +9,7 @@ import { Button, Box, Text } from '@island.is/island-ui/core' import { HealthPaths } from '../../lib/paths' import { Problem } from '@island.is/react-spa/shared' import { useGetDonorStatusQuery } from './OrganDonation.generated' + const OrganDonation = () => { useNamespaces('sp.health') @@ -17,14 +18,16 @@ const OrganDonation = () => { fetchPolicy: 'no-cache', }) const donorStatus = data?.HealthDirectorateOrganDonation.donor - - //TODO: Move this to service - const exceptionText: string = donorStatus?.limitations?.hasLimitations - ? [ - donorStatus?.limitations.comment, - donorStatus?.limitations.organList?.join(', '), - ].join(':') + '.' ?? '' - : donorStatus?.limitations?.comment ?? '' + const cardText: string = donorStatus?.isDonor + ? donorStatus?.limitations?.hasLimitations + ? [ + formatMessage(m.iAmOrganDonorWithExceptionsText), + donorStatus?.limitations.limitedOrgansList + ?.map((organ) => organ.name) + .join(', '), + ].join(' ') + '.' ?? '' + : formatMessage(m.iAmOrganDonorText) + : formatMessage(m.iAmNotOrganDonorText) return ( @@ -66,7 +69,7 @@ const OrganDonation = () => { : formatMessage(m.iAmOrganDonor) : formatMessage(m.iAmNotOrganDonor) } - text={exceptionText} + text={cardText} cta={{ url: HealthPaths.HealthOrganDonationRegistration, label: formatMessage(m.changeTake), diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx index 4888d98d59c9..13c35d8822c1 100644 --- a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx @@ -41,9 +41,11 @@ export const Form2 = () => { const isDonor = data?.HealthDirectorateOrganDonation.donor?.isDonor const hasLimitations = data?.HealthDirectorateOrganDonation.donor?.limitations?.hasLimitations - const limitations = data?.HealthDirectorateOrganDonation.organList + const allLimitations = data?.HealthDirectorateOrganDonation.organList const selectedLimitations = - data?.HealthDirectorateOrganDonation.donor?.limitations?.organIds + data?.HealthDirectorateOrganDonation.donor?.limitations?.limitedOrgansList?.map( + (item) => item.id, + ) const donorStatus = isDonor ? hasLimitations ? OPT_IN_EXCEPTIONS @@ -134,11 +136,11 @@ export const Form2 = () => { checked={radioValue === OPT_IN_EXCEPTIONS} onChange={() => setRadioValue(OPT_IN_EXCEPTIONS)} /> - {limitations && - limitations.length > 0 && + {allLimitations && + allLimitations.length > 0 && radioValue === OPT_IN_EXCEPTIONS && ( )} diff --git a/libs/service-portal/health/src/utils/tagSelector.ts b/libs/service-portal/health/src/utils/tagSelector.ts index 212a3f1c2d35..475ae4ec5f6c 100644 --- a/libs/service-portal/health/src/utils/tagSelector.ts +++ b/libs/service-portal/health/src/utils/tagSelector.ts @@ -1,5 +1,9 @@ +import { isDefined } from 'class-validator' + // Tag selector for expandable, sorting table in vaccinations -export const tagSelector = (str: string) => { +export const tagSelector = (str?: string | null) => { + if (!isDefined(str)) return 'blue' + const obj = { expired: 'blue', unvaccinated: 'red', @@ -7,7 +11,7 @@ export const tagSelector = (str: string) => { valid: 'mint', } - return (obj as any)?.[str] || 'blue' + return (str && (obj as any)?.[str]) || 'blue' } // Valid = 'valid', From a86a193f91234530d6ed32ea271e25bd2e5e576a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Tue, 3 Sep 2024 12:51:30 +0000 Subject: [PATCH 06/11] feat: add loaders --- .../screens/OrganDonation/OrganDonation.tsx | 86 +++++++++---------- .../OrganDonationRegistration/Loader.tsx | 32 +++++++ .../RegistrationForm.tsx | 4 +- 3 files changed, 77 insertions(+), 45 deletions(-) create mode 100644 libs/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx index 749af473ad42..e0d1f836eddd 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx @@ -1,6 +1,7 @@ import { useLocale, useNamespaces } from '@island.is/localization' import { ActionCard, + CardLoader, IntroHeader, LinkResolver, } from '@island.is/service-portal/core' @@ -35,50 +36,49 @@ const OrganDonation = () => { title={formatMessage(m.organDonation)} intro={formatMessage(m.organDonationDescription)} /> + + + + + + {loading && ( + + + + )} {!error && !loading && donorStatus !== null && ( - <> - - - - - - - - {formatMessage(m.takeOnOrganDonation)} - - - - + + + {formatMessage(m.takeOnOrganDonation)} + + + )} {error && !loading && } {!error && !loading && data === null && ( diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx new file mode 100644 index 000000000000..fb45c474eb98 --- /dev/null +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx @@ -0,0 +1,32 @@ +import React from 'react' +import { Box, SkeletonLoader, Stack } from '@island.is/island-ui/core' +import { useIsMobile } from '@island.is/service-portal/core' + +interface Props { + amount?: number +} +export const Loader = ({ amount = 3 }: Props) => { + const { isMobile } = useIsMobile() + const length = isMobile ? 200 : 500 + const loaderItem = ( + +
    + +
    +
    + ) + return ( + + {Array.from({ length: amount }).map((_, i) => ( + {loaderItem} + ))} + + ) +} diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx index 13c35d8822c1..ce6e847ce7f7 100644 --- a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx @@ -24,6 +24,7 @@ import { useGetOrgansListQuery, useUpdateOrganDonationInfoMutation, } from '../OrganDonation/OrganDonation.generated' +import { Loader } from './Loader' const OPT_IN = 'opt-in' const OPT_IN_EXCEPTIONS = 'opt-in-exceptions' @@ -98,8 +99,7 @@ export const Form2 = () => { {formatMessage(messages.changeTake)} - {/* TODO: Better loading state */} - {loading && } + {loading && } {!loading && (
    From a3538ae4b391c4b35f6beab9fb32958201ae1f3d Mon Sep 17 00:00:00 2001 From: andes-it Date: Fri, 6 Sep 2024 09:10:13 +0000 Subject: [PATCH 07/11] chore: charts update dirty files --- charts/islandis/values.staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index f8b13440e49f..42424d8c73ed 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -353,7 +353,7 @@ api: XROAD_FINANCIAL_AID_BACKEND_PATH: 'IS-TEST/MUN/5502694739/samband-sveitarfelaga/financial-aid-backend' XROAD_FIREARM_LICENSE_PATH: 'IS/GOV/5309672079/Logreglan-Protected/island-api-v1' XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1' - XROAD_HEALTH_DIRECTORATE_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir' + XROAD_HEALTH_DIRECTORATE_PATH: 'IS-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir' XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1' XROAD_HEALTH_INSURANCE_ID: 'IS-TEST/GOV/4804080550/SJUKRA-Protected' XROAD_HEALTH_INSURANCE_MY_PAGES_PATH: 'IS-TEST/GOV/4804080550/SJUKRA-Protected/minarsidur' From bebd4d96a58f283fb5c960894d5fe8c7d89caee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Fri, 6 Sep 2024 10:42:10 +0000 Subject: [PATCH 08/11] fix: charts values for staging --- charts/islandis/values.staging.yaml | 4 ++-- infra/src/dsl/xroad.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index 42424d8c73ed..a0dfb5fe4ab9 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -352,9 +352,9 @@ api: XROAD_FINANCES_V2_PATH: 'IS-TEST/GOV/10021/FJS-Public/financeServicesFJS_v2' XROAD_FINANCIAL_AID_BACKEND_PATH: 'IS-TEST/MUN/5502694739/samband-sveitarfelaga/financial-aid-backend' XROAD_FIREARM_LICENSE_PATH: 'IS/GOV/5309672079/Logreglan-Protected/island-api-v1' - XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1' + XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: 'IS-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1' XROAD_HEALTH_DIRECTORATE_PATH: 'IS-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir' - XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1' + XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: 'IS-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1' XROAD_HEALTH_INSURANCE_ID: 'IS-TEST/GOV/4804080550/SJUKRA-Protected' XROAD_HEALTH_INSURANCE_MY_PAGES_PATH: 'IS-TEST/GOV/4804080550/SJUKRA-Protected/minarsidur' XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' diff --git a/infra/src/dsl/xroad.ts b/infra/src/dsl/xroad.ts index b07c0342b0ac..0dc7df744772 100644 --- a/infra/src/dsl/xroad.ts +++ b/infra/src/dsl/xroad.ts @@ -896,7 +896,7 @@ export const HealthDirectorateOrganDonation = new XroadConf({ XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH: { dev: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', staging: - 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', + 'IS-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/organ-donation-v1', prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/organ-donation-v1', }, }, @@ -906,7 +906,7 @@ export const HealthDirectorateVaccination = new XroadConf({ env: { XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH: { dev: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', - staging: 'IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', + staging: 'IS-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1', prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/vaccination-v1', }, }, From bef6497b0ef1d73e5146a984bded7ffbb6eb47ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Fri, 6 Sep 2024 11:12:58 +0000 Subject: [PATCH 09/11] fix: PR comments --- .../src/lib/health-directorate.resolver.ts | 6 +++--- .../src/lib/models/vaccinations.model.ts | 8 ++++---- .../organ-donation/organDonation.service.ts | 14 +++++--------- .../screens/OrganDonation/OrganDonation.graphql | 6 +++--- .../src/screens/OrganDonation/OrganDonation.tsx | 2 +- .../OrganDonationRegistration/RegistrationForm.tsx | 8 ++++---- .../src/screens/Vaccinations/Vaccinations.graphql | 2 +- .../screens/Vaccinations/VaccinationsWrapper.tsx | 2 +- 8 files changed, 22 insertions(+), 26 deletions(-) diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts index 1b9d1e907e86..123ede8ee342 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts @@ -32,7 +32,7 @@ export class HealthDirectorateResolver { /* Organ Donation */ @Query(() => OrganDonation, { - name: 'HealthDirectorateOrganDonation', + name: 'healthDirectorateOrganDonation', }) @Audit() async getDonorStatus( @@ -55,7 +55,7 @@ export class HealthDirectorateResolver { @Mutation(() => Boolean, { nullable: true, - name: 'HealthDirectorateOrganDonationUpdateDonorStatus', + name: 'healthDirectorateOrganDonationUpdateDonorStatus', }) @Audit() async updateDonorStatus( @@ -67,7 +67,7 @@ export class HealthDirectorateResolver { /* Vaccinations */ @Query(() => Vaccinations, { - name: 'HealthDirectorateVaccinations', + name: 'healthDirectorateVaccinations', }) @Audit() getVaccinations(@CurrentUser() user: User): Promise { diff --git a/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts b/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts index 54a747707083..6b1c9fc8115c 100644 --- a/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts @@ -1,5 +1,5 @@ import { DiseaseVaccinationDtoVaccinationStatusEnum } from '@island.is/clients/health-directorate' -import { Field, ObjectType, registerEnumType } from '@nestjs/graphql' +import { Field, Int, ObjectType, registerEnumType } from '@nestjs/graphql' registerEnumType(DiseaseVaccinationDtoVaccinationStatusEnum, { name: 'HealthDirectorateVaccinationsStatus', @@ -7,16 +7,16 @@ registerEnumType(DiseaseVaccinationDtoVaccinationStatusEnum, { @ObjectType('HealthDirectorateVaccinationsAge') export class Age { - @Field(() => Number, { nullable: true }) + @Field(() => Int, { nullable: true }) years?: number - @Field(() => Number, { nullable: true }) + @Field(() => Int, { nullable: true }) months?: number } @ObjectType('HealthDirectorateVaccinationsInfo') export class Info { - @Field(() => Number) + @Field(() => Int) id!: number @Field({ nullable: true }) diff --git a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts index ad2a9b7bceca..37ceeb3da061 100644 --- a/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts +++ b/libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts @@ -47,15 +47,11 @@ export class HealthDirectorateOrganDonationService { auth: Auth, input: UpdateOrganDonorDto, ): Promise { - await this.organDonationApiWithAuth(auth) - .meDonorStatusControllerUpdateOrganDonorStatus({ - updateOrganDonorDto: input, - }) - .catch((error: Error) => { - throw new Error( - `health-directorate-organ-donation-client: update organ donation status failed ${error.message}`, - ) - }) + await this.organDonationApiWithAuth( + auth, + ).meDonorStatusControllerUpdateOrganDonorStatus({ + updateOrganDonorDto: input, + }) } public async getDonationExceptions( diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql index be4a07980ac3..e445153ee094 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql @@ -1,5 +1,5 @@ query getDonorStatus($locale: String) { - HealthDirectorateOrganDonation(locale: $locale) { + healthDirectorateOrganDonation(locale: $locale) { donor { isDonor limitations { @@ -15,7 +15,7 @@ query getDonorStatus($locale: String) { } query getOrgansList($locale: String) { - HealthDirectorateOrganDonation(locale: $locale) { + healthDirectorateOrganDonation(locale: $locale) { donor { isDonor limitations { @@ -34,5 +34,5 @@ query getOrgansList($locale: String) { } mutation updateOrganDonationInfo($input: HealthDirectorateOrganDonorInput!) { - HealthDirectorateOrganDonationUpdateDonorStatus(input: $input) + healthDirectorateOrganDonationUpdateDonorStatus(input: $input) } diff --git a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx index e0d1f836eddd..275e6b0fd25b 100644 --- a/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx +++ b/libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx @@ -18,7 +18,7 @@ const OrganDonation = () => { const { data, loading, error } = useGetDonorStatusQuery({ fetchPolicy: 'no-cache', }) - const donorStatus = data?.HealthDirectorateOrganDonation.donor + const donorStatus = data?.healthDirectorateOrganDonation.donor const cardText: string = donorStatus?.isDonor ? donorStatus?.limitations?.hasLimitations ? [ diff --git a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx index ce6e847ce7f7..090f933a10b6 100644 --- a/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx +++ b/libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx @@ -39,12 +39,12 @@ export const Form2 = () => { variables: { locale: lang }, }) - const isDonor = data?.HealthDirectorateOrganDonation.donor?.isDonor + const isDonor = data?.healthDirectorateOrganDonation.donor?.isDonor const hasLimitations = - data?.HealthDirectorateOrganDonation.donor?.limitations?.hasLimitations - const allLimitations = data?.HealthDirectorateOrganDonation.organList + data?.healthDirectorateOrganDonation.donor?.limitations?.hasLimitations + const allLimitations = data?.healthDirectorateOrganDonation.organList const selectedLimitations = - data?.HealthDirectorateOrganDonation.donor?.limitations?.limitedOrgansList?.map( + data?.healthDirectorateOrganDonation.donor?.limitations?.limitedOrgansList?.map( (item) => item.id, ) const donorStatus = isDonor diff --git a/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql b/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql index f3612deae59a..18d2890814fb 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql +++ b/libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql @@ -1,5 +1,5 @@ query getVaccinations { - HealthDirectorateVaccinations { + healthDirectorateVaccinations { vaccinations { id name diff --git a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx index 9e2000e553b0..4cea2521d6c6 100644 --- a/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx +++ b/libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx @@ -18,7 +18,7 @@ export const VaccinationsWrapper = () => { const { formatMessage } = useLocale() const { data, loading, error } = useGetVaccinationsQuery() - const vaccinations = data?.HealthDirectorateVaccinations.vaccinations + const vaccinations = data?.healthDirectorateVaccinations.vaccinations const general = vaccinations?.filter((x) => x.isFeatured) const other = vaccinations?.filter((x) => !x.isFeatured) From 42ba86353879168f12b61f4ac7ce731616027ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Fri, 6 Sep 2024 11:45:30 +0000 Subject: [PATCH 10/11] fix: pr comments vol 2 --- .../src/lib/health-directorate.service.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts index 07461b360f42..4e40a778de6c 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.service.ts @@ -20,12 +20,15 @@ export class HealthDirectorateService { ) {} /* Organ Donation */ - async getDonorStatus(auth: Auth, locale: Locale): Promise { + async getDonorStatus(auth: Auth, locale: Locale): Promise { const lang: organLocale = locale === 'is' ? organLocale.Is : organLocale.En const data: OrganDonorDto | null = await this.organDonationApi.getOrganDonation(auth, lang) // Fetch organ list to get all names in correct language to sort out the names of the organs the user has limitations for + if (data === null) { + return null + } const donorStatus: Donor = { isDonor: data?.isDonor ?? true, limitations: { @@ -63,8 +66,11 @@ export class HealthDirectorateService { } /* Vaccinations */ - async getVaccinations(auth: Auth): Promise { + async getVaccinations(auth: Auth): Promise { const data = await this.vaccinationApi.getVaccinationDiseaseDetail(auth) + if (data === null) { + return null + } const vaccinations: Array = data?.map((item) => { return { @@ -87,7 +93,7 @@ export class HealthDirectorateService { url: vaccination.vaccineUrl, comment: vaccination.generalComment, rejected: vaccination.rejected, - } as Info + } }, ), } From c41ce06cfe35f4f833967a58d6a21518339227b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Fri, 6 Sep 2024 11:59:20 +0000 Subject: [PATCH 11/11] fix: null --- .../health-directorate/src/lib/health-directorate.resolver.ts | 2 +- .../health-directorate/src/lib/models/organ-donation.model.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts index 123ede8ee342..05f73ec5209d 100644 --- a/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts +++ b/libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts @@ -70,7 +70,7 @@ export class HealthDirectorateResolver { name: 'healthDirectorateVaccinations', }) @Audit() - getVaccinations(@CurrentUser() user: User): Promise { + getVaccinations(@CurrentUser() user: User): Promise { return this.api.getVaccinations(user) } } diff --git a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts index fd47431acb9a..8893f2149324 100644 --- a/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts +++ b/libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts @@ -38,7 +38,7 @@ export class Donor { @ObjectType('HealthDirectorateOrganDonation') export class OrganDonation { @Field(() => Donor, { nullable: true }) - donor?: Donor + donor?: Donor | null @Field(() => [Organ], { nullable: true }) organList?: Array