Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
pearl-truss committed Apr 11, 2024
1 parent a9eabdd commit 1652d80
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 124 deletions.
15 changes: 8 additions & 7 deletions services/app-web/src/common-code/ContractType.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import { Contract, ContractRevision } from '../gen/gqlClient'
import { getLastContractSubmission } from '../gqlHelpers/contractsAndRates'

const getContractRev = (contract: Contract): ContractRevision => {
const getContractRev = (contract: Contract): ContractRevision | undefined => {
if (contract.draftRevision) {
return contract.draftRevision
} else {
return contract.packageSubmissions[0].contractRevision
return getLastContractSubmission(contract)?.contractRevision
}
}
const isContractOnly = (contract: Contract): boolean => {
const contractRev = getContractRev(contract)
return contractRev.formData.submissionType === 'CONTRACT_ONLY'
return contractRev?.formData?.submissionType === 'CONTRACT_ONLY'
}


const isBaseContract = (contract: Contract): boolean => {
const contractRev = getContractRev(contract)
return contractRev.formData.contractType === 'BASE'
return contractRev?.formData?.contractType === 'BASE'
}

const isContractAmendment = (contract: Contract): boolean => {
const contractRev = getContractRev(contract)
return contractRev.formData.contractType === 'AMENDMENT'
return contractRev?.formData?.contractType === 'AMENDMENT'
}

const isCHIPOnly = (contract: Contract): boolean => {
const contractRev = getContractRev(contract)
return contractRev.formData.populationCovered === 'CHIP'
return contractRev?.formData?.populationCovered === 'CHIP'
}

const isContractAndRates = (contract: Contract): boolean => {
const contractRev = getContractRev(contract)
return contractRev.formData.submissionType === 'CONTRACT_AND_RATES'
return contractRev?.formData?.submissionType === 'CONTRACT_AND_RATES'
}

const isContractWithProvisions = (contract: Contract): boolean =>
Expand Down
41 changes: 21 additions & 20 deletions services/app-web/src/common-code/ContractTypeProvisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
isContractAmendment,
isContractWithProvisions,
} from './ContractType'
import { getLastContractSubmission } from '../gqlHelpers/contractsAndRates'

/*
Each provision key represents a Yes/No question asked on Contract Details.
Expand Down Expand Up @@ -84,27 +85,27 @@ const generateProvisionLabel = (
const sortModifiedProvisions = (
contract: Contract
): [GeneralizedProvisionType[], GeneralizedProvisionType[]] => {
const contractFormData = contract.draftRevision?.formData || contract.packageSubmissions[0].contractRevision.formData
const contractFormData = contract.draftRevision?.formData || getLastContractSubmission(contract)?.contractRevision.formData
const initialProvisions = {
inLieuServicesAndSettings: contractFormData.inLieuServicesAndSettings,
modifiedBenefitsProvided: contractFormData.modifiedBenefitsProvided,
modifiedGeoAreaServed: contractFormData.modifiedGeoAreaServed,
modifiedMedicaidBeneficiaries: contractFormData.modifiedMedicaidBeneficiaries,
modifiedRiskSharingStrategy: contractFormData.modifiedRiskSharingStrategy,
modifiedIncentiveArrangements: contractFormData.modifiedIncentiveArrangements,
modifiedWitholdAgreements: contractFormData.modifiedWitholdAgreements,
modifiedStateDirectedPayments: contractFormData.modifiedStateDirectedPayments,
modifiedPassThroughPayments: contractFormData.modifiedPassThroughPayments,
modifiedPaymentsForMentalDiseaseInstitutions: contractFormData.modifiedPaymentsForMentalDiseaseInstitutions,
modifiedMedicalLossRatioStandards: contractFormData.modifiedMedicalLossRatioStandards,
modifiedOtherFinancialPaymentIncentive: contractFormData.modifiedOtherFinancialPaymentIncentive,
modifiedEnrollmentProcess: contractFormData.modifiedEnrollmentProcess,
modifiedGrevienceAndAppeal: contractFormData.modifiedGrevienceAndAppeal,
modifiedNetworkAdequacyStandards: contractFormData.modifiedNetworkAdequacyStandards,
modifiedLengthOfContract: contractFormData.modifiedLengthOfContract,
modifiedNonRiskPaymentArrangements: contractFormData.modifiedNonRiskPaymentArrangements,
statutoryRegulatoryAttestation: contractFormData.statutoryRegulatoryAttestation,
statutoryRegulatoryAttestationDescription: contractFormData.statutoryRegulatoryAttestationDescription
inLieuServicesAndSettings: contractFormData?.inLieuServicesAndSettings,
modifiedBenefitsProvided: contractFormData?.modifiedBenefitsProvided,
modifiedGeoAreaServed: contractFormData?.modifiedGeoAreaServed,
modifiedMedicaidBeneficiaries: contractFormData?.modifiedMedicaidBeneficiaries,
modifiedRiskSharingStrategy: contractFormData?.modifiedRiskSharingStrategy,
modifiedIncentiveArrangements: contractFormData?.modifiedIncentiveArrangements,
modifiedWitholdAgreements: contractFormData?.modifiedWitholdAgreements,
modifiedStateDirectedPayments: contractFormData?.modifiedStateDirectedPayments,
modifiedPassThroughPayments: contractFormData?.modifiedPassThroughPayments,
modifiedPaymentsForMentalDiseaseInstitutions: contractFormData?.modifiedPaymentsForMentalDiseaseInstitutions,
modifiedMedicalLossRatioStandards: contractFormData?.modifiedMedicalLossRatioStandards,
modifiedOtherFinancialPaymentIncentive: contractFormData?.modifiedOtherFinancialPaymentIncentive,
modifiedEnrollmentProcess: contractFormData?.modifiedEnrollmentProcess,
modifiedGrevienceAndAppeal: contractFormData?.modifiedGrevienceAndAppeal,
modifiedNetworkAdequacyStandards: contractFormData?.modifiedNetworkAdequacyStandards,
modifiedLengthOfContract: contractFormData?.modifiedLengthOfContract,
modifiedNonRiskPaymentArrangements: contractFormData?.modifiedNonRiskPaymentArrangements,
statutoryRegulatoryAttestation: contractFormData?.statutoryRegulatoryAttestation,
statutoryRegulatoryAttestationDescription: contractFormData?.statutoryRegulatoryAttestationDescription
}
const hasInitialProvisions = Object.values(initialProvisions).some((val) => val !== undefined)
const modifiedProvisions: GeneralizedProvisionType[] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export const ContactsSummarySection = ({
const isSubmitted = contract.status === 'SUBMITTED'
const contractFormData =
contract.draftRevision?.formData ||
contract.packageSubmissions[0].contractRevision.formData
getLastContractSubmission(contract)?.contractRevision.formData

let rateRev: RateRevision | undefined = undefined

if (contractFormData.submissionType === 'CONTRACT_AND_RATES') {
if (contractFormData?.submissionType === 'CONTRACT_AND_RATES') {
// Find first rate associated with the contract to deal with rates info on contacts page
// TODO move the fields using this data to rate details
const draftRates = getDraftRates(contract)
Expand All @@ -68,8 +68,8 @@ export const ContactsSummarySection = ({
<GridContainer className="padding-left-0">
<Grid row>
<dl>
{contractFormData.stateContacts.length > 0 ? (
contractFormData.stateContacts.map(
{contractFormData && contractFormData.stateContacts.length > 0 ? (
contractFormData?.stateContacts.map(
(stateContact, index) => (
<DataDetail
key={'statecontact_' + index}
Expand All @@ -95,7 +95,7 @@ export const ContactsSummarySection = ({
</Grid>
</GridContainer>

{contractFormData.submissionType === 'CONTRACT_AND_RATES' && (
{contractFormData?.submissionType === 'CONTRACT_AND_RATES' && (
<>
{rateRev?.formData?.addtlActuaryContacts !== undefined &&
rateRev.formData.addtlActuaryContacts.length > 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ export const ContractDetailsSummarySectionV2 = ({

const contractFormData =
contract.draftRevision?.formData ||
contract.packageSubmissions[0].contractRevision.formData
getLastContractSubmission(contract)?.contractRevision.formData
const contract438Attestation = ldClient?.variation(
featureFlags.CONTRACT_438_ATTESTATION.flag,
featureFlags.CONTRACT_438_ATTESTATION.defaultValue
)

const attestationYesNo =
contractFormData.statutoryRegulatoryAttestation != null &&
contractFormData?.statutoryRegulatoryAttestation != null &&
booleanAsYesNoFormValue(contractFormData.statutoryRegulatoryAttestation)

const contractSupportingDocuments = contractFormData?.supportingDocuments
const isEditing = !isSubmitted(contract) && editNavigateTo !== undefined
const applicableFederalAuthorities = isCHIPOnly(contract)
? contractFormData.federalAuthorities.filter((authority) =>
? contractFormData?.federalAuthorities.filter((authority) =>
federalAuthorityKeysForCHIP.includes(
authority as CHIPFederalAuthority
)
Expand All @@ -116,7 +116,7 @@ export const ContractDetailsSummarySectionV2 = ({

// get all the keys for the documents we want to zip
async function fetchZipUrl() {
const keysFromDocs = contractFormData.contractDocuments
const keysFromDocs = contractSupportingDocuments && contractFormData?.contractDocuments
.concat(contractSupportingDocuments)
.map((doc) => {
const key = getKey(doc.s3URL)
Expand All @@ -126,7 +126,7 @@ export const ContractDetailsSummarySectionV2 = ({
.filter((key) => key !== '')

// call the lambda to zip the files and get the url
const zippedURL = await getBulkDlURL(
const zippedURL = keysFromDocs && await getBulkDlURL(
keysFromDocs,
submissionName + '-contract-details.zip',
'HEALTH_PLAN_DOCS'
Expand Down Expand Up @@ -204,7 +204,7 @@ export const ContractDetailsSummarySectionV2 = ({
label="Non-compliance description"
explainMissingData={!isSubmitted}
children={
contractFormData.statutoryRegulatoryAttestationDescription
contractFormData?.statutoryRegulatoryAttestationDescription
}
/>
</Grid>
Expand Down Expand Up @@ -314,7 +314,7 @@ export const ContractDetailsSummarySectionV2 = ({
</DoubleColumnGrid>
)}
</dl>
{contractFormData.contractDocuments && (
{contractFormData?.contractDocuments && (
<UploadedDocumentsTable
documents={contractFormData.contractDocuments}
previousSubmissionDate={lastSubmittedDate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const RateDetailsSummarySectionV2 = ({
const refreshPackagesWithSharedRateCert = (
rateFormData: RateFormData
): SharedRateCertDisplay[] | undefined => {
return rateFormData.packagesWithSharedRateCerts?.map(
return rateFormData?.packagesWithSharedRateCerts?.map(
({ packageId, packageName }) => {
const refreshedName =
packageId &&
Expand All @@ -118,8 +118,8 @@ export const RateDetailsSummarySectionV2 = ({

const rateCapitationType = (rate: Rate | RateRevision) => {
const rateFormData = getRateFormData(rate)
return rateFormData.rateCapitationType
? rateFormData.rateCapitationType === 'RATE_CELL'
return rateFormData?.rateCapitationType
? rateFormData?.rateCapitationType === 'RATE_CELL'
? 'Certification of capitation rates specific to each rate cell'
: 'Certification of rate ranges of capitation rates per rate cell'
: ''
Expand All @@ -131,10 +131,10 @@ export const RateDetailsSummarySectionV2 = ({
const rateFormData = getRateFormData(rate)

if (
rateFormData.rateProgramIDs &&
rateFormData.rateProgramIDs.length > 0
rateFormData?.rateProgramIDs &&
rateFormData?.rateProgramIDs.length > 0
) {
programIDs = rateFormData.rateProgramIDs
programIDs = rateFormData?.rateProgramIDs
} else if (
contractFormData?.programIDs &&
contractFormData?.programIDs.length > 0
Expand All @@ -150,10 +150,10 @@ export const RateDetailsSummarySectionV2 = ({

const rateCertificationType = (rate: Rate | RateRevision) => {
const rateFormData = getRateFormData(rate)
if (rateFormData.rateType === 'AMENDMENT') {
if (rateFormData?.rateType === 'AMENDMENT') {
return 'Amendment to prior rate certification'
}
if (rateFormData.rateType === 'NEW') {
if (rateFormData?.rateType === 'NEW') {
return 'New rate certification'
}
}
Expand All @@ -166,7 +166,7 @@ export const RateDetailsSummarySectionV2 = ({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return rate.draftRevision!.formData
} else {
return rate.revisions[0].formData
return rate.revisions[0]?.formData
}
} else {
return rate.formData
Expand All @@ -179,7 +179,7 @@ export const RateDetailsSummarySectionV2 = ({

// get all the keys for the documents we want to zip
async function fetchZipUrl() {
const submittedRates = contract.packageSubmissions[0].rateRevisions
const submittedRates = getLastContractSubmission(contract)?.rateRevisions
if (submittedRates !== undefined) {
const keysFromDocs = submittedRates
.flatMap((rateInfo) =>
Expand Down Expand Up @@ -246,7 +246,7 @@ export const RateDetailsSummarySectionV2 = ({
aria-label={`Rate ID: ${rateFormData?.rateCertificationName}`}
className={styles.rateName}
>
{rateFormData.rateCertificationName}
{rateFormData?.rateCertificationName}
</h3>
<dl>
<DoubleColumnGrid>
Expand All @@ -267,15 +267,15 @@ export const RateDetailsSummarySectionV2 = ({
<DataDetail
id="ratingPeriod"
label={
rateFormData.rateType ===
rateFormData?.rateType ===
'AMENDMENT'
? 'Rating period of original rate certification'
: 'Rating period'
}
explainMissingData={!isSubmitted}
children={
rateFormData.rateDateStart &&
rateFormData.rateDateEnd ? (
rateFormData?.rateDateStart &&
rateFormData?.rateDateEnd ? (
`${formatCalendarDate(
rateFormData?.rateDateStart
)} to ${formatCalendarDate(
Expand All @@ -289,13 +289,13 @@ export const RateDetailsSummarySectionV2 = ({
<DataDetail
id="dateCertified"
label={
rateFormData.amendmentEffectiveDateStart
rateFormData?.amendmentEffectiveDateStart
? 'Date certified for rate amendment'
: 'Date certified'
}
explainMissingData={!isSubmitted}
children={formatCalendarDate(
rateFormData.rateDateCertified
rateFormData?.rateDateCertified
)}
/>
{rateFormData?.amendmentEffectiveDateStart ? (
Expand All @@ -304,14 +304,14 @@ export const RateDetailsSummarySectionV2 = ({
label="Rate amendment effective dates"
explainMissingData={!isSubmitted}
children={`${formatCalendarDate(
rateFormData.amendmentEffectiveDateStart
rateFormData?.amendmentEffectiveDateStart
)} to ${formatCalendarDate(
rateFormData.amendmentEffectiveDateEnd
rateFormData?.amendmentEffectiveDateEnd
)}`}
/>
) : null}
{rateFormData
.certifyingActuaryContacts[0] && (
?.certifyingActuaryContacts[0] && (
<DataDetail
id="certifyingActuary"
label="Certifying actuary"
Expand All @@ -336,7 +336,7 @@ export const RateDetailsSummarySectionV2 = ({
</dl>
{rateFormData?.rateDocuments && (
<UploadedDocumentsTable
documents={rateFormData.rateDocuments}
documents={rateFormData?.rateDocuments}
packagesWithSharedRateCerts={
isEditing
? undefined
Expand All @@ -353,7 +353,7 @@ export const RateDetailsSummarySectionV2 = ({
)}
{rateFormData?.supportingDocuments && (
<UploadedDocumentsTable
documents={rateFormData.supportingDocuments}
documents={rateFormData?.supportingDocuments}
previousSubmissionDate={lastSubmittedDate}
packagesWithSharedRateCerts={
isEditing
Expand Down
Loading

0 comments on commit 1652d80

Please sign in to comment.