Skip to content

Commit

Permalink
Move actuary contacts section to rate details page (#2365)
Browse files Browse the repository at this point in the history
* WIP: moved actuary radio group

* form validation

* removal from contacts page

* added flexibility to span

* added addtlActuaryContacts

* dynamic addtnlActuaryContacts form working wip

* testing

* removed old tests

* test fixes

* removing unneeded work after pivoting back to dynamic functionality

* removed cypress tests

* cypress fixes

* more test fixes

* v1 ratedetails

* moved comms preference, still need to follow up with fixing tests

* v2 test fixes

* v1 test fixes

* test fix

* test fixes

* something isnt working here WIP

* cypress fixes

* updating test

* cypress fixes

* Update protobuffer functions for rate additl actuary workaround. Update zod.

* Only save addtl actuaries at the rate level.

* Update API and helpers with rate level addtl actuaries workaround.

* Use addtlActuaryContacts from rate data.

* Display addtl actuaries from rate level.

* Update for addtl actuary change.

* test fix

* small fix for cypress

* A comment

* Another comment

---------

Co-authored-by: Jason Lin <maolin@truss.works>
Co-authored-by: MacRae Linton <macrael@truss.works>
  • Loading branch information
3 people authored Apr 30, 2024
1 parent f58aa97 commit b02ef4f
Show file tree
Hide file tree
Showing 43 changed files with 1,000 additions and 919 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
ActuaryCommunicationType,
ActuaryContact,
HealthPlanFormDataType,
RateInfoType,
SubmissionDocument,
Expand All @@ -17,7 +16,6 @@ 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 +89,6 @@ function convertContractWithRatesToFormData(
stateNumber: number
): HealthPlanFormDataType | Error {
// additional certifying actuaries are on every rate post refactor but on the package pre-refactor
const pkgAdditionalCertifyingActuaries: ActuaryContact[] = []
let pkgActuaryCommsPref: ActuaryCommunicationType | undefined = undefined

const rateInfos: RateInfoType[] = contractRev.rateRevisions.map(
Expand All @@ -114,16 +111,6 @@ function convertContractWithRatesToFormData(
actuaryCommunicationPreference,
} = rateRev.formData

for (const additionalActuary of addtlActuaryContacts) {
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
if (actuaryCommunicationPreference && !pkgActuaryCommsPref) {
pkgActuaryCommsPref = actuaryCommunicationPreference
Expand Down Expand Up @@ -151,6 +138,7 @@ function convertContractWithRatesToFormData(
rateProgramIDs,
rateCertificationName,
actuaryContacts: certifyingActuaryContacts ?? [],
addtlActuaryContacts: addtlActuaryContacts ?? [],
actuaryCommunicationPreference,
packagesWithSharedRateCerts,
}
Expand All @@ -171,7 +159,6 @@ function convertContractWithRatesToFormData(
submissionDescription: contractRev.formData.submissionDescription,
stateContacts: contractRev.formData.stateContacts,
addtlActuaryCommunicationPreference: pkgActuaryCommsPref,
addtlActuaryContacts: [...pkgAdditionalCertifyingActuaries],
documents: contractRev.formData.supportingDocuments.map((doc) => ({
...doc,
})) as SubmissionDocument[],
Expand Down Expand Up @@ -225,6 +212,12 @@ function convertContractWithRatesToFormData(
contractRev.formData.modifiedNonRiskPaymentArrangements,
},
},
/**
* This field is unused and will need cleaned up, additional actuaries have been moved to the rate level.
* Leaving this as am empty array to get linked rates feature work in without having to fix all the broken tests
* by removing this field.
*/
addtlActuaryContacts: [],
statutoryRegulatoryAttestation:
contractRev.formData.statutoryRegulatoryAttestation,
statutoryRegulatoryAttestationDescription:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,12 @@ function updateDraftContractRates(
let thisPosition = 1
for (const rateUpdate of parsedUpdates) {
if (rateUpdate.type === 'CREATE') {

// set rateName for now https://jiraent.cms.gov/browse/MCR-4012
const rateName = generateRateCertificationName(
rateUpdate.formData,
contract.stateCode,
contract.stateNumber,
statePrograms,
statePrograms
)

rateUpdates.create.push({
Expand Down Expand Up @@ -206,7 +205,12 @@ function updateDraftContractRates(
throw new Error(errmsg)
}

if (!(rateToUpdate.status === 'DRAFT' || rateToUpdate.status === 'UNLOCKED')) {
if (
!(
rateToUpdate.status === 'DRAFT' ||
rateToUpdate.status === 'UNLOCKED'
)
) {
// eventually, this will be enough to cancel this. But until we have unlock-rate, you can edit UNLOCKED children of this contract.
const errmsg =
'Attempted to update a rate that is not editable: ' +
Expand All @@ -230,7 +234,7 @@ function updateDraftContractRates(
rateUpdate.formData,
contract.stateCode,
contract.stateNumber,
statePrograms,
statePrograms
)

rateUpdates.update.push({
Expand All @@ -253,7 +257,6 @@ function updateDraftContractRates(
ratePosition: thisPosition,
})
} else {

// linked rates must exist and not be DRAFT
const rateToLink = await store.findRateWithHistory(
rateUpdate.rateID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ describe('convertHealthPlanPackageRatesToDomain', () => {
email: 'actuarycontact1@test.com',
},
],
addtlActuaryContacts: [
{
actuarialFirm: 'DELOITTE',
name: 'Additional Actuary Contact',
titleRole: 'Test Additional Actuary Contact',
email: 'additionalactuarycontact1@test.com',
},
],
actuaryCommunicationPreference: 'OACT_TO_ACTUARY',
packagesWithSharedRateCerts: [],
},
Expand Down Expand Up @@ -199,6 +207,14 @@ describe('convertHealthPlanPackageRatesToDomain', () => {
email: 'actuarycontact1@test.com',
},
],
addtlActuaryContacts: [
{
actuarialFirm: 'DELOITTE',
name: 'Additional Actuary Contact',
titleRole: 'Test Additional Actuary Contact',
email: 'additionalactuarycontact1@test.com',
},
],
actuaryCommunicationPreference: 'OACT_TO_ACTUARY',
packagesWithSharedRateCerts: [
{
Expand All @@ -217,15 +233,8 @@ describe('convertHealthPlanPackageRatesToDomain', () => {
},
],
stateContacts: [],
addtlActuaryContacts: [],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
addtlActuaryContacts: [
{
actuarialFirm: 'DELOITTE',
name: 'Additional Actuary Contact',
titleRole: 'Test Actuary Contact',
email: 'additionalactuarycontact1@test.com',
},
],
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
Expand Down Expand Up @@ -258,12 +267,11 @@ describe('convertHealthPlanPackageRatesToDomain', () => {
],
actuaryCommunicationPreference: 'OACT_TO_ACTUARY',
packagesWithSharedRateCerts: [],
// Additional actuaries from package should be in each rate now.
addtlActuaryContacts: [
{
actuarialFirm: 'DELOITTE',
name: 'Additional Actuary Contact',
titleRole: 'Test Actuary Contact',
titleRole: 'Test Additional Actuary Contact',
email: 'additionalactuarycontact1@test.com',
},
],
Expand Down Expand Up @@ -308,7 +316,7 @@ describe('convertHealthPlanPackageRatesToDomain', () => {
{
actuarialFirm: 'DELOITTE',
name: 'Additional Actuary Contact',
titleRole: 'Test Actuary Contact',
titleRole: 'Test Additional Actuary Contact',
email: 'additionalactuarycontact1@test.com',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ const convertHealthPlanPackageRatesToDomain = async (
rateProgramIDs: hppRateFormData.rateProgramIDs,
rateCertificationName: hppRateFormData.rateCertificationName,
certifyingActuaryContacts: hppRateFormData.actuaryContacts,
// Frontend UI saves both these two values ar the contract level of the HPP type. Our new Contract type does
// not have these two fields, they are at the rate revision level. So, when converting we need to get the
// values from the HPP contract and set them into our rate.
addtlActuaryContacts: unlockedFormData.addtlActuaryContacts,
addtlActuaryContacts: hppRateFormData.addtlActuaryContacts,
// toProtobuffer already does this, so we can directly set the value from the rate data.
actuaryCommunicationPreference:
hppRateFormData.actuaryCommunicationPreference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ describe(`Tests unlockHealthPlanPackage`, () => {
email: 'en@example.com',
actuarialFirm: 'MERCER',
},
],
addtlActuaryContacts: [
{
name: 'Enrico Soletzo 2',
titleRole: 'person',
Expand Down Expand Up @@ -383,8 +385,14 @@ describe(`Tests unlockHealthPlanPackage`, () => {
finallySubmittedFormData.rateInfos[0].actuaryContacts.map(
(c) => c.name
)
expect(actuariesInOrder).toEqual([
'Enrico Soletzo 1',
expect(actuariesInOrder).toEqual(['Enrico Soletzo 1'])

// checks additional actuaries in order
const addtlActuariesInOrder =
finallySubmittedFormData.rateInfos[0].addtlActuaryContacts?.map(
(c) => c.name
)
expect(addtlActuariesInOrder).toEqual([
'Enrico Soletzo 2',
'Enrico Soletzo 3',
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,28 @@ describe(`Tests UpdateHealthPlanFormData`, () => {

// update that draft form data.
const formData = Object.assign(latestFormData(createdDraft), {
addtlActuaryContacts: [
rateInfos: [
{
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: '',
...rate1,
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: '',
},
],
},
rate2,
],
rateInfos: [rate1, rate2],
})

// convert to base64 proto
Expand Down Expand Up @@ -284,6 +289,18 @@ describe(`Tests UpdateHealthPlanFormData`, () => {
packageName: packageWithSharedRate2.packageName,
}),
]),
addtlActuaryContacts: expect.arrayContaining([
expect.objectContaining({
name: 'additional actuary 1',
titleRole: 'additional actuary title 1',
email: 'additionalactuary1@example.com',
}),
expect.objectContaining({
name: 'additional actuary 2',
titleRole: 'additional actuary title 2',
email: 'additionalactuary1@example.com',
}),
]),
}),
expect.objectContaining({
...rate2,
Expand Down
Loading

0 comments on commit b02ef4f

Please sign in to comment.