From a3ee4db248aa975de947dfbdc133731894639b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 7 May 2024 10:22:15 +0000 Subject: [PATCH 01/30] First commit after rebasing main --- .../healthcare-work-permit.module.ts | 29 +++ .../healthcare-work-permit.service.ts | 95 +++++++++ .../src/lib/modules/templates/index.ts | 4 + .../national-registry-ees.module.ts | 17 ++ .../national-registry-ees.service.ts | 21 ++ .../src/lib/templateLoaders.ts | 2 + .../templates/healthcare-work-permit/.babelrc | 12 ++ .../healthcare-work-permit/.eslintrc.json | 18 ++ .../healthcare-work-permit/README.md | 7 + .../healthcare-work-permit/jest.config.ts | 12 ++ .../healthcare-work-permit/project.json | 32 +++ .../src/assets/Logo.tsx | 43 ++++ .../src/dataProviders/index.ts | 35 ++++ .../fields/SelectWorkPermitField/index.tsx | 96 +++++++++ .../src/fields/index.ts | 1 + .../forms/HealthcareWorkPermitForm/index.ts | 36 ++++ .../personalSection.ts | 76 +++++++ .../selectWorkPermitSection.ts | 25 +++ .../src/forms/Prerequisites/index.ts | 105 ++++++++++ .../healthcare-work-permit/src/index.ts | 14 ++ .../src/lib/HealthcareWorkPermitTemplate.ts | 192 ++++++++++++++++++ .../src/lib/constants.ts | 14 ++ .../src/lib/dataSchema.ts | 16 ++ .../src/lib/messages/application.ts | 38 ++++ .../src/lib/messages/confirmation.ts | 26 +++ .../src/lib/messages/error.ts | 21 ++ .../src/lib/messages/externalData.ts | 78 +++++++ .../src/lib/messages/index.ts | 7 + .../src/lib/messages/information.ts | 47 +++++ .../src/lib/messages/payment.ts | 35 ++++ .../src/lib/messages/personal.ts | 50 +++++ .../src/shared/constants.ts | 7 + .../src/shared/index.ts | 1 + .../src/utils/formatDate.ts | 4 + .../src/utils/getChargeItemCodes.ts | 25 +++ .../healthcare-work-permit/src/utils/index.ts | 2 + .../healthcare-work-permit/tsconfig.json | 20 ++ .../healthcare-work-permit/tsconfig.lib.json | 23 +++ .../healthcare-work-permit/tsconfig.spec.json | 20 ++ .../types/src/lib/ApplicationTypes.ts | 5 + .../types/src/lib/InstitutionMapper.ts | 4 + libs/feature-flags/src/lib/features.ts | 2 + tsconfig.base.json | 3 + 43 files changed, 1320 insertions(+) create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts create mode 100644 libs/application/templates/healthcare-work-permit/.babelrc create mode 100644 libs/application/templates/healthcare-work-permit/.eslintrc.json create mode 100644 libs/application/templates/healthcare-work-permit/README.md create mode 100644 libs/application/templates/healthcare-work-permit/jest.config.ts create mode 100644 libs/application/templates/healthcare-work-permit/project.json create mode 100644 libs/application/templates/healthcare-work-permit/src/assets/Logo.tsx create mode 100644 libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx create mode 100644 libs/application/templates/healthcare-work-permit/src/fields/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/constants.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/application.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/confirmation.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/shared/constants.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/shared/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/utils/formatDate.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/utils/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/tsconfig.json create mode 100644 libs/application/templates/healthcare-work-permit/tsconfig.lib.json create mode 100644 libs/application/templates/healthcare-work-permit/tsconfig.spec.json diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts new file mode 100644 index 000000000000..1a8f2103ba8f --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -0,0 +1,29 @@ +import { DynamicModule } from '@nestjs/common' +import { ConfigModule } from '@nestjs/config' +import { SharedTemplateAPIModule } from '../../shared' +import { BaseTemplateAPIModuleConfig } from '../../../types' +import { HealthcareWorkPermitService } from './healthcare-work-permit.service' +import { + HealthDirectorateClientModule, + HealthDirectorateClientConfig, +} from '@island.is/clients/health-directorate' +import { UniversityOfIcelandClientConfig, UniversityOfIcelandClientModule } from '@island.is/clients/university-of-iceland' + +export class HealthcareWorkPermitModule { + static register(baseConfig: BaseTemplateAPIModuleConfig): DynamicModule { + return { + module: HealthcareWorkPermitModule, + imports: [ + SharedTemplateAPIModule.register(baseConfig), + HealthDirectorateClientModule, + UniversityOfIcelandClientModule, + ConfigModule.forRoot({ + isGlobal: true, + load: [HealthDirectorateClientConfig, UniversityOfIcelandClientConfig], + }), + ], + providers: [HealthcareWorkPermitService], + exports: [HealthcareWorkPermitService], + } + } +} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts new file mode 100644 index 000000000000..2fdb7bcb7007 --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -0,0 +1,95 @@ +import { Injectable } from '@nestjs/common' +import { SharedTemplateApiService } from '../../shared' +import { TemplateApiModuleActionProps } from '../../../types' +import { BaseTemplateApiService } from '../../base-template-api.service' +import { + ApplicationTypes, +} from '@island.is/application/types' +import { + error as errorMsg, +} from '@island.is/application/templates/healthcare-work-permit' +import { + HealthDirectorateClientService, + HealthcareLicense, +} from '@island.is/clients/health-directorate' +import { + Transcripts, + UniversityOfIcelandService +} from '@island.is/clients/university-of-iceland' +import { TemplateApiError } from '@island.is/nest/problem' + +@Injectable() +export class HealthcareWorkPermitService extends BaseTemplateApiService { + constructor( + private readonly sharedTemplateAPIService: SharedTemplateApiService, + private readonly healthDirectorateClientService: HealthDirectorateClientService, + private readonly universityOfIcelandService: UniversityOfIcelandService + ) { + super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) + } + + async getMyHealthcareLicenses({ + auth, + }: TemplateApiModuleActionProps): Promise { + const result = + await this.healthDirectorateClientService.getMyHealthcareLicenses(auth) + + // TODO Error if the service does not respond/is down ? + + return result + } + + async getMyAcademicCareer({ + auth, + }: TemplateApiModuleActionProps): Promise { + const result = + await this.universityOfIcelandService.studentInfo(auth) + + if(!result){ + throw new TemplateApiError( + { + title: errorMsg.emptyCareerResponseTitle, + summary: errorMsg.emptyCareerResponseMessage, + }, + 400, + ) + } + + return result + } + + + async submitApplication({ + application, + auth, + }: TemplateApiModuleActionProps): Promise { // TODO Add type here! + + const { paymentUrl } = application.externalData.createCharge.data as { + paymentUrl: string + } + if (!paymentUrl) { + throw new Error( + 'Ekki er búið að staðfesta greiðslu, hinkraðu þar til greiðslan er staðfest.', + ) + } + + const isPayment: { fulfilled: boolean } | undefined = + await this.sharedTemplateAPIService.getPaymentStatus(auth, application.id) + + if (!isPayment?.fulfilled) { + throw new Error( + 'Ekki er búið að staðfesta greiðslu, hinkraðu þar til greiðslan er staðfest.', + ) + } + + // const answers = application.answers as HealthcareWorkPermitAnswers + + // const nationalRegistryData = application.externalData.nationalRegistry + // ?.data as NationalRegistryIndividual + + // Submit the application + + return {} + + } +} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/index.ts b/libs/application/template-api-modules/src/lib/modules/templates/index.ts index e6ffe2329d06..e2acbdebc788 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/index.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/index.ts @@ -73,6 +73,8 @@ import { } from './european-health-insurance-card' import { HealthcareLicenseCertificateModule } from './healthcare-license-certificate/healthcare-license-certificate.module' import { HealthcareLicenseCertificateService } from './healthcare-license-certificate/healthcare-license-certificate.service' +import { HealthcareWorkPermitModule } from './healthcare-work-permit/healthcare-work-permit.module' +import { HealthcareWorkPermitService } from './healthcare-work-permit/healthcare-work-permit.service' import { AnonymityInVehicleRegistryModule } from './transport-authority/anonymity-in-vehicle-registry/anonymity-in-vehicle-registry.module' import { AnonymityInVehicleRegistryService } from './transport-authority/anonymity-in-vehicle-registry/anonymity-in-vehicle-registry.service' import { ChangeCoOwnerOfVehicleModule } from './transport-authority/change-co-owner-of-vehicle/change-co-owner-of-vehicle.module' @@ -182,6 +184,7 @@ export const modules = [ CitizenshipModule, EnergyFundsModule, HealthcareLicenseCertificateModule, + HealthcareWorkPermitModule, SignatureListCreationModule, SignatureListSigningModule, TransferOfMachineOwnershipTemplateModule, @@ -250,6 +253,7 @@ export const services = [ CitizenshipService, EnergyFundsService, HealthcareLicenseCertificateService, + HealthcareWorkPermitService, SignatureListCreationService, SignatureListSigningService, TransferOfMachineOwnershipTemplateService, diff --git a/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts new file mode 100644 index 000000000000..ba06046ae417 --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts @@ -0,0 +1,17 @@ +import { DynamicModule } from '@nestjs/common' + +import { SharedTemplateAPIModule } from '../../shared' +import { NationalRegistryEESService } from './national-registry-ees.service' +import { BaseTemplateAPIModuleConfig } from '../../../types' + + +export class NationalRegistyEESModule { + static register(config: BaseTemplateAPIModuleConfig): DynamicModule { + return { + module: NationalRegistyEESModule, + imports: [SharedTemplateAPIModule.register(config)], + providers: [NationalRegistryEESService], + exports: [NationalRegistryEESService], + } + } +} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts new file mode 100644 index 000000000000..82f9a60a7d5c --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@nestjs/common' + +import { TemplateApiModuleActionProps } from '../../../types' +import { ApplicationTypes } from '@island.is/application/types' +import { BaseTemplateApiService } from '../../base-template-api.service' +import { NationalRegistryClientService } from '@island.is/clients/national-registry-v2' + +@Injectable() +export class NationalRegistryEESService extends BaseTemplateApiService { + constructor( + private readonly nationalRegistryClientService: NationalRegistryClientService, + ) { + super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) + } + + async getNationalRegistryWithEESValidation({ auth }: TemplateApiModuleActionProps) { + const person = this.nationalRegistryClientService.getIndividual(auth.nationalId) + + return person + } +} diff --git a/libs/application/template-loader/src/lib/templateLoaders.ts b/libs/application/template-loader/src/lib/templateLoaders.ts index 8f4bc8c96218..4ab7a01491f4 100644 --- a/libs/application/template-loader/src/lib/templateLoaders.ts +++ b/libs/application/template-loader/src/lib/templateLoaders.ts @@ -151,6 +151,8 @@ const templates: Record Promise> = { import('@island.is/application/templates/energy-funds'), [ApplicationTypes.HEALTHCARE_LICENSE_CERTIFICATE]: () => import('@island.is/application/templates/healthcare-license-certificate'), + [ApplicationTypes.HEALTHCARE_WORK_PERMIT]: () => + import('@island.is/application/templates/healthcare-work-permit'), [ApplicationTypes.PENSION_SUPPLEMENT]: () => import( '@island.is/application/templates/social-insurance-administration/pension-supplement' diff --git a/libs/application/templates/healthcare-work-permit/.babelrc b/libs/application/templates/healthcare-work-permit/.babelrc new file mode 100644 index 000000000000..1ea870ead410 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/application/templates/healthcare-work-permit/.eslintrc.json b/libs/application/templates/healthcare-work-permit/.eslintrc.json new file mode 100644 index 000000000000..772a43d27834 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nx/react", "../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/application/templates/healthcare-work-permit/README.md b/libs/application/templates/healthcare-work-permit/README.md new file mode 100644 index 000000000000..11ede5bfd48f --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/README.md @@ -0,0 +1,7 @@ +# application-templates-healthcare-work-permit + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test application-templates-healthcare-work-permit` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/application/templates/healthcare-work-permit/jest.config.ts b/libs/application/templates/healthcare-work-permit/jest.config.ts new file mode 100644 index 000000000000..90f25f8886fb --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/jest.config.ts @@ -0,0 +1,12 @@ +/* eslint-disable */ +export default { + displayName: 'application-templates-healthcare-work-permit', + preset: '../../../../jest.preset.js', + transform: { + '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', + '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: + '../../../../coverage/libs/application/templates/healthcare-work-permit', +} diff --git a/libs/application/templates/healthcare-work-permit/project.json b/libs/application/templates/healthcare-work-permit/project.json new file mode 100644 index 000000000000..094de40bcdab --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/project.json @@ -0,0 +1,32 @@ +{ + "name": "application-templates-healthcare-work-permit", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/application/templates/healthcare-work-permit/src", + "projectType": "library", + "tags": ["scope:application-system", "lib:application-system"], + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/application/templates/healthcare-work-permit/**/*.{ts,tsx,js,jsx}" + ] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/application/templates/healthcare-work-permit/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + } +} diff --git a/libs/application/templates/healthcare-work-permit/src/assets/Logo.tsx b/libs/application/templates/healthcare-work-permit/src/assets/Logo.tsx new file mode 100644 index 000000000000..8958fd81fac6 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/assets/Logo.tsx @@ -0,0 +1,43 @@ +import React, { FC } from 'react' + +export const Logo: FC> = () => ( + + + + + + + + + + + + + +) diff --git a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts new file mode 100644 index 000000000000..ba0db3575f2d --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts @@ -0,0 +1,35 @@ +import { + InstitutionNationalIds, + PaymentCatalogApi, + defineTemplateApi, + } from '@island.is/application/types' + import { ApiActions } from '../shared' + + export { + NationalRegistryUserApi, + UserProfileApi, + } from '@island.is/application/types' + + export const EmbaettiLandlaeknisPaymentCatalogApi = PaymentCatalogApi.configure( + { + params: { + organizationId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, + }, + externalDataId: 'payment', + }, + ) + + export const HealtcareLicenesApi = defineTemplateApi({ + action: ApiActions.getMyHealthcareLicenses, + externalDataId: 'healthcareLicenses', + }) + + export const UniversityOfIcelandApi = defineTemplateApi({ + action: ApiActions.getMyAcademicCareer, + externalDataId: 'universityOfIceland', + }) + + export const NationalRegistryApi = defineTemplateApi({ + action: ApiActions.getNationalRegistryWithEESValidation, + externalDataId: 'nationalRegistry', + }) \ No newline at end of file diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx new file mode 100644 index 000000000000..b078bf8db6b0 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx @@ -0,0 +1,96 @@ +import { FieldBaseProps } from '@island.is/application/types' +import { AlertMessage, Box, Text } from '@island.is/island-ui/core' +import { FC } from 'react' +import { useLocale } from '@island.is/localization' +import { + CheckboxController, + RadioController, +} from '@island.is/shared/form-fields' +import { information } from '../../lib/messages' +import { formatDate } from '../../utils' +import { Transcripts } from '@island.is/clients/university-of-iceland' + +interface Option { + value: string + label: React.ReactNode + disabled?: boolean +} + +export const SelectWorkPermitField: FC< + React.PropsWithChildren +> = (props) => { + console.log('MAAADE IT') + + const { lang, formatMessage } = useLocale() + const { application } = props + + const workPermitOptions = (workPermits: Transcripts) => { + const options: Option[] = [] + + for (const workPermit of workPermits.transcripts ?? []) { + const disabled = false + + options.push({ + value: `${workPermit.studyProgram}`, + label: ( + + + + {lang === 'is' + ? workPermit.studyProgram + : workPermit.studyProgram} + + {/* {license.isTemporary && ( + + {formatMessage( + information.labels.selectWorkPermit + .workPermitOptionSubLabelTemporary, + { + dateTo: formatDate(license.validTo || new Date()), + }, + )} + + )} */} + + {disabled && ( + + + + {formatMessage( + information.labels.selectWorkPermit + .restrictionAlertMessage, + )} + + + } + /> + + )} + + ), + disabled: disabled, + }) + } + return options + } + + return ( + + + + ) +} diff --git a/libs/application/templates/healthcare-work-permit/src/fields/index.ts b/libs/application/templates/healthcare-work-permit/src/fields/index.ts new file mode 100644 index 000000000000..cc0e010516db --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/fields/index.ts @@ -0,0 +1 @@ +export { SelectWorkPermitField } from './SelectWorkPermitField' \ No newline at end of file diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts new file mode 100644 index 000000000000..5e0093ac0c8f --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts @@ -0,0 +1,36 @@ +import { buildForm, buildSection } from '@island.is/application/core' +import { Form, FormModes } from '@island.is/application/types' +import { confirmation, externalData, payment } from '../../lib/messages' +import { PersonalSection } from './personalSection' +import { SelectWorkPermitSection } from './selectWorkPermitSection' +import { Logo } from '../../assets/Logo' +import { buildFormPaymentChargeOverviewSection } from '@island.is/application/ui-forms' +import { getChargeItemCodesAndExtraLabel } from '../../utils' + + +export const HealthcareWorkPermitForm: Form = buildForm({ + id: 'HealthcareWorkPermitForm', + title: '', + logo: Logo, + mode: FormModes.DRAFT, + renderLastScreenButton: true, + renderLastScreenBackButton: true, + children: [ + buildSection({ + id: 'externalData', + title: externalData.dataProvider.sectionTitle, + children: [], + }), + PersonalSection, + SelectWorkPermitSection, + buildFormPaymentChargeOverviewSection({ + sectionTitle: payment.general.sectionTitle, + getSelectedChargeItems: getChargeItemCodesAndExtraLabel, + }), + buildSection({ + id: 'confirmation', + title: confirmation.general.sectionTitle, + children: [], + }), + ], +}) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts new file mode 100644 index 000000000000..9d20b7f9ac67 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts @@ -0,0 +1,76 @@ +import { + buildDescriptionField, + buildMultiField, + buildPhoneField, + buildSection, + buildTextField, +} from '@island.is/application/core' +import { personal } from '../../lib/messages' +import { Application } from '@island.is/api/schema' +import { formatDate } from '../../utils' + +export const PersonalSection = buildSection({ + id: 'personal', + title: personal.general.sectionTitle, + children: [ + buildMultiField({ + id: 'userInformation', + title: personal.labels.userInformation.pageTitle, + children: [ + buildDescriptionField({ + id: 'userInformation.title', + title: personal.labels.userInformation.title, + titleVariant: 'h5', + }), + buildTextField({ + id: 'userInformation.nationalId', + title: personal.labels.userInformation.nationalId, + backgroundColor: 'white', + width: 'half', + readOnly: true, + format: '######-####', + defaultValue: (application: Application) => + application.externalData?.nationalRegistry?.data?.nationalId, + }), + buildTextField({ + id: 'userInformation.name', + title: personal.labels.userInformation.name, + backgroundColor: 'white', + width: 'half', + readOnly: true, + defaultValue: (application: Application) => + application.externalData?.nationalRegistry?.data?.fullName, + }), + buildTextField({ + id: 'userInformation.birthDate', + title: personal.labels.userInformation.birthDate, + backgroundColor: 'white', + width: 'half', + readOnly: true, + defaultValue: (application: Application) => + formatDate( + application.externalData?.nationalRegistry?.data?.birthDate, + ), + }), + buildTextField({ + id: 'userInformation.email', + title: personal.labels.userInformation.email, + width: 'half', + variant: 'email', + required: true, + defaultValue: (application: Application) => + application.externalData?.userProfile?.data?.email, + }), + buildPhoneField({ + id: 'userInformation.phone', + title: personal.labels.userInformation.phone, + width: 'half', + backgroundColor: 'blue', + required: true, + defaultValue: (application: Application) => + application.externalData?.userProfile?.data?.mobilePhoneNumber, + }), + ], + }), + ], +}) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts new file mode 100644 index 000000000000..ae7212d1ad9b --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts @@ -0,0 +1,25 @@ +import { + buildCustomField, + buildMultiField, + buildSection, +} from '@island.is/application/core' +import { information } from '../../lib/messages' + +export const SelectWorkPermitSection = buildSection({ + id: 'selectWorkPermitSection', + title: information.general.sectionTitle, + children: [ + buildMultiField({ + id: 'selectWorkPermit.multiField', + title: information.labels.selectWorkPermit.pageTitle, + description: information.labels.selectWorkPermit.description, + children: [ + buildCustomField({ + id: 'selectWorkPermit', + component: 'SelectWorkPermitField', + title: '', + }), + ], + }), + ], +}) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts new file mode 100644 index 000000000000..1c58bc5bdd4e --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -0,0 +1,105 @@ +import { + buildDataProviderItem, + buildExternalDataProvider, + buildForm, + buildSection, + buildSubmitField, + coreMessages, + } from '@island.is/application/core' + import { DefaultEvents, Form, FormModes } from '@island.is/application/types' + import { + confirmation, + externalData, + information, + payment, + personal, + } from '../../lib/messages' + import { + EmbaettiLandlaeknisPaymentCatalogApi, + HealtcareLicenesApi, + UserProfileApi, + UniversityOfIcelandApi, + NationalRegistryApi, + } from '../../dataProviders' + + export const Prerequisites: Form = buildForm({ + id: 'PrerequisitesForm', + title: '', + mode: FormModes.NOT_STARTED, + renderLastScreenButton: true, + renderLastScreenBackButton: true, + children: [ + buildSection({ + id: 'externalData', + title: externalData.dataProvider.sectionTitle, + children: [ + buildExternalDataProvider({ + title: externalData.dataProvider.pageTitle, + id: 'approveExternalData', + subTitle: externalData.dataProvider.subTitle, + checkboxLabel: externalData.dataProvider.checkboxLabel, + submitField: buildSubmitField({ + id: 'submit', + placement: 'footer', + title: '', + refetchApplicationAfterSubmit: true, + actions: [ + { + event: DefaultEvents.SUBMIT, + name: coreMessages.buttonNext, + type: 'primary', + }, + ], + }), + dataProviders: [ + buildDataProviderItem({ + provider: NationalRegistryApi, + title: externalData.nationalRegistry.title, + subTitle: externalData.nationalRegistry.subTitle, + }), + buildDataProviderItem({ + provider: UserProfileApi, + title: externalData.userProfile.title, + subTitle: externalData.userProfile.subTitle, + }), + buildDataProviderItem({ + provider: HealtcareLicenesApi, + title: externalData.healtcareLicenses.title, + subTitle: externalData.healtcareLicenses.subTitle, + }), + buildDataProviderItem({ + provider: UniversityOfIcelandApi, + title: externalData.universityOfIceland.title, + subTitle: externalData.universityOfIceland.subTitle, + }), + buildDataProviderItem({ + provider: EmbaettiLandlaeknisPaymentCatalogApi, + title: '', + }), + ], + }), + ], + }), + buildSection({ + id: 'personal', + title: personal.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'selectLicenseSection', + title: information.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'payment', + title: payment.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'confirmation', + title: confirmation.general.sectionTitle, + children: [], + }), + ], + }) + \ No newline at end of file diff --git a/libs/application/templates/healthcare-work-permit/src/index.ts b/libs/application/templates/healthcare-work-permit/src/index.ts new file mode 100644 index 000000000000..245438da20e4 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/index.ts @@ -0,0 +1,14 @@ +import template from './lib/HealthcareWorkPermitTemplate' +import { HealthcareWorkPermit } from './lib/dataSchema' + +export const getFields = () => import('./fields/') +export const getDataProviders = () => import('./dataProviders/') + +export type HealthcareWorkPermitAnswers = HealthcareWorkPermit + +export * from './utils' + +export * from './lib/messages/externalData' +export * from './lib/messages/error' + +export default template diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts new file mode 100644 index 000000000000..9515e9ce4838 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -0,0 +1,192 @@ +import { + ApplicationConfigurations, + ApplicationTemplate, + ApplicationTypes, + ApplicationContext, + ApplicationRole, + ApplicationStateSchema, + Application, + DefaultEvents, + defineTemplateApi, + InstitutionNationalIds, +} from '@island.is/application/types' +import { + EphemeralStateLifeCycle, + coreHistoryMessages, + corePendingActionMessages, + pruneAfterDays, +} from '@island.is/application/core' +import { Events, States, Roles } from './constants' +import { application as applicationMessage } from './messages' +import { Features } from '@island.is/feature-flags' +import { ApiActions } from '../shared' +import { + UserProfileApi, + EmbaettiLandlaeknisPaymentCatalogApi, + HealtcareLicenesApi, + NationalRegistryApi, + UniversityOfIcelandApi, +} from '../dataProviders' +import { buildPaymentState } from '@island.is/application/utils' +import { HealthcareWorkPermitSchema } from './dataSchema' + +const template: ApplicationTemplate< + ApplicationContext, + ApplicationStateSchema, + Events +> = { + type: ApplicationTypes.HEALTHCARE_WORK_PERMIT, + name: applicationMessage.name, + institution: applicationMessage.institutionName, + translationNamespaces: [ + ApplicationConfigurations.HealthcareWorkPermit.translation, + ], + dataSchema: HealthcareWorkPermitSchema, + featureFlag: Features.healthcareLicenseCertificate, + stateMachineConfig: { + initial: States.PREREQUISITES, + states: { + [States.PREREQUISITES]: { + meta: { + name: 'Gagnaöflun', + status: 'draft', + actionCard: { + tag: { + label: applicationMessage.actionCardPrerequisites, + variant: 'blue', + }, + historyLogs: [ + { + logMessage: coreHistoryMessages.applicationStarted, + onEvent: DefaultEvents.SUBMIT, + }, + ], + }, + lifecycle: EphemeralStateLifeCycle, + roles: [ + { + id: Roles.APPLICANT, + formLoader: () => + import('../forms/Prerequisites').then((module) => + Promise.resolve(module.Prerequisites), + ), + actions: [ + { + event: DefaultEvents.SUBMIT, + name: 'Staðfesta', + type: 'primary', + }, + ], + write: 'all', + delete: true, + api: [ + NationalRegistryApi, + UserProfileApi, + EmbaettiLandlaeknisPaymentCatalogApi, + HealtcareLicenesApi, + UniversityOfIcelandApi + ], + }, + ], + }, + on: { + [DefaultEvents.SUBMIT]: { target: States.DRAFT }, + }, + }, + [States.DRAFT]: { + meta: { + name: 'Umsókn vegna starfsleyfis', + status: 'draft', + actionCard: { + tag: { + label: applicationMessage.actionCardDraft, + variant: 'blue', + }, + historyLogs: [ + { + logMessage: coreHistoryMessages.paymentStarted, + onEvent: DefaultEvents.SUBMIT, + }, + ], + }, + lifecycle: { + shouldBeListed: true, + shouldBePruned: true, + whenToPrune: 600 * 1000 * 6, // 60 minutes + }, + roles: [ + { + id: Roles.APPLICANT, + formLoader: () => + import('../forms/HealthcareWorkPermitForm').then( + (module) => + Promise.resolve(module.HealthcareWorkPermitForm), + ), + write: 'all', + delete: true, + }, + ], + }, + on: { + [DefaultEvents.SUBMIT]: { target: States.PAYMENT }, + }, + }, + [States.PAYMENT]: buildPaymentState({ + organizationId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, + chargeItemCodes: [], + submitTarget: States.COMPLETED, + lifecycle: { + shouldBeListed: true, + shouldBePruned: true, + whenToPrune: 600 * 1000 * 6, // 60 minutes + }, + onExit: [ + defineTemplateApi({ + action: ApiActions.submitApplication, + triggerEvent: DefaultEvents.SUBMIT, + }), + ], + }), + [States.COMPLETED]: { + meta: { + name: 'Completed', + status: 'completed', + lifecycle: pruneAfterDays(3 * 30), + actionCard: { + tag: { + label: applicationMessage.actionCardDone, + variant: 'blueberry', + }, + pendingAction: { + title: corePendingActionMessages.applicationReceivedTitle, + displayStatus: 'success', + }, + }, + roles: [ + { + id: Roles.APPLICANT, + formLoader: () => + import('../forms/HealthcareWorkPermitForm').then((val) => + Promise.resolve(val.HealthcareWorkPermitForm), + ), + read: 'all', + }, + ], + }, + }, + + }, + }, + mapUserToRole( + id: string, + application: Application, + ): ApplicationRole | undefined { + if (id === application.applicant) { + return Roles.APPLICANT + } + return undefined + }, +} + +export default template + diff --git a/libs/application/templates/healthcare-work-permit/src/lib/constants.ts b/libs/application/templates/healthcare-work-permit/src/lib/constants.ts new file mode 100644 index 000000000000..6eb8df54aadb --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/constants.ts @@ -0,0 +1,14 @@ +import { DefaultEvents } from '@island.is/application/types' + +export type Events = { type: DefaultEvents.SUBMIT | DefaultEvents.ABORT } + +export enum States { + PREREQUISITES = 'prerequisites', + DRAFT = 'draft', + PAYMENT = 'payment', + COMPLETED = 'completed', +} + +export enum Roles { + APPLICANT = 'applicant', +} diff --git a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts new file mode 100644 index 000000000000..0afa6aed26c4 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts @@ -0,0 +1,16 @@ +import { z } from 'zod' + +const UserInformationSchema = z.object({ + email: z.string().min(1), + phone: z.string().min(1), +}) + + +export const HealthcareWorkPermitSchema = z.object({ + approveExternalData: z.boolean().refine((v) => v), + userInformation: UserInformationSchema, +}) + +export type HealthcareWorkPermit = z.TypeOf< + typeof HealthcareWorkPermitSchema +> diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/application.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/application.ts new file mode 100644 index 000000000000..b6da2f53ef01 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/application.ts @@ -0,0 +1,38 @@ +import { defineMessages } from 'react-intl' + +export const application = defineMessages({ + name: { + id: 'hwp.application:name', + defaultMessage: 'Umsókn um starfsleyfi', + description: `Application's name`, + }, + institutionName: { + id: 'hwp.application:institution', + defaultMessage: 'Embætti Landlæknis', + description: `Institution's name`, + }, + actionCardPrerequisites: { + id: 'hwp.application:actionCardPrerequisites', + defaultMessage: 'Gagnaöflun', + description: + 'Description of application state/status when the application is in prerequisites', + }, + actionCardDraft: { + id: 'hwp.application:actionCardDraft', + defaultMessage: 'Í vinnslu', + description: + 'Description of application state/status when the application is in progress', + }, + actionCardPayment: { + id: 'hwp.application:actionCardPayment', + defaultMessage: 'Greiðslu vantar', + description: + 'Description of application state/status when payment is pending', + }, + actionCardDone: { + id: 'hwp.application:actionCardDone', + defaultMessage: 'Afgreidd', + description: + 'Description of application state/status when application is processed', + }, +}) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/confirmation.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/confirmation.ts new file mode 100644 index 000000000000..56b79178f4a2 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/confirmation.ts @@ -0,0 +1,26 @@ +import { defineMessages } from 'react-intl' + +export const confirmation = { + general: defineMessages({ + sectionTitle: { + id: 'hwp.application:confirmation.general.sectionTitle', + defaultMessage: 'Staðfesting', + description: 'Confirmation section title', + }, + pageTitle: { + id: 'hwp.application:confirmation.general.pageTitle', + defaultMessage: 'Staðfesting', + description: 'Confirmation page title', + }, + alertTitle: { + id: 'hwp.application:confirmation.general.alertTitle', + defaultMessage: 'Vottorð vegna starfsleyfis hefur verið útbúið / sent', + description: 'Confirmation alert title', + }, + alertMessage: { + id: 'hwp.application:confirmation.general.alertMessage', + defaultMessage: 'Þú getur nálgast vottorðið á mínum síðum á island.is', + description: 'Confirmation alert message', + }, + }), +} diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts new file mode 100644 index 000000000000..b94b17c47ab0 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -0,0 +1,21 @@ +import { defineMessages } from 'react-intl' + +export const error = defineMessages({ + errorDataProvider: { + id: 'hwp.application:error.dataProvider', + defaultMessage: 'Reyndu aftur síðar', + description: 'Unhandled error in data provider', + }, + emptyCareerResponseTitle: { + id: 'hlc.application:error.emptyHealthLicenseListTitle', + defaultMessage: + 'Samkvæmt þjónustu Háskóla Íslands ertu ekki með brautskráningu á skrá', + description: 'Empty career response', + }, + emptyCareerResponseMessage: { + id: 'hlc.application:error.emptyHealthLicenseListMessage', + defaultMessage: + 'Samkvæmt þjónustu Háskóla Íslands ertu ekki með brautskráningu á skrá', + description: 'Empty career response', + }, +}) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts new file mode 100644 index 000000000000..3bcde6646530 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts @@ -0,0 +1,78 @@ +import { defineMessages } from 'react-intl' + +export const externalData = { + dataProvider: defineMessages({ + sectionTitle: { + id: 'hwp.application:externalData.dataProvider.sectionTitle', + defaultMessage: 'Gagnaöflun', + description: 'External data section title', + }, + pageTitle: { + id: 'hwp.application:externalData.dataProvider.pageTitle', + defaultMessage: 'Gagnaöflun', + description: 'External data page title', + }, + subTitle: { + id: 'hwp.application:externalData.dataProvider.subTitle', + defaultMessage: 'Eftirfarandi gögn verða sótt rafrænt með þínu samþykki.', + description: 'External data sub title', + }, + checkboxLabel: { + id: 'hwp.application:externalData.dataProvider.checkboxLabel', + defaultMessage: 'Ég skil að ofangreindra upplýsinga verður aflað', + description: 'External data checkbox label', + }, + }), + nationalRegistry: defineMessages({ + title: { + id: 'hwp.application:externalData.nationalRegistry.title', + defaultMessage: 'Upplýsingar úr Þjóðskrá', + description: 'National Registry title', + }, + subTitle: { + id: 'hwp.application:externalData.nationalRegistry.subTitle', + defaultMessage: + 'Til þess að auðvelda fyrir sækjum við persónuupplýsingar úr Þjóðskrá til þess að fylla út umsóknina.', + description: 'National Registry sub title', + }, + }), + userProfile: defineMessages({ + title: { + id: 'hwp.application:externalData.userProfile.title', + defaultMessage: 'Netfang og símanúmer úr þínum stillingum', + description: 'User profile title', + }, + subTitle: { + id: 'hwp.application:externalData.userProfile.subTitle', + defaultMessage: + 'Til þess að auðvelda umsóknarferlið er gott að hafa fyllt út netfang og símanúmer á mínum síðum', + description: 'User profile sub title', + }, + }), + healtcareLicenses: defineMessages({ + title: { + id: 'hwp.application:externalData.healtcaseLicenses.title', + defaultMessage: 'Starfsleyfi hjá Embætti Landlæknis', + description: 'Healthcare licenses title', + }, + subTitle: { + id: 'hwp.application:externalData.healtcaseLicenses.subTitle', + defaultMessage: + 'Upplýsingar úr starfsleyfaskrá um þín starfsleyfi hjá Embætti Landlæknis.', + description: 'Healthcare licenses sub title', + }, + }), + universityOfIceland: defineMessages({ + title: { + id: 'hwp.application:externalData.universityOfIceland.title', + defaultMessage: 'Námsferill hjá Háskóla Íslands', + description: 'Academic career title', + }, + subTitle: { + id: 'hwp.application:externalData.universityOfIceland.subTitle', + defaultMessage: + 'Upplýsingar um brautskráningar frá Háskóla Íslands verða sóttar', + description: 'Healthcare licenses sub title', + }, + }), +} diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/index.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/index.ts new file mode 100644 index 000000000000..c0ec8cee0221 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/index.ts @@ -0,0 +1,7 @@ +export * from './application' +export * from './confirmation' +export * from './error' +export * from './externalData' +export * from './information' +export * from './payment' +export * from './personal' diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts new file mode 100644 index 000000000000..7e2abbad4799 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts @@ -0,0 +1,47 @@ +import { defineMessages } from 'react-intl' + +export const information = { + general: defineMessages({ + sectionTitle: { + id: 'hwp.application:information.general.sectionTitle', + defaultMessage: 'Starfsleyfi', + description: 'Select work permit section title', + }, + }), + labels: { + selectWorkPermit: defineMessages({ + pageTitle: { + id: 'hwp.application:information.labels.selectWorkPermit.pageTitle', + defaultMessage: 'Brautskráninganar þínar', + description: 'Select work permit page', + }, + description: { + id: 'hwp.application:information.labels.selectWorkPermit.description', + defaultMessage: + 'Hér má sjá lista yfir þau starfsleyfi sem eru skráð á þig í starfsleyfaskrá embættis landlæknis sem uppfærð er daglega.', + description: 'Select work permit description', + }, + workPermitOptionSubLabelSpeciality: { + id: 'hwp.application:information.labels.selectWorkPermit.workPermitOptionSubLabelSpeciality', + defaultMessage: 'Sérgrein: {specialityList}', + description: 'Select work permit option sub label speciality', + }, + workPermitOptionSubLabelTemporary: { + id: 'hwp.application:information.labels.selectWorkPermit.workPermitOptionSubLabelTemporary', + defaultMessage: 'Tímabundið starfsleyfi - Gildir til: {dateTo}', + description: 'Select work permit option sub label temporary', + }, + restrictionAlertTitle: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionAlertTitle', + defaultMessage: 'Takmörkun á starfsleyfi', + description: 'Select work permit restriction alert title', + }, + restrictionAlertMessage: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionAlertMessage', + defaultMessage: + 'Vinsamlega sendið póst á starfsleyfi@landlaeknir.is ef frekari upplýsingar óskast', + description: 'Select work permit restriction alert message', + }, + }), + }, +} diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts new file mode 100644 index 000000000000..9b6d48dd2766 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts @@ -0,0 +1,35 @@ +import { defineMessages } from 'react-intl' + +export const payment = { + general: defineMessages({ + sectionTitle: { + id: 'hwp.application:payment.general.sectionTitle', + defaultMessage: 'Greiðsla', + description: 'Payment section title', + }, + pageTitle: { + id: 'hwp.application:payment.general.pageTitle', + defaultMessage: 'Greiðsla', + description: 'Payment page title', + }, + }), + paymentChargeOverview: defineMessages({ + forPayment: { + id: 'hwp.application:payment.paymentChargeOverview.forPayment', + defaultMessage: 'Til greiðslu', + description: 'For payment label', + }, + total: { + id: 'hwp.application:payment.paymentChargeOverview.total', + defaultMessage: 'Samtals', + description: 'Total amount label', + }, + }), + confirmation: defineMessages({ + confirm: { + id: 'hwp.application:payment.confirmation.confirm', + defaultMessage: 'Áfram', + description: 'Confirm label', + }, + }), +} diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts new file mode 100644 index 000000000000..4cc68bce0075 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts @@ -0,0 +1,50 @@ +import { defineMessages } from 'react-intl' + +export const personal = { + general: defineMessages({ + sectionTitle: { + id: 'hwp.application:personal.general.sectionTitle', + defaultMessage: 'Persónuupplýsingar', + description: 'Personal section title', + }, + }), + labels: { + userInformation: defineMessages({ + pageTitle: { + id: 'hwp.application:personal.labels.userInformation.pageTitle', + defaultMessage: 'Persónuupplýsingar', + description: 'User information page title', + }, + title: { + id: 'hwp.application:personal.labels.userInformation.title', + defaultMessage: 'Umsækjandi', + description: 'User information title', + }, + nationalId: { + id: 'hwp.application:personal.labels.userInformation.nationalId', + defaultMessage: 'Kennitala', + description: 'User information national ID label', + }, + name: { + id: 'hwp.application:personal.labels.userInformation.name', + defaultMessage: 'Nafn', + description: 'User information name label', + }, + birthDate: { + id: 'hwp.application:personal.labels.userInformation.birthDate', + defaultMessage: 'Fæðingardagur', + description: 'User information birth date label', + }, + email: { + id: 'hwp.application:personal.labels.userInformation.email', + defaultMessage: 'Netfang', + description: 'User information email label', + }, + phone: { + id: 'hwp.application:personal.labels.userInformation.phone', + defaultMessage: 'Símanúmer', + description: 'User information phone number label', + }, + }), + }, +} diff --git a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts new file mode 100644 index 000000000000..2c96b067a7c8 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts @@ -0,0 +1,7 @@ +export enum ApiActions { + submitApplication = 'submitApplication', + getMyHealthcareLicenses = 'getMyHealthcareLicenses', + getMyAcademicCareer = 'getMyAcademicCareer', + getNationalRegistryWithEESValidation = 'getNationalRegistryWithEESValidation' + } + \ No newline at end of file diff --git a/libs/application/templates/healthcare-work-permit/src/shared/index.ts b/libs/application/templates/healthcare-work-permit/src/shared/index.ts new file mode 100644 index 000000000000..f87cf0102a14 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/shared/index.ts @@ -0,0 +1 @@ +export * from './constants' diff --git a/libs/application/templates/healthcare-work-permit/src/utils/formatDate.ts b/libs/application/templates/healthcare-work-permit/src/utils/formatDate.ts new file mode 100644 index 000000000000..b491a85d357f --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/utils/formatDate.ts @@ -0,0 +1,4 @@ +import format from 'date-fns/format' + +export const formatDate = (date: Date): string => + date ? format(new Date(date), 'dd.MM.yyyy') : '' diff --git a/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts b/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts new file mode 100644 index 000000000000..b4961f4f0b78 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts @@ -0,0 +1,25 @@ +import { ChargeItemCode } from '@island.is/shared/constants' +import { Application, StaticText } from '@island.is/application/types' +import { HealthcareWorkPermit } from '../lib/dataSchema' +import { HealthcareLicense } from '@island.is/clients/health-directorate' + +export const getChargeItemCodes = (application: Application): Array => { + return getChargeItemCodesAndExtraLabel(application).map( + (x) => x.chargeItemCode, + ) +} + +export const getChargeItemCodesAndExtraLabel = ( + application: Application, +): Array<{ + chargeItemCode: string + extraLabel?: StaticText +}> => { + const answers = application.answers as HealthcareWorkPermit + + const licenses = application?.externalData?.healthcareLicenses + ?.data as HealthcareLicense[] + + + return [] +} diff --git a/libs/application/templates/healthcare-work-permit/src/utils/index.ts b/libs/application/templates/healthcare-work-permit/src/utils/index.ts new file mode 100644 index 000000000000..d4b56256252c --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from './getChargeItemCodes' +export * from './formatDate' diff --git a/libs/application/templates/healthcare-work-permit/tsconfig.json b/libs/application/templates/healthcare-work-permit/tsconfig.json new file mode 100644 index 000000000000..c88d07daddd5 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": false, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "extends": "../../../../tsconfig.base.json" +} diff --git a/libs/application/templates/healthcare-work-permit/tsconfig.lib.json b/libs/application/templates/healthcare-work-permit/tsconfig.lib.json new file mode 100644 index 000000000000..9668c0996130 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/tsconfig.lib.json @@ -0,0 +1,23 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../../../node_modules/@nx/react/typings/cssmodule.d.ts", + "../../../../node_modules/@nx/react/typings/image.d.ts" + ], + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx", + "jest.config.ts" + ], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/libs/application/templates/healthcare-work-permit/tsconfig.spec.json b/libs/application/templates/healthcare-work-permit/tsconfig.spec.json new file mode 100644 index 000000000000..1033686367b0 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/libs/application/types/src/lib/ApplicationTypes.ts b/libs/application/types/src/lib/ApplicationTypes.ts index 473ad338ad91..9f05b5f8f68d 100644 --- a/libs/application/types/src/lib/ApplicationTypes.ts +++ b/libs/application/types/src/lib/ApplicationTypes.ts @@ -56,6 +56,7 @@ export enum ApplicationTypes { ADDITIONAL_SUPPORT_FOR_THE_ELDERLY = 'AdditionalSupportForTheElderly', ENERGY_FUNDS = 'EnergyFunds', HEALTHCARE_LICENSE_CERTIFICATE = 'HealthcareLicenseCertificate', + HEALTHCARE_WORK_PERMIT = 'HealthcareWorkPermit', PENSION_SUPPLEMENT = 'PensionSupplement', TRANSFER_OF_MACHINE_OWNERSHIP = 'TransferOfMachineOwnership', UNIVERSITY = 'University', @@ -302,6 +303,10 @@ export const ApplicationConfigurations = { slug: 'starfsleyfis-vottord', translation: 'hlc.application', }, + [ApplicationTypes.HEALTHCARE_WORK_PERMIT]: { + slug: 'starfsleyfis-umsokn', + translation: 'hwp.application', + }, [ApplicationTypes.PENSION_SUPPLEMENT]: { slug: 'uppbot-a-lifeyri', translation: ['ul.application', 'sia.application', 'uiForms.application'], diff --git a/libs/application/types/src/lib/InstitutionMapper.ts b/libs/application/types/src/lib/InstitutionMapper.ts index 589ee84d76ca..26186fc15fe9 100644 --- a/libs/application/types/src/lib/InstitutionMapper.ts +++ b/libs/application/types/src/lib/InstitutionMapper.ts @@ -227,6 +227,10 @@ export const institutionMapper = { nationalId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, slug: InstitutionTypes.EMBAETTI_LANDLAEKNIS, }, + [ApplicationTypes.HEALTHCARE_WORK_PERMIT]: { + nationalId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, + slug: InstitutionTypes.EMBAETTI_LANDLAEKNIS, + }, [ApplicationTypes.TRANSFER_OF_MACHINE_OWNERSHIP]: { nationalId: InstitutionNationalIds.VINNUEFTIRLITID, slug: InstitutionTypes.VINNUEFTIRLITID, diff --git a/libs/feature-flags/src/lib/features.ts b/libs/feature-flags/src/lib/features.ts index a9f8d0ed02bb..70c1c9ed5774 100644 --- a/libs/feature-flags/src/lib/features.ts +++ b/libs/feature-flags/src/lib/features.ts @@ -22,6 +22,8 @@ export enum Features { energyFunds = 'isEnergyFundsEnabled', complaintsToAlthingiOmbudsman = 'isComplaintToAlthingiOmbudsmanEnabled', healthcareLicenseCertificate = 'isHealthcareLicenseCertificateEnabled', + healthcareWorkPermit = 'isHealthcareWorkPermitEnabled', + pensionSupplementApplication = 'isPensionSupplementEnable', transferOfMachineOwnership = 'isTransferOfMachineOwnershipEnabled', university = 'isUniversityEnabled', homeSupport = 'isHomeSupportEnabled', diff --git a/tsconfig.base.json b/tsconfig.base.json index 644570efaf56..bd502ec5f37a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -406,6 +406,9 @@ "@island.is/application/templates/healthcare-license-certificate": [ "libs/application/templates/healthcare-license-certificate/src/index.ts" ], + "@island.is/application/templates/healthcare-work-permit": [ + "libs/application/templates/healthcare-work-permit/src/index.ts" + ], "@island.is/application/templates/home-support": [ "libs/application/templates/home-support/src/index.ts" ], From 6dbd9f5ca167f0c7b50a9597e7d96f476bed1623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Wed, 3 Apr 2024 14:48:20 +0000 Subject: [PATCH 02/30] Work permit application progress --- .../healthcare-work-permit.service.ts | 69 +- .../src/lib/modules/templates/index.ts | 1 + .../national-registry-ees.module.ts | 17 - .../national-registry-ees.service.ts | 21 - .../src/dataProviders/index.ts | 60 +- .../fields/SelectWorkPermitField/index.tsx | 19 +- .../src/forms/Prerequisites/index.ts | 216 +++--- .../src/lib/HealthcareWorkPermitTemplate.ts | 22 +- .../src/lib/dataSchema.ts | 9 +- .../src/shared/constants.ts | 12 +- .../src/utils/getChargeItemCodes.ts | 11 +- .../health-directorate/src/clientConfig.json | 671 +++++++++++++++++- .../src/lib/apiConfiguration.ts | 3 +- .../lib/healthDirectorateClient.service.ts | 65 +- .../src/lib/healthDirectorateClient.types.ts | 11 + .../constants/src/lib/chargeItemCode.ts | 1 + 16 files changed, 970 insertions(+), 238 deletions(-) delete mode 100644 libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts delete mode 100644 libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 2fdb7bcb7007..b99e5275a367 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -4,17 +4,20 @@ import { TemplateApiModuleActionProps } from '../../../types' import { BaseTemplateApiService } from '../../base-template-api.service' import { ApplicationTypes, + NationalRegistryIndividual, } from '@island.is/application/types' import { + HealthcareWorkPermitAnswers, error as errorMsg, } from '@island.is/application/templates/healthcare-work-permit' import { HealthDirectorateClientService, - HealthcareLicense, + StarfsleyfiUmsoknStarfsleyfi, + UtbuaStarfsleyfiSkjalResponse, } from '@island.is/clients/health-directorate' import { Transcripts, - UniversityOfIcelandService + UniversityOfIcelandService, } from '@island.is/clients/university-of-iceland' import { TemplateApiError } from '@island.is/nest/problem' @@ -23,29 +26,43 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { constructor( private readonly sharedTemplateAPIService: SharedTemplateApiService, private readonly healthDirectorateClientService: HealthDirectorateClientService, - private readonly universityOfIcelandService: UniversityOfIcelandService + private readonly universityOfIcelandService: UniversityOfIcelandService, ) { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) } async getMyHealthcareLicenses({ auth, - }: TemplateApiModuleActionProps): Promise { + }: TemplateApiModuleActionProps): Promise { const result = - await this.healthDirectorateClientService.getMyHealthcareLicenses(auth) - - // TODO Error if the service does not respond/is down ? + await this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( + auth, + ) + + // TODO Error if the service does not respond/is down ? + + return result + } + + async getEducationInfo({ + auth, + }: TemplateApiModuleActionProps): Promise { + const result = + await this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + auth, + ) + + // TODO Error if the service does not respond/is down ? - return result + return result } async getMyAcademicCareer({ auth, }: TemplateApiModuleActionProps): Promise { - const result = - await this.universityOfIcelandService.studentInfo(auth) + const result = await this.universityOfIcelandService.studentInfo(auth) - if(!result){ + if (!result) { throw new TemplateApiError( { title: errorMsg.emptyCareerResponseTitle, @@ -55,15 +72,15 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } - return result + return result } - async submitApplication({ application, auth, - }: TemplateApiModuleActionProps): Promise { // TODO Add type here! - + }: TemplateApiModuleActionProps): Promise { + // TODO Change to custom type with base64 + .. ? + const { paymentUrl } = application.externalData.createCharge.data as { paymentUrl: string } @@ -82,14 +99,22 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } - // const answers = application.answers as HealthcareWorkPermitAnswers - - // const nationalRegistryData = application.externalData.nationalRegistry - // ?.data as NationalRegistryIndividual - - // Submit the application + const answers = application.answers as HealthcareWorkPermitAnswers - return {} + const nationalRegistryData = application.externalData.nationalRegistry + ?.data as NationalRegistryIndividual + return await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( + auth, + { + name: nationalRegistryData.fullName, + dateOfBirth: nationalRegistryData.birthDate, + email: answers.userInformation?.email, + phone: answers.userInformation?.phone, // TODO Is phone in correct format ? + idProfession: answers.selectWorkPermit.studyProgram, // TODO Where can I get idProfession from + citizenship: nationalRegistryData.citizenship?.code || '', + education: [], // TODO + }, + ) } } diff --git a/libs/application/template-api-modules/src/lib/modules/templates/index.ts b/libs/application/template-api-modules/src/lib/modules/templates/index.ts index e2acbdebc788..d74b190eb4f2 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/index.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/index.ts @@ -130,6 +130,7 @@ import { RequestInspectionTemplateService } from './aosh/request-inspection/requ import { HealthInsuranceDeclarationModule } from './health-insurance-declaration/health-insurance-declaration.module' import { HealthInsuranceDeclarationService } from './health-insurance-declaration/health-insurance-declaration.service' + export const modules = [ ReferenceTemplateModule, GeneralFishingLicenseModule, diff --git a/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts deleted file mode 100644 index ba06046ae417..000000000000 --- a/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { DynamicModule } from '@nestjs/common' - -import { SharedTemplateAPIModule } from '../../shared' -import { NationalRegistryEESService } from './national-registry-ees.service' -import { BaseTemplateAPIModuleConfig } from '../../../types' - - -export class NationalRegistyEESModule { - static register(config: BaseTemplateAPIModuleConfig): DynamicModule { - return { - module: NationalRegistyEESModule, - imports: [SharedTemplateAPIModule.register(config)], - providers: [NationalRegistryEESService], - exports: [NationalRegistryEESService], - } - } -} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts deleted file mode 100644 index 82f9a60a7d5c..000000000000 --- a/libs/application/template-api-modules/src/lib/modules/templates/national-registry-ees/national-registry-ees.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Injectable } from '@nestjs/common' - -import { TemplateApiModuleActionProps } from '../../../types' -import { ApplicationTypes } from '@island.is/application/types' -import { BaseTemplateApiService } from '../../base-template-api.service' -import { NationalRegistryClientService } from '@island.is/clients/national-registry-v2' - -@Injectable() -export class NationalRegistryEESService extends BaseTemplateApiService { - constructor( - private readonly nationalRegistryClientService: NationalRegistryClientService, - ) { - super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) - } - - async getNationalRegistryWithEESValidation({ auth }: TemplateApiModuleActionProps) { - const person = this.nationalRegistryClientService.getIndividual(auth.nationalId) - - return person - } -} diff --git a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts index ba0db3575f2d..6bb2a888db98 100644 --- a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts @@ -1,35 +1,35 @@ import { - InstitutionNationalIds, - PaymentCatalogApi, - defineTemplateApi, - } from '@island.is/application/types' - import { ApiActions } from '../shared' - - export { - NationalRegistryUserApi, - UserProfileApi, - } from '@island.is/application/types' - - export const EmbaettiLandlaeknisPaymentCatalogApi = PaymentCatalogApi.configure( - { - params: { - organizationId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, - }, - externalDataId: 'payment', + InstitutionNationalIds, + PaymentCatalogApi, + defineTemplateApi, +} from '@island.is/application/types' +import { ApiActions } from '../shared' + +export { + NationalRegistryUserApi, + UserProfileApi, +} from '@island.is/application/types' + +export const EmbaettiLandlaeknisPaymentCatalogApi = PaymentCatalogApi.configure( + { + params: { + organizationId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, }, - ) + externalDataId: 'payment', + }, +) - export const HealtcareLicenesApi = defineTemplateApi({ - action: ApiActions.getMyHealthcareLicenses, - externalDataId: 'healthcareLicenses', - }) +export const HealtcareLicenesApi = defineTemplateApi({ + action: ApiActions.getMyHealthcareLicenses, + externalDataId: 'healthcareLicenses', +}) - export const UniversityOfIcelandApi = defineTemplateApi({ - action: ApiActions.getMyAcademicCareer, - externalDataId: 'universityOfIceland', - }) +export const UniversityOfIcelandApi = defineTemplateApi({ + action: ApiActions.getMyAcademicCareer, + externalDataId: 'universityOfIceland', +}) - export const NationalRegistryApi = defineTemplateApi({ - action: ApiActions.getNationalRegistryWithEESValidation, - externalDataId: 'nationalRegistry', - }) \ No newline at end of file +export const EducationInfoApi = defineTemplateApi({ + action: ApiActions.getEducationInfo, + externalDataId: 'educationInfo', +}) diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx index b078bf8db6b0..20c16c71db97 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx @@ -2,12 +2,8 @@ import { FieldBaseProps } from '@island.is/application/types' import { AlertMessage, Box, Text } from '@island.is/island-ui/core' import { FC } from 'react' import { useLocale } from '@island.is/localization' -import { - CheckboxController, - RadioController, -} from '@island.is/shared/form-fields' +import { RadioController } from '@island.is/shared/form-fields' import { information } from '../../lib/messages' -import { formatDate } from '../../utils' import { Transcripts } from '@island.is/clients/university-of-iceland' interface Option { @@ -19,8 +15,6 @@ interface Option { export const SelectWorkPermitField: FC< React.PropsWithChildren > = (props) => { - console.log('MAAADE IT') - const { lang, formatMessage } = useLocale() const { application } = props @@ -40,17 +34,6 @@ export const SelectWorkPermitField: FC< ? workPermit.studyProgram : workPermit.studyProgram} - {/* {license.isTemporary && ( - - {formatMessage( - information.labels.selectWorkPermit - .workPermitOptionSubLabelTemporary, - { - dateTo: formatDate(license.validTo || new Date()), - }, - )} - - )} */} {disabled && ( diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index 1c58bc5bdd4e..63b7a2f4cbd5 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -1,105 +1,117 @@ import { - buildDataProviderItem, - buildExternalDataProvider, - buildForm, - buildSection, - buildSubmitField, - coreMessages, - } from '@island.is/application/core' - import { DefaultEvents, Form, FormModes } from '@island.is/application/types' - import { - confirmation, - externalData, - information, - payment, - personal, - } from '../../lib/messages' - import { - EmbaettiLandlaeknisPaymentCatalogApi, - HealtcareLicenesApi, - UserProfileApi, - UniversityOfIcelandApi, - NationalRegistryApi, - } from '../../dataProviders' - - export const Prerequisites: Form = buildForm({ - id: 'PrerequisitesForm', - title: '', - mode: FormModes.NOT_STARTED, - renderLastScreenButton: true, - renderLastScreenBackButton: true, - children: [ - buildSection({ - id: 'externalData', - title: externalData.dataProvider.sectionTitle, - children: [ - buildExternalDataProvider({ - title: externalData.dataProvider.pageTitle, - id: 'approveExternalData', - subTitle: externalData.dataProvider.subTitle, - checkboxLabel: externalData.dataProvider.checkboxLabel, - submitField: buildSubmitField({ - id: 'submit', - placement: 'footer', - title: '', - refetchApplicationAfterSubmit: true, - actions: [ - { - event: DefaultEvents.SUBMIT, - name: coreMessages.buttonNext, - type: 'primary', - }, - ], - }), - dataProviders: [ - buildDataProviderItem({ - provider: NationalRegistryApi, - title: externalData.nationalRegistry.title, - subTitle: externalData.nationalRegistry.subTitle, - }), - buildDataProviderItem({ - provider: UserProfileApi, - title: externalData.userProfile.title, - subTitle: externalData.userProfile.subTitle, - }), - buildDataProviderItem({ - provider: HealtcareLicenesApi, - title: externalData.healtcareLicenses.title, - subTitle: externalData.healtcareLicenses.subTitle, - }), - buildDataProviderItem({ - provider: UniversityOfIcelandApi, - title: externalData.universityOfIceland.title, - subTitle: externalData.universityOfIceland.subTitle, - }), - buildDataProviderItem({ - provider: EmbaettiLandlaeknisPaymentCatalogApi, - title: '', - }), + buildDataProviderItem, + buildExternalDataProvider, + buildForm, + buildSection, + buildSubmitField, + coreMessages, +} from '@island.is/application/core' +import { + DefaultEvents, + Form, + FormModes, + NationalRegistryUserApi, +} from '@island.is/application/types' +import { + confirmation, + externalData, + information, + payment, + personal, +} from '../../lib/messages' +import { + EmbaettiLandlaeknisPaymentCatalogApi, + HealtcareLicenesApi, + UserProfileApi, + UniversityOfIcelandApi, + EducationInfoApi, +} from '../../dataProviders' + +export const Prerequisites: Form = buildForm({ + id: 'PrerequisitesForm', + title: '', + mode: FormModes.NOT_STARTED, + renderLastScreenButton: true, + renderLastScreenBackButton: true, + children: [ + buildSection({ + id: 'externalData', + title: externalData.dataProvider.sectionTitle, + children: [ + buildExternalDataProvider({ + title: externalData.dataProvider.pageTitle, + id: 'approveExternalData', + subTitle: externalData.dataProvider.subTitle, + checkboxLabel: externalData.dataProvider.checkboxLabel, + submitField: buildSubmitField({ + id: 'submit', + placement: 'footer', + title: '', + refetchApplicationAfterSubmit: true, + actions: [ + { + event: DefaultEvents.SUBMIT, + name: coreMessages.buttonNext, + type: 'primary', + }, ], }), - ], - }), - buildSection({ - id: 'personal', - title: personal.general.sectionTitle, - children: [], - }), - buildSection({ - id: 'selectLicenseSection', - title: information.general.sectionTitle, - children: [], - }), - buildSection({ - id: 'payment', - title: payment.general.sectionTitle, - children: [], - }), - buildSection({ - id: 'confirmation', - title: confirmation.general.sectionTitle, - children: [], - }), - ], - }) - \ No newline at end of file + dataProviders: [ + buildDataProviderItem({ + provider: NationalRegistryUserApi.configure({ + params: { + icelandicCitizenship: true, + }, + }), + title: externalData.nationalRegistry.title, + subTitle: externalData.nationalRegistry.subTitle, + }), + buildDataProviderItem({ + provider: UserProfileApi, + title: externalData.userProfile.title, + subTitle: externalData.userProfile.subTitle, + }), + buildDataProviderItem({ + provider: HealtcareLicenesApi, + title: externalData.healtcareLicenses.title, + subTitle: externalData.healtcareLicenses.subTitle, + }), + buildDataProviderItem({ + provider: UniversityOfIcelandApi, + title: externalData.universityOfIceland.title, + subTitle: externalData.universityOfIceland.subTitle, + }), + buildDataProviderItem({ + provider: EmbaettiLandlaeknisPaymentCatalogApi, + title: '', + }), + buildDataProviderItem({ + provider: EducationInfoApi, + title: '', + }), + ], + }), + ], + }), + buildSection({ + id: 'personal', + title: personal.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'selectLicenseSection', + title: information.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'payment', + title: payment.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'confirmation', + title: confirmation.general.sectionTitle, + children: [], + }), + ], +}) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index 9515e9ce4838..c0d8267f405a 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -9,6 +9,7 @@ import { DefaultEvents, defineTemplateApi, InstitutionNationalIds, + NationalRegistryUserApi, } from '@island.is/application/types' import { EphemeralStateLifeCycle, @@ -24,11 +25,12 @@ import { UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, - NationalRegistryApi, UniversityOfIcelandApi, + EducationInfoApi, } from '../dataProviders' import { buildPaymentState } from '@island.is/application/utils' import { HealthcareWorkPermitSchema } from './dataSchema' +import { getChargeItemCodes } from '../utils' const template: ApplicationTemplate< ApplicationContext, @@ -80,11 +82,16 @@ const template: ApplicationTemplate< write: 'all', delete: true, api: [ - NationalRegistryApi, + NationalRegistryUserApi.configure({ + params: { + // Add is part of EES + }, + }), UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, - UniversityOfIcelandApi + UniversityOfIcelandApi, + EducationInfoApi, ], }, ], @@ -118,9 +125,8 @@ const template: ApplicationTemplate< { id: Roles.APPLICANT, formLoader: () => - import('../forms/HealthcareWorkPermitForm').then( - (module) => - Promise.resolve(module.HealthcareWorkPermitForm), + import('../forms/HealthcareWorkPermitForm').then((module) => + Promise.resolve(module.HealthcareWorkPermitForm), ), write: 'all', delete: true, @@ -133,7 +139,7 @@ const template: ApplicationTemplate< }, [States.PAYMENT]: buildPaymentState({ organizationId: InstitutionNationalIds.EMBAETTI_LANDLAEKNIS, - chargeItemCodes: [], + chargeItemCodes: getChargeItemCodes, submitTarget: States.COMPLETED, lifecycle: { shouldBeListed: true, @@ -174,7 +180,6 @@ const template: ApplicationTemplate< ], }, }, - }, }, mapUserToRole( @@ -189,4 +194,3 @@ const template: ApplicationTemplate< } export default template - diff --git a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts index 0afa6aed26c4..e0d6641e618a 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts @@ -5,12 +5,15 @@ const UserInformationSchema = z.object({ phone: z.string().min(1), }) +const SelectWorkPermitSchema = z.object({ + studyProgram: z.string().min(1), + //idProfession: z.string().min(1), +}) export const HealthcareWorkPermitSchema = z.object({ approveExternalData: z.boolean().refine((v) => v), userInformation: UserInformationSchema, + selectWorkPermit: SelectWorkPermitSchema, }) -export type HealthcareWorkPermit = z.TypeOf< - typeof HealthcareWorkPermitSchema -> +export type HealthcareWorkPermit = z.TypeOf diff --git a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts index 2c96b067a7c8..13bff425a788 100644 --- a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts +++ b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts @@ -1,7 +1,7 @@ export enum ApiActions { - submitApplication = 'submitApplication', - getMyHealthcareLicenses = 'getMyHealthcareLicenses', - getMyAcademicCareer = 'getMyAcademicCareer', - getNationalRegistryWithEESValidation = 'getNationalRegistryWithEESValidation' - } - \ No newline at end of file + submitApplication = 'submitApplication', + getMyHealthcareLicenses = 'getMyHealthcareLicenses', + getMyAcademicCareer = 'getMyAcademicCareer', + getEducationInfo = 'getEducationInfo', + getNationalRegistryWithEESValidation = 'getNationalRegistryWithEESValidation', +} diff --git a/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts b/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts index b4961f4f0b78..0402735d0dad 100644 --- a/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts +++ b/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts @@ -17,9 +17,14 @@ export const getChargeItemCodesAndExtraLabel = ( }> => { const answers = application.answers as HealthcareWorkPermit - const licenses = application?.externalData?.healthcareLicenses - ?.data as HealthcareLicense[] + // const licenses = application?.externalData?.healthcareLicenses + // ?.data as HealthcareLicense[] + const result = [] + result.push({ + chargeItemCode: ChargeItemCode.HEALTHCARE_WORK_PERMIT.toString(), + extraLabel: answers.selectWorkPermit.studyProgram, + }) - return [] + return result } diff --git a/libs/clients/health-directorate/src/clientConfig.json b/libs/clients/health-directorate/src/clientConfig.json index 280531dc0f12..b9caef5152eb 100644 --- a/libs/clients/health-directorate/src/clientConfig.json +++ b/libs/clients/health-directorate/src/clientConfig.json @@ -120,6 +120,124 @@ } } }, + "/UmsoknStarfsleyfi/NamsUpplys": { + "get": { + "tags": ["UmsoknStarfsleyfi"], + "summary": "Sækja upplýsingar um námsgögn fyrir umsóknir um starfsleyfi", + "responses": { + "200": { + "description": "Skilar námsupplýsingum", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/NamsUpplysingar" } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/NamsUpplysingar" } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/NamsUpplysingar" } + } + } + } + } + } + } + }, + "/UmsoknStarfsleyfi/Starfsleyfi": { + "get": { + "tags": ["UmsoknStarfsleyfi"], + "summary": "Sækja upplýsingar um starfsleyfi fyrir umsóknir um vottorð", + "responses": { + "200": { + "description": "Skilar starfsleyfum", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/StarfsleyfiUmsoknStarfsleyfi" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/StarfsleyfiUmsoknStarfsleyfi" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/StarfsleyfiUmsoknStarfsleyfi" + } + } + } + } + }, + "400": { "description": "Kennitala er á röngu formi" } + } + } + }, + "/UmsoknStarfsleyfi/UtbuaSkjal": { + "post": { + "tags": ["UmsoknStarfsleyfi"], + "summary": "Útbúa innsiglað vottorð um starfsleyfi", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalRequest" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalRequest" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Skilar base64 streng", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + } + } + } + }, + "400": { "description": "Kennitala er á röngu formi" }, + "404": { "description": "Starfsmaður fannst ekki" } + } + } + }, "/Vottord/StarfsleyfiVottord": { "get": { "tags": ["Vottord"], @@ -153,6 +271,46 @@ } } }, + "/Vottord/StarfstettVottord/{ssnNumber}": { + "get": { + "tags": ["Vottord"], + "summary": "Sækja upplýsingar um starfstétt fyrir umsóknir um vottorð B leið", + "parameters": [ + { + "name": "ssnNumber", + "in": "path", + "required": true, + "schema": { "type": "string", "nullable": true } + } + ], + "responses": { + "200": { + "description": "Skilar starfsleyfum", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/StarfstettVottord" } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/StarfstettVottord" } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/StarfstettVottord" } + } + } + } + }, + "400": { "description": "Kennitala er á röngu formi" } + } + } + }, "/Vottord/UtbuaSkjal": { "post": { "tags": ["Vottord"], @@ -189,6 +347,96 @@ "404": { "description": "Starfsmaður fannst ekki" } } } + }, + "/Vottord/SkraUmsokn": { + "post": { + "tags": ["Vottord"], + "summary": "Skrá inn nýja umsókn um vottorð", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/VottordUpplB" } + }, + "text/json": { + "schema": { "$ref": "#/components/schemas/VottordUpplB" } + }, + "application/*+json": { + "schema": { "$ref": "#/components/schemas/VottordUpplB" } + } + } + }, + "responses": { + "200": { + "description": "Skilar strengnum \"Umsókn skráð\"", + "content": { + "text/plain": { "schema": { "type": "string" } }, + "application/json": { "schema": { "type": "string" } }, + "text/json": { "schema": { "type": "string" } } + } + }, + "400": { "description": "Kennitala er á röngu formi" }, + "404": { "description": "Starfsmaður fannst ekki" } + } + } + }, + "/Vottord/SkraUmsokn/Upload": { + "post": { + "tags": ["Vottord"], + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UploadFilesItem" } + }, + "text/json": { + "schema": { "$ref": "#/components/schemas/UploadFilesItem" } + }, + "application/*+json": { + "schema": { "$ref": "#/components/schemas/UploadFilesItem" } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { "schema": { "type": "string" } }, + "application/json": { "schema": { "type": "string" } }, + "text/json": { "schema": { "type": "string" } } + } + } + } + } + }, + "/Vottord/Reglusett": { + "post": { + "tags": ["Vottord"], + "summary": "Skrá inn nýja umsókn um vottorð", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ReglusettVottordB" } + }, + "text/json": { + "schema": { "$ref": "#/components/schemas/ReglusettVottordB" } + }, + "application/*+json": { + "schema": { "$ref": "#/components/schemas/ReglusettVottordB" } + } + } + }, + "responses": { + "200": { + "description": "Skilar strengnum \"Umsókn skráð\"", + "content": { + "text/plain": { "schema": { "type": "string" } }, + "application/json": { "schema": { "type": "string" } }, + "text/json": { "schema": { "type": "string" } } + } + }, + "400": { "description": "Kennitala er á röngu formi" }, + "404": { "description": "Starfsmaður fannst ekki" } + } + } } }, "components": { @@ -624,6 +872,184 @@ "additionalProperties": false, "description": "Gagnaklasi fyrir skil á upplýsingum Heilbrigðisstarfsmenn" }, + "NamsUpplysingar": { + "type": "object", + "properties": { + "id": { "type": "integer", "format": "int32" }, + "idProfession": { + "type": "string", + "description": "Auðkenni Starfstétts", + "nullable": true, + "example": "SF" + }, + "educationId": { + "type": "integer", + "description": "Prof_id", + "format": "int32", + "example": 0 + }, + "educationName": { + "type": "string", + "description": "Nafn á prófi", + "nullable": true, + "example": "Framhaldskólapróf" + }, + "educationValidFrom": { + "type": "string", + "description": "Gildir frá dagsetning á prófinu", + "format": "date-time", + "nullable": true, + "example": "2009-11-03T00:00:00.0000000" + } + }, + "additionalProperties": false + }, + "StarfsleyfiUmsoknStarfsleyfi": { + "type": "object", + "properties": { + "ssnNumber": { + "type": "string", + "description": "Kennitala á Viðkomandi", + "nullable": true, + "example": "123456-1234" + }, + "name": { + "type": "string", + "description": "Nafn á viðkomandi", + "nullable": true, + "example": "Jón Jónsson" + }, + "idProfession": { + "type": "string", + "description": "Auðkenni Starfstétts", + "nullable": true, + "example": "SF" + }, + "professionIsl": { + "type": "string", + "description": "Heiti starfsstétt", + "nullable": true, + "example": "Sjúkraflutningamaður" + }, + "professionEn": { + "type": "string", + "description": "Heiti starfsstétt á ensku", + "nullable": true, + "example": "Emergency Medical Technician" + }, + "specialityIsl": { + "type": "string", + "description": "Leyfi", + "nullable": true, + "example": "Starfsleyfi" + }, + "specialityEn": { + "type": "string", + "description": "Leyfi á ensku", + "nullable": true, + "example": "Licence to practice" + }, + "validFrom": { + "type": "string", + "description": "Gildir frá dagsetning", + "format": "date-time", + "nullable": true, + "example": "2009-11-03T00:00:00.0000000" + }, + "validTo": { + "type": "string", + "description": "Gildir Til dagsetning", + "format": "date-time", + "nullable": true, + "example": "2009-11-03T00:00:00.0000000" + } + }, + "additionalProperties": false + }, + "Nam": { + "type": "object", + "properties": { + "educationId": { + "type": "integer", + "description": "Prof_id", + "format": "int32", + "example": 0 + }, + "graduationDate": { + "type": "string", + "description": "Útskriftadagsetning", + "format": "date-time", + "example": "2009-11-03T00:00:00.0000000" + }, + "school": { + "type": "string", + "description": "Nafn skóla", + "nullable": true, + "example": "Háskóli Íslands" + } + }, + "additionalProperties": false + }, + "UtbuaStarfsleyfiSkjalRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Nafn heilbrigðisstarfsmanns", + "nullable": true, + "example": "Jón Jónsson" + }, + "dateOfBirth": { + "type": "string", + "description": "Afmælisdagur heilbrigðisstarfsmanns. Þarf að vera á 'DD.MM.YYYY' sniði", + "nullable": true, + "example": "01.01.2000" + }, + "citizenship": { + "type": "string", + "description": "Ríkisfang", + "nullable": true, + "example": "IS" + }, + "email": { + "type": "string", + "description": "Netfang heilbrigðisstarfsmanns", + "nullable": true, + "example": "jonjonsson@landlaeknir.is" + }, + "phoneNo": { + "type": "string", + "description": "Símanúmer heilbrigðisstarfsmanns", + "nullable": true, + "example": "0000000" + }, + "idProfession": { + "type": "string", + "description": "Auðkenni Starfstétt heilbrigðisstarfsmanns", + "nullable": true, + "example": "HJ" + }, + "education": { + "type": "array", + "items": { "$ref": "#/components/schemas/Nam" }, + "nullable": true + } + }, + "additionalProperties": false, + "description": "Gagnaklasi fyrir Innsigluð vottorð" + }, + "UtbuaStarfsleyfiSkjalResponse": { + "type": "object", + "properties": { + "base64String": { + "type": "string", + "description": "Base64 strengur", + "nullable": true, + "example": "\"JVBER..." + } + }, + "additionalProperties": false + }, "StarfsleyfiVottord": { "type": "object", "properties": { @@ -698,12 +1124,48 @@ }, "additionalProperties": false }, + "StarfstettVottord": { + "type": "object", + "properties": { + "ssnNumber": { + "type": "string", + "description": "Kennitala á Viðkomandi", + "nullable": true, + "example": "123456-1234" + }, + "name": { + "type": "string", + "description": "Nafn á viðkomandi", + "nullable": true, + "example": "Jón Jónsson" + }, + "idProfession": { + "type": "string", + "description": "Auðkenni Starfstétts", + "nullable": true, + "example": "SF" + }, + "professionIsl": { + "type": "string", + "description": "Heiti starfsstétt", + "nullable": true, + "example": "Sjúkraflutningamaður" + }, + "professionEn": { + "type": "string", + "description": "Heiti starfsstétt á ensku", + "nullable": true, + "example": "Emergency Medical Technician" + } + }, + "additionalProperties": false + }, "UtbuaSkjalRequest": { "type": "object", "properties": { "name": { "type": "string", - "description": "nafn heilbrigðisstarfsmanns", + "description": "Nafn heilbrigðisstarfsmanns", "nullable": true, "example": "Jón Jónsson" }, @@ -742,7 +1204,212 @@ "type": "string", "description": "Base64 strengur", "nullable": true, - "example": "\"%PDF-1.5\\..." + "example": "\"JVBER..." + } + }, + "additionalProperties": false + }, + "AdilarItem": { + "type": "object", + "properties": { + "kennitala": { "type": "string", "nullable": true }, + "heiti": { "type": "string", "nullable": true }, + "heimili": { "type": "string", "nullable": true }, + "stadur": { "type": "string", "nullable": true }, + "postnumer": { "type": "string", "nullable": true }, + "tegund": { "type": "integer", "format": "int32" }, + "hlutverk": { "type": "string", "nullable": true }, + "netfang": { "type": "string", "nullable": true }, + "simi": { "type": "string", "nullable": true } + }, + "additionalProperties": false + }, + "NotandagognItem": { + "type": "object", + "properties": { + "guid": { "type": "string", "nullable": true }, + "flokkur": { "type": "string", "nullable": true }, + "heiti": { "type": "string", "nullable": true }, + "tegund": { "type": "string", "nullable": true }, + "gildi": { "type": "string", "nullable": true } + }, + "additionalProperties": false, + "description": "Kennitala á Viðkomandi" + }, + "GreidslaItem": { + "type": "object", + "properties": { + "upphaed": { "type": "number", "format": "double" }, + "dags": { "type": "string", "nullable": true }, + "korthafi": { "type": "string", "nullable": true }, + "kortanumer": { "type": "string", "nullable": true }, + "tegundKorts": { "type": "string", "nullable": true } + }, + "additionalProperties": false + }, + "FilesItem": { + "type": "object", + "properties": { + "flokkur": { "type": "integer", "format": "int32" }, + "heiti": { "type": "string", "nullable": true }, + "dags": { "type": "string", "nullable": true }, + "tegund": { "type": "string", "nullable": true }, + "fileID": { "type": "string", "nullable": true }, + "ending": { "type": "string", "nullable": true } + }, + "additionalProperties": false + }, + "VottordUpplB": { + "type": "object", + "properties": { + "language": { "type": "string", "nullable": true }, + "portalApplicationID": { "type": "string", "nullable": true }, + "applicationType": { "type": "string", "nullable": true }, + "applicationName": { "type": "string", "nullable": true }, + "dagssetning": { "type": "string", "nullable": true }, + "adilar": { + "type": "array", + "items": { "$ref": "#/components/schemas/AdilarItem" }, + "nullable": true + }, + "notandagogn": { + "type": "array", + "items": { "$ref": "#/components/schemas/NotandagognItem" }, + "nullable": true + }, + "greidsla": { "$ref": "#/components/schemas/GreidslaItem" }, + "files": { + "type": "array", + "items": { "$ref": "#/components/schemas/FilesItem" }, + "nullable": true + }, + "status": { "type": "integer", "format": "int32" } + }, + "additionalProperties": false + }, + "UploadFilesItem": { + "type": "object", + "properties": { + "file": { "type": "string", "nullable": true }, + "applicationID": { "type": "string", "nullable": true }, + "content": { "type": "string", "nullable": true }, + "applicationType": { "type": "string", "nullable": true } + }, + "additionalProperties": false + }, + "applicantType": { + "enum": [0, 1, 2, -2], + "type": "integer", + "description": "Type of applicants", + "format": "int32" + }, + "Adilar": { + "type": "object", + "properties": { + "kennitala": { + "type": "string", + "description": "kennitala for legal / natural persons", + "nullable": true + }, + "heiti": { + "type": "string", + "description": "Name", + "nullable": true + }, + "heimili": { + "type": "string", + "description": "Address", + "nullable": true + }, + "tegund": { "$ref": "#/components/schemas/applicantType" }, + "hlutverk": { + "type": "string", + "description": "description for the person", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Information regarding legal and natural persons within the application." + }, + "Notandagogn": { + "type": "object", + "properties": { + "flokkur": { + "type": "string", + "description": "Group name", + "nullable": true + }, + "heiti": { + "type": "string", + "description": "Name of the variable", + "nullable": true + }, + "tegund": { + "type": "string", + "description": "Type of variable", + "nullable": true + }, + "gildi": { + "type": "string", + "description": "Value for inspection", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Data entered by the applicant to be inspected bu the ruleset" + }, + "Reglusett": { + "type": "object", + "properties": { + "flokkur": { + "type": "string", + "description": "Groupname for the variable", + "nullable": true + }, + "heiti": { + "type": "string", + "description": "Name of the variable", + "nullable": true + }, + "tegund": { + "type": "string", + "description": "Type of variable", + "nullable": true + }, + "gildi": { + "type": "string", + "description": "The value to be set for the variable", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Data the can be set by the ruleset." + }, + "ReglusettVottordB": { + "type": "object", + "properties": { + "adilar": { + "type": "array", + "items": { "$ref": "#/components/schemas/Adilar" }, + "description": "List of persons that have a role in the application", + "nullable": true + }, + "notandagogn": { + "type": "array", + "items": { "$ref": "#/components/schemas/Notandagogn" }, + "description": "Information extracted from the application the the ruleset can use.", + "nullable": true + }, + "reglusett": { + "type": "array", + "items": { "$ref": "#/components/schemas/Reglusett" }, + "description": "Variable that the ruleset can set to be used in the application.\r\nCurrently we support String, Int and Date.", + "nullable": true + }, + "applicationType": { + "type": "string", + "description": "Unique id for the application type this unique id is provided when\r\nthe application is made by the provider. This can be used to have\r\ndifferent behaviour depending on application type.", + "nullable": true } }, "additionalProperties": false diff --git a/libs/clients/health-directorate/src/lib/apiConfiguration.ts b/libs/clients/health-directorate/src/lib/apiConfiguration.ts index dc790cf74f41..cf39ecf9d6df 100644 --- a/libs/clients/health-directorate/src/lib/apiConfiguration.ts +++ b/libs/clients/health-directorate/src/lib/apiConfiguration.ts @@ -9,6 +9,7 @@ import { HealthDirectorateClientConfig } from './healthDirectorateClient.config' import { Configuration, StarfsleyfiAMinumSidumApi, + UmsoknStarfsleyfiApi, VottordApi, } from '../../gen/fetch' @@ -39,7 +40,7 @@ const configFactory = ( }, }) -export const exportedApis = [StarfsleyfiAMinumSidumApi, VottordApi].map( +export const exportedApis = [StarfsleyfiAMinumSidumApi, VottordApi, UmsoknStarfsleyfiApi].map( (Api) => ({ provide: Api, scope: LazyDuringDevScope, diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index e902e4f8b7b0..7f47796ff376 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -1,12 +1,19 @@ import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools' -import { StarfsleyfiAMinumSidumApi, VottordApi } from '../../gen/fetch' import { Inject, Injectable, NotFoundException } from '@nestjs/common' import { - HealthDirectorateLicenseStatus, - HealthDirectorateLicenseToPractice, + NamsUpplysingar, + StarfsleyfiAMinumSidumApi, + StarfsleyfiUmsoknStarfsleyfi, + UmsoknStarfsleyfiApi, + UtbuaStarfsleyfiSkjalResponse, + VottordApi, +} from '../../gen/fetch' +import { HealthcareLicense, HealthcareLicenseCertificate, HealthcareLicenseCertificateRequest, + HealthDirectorateLicenseStatus, + HealthDirectorateLicenseToPractice, } from './healthDirectorateClient.types' import { isDefined } from '@island.is/shared/utils' import format from 'date-fns/format' @@ -17,6 +24,7 @@ export class HealthDirectorateClientService { constructor( private readonly starfsleyfiAMinumSidumApi: StarfsleyfiAMinumSidumApi, private readonly vottordApi: VottordApi, + private readonly umsoknStarfsleyfiApi: UmsoknStarfsleyfiApi, ) {} private starfsleyfiAMinumSidumApiWithAuth(auth: Auth) { @@ -29,7 +37,11 @@ export class HealthDirectorateClientService { return this.vottordApi.withMiddleware(new AuthMiddleware(auth)) } - public async getHealthDirectorateLicenseToPractice( + private umsoknStarfsleyfiApiWith(auth: Auth) { + return this.umsoknStarfsleyfiApi.withMiddleware(new AuthMiddleware(auth)) + } + + public async getHealthDirectorateLicense( auth: User, ): Promise | null> { const licenses = await this.starfsleyfiAMinumSidumApiWithAuth(auth) @@ -137,6 +149,51 @@ export class HealthDirectorateClientService { return result } + async getHealthCareLicensesForWorkPermit( + auth: Auth, + ): Promise { + const licenses = await this.umsoknStarfsleyfiApiWith( + auth, + ).umsoknStarfsleyfiStarfsleyfiGet() + + return licenses + } + + async getHealthCareWorkPermitEducationInfo( + auth: Auth, + ): Promise { + const educationInfo = await this.umsoknStarfsleyfiApiWith( + auth, + ).umsoknStarfsleyfiNamsUpplysGet() + + return educationInfo + } + + async submitApplicationHealthcareWorkPermit( + auth: User, + request: HealthcareWorkPermitRequest, + ): Promise { + const item = await this.umsoknStarfsleyfiApiWith( + auth, + ).umsoknStarfsleyfiUtbuaSkjalPost({ + utbuaStarfsleyfiSkjalRequest: { + name: request.name, + dateOfBirth: format(new Date(request.dateOfBirth), 'dd.MM.yyyy'), + citizenship: request.citizenship, + email: request.email, + phoneNo: request.phone, + idProfession: request.idProfession, + education: request.education, + }, + }) + + if (!item.base64String) { + throw new Error('Empty file') + } + + return item + } + async submitApplicationHealthcareLicenseCertificate( auth: User, request: HealthcareLicenseCertificateRequest, diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.types.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.types.ts index c7ad3b78b989..7fba856afad0 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.types.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.types.ts @@ -1,3 +1,5 @@ +import { Nam } from '../../gen/fetch' + export interface HealthcareLicense { professionId: string professionNameIs: string @@ -44,3 +46,12 @@ export interface HealthDirectorateLicenseToPractice { validTo?: Date status: HealthDirectorateLicenseStatus } +export interface HealthcareWorkPermitRequest { + name: string + dateOfBirth: Date + email: string + phone: string + idProfession: string + citizenship: string + education: Nam[] +} diff --git a/libs/shared/constants/src/lib/chargeItemCode.ts b/libs/shared/constants/src/lib/chargeItemCode.ts index 21744a02e0ee..6a6d9c40db87 100644 --- a/libs/shared/constants/src/lib/chargeItemCode.ts +++ b/libs/shared/constants/src/lib/chargeItemCode.ts @@ -26,4 +26,5 @@ export enum ChargeItemCode { AOSH_STREET_REGISTRATION_SA116 = 'SA116', // Nýskráning AOSH_STREET_REGISTRATION_SA117 = 'SA117', // Rafræn forskráning HEALTHCARE_LICENSE_CERTIFICATE = 'L6102', + HEALTHCARE_WORK_PERMIT = 'L6101', } From ebd70efe6116263b2f61fce5d9c4d56a4f9eff6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Mon, 8 Apr 2024 13:25:38 +0000 Subject: [PATCH 03/30] Error messages --- .../healthcare-work-permit.service.ts | 23 +++++++++++-- .../src/lib/messages/error.ts | 32 +++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index b99e5275a367..531e2e06ac35 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -39,7 +39,16 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { auth, ) - // TODO Error if the service does not respond/is down ? + // TODO Double check if this fails on empty response + // if (!result) { + // throw new TemplateApiError( + // { + // title: errorMsg.healthcareLicenseErrorTitle, + // summary: errorMsg.healthcareLicenseErrorMessage, + // }, + // 400, + // ) + // } return result } @@ -52,7 +61,17 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { auth, ) - // TODO Error if the service does not respond/is down ? + console.log('Accessing education info', result) + + // if (!result) { + // throw new TemplateApiError( + // { + // title: errorMsg.healthcareLicenseErrorTitle, + // summary: errorMsg.noResponseEducationInfoMessage, + // }, + // 400, + // ) + // } return result } diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts index b94b17c47ab0..10da04a8f1b4 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -7,15 +7,43 @@ export const error = defineMessages({ description: 'Unhandled error in data provider', }, emptyCareerResponseTitle: { - id: 'hlc.application:error.emptyHealthLicenseListTitle', + id: 'hlc.application:error.emptyCareerResponseTitle', defaultMessage: 'Samkvæmt þjónustu Háskóla Íslands ertu ekki með brautskráningu á skrá', description: 'Empty career response', }, emptyCareerResponseMessage: { - id: 'hlc.application:error.emptyHealthLicenseListMessage', + id: 'hlc.application:error.emptyCareerResponseMessage', defaultMessage: 'Samkvæmt þjónustu Háskóla Íslands ertu ekki með brautskráningu á skrá', description: 'Empty career response', }, + noResponseEducationInfoTitle: { + id: 'hlc.application:error.noResponseEducationInfoTitle', + defaultMessage: + 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + description: + 'No response or faulty response when fetching info on education paths', + }, + noResponseEducationInfoMessage: { + id: 'hlc.application:error.noResponseEducationInfoMessage', + defaultMessage: + 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + description: + 'No response or faulty response when fetching info on education paths', + }, + healthcareLicenseErrorTitle: { + id: 'hlc.application:error.healthcareLicenseErrorTitle', + defaultMessage: + 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + description: + 'No response or faulty response when fetching info on education paths', + }, + healthcareLicenseErrorMessage: { + id: 'hlc.application:error.healthcareLicenseErrorMessage', + defaultMessage: + 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + description: + 'No response or faulty response when fetching info on education paths', + }, }) From 70479226575ff63efeba408c661e7cb05094f517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 16 Apr 2024 09:00:46 +0000 Subject: [PATCH 04/30] Messages and extract strings to project.json --- .../healthcare-work-permit/project.json | 6 ++++++ .../src/fields/SelectWorkPermitField/index.tsx | 10 +++++++++- .../selectWorkPermitSection.ts | 9 +++++++++ .../src/lib/messages/confirmation.ts | 4 ++-- .../src/lib/messages/externalData.ts | 7 +++---- .../src/lib/messages/information.ts | 18 +++++++++++++++--- .../src/utils/getChargeItemCodes.ts | 3 ++- 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/libs/application/templates/healthcare-work-permit/project.json b/libs/application/templates/healthcare-work-permit/project.json index 094de40bcdab..e5cd25aa6b41 100644 --- a/libs/application/templates/healthcare-work-permit/project.json +++ b/libs/application/templates/healthcare-work-permit/project.json @@ -27,6 +27,12 @@ "codeCoverage": true } } + }, + "extract-strings": { + "executor": "nx:run-commands", + "options": { + "command": "yarn ts-node -P libs/localization/tsconfig.lib.json libs/localization/scripts/extract 'libs/application/templates/healthcare-work-permit/src/**/*.{js,ts,tsx}'" + } } } } diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx index 20c16c71db97..815f078441a9 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx @@ -64,7 +64,15 @@ export const SelectWorkPermitField: FC< } return ( - + + + {formatMessage(information.labels.selectWorkPermit.sectionTitle)} + => { return getChargeItemCodesAndExtraLabel(application).map( @@ -17,6 +16,8 @@ export const getChargeItemCodesAndExtraLabel = ( }> => { const answers = application.answers as HealthcareWorkPermit + // TODO Get Id instead of studyProgram string, fetch programme via id and display info. + // const licenses = application?.externalData?.healthcareLicenses // ?.data as HealthcareLicense[] From 36bd665b8e00776a47fd2142db5d975eb01741e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 23 Apr 2024 08:18:16 +0000 Subject: [PATCH 05/30] Skeleton of confirmation step --- .../healthcare-work-permit.service.ts | 38 +++++++-------- .../index.tsx | 24 ++++++++++ .../styles.css.ts | 16 +++++++ .../src/forms/Confirmation/index.ts | 48 +++++++++++++++++++ .../selectWorkPermitSection.ts | 1 - .../src/lib/HealthcareWorkPermitTemplate.ts | 4 +- .../src/lib/dataSchema.ts | 2 +- 7 files changed, 109 insertions(+), 24 deletions(-) create mode 100644 libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx create mode 100644 libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/styles.css.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 531e2e06ac35..28b220781642 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -40,15 +40,15 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) // TODO Double check if this fails on empty response - // if (!result) { - // throw new TemplateApiError( - // { - // title: errorMsg.healthcareLicenseErrorTitle, - // summary: errorMsg.healthcareLicenseErrorMessage, - // }, - // 400, - // ) - // } + if (!result) { + throw new TemplateApiError( + { + title: errorMsg.healthcareLicenseErrorTitle, + summary: errorMsg.healthcareLicenseErrorMessage, + }, + 400, + ) + } return result } @@ -61,17 +61,15 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { auth, ) - console.log('Accessing education info', result) - - // if (!result) { - // throw new TemplateApiError( - // { - // title: errorMsg.healthcareLicenseErrorTitle, - // summary: errorMsg.noResponseEducationInfoMessage, - // }, - // 400, - // ) - // } + if (!result) { + throw new TemplateApiError( + { + title: errorMsg.healthcareLicenseErrorTitle, + summary: errorMsg.noResponseEducationInfoMessage, + }, + 400, + ) + } return result } diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx new file mode 100644 index 000000000000..a25cdfb03cb8 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx @@ -0,0 +1,24 @@ +import { FieldBaseProps } from '@island.is/application/types' +import { useLocale } from '@island.is/localization' +import { FC, useState } from 'react' + +export const CustomFormConclusionSectionField: FC< + React.PropsWithChildren +> = (props) => { + const { application } = props + const { formatMessage } = useLocale() + + const [fileToView, setFileToView] = useState< + | { + base64: string + filename: string + } + | undefined + >(undefined) + + if (fileToView) { + return <> + } + + return <> +} diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/styles.css.ts b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/styles.css.ts new file mode 100644 index 000000000000..72c3f804636c --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/styles.css.ts @@ -0,0 +1,16 @@ +import { style, globalStyle } from '@vanilla-extract/css' + +export const pdfViewer = style({}) + +globalStyle(`${pdfViewer} canvas`, { + maxWidth: '100%', + width: '100% !important', + height: 'auto !important', + border: '1px solid #CCDFFF', +}) + +export const linkWithoutDecorations = style({ + ':hover': { + textDecoration: 'none', + }, +}) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts new file mode 100644 index 000000000000..9fbee48fca42 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts @@ -0,0 +1,48 @@ +import { + buildCustomField, + buildForm, + buildSection, +} from '@island.is/application/core' +import { Form, FormModes } from '@island.is/application/types' +import { + information, + externalData, + payment, + personal, +} from '../../lib/messages' +import { Logo } from '../../assets/Logo' + +export const Confirmation: Form = buildForm({ + id: 'ConfirmationForm', + title: '', + logo: Logo, + mode: FormModes.COMPLETED, + children: [ + buildSection({ + id: 'externalData', + title: externalData.dataProvider.sectionTitle, + children: [], + }), + buildSection({ + id: 'personal', + title: personal.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'informationSection', + title: information.general.sectionTitle, + children: [], + }), + buildSection({ + id: 'payment', + title: payment.general.sectionTitle, + children: [], + }), + buildCustomField({ + component: 'CustomFormConclusionSectionField', + id: 'custom.conclusionSection', + title: '', + description: '', + }), + ], +}) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts index 791928a68881..5e9a6cbe3f53 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts @@ -3,7 +3,6 @@ import { buildCustomField, buildMultiField, buildSection, - buildTextField, } from '@island.is/application/core' import { information } from '../../lib/messages' diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index c0d8267f405a..c3a9a82bcfd4 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -172,8 +172,8 @@ const template: ApplicationTemplate< { id: Roles.APPLICANT, formLoader: () => - import('../forms/HealthcareWorkPermitForm').then((val) => - Promise.resolve(val.HealthcareWorkPermitForm), + import('../forms/Confirmation').then((val) => + Promise.resolve(val.Confirmation), ), read: 'all', }, diff --git a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts index e0d6641e618a..57aade28e852 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts @@ -7,7 +7,7 @@ const UserInformationSchema = z.object({ const SelectWorkPermitSchema = z.object({ studyProgram: z.string().min(1), - //idProfession: z.string().min(1), + // idProfession: z.string().min(1), }) export const HealthcareWorkPermitSchema = z.object({ From c8f0af1129230427e7cd47f8ca27dac64a2c5f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 7 May 2024 13:48:51 +0000 Subject: [PATCH 06/30] Updating uni of iceland openapi --- .../healthcare-work-permit.service.ts | 23 ++++++++++++++++--- .../src/lib/HealthcareWorkPermitTemplate.ts | 2 +- .../health-directorate/src/clientConfig.json | 18 +++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 28b220781642..5c0996635cc9 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -12,6 +12,7 @@ import { } from '@island.is/application/templates/healthcare-work-permit' import { HealthDirectorateClientService, + NamsUpplysingar, StarfsleyfiUmsoknStarfsleyfi, UtbuaStarfsleyfiSkjalResponse, } from '@island.is/clients/health-directorate' @@ -56,12 +57,14 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async getEducationInfo({ auth, }: TemplateApiModuleActionProps): Promise { - const result = + const academicCareer: Transcripts | null = + await this.universityOfIcelandService.studentInfo(auth) + const educationTracks: NamsUpplysingar[] = await this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( auth, ) - if (!result) { + if (!educationTracks || !academicCareer) { throw new TemplateApiError( { title: errorMsg.healthcareLicenseErrorTitle, @@ -71,7 +74,21 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } - return result + // TODO Here I need to make sure that at least some of the users academic career exist in the workpermit educational info list in order + // to make it to the next step. + // const educationShortIdMap: { [shortId: string]: boolean } = {}; + // academicCareer?.transcripts?.forEach(edu => { + // educationShortIdMap[edu.shortId] = true; + // }); + + // // Match transcripts with education that gives a work permit + // const matchedTranscripts: Transcripts = academicCareer?.transcripts?.filter(transcript => { + // return transcript.shortId in educationShortIdMap; + // }); + + // console.log("Matched Transcripts:", matchedTranscripts); + + return educationTracks } async getMyAcademicCareer({ diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index c3a9a82bcfd4..cb76af56363d 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -89,8 +89,8 @@ const template: ApplicationTemplate< }), UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, - HealtcareLicenesApi, UniversityOfIcelandApi, + HealtcareLicenesApi, EducationInfoApi, ], }, diff --git a/libs/clients/health-directorate/src/clientConfig.json b/libs/clients/health-directorate/src/clientConfig.json index b9caef5152eb..6c76fbdf3e55 100644 --- a/libs/clients/health-directorate/src/clientConfig.json +++ b/libs/clients/health-directorate/src/clientConfig.json @@ -900,6 +900,24 @@ "format": "date-time", "nullable": true, "example": "2009-11-03T00:00:00.0000000" + }, + "shortId": { + "type": "string", + "description": "Stutt ID frá háskólunum. Notað til að mappa saman nám.", + "nullable": true, + "example": "HJÚ273" + }, + "dataOrder": { + "type": "integer", + "description": "Röðun prófa/gagna, 1 = lægsta stig. NoOfData = hæðsta stig", + "format": "int32", + "example": 1 + }, + "noOfData": { + "type": "integer", + "description": "Fjöldi prófa/gagna sem þarf að skila.", + "format": "int32", + "example": 2 } }, "additionalProperties": false From 007bc4d46ebdc010d1496cd733bb049083ad2ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Fri, 17 May 2024 09:56:23 +0000 Subject: [PATCH 07/30] starting to add EES validation and calling nationalRegistry from work permit service --- .../healthcare-work-permit.module.ts | 16 +- .../healthcare-work-permit.service.ts | 46 +-- .../templates/healthcare-work-permit/EES.ts | 336 ++++++++++++++++++ .../src/forms/Prerequisites/index.ts | 6 +- .../src/lib/HealthcareWorkPermitTemplate.ts | 6 +- 5 files changed, 378 insertions(+), 32 deletions(-) create mode 100644 libs/application/templates/healthcare-work-permit/EES.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts index 1a8f2103ba8f..49d259f91269 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -7,7 +7,14 @@ import { HealthDirectorateClientModule, HealthDirectorateClientConfig, } from '@island.is/clients/health-directorate' -import { UniversityOfIcelandClientConfig, UniversityOfIcelandClientModule } from '@island.is/clients/university-of-iceland' +import { + UniversityOfIcelandClientConfig, + UniversityOfIcelandClientModule, +} from '@island.is/clients/university-of-iceland' +import { + NationalRegistryClientConfig, + NationalRegistryClientModule, +} from '@island.is/clients/national-registry-v2' export class HealthcareWorkPermitModule { static register(baseConfig: BaseTemplateAPIModuleConfig): DynamicModule { @@ -17,9 +24,14 @@ export class HealthcareWorkPermitModule { SharedTemplateAPIModule.register(baseConfig), HealthDirectorateClientModule, UniversityOfIcelandClientModule, + NationalRegistryClientModule, ConfigModule.forRoot({ isGlobal: true, - load: [HealthDirectorateClientConfig, UniversityOfIcelandClientConfig], + load: [ + HealthDirectorateClientConfig, + UniversityOfIcelandClientConfig, + NationalRegistryClientConfig, + ], }), ], providers: [HealthcareWorkPermitService], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 5c0996635cc9..0342fed8f9b1 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -12,7 +12,6 @@ import { } from '@island.is/application/templates/healthcare-work-permit' import { HealthDirectorateClientService, - NamsUpplysingar, StarfsleyfiUmsoknStarfsleyfi, UtbuaStarfsleyfiSkjalResponse, } from '@island.is/clients/health-directorate' @@ -21,6 +20,7 @@ import { UniversityOfIcelandService, } from '@island.is/clients/university-of-iceland' import { TemplateApiError } from '@island.is/nest/problem' +import { NationalRegistryService } from '../../shared/api/national-registry/national-registry.service' @Injectable() export class HealthcareWorkPermitService extends BaseTemplateApiService { @@ -28,10 +28,32 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { private readonly sharedTemplateAPIService: SharedTemplateApiService, private readonly healthDirectorateClientService: HealthDirectorateClientService, private readonly universityOfIcelandService: UniversityOfIcelandService, + private readonly nationalRegistryService: NationalRegistryService, ) { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) } + async getNationalRegistryWithEESValidation({ + auth, + }: TemplateApiModuleActionProps): Promise { + const result = await this.nationalRegistryService.getIndividual( + auth.nationalId, + ) + + // TODO Double check if this fails on empty response + if (!result) { + throw new TemplateApiError( + { + title: errorMsg.healthcareLicenseErrorTitle, + summary: errorMsg.healthcareLicenseErrorMessage, + }, + 400, + ) + } + + return result + } + async getMyHealthcareLicenses({ auth, }: TemplateApiModuleActionProps): Promise { @@ -57,14 +79,12 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async getEducationInfo({ auth, }: TemplateApiModuleActionProps): Promise { - const academicCareer: Transcripts | null = - await this.universityOfIcelandService.studentInfo(auth) - const educationTracks: NamsUpplysingar[] = + const result = await this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( auth, ) - if (!educationTracks || !academicCareer) { + if (!result) { throw new TemplateApiError( { title: errorMsg.healthcareLicenseErrorTitle, @@ -74,21 +94,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } - // TODO Here I need to make sure that at least some of the users academic career exist in the workpermit educational info list in order - // to make it to the next step. - // const educationShortIdMap: { [shortId: string]: boolean } = {}; - // academicCareer?.transcripts?.forEach(edu => { - // educationShortIdMap[edu.shortId] = true; - // }); - - // // Match transcripts with education that gives a work permit - // const matchedTranscripts: Transcripts = academicCareer?.transcripts?.filter(transcript => { - // return transcript.shortId in educationShortIdMap; - // }); - - // console.log("Matched Transcripts:", matchedTranscripts); - - return educationTracks + return result } async getMyAcademicCareer({ diff --git a/libs/application/templates/healthcare-work-permit/EES.ts b/libs/application/templates/healthcare-work-permit/EES.ts new file mode 100644 index 000000000000..450ef7a8a694 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/EES.ts @@ -0,0 +1,336 @@ +export const EES = [ + { + name: 'Austria', + topLevelDomain: ['.at'], + alpha2Code: 'AT', + alpha3Code: 'AUT', + callingCodes: ['43'], + capital: 'Vienna', + altSpellings: ['AT', 'Österreich', 'Osterreich', 'Oesterreich'], + region: 'Europe', + }, + { + name: 'Belgium', + topLevelDomain: ['.be'], + alpha2Code: 'BE', + alpha3Code: 'BEL', + callingCodes: ['32'], + capital: 'Brussels', + altSpellings: [ + 'BE', + 'België', + 'Belgie', + 'Belgien', + 'Belgique', + 'Kingdom of Belgium', + 'Koninkrijk België', + 'Royaume de Belgique', + 'Königreich Belgien', + ], + region: 'Europe', + }, + { + name: 'Bulgaria', + topLevelDomain: ['.bg'], + alpha2Code: 'BG', + alpha3Code: 'BGR', + callingCodes: ['359'], + capital: 'Sofia', + altSpellings: ['BG', 'Republic of Bulgaria', 'Република България'], + region: 'Europe', + }, + { + name: 'Croatia', + topLevelDomain: ['.hr'], + alpha2Code: 'HR', + alpha3Code: 'HRV', + callingCodes: ['385'], + capital: 'Zagreb', + altSpellings: [ + 'HR', + 'Hrvatska', + 'Republic of Croatia', + 'Republika Hrvatska', + ], + region: 'Europe', + }, + { + name: 'Czech Republic', + topLevelDomain: ['.cz'], + alpha2Code: 'CZ', + alpha3Code: 'CZE', + callingCodes: ['420'], + capital: 'Prague', + altSpellings: ['CZ', 'Česká republika', 'Česko'], + region: 'Europe', + }, + { + name: 'Denmark', + topLevelDomain: ['.dk'], + alpha2Code: 'DK', + alpha3Code: 'DNK', + callingCodes: ['45'], + capital: 'Copenhagen', + altSpellings: ['DK', 'Danmark', 'Kingdom of Denmark', 'Kongeriget Danmark'], + region: 'Europe', + }, + { + name: 'Estonia', + topLevelDomain: ['.ee'], + alpha2Code: 'EE', + alpha3Code: 'EST', + callingCodes: ['372'], + capital: 'Tallinn', + altSpellings: ['EE', 'Eesti', 'Republic of Estonia', 'Eesti Vabariik'], + region: 'Europe', + }, + { + name: 'Finland', + topLevelDomain: ['.fi'], + alpha2Code: 'FI', + alpha3Code: 'FIN', + callingCodes: ['358'], + capital: 'Helsinki', + altSpellings: [ + 'FI', + 'Suomi', + 'Republic of Finland', + 'Suomen tasavalta', + 'Republiken Finland', + ], + region: 'Europe', + }, + { + name: 'France', + topLevelDomain: ['.fr'], + alpha2Code: 'FR', + alpha3Code: 'FRA', + callingCodes: ['33'], + capital: 'Paris', + altSpellings: ['FR', 'French Republic', 'République française'], + region: 'Europe', + }, + { + name: 'Germany', + topLevelDomain: ['.de'], + alpha2Code: 'DE', + alpha3Code: 'DEU', + callingCodes: ['49'], + capital: 'Berlin', + altSpellings: [ + 'DE', + 'Federal Republic of Germany', + 'Bundesrepublik Deutschland', + ], + region: 'Europe', + }, + { + name: 'Greece', + topLevelDomain: ['.gr'], + alpha2Code: 'GR', + alpha3Code: 'GRC', + callingCodes: ['30'], + capital: 'Athens', + altSpellings: ['GR', 'Elláda', 'Hellenic Republic', 'Ελληνική Δημοκρατία'], + region: 'Europe', + }, + { + name: 'Hungary', + topLevelDomain: ['.hu'], + alpha2Code: 'HU', + alpha3Code: 'HUN', + callingCodes: ['36'], + capital: 'Budapest', + altSpellings: ['HU'], + region: 'Europe', + }, + { + name: 'Italy', + topLevelDomain: ['.it'], + alpha2Code: 'IT', + alpha3Code: 'ITA', + callingCodes: ['39'], + capital: 'Rome', + altSpellings: ['IT', 'Italian Republic', 'Repubblica italiana'], + region: 'Europe', + }, + { + name: 'Latvia', + topLevelDomain: ['.lv'], + alpha2Code: 'LV', + alpha3Code: 'LVA', + callingCodes: ['371'], + capital: 'Riga', + altSpellings: ['LV', 'Republic of Latvia', 'Latvijas Republika'], + region: 'Europe', + }, + { + name: 'Liechtenstein', + topLevelDomain: ['.li'], + alpha2Code: 'LI', + alpha3Code: 'LIE', + callingCodes: ['423'], + capital: 'Vaduz', + altSpellings: [ + 'LI', + 'Principality of Liechtenstein', + 'Fürstentum Liechtenstein', + ], + region: 'Europe', + }, + { + name: 'Lithuania', + topLevelDomain: ['.lt'], + alpha2Code: 'LT', + alpha3Code: 'LTU', + callingCodes: ['370'], + capital: 'Vilnius', + altSpellings: ['LT', 'Republic of Lithuania', 'Lietuvos Respublika'], + region: 'Europe', + }, + { + name: 'Luxembourg', + topLevelDomain: ['.lu'], + alpha2Code: 'LU', + alpha3Code: 'LUX', + callingCodes: ['352'], + capital: 'Luxembourg', + altSpellings: [ + 'LU', + 'Grand Duchy of Luxembourg', + 'Grand-Duché de Luxembourg', + 'Großherzogtum Luxemburg', + 'Groussherzogtum Lëtzebuerg', + ], + region: 'Europe', + }, + { + name: 'Malta', + topLevelDomain: ['.mt'], + alpha2Code: 'MT', + alpha3Code: 'MLT', + callingCodes: ['356'], + capital: 'Valletta', + altSpellings: ['MT', 'Republic of Malta', "Repubblika ta' Malta"], + region: 'Europe', + }, + { + name: 'Netherlands', + topLevelDomain: ['.nl'], + alpha2Code: 'NL', + alpha3Code: 'NLD', + callingCodes: ['31'], + capital: 'Amsterdam', + altSpellings: ['NL', 'Holland', 'Nederland'], + region: 'Europe', + }, + { + name: 'Norway', + topLevelDomain: ['.no'], + alpha2Code: 'NO', + alpha3Code: 'NOR', + callingCodes: ['47'], + capital: 'Oslo', + altSpellings: [ + 'NO', + 'Norge', + 'Noreg', + 'Kingdom of Norway', + 'Kongeriket Norge', + 'Kongeriket Noreg', + ], + region: 'Europe', + }, + { + name: 'Poland', + topLevelDomain: ['.pl'], + alpha2Code: 'PL', + alpha3Code: 'POL', + callingCodes: ['48'], + capital: 'Warsaw', + altSpellings: ['PL', 'Republic of Poland', 'Rzeczpospolita Polska'], + region: 'Europe', + }, + { + name: 'Portugal', + topLevelDomain: ['.pt'], + alpha2Code: 'PT', + alpha3Code: 'PRT', + callingCodes: ['351'], + capital: 'Lisbon', + altSpellings: [ + 'PT', + 'Portuguesa', + 'Portuguese Republic', + 'República Portuguesa', + ], + region: 'Europe', + }, + { + name: 'Romania', + topLevelDomain: ['.ro'], + alpha2Code: 'RO', + alpha3Code: 'ROU', + callingCodes: ['40'], + capital: 'Bucharest', + altSpellings: ['RO', 'Rumania', 'Roumania', 'România'], + region: 'Europe', + }, + { + name: 'Slovakia', + topLevelDomain: ['.sk'], + alpha2Code: 'SK', + alpha3Code: 'SVK', + callingCodes: ['421'], + capital: 'Bratislava', + altSpellings: ['SK', 'Slovak Republic', 'Slovenská republika'], + region: 'Europe', + }, + { + name: 'Slovenia', + topLevelDomain: ['.si'], + alpha2Code: 'SI', + alpha3Code: 'SVN', + callingCodes: ['386'], + capital: 'Ljubljana', + altSpellings: ['SI', 'Republic of Slovenia', 'Republika Slovenija'], + region: 'Europe', + }, + { + name: 'Spain', + topLevelDomain: ['.es'], + alpha2Code: 'ES', + alpha3Code: 'ESP', + callingCodes: ['34'], + capital: 'Madrid', + altSpellings: ['ES', 'Kingdom of Spain', 'Reino de España'], + region: 'Europe', + }, + { + name: 'Sweden', + topLevelDomain: ['.se'], + alpha2Code: 'SE', + alpha3Code: 'SWE', + callingCodes: ['46'], + capital: 'Stockholm', + altSpellings: ['SE', 'Kingdom of Sweden', 'Konungariket Sverige'], + region: 'Europe', + }, + { + name: 'Switzerland', + topLevelDomain: ['.ch'], + alpha2Code: 'CH', + alpha3Code: 'CHE', + callingCodes: ['41'], + capital: 'Bern', + altSpellings: [ + 'CH', + 'Swiss Confederation', + 'Schweiz', + 'Suisse', + 'Svizzera', + 'Svizra', + ], + region: 'Europe', + }, +] diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index 63b7a2f4cbd5..850e1a4c2a87 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -58,11 +58,7 @@ export const Prerequisites: Form = buildForm({ }), dataProviders: [ buildDataProviderItem({ - provider: NationalRegistryUserApi.configure({ - params: { - icelandicCitizenship: true, - }, - }), + provider: NationalRegistryUserApi, title: externalData.nationalRegistry.title, subTitle: externalData.nationalRegistry.subTitle, }), diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index cb76af56363d..c3d8817de1c6 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -82,11 +82,7 @@ const template: ApplicationTemplate< write: 'all', delete: true, api: [ - NationalRegistryUserApi.configure({ - params: { - // Add is part of EES - }, - }), + NationalRegistryUserApi, UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, UniversityOfIcelandApi, From 7fa0bbff9bcf3a3b7c2513780cee582a0cb0eae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 21 May 2024 09:05:29 +0000 Subject: [PATCH 08/30] Commenting out code to get project to build --- .../healthcare-work-permit.module.ts | 21 +++----- .../healthcare-work-permit.service.ts | 53 +++++++++++-------- .../lib/healthDirectorateClient.service.ts | 1 + 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts index 49d259f91269..d4d7d468115f 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -8,13 +8,10 @@ import { HealthDirectorateClientConfig, } from '@island.is/clients/health-directorate' import { - UniversityOfIcelandClientConfig, - UniversityOfIcelandClientModule, -} from '@island.is/clients/university-of-iceland' -import { - NationalRegistryClientConfig, - NationalRegistryClientModule, -} from '@island.is/clients/national-registry-v2' + NationalRegistryV3ClientConfig, + NationalRegistryV3ClientModule, +} from '@island.is/clients/national-registry-v3' +import { UniversityCareersClientModule } from '@island.is/clients/university-careers' export class HealthcareWorkPermitModule { static register(baseConfig: BaseTemplateAPIModuleConfig): DynamicModule { @@ -23,15 +20,11 @@ export class HealthcareWorkPermitModule { imports: [ SharedTemplateAPIModule.register(baseConfig), HealthDirectorateClientModule, - UniversityOfIcelandClientModule, - NationalRegistryClientModule, + NationalRegistryV3ClientModule, + // UniversityCareersClientModule, ConfigModule.forRoot({ isGlobal: true, - load: [ - HealthDirectorateClientConfig, - UniversityOfIcelandClientConfig, - NationalRegistryClientConfig, - ], + load: [HealthDirectorateClientConfig, NationalRegistryV3ClientConfig], }), ], providers: [HealthcareWorkPermitService], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 0342fed8f9b1..9fa3e44507d1 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -15,28 +15,31 @@ import { StarfsleyfiUmsoknStarfsleyfi, UtbuaStarfsleyfiSkjalResponse, } from '@island.is/clients/health-directorate' -import { - Transcripts, - UniversityOfIcelandService, -} from '@island.is/clients/university-of-iceland' import { TemplateApiError } from '@island.is/nest/problem' -import { NationalRegistryService } from '../../shared/api/national-registry/national-registry.service' +import { + UniversityCareersClientService, + UniversityId, +} from '@island.is/clients/university-careers' +import { + EinstaklingurDTOAllt, + NationalRegistryV3ClientService, +} from '@island.is/clients/national-registry-v3' @Injectable() export class HealthcareWorkPermitService extends BaseTemplateApiService { constructor( private readonly sharedTemplateAPIService: SharedTemplateApiService, private readonly healthDirectorateClientService: HealthDirectorateClientService, - private readonly universityOfIcelandService: UniversityOfIcelandService, - private readonly nationalRegistryService: NationalRegistryService, + // private readonly universityCareersClientService: UniversityCareersClientService, + private readonly nationalRegistryService: NationalRegistryV3ClientService, ) { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) } async getNationalRegistryWithEESValidation({ auth, - }: TemplateApiModuleActionProps): Promise { - const result = await this.nationalRegistryService.getIndividual( + }: TemplateApiModuleActionProps): Promise { + const result = await this.nationalRegistryService.getAllDataIndividual( auth.nationalId, ) @@ -99,20 +102,24 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async getMyAcademicCareer({ auth, - }: TemplateApiModuleActionProps): Promise { - const result = await this.universityOfIcelandService.studentInfo(auth) - - if (!result) { - throw new TemplateApiError( - { - title: errorMsg.emptyCareerResponseTitle, - summary: errorMsg.emptyCareerResponseMessage, - }, - 400, - ) - } - - return result + }: TemplateApiModuleActionProps): Promise<[]> { + // const result = + // await this.universityCareersClientService.getStudentTrackHistory( + // auth, + // UniversityId.UNIVERSITY_OF_ICELAND, + // ) + + // if (!result) { + // throw new TemplateApiError( + // { + // title: errorMsg.emptyCareerResponseTitle, + // summary: errorMsg.emptyCareerResponseMessage, + // }, + // 400, + // ) + // } + + return [] } async submitApplication({ diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 7f47796ff376..d72fd94fdcfb 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -12,6 +12,7 @@ import { HealthcareLicense, HealthcareLicenseCertificate, HealthcareLicenseCertificateRequest, + HealthcareWorkPermitRequest, HealthDirectorateLicenseStatus, HealthDirectorateLicenseToPractice, } from './healthDirectorateClient.types' From b6e58d568e6cc00a97f9dfb8c919bc73dc4bdd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 21 May 2024 10:07:27 +0000 Subject: [PATCH 09/30] Comments, error messages, typing to get project to run after rebasing --- .../healthcare-work-permit.service.ts | 20 ++++++++++++++++--- .../fields/SelectWorkPermitField/index.tsx | 5 ++--- .../src/lib/messages/error.ts | 10 ++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 9fa3e44507d1..378cbecb6065 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -17,6 +17,7 @@ import { } from '@island.is/clients/health-directorate' import { TemplateApiError } from '@island.is/nest/problem' import { + StudentTrackDto, UniversityCareersClientService, UniversityId, } from '@island.is/clients/university-careers' @@ -30,7 +31,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { constructor( private readonly sharedTemplateAPIService: SharedTemplateApiService, private readonly healthDirectorateClientService: HealthDirectorateClientService, - // private readonly universityCareersClientService: UniversityCareersClientService, + //private readonly universityCareersClientService: UniversityCareersClientService, private readonly nationalRegistryService: NationalRegistryV3ClientService, ) { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) @@ -43,7 +44,17 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { auth.nationalId, ) - // TODO Double check if this fails on empty response + // TODO Check if user has EES citizenship + // if(!hasEESCitizenship) { + // throw new TemplateApiError( + // { + // title: errorMsg.healthcareLicenseErrorTitle, + // summary: errorMsg.healthcareLicenseErrorMessage, + // }, + // 400, + // ) + // } + if (!result) { throw new TemplateApiError( { @@ -57,6 +68,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } + /* Which health care licenses does this user already have */ async getMyHealthcareLicenses({ auth, }: TemplateApiModuleActionProps): Promise { @@ -79,6 +91,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } + /* Info on different education programs that give work permit licenses */ async getEducationInfo({ auth, }: TemplateApiModuleActionProps): Promise { @@ -100,9 +113,10 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } + /* The academic career of the logged in uses. Used to find which programmes are valid for work permit */ async getMyAcademicCareer({ auth, - }: TemplateApiModuleActionProps): Promise<[]> { + }: TemplateApiModuleActionProps): Promise { // const result = // await this.universityCareersClientService.getStudentTrackHistory( // auth, diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx index 815f078441a9..426c719fd1cb 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx @@ -4,7 +4,6 @@ import { FC } from 'react' import { useLocale } from '@island.is/localization' import { RadioController } from '@island.is/shared/form-fields' import { information } from '../../lib/messages' -import { Transcripts } from '@island.is/clients/university-of-iceland' interface Option { value: string @@ -18,7 +17,7 @@ export const SelectWorkPermitField: FC< const { lang, formatMessage } = useLocale() const { application } = props - const workPermitOptions = (workPermits: Transcripts) => { + const workPermitOptions = (workPermits: any) => { const options: Option[] = [] for (const workPermit of workPermits.transcripts ?? []) { @@ -79,7 +78,7 @@ export const SelectWorkPermitField: FC< backgroundColor="blue" defaultValue={[]} options={workPermitOptions( - application?.externalData?.universityOfIceland?.data as Transcripts, + application?.externalData?.universityOfIceland?.data as any, )} /> diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts index 10da04a8f1b4..86fb8462ff54 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -46,4 +46,14 @@ export const error = defineMessages({ description: 'No response or faulty response when fetching info on education paths', }, + nationalRegistryOutsideEESErrorTitle: { + id: 'hlc.application:error.nationalRegistryOutsideEESErrorTitle', + defaultMessage: 'Þú ert ekki ríkisborgari innan EES', + description: 'You are not a citizen within EES', + }, + nationalRegistryOutsideEESErrorMessage: { + id: 'hlc.application:error.nationalRegistryOutsideEESErrorMessage', + defaultMessage: 'Lorem ipsum', + description: 'Lorem ipsum', + }, }) From b7f36a4c4aa427c9251fc3eeec5e009d3788a9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 28 May 2024 13:40:31 +0000 Subject: [PATCH 10/30] Logic work for work permits, cleanup and more --- .../healthcare-work-permit.module.ts | 21 +- .../healthcare-work-permit.service.ts | 393 ++++++++++++++++-- .../src/dataProviders/index.ts | 19 +- .../fields/SelectWorkPermitField/index.tsx | 74 ++-- .../personalSection.ts | 22 +- .../src/forms/Prerequisites/index.ts | 17 +- .../healthcare-work-permit/src/index.ts | 3 + .../src/lib/HealthcareWorkPermitTemplate.ts | 8 +- .../src/lib/messages/error.ts | 31 +- .../src/lib/messages/information.ts | 25 ++ .../src/lib/messages/personal.ts | 5 + .../src/shared/constants.ts | 1 + .../{ => src/utils}/EES.ts | 37 ++ .../university-careers/src/lib/dto/index.ts | 1 + .../src/lib/dto/studentTrackDto.ts | 1 + 15 files changed, 560 insertions(+), 98 deletions(-) rename libs/application/templates/healthcare-work-permit/{ => src/utils}/EES.ts (90%) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts index d4d7d468115f..c3a896019349 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -11,7 +11,14 @@ import { NationalRegistryV3ClientConfig, NationalRegistryV3ClientModule, } from '@island.is/clients/national-registry-v3' -import { UniversityCareersClientModule } from '@island.is/clients/university-careers' +import { + AgriculturalUniversityOfIcelandCareerClientConfig, + BifrostUniversityCareerClientConfig, + HolarUniversityCareerClientConfig, + UniversityCareersClientModule, + UniversityOfAkureyriCareerClientConfig, + UniversityOfIcelandCareerClientConfig, +} from '@island.is/clients/university-careers' export class HealthcareWorkPermitModule { static register(baseConfig: BaseTemplateAPIModuleConfig): DynamicModule { @@ -21,10 +28,18 @@ export class HealthcareWorkPermitModule { SharedTemplateAPIModule.register(baseConfig), HealthDirectorateClientModule, NationalRegistryV3ClientModule, - // UniversityCareersClientModule, + UniversityCareersClientModule, ConfigModule.forRoot({ isGlobal: true, - load: [HealthDirectorateClientConfig, NationalRegistryV3ClientConfig], + load: [ + HealthDirectorateClientConfig, + NationalRegistryV3ClientConfig, + AgriculturalUniversityOfIcelandCareerClientConfig, + BifrostUniversityCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, + UniversityOfIcelandCareerClientConfig, + HolarUniversityCareerClientConfig, + ], }), ], providers: [HealthcareWorkPermitService], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 378cbecb6065..8185498321cc 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -7,31 +7,85 @@ import { NationalRegistryIndividual, } from '@island.is/application/types' import { + EES, HealthcareWorkPermitAnswers, error as errorMsg, + information, } from '@island.is/application/templates/healthcare-work-permit' import { HealthDirectorateClientService, + NamsUpplysingar, StarfsleyfiUmsoknStarfsleyfi, UtbuaStarfsleyfiSkjalResponse, } from '@island.is/clients/health-directorate' import { TemplateApiError } from '@island.is/nest/problem' import { StudentTrackDto, + StudentTrackInstitutionDto, UniversityCareersClientService, UniversityId, } from '@island.is/clients/university-careers' import { - EinstaklingurDTOAllt, + EinstaklingurDTOFaeding, + EinstaklingurDTOHeimili, + EinstaklingurDTONafnAllt, + EinstaklingurDTORikisfang, NationalRegistryV3ClientService, } from '@island.is/clients/national-registry-v3' +const isCitizenOfEES = (alpha2Code: string) => { + return EES.some((country) => country.alpha2Code === alpha2Code) +} + +interface Message { + id: string + defaultMessage: string + description: string +} + +export interface EinstaklingurDTO { + kennitala?: string | null + nafn?: string | null + heimilisfang?: EinstaklingurDTOHeimili + rikisfang?: EinstaklingurDTORikisfang + faedingarstadur?: EinstaklingurDTOFaeding + fulltNafn?: EinstaklingurDTONafnAllt +} + +interface PermitProgram { + name?: string + programId?: string + institution?: StudentTrackInstitutionDto + error?: boolean + errorMsg?: Message | string + professionId?: string + prereq?: StudentTrackDto // TODO Probably don't need this +} + +const getFoundationProgram = ( + professionId: string, + foundationPrograms: NamsUpplysingar[], +): NamsUpplysingar | undefined => { + return foundationPrograms?.find( + (foundationProgram) => foundationProgram.idProfession === professionId, + ) +} + +const getCareerFoundationProgram = ( + foundationProgram: NamsUpplysingar, + relevantCareerFoundationPrograms: StudentTrackDto[], +): StudentTrackDto | undefined => { + return relevantCareerFoundationPrograms.find( + (obj) => obj.programId === foundationProgram?.shortId, + ) +} + @Injectable() export class HealthcareWorkPermitService extends BaseTemplateApiService { constructor( private readonly sharedTemplateAPIService: SharedTemplateApiService, private readonly healthDirectorateClientService: HealthDirectorateClientService, - //private readonly universityCareersClientService: UniversityCareersClientService, + private readonly universityCareersClientService: UniversityCareersClientService, private readonly nationalRegistryService: NationalRegistryV3ClientService, ) { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) @@ -39,33 +93,52 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async getNationalRegistryWithEESValidation({ auth, - }: TemplateApiModuleActionProps): Promise { + }: TemplateApiModuleActionProps): Promise { const result = await this.nationalRegistryService.getAllDataIndividual( auth.nationalId, ) - // TODO Check if user has EES citizenship - // if(!hasEESCitizenship) { - // throw new TemplateApiError( - // { - // title: errorMsg.healthcareLicenseErrorTitle, - // summary: errorMsg.healthcareLicenseErrorMessage, - // }, - // 400, - // ) - // } - if (!result) { throw new TemplateApiError( { - title: errorMsg.healthcareLicenseErrorTitle, - summary: errorMsg.healthcareLicenseErrorMessage, + title: errorMsg.nationalRegistryFetchErrorTitle, + summary: errorMsg.nationalRegistryFetchErrorMessage, }, 400, ) } - return result + const hasEESCitizenship = isCitizenOfEES( + result?.rikisfang?.rikisfangKodi || '', + ) + + if (!hasEESCitizenship) { + throw new TemplateApiError( + { + title: errorMsg.nationalRegistryOutsideEESErrorTitle, + summary: errorMsg.nationalRegistryOutsideEESErrorMessage, + }, + + 400, + ) + } + + const { + fulltNafn, + heimilisfang, + rikisfang, + kennitala, + nafn, + faedingarstadur, + } = result + return { + fulltNafn, + heimilisfang, + rikisfang, + kennitala, + nafn, + faedingarstadur, + } } /* Which health care licenses does this user already have */ @@ -94,7 +167,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { /* Info on different education programs that give work permit licenses */ async getEducationInfo({ auth, - }: TemplateApiModuleActionProps): Promise { + }: TemplateApiModuleActionProps): Promise { const result = await this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( auth, @@ -103,7 +176,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { if (!result) { throw new TemplateApiError( { - title: errorMsg.healthcareLicenseErrorTitle, + title: errorMsg.noResponseEducationInfoTitle, summary: errorMsg.noResponseEducationInfoMessage, }, 400, @@ -117,23 +190,271 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async getMyAcademicCareer({ auth, }: TemplateApiModuleActionProps): Promise { - // const result = - // await this.universityCareersClientService.getStudentTrackHistory( - // auth, - // UniversityId.UNIVERSITY_OF_ICELAND, - // ) - - // if (!result) { - // throw new TemplateApiError( - // { - // title: errorMsg.emptyCareerResponseTitle, - // summary: errorMsg.emptyCareerResponseMessage, - // }, - // 400, - // ) - // } - - return [] + const result = + await this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_ICELAND, + ) + + if (!result) { + throw new TemplateApiError( + { + title: errorMsg.emptyCareerResponseTitle, + summary: errorMsg.emptyCareerResponseMessage, + }, + 400, + ) + } + + return result + } + + async processPermits({ + auth, + }: TemplateApiModuleActionProps): Promise { + const [licenses, programs, careerPrograms] = await Promise.all([ + this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( + auth, + ), + this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + auth, + ), + this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_ICELAND, + ), + ]) + + throw new TemplateApiError( + { + title: errorMsg.noResponseEducationInfoTitle, + summary: errorMsg.noResponseEducationInfoMessage, + }, + 400, + ) + if (!careerPrograms) { + throw new TemplateApiError( + { + title: errorMsg.emptyCareerResponseTitle, + summary: errorMsg.emptyCareerResponseMessage, + }, + 400, + ) + } + if (licenses === undefined) { + throw new TemplateApiError( + { + title: errorMsg.healthcareLicenseErrorTitle, + summary: errorMsg.healthcareLicenseErrorMessage, + }, + 400, + ) + } + + const studentTrackDto = [ + { + name: 'John Doe', + nationalId: '1234567890', + graduationDate: new Date('2024-01-15'), + trackNumber: 3, + institution: {}, + school: 'School of Science', + faculty: 'Faculty of Mathematics', + studyProgram: 'Sjúkraliði', + degree: 'Bachelor of Science', + programId: 'SJÚ441', + }, + { + name: 'John Doe', + nationalId: '1234567890', + graduationDate: new Date('2024-05-15'), + trackNumber: 3, + institution: {}, + school: 'School of Science', + faculty: 'Faculty of Mathematics', + studyProgram: 'Geislafræðingur', + degree: 'Bachelor of Science', + programId: 'GSL321', + }, + { + name: 'John Doe', + nationalId: '1234567890', + graduationDate: new Date('2024-05-15'), + trackNumber: 3, + institution: {}, + school: 'School of Science', + faculty: 'Faculty of Mathematics', + studyProgram: 'Hjúkrunafræðingur', + degree: 'Bachelor of Science', + programId: 'GSL260', + }, + { + name: 'John', + nationalId: '1234567890', + graduationDate: new Date('2024-05-15'), + trackNumber: 3, + institution: {}, + school: 'School of Science', + faculty: 'Faculty of Mathematics', + studyProgram: 'Ljósmóðir', + degree: 'Bachelor of Science', + programId: 'LJÓ443', + }, + ] as StudentTrackDto[] + + // Programs that give licenses to practice (permits) + const permitValidPrograms = programs?.filter((program) => { + return ( + (program.dataOrder === 1 && program.noOfData === 1) || + (program.dataOrder === 2 && program.noOfData === 2) + ) + }) + + // Programs that serve as Foundation for certain licenses (Hjúkrunfræði fyrir Ljósmóðir t.d) + const foundationPrograms = programs?.filter((program) => { + return program.dataOrder === 1 && program.noOfData === 2 + }) + + const validPermitIds = new Set( + permitValidPrograms?.map((item) => item.shortId), + ) + // Programs user has graduated that are viable for work permit + const relevantCareerPermitPrograms = studentTrackDto?.filter((program) => + validPermitIds.has(program.programId), + ) + const validFoundationProgramIds = new Set( + foundationPrograms?.map((item) => item.shortId), + ) + // Programs user has graduated that are needed as foundation for certain work permit (Nursing for Midwife f.x) + const relevantCareerFoundationPrograms = studentTrackDto?.filter( + (program) => validFoundationProgramIds.has(program.programId), + ) + + const programsToBeDisplayed = + relevantCareerPermitPrograms?.map((program) => { + const { programId, studyProgram, institution, graduationDate } = program + let currentPermitProgramProfessionId = '' + // Find the education program for this career program + const currentPermitProgram = permitValidPrograms?.find( + (permitProgram) => { + if (permitProgram.shortId === program.programId) { + currentPermitProgramProfessionId = + permitProgram.idProfession || '' + return true + } + return false + }, + ) + + // Checking if user already has a license with the same professionId + const license = licenses?.find( + (item) => item.idProfession === currentPermitProgramProfessionId, + ) + if (license) { + return { + name: studyProgram, + programId, + institution, + professionId: currentPermitProgramProfessionId, + error: true, + errorMsg: + information.labels.selectWorkPermit.restrictionAlreadyHasLicense, + } + } + + if (currentPermitProgram?.noOfData === 2) { + // Work permit requires some foundational program to qualify for work permit + const currentFoundationProgram = getFoundationProgram( + currentPermitProgramProfessionId, + foundationPrograms || [], + ) + const currentFoundationCareerProgram = getCareerFoundationProgram( + currentFoundationProgram || {}, + relevantCareerFoundationPrograms || [], + ) + + if (!currentFoundationCareerProgram) { + return { + name: studyProgram, + programId, + institution, + professionId: currentPermitProgramProfessionId, + error: true, + errorMsg: + information.labels.selectWorkPermit + .restrictionFoundationMissing, + } + } + if ( + !currentFoundationCareerProgram?.graduationDate || + !currentFoundationProgram?.educationValidFrom + ) { + return { + name: studyProgram, + programId, + institution, + professionId: currentPermitProgramProfessionId, + error: true, + errorMsg: + information.labels.selectWorkPermit.restrictionDataError, + } + } else { + if ( + currentFoundationCareerProgram?.graduationDate < + new Date(currentFoundationProgram?.educationValidFrom) + ) { + return { + name: studyProgram, + programId, + institution, + professionId: currentPermitProgramProfessionId, + error: true, + errorMsg: + information.labels.selectWorkPermit.restrictionDataError, + } + } + } + } + let error = true + let errorMsg: string | Message = '' + // This program give permit on its own. + if (!graduationDate || !currentPermitProgram?.educationValidFrom) { + error = true + errorMsg = information.labels.selectWorkPermit.restrictionDataError + } else { + const validDate = + graduationDate > new Date(currentPermitProgram?.educationValidFrom) + if (validDate) { + error = false + errorMsg = '' + } else { + error = true + errorMsg = + information.labels.selectWorkPermit.restrictionGraduationDate + } + } + + return { + name: studyProgram, + programId, + institution, + professionId: currentPermitProgramProfessionId, + error, + errorMsg, + } + }) || [] + + if (programsToBeDisplayed.length === 0) { + throw new TemplateApiError( + { + title: errorMsg.noPermitValidGraduationFoundTitle, + summary: errorMsg.noPermitValidGraduationFoundMessage, + }, + 400, + ) + } + + return programsToBeDisplayed } async submitApplication({ diff --git a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts index 6bb2a888db98..2ee4d3844b32 100644 --- a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts @@ -5,10 +5,7 @@ import { } from '@island.is/application/types' import { ApiActions } from '../shared' -export { - NationalRegistryUserApi, - UserProfileApi, -} from '@island.is/application/types' +export { UserProfileApi } from '@island.is/application/types' export const EmbaettiLandlaeknisPaymentCatalogApi = PaymentCatalogApi.configure( { @@ -24,12 +21,22 @@ export const HealtcareLicenesApi = defineTemplateApi({ externalDataId: 'healthcareLicenses', }) -export const UniversityOfIcelandApi = defineTemplateApi({ +export const UniversityCareersApi = defineTemplateApi({ action: ApiActions.getMyAcademicCareer, - externalDataId: 'universityOfIceland', + externalDataId: 'universityCareer', +}) + +export const ProcessPermitsApi = defineTemplateApi({ + action: ApiActions.processPermits, + externalDataId: 'permitOptions', }) export const EducationInfoApi = defineTemplateApi({ action: ApiActions.getEducationInfo, externalDataId: 'educationInfo', }) + +export const NationalRegistryUserApi = defineTemplateApi({ + action: ApiActions.getNationalRegistryWithEESValidation, + externalDataId: 'nationalRegistry', +}) diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx index 426c719fd1cb..7c0456ca27cc 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx @@ -1,9 +1,14 @@ -import { FieldBaseProps } from '@island.is/application/types' -import { AlertMessage, Box, Text } from '@island.is/island-ui/core' -import { FC } from 'react' +import { FieldBaseProps, FormatMessage } from '@island.is/application/types' +import { Box, Text } from '@island.is/island-ui/core' +import { FC, useEffect, useState } from 'react' import { useLocale } from '@island.is/localization' import { RadioController } from '@island.is/shared/form-fields' import { information } from '../../lib/messages' +import { + StudentTrackDto, + StudentTrackInstitutionDto, +} from '@island.is/clients/university-careers' +import { MessageDescriptor } from 'react-intl' interface Option { value: string @@ -11,49 +16,48 @@ interface Option { disabled?: boolean } +interface Message { + id: string + defaultMessage: string + description: string +} + +interface PermitProgram { + name?: string + programId?: string + institution?: StudentTrackInstitutionDto + error?: boolean + errorMsg?: Message | string + professionId?: string + prereq?: StudentTrackDto // TODO Probably don't need this +} + export const SelectWorkPermitField: FC< React.PropsWithChildren > = (props) => { const { lang, formatMessage } = useLocale() const { application } = props - const workPermitOptions = (workPermits: any) => { + const workPermitOptions = (workPermits: PermitProgram[]) => { const options: Option[] = [] - for (const workPermit of workPermits.transcripts ?? []) { - const disabled = false + for (const permitProgram of workPermits) { + const disabled = permitProgram.error + const formattedErrorMsg = formatMessage( + permitProgram.errorMsg as MessageDescriptor, + ) options.push({ - value: `${workPermit.studyProgram}`, + value: `${permitProgram.name}`, label: ( - {lang === 'is' - ? workPermit.studyProgram - : workPermit.studyProgram} + {`${lang === 'is' ? permitProgram.name : permitProgram.name}${ + disabled ? ` (${formattedErrorMsg})` : '' + }`} - {disabled && ( - - - - {formatMessage( - information.labels.selectWorkPermit - .restrictionAlertMessage, - )} - - - } - /> - - )} ), disabled: disabled, @@ -62,6 +66,10 @@ export const SelectWorkPermitField: FC< return options } + useEffect(() => { + props.setSubmitButtonDisabled && props.setSubmitButtonDisabled(true) + }, []) + return ( + props.setSubmitButtonDisabled && props.setSubmitButtonDisabled(false) + } /> ) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts index 9d20b7f9ac67..92151e6c7ba0 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts @@ -30,7 +30,7 @@ export const PersonalSection = buildSection({ readOnly: true, format: '######-####', defaultValue: (application: Application) => - application.externalData?.nationalRegistry?.data?.nationalId, + application.externalData?.nationalRegistry?.data?.kennitala, }), buildTextField({ id: 'userInformation.name', @@ -39,7 +39,8 @@ export const PersonalSection = buildSection({ width: 'half', readOnly: true, defaultValue: (application: Application) => - application.externalData?.nationalRegistry?.data?.fullName, + application.externalData?.nationalRegistry?.data?.fulltNafn + ?.fulltNafn, }), buildTextField({ id: 'userInformation.birthDate', @@ -49,15 +50,26 @@ export const PersonalSection = buildSection({ readOnly: true, defaultValue: (application: Application) => formatDate( - application.externalData?.nationalRegistry?.data?.birthDate, + application.externalData?.nationalRegistry?.data?.faedingarstadur + ?.faedingarDagur, ), }), + buildTextField({ + id: 'userInformation.birthDate', + title: personal.labels.userInformation.citizenship, + backgroundColor: 'white', + width: 'half', + readOnly: true, + defaultValue: (application: Application) => + application.externalData?.nationalRegistry?.data?.rikisfang + ?.rikisfangLand, + }), buildTextField({ id: 'userInformation.email', title: personal.labels.userInformation.email, width: 'half', variant: 'email', - required: true, + readOnly: true, defaultValue: (application: Application) => application.externalData?.userProfile?.data?.email, }), @@ -66,7 +78,7 @@ export const PersonalSection = buildSection({ title: personal.labels.userInformation.phone, width: 'half', backgroundColor: 'blue', - required: true, + readOnly: true, defaultValue: (application: Application) => application.externalData?.userProfile?.data?.mobilePhoneNumber, }), diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index 850e1a4c2a87..8b8875ff47b8 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -6,12 +6,7 @@ import { buildSubmitField, coreMessages, } from '@island.is/application/core' -import { - DefaultEvents, - Form, - FormModes, - NationalRegistryUserApi, -} from '@island.is/application/types' +import { DefaultEvents, Form, FormModes } from '@island.is/application/types' import { confirmation, externalData, @@ -23,8 +18,10 @@ import { EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, UserProfileApi, - UniversityOfIcelandApi, + UniversityCareersApi, EducationInfoApi, + NationalRegistryUserApi, + ProcessPermitsApi, } from '../../dataProviders' export const Prerequisites: Form = buildForm({ @@ -68,12 +65,10 @@ export const Prerequisites: Form = buildForm({ subTitle: externalData.userProfile.subTitle, }), buildDataProviderItem({ - provider: HealtcareLicenesApi, title: externalData.healtcareLicenses.title, subTitle: externalData.healtcareLicenses.subTitle, }), buildDataProviderItem({ - provider: UniversityOfIcelandApi, title: externalData.universityOfIceland.title, subTitle: externalData.universityOfIceland.subTitle, }), @@ -81,6 +76,10 @@ export const Prerequisites: Form = buildForm({ provider: EmbaettiLandlaeknisPaymentCatalogApi, title: '', }), + buildDataProviderItem({ + provider: ProcessPermitsApi, + title: '', + }), buildDataProviderItem({ provider: EducationInfoApi, title: '', diff --git a/libs/application/templates/healthcare-work-permit/src/index.ts b/libs/application/templates/healthcare-work-permit/src/index.ts index 245438da20e4..b5f710782e5b 100644 --- a/libs/application/templates/healthcare-work-permit/src/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/index.ts @@ -10,5 +10,8 @@ export * from './utils' export * from './lib/messages/externalData' export * from './lib/messages/error' +export * from './lib/messages/information' export default template + +export { EES } from './utils/EES' diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index c3d8817de1c6..1806c16289e7 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -9,7 +9,6 @@ import { DefaultEvents, defineTemplateApi, InstitutionNationalIds, - NationalRegistryUserApi, } from '@island.is/application/types' import { EphemeralStateLifeCycle, @@ -25,8 +24,10 @@ import { UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, - UniversityOfIcelandApi, + UniversityCareersApi, EducationInfoApi, + NationalRegistryUserApi, + ProcessPermitsApi, } from '../dataProviders' import { buildPaymentState } from '@island.is/application/utils' import { HealthcareWorkPermitSchema } from './dataSchema' @@ -85,9 +86,10 @@ const template: ApplicationTemplate< NationalRegistryUserApi, UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, - UniversityOfIcelandApi, + UniversityCareersApi, HealtcareLicenesApi, EducationInfoApi, + ProcessPermitsApi, ], }, ], diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts index 86fb8462ff54..04f827eee6d2 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -35,16 +35,16 @@ export const error = defineMessages({ healthcareLicenseErrorTitle: { id: 'hlc.application:error.healthcareLicenseErrorTitle', defaultMessage: - 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: - 'No response or faulty response when fetching info on education paths', + 'No response or faulty response when fetching info on healthcare licenses', }, healthcareLicenseErrorMessage: { id: 'hlc.application:error.healthcareLicenseErrorMessage', defaultMessage: 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: - 'No response or faulty response when fetching info on education paths', + 'No response or faulty response when fetching healthcare licenses', }, nationalRegistryOutsideEESErrorTitle: { id: 'hlc.application:error.nationalRegistryOutsideEESErrorTitle', @@ -53,7 +53,30 @@ export const error = defineMessages({ }, nationalRegistryOutsideEESErrorMessage: { id: 'hlc.application:error.nationalRegistryOutsideEESErrorMessage', + defaultMessage: 'Þú ert ekki ríkisborgari innan EES', + description: 'You are not a citizen within EES', + }, + nationalRegistryFetchErrorTitle: { + id: 'hlc.application:error.nationalRegistryFetchErrorTitle', + defaultMessage: + 'Ekki tókst að sækja gögn frá þjóðskrá, vinsamlegast prufaðu aftur seinna', + description: + 'No response or faulty response when fetching info on current user from nation registry', + }, + nationalRegistryFetchErrorMessage: { + id: 'hlc.application:error.nationalRegistryFetchErrorMessage', defaultMessage: 'Lorem ipsum', - description: 'Lorem ipsum', + description: + 'No response or faulty response when fetching info on current user from nation registry', + }, + noPermitValidGraduationFoundTitle: { + id: 'hlc.application:error.noPermitValidGraduationFoundTitle', + defaultMessage: 'Ekki fundust brautskráningar sem gefa starfsleyfi', + description: 'No graduated programs found that are valid form work permit', + }, + noPermitValidGraduationFoundMessage: { + id: 'hlc.application:error.noPermitValidGraduationFoundMessage', + defaultMessage: 'Ekki fundust brautskráningar sem gefa starfsleyfi', + description: 'No graduated programs found that are valid form work permit', }, }) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts index 5e36ea626948..a27bcb74e403 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts @@ -47,6 +47,31 @@ export const information = { 'Vinsamlega sendið póst á starfsleyfi@landlaeknir.is ef frekari upplýsingar óskast', description: 'Select work permit restriction alert message', }, + restrictionGraduationDate: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionGraduationDate', + defaultMessage: + 'Prófgráða er of gömul. Ekki er hægt að veita starfsleyfi', + description: + 'Select work permit restriction message, graduation date too old', + }, + restrictionFoundationMissing: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionFoundationMissing', + defaultMessage: 'Ekki fannst grunnnám', + description: + 'Select work permit restriction message, graduation date too old', + }, + restrictionDataError: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionDataError', + defaultMessage: 'Villa í gögnum, engin dagsetning fannst', + description: + 'Select work permit restriction message, graduation date too old', + }, + restrictionAlreadyHasLicense: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionAlreadyHasLicense', + defaultMessage: 'Þegar útgefið', + description: + 'Select work permit restriction message, user already has this license', + }, infoMessage: { id: 'hwp.application:information.labels.selectWorkPermit.infoMessage', defaultMessage: diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts index 4cc68bce0075..06a53f3825e4 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/personal.ts @@ -35,6 +35,11 @@ export const personal = { defaultMessage: 'Fæðingardagur', description: 'User information birth date label', }, + citizenship: { + id: 'hwp.application:personal.labels.userInformation.citizenship', + defaultMessage: 'Fæðingarstaður', + description: 'User information birth place label', + }, email: { id: 'hwp.application:personal.labels.userInformation.email', defaultMessage: 'Netfang', diff --git a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts index 13bff425a788..5851aec2decf 100644 --- a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts +++ b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts @@ -4,4 +4,5 @@ export enum ApiActions { getMyAcademicCareer = 'getMyAcademicCareer', getEducationInfo = 'getEducationInfo', getNationalRegistryWithEESValidation = 'getNationalRegistryWithEESValidation', + processPermits = 'processPermits', } diff --git a/libs/application/templates/healthcare-work-permit/EES.ts b/libs/application/templates/healthcare-work-permit/src/utils/EES.ts similarity index 90% rename from libs/application/templates/healthcare-work-permit/EES.ts rename to libs/application/templates/healthcare-work-permit/src/utils/EES.ts index 450ef7a8a694..9115ce483d51 100644 --- a/libs/application/templates/healthcare-work-permit/EES.ts +++ b/libs/application/templates/healthcare-work-permit/src/utils/EES.ts @@ -39,6 +39,23 @@ export const EES = [ altSpellings: ['BG', 'Republic of Bulgaria', 'Република България'], region: 'Europe', }, + { + name: 'Cyprus', + topLevelDomain: ['.cy'], + alpha2Code: 'CY', + alpha3Code: 'CYP', + callingCodes: ['357'], + capital: 'Nicosia', + altSpellings: [ + 'CY', + 'Kýpros', + 'Kıbrıs', + 'Republic of Cyprus', + 'Κυπριακή Δημοκρατία', + 'Kıbrıs Cumhuriyeti', + ], + region: 'Europe', + }, { name: 'Croatia', topLevelDomain: ['.hr'], @@ -144,6 +161,26 @@ export const EES = [ altSpellings: ['HU'], region: 'Europe', }, + { + name: 'Iceland', + topLevelDomain: ['.is'], + alpha2Code: 'IS', + alpha3Code: 'ISL', + callingCodes: ['354'], + capital: 'Reykjavik', + altSpellings: ['Ísland', 'IS'], + region: 'Europe', + }, + { + name: 'Ireland', + topLevelDomain: ['.ie'], + alpha2Code: 'IE', + alpha3Code: 'IRL', + callingCodes: ['353'], + capital: 'Dublin', + altSpellings: ['IE', 'Éire', 'Republic of Ireland', 'Poblacht na hÉireann'], + region: 'Europe', + }, { name: 'Italy', topLevelDomain: ['.it'], diff --git a/libs/clients/university-careers/src/lib/dto/index.ts b/libs/clients/university-careers/src/lib/dto/index.ts index 1b554446f011..0d3816c0be61 100644 --- a/libs/clients/university-careers/src/lib/dto/index.ts +++ b/libs/clients/university-careers/src/lib/dto/index.ts @@ -1,3 +1,4 @@ export { StudentTrackDto } from './studentTrackDto' +export { StudentTrackInstitutionDto } from './studentTrackInstitutionDto' export { StudentTrackOverviewBodyDto } from './studentTrackOverviewBodyDto' export { StudentTrackOverviewDto } from './studentTrackOverviewDto' diff --git a/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts b/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts index 060df61ab33a..b012dff995e0 100644 --- a/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts +++ b/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts @@ -21,6 +21,7 @@ export interface StudentTrackDto { faculty?: string studyProgram?: string degree?: string + programId?: string } export const mapToStudentTrackDto = ( From 4936e373cbcb7261fd7296615ac7a58a98e2180b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 4 Jun 2024 10:29:35 +0000 Subject: [PATCH 11/30] Work permit application progress --- .../healthcare-work-permit.service.ts | 282 ++++++++++++------ .../index.tsx | 128 ++++++++ .../styles.css.ts | 0 .../index.tsx | 24 -- .../fields/SelectWorkPermitField/index.tsx | 6 +- .../src/fields/index.ts | 3 +- .../selectWorkPermitSection.ts | 54 +++- .../src/forms/Prerequisites/index.ts | 2 +- .../healthcare-work-permit/src/index.ts | 1 + .../src/lib/dataSchema.ts | 3 +- .../healthcare-work-permit/src/lib/index.ts | 1 + .../src/lib/messages/error.ts | 16 +- .../src/lib/messages/information.ts | 2 +- .../healthcare-work-permit/src/lib/types.ts | 17 ++ .../src/utils/getChargeItemCodes.ts | 12 +- 15 files changed, 416 insertions(+), 135 deletions(-) create mode 100644 libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx rename libs/application/templates/healthcare-work-permit/src/fields/{CustomFormConclusionSelectionField => CustomFormConclusionSectionField}/styles.css.ts (100%) delete mode 100644 libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/index.ts create mode 100644 libs/application/templates/healthcare-work-permit/src/lib/types.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 8185498321cc..e3209145d80c 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -2,18 +2,18 @@ import { Injectable } from '@nestjs/common' import { SharedTemplateApiService } from '../../shared' import { TemplateApiModuleActionProps } from '../../../types' import { BaseTemplateApiService } from '../../base-template-api.service' -import { - ApplicationTypes, - NationalRegistryIndividual, -} from '@island.is/application/types' +import { ApplicationTypes } from '@island.is/application/types' import { EES, HealthcareWorkPermitAnswers, + PermitProgram, + Message, error as errorMsg, information, } from '@island.is/application/templates/healthcare-work-permit' import { HealthDirectorateClientService, + Nam, NamsUpplysingar, StarfsleyfiUmsoknStarfsleyfi, UtbuaStarfsleyfiSkjalResponse, @@ -21,7 +21,6 @@ import { import { TemplateApiError } from '@island.is/nest/problem' import { StudentTrackDto, - StudentTrackInstitutionDto, UniversityCareersClientService, UniversityId, } from '@island.is/clients/university-careers' @@ -37,12 +36,6 @@ const isCitizenOfEES = (alpha2Code: string) => { return EES.some((country) => country.alpha2Code === alpha2Code) } -interface Message { - id: string - defaultMessage: string - description: string -} - export interface EinstaklingurDTO { kennitala?: string | null nafn?: string | null @@ -52,16 +45,6 @@ export interface EinstaklingurDTO { fulltNafn?: EinstaklingurDTONafnAllt } -interface PermitProgram { - name?: string - programId?: string - institution?: StudentTrackInstitutionDto - error?: boolean - errorMsg?: Message | string - professionId?: string - prereq?: StudentTrackDto // TODO Probably don't need this -} - const getFoundationProgram = ( professionId: string, foundationPrograms: NamsUpplysingar[], @@ -168,11 +151,66 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async getEducationInfo({ auth, }: TemplateApiModuleActionProps): Promise { - const result = - await this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + const result: NamsUpplysingar[] = [] + const test = + await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( auth, + { + name: 'Gervimaður Danmörk', + dateOfBirth: new Date('01.01.2000'), + citizenship: 'IS', + email: 'jonjonsson@landlaeknir.is', + phone: '0000000', + idProfession: 'HJ', + education: [ + { + educationId: 81, + graduationDate: new Date('2009-11-03T00:00:00.0000000'), + school: 'Háskóli Íslands', + }, + ], + }, ) + console.log('test', test) + + // const myHeaders = new Headers() + // myHeaders.append('X-Road-Client', 'IS-DEV/GOV/10000/island-is-client') + // myHeaders.append('Content-Type', 'application/json') + // myHeaders.append( + // 'Authorization', + // 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjA0NTM2MDVDRTc1M0UxMTJDRTc0QkJGQjhEQ0E1RTM0IiwidHlwIjoiYXQrand0In0.eyJpc3MiOiJodHRwczovL2lkZW50aXR5LXNlcnZlci5kZXYwMS5kZXZsYW5kLmlzIiwibmJmIjoxNzE3MTYzNDgyLCJpYXQiOjE3MTcxNjM0ODIsImV4cCI6MTcxNzE2NzA4MiwiYXVkIjoiQGxhbmRsYWVrbmlyLmlzL3N0YXJmc2xleWZpIiwic2NvcGUiOiJAbGFuZGxhZWtuaXIuaXMvc3RhcmZzbGV5ZmkiLCJhbXIiOlsiIl0sImNsaWVudF9pZCI6IkBpc2xhbmQuaXMvY2xpZW50cy9kZXYiLCJzdWIiOiI2RUI4RkZGNUI1MDMzNkMzQjJEMzMxNkI0RjI3QTk4Rjg4MEQzRDNFOEUzOTRFNTlEQUYwMEQ4MTY0RDI5NjdGIiwiYXV0aF90aW1lIjoxNzE3MTYwOTI0LCJpZHAiOiJnZXJ2aW1hZHVyIiwiYWNyIjoiMCIsIm5hdGlvbmFsSWQiOiIwMTAxMzAyNDc5Iiwic2lkIjoiRTg2QTNBRUY1RjlDMUNEOTI2NDBDQzYyRjlFN0VBQTAiLCJqdGkiOiIzNTk0QjE2QjI5RTk5QUEzN0FCRUQ3MDk0NEMxQ0VDRiJ9.Evl34Sk3GsPCWeMq-x2xODsQunj7vLEMUbKZS_PKuQmZ-Zr9FzlQxzpjBISdr02-cYqcINnuya2QTk-fSyv6bcdV7a0qvHU1up1n3jgPhOhgrmiysaD1QhZhyb67xUSld0O2vOfVY4EGI7RpNotOPd_fUHtmGu1ZLJJchV7jtxpCn0n5r_lJnVAtZ3DiFFpZo1PUesFIsYyt1vmLTl9O3OG9kq2pI0ciPefQbtmk_WZ3SW8vhhcPfnLlGb8fuk9mbYvqehB60sYjaYXm3ioMs9JJIowp7DV8fj-WYbx3LD4nDpew6ze8VaWObgB_zm_4cakxRglW9m3vxYqJPFI-RA', + // ) + + // const raw = JSON.stringify({ + // name: 'Gervimaður Danmörk', + // dateOfBirth: '01.01.2000', + // citizenship: 'IS', + // email: 'jonjonsson@landlaeknir.is', + // phoneNo: '0000000', + // idProfession: 'HJ', + // education: [ + // { + // educationId: 81, + // graduationDate: '2009-11-03T00:00:00.0000000', + // school: 'Háskóli Íslands', + // }, + // ], + // }) + + // const requestOptions = { + // method: 'POST', + // headers: myHeaders, + // body: raw, + // } + + // fetch( + // 'http://localhost:8081/r1/IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir/UmsoknStarfsleyfi/UtbuaSkjal', + // requestOptions, + // ) + // .then((response) => response.text()) + // .then((result) => console.log(result)) + // .catch((error) => console.error(error)) if (!result) { throw new TemplateApiError( { @@ -212,31 +250,29 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async processPermits({ auth, }: TemplateApiModuleActionProps): Promise { - const [licenses, programs, careerPrograms] = await Promise.all([ - this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( - auth, - ), - this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( - auth, - ), - this.universityCareersClientService.getStudentTrackHistory( - auth, - UniversityId.UNIVERSITY_OF_ICELAND, - ), - ]) - - throw new TemplateApiError( - { - title: errorMsg.noResponseEducationInfoTitle, - summary: errorMsg.noResponseEducationInfoMessage, - }, - 400, - ) - if (!careerPrograms) { + const [licenses, programs, careerProgramsHI, careerProgramsUNAK] = + await Promise.all([ + this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( + auth, + ), + this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + auth, + ), + this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_ICELAND, + ), + this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_AKUREYRI, + ), + ]) + + if (!programs) { throw new TemplateApiError( { - title: errorMsg.emptyCareerResponseTitle, - summary: errorMsg.emptyCareerResponseMessage, + title: errorMsg.noResponseEducationInfoTitle, + summary: errorMsg.noResponseEducationInfoMessage, }, 400, ) @@ -251,18 +287,33 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } + const careerPrograms = careerProgramsHI?.concat(careerProgramsUNAK ?? []) + if (!careerPrograms || careerPrograms?.length < 1) { + { + throw new TemplateApiError( + { + title: errorMsg.emptyCareerResponseTitle, + summary: errorMsg.emptyCareerResponseMessage, + }, + 400, + ) + } + } + const studentTrackDto = [ { name: 'John Doe', nationalId: '1234567890', graduationDate: new Date('2024-01-15'), trackNumber: 3, - institution: {}, + institution: { + displayName: 'Háskóli Íslands', + }, school: 'School of Science', faculty: 'Faculty of Mathematics', - studyProgram: 'Sjúkraliði', + studyProgram: 'Tannsmiður', degree: 'Bachelor of Science', - programId: 'SJÚ441', + programId: 'TSM261', }, { name: 'John Doe', @@ -332,30 +383,36 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { const programsToBeDisplayed = relevantCareerPermitPrograms?.map((program) => { - const { programId, studyProgram, institution, graduationDate } = program - let currentPermitProgramProfessionId = '' + const { programId, studyProgram, graduationDate, institution } = program + // Find the education program for this career program const currentPermitProgram = permitValidPrograms?.find( (permitProgram) => { if (permitProgram.shortId === program.programId) { - currentPermitProgramProfessionId = - permitProgram.idProfession || '' return true } return false }, ) - + const currentPermitProgramProfessionId = + currentPermitProgram?.idProfession || '' + const base = { + name: studyProgram, + programId, + professionId: currentPermitProgramProfessionId, + mainProgram: { + educationId: currentPermitProgram?.educationId, + school: institution?.displayName, + graduationDate, + }, + } // Checking if user already has a license with the same professionId const license = licenses?.find( (item) => item.idProfession === currentPermitProgramProfessionId, ) if (license) { return { - name: studyProgram, - programId, - institution, - professionId: currentPermitProgramProfessionId, + ...base, error: true, errorMsg: information.labels.selectWorkPermit.restrictionAlreadyHasLicense, @@ -373,12 +430,18 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { relevantCareerFoundationPrograms || [], ) + const baseWithFoundationProgram = { + ...base, + foundationProgram: { + educationId: currentFoundationProgram?.educationId, + school: currentFoundationCareerProgram?.institution?.displayName, + graduationDate: currentFoundationCareerProgram?.graduationDate, + }, + } + if (!currentFoundationCareerProgram) { return { - name: studyProgram, - programId, - institution, - professionId: currentPermitProgramProfessionId, + ...baseWithFoundationProgram, error: true, errorMsg: information.labels.selectWorkPermit @@ -390,10 +453,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { !currentFoundationProgram?.educationValidFrom ) { return { - name: studyProgram, - programId, - institution, - professionId: currentPermitProgramProfessionId, + ...baseWithFoundationProgram, error: true, errorMsg: information.labels.selectWorkPermit.restrictionDataError, @@ -404,10 +464,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { new Date(currentFoundationProgram?.educationValidFrom) ) { return { - name: studyProgram, - programId, - institution, - professionId: currentPermitProgramProfessionId, + ...baseWithFoundationProgram, error: true, errorMsg: information.labels.selectWorkPermit.restrictionDataError, @@ -435,10 +492,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { } return { - name: studyProgram, - programId, - institution, - professionId: currentPermitProgramProfessionId, + ...base, error, errorMsg, } @@ -454,7 +508,23 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } - return programsToBeDisplayed + const hasNoError = programsToBeDisplayed.some( + (program) => program.error === false, + ) + + if (!hasNoError) { + throw new TemplateApiError( + { + title: errorMsg.noPermitValidForSelfServiceTitle, + summary: errorMsg.noPermitValidForSelfServiceMessage, + }, + 400, + ) + } + + return programsToBeDisplayed.sort( + (a, b) => Number(a.error) - Number(b.error), + ) } async submitApplication({ @@ -484,18 +554,64 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { const answers = application.answers as HealthcareWorkPermitAnswers const nationalRegistryData = application.externalData.nationalRegistry - ?.data as NationalRegistryIndividual + ?.data as EinstaklingurDTO + if (!nationalRegistryData) { + throw new Error('National registry data is missing.') + } + + const permitPrograms = application.externalData.permitOptions + ?.data as PermitProgram[] + if (!permitPrograms) { + throw new Error('Permit programs data is missing.') + } + + const chosenProgram = permitPrograms.find( + (program) => program.programId === answers.selectWorkPermit.programId, + ) + if (!chosenProgram || !chosenProgram.professionId) { + throw new Error('Chosen program not found.') + } + + const { fulltNafn, faedingarstadur, rikisfang } = nationalRegistryData + if ( + !fulltNafn?.fulltNafn || + !faedingarstadur?.faedingarDagur || + !rikisfang?.rikisfangKodi + ) { + throw new Error('Incomplete national registry data.') + } + + const { email, phone } = answers.userInformation + if (!email || !phone) { + throw new Error('User information is incomplete.') + } + + const educations: Nam[] = [] + if (chosenProgram.mainProgram) { + if (chosenProgram.mainProgram.graduationDate) + chosenProgram.mainProgram.graduationDate = new Date( + chosenProgram.mainProgram.graduationDate, + ) + educations.push(chosenProgram.mainProgram) + } + if (chosenProgram.foundationProgram) { + if (chosenProgram.foundationProgram.graduationDate) + chosenProgram.foundationProgram.graduationDate = new Date( + chosenProgram.foundationProgram.graduationDate, + ) + educations.push(chosenProgram.foundationProgram) + } return await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( auth, { - name: nationalRegistryData.fullName, - dateOfBirth: nationalRegistryData.birthDate, - email: answers.userInformation?.email, - phone: answers.userInformation?.phone, // TODO Is phone in correct format ? - idProfession: answers.selectWorkPermit.studyProgram, // TODO Where can I get idProfession from - citizenship: nationalRegistryData.citizenship?.code || '', - education: [], // TODO + name: fulltNafn.fulltNafn, + dateOfBirth: faedingarstadur.faedingarDagur, + email: email, + phone: phone, + idProfession: chosenProgram.professionId, + citizenship: rikisfang.rikisfangKodi, + education: educations, }, ) } diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx new file mode 100644 index 000000000000..76b70d47e3e4 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx @@ -0,0 +1,128 @@ +import { + FieldBaseProps, + FieldComponents, + FieldTypes, +} from '@island.is/application/types' +import { Box, Button, Text, PdfViewer } from '@island.is/island-ui/core' +import { useLocale } from '@island.is/localization' +import { FC, useState } from 'react' +import { + AlertMessageFormField, + MessageWithLinkButtonFormField, + PdfLinkButtonFormField, +} from '@island.is/application/ui-fields' +import { coreMessages, formatText } from '@island.is/application/core' +import * as styles from './styles.css' +import { confirmation } from '../../lib/messages' +import { conclusionMessages } from '@island.is/application/ui-forms' + +export const CustomFormConclusionSectionField: FC< + React.PropsWithChildren +> = (props) => { + const { application } = props + const { formatMessage } = useLocale() + + const [fileToView, setFileToView] = useState< + | { + base64: string + filename: string + } + | undefined + >(undefined) + + if (fileToView) { + return ( + <> + + + + + + + + ) + } + + return ( + <> + + {formatMessage(confirmation.general.pageTitle)} + + + { + const data = application.externalData.submitApplication.data as { + base64: string + }[] + + return data.map((x, index) => ({ + base64: x.base64, + customButtonText: { is: 'TODO_IS', en: 'TODO_EN' }, + filename: `starfsleyfi_${index}.pdf`, + })) + }, + setViewPdfFile: (file: { base64: string; filename: string }) => { + setFileToView(file) + }, + }} + /> + + + ) +} diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/styles.css.ts b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/styles.css.ts similarity index 100% rename from libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/styles.css.ts rename to libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/styles.css.ts diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx deleted file mode 100644 index a25cdfb03cb8..000000000000 --- a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSelectionField/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { FieldBaseProps } from '@island.is/application/types' -import { useLocale } from '@island.is/localization' -import { FC, useState } from 'react' - -export const CustomFormConclusionSectionField: FC< - React.PropsWithChildren -> = (props) => { - const { application } = props - const { formatMessage } = useLocale() - - const [fileToView, setFileToView] = useState< - | { - base64: string - filename: string - } - | undefined - >(undefined) - - if (fileToView) { - return <> - } - - return <> -} diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx index 7c0456ca27cc..7ce507fd4652 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx @@ -1,6 +1,6 @@ -import { FieldBaseProps, FormatMessage } from '@island.is/application/types' +import { FieldBaseProps } from '@island.is/application/types' import { Box, Text } from '@island.is/island-ui/core' -import { FC, useEffect, useState } from 'react' +import { FC, useEffect } from 'react' import { useLocale } from '@island.is/localization' import { RadioController } from '@island.is/shared/form-fields' import { information } from '../../lib/messages' @@ -81,7 +81,7 @@ export const SelectWorkPermitField: FC< {formatMessage(information.labels.selectWorkPermit.sectionTitle)} + application.externalData?.permitOptions.data[0].programId, + options: (application) => { + const permitPrograms = application?.externalData.permitOptions + .data as PermitProgram[] + return permitPrograms.map((permitProgram) => { + return { + value: permitProgram.programId || '', + label: permitProgram.name || '', + subLabel: '', + disabled: permitProgram.error, + } + }) + }, }), ], }), diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index 8b8875ff47b8..a2e2aeb9fb49 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -18,7 +18,6 @@ import { EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, UserProfileApi, - UniversityCareersApi, EducationInfoApi, NationalRegistryUserApi, ProcessPermitsApi, @@ -65,6 +64,7 @@ export const Prerequisites: Form = buildForm({ subTitle: externalData.userProfile.subTitle, }), buildDataProviderItem({ + provider: HealtcareLicenesApi, title: externalData.healtcareLicenses.title, subTitle: externalData.healtcareLicenses.subTitle, }), diff --git a/libs/application/templates/healthcare-work-permit/src/index.ts b/libs/application/templates/healthcare-work-permit/src/index.ts index b5f710782e5b..e6f3ddf99fad 100644 --- a/libs/application/templates/healthcare-work-permit/src/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/index.ts @@ -11,6 +11,7 @@ export * from './utils' export * from './lib/messages/externalData' export * from './lib/messages/error' export * from './lib/messages/information' +export * from './lib/types' export default template diff --git a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts index 57aade28e852..0cc9a9edff54 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts @@ -6,8 +6,7 @@ const UserInformationSchema = z.object({ }) const SelectWorkPermitSchema = z.object({ - studyProgram: z.string().min(1), - // idProfession: z.string().min(1), + programId: z.string().min(1), }) export const HealthcareWorkPermitSchema = z.object({ diff --git a/libs/application/templates/healthcare-work-permit/src/lib/index.ts b/libs/application/templates/healthcare-work-permit/src/lib/index.ts new file mode 100644 index 000000000000..c9f6f047dc00 --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/index.ts @@ -0,0 +1 @@ +export * from './types' diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts index 04f827eee6d2..08cdaad8325c 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -21,14 +21,14 @@ export const error = defineMessages({ noResponseEducationInfoTitle: { id: 'hlc.application:error.noResponseEducationInfoTitle', defaultMessage: - 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on education paths', }, noResponseEducationInfoMessage: { id: 'hlc.application:error.noResponseEducationInfoMessage', defaultMessage: - 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on education paths', }, @@ -79,4 +79,16 @@ export const error = defineMessages({ defaultMessage: 'Ekki fundust brautskráningar sem gefa starfsleyfi', description: 'No graduated programs found that are valid form work permit', }, + noPermitValidForSelfServiceTitle: { + id: 'hlc.application:error.noPermitValidForSelfServiceTitle', + defaultMessage: + 'Ekki fundust brautskráningar sem geta farið í gegnum sjálfsafgreiðslu, vinsamlega hafðu samband við Embætti Landlæknis', + description: 'No graduated programs found that can go through self service', + }, + noPermitValidForSelfServiceMessage: { + id: 'hlc.application:error.noPermitValidForSelfServiceMessage', + defaultMessage: + 'Ekki fundust brautskráningar sem geta farið í gegnum sjálfsafgreiðslu, vinsamlega hafðu samband við Embætti Landlæknis', + description: 'No graduated programs found that can go through self service', + }, }) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts index a27bcb74e403..2e11e82f5e86 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts @@ -23,7 +23,7 @@ export const information = { description: { id: 'hwp.application:information.labels.selectWorkPermit.description', defaultMessage: - 'Hér að neðan er listi yfir loknar prófgráður frá Háskóla Íslands sem gefa réttindi til starfsleyfa. ', + 'Hér að neðan er listi yfir loknar prófgráður sem gefa réttindi til starfsleyfa. ', description: 'Select work permit description', }, workPermitOptionSubLabelSpeciality: { diff --git a/libs/application/templates/healthcare-work-permit/src/lib/types.ts b/libs/application/templates/healthcare-work-permit/src/lib/types.ts new file mode 100644 index 000000000000..3b1e4bd2ac0d --- /dev/null +++ b/libs/application/templates/healthcare-work-permit/src/lib/types.ts @@ -0,0 +1,17 @@ +import { Nam } from '@island.is/clients/health-directorate' + +export interface Message { + id: string + defaultMessage: string + description: string +} + +export interface PermitProgram { + name?: string + programId?: string + error?: boolean + errorMsg?: Message | string + professionId?: string + mainProgram?: Nam + foundationProgram?: Nam +} diff --git a/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts b/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts index 753fab421a45..9a1cbcb6d4f5 100644 --- a/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts +++ b/libs/application/templates/healthcare-work-permit/src/utils/getChargeItemCodes.ts @@ -1,6 +1,7 @@ import { ChargeItemCode } from '@island.is/shared/constants' import { Application, StaticText } from '@island.is/application/types' import { HealthcareWorkPermit } from '../lib/dataSchema' +import { PermitProgram } from '../lib' export const getChargeItemCodes = (application: Application): Array => { return getChargeItemCodesAndExtraLabel(application).map( @@ -16,15 +17,16 @@ export const getChargeItemCodesAndExtraLabel = ( }> => { const answers = application.answers as HealthcareWorkPermit - // TODO Get Id instead of studyProgram string, fetch programme via id and display info. - - // const licenses = application?.externalData?.healthcareLicenses - // ?.data as HealthcareLicense[] + const permitPrograms = application.externalData.permitOptions + .data as PermitProgram[] + const chosenProgram = permitPrograms.find( + (program) => program.programId === answers.selectWorkPermit.programId, + ) const result = [] result.push({ chargeItemCode: ChargeItemCode.HEALTHCARE_WORK_PERMIT.toString(), - extraLabel: answers.selectWorkPermit.studyProgram, + extraLabel: chosenProgram?.name, }) return result From 29a8b79e7685183f3f3235694f8b32dc61a545a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 4 Jun 2024 11:08:35 +0000 Subject: [PATCH 12/30] removing test code that had old bearer token --- .../healthcare-work-permit.service.ts | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index e3209145d80c..113e57087dcc 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -172,45 +172,6 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { }, ) - console.log('test', test) - - // const myHeaders = new Headers() - // myHeaders.append('X-Road-Client', 'IS-DEV/GOV/10000/island-is-client') - // myHeaders.append('Content-Type', 'application/json') - // myHeaders.append( - // 'Authorization', - // 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjA0NTM2MDVDRTc1M0UxMTJDRTc0QkJGQjhEQ0E1RTM0IiwidHlwIjoiYXQrand0In0.eyJpc3MiOiJodHRwczovL2lkZW50aXR5LXNlcnZlci5kZXYwMS5kZXZsYW5kLmlzIiwibmJmIjoxNzE3MTYzNDgyLCJpYXQiOjE3MTcxNjM0ODIsImV4cCI6MTcxNzE2NzA4MiwiYXVkIjoiQGxhbmRsYWVrbmlyLmlzL3N0YXJmc2xleWZpIiwic2NvcGUiOiJAbGFuZGxhZWtuaXIuaXMvc3RhcmZzbGV5ZmkiLCJhbXIiOlsiIl0sImNsaWVudF9pZCI6IkBpc2xhbmQuaXMvY2xpZW50cy9kZXYiLCJzdWIiOiI2RUI4RkZGNUI1MDMzNkMzQjJEMzMxNkI0RjI3QTk4Rjg4MEQzRDNFOEUzOTRFNTlEQUYwMEQ4MTY0RDI5NjdGIiwiYXV0aF90aW1lIjoxNzE3MTYwOTI0LCJpZHAiOiJnZXJ2aW1hZHVyIiwiYWNyIjoiMCIsIm5hdGlvbmFsSWQiOiIwMTAxMzAyNDc5Iiwic2lkIjoiRTg2QTNBRUY1RjlDMUNEOTI2NDBDQzYyRjlFN0VBQTAiLCJqdGkiOiIzNTk0QjE2QjI5RTk5QUEzN0FCRUQ3MDk0NEMxQ0VDRiJ9.Evl34Sk3GsPCWeMq-x2xODsQunj7vLEMUbKZS_PKuQmZ-Zr9FzlQxzpjBISdr02-cYqcINnuya2QTk-fSyv6bcdV7a0qvHU1up1n3jgPhOhgrmiysaD1QhZhyb67xUSld0O2vOfVY4EGI7RpNotOPd_fUHtmGu1ZLJJchV7jtxpCn0n5r_lJnVAtZ3DiFFpZo1PUesFIsYyt1vmLTl9O3OG9kq2pI0ciPefQbtmk_WZ3SW8vhhcPfnLlGb8fuk9mbYvqehB60sYjaYXm3ioMs9JJIowp7DV8fj-WYbx3LD4nDpew6ze8VaWObgB_zm_4cakxRglW9m3vxYqJPFI-RA', - // ) - - // const raw = JSON.stringify({ - // name: 'Gervimaður Danmörk', - // dateOfBirth: '01.01.2000', - // citizenship: 'IS', - // email: 'jonjonsson@landlaeknir.is', - // phoneNo: '0000000', - // idProfession: 'HJ', - // education: [ - // { - // educationId: 81, - // graduationDate: '2009-11-03T00:00:00.0000000', - // school: 'Háskóli Íslands', - // }, - // ], - // }) - - // const requestOptions = { - // method: 'POST', - // headers: myHeaders, - // body: raw, - // } - - // fetch( - // 'http://localhost:8081/r1/IS-DEV/GOV/10015/EmbaettiLandlaeknis-Protected/landlaeknir/UmsoknStarfsleyfi/UtbuaSkjal', - // requestOptions, - // ) - // .then((response) => response.text()) - // .then((result) => console.log(result)) - // .catch((error) => console.error(error)) if (!result) { throw new TemplateApiError( { From 8f748f8cde84e177b9e2cc2f43c613a9cb8dc1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Wed, 5 Jun 2024 10:22:15 +0000 Subject: [PATCH 13/30] Work on permit application after fixes from Landlaeknir --- .../healthcare-work-permit.service.ts | 218 ++++++++---------- .../index.tsx | 5 +- .../src/forms/Confirmation/index.ts | 5 + .../src/forms/Prerequisites/index.ts | 8 +- .../src/lib/messages/externalData.ts | 5 + .../health-directorate/src/clientConfig.json | 15 +- .../lib/healthDirectorateClient.service.ts | 16 +- 7 files changed, 139 insertions(+), 133 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 113e57087dcc..5ebd0066222d 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -59,7 +59,7 @@ const getCareerFoundationProgram = ( relevantCareerFoundationPrograms: StudentTrackDto[], ): StudentTrackDto | undefined => { return relevantCareerFoundationPrograms.find( - (obj) => obj.programId === foundationProgram?.shortId, + (program) => program.programId === foundationProgram?.shortId, ) } @@ -74,6 +74,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) } + /* Fetching national registry information and validating that user is from within EES */ async getNationalRegistryWithEESValidation({ auth, }: TemplateApiModuleActionProps): Promise { @@ -111,7 +112,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { heimilisfang, rikisfang, kennitala, - nafn, + nafn, // TODO Don't need this ? faedingarstadur, } = result return { @@ -124,7 +125,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { } } - /* Which health care licenses does this user already have */ + /* Fetching this users healthcare licenses */ async getMyHealthcareLicenses({ auth, }: TemplateApiModuleActionProps): Promise { @@ -133,7 +134,6 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { auth, ) - // TODO Double check if this fails on empty response if (!result) { throw new TemplateApiError( { @@ -147,45 +147,29 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } - /* Info on different education programs that give work permit licenses */ - async getEducationInfo({ - auth, - }: TemplateApiModuleActionProps): Promise { - const result: NamsUpplysingar[] = [] - const test = - await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( - auth, - { - name: 'Gervimaður Danmörk', - dateOfBirth: new Date('01.01.2000'), - citizenship: 'IS', - email: 'jonjonsson@landlaeknir.is', - phone: '0000000', - idProfession: 'HJ', - education: [ - { - educationId: 81, - graduationDate: new Date('2009-11-03T00:00:00.0000000'), - school: 'Háskóli Íslands', - }, - ], - }, - ) - - if (!result) { - throw new TemplateApiError( - { - title: errorMsg.noResponseEducationInfoTitle, - summary: errorMsg.noResponseEducationInfoMessage, - }, - 400, - ) - } - - return result - } - - /* The academic career of the logged in uses. Used to find which programmes are valid for work permit */ + // /* Info on different education programs that give work permit licenses */ + // async getEducationInfo({ + // auth, + // }: TemplateApiModuleActionProps): Promise { + // const result = + // this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + // auth, + // ) + + // if (!result) { + // throw new TemplateApiError( + // { + // title: errorMsg.noResponseEducationInfoTitle, + // summary: errorMsg.noResponseEducationInfoMessage, + // }, + // 400, + // ) + // } + + // return result + // } + + /* The academic career of the logged in user. Used to find which programmes are valid for work permit */ async getMyAcademicCareer({ auth, }: TemplateApiModuleActionProps): Promise { @@ -211,23 +195,23 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async processPermits({ auth, }: TemplateApiModuleActionProps): Promise { - const [licenses, programs, careerProgramsHI, careerProgramsUNAK] = - await Promise.all([ - this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( - auth, - ), - this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( - auth, - ), - this.universityCareersClientService.getStudentTrackHistory( - auth, - UniversityId.UNIVERSITY_OF_ICELAND, - ), - this.universityCareersClientService.getStudentTrackHistory( - auth, - UniversityId.UNIVERSITY_OF_AKUREYRI, - ), - ]) + const [licenses, programs, careerProgramsHI] = await Promise.all([ + this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( + auth, + ), + this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + auth, + ), + this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_ICELAND, + ), + // this.universityCareersClientService.getStudentTrackHistory( + // auth, + // UniversityId.UNIVERSITY_OF_AKUREYRI, + // ), + ]) + const careerProgramsUNAK: StudentTrackDto[] = [] if (!programs) { throw new TemplateApiError( @@ -261,58 +245,58 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { } } - const studentTrackDto = [ - { - name: 'John Doe', - nationalId: '1234567890', - graduationDate: new Date('2024-01-15'), - trackNumber: 3, - institution: { - displayName: 'Háskóli Íslands', - }, - school: 'School of Science', - faculty: 'Faculty of Mathematics', - studyProgram: 'Tannsmiður', - degree: 'Bachelor of Science', - programId: 'TSM261', - }, - { - name: 'John Doe', - nationalId: '1234567890', - graduationDate: new Date('2024-05-15'), - trackNumber: 3, - institution: {}, - school: 'School of Science', - faculty: 'Faculty of Mathematics', - studyProgram: 'Geislafræðingur', - degree: 'Bachelor of Science', - programId: 'GSL321', - }, - { - name: 'John Doe', - nationalId: '1234567890', - graduationDate: new Date('2024-05-15'), - trackNumber: 3, - institution: {}, - school: 'School of Science', - faculty: 'Faculty of Mathematics', - studyProgram: 'Hjúkrunafræðingur', - degree: 'Bachelor of Science', - programId: 'GSL260', - }, - { - name: 'John', - nationalId: '1234567890', - graduationDate: new Date('2024-05-15'), - trackNumber: 3, - institution: {}, - school: 'School of Science', - faculty: 'Faculty of Mathematics', - studyProgram: 'Ljósmóðir', - degree: 'Bachelor of Science', - programId: 'LJÓ443', - }, - ] as StudentTrackDto[] + // const studentTrackDto = [ + // { + // name: 'John Doe', + // nationalId: '1234567890', + // graduationDate: new Date('2024-01-15'), + // trackNumber: 3, + // institution: { + // displayName: 'Háskóli Íslands', + // }, + // school: 'School of Science', + // faculty: 'Faculty of Mathematics', + // studyProgram: 'Sjúkraþjálfari', + // degree: 'Bachelor of Science', + // programId: 'SJÚ441', + // }, + // { + // name: 'John Doe', + // nationalId: '1234567890', + // graduationDate: new Date('2024-05-15'), + // trackNumber: 3, + // institution: {}, + // school: 'School of Science', + // faculty: 'Faculty of Mathematics', + // studyProgram: 'Geislafræðingur', + // degree: 'Bachelor of Science', + // programId: 'GSL321', + // }, + // { + // name: 'John Doe', + // nationalId: '1234567890', + // graduationDate: new Date('2024-05-15'), + // trackNumber: 3, + // institution: {}, + // school: 'School of Science', + // faculty: 'Faculty of Mathematics', + // studyProgram: 'Hjúkrunafræðingur', + // degree: 'Bachelor of Science', + // programId: 'GSL260', + // }, + // { + // name: 'John', + // nationalId: '1234567890', + // graduationDate: new Date('2024-05-15'), + // trackNumber: 3, + // institution: {}, + // school: 'School of Science', + // faculty: 'Faculty of Mathematics', + // studyProgram: 'Ljósmóðir', + // degree: 'Bachelor of Science', + // programId: 'LJÓ443', + // }, + // ] as StudentTrackDto[] // Programs that give licenses to practice (permits) const permitValidPrograms = programs?.filter((program) => { @@ -331,15 +315,15 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { permitValidPrograms?.map((item) => item.shortId), ) // Programs user has graduated that are viable for work permit - const relevantCareerPermitPrograms = studentTrackDto?.filter((program) => + const relevantCareerPermitPrograms = careerPrograms?.filter((program) => validPermitIds.has(program.programId), ) const validFoundationProgramIds = new Set( foundationPrograms?.map((item) => item.shortId), ) // Programs user has graduated that are needed as foundation for certain work permit (Nursing for Midwife f.x) - const relevantCareerFoundationPrograms = studentTrackDto?.filter( - (program) => validFoundationProgramIds.has(program.programId), + const relevantCareerFoundationPrograms = careerPrograms?.filter((program) => + validFoundationProgramIds.has(program.programId), ) const programsToBeDisplayed = @@ -491,9 +475,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { async submitApplication({ application, auth, - }: TemplateApiModuleActionProps): Promise { - // TODO Change to custom type with base64 + .. ? - + }: TemplateApiModuleActionProps): Promise { const { paymentUrl } = application.externalData.createCharge.data as { paymentUrl: string } diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx index 76b70d47e3e4..f38d5cc54d20 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx @@ -98,11 +98,10 @@ export const CustomFormConclusionSectionField: FC< conclusionMessages.pdfLinkButtonField.verificationLinkUrl, getPdfFiles: (application) => { const data = application.externalData.submitApplication.data as { - base64: string + base64String: string }[] - return data.map((x, index) => ({ - base64: x.base64, + base64: x.base64String, customButtonText: { is: 'TODO_IS', en: 'TODO_EN' }, filename: `starfsleyfi_${index}.pdf`, })) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts index 9fbee48fca42..a632f469436e 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Confirmation/index.ts @@ -38,6 +38,11 @@ export const Confirmation: Form = buildForm({ title: payment.general.sectionTitle, children: [], }), + buildSection({ + id: 'confirmation', + title: externalData.dataProvider.confirmationStepTitle, + children: [], + }), buildCustomField({ component: 'CustomFormConclusionSectionField', id: 'custom.conclusionSection', diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index a2e2aeb9fb49..f0b7d04d826f 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -80,10 +80,10 @@ export const Prerequisites: Form = buildForm({ provider: ProcessPermitsApi, title: '', }), - buildDataProviderItem({ - provider: EducationInfoApi, - title: '', - }), + // buildDataProviderItem({ + // provider: EducationInfoApi, + // title: '', + // }), ], }), ], diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts index ce5bbfe60c6c..f1519c1b9230 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/externalData.ts @@ -7,6 +7,11 @@ export const externalData = { defaultMessage: 'Gagnaöflun', description: 'External data section title', }, + confirmationStepTitle: { + id: 'hwp.application:externalData.dataProvider.confirmationStepTitle', + defaultMessage: 'Staðfesting', + description: 'Confirmation step title', + }, pageTitle: { id: 'hwp.application:externalData.dataProvider.pageTitle', defaultMessage: 'Gagnaöflun', diff --git a/libs/clients/health-directorate/src/clientConfig.json b/libs/clients/health-directorate/src/clientConfig.json index 6c76fbdf3e55..47e5c87470b9 100644 --- a/libs/clients/health-directorate/src/clientConfig.json +++ b/libs/clients/health-directorate/src/clientConfig.json @@ -218,17 +218,26 @@ "content": { "text/plain": { "schema": { - "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + "type": "array", + "items": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + } } }, "application/json": { "schema": { - "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + "type": "array", + "items": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + } } }, "text/json": { "schema": { - "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + "type": "array", + "items": { + "$ref": "#/components/schemas/UtbuaStarfsleyfiSkjalResponse" + } } } } diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index d72fd94fdcfb..242de11ee90f 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -173,8 +173,8 @@ export class HealthDirectorateClientService { async submitApplicationHealthcareWorkPermit( auth: User, request: HealthcareWorkPermitRequest, - ): Promise { - const item = await this.umsoknStarfsleyfiApiWith( + ): Promise { + const items = await this.umsoknStarfsleyfiApiWith( auth, ).umsoknStarfsleyfiUtbuaSkjalPost({ utbuaStarfsleyfiSkjalRequest: { @@ -188,11 +188,17 @@ export class HealthDirectorateClientService { }, }) - if (!item.base64String) { - throw new Error('Empty file') + if (!items || !Array.isArray(items) || items.length === 0) { + throw new Error('No items returned') } - return item + for (const item of items) { + if (!item.base64String) { + throw new Error('Empty file in one of the items') + } + } + + return items } async submitApplicationHealthcareLicenseCertificate( From c431cca5b8b327b82976af8cae5b2459433e5832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Fri, 7 Jun 2024 11:19:56 +0000 Subject: [PATCH 14/30] cleanup before pr --- .../healthcare-work-permit.module.ts | 2 + .../healthcare-work-permit.service.ts | 156 +++++------------- .../src/dataProviders/index.ts | 5 - .../index.tsx | 25 ++- .../fields/SelectWorkPermitField/index.tsx | 96 ----------- .../src/fields/index.ts | 1 - .../selectWorkPermitSection.ts | 25 +-- .../src/forms/Prerequisites/index.ts | 5 - .../src/lib/HealthcareWorkPermitTemplate.ts | 4 +- .../src/lib/messages/information.ts | 9 +- libs/feature-flags/src/lib/features.ts | 2 +- 11 files changed, 73 insertions(+), 257 deletions(-) delete mode 100644 libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts index c3a896019349..b6b89261c9e6 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -15,6 +15,7 @@ import { AgriculturalUniversityOfIcelandCareerClientConfig, BifrostUniversityCareerClientConfig, HolarUniversityCareerClientConfig, + IcelandUniversityOfTheArtsCareerClientConfig, UniversityCareersClientModule, UniversityOfAkureyriCareerClientConfig, UniversityOfIcelandCareerClientConfig, @@ -39,6 +40,7 @@ export class HealthcareWorkPermitModule { UniversityOfAkureyriCareerClientConfig, UniversityOfIcelandCareerClientConfig, HolarUniversityCareerClientConfig, + IcelandUniversityOfTheArtsCareerClientConfig, ], }), ], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 5ebd0066222d..3754a3d7c7f3 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -107,20 +107,13 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) } - const { - fulltNafn, - heimilisfang, - rikisfang, - kennitala, - nafn, // TODO Don't need this ? - faedingarstadur, - } = result + const { fulltNafn, heimilisfang, rikisfang, kennitala, faedingarstadur } = + result return { fulltNafn, heimilisfang, rikisfang, kennitala, - nafn, faedingarstadur, } } @@ -147,28 +140,6 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } - // /* Info on different education programs that give work permit licenses */ - // async getEducationInfo({ - // auth, - // }: TemplateApiModuleActionProps): Promise { - // const result = - // this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( - // auth, - // ) - - // if (!result) { - // throw new TemplateApiError( - // { - // title: errorMsg.noResponseEducationInfoTitle, - // summary: errorMsg.noResponseEducationInfoMessage, - // }, - // 400, - // ) - // } - - // return result - // } - /* The academic career of the logged in user. Used to find which programmes are valid for work permit */ async getMyAcademicCareer({ auth, @@ -192,26 +163,27 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } + /* Processing and cross validating users graduated programs and healthcare licenses with education info from Landlæknir */ async processPermits({ auth, }: TemplateApiModuleActionProps): Promise { - const [licenses, programs, careerProgramsHI] = await Promise.all([ - this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( - auth, - ), - this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( - auth, - ), - this.universityCareersClientService.getStudentTrackHistory( - auth, - UniversityId.UNIVERSITY_OF_ICELAND, - ), - // this.universityCareersClientService.getStudentTrackHistory( - // auth, - // UniversityId.UNIVERSITY_OF_AKUREYRI, - // ), - ]) - const careerProgramsUNAK: StudentTrackDto[] = [] + const [licenses, programs, careerProgramsUNAK, careerProgramsHI] = + await Promise.all([ + this.healthDirectorateClientService.getHealthCareLicensesForWorkPermit( + auth, + ), + this.healthDirectorateClientService.getHealthCareWorkPermitEducationInfo( + auth, + ), + this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_AKUREYRI, + ), + this.universityCareersClientService.getStudentTrackHistory( + auth, + UniversityId.UNIVERSITY_OF_ICELAND, + ), + ]) if (!programs) { throw new TemplateApiError( @@ -245,59 +217,6 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { } } - // const studentTrackDto = [ - // { - // name: 'John Doe', - // nationalId: '1234567890', - // graduationDate: new Date('2024-01-15'), - // trackNumber: 3, - // institution: { - // displayName: 'Háskóli Íslands', - // }, - // school: 'School of Science', - // faculty: 'Faculty of Mathematics', - // studyProgram: 'Sjúkraþjálfari', - // degree: 'Bachelor of Science', - // programId: 'SJÚ441', - // }, - // { - // name: 'John Doe', - // nationalId: '1234567890', - // graduationDate: new Date('2024-05-15'), - // trackNumber: 3, - // institution: {}, - // school: 'School of Science', - // faculty: 'Faculty of Mathematics', - // studyProgram: 'Geislafræðingur', - // degree: 'Bachelor of Science', - // programId: 'GSL321', - // }, - // { - // name: 'John Doe', - // nationalId: '1234567890', - // graduationDate: new Date('2024-05-15'), - // trackNumber: 3, - // institution: {}, - // school: 'School of Science', - // faculty: 'Faculty of Mathematics', - // studyProgram: 'Hjúkrunafræðingur', - // degree: 'Bachelor of Science', - // programId: 'GSL260', - // }, - // { - // name: 'John', - // nationalId: '1234567890', - // graduationDate: new Date('2024-05-15'), - // trackNumber: 3, - // institution: {}, - // school: 'School of Science', - // faculty: 'Faculty of Mathematics', - // studyProgram: 'Ljósmóðir', - // degree: 'Bachelor of Science', - // programId: 'LJÓ443', - // }, - // ] as StudentTrackDto[] - // Programs that give licenses to practice (permits) const permitValidPrograms = programs?.filter((program) => { return ( @@ -306,21 +225,24 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { ) }) - // Programs that serve as Foundation for certain licenses (Hjúkrunfræði fyrir Ljósmóðir t.d) + // Programs that serve as Foundation for certain licenses (Nursing for Midwife f.x) const foundationPrograms = programs?.filter((program) => { return program.dataOrder === 1 && program.noOfData === 2 }) + // Splitting up programs from Embætti Landlæknis into those that give permits and those that server as foundation + // for other permits. For easy lookup const validPermitIds = new Set( permitValidPrograms?.map((item) => item.shortId), ) + const validFoundationProgramIds = new Set( + foundationPrograms?.map((item) => item.shortId), + ) + // Programs user has graduated that are viable for work permit const relevantCareerPermitPrograms = careerPrograms?.filter((program) => validPermitIds.has(program.programId), ) - const validFoundationProgramIds = new Set( - foundationPrograms?.map((item) => item.shortId), - ) // Programs user has graduated that are needed as foundation for certain work permit (Nursing for Midwife f.x) const relevantCareerFoundationPrograms = careerPrograms?.filter((program) => validFoundationProgramIds.has(program.programId), @@ -345,6 +267,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { name: studyProgram, programId, professionId: currentPermitProgramProfessionId, + error: true, mainProgram: { educationId: currentPermitProgram?.educationId, school: institution?.displayName, @@ -358,14 +281,13 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { if (license) { return { ...base, - error: true, errorMsg: information.labels.selectWorkPermit.restrictionAlreadyHasLicense, } } if (currentPermitProgram?.noOfData === 2) { - // Work permit requires some foundational program to qualify for work permit + // If noOfData equals 2, means that this graduated program requires a specific foundation/prereq const currentFoundationProgram = getFoundationProgram( currentPermitProgramProfessionId, foundationPrograms || [], @@ -387,32 +309,28 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { if (!currentFoundationCareerProgram) { return { ...baseWithFoundationProgram, - error: true, errorMsg: information.labels.selectWorkPermit .restrictionFoundationMissing, } } - if ( - !currentFoundationCareerProgram?.graduationDate || - !currentFoundationProgram?.educationValidFrom - ) { + + const graduationDate = currentFoundationCareerProgram?.graduationDate + const educationValidFrom = + currentFoundationProgram?.educationValidFrom + + if (!graduationDate || !educationValidFrom) { return { ...baseWithFoundationProgram, - error: true, errorMsg: information.labels.selectWorkPermit.restrictionDataError, } } else { - if ( - currentFoundationCareerProgram?.graduationDate < - new Date(currentFoundationProgram?.educationValidFrom) - ) { + if (graduationDate < new Date(educationValidFrom)) { return { ...baseWithFoundationProgram, - error: true, errorMsg: - information.labels.selectWorkPermit.restrictionDataError, + information.labels.selectWorkPermit.restrictionFoundationDate, } } } diff --git a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts index 2ee4d3844b32..ea077a6a6d07 100644 --- a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts @@ -31,11 +31,6 @@ export const ProcessPermitsApi = defineTemplateApi({ externalDataId: 'permitOptions', }) -export const EducationInfoApi = defineTemplateApi({ - action: ApiActions.getEducationInfo, - externalDataId: 'educationInfo', -}) - export const NationalRegistryUserApi = defineTemplateApi({ action: ApiActions.getNationalRegistryWithEESValidation, externalDataId: 'nationalRegistry', diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx index f38d5cc54d20..c27ef079782d 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx @@ -15,6 +15,8 @@ import { coreMessages, formatText } from '@island.is/application/core' import * as styles from './styles.css' import { confirmation } from '../../lib/messages' import { conclusionMessages } from '@island.is/application/ui-forms' +import { PermitProgram } from '../../lib' +import { HealthcareWorkPermitAnswers } from '../..' export const CustomFormConclusionSectionField: FC< React.PropsWithChildren @@ -68,6 +70,18 @@ export const CustomFormConclusionSectionField: FC< ) } + const answers = props.application.answers as HealthcareWorkPermitAnswers + + const permitPrograms = props.application.externalData.permitOptions + ?.data as PermitProgram[] + if (!permitPrograms) { + throw new Error('Permit programs data is missing.') + } + + const chosenProgram = permitPrograms.find( + (program) => program.programId === answers.selectWorkPermit.programId, + ) + return ( <> @@ -100,10 +114,17 @@ export const CustomFormConclusionSectionField: FC< const data = application.externalData.submitApplication.data as { base64String: string }[] + // This should only ever be at most 2 files, in order license -> license number (when license number is applicable) return data.map((x, index) => ({ base64: x.base64String, - customButtonText: { is: 'TODO_IS', en: 'TODO_EN' }, - filename: `starfsleyfi_${index}.pdf`, + customButtonText: { + is: + index === 0 + ? `Starfsleyfi - ${chosenProgram?.name}` + : `Leyfisnúmer`, + en: index === 0 ? `License to practice` : `License number`, + }, + filename: index === 0 ? `starfsleyfi_.pdf` : `leyfisnumer_.pdf`, })) }, setViewPdfFile: (file: { base64: string; filename: string }) => { diff --git a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx deleted file mode 100644 index 7ce507fd4652..000000000000 --- a/libs/application/templates/healthcare-work-permit/src/fields/SelectWorkPermitField/index.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { FieldBaseProps } from '@island.is/application/types' -import { Box, Text } from '@island.is/island-ui/core' -import { FC, useEffect } from 'react' -import { useLocale } from '@island.is/localization' -import { RadioController } from '@island.is/shared/form-fields' -import { information } from '../../lib/messages' -import { - StudentTrackDto, - StudentTrackInstitutionDto, -} from '@island.is/clients/university-careers' -import { MessageDescriptor } from 'react-intl' - -interface Option { - value: string - label: React.ReactNode - disabled?: boolean -} - -interface Message { - id: string - defaultMessage: string - description: string -} - -interface PermitProgram { - name?: string - programId?: string - institution?: StudentTrackInstitutionDto - error?: boolean - errorMsg?: Message | string - professionId?: string - prereq?: StudentTrackDto // TODO Probably don't need this -} - -export const SelectWorkPermitField: FC< - React.PropsWithChildren -> = (props) => { - const { lang, formatMessage } = useLocale() - const { application } = props - - const workPermitOptions = (workPermits: PermitProgram[]) => { - const options: Option[] = [] - - for (const permitProgram of workPermits) { - const disabled = permitProgram.error - const formattedErrorMsg = formatMessage( - permitProgram.errorMsg as MessageDescriptor, - ) - - options.push({ - value: `${permitProgram.name}`, - label: ( - - - - {`${lang === 'is' ? permitProgram.name : permitProgram.name}${ - disabled ? ` (${formattedErrorMsg})` : '' - }`} - - - - ), - disabled: disabled, - }) - } - return options - } - - useEffect(() => { - props.setSubmitButtonDisabled && props.setSubmitButtonDisabled(true) - }, []) - - return ( - - - {formatMessage(information.labels.selectWorkPermit.sectionTitle)} - - - props.setSubmitButtonDisabled && props.setSubmitButtonDisabled(false) - } - /> - - ) -} diff --git a/libs/application/templates/healthcare-work-permit/src/fields/index.ts b/libs/application/templates/healthcare-work-permit/src/fields/index.ts index 6b5d03a714ea..2501efd30860 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/fields/index.ts @@ -1,2 +1 @@ -export { SelectWorkPermitField } from './SelectWorkPermitField' export { CustomFormConclusionSectionField } from './CustomFormConclusionSectionField' diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts index 9cdd4ea8c0e0..0a7e3a1713db 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/selectWorkPermitSection.ts @@ -1,32 +1,11 @@ import { - buildHiddenInput, buildMultiField, buildRadioField, buildSection, } from '@island.is/application/core' import { information } from '../../lib/messages' -import { - StudentTrackDto, - StudentTrackInstitutionDto, -} from '@island.is/clients/university-careers' -import { formatText } from '@island.is/application/core' import { Application } from '@island.is/api/schema' - -interface Message { - id: string - defaultMessage: string - description: string -} - -interface PermitProgram { - name?: string - programId?: string - institution?: StudentTrackInstitutionDto - error?: boolean - errorMsg?: Message | string - professionId?: string - prereq?: StudentTrackDto // TODO Probably don't need this -} +import { PermitProgram } from '../../lib' export const SelectWorkPermitSection = buildSection({ id: 'selectWorkPermitSection', @@ -49,7 +28,7 @@ export const SelectWorkPermitSection = buildSection({ return { value: permitProgram.programId || '', label: permitProgram.name || '', - subLabel: '', + subLabel: permitProgram.errorMsg, disabled: permitProgram.error, } }) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index f0b7d04d826f..05d67bf6a91f 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -18,7 +18,6 @@ import { EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, UserProfileApi, - EducationInfoApi, NationalRegistryUserApi, ProcessPermitsApi, } from '../../dataProviders' @@ -80,10 +79,6 @@ export const Prerequisites: Form = buildForm({ provider: ProcessPermitsApi, title: '', }), - // buildDataProviderItem({ - // provider: EducationInfoApi, - // title: '', - // }), ], }), ], diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index 1806c16289e7..c9cad69448ba 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -25,7 +25,6 @@ import { EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, UniversityCareersApi, - EducationInfoApi, NationalRegistryUserApi, ProcessPermitsApi, } from '../dataProviders' @@ -45,7 +44,7 @@ const template: ApplicationTemplate< ApplicationConfigurations.HealthcareWorkPermit.translation, ], dataSchema: HealthcareWorkPermitSchema, - featureFlag: Features.healthcareLicenseCertificate, + featureFlag: Features.healthcareWorkPermit, stateMachineConfig: { initial: States.PREREQUISITES, states: { @@ -88,7 +87,6 @@ const template: ApplicationTemplate< EmbaettiLandlaeknisPaymentCatalogApi, UniversityCareersApi, HealtcareLicenesApi, - EducationInfoApi, ProcessPermitsApi, ], }, diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts index 2e11e82f5e86..e257c3dc5402 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/information.ts @@ -58,13 +58,18 @@ export const information = { id: 'hwp.application:information.labels.selectWorkPermit.restrictionFoundationMissing', defaultMessage: 'Ekki fannst grunnnám', description: - 'Select work permit restriction message, graduation date too old', + 'Select work permit restriction message, foundation program missing', }, restrictionDataError: { id: 'hwp.application:information.labels.selectWorkPermit.restrictionDataError', defaultMessage: 'Villa í gögnum, engin dagsetning fannst', + description: 'Select work permit restriction message, error in data', + }, + restrictionFoundationDate: { + id: 'hwp.application:information.labels.selectWorkPermit.restrictionFoundationDate', + defaultMessage: 'Útskrift grunnnáms fyrir starfsleyfi er of gömull', description: - 'Select work permit restriction message, graduation date too old', + 'Select work permit restriction message, foundation graduation date is too old', }, restrictionAlreadyHasLicense: { id: 'hwp.application:information.labels.selectWorkPermit.restrictionAlreadyHasLicense', diff --git a/libs/feature-flags/src/lib/features.ts b/libs/feature-flags/src/lib/features.ts index 70c1c9ed5774..5fe8b5de340a 100644 --- a/libs/feature-flags/src/lib/features.ts +++ b/libs/feature-flags/src/lib/features.ts @@ -22,7 +22,7 @@ export enum Features { energyFunds = 'isEnergyFundsEnabled', complaintsToAlthingiOmbudsman = 'isComplaintToAlthingiOmbudsmanEnabled', healthcareLicenseCertificate = 'isHealthcareLicenseCertificateEnabled', - healthcareWorkPermit = 'isHealthcareWorkPermitEnabled', + healthcareWorkPermit = 'ishealthcareworkpermitenabled', pensionSupplementApplication = 'isPensionSupplementEnable', transferOfMachineOwnership = 'isTransferOfMachineOwnershipEnabled', university = 'isUniversityEnabled', From ffc2f88474406b7529793366fe8adacf9a40da56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Fri, 7 Jun 2024 12:15:45 +0000 Subject: [PATCH 15/30] Reverting name of function that was renamed by accident --- .../src/lib/healthDirectorateClient.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 242de11ee90f..44fc1a78f103 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -42,7 +42,7 @@ export class HealthDirectorateClientService { return this.umsoknStarfsleyfiApi.withMiddleware(new AuthMiddleware(auth)) } - public async getHealthDirectorateLicense( + public async getHealthDirectorateLicenseToPractice( auth: User, ): Promise | null> { const licenses = await this.starfsleyfiAMinumSidumApiWithAuth(auth) From 026e033f4fddad55273e70674b123f2efd993238 Mon Sep 17 00:00:00 2001 From: andes-it Date: Fri, 7 Jun 2024 12:40:35 +0000 Subject: [PATCH 16/30] chore: nx format:write update dirty files --- .../src/lib/modules/templates/index.ts | 1 - .../forms/HealthcareWorkPermitForm/index.ts | 1 - .../src/lib/apiConfiguration.ts | 42 ++++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/index.ts b/libs/application/template-api-modules/src/lib/modules/templates/index.ts index d74b190eb4f2..e2acbdebc788 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/index.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/index.ts @@ -130,7 +130,6 @@ import { RequestInspectionTemplateService } from './aosh/request-inspection/requ import { HealthInsuranceDeclarationModule } from './health-insurance-declaration/health-insurance-declaration.module' import { HealthInsuranceDeclarationService } from './health-insurance-declaration/health-insurance-declaration.service' - export const modules = [ ReferenceTemplateModule, GeneralFishingLicenseModule, diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts index 5e0093ac0c8f..6402e672fc20 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/index.ts @@ -7,7 +7,6 @@ import { Logo } from '../../assets/Logo' import { buildFormPaymentChargeOverviewSection } from '@island.is/application/ui-forms' import { getChargeItemCodesAndExtraLabel } from '../../utils' - export const HealthcareWorkPermitForm: Form = buildForm({ id: 'HealthcareWorkPermitForm', title: '', diff --git a/libs/clients/health-directorate/src/lib/apiConfiguration.ts b/libs/clients/health-directorate/src/lib/apiConfiguration.ts index cf39ecf9d6df..c6cdd7897879 100644 --- a/libs/clients/health-directorate/src/lib/apiConfiguration.ts +++ b/libs/clients/health-directorate/src/lib/apiConfiguration.ts @@ -40,23 +40,25 @@ const configFactory = ( }, }) -export const exportedApis = [StarfsleyfiAMinumSidumApi, VottordApi, UmsoknStarfsleyfiApi].map( - (Api) => ({ - provide: Api, - scope: LazyDuringDevScope, - useFactory: ( - xRoadConfig: ConfigType, - config: ConfigType, - idsClientConfig: ConfigType, - ) => { - return new Api( - new Configuration(configFactory(xRoadConfig, config, idsClientConfig)), - ) - }, - inject: [ - XRoadConfig.KEY, - HealthDirectorateClientConfig.KEY, - IdsClientConfig.KEY, - ], - }), -) +export const exportedApis = [ + StarfsleyfiAMinumSidumApi, + VottordApi, + UmsoknStarfsleyfiApi, +].map((Api) => ({ + provide: Api, + scope: LazyDuringDevScope, + useFactory: ( + xRoadConfig: ConfigType, + config: ConfigType, + idsClientConfig: ConfigType, + ) => { + return new Api( + new Configuration(configFactory(xRoadConfig, config, idsClientConfig)), + ) + }, + inject: [ + XRoadConfig.KEY, + HealthDirectorateClientConfig.KEY, + IdsClientConfig.KEY, + ], +})) From 6a8ec2afc6fa85136e4975039f3d1491b9a1334a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Fri, 7 Jun 2024 13:29:50 +0000 Subject: [PATCH 17/30] Changing id of textField, was duplicate --- .../src/forms/HealthcareWorkPermitForm/personalSection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts index 92151e6c7ba0..38dcaa8ab266 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts @@ -55,7 +55,7 @@ export const PersonalSection = buildSection({ ), }), buildTextField({ - id: 'userInformation.birthDate', + id: 'userInformation.citizenship', title: personal.labels.userInformation.citizenship, backgroundColor: 'white', width: 'half', From f02be593c336d5fefda848d8ff30f1a378bab8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Mon, 10 Jun 2024 15:10:11 +0000 Subject: [PATCH 18/30] changing ids from hlc to hwp --- .../src/lib/messages/error.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts index 08cdaad8325c..a26aaf74fcd9 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -7,86 +7,86 @@ export const error = defineMessages({ description: 'Unhandled error in data provider', }, emptyCareerResponseTitle: { - id: 'hlc.application:error.emptyCareerResponseTitle', + id: 'hwp.application:error.emptyCareerResponseTitle', defaultMessage: 'Samkvæmt þjónustu Háskóla Íslands ertu ekki með brautskráningu á skrá', description: 'Empty career response', }, emptyCareerResponseMessage: { - id: 'hlc.application:error.emptyCareerResponseMessage', + id: 'hwp.application:error.emptyCareerResponseMessage', defaultMessage: 'Samkvæmt þjónustu Háskóla Íslands ertu ekki með brautskráningu á skrá', description: 'Empty career response', }, noResponseEducationInfoTitle: { - id: 'hlc.application:error.noResponseEducationInfoTitle', + id: 'hwp.application:error.noResponseEducationInfoTitle', defaultMessage: 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on education paths', }, noResponseEducationInfoMessage: { - id: 'hlc.application:error.noResponseEducationInfoMessage', + id: 'hwp.application:error.noResponseEducationInfoMessage', defaultMessage: 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on education paths', }, healthcareLicenseErrorTitle: { - id: 'hlc.application:error.healthcareLicenseErrorTitle', + id: 'hwp.application:error.healthcareLicenseErrorTitle', defaultMessage: 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on healthcare licenses', }, healthcareLicenseErrorMessage: { - id: 'hlc.application:error.healthcareLicenseErrorMessage', + id: 'hwp.application:error.healthcareLicenseErrorMessage', defaultMessage: 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching healthcare licenses', }, nationalRegistryOutsideEESErrorTitle: { - id: 'hlc.application:error.nationalRegistryOutsideEESErrorTitle', + id: 'hwp.application:error.nationalRegistryOutsideEESErrorTitle', defaultMessage: 'Þú ert ekki ríkisborgari innan EES', description: 'You are not a citizen within EES', }, nationalRegistryOutsideEESErrorMessage: { - id: 'hlc.application:error.nationalRegistryOutsideEESErrorMessage', + id: 'hwp.application:error.nationalRegistryOutsideEESErrorMessage', defaultMessage: 'Þú ert ekki ríkisborgari innan EES', description: 'You are not a citizen within EES', }, nationalRegistryFetchErrorTitle: { - id: 'hlc.application:error.nationalRegistryFetchErrorTitle', + id: 'hwp.application:error.nationalRegistryFetchErrorTitle', defaultMessage: 'Ekki tókst að sækja gögn frá þjóðskrá, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on current user from nation registry', }, nationalRegistryFetchErrorMessage: { - id: 'hlc.application:error.nationalRegistryFetchErrorMessage', + id: 'hwp.application:error.nationalRegistryFetchErrorMessage', defaultMessage: 'Lorem ipsum', description: 'No response or faulty response when fetching info on current user from nation registry', }, noPermitValidGraduationFoundTitle: { - id: 'hlc.application:error.noPermitValidGraduationFoundTitle', + id: 'hwp.application:error.noPermitValidGraduationFoundTitle', defaultMessage: 'Ekki fundust brautskráningar sem gefa starfsleyfi', description: 'No graduated programs found that are valid form work permit', }, noPermitValidGraduationFoundMessage: { - id: 'hlc.application:error.noPermitValidGraduationFoundMessage', + id: 'hwp.application:error.noPermitValidGraduationFoundMessage', defaultMessage: 'Ekki fundust brautskráningar sem gefa starfsleyfi', description: 'No graduated programs found that are valid form work permit', }, noPermitValidForSelfServiceTitle: { - id: 'hlc.application:error.noPermitValidForSelfServiceTitle', + id: 'hwp.application:error.noPermitValidForSelfServiceTitle', defaultMessage: 'Ekki fundust brautskráningar sem geta farið í gegnum sjálfsafgreiðslu, vinsamlega hafðu samband við Embætti Landlæknis', description: 'No graduated programs found that can go through self service', }, noPermitValidForSelfServiceMessage: { - id: 'hlc.application:error.noPermitValidForSelfServiceMessage', + id: 'hwp.application:error.noPermitValidForSelfServiceMessage', defaultMessage: 'Ekki fundust brautskráningar sem geta farið í gegnum sjálfsafgreiðslu, vinsamlega hafðu samband við Embætti Landlæknis', description: 'No graduated programs found that can go through self service', From a40849d0458124aee403161299c25c0740411321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Mon, 10 Jun 2024 15:17:47 +0000 Subject: [PATCH 19/30] updating CODEOWNERS --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a81bdc6d4058..f3ae9cd81216 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -339,6 +339,10 @@ codemagic.yaml /libs/application/templates/healthcare-license-certificate/ @island-is/origo /libs/application/template-api-modules/src/lib/modules/templates/healthcare-license-certificate/ @island-is/origo + +/libs/application/templates/healthcare-work-permit/ @island-is/origo +/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/ @island-is/origo + /libs/application/templates/energy-funds/ @island-is/origo /libs/application/template-api-modules/src/lib/modules/templates/energy-funds/ @island-is/origo /libs/api/domains/energy-funds/ @island-is/origo From ff6625f13da9237167b978fdc7b69a99b8d927fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Tue, 11 Jun 2024 07:38:47 +0000 Subject: [PATCH 20/30] fixing typos and placeholders in error message --- .../healthcare-work-permit/src/lib/messages/error.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts index a26aaf74fcd9..a901adaef7d0 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/messages/error.ts @@ -3,7 +3,7 @@ import { defineMessages } from 'react-intl' export const error = defineMessages({ errorDataProvider: { id: 'hwp.application:error.dataProvider', - defaultMessage: 'Reyndu aftur síðar', + defaultMessage: 'Ekki tókst að sækja gögn, vinsamlegast reyndu aftur síðar', description: 'Unhandled error in data provider', }, emptyCareerResponseTitle: { @@ -28,21 +28,21 @@ export const error = defineMessages({ noResponseEducationInfoMessage: { id: 'hwp.application:error.noResponseEducationInfoMessage', defaultMessage: - 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + 'Ekki tókst að sækja gögn frá Embætti Landlæknis, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on education paths', }, healthcareLicenseErrorTitle: { id: 'hwp.application:error.healthcareLicenseErrorTitle', defaultMessage: - 'Ekki tókst að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + 'Ekki tókst að sækja gögn frá Embætti Landlæknis, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching info on healthcare licenses', }, healthcareLicenseErrorMessage: { id: 'hwp.application:error.healthcareLicenseErrorMessage', defaultMessage: - 'Ekki tóks að sækja gögn frá Landlækni, vinsamlegast prufaðu aftur seinna', + 'Ekki tókst að sækja gögn frá Embætti Landlæknis, vinsamlegast prufaðu aftur seinna', description: 'No response or faulty response when fetching healthcare licenses', }, @@ -65,7 +65,8 @@ export const error = defineMessages({ }, nationalRegistryFetchErrorMessage: { id: 'hwp.application:error.nationalRegistryFetchErrorMessage', - defaultMessage: 'Lorem ipsum', + defaultMessage: + 'Ekki tókst að sækja gögn frá Þjóðskrá, vinsamlegast reyndu aftur síðar', description: 'No response or faulty response when fetching info on current user from nation registry', }, From 0c199f8650934a86dc45a1904e273852ac3d2550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Wed, 12 Jun 2024 14:58:13 +0000 Subject: [PATCH 21/30] first batch of responding to PR comments --- libs/application/core/src/lib/messages.ts | 5 + .../shared/api/national-registry}/EES.ts | 0 .../national-registry.service.ts | 22 ++++- .../healthcare-work-permit.module.ts | 6 -- .../healthcare-work-permit.service.ts | 95 ++----------------- .../HealthcareLicenseCertificateTemplate.ts | 6 +- .../healthcare-work-permit/project.json | 28 +++--- .../src/dataProviders/index.ts | 10 -- .../src/forms/Prerequisites/index.ts | 14 ++- .../healthcare-work-permit/src/index.ts | 2 - .../src/lib/HealthcareWorkPermitTemplate.ts | 10 +- .../src/shared/constants.ts | 1 - .../national-registry-user.ts | 1 + .../lib/healthDirectorateClient.service.ts | 19 +++- 14 files changed, 87 insertions(+), 132 deletions(-) rename libs/application/{templates/healthcare-work-permit/src/utils => template-api-modules/src/lib/modules/shared/api/national-registry}/EES.ts (100%) diff --git a/libs/application/core/src/lib/messages.ts b/libs/application/core/src/lib/messages.ts index 0802b9385f1d..f7be2dbb8e1b 100644 --- a/libs/application/core/src/lib/messages.ts +++ b/libs/application/core/src/lib/messages.ts @@ -556,6 +556,11 @@ export const coreErrorMessages = defineMessages({ defaultMessage: 'Þú ert ekki með íslenskt ríkisfang', description: 'You do not have a domicile in Iceland', }, + nationalRegistryCitizenshipNotWithinEES: { + id: 'application.system:core.fetch.data.nationalRegistryCitizenshipNotWithinEES', + defaultMessage: 'Þú ert ekki með ríkisfang innan EES', + description: 'You do not have citizenship with EES', + }, nationalRegistryAgeNotValid: { id: 'application.system:core.fetch.data.nationalRegistryAgeNotValid', defaultMessage: 'Þú hefur ekki náð tilskyldum aldri fyrir þessa umsókn', diff --git a/libs/application/templates/healthcare-work-permit/src/utils/EES.ts b/libs/application/template-api-modules/src/lib/modules/shared/api/national-registry/EES.ts similarity index 100% rename from libs/application/templates/healthcare-work-permit/src/utils/EES.ts rename to libs/application/template-api-modules/src/lib/modules/shared/api/national-registry/EES.ts diff --git a/libs/application/template-api-modules/src/lib/modules/shared/api/national-registry/national-registry.service.ts b/libs/application/template-api-modules/src/lib/modules/shared/api/national-registry/national-registry.service.ts index 524dad8ef7ce..1f861243d450 100644 --- a/libs/application/template-api-modules/src/lib/modules/shared/api/national-registry/national-registry.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/shared/api/national-registry/national-registry.service.ts @@ -17,6 +17,7 @@ import { NationalRegistryClientService } from '@island.is/clients/national-regis import { AssetsXRoadService } from '@island.is/api/domains/assets' import { TemplateApiError } from '@island.is/nest/problem' import { coreErrorMessages } from '@island.is/application/core' +import { EES } from './EES' @Injectable() export class NationalRegistryService extends BaseTemplateApiService { @@ -32,7 +33,6 @@ export class NationalRegistryService extends BaseTemplateApiService { params, }: TemplateApiModuleActionProps): Promise { const individual = await this.getIndividual(auth.nationalId) - //Check if individual is found in national registry if (!individual) { throw new TemplateApiError( @@ -73,6 +73,10 @@ export class NationalRegistryService extends BaseTemplateApiService { if (params?.ageToValidate && !isChild) { this.validateAge(params, individual) } + + if (params?.citizenshipWithinEES) { + this.validateCitizenshipWithinEES(individual) + } } private async validateChildren( @@ -87,6 +91,22 @@ export class NationalRegistryService extends BaseTemplateApiService { } } + private validateCitizenshipWithinEES(individual: NationalRegistryIndividual) { + const isWithinEES = EES.some( + (country) => country.alpha2Code === individual.citizenship?.code, + ) + if (!isWithinEES) { + // If individuals citizenship is not within EES + throw new TemplateApiError( + { + title: coreErrorMessages.nationalRegistryCitizenshipNotWithinEES, + summary: coreErrorMessages.nationalRegistryCitizenshipNotWithinEES, + }, + 400, + ) + } + } + private validateDomicileInIceland(individual: NationalRegistryIndividual) { const domicileCode = individual?.address?.municipalityCode if (!domicileCode || domicileCode.substring(0, 2) === '99') { diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts index b6b89261c9e6..c0350c3a9bd6 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -7,10 +7,6 @@ import { HealthDirectorateClientModule, HealthDirectorateClientConfig, } from '@island.is/clients/health-directorate' -import { - NationalRegistryV3ClientConfig, - NationalRegistryV3ClientModule, -} from '@island.is/clients/national-registry-v3' import { AgriculturalUniversityOfIcelandCareerClientConfig, BifrostUniversityCareerClientConfig, @@ -28,13 +24,11 @@ export class HealthcareWorkPermitModule { imports: [ SharedTemplateAPIModule.register(baseConfig), HealthDirectorateClientModule, - NationalRegistryV3ClientModule, UniversityCareersClientModule, ConfigModule.forRoot({ isGlobal: true, load: [ HealthDirectorateClientConfig, - NationalRegistryV3ClientConfig, AgriculturalUniversityOfIcelandCareerClientConfig, BifrostUniversityCareerClientConfig, UniversityOfAkureyriCareerClientConfig, diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 3754a3d7c7f3..5d63e7690614 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -2,9 +2,11 @@ import { Injectable } from '@nestjs/common' import { SharedTemplateApiService } from '../../shared' import { TemplateApiModuleActionProps } from '../../../types' import { BaseTemplateApiService } from '../../base-template-api.service' -import { ApplicationTypes } from '@island.is/application/types' import { - EES, + ApplicationTypes, + NationalRegistryIndividual, +} from '@island.is/application/types' +import { HealthcareWorkPermitAnswers, PermitProgram, Message, @@ -29,13 +31,8 @@ import { EinstaklingurDTOHeimili, EinstaklingurDTONafnAllt, EinstaklingurDTORikisfang, - NationalRegistryV3ClientService, } from '@island.is/clients/national-registry-v3' -const isCitizenOfEES = (alpha2Code: string) => { - return EES.some((country) => country.alpha2Code === alpha2Code) -} - export interface EinstaklingurDTO { kennitala?: string | null nafn?: string | null @@ -69,55 +66,10 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { private readonly sharedTemplateAPIService: SharedTemplateApiService, private readonly healthDirectorateClientService: HealthDirectorateClientService, private readonly universityCareersClientService: UniversityCareersClientService, - private readonly nationalRegistryService: NationalRegistryV3ClientService, ) { super(ApplicationTypes.HEALTHCARE_WORK_PERMIT) } - /* Fetching national registry information and validating that user is from within EES */ - async getNationalRegistryWithEESValidation({ - auth, - }: TemplateApiModuleActionProps): Promise { - const result = await this.nationalRegistryService.getAllDataIndividual( - auth.nationalId, - ) - - if (!result) { - throw new TemplateApiError( - { - title: errorMsg.nationalRegistryFetchErrorTitle, - summary: errorMsg.nationalRegistryFetchErrorMessage, - }, - 400, - ) - } - - const hasEESCitizenship = isCitizenOfEES( - result?.rikisfang?.rikisfangKodi || '', - ) - - if (!hasEESCitizenship) { - throw new TemplateApiError( - { - title: errorMsg.nationalRegistryOutsideEESErrorTitle, - summary: errorMsg.nationalRegistryOutsideEESErrorMessage, - }, - - 400, - ) - } - - const { fulltNafn, heimilisfang, rikisfang, kennitala, faedingarstadur } = - result - return { - fulltNafn, - heimilisfang, - rikisfang, - kennitala, - faedingarstadur, - } - } - /* Fetching this users healthcare licenses */ async getMyHealthcareLicenses({ auth, @@ -140,29 +92,6 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return result } - /* The academic career of the logged in user. Used to find which programmes are valid for work permit */ - async getMyAcademicCareer({ - auth, - }: TemplateApiModuleActionProps): Promise { - const result = - await this.universityCareersClientService.getStudentTrackHistory( - auth, - UniversityId.UNIVERSITY_OF_ICELAND, - ) - - if (!result) { - throw new TemplateApiError( - { - title: errorMsg.emptyCareerResponseTitle, - summary: errorMsg.emptyCareerResponseMessage, - }, - 400, - ) - } - - return result - } - /* Processing and cross validating users graduated programs and healthcare licenses with education info from Landlæknir */ async processPermits({ auth, @@ -415,7 +344,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { const answers = application.answers as HealthcareWorkPermitAnswers const nationalRegistryData = application.externalData.nationalRegistry - ?.data as EinstaklingurDTO + ?.data as NationalRegistryIndividual if (!nationalRegistryData) { throw new Error('National registry data is missing.') } @@ -433,12 +362,8 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { throw new Error('Chosen program not found.') } - const { fulltNafn, faedingarstadur, rikisfang } = nationalRegistryData - if ( - !fulltNafn?.fulltNafn || - !faedingarstadur?.faedingarDagur || - !rikisfang?.rikisfangKodi - ) { + const { fullName, citizenship, birthDate } = nationalRegistryData + if (!fullName || !birthDate || !citizenship?.code) { throw new Error('Incomplete national registry data.') } @@ -466,12 +391,12 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { return await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( auth, { - name: fulltNafn.fulltNafn, - dateOfBirth: faedingarstadur.faedingarDagur, + name: fullName, + dateOfBirth: birthDate, email: email, phone: phone, idProfession: chosenProgram.professionId, - citizenship: rikisfang.rikisfangKodi, + citizenship: citizenship.code, education: educations, }, ) diff --git a/libs/application/templates/healthcare-license-certificate/src/lib/HealthcareLicenseCertificateTemplate.ts b/libs/application/templates/healthcare-license-certificate/src/lib/HealthcareLicenseCertificateTemplate.ts index 89120872b73d..5bf998459aca 100644 --- a/libs/application/templates/healthcare-license-certificate/src/lib/HealthcareLicenseCertificateTemplate.ts +++ b/libs/application/templates/healthcare-license-certificate/src/lib/HealthcareLicenseCertificateTemplate.ts @@ -80,7 +80,11 @@ const template: ApplicationTemplate< write: 'all', delete: true, api: [ - NationalRegistryUserApi, + NationalRegistryUserApi.configure({ + params: { + citizenshipWithinEES: true, + }, + }), UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, diff --git a/libs/application/templates/healthcare-work-permit/project.json b/libs/application/templates/healthcare-work-permit/project.json index e5cd25aa6b41..dffea26c63e8 100644 --- a/libs/application/templates/healthcare-work-permit/project.json +++ b/libs/application/templates/healthcare-work-permit/project.json @@ -14,24 +14,24 @@ ] } }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/application/templates/healthcare-work-permit/jest.config.ts", - "passWithNoTests": true - }, - "configurations": { - "ci": { - "ci": true, - "codeCoverage": true - } - } - }, "extract-strings": { "executor": "nx:run-commands", "options": { "command": "yarn ts-node -P libs/localization/tsconfig.lib.json libs/localization/scripts/extract 'libs/application/templates/healthcare-work-permit/src/**/*.{js,ts,tsx}'" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/application/templates/healthcare-work-permit/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } } } } diff --git a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts index ea077a6a6d07..0e965c164678 100644 --- a/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/dataProviders/index.ts @@ -21,17 +21,7 @@ export const HealtcareLicenesApi = defineTemplateApi({ externalDataId: 'healthcareLicenses', }) -export const UniversityCareersApi = defineTemplateApi({ - action: ApiActions.getMyAcademicCareer, - externalDataId: 'universityCareer', -}) - export const ProcessPermitsApi = defineTemplateApi({ action: ApiActions.processPermits, externalDataId: 'permitOptions', }) - -export const NationalRegistryUserApi = defineTemplateApi({ - action: ApiActions.getNationalRegistryWithEESValidation, - externalDataId: 'nationalRegistry', -}) diff --git a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts index 05d67bf6a91f..9313b21eb931 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/Prerequisites/index.ts @@ -6,7 +6,12 @@ import { buildSubmitField, coreMessages, } from '@island.is/application/core' -import { DefaultEvents, Form, FormModes } from '@island.is/application/types' +import { + DefaultEvents, + Form, + FormModes, + NationalRegistryUserApi, +} from '@island.is/application/types' import { confirmation, externalData, @@ -18,7 +23,6 @@ import { EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, UserProfileApi, - NationalRegistryUserApi, ProcessPermitsApi, } from '../../dataProviders' @@ -53,7 +57,11 @@ export const Prerequisites: Form = buildForm({ }), dataProviders: [ buildDataProviderItem({ - provider: NationalRegistryUserApi, + provider: NationalRegistryUserApi.configure({ + params: { + citizenshipWithinEES: true, + }, + }), title: externalData.nationalRegistry.title, subTitle: externalData.nationalRegistry.subTitle, }), diff --git a/libs/application/templates/healthcare-work-permit/src/index.ts b/libs/application/templates/healthcare-work-permit/src/index.ts index e6f3ddf99fad..d92fef8e5a40 100644 --- a/libs/application/templates/healthcare-work-permit/src/index.ts +++ b/libs/application/templates/healthcare-work-permit/src/index.ts @@ -14,5 +14,3 @@ export * from './lib/messages/information' export * from './lib/types' export default template - -export { EES } from './utils/EES' diff --git a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts index c9cad69448ba..9beee0bab451 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/HealthcareWorkPermitTemplate.ts @@ -9,6 +9,7 @@ import { DefaultEvents, defineTemplateApi, InstitutionNationalIds, + NationalRegistryUserApi, } from '@island.is/application/types' import { EphemeralStateLifeCycle, @@ -24,8 +25,6 @@ import { UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, HealtcareLicenesApi, - UniversityCareersApi, - NationalRegistryUserApi, ProcessPermitsApi, } from '../dataProviders' import { buildPaymentState } from '@island.is/application/utils' @@ -82,10 +81,13 @@ const template: ApplicationTemplate< write: 'all', delete: true, api: [ - NationalRegistryUserApi, + NationalRegistryUserApi.configure({ + params: { + citizenshipWithinEES: true, + }, + }), UserProfileApi, EmbaettiLandlaeknisPaymentCatalogApi, - UniversityCareersApi, HealtcareLicenesApi, ProcessPermitsApi, ], diff --git a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts index 5851aec2decf..2e3ceb846cd3 100644 --- a/libs/application/templates/healthcare-work-permit/src/shared/constants.ts +++ b/libs/application/templates/healthcare-work-permit/src/shared/constants.ts @@ -3,6 +3,5 @@ export enum ApiActions { getMyHealthcareLicenses = 'getMyHealthcareLicenses', getMyAcademicCareer = 'getMyAcademicCareer', getEducationInfo = 'getEducationInfo', - getNationalRegistryWithEESValidation = 'getNationalRegistryWithEESValidation', processPermits = 'processPermits', } diff --git a/libs/application/types/src/lib/template-api/shared-api/shared-api-definitions/national-registry-user.ts b/libs/application/types/src/lib/template-api/shared-api/shared-api-definitions/national-registry-user.ts index c9574a1d11ad..c1f33d57daf2 100644 --- a/libs/application/types/src/lib/template-api/shared-api/shared-api-definitions/national-registry-user.ts +++ b/libs/application/types/src/lib/template-api/shared-api/shared-api-definitions/national-registry-user.ts @@ -8,6 +8,7 @@ export interface NationalRegistryParameters { icelandicCitizenship?: boolean validateAlreadyHasIcelandicCitizenship?: boolean allowPassOnChild?: boolean + citizenshipWithinEES?: boolean } export interface ChildrenCustodyInformationParameters { diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 44fc1a78f103..2f90df10c5b3 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -19,6 +19,7 @@ import { import { isDefined } from '@island.is/shared/utils' import format from 'date-fns/format' import { handle404 } from '@island.is/clients/middlewares' +import { logger } from '@island.is/logging' @Injectable() export class HealthDirectorateClientService { @@ -189,13 +190,21 @@ export class HealthDirectorateClientService { }) if (!items || !Array.isArray(items) || items.length === 0) { - throw new Error('No items returned') + logger.error( + 'Health directorate did not respond with a pdf license to practice', + ) + throw new Error( + 'Health directorate did not respond with a pdf license to practice', + ) } - for (const item of items) { - if (!item.base64String) { - throw new Error('Empty file in one of the items') - } + if (items.some((item) => !item.base64String)) { + logger.error( + 'Either the license to practice and/or license number pdf is missing from response', + ) + throw new Error( + 'Either the license to practice and/or license number pdf is missing from response', + ) } return items From 79de51bbc6db41572ea3fafa82f11a21cb090e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 07:51:55 +0000 Subject: [PATCH 22/30] removing comment --- .../src/lib/healthDirectorateClient.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 2f90df10c5b3..484834ad5a2a 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -167,6 +167,7 @@ export class HealthDirectorateClientService { const educationInfo = await this.umsoknStarfsleyfiApiWith( auth, ).umsoknStarfsleyfiNamsUpplysGet() + // .catch(handle404) return educationInfo } From 8b594ba451c5c63408cf525eb27b7f8871adfd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 08:43:53 +0000 Subject: [PATCH 23/30] error handling --- .../src/lib/healthDirectorateClient.service.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 484834ad5a2a..369aaecdb77d 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -1,5 +1,5 @@ import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools' -import { Inject, Injectable, NotFoundException } from '@nestjs/common' +import { Injectable } from '@nestjs/common' import { NamsUpplysingar, StarfsleyfiAMinumSidumApi, @@ -164,10 +164,18 @@ export class HealthDirectorateClientService { async getHealthCareWorkPermitEducationInfo( auth: Auth, ): Promise { - const educationInfo = await this.umsoknStarfsleyfiApiWith( - auth, - ).umsoknStarfsleyfiNamsUpplysGet() - // .catch(handle404) + const educationInfo = await this.umsoknStarfsleyfiApiWith(auth) + .umsoknStarfsleyfiNamsUpplysGet() + .catch(handle404) + + if (!educationInfo) { + logger.error( + 'Health directorate not responding with education info, which is required to process potential permits', + ) + throw new Error( + 'Health directorate not responding with education info, which is required to process potential permits', + ) + } return educationInfo } From 107887181671184ece052e2933ac9c90817ae003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 09:24:58 +0000 Subject: [PATCH 24/30] removing unnecessary block --- .../healthcare-work-permit.service.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 5d63e7690614..dbb60c62535a 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -135,15 +135,13 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { const careerPrograms = careerProgramsHI?.concat(careerProgramsUNAK ?? []) if (!careerPrograms || careerPrograms?.length < 1) { - { - throw new TemplateApiError( - { - title: errorMsg.emptyCareerResponseTitle, - summary: errorMsg.emptyCareerResponseMessage, - }, - 400, - ) - } + throw new TemplateApiError( + { + title: errorMsg.emptyCareerResponseTitle, + summary: errorMsg.emptyCareerResponseMessage, + }, + 400, + ) } // Programs that give licenses to practice (permits) From ea218a71e9ebb0ed55bf0471739d7b02be9b457a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 10:14:01 +0000 Subject: [PATCH 25/30] Validation in personalSection --- .../healthcare-work-permit.service.ts | 1 + .../forms/HealthcareWorkPermitForm/personalSection.ts | 11 ++++------- .../healthcare-work-permit/src/lib/dataSchema.ts | 4 ++++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index dbb60c62535a..4b592ffd2710 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -25,6 +25,7 @@ import { StudentTrackDto, UniversityCareersClientService, UniversityId, + UniversityIdShort, } from '@island.is/clients/university-careers' import { EinstaklingurDTOFaeding, diff --git a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts index 38dcaa8ab266..7f342bafa92c 100644 --- a/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts +++ b/libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts @@ -30,7 +30,7 @@ export const PersonalSection = buildSection({ readOnly: true, format: '######-####', defaultValue: (application: Application) => - application.externalData?.nationalRegistry?.data?.kennitala, + application.externalData?.nationalRegistry?.data?.nationalId, }), buildTextField({ id: 'userInformation.name', @@ -39,8 +39,7 @@ export const PersonalSection = buildSection({ width: 'half', readOnly: true, defaultValue: (application: Application) => - application.externalData?.nationalRegistry?.data?.fulltNafn - ?.fulltNafn, + application.externalData?.nationalRegistry?.data?.fullName, }), buildTextField({ id: 'userInformation.birthDate', @@ -50,8 +49,7 @@ export const PersonalSection = buildSection({ readOnly: true, defaultValue: (application: Application) => formatDate( - application.externalData?.nationalRegistry?.data?.faedingarstadur - ?.faedingarDagur, + application.externalData?.nationalRegistry?.data?.birthDate, ), }), buildTextField({ @@ -61,8 +59,7 @@ export const PersonalSection = buildSection({ width: 'half', readOnly: true, defaultValue: (application: Application) => - application.externalData?.nationalRegistry?.data?.rikisfang - ?.rikisfangLand, + application.externalData?.nationalRegistry?.data?.citizenship.name, }), buildTextField({ id: 'userInformation.email', diff --git a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts index 0cc9a9edff54..4f6e7adda687 100644 --- a/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts +++ b/libs/application/templates/healthcare-work-permit/src/lib/dataSchema.ts @@ -3,6 +3,10 @@ import { z } from 'zod' const UserInformationSchema = z.object({ email: z.string().min(1), phone: z.string().min(1), + nationalId: z.string().min(1), + name: z.string().min(1), + birthDate: z.string().min(1), + citizenship: z.string().min(1), }) const SelectWorkPermitSchema = z.object({ From 48beaa488814ff73f61d7eef2d9032d4acc70765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 10:32:38 +0000 Subject: [PATCH 26/30] removing unused imports and types --- .../healthcare-work-permit.service.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index 4b592ffd2710..eb22f1dd0da1 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -25,23 +25,7 @@ import { StudentTrackDto, UniversityCareersClientService, UniversityId, - UniversityIdShort, } from '@island.is/clients/university-careers' -import { - EinstaklingurDTOFaeding, - EinstaklingurDTOHeimili, - EinstaklingurDTONafnAllt, - EinstaklingurDTORikisfang, -} from '@island.is/clients/national-registry-v3' - -export interface EinstaklingurDTO { - kennitala?: string | null - nafn?: string | null - heimilisfang?: EinstaklingurDTOHeimili - rikisfang?: EinstaklingurDTORikisfang - faedingarstadur?: EinstaklingurDTOFaeding - fulltNafn?: EinstaklingurDTONafnAllt -} const getFoundationProgram = ( professionId: string, From 33eb3d2fb1a023515df1790e822f5678fea55cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 12:48:04 +0000 Subject: [PATCH 27/30] Logging in client and returning null --- .../healthcare-work-permit.service.ts | 35 +++++++++------ .../lib/healthDirectorateClient.service.ts | 45 ++++++++++--------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts index eb22f1dd0da1..d2741e156a7f 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.service.ts @@ -108,7 +108,7 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { 400, ) } - if (licenses === undefined) { + if (licenses === undefined || licenses === null) { throw new TemplateApiError( { title: errorMsg.healthcareLicenseErrorTitle, @@ -371,17 +371,26 @@ export class HealthcareWorkPermitService extends BaseTemplateApiService { educations.push(chosenProgram.foundationProgram) } - return await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( - auth, - { - name: fullName, - dateOfBirth: birthDate, - email: email, - phone: phone, - idProfession: chosenProgram.professionId, - citizenship: citizenship.code, - education: educations, - }, - ) + const response = + await this.healthDirectorateClientService.submitApplicationHealthcareWorkPermit( + auth, + { + name: fullName, + dateOfBirth: birthDate, + email: email, + phone: phone, + idProfession: chosenProgram.professionId, + citizenship: citizenship.code, + education: educations, + }, + ) + + if (!response) { + throw Error( + 'Health Directorate did not respond with a PDF license and/or PDF license number', + ) + } + + return response } } diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 369aaecdb77d..2ce09d68324e 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -153,28 +153,33 @@ export class HealthDirectorateClientService { async getHealthCareLicensesForWorkPermit( auth: Auth, - ): Promise { - const licenses = await this.umsoknStarfsleyfiApiWith( - auth, - ).umsoknStarfsleyfiStarfsleyfiGet() + ): Promise { + const licenses = await this.umsoknStarfsleyfiApiWith(auth) + .umsoknStarfsleyfiStarfsleyfiGet() + .catch(handle404) + + if (!licenses) { + logger.warn( + 'Failed to fetch users healthcare licenses from Health Directorate. Unable to process application without this data with risk of giving out duplicate licenses', + ) + return null + } return licenses } async getHealthCareWorkPermitEducationInfo( auth: Auth, - ): Promise { + ): Promise { const educationInfo = await this.umsoknStarfsleyfiApiWith(auth) .umsoknStarfsleyfiNamsUpplysGet() .catch(handle404) - if (!educationInfo) { - logger.error( - 'Health directorate not responding with education info, which is required to process potential permits', - ) - throw new Error( - 'Health directorate not responding with education info, which is required to process potential permits', + if (educationInfo) { + logger.warn( + 'Health directorate did not provide the required education information needed to process permits. Unable to process potential permits without this data.', ) + return null } return educationInfo @@ -183,7 +188,7 @@ export class HealthDirectorateClientService { async submitApplicationHealthcareWorkPermit( auth: User, request: HealthcareWorkPermitRequest, - ): Promise { + ): Promise { const items = await this.umsoknStarfsleyfiApiWith( auth, ).umsoknStarfsleyfiUtbuaSkjalPost({ @@ -199,21 +204,17 @@ export class HealthDirectorateClientService { }) if (!items || !Array.isArray(items) || items.length === 0) { - logger.error( - 'Health directorate did not respond with a pdf license to practice', - ) - throw new Error( - 'Health directorate did not respond with a pdf license to practice', + logger.warn( + 'Health directorate response is missing the PDF license to practice. User has already been through payment process. Attention required.', ) + return null } if (items.some((item) => !item.base64String)) { - logger.error( - 'Either the license to practice and/or license number pdf is missing from response', - ) - throw new Error( - 'Either the license to practice and/or license number pdf is missing from response', + logger.warn( + 'Health directorate response is missing the PDF license to practice or the license number. User has already been through payment process. Attention required.', ) + return null } return items From a2c1474231e19364d031b803ad0c6b84b49bf7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Thu, 13 Jun 2024 13:04:06 +0000 Subject: [PATCH 28/30] inverting boolean if check after testing logger functionality --- .../src/lib/healthDirectorateClient.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts index 2ce09d68324e..022318582776 100644 --- a/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts +++ b/libs/clients/health-directorate/src/lib/healthDirectorateClient.service.ts @@ -175,7 +175,7 @@ export class HealthDirectorateClientService { .umsoknStarfsleyfiNamsUpplysGet() .catch(handle404) - if (educationInfo) { + if (!educationInfo) { logger.warn( 'Health directorate did not provide the required education information needed to process permits. Unable to process potential permits without this data.', ) From df747ae8f656c5c10b34093ecc6a9f0597d97d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Fri, 14 Jun 2024 09:59:17 +0000 Subject: [PATCH 29/30] typing added to FormConclusion, syntax made more concise --- .../index.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx index c27ef079782d..ed8863c14900 100644 --- a/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx +++ b/libs/application/templates/healthcare-work-permit/src/fields/CustomFormConclusionSectionField/index.tsx @@ -5,7 +5,7 @@ import { } from '@island.is/application/types' import { Box, Button, Text, PdfViewer } from '@island.is/island-ui/core' import { useLocale } from '@island.is/localization' -import { FC, useState } from 'react' +import { useState } from 'react' import { AlertMessageFormField, MessageWithLinkButtonFormField, @@ -18,19 +18,16 @@ import { conclusionMessages } from '@island.is/application/ui-forms' import { PermitProgram } from '../../lib' import { HealthcareWorkPermitAnswers } from '../..' -export const CustomFormConclusionSectionField: FC< - React.PropsWithChildren -> = (props) => { +interface PdfFile { + base64: string + filename: string +} + +export const CustomFormConclusionSectionField = (props: FieldBaseProps) => { const { application } = props const { formatMessage } = useLocale() - const [fileToView, setFileToView] = useState< - | { - base64: string - filename: string - } - | undefined - >(undefined) + const [fileToView, setFileToView] = useState(undefined) if (fileToView) { return ( @@ -127,7 +124,7 @@ export const CustomFormConclusionSectionField: FC< filename: index === 0 ? `starfsleyfi_.pdf` : `leyfisnumer_.pdf`, })) }, - setViewPdfFile: (file: { base64: string; filename: string }) => { + setViewPdfFile: (file: PdfFile) => { setFileToView(file) }, }} From 89406251bd400372bbc2d16fcb746c254cb9393a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baldur=20=C3=93li=20Barkarson?= Date: Fri, 14 Jun 2024 13:15:42 +0000 Subject: [PATCH 30/30] Adding configs to app.module --- .../api/src/app/app.module.ts | 16 +++++++++++ .../healthcare-work-permit.module.ts | 28 ++----------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/apps/application-system/api/src/app/app.module.ts b/apps/application-system/api/src/app/app.module.ts index d81eb4cafd50..4fe70fb4e56b 100644 --- a/apps/application-system/api/src/app/app.module.ts +++ b/apps/application-system/api/src/app/app.module.ts @@ -38,6 +38,15 @@ import { SignatureCollectionClientConfig } from '@island.is/clients/signature-co import { InnaClientConfig } from '@island.is/clients/inna' import { OfficialJournalOfIcelandClientConfig } from '@island.is/clients/official-journal-of-iceland' import { OfficialJournalOfIcelandApplicationClientConfig } from '@island.is/clients/official-journal-of-iceland/application' +import { HealthDirectorateClientConfig } from '@island.is/clients/health-directorate' +import { + AgriculturalUniversityOfIcelandCareerClientConfig, + BifrostUniversityCareerClientConfig, + HolarUniversityCareerClientConfig, + IcelandUniversityOfTheArtsCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, + UniversityOfIcelandCareerClientConfig, +} from '@island.is/clients/university-careers' @Module({ imports: [ @@ -79,6 +88,13 @@ import { OfficialJournalOfIcelandApplicationClientConfig } from '@island.is/clie InnaClientConfig, OfficialJournalOfIcelandClientConfig, OfficialJournalOfIcelandApplicationClientConfig, + HealthDirectorateClientConfig, + AgriculturalUniversityOfIcelandCareerClientConfig, + BifrostUniversityCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, + UniversityOfIcelandCareerClientConfig, + HolarUniversityCareerClientConfig, + IcelandUniversityOfTheArtsCareerClientConfig, ], }), ], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts index c0350c3a9bd6..05c9b1dc99d1 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/healthcare-work-permit/healthcare-work-permit.module.ts @@ -1,21 +1,9 @@ import { DynamicModule } from '@nestjs/common' -import { ConfigModule } from '@nestjs/config' import { SharedTemplateAPIModule } from '../../shared' import { BaseTemplateAPIModuleConfig } from '../../../types' import { HealthcareWorkPermitService } from './healthcare-work-permit.service' -import { - HealthDirectorateClientModule, - HealthDirectorateClientConfig, -} from '@island.is/clients/health-directorate' -import { - AgriculturalUniversityOfIcelandCareerClientConfig, - BifrostUniversityCareerClientConfig, - HolarUniversityCareerClientConfig, - IcelandUniversityOfTheArtsCareerClientConfig, - UniversityCareersClientModule, - UniversityOfAkureyriCareerClientConfig, - UniversityOfIcelandCareerClientConfig, -} from '@island.is/clients/university-careers' +import { HealthDirectorateClientModule } from '@island.is/clients/health-directorate' +import { UniversityCareersClientModule } from '@island.is/clients/university-careers' export class HealthcareWorkPermitModule { static register(baseConfig: BaseTemplateAPIModuleConfig): DynamicModule { @@ -25,18 +13,6 @@ export class HealthcareWorkPermitModule { SharedTemplateAPIModule.register(baseConfig), HealthDirectorateClientModule, UniversityCareersClientModule, - ConfigModule.forRoot({ - isGlobal: true, - load: [ - HealthDirectorateClientConfig, - AgriculturalUniversityOfIcelandCareerClientConfig, - BifrostUniversityCareerClientConfig, - UniversityOfAkureyriCareerClientConfig, - UniversityOfIcelandCareerClientConfig, - HolarUniversityCareerClientConfig, - IcelandUniversityOfTheArtsCareerClientConfig, - ], - }), ], providers: [HealthcareWorkPermitService], exports: [HealthcareWorkPermitService],