From e4af46a7a463bda3d1eb0aeb864c0d99aa8ef97b Mon Sep 17 00:00:00 2001 From: Jason Lin <98117700+JasonLin0991@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:41:03 -0400 Subject: [PATCH] Fix additional actuary duplication and add tests. (#1954) * Fix additional actuary duplication and add tests. * cypress re-run --- .../convertContractWithRatesToHPP.ts | 11 +++++++++-- .../updateHealthPlanFormData.test.ts | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/services/app-api/src/domain-models/contractAndRates/convertContractWithRatesToHPP.ts b/services/app-api/src/domain-models/contractAndRates/convertContractWithRatesToHPP.ts index 0ad2968a29..c9ccbb8bf8 100644 --- a/services/app-api/src/domain-models/contractAndRates/convertContractWithRatesToHPP.ts +++ b/services/app-api/src/domain-models/contractAndRates/convertContractWithRatesToHPP.ts @@ -17,6 +17,7 @@ import { import type { ContractRevisionWithRatesType } from './revisionTypes' import { parsePartialHPFD } from '../../../../app-web/src/common-code/proto/healthPlanFormDataProto/toDomain' import type { PartialHealthPlanFormData } from '../../../../app-web/src/common-code/proto/healthPlanFormDataProto/toDomain' +import { isEqualData } from '../../resolvers/healthPlanPackage/contractAndRates/resolverHelpers' function convertContractWithRatesToUnlockedHPP( contract: ContractType @@ -91,7 +92,7 @@ function convertContractWithRatesToFormData( stateNumber: number ): HealthPlanFormDataType | Error { // additional certifying actuaries are on every rate post refactor but on the package pre-refactor - const pkgAdditionalCertifyingActuaries: Set = new Set() + const pkgAdditionalCertifyingActuaries: ActuaryContact[] = [] let pkgActuaryCommsPref: ActuaryCommunicationType | undefined = undefined const rateInfos: RateInfoType[] = contractRev.rateRevisions.map( @@ -115,7 +116,13 @@ function convertContractWithRatesToFormData( } = rateRev.formData for (const additionalActuary of addtlActuaryContacts) { - pkgAdditionalCertifyingActuaries.add(additionalActuary) + if ( + !pkgAdditionalCertifyingActuaries.find((actuary) => + isEqualData(actuary, additionalActuary) + ) + ) { + pkgAdditionalCertifyingActuaries.push(additionalActuary) + } } // The first time we find a rate that has an actuary comms pref, we use that to set the package's prefs diff --git a/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts b/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts index c065a25320..c39c52967d 100644 --- a/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts +++ b/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts @@ -257,6 +257,22 @@ describe.each(flagValueTestParameters)( // update that draft form data. const formData = Object.assign(latestFormData(createdDraft), { + addtlActuaryContacts: [ + { + name: 'additional actuary 1', + titleRole: 'additional actuary title 1', + email: 'additionalactuary1@example.com', + actuarialFirm: 'MERCER' as const, + actuarialFirmOther: '', + }, + { + name: 'additional actuary 2', + titleRole: 'additional actuary title 2', + email: 'additionalactuary1@example.com', + actuarialFirm: 'MERCER' as const, + actuarialFirmOther: '', + }, + ], rateInfos: [rate1, rate2], })