Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(service-portal): Health Directorate - Fixes #15728

Merged
merged 16 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import {
OfficialJournalOfIceland,
OfficialJournalOfIcelandApplication,
Frigg,
HealthDirectorateOrganDonation,
HealthDirectorateVaccination,
} from '../../../infra/src/dsl/xroad'

export const serviceSetup = (services: {
Expand Down Expand Up @@ -427,6 +429,8 @@ export const serviceSetup = (services: {
OfficialJournalOfIceland,
OfficialJournalOfIcelandApplication,
Frigg,
HealthDirectorateOrganDonation,
HealthDirectorateVaccination,
)
.files({ filename: 'islyklar.p12', env: 'ISLYKILL_CERT' })
.ingress({
Expand Down
2 changes: 2 additions & 0 deletions charts/islandis/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions charts/islandis/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions charts/islandis/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +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-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-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'
Expand Down
21 changes: 21 additions & 0 deletions infra/src/dsl/xroad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,3 +890,24 @@ 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-TEST/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-TEST/GOV/10015/EmbaettiLandlaeknis-Protected/vaccination-v1',
prod: 'IS/GOV/7101695009/EmbaettiLandlaeknis-Protected/vaccination-v1',
},
},
})
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -11,65 +18,59 @@ 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'

@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<DonorStatus> {
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<DonationException> {
return this.api.getDonationExceptions(user, locale)
): Promise<OrganDonation> {
const data = await this.api.getDonorStatus(user, locale)
return { donor: data, locale: locale }
}
@ResolveField('organList', () => [Organ], {
nullable: true,
})
async resolveOrganList(
@Parent() organDonation: OrganDonation,
@CurrentUser() user: User,
): Promise<Array<Organ>> {
return this.api.getDonationExceptions(user, organDonation.locale ?? 'is')
}

@Mutation(() => Boolean, {
nullable: true,
name: 'HealthDirectorateOrganDonationUpdateDonorStatus',
name: 'healthDirectorateOrganDonationUpdateDonorStatus',
})
@Audit()
async updateDonorStatus(
@Args('input') input: DonorStatusInput,
@Args('input') input: DonorInput,
@CurrentUser() user: User,
): Promise<void> {
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<Array<Vaccinations>> {
return this.api.getVaccinations(user, locale)
getVaccinations(@CurrentUser() user: User): Promise<Vaccinations> {
return this.api.getVaccinations(user)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -24,84 +20,78 @@ export class HealthDirectorateService {
) {}

/* Organ Donation */
async getDonorStatus(auth: Auth): Promise<DonorStatus> {
async getDonorStatus(auth: Auth, locale: Locale): Promise<Donor> {
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
disaerna marked this conversation as resolved.
Show resolved Hide resolved

const donorStatus: DonorStatus = {
isDonor: data?.isDonor || false,
registrationDate: data?.registrationDate,
exceptions: data?.exceptions,
exceptionComment: data?.exceptionComment,
const donorStatus: Donor = {
isDonor: data?.isDonor ?? true,
limitations: {
hasLimitations:
((data?.exceptions?.length ?? 0) > 0 && data?.isDonor) ?? false,
limitedOrgansList: data?.exceptions,
comment: data?.exceptionComment,
},
}
return donorStatus
}

async getDonationExceptions(
auth: Auth,
locale: Locale,
): Promise<DonationException> {
): Promise<Array<Organ>> {
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<Organ> =
data?.map((item) => {
return {
id: item.id,
name: item.name,
}
}) ?? []

return exceptions
return limitations
}

async updateDonorStatus(auth: Auth, input: DonorStatusInput): Promise<void> {
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<void> {
return await this.organDonationApi.updateOrganDonation(auth, {
isDonor: input.isDonor,
exceptions: input.organLimitations ?? [],
})
}

/* Vaccinations */
async getVaccinations(
auth: Auth,
locale: Locale,
): Promise<Array<Vaccinations>> {
const data = await this.vaccinationApi.getVaccinationDiseaseDetail(auth, {
locale,
})
const vaccinations: Array<Vaccinations> =
async getVaccinations(auth: Auth): Promise<Vaccinations> {
const data = await this.vaccinationApi.getVaccinationDiseaseDetail(auth)
const vaccinations: Array<Vaccination> =
data?.map((item) => {
return {
diseaseId: item.diseaseId,
diseaseName: item.diseaseName,
diseaseDescription: item.diseaseDescription,
vaccinationStatus: item.vaccinationStatus,
vaccinationsStatusName: item.vaccinationStatusName,
lastVaccinationDate: item.lastVaccinationDate,
vaccinations:
item.vaccinations?.map((vaccination: VaccinationDto) => {
id: item.diseaseId,
name: item.diseaseName,
description: item.diseaseDescription,
isFeatured: item.isFeatured,
status: item.vaccinationStatus,
statusName: item.vaccinationStatusName,
statusColor: item.vaccinationStatusColor,
lastVaccinationDate: item.lastVaccinationDate ?? null,
comments: item.comments,
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.vaccineCodeDescriptionShort,
date: vaccination.vaccinationDate,
age: vaccination.vaccinationAge,
url: vaccination.vaccineUrl,
comment: vaccination.generalComment,
rejected: vaccination.rejected,
}
}) ?? [],
} as Info
disaerna marked this conversation as resolved.
Show resolved Hide resolved
},
),
}
}) ?? []
return vaccinations
return { vaccinations }
disaerna marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading