Skip to content

Commit

Permalink
Refactor updateDraftContractRates handler into updateDraftContract.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Sep 11, 2023
1 parent 6eed285 commit 8436474
Show file tree
Hide file tree
Showing 13 changed files with 771 additions and 1,004 deletions.
6 changes: 3 additions & 3 deletions services/app-api/src/domain-models/healthPlanPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ function convertContractRateRevisionToHealthPlanRevision(
rateProgramIDs: formData.rateProgramIDs,
rateCertificationName: formData.rateCertificationName,
actuaryContacts: formData.certifyingActuaryContacts?.length
? formData.certifyingActuaryContacts
? formData.certifyingActuaryContacts.concat(
formData.addtlActuaryContacts ?? []
)
: [],
// From the TODO in convertContractRevisionToHealthPlanRevision, these can just be set as whatever is in the
// database. The frontend does not read this values.
Expand All @@ -150,8 +152,6 @@ function convertContractRevisionToHealthPlanRevision(
// the rate revision level. Since at update contract we are setting both fields in each rate using what the values
// on the contract level, when we pull data out from our new DB model, we need to do the inverse by using, the
// the first rates values.
// This will need to be updated and fixed when we figure out shared rates, because shared rates are not
// guaranteed to have the same values.
const addtlActuaryCommunicationPreference =
contract.draftRevision?.rateRevisions[0]?.formData
?.actuaryCommunicationPreference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { updateDraftRate } from './updateDraftRate'
import { unlockRate } from './unlockRate'
import { findRateWithHistory } from './findRateWithHistory'
import { must, createInsertContractData } from '../../testHelpers'
import { updateDraftContractRates } from './updateDraftContractRates'
import { createInsertRateData } from '../../testHelpers/contractAndRates/rateHelpers'
import type { DraftContractType } from '../../domain-models/contractAndRates'

describe('findContract', () => {
it('finds a stripped down contract with history', async () => {
Expand Down Expand Up @@ -187,15 +185,15 @@ describe('findContract', () => {
expect(testingContract.revisions).toHaveLength(7)

// Make a new Contract Revision, changing the connections should show up as a single new rev.
must(
const unlockedContractA = must(
await unlockContract(
client,
contractA.id,
cmsUser.id,
'unlocking A.1'
)
)
const updatedDraftContract = must(
must(
await updateDraftContract(client, {
contractID: contractA.id,
formData: {
Expand All @@ -206,17 +204,14 @@ describe('findContract', () => {
populationCovered: 'MEDICAID',
riskBasedContract: false,
},
})
) as DraftContractType

// Remove rate 1 and rate 2 from contract
must(
await updateDraftContractRates(client, {
draftContract: updatedDraftContract,
disconnectRates: [rate1.id, rate2.id],
rateFormDatas:
unlockedContractA.draftRevision?.rateRevisions.filter(
(rateRevision) =>
rateRevision.formData.rateID !== rate1.id &&
rateRevision.formData.rateID !== rate2.id
),
})
)

must(
await submitContract(
client,
Expand Down Expand Up @@ -467,15 +462,16 @@ describe('findContract', () => {
)

// Make a new Contract Revision, changing the connections should show up as a single new rev.
must(
const unlockedContractA = must(
await unlockContract(
client,
contractA.id,
cmsUser.id,
'unlocking A.1'
)
)
const updatedDraftContract = must(
// Remove rate 1 and rate 2 from contract
must(
await updateDraftContract(client, {
contractID: contractA.id,
formData: {
Expand All @@ -486,14 +482,12 @@ describe('findContract', () => {
populationCovered: 'MEDICAID',
riskBasedContract: false,
},
})
) as DraftContractType

// Remove rate 1 and rate 2 from contract
must(
await updateDraftContractRates(client, {
draftContract: updatedDraftContract,
disconnectRates: [rate1.id, rate2.id],
rateFormDatas:
unlockedContractA.draftRevision?.rateRevisions.filter(
(rateRevision) =>
rateRevision.formData.rateID !== rate1.id &&
rateRevision.formData.rateID !== rate2.id
),
})
)

Expand Down Expand Up @@ -592,11 +586,13 @@ describe('findContract', () => {
})

const rate1 = createInsertRateData({
id: uuidv4(),
stateCode: 'MN',
rateCertificationName: 'onepoint0',
})

const rate2 = createInsertRateData({
id: uuidv4(),
stateCode: 'MN',
rateCertificationName: 'twopoint0',
})
Expand All @@ -608,7 +604,7 @@ describe('findContract', () => {
const contractA = must(
await insertDraftContract(client, draftContractData)
)
const updatedDraftContract = must(
const updatedDraftContractWithRates = must(
await updateDraftContract(client, {
contractID: contractA.id,
formData: {
Expand All @@ -619,14 +615,7 @@ describe('findContract', () => {
populationCovered: 'MEDICAID',
riskBasedContract: false,
},
})
) as DraftContractType

// Add rate 1 and rate 2 to contract
const updatedDraftContractWithRates = must(
await updateDraftContractRates(client, {
draftContract: updatedDraftContract,
connectOrCreate: [rate1, rate2],
rateFormDatas: [rate1, rate2],
})
)

Expand Down
Loading

0 comments on commit 8436474

Please sign in to comment.