Skip to content

Commit

Permalink
Start building test converters to go from HPP to contract rates - nee…
Browse files Browse the repository at this point in the history
…ds these for existing tests to keep working
  • Loading branch information
haworku committed Jun 4, 2024
1 parent 3583411 commit 721b8c2
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 111 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import type { UnlockedHealthPlanFormDataType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { ContractFormData, RateFormData } from '../../gen/gqlServer'

// interim solution -this file was made to deal with test helpers that may expect contract rates when we only have HPP coming from another test helper

// Take a HPP domain model and return form datas we can use in contract or rate test helpers
// if there are no rates on this contract, return null
const convertUnlockedHPPToContractAndRates = (
pkg: UnlockedHealthPlanFormDataType
): [ContractFormData, RateFormData[]] => {
const {
submissionType,
submissionDescription,
stateContacts,
contractType,
contractExecutionStatus,
contractDateStart,
contractDateEnd,
contractDocuments,
managedCareEntities,
federalAuthorities,
populationCovered,
statutoryRegulatoryAttestation,
statutoryRegulatoryAttestationDescription,
programIDs,
documents,
} = pkg

const contractFormData: ContractFormData = {
submissionType,
submissionDescription,
stateContacts,
contractType,
contractExecutionStatus,
contractDateStart,
contractDateEnd,
programIDs,
contractDocuments,
supportingDocuments: documents,
managedCareEntities,
federalAuthorities,
populationCovered,
inLieuServicesAndSettings:
pkg.contractAmendmentInfo?.modifiedProvisions
.inLieuServicesAndSettings,
modifiedRiskSharingStrategy:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedRiskSharingStrategy,
modifiedIncentiveArrangements:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedIncentiveArrangements,
modifiedWitholdAgreements:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedWitholdAgreements,
modifiedStateDirectedPayments:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedStateDirectedPayments,
modifiedPassThroughPayments:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedPassThroughPayments,
modifiedPaymentsForMentalDiseaseInstitutions:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedPaymentsForMentalDiseaseInstitutions,
modifiedNonRiskPaymentArrangements:
pkg.contractAmendmentInfo?.modifiedProvisions
.modifiedNonRiskPaymentArrangements,
statutoryRegulatoryAttestation,
statutoryRegulatoryAttestationDescription,
}
const rateFormDatas: RateFormData[] = pkg.rateInfos.map(
(rateInfo): RateFormData => {
const {
rateType,
rateCapitationType,
rateCertificationName,
rateDateCertified,
rateDateEnd,
rateDateStart,
rateDocuments = [],
supportingDocuments = [],
rateProgramIDs = [],
addtlActuaryContacts = [],
actuaryCommunicationPreference,
} = rateInfo

return {
rateType,
rateCapitationType,
rateCertificationName,
rateDateCertified,
rateDateEnd,
rateDateStart,
rateDocuments,
supportingDocuments,
rateProgramIDs,
certifyingActuaryContacts: [rateInfo.actuaryContacts[0]],
deprecatedRateProgramIDs: [], //ignore this deprecated field
packagesWithSharedRateCerts: [], // ignore this depårecated field
addtlActuaryContacts,
actuaryCommunicationPreference,
}
}
)

return [contractFormData, rateFormDatas]
}

export { convertUnlockedHPPToContractAndRates }
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export function parseAndSubmit(
: draft.statutoryRegulatoryAttestation ||
(draft.statutoryRegulatoryAttestation === false &&
draft.statutoryRegulatoryAttestationDescription)

if (
isValidAndCurrentLockedHealthPlanFormData(maybeStateSubmission) &&
hasValid438Attestation
Expand Down
49 changes: 22 additions & 27 deletions services/app-api/src/testHelpers/gqlContractHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import { mockInsertContractArgs, mockContractData } from './contractDataMocks'
import { sharedTestPrismaClient } from './storeHelpers'
import { insertDraftContract } from '../postgres/contractAndRates/insertContract'

import type { ContractType } from '../domain-models'
import { type ContractType } from '../domain-models'
import type { ApolloServer } from 'apollo-server-lambda'
import type { Contract, RateFormData } from '../gen/gqlServer'
import type { Contract, ContractFormData, RateFormData } from '../gen/gqlServer'
import { latestFormData } from './healthPlanPackageHelpers'
import type {
StateCodeType,
UnlockedHealthPlanFormDataType,
} from 'app-web/src/common-code/healthPlanFormDataType'
import type { StateCodeType } from 'app-web/src/common-code/healthPlanFormDataType'
import { addNewRateToTestContract } from './gqlRateHelpers'

const createAndSubmitTestContract = async (
Expand Down Expand Up @@ -149,7 +146,7 @@ async function createAndUpdateTestContractWithRate(
const createAndUpdateTestContractWithoutRates = async (
server: ApolloServer,
stateCode?: StateCodeType,
contractFormDataOverrides?: Partial<UnlockedHealthPlanFormDataType>
contractFormDataOverrides?: Partial<ContractFormData>
): Promise<Contract> => {
const pkg = await createTestHealthPlanPackage(server, stateCode)
const draft = latestFormData(pkg)
Expand Down Expand Up @@ -200,11 +197,12 @@ const createAndUpdateTestContractWithoutRates = async (
return updatedContract
}

const linkRateToDraftContract = async ( server: ApolloServer,
const linkRateToDraftContract = async (
server: ApolloServer,
contractID: string,
linkedRateID: string) => {

const updatedContract = await server.executeOperation({
linkedRateID: string
) => {
const updatedContract = await server.executeOperation({
query: UPDATE_DRAFT_CONTRACT_RATES,
variables: {
input: {
Expand All @@ -221,18 +219,16 @@ const linkRateToDraftContract = async ( server: ApolloServer,
return updatedContract
}

const clearRatesOnDraftContract = async ( server: ApolloServer,
contractID: string,
) => {

const updatedContract = await server.executeOperation({
const clearRatesOnDraftContract = async (
server: ApolloServer,
contractID: string
) => {
const updatedContract = await server.executeOperation({
query: UPDATE_DRAFT_CONTRACT_RATES,
variables: {
input: {
contractID: contractID,
updatedRates: [

],
updatedRates: [],
},
},
})
Expand All @@ -243,10 +239,9 @@ const updateRateOnDraftContract = async (
server: ApolloServer,
contractID: string,
rateID: string,
rateData: Partial<RateFormData>,
) : Promise<ContractType> => {

const updatedContract = await server.executeOperation({
rateData: Partial<RateFormData>
): Promise<ContractType> => {
const updatedContract = await server.executeOperation({
query: UPDATE_DRAFT_CONTRACT_RATES,
variables: {
input: {
Expand All @@ -255,19 +250,19 @@ const updateRateOnDraftContract = async (
{
type: 'UPDATE',
formData: rateData,
rateID: rateID
rateID: rateID,
},
],
},
},
})
must(updatedContract)
const contractData = updatedContract.data?.updateDraftContractRates.contract
if (!contractData)throw Error (`malformatted response: ${updatedContract.data}` )
if (!contractData)
throw Error(`malformatted response: ${updatedContract.data}`)
return updatedContract.data?.contract
}


export {
createTestContract,
submitTestContract,
Expand All @@ -278,5 +273,5 @@ export {
createAndSubmitTestContractWithRate,
linkRateToDraftContract,
updateRateOnDraftContract,
clearRatesOnDraftContract
clearRatesOnDraftContract,
}
Loading

0 comments on commit 721b8c2

Please sign in to comment.