Skip to content

Commit

Permalink
Fix additional actuary duplication and add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Oct 3, 2023
1 parent 9bfc027 commit 0b02582
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<ActuaryContact> = new Set()
const pkgAdditionalCertifyingActuaries: ActuaryContact[] = []
let pkgActuaryCommsPref: ActuaryCommunicationType | undefined = undefined

const rateInfos: RateInfoType[] = contractRev.rateRevisions.map(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
})

Expand Down

0 comments on commit 0b02582

Please sign in to comment.