Skip to content

Commit

Permalink
MCR-3988 Update the Dates in Documents Table to use Contract data (#2352
Browse files Browse the repository at this point in the history
)

* WIP

* Simply FE by reading from new dateAdded field

* Progress on backend with types

* WIP - loosen types further and start fixing up transformation between domain model and prisma

* WIP

* Fixup app-api tests

* Progress towards date added displaying without errors

* Simplify UploadedDocumentsTable props and tests passing
  • Loading branch information
haworku authored Apr 9, 2024
1 parent de259c8 commit a9eabdd
Show file tree
Hide file tree
Showing 50 changed files with 771 additions and 733 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const documentSchema = z.object({
name: z.string(),
s3URL: z.string(),
sha256: z.string(),
dateAdded: z.date().optional(), // date added to the first submission to CMS
})

const managedCareEntitiesSchema = z.union([
Expand Down Expand Up @@ -90,10 +91,19 @@ const rateFormDataSchema = z.object({
.optional(),
})

type DocumentType = z.infer<typeof documentSchema>
type ContractFormDataType = z.infer<typeof contractFormDataSchema>
type RateFormDataType = z.infer<typeof rateFormDataSchema>
type DocumentType = z.infer<typeof documentSchema>

type ContractFormEditableType = Partial<ContractFormDataType>
type RateFormEditableType = Partial<RateFormDataType>

export { contractFormDataSchema, rateFormDataSchema }

export type { ContractFormDataType, RateFormDataType, DocumentType }
export type {
ContractFormDataType,
RateFormDataType,
DocumentType,
RateFormEditableType,
ContractFormEditableType,
}
2 changes: 2 additions & 0 deletions services/app-api/src/domain-models/contractAndRates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type {
ContractFormDataType,
RateFormDataType,
DocumentType,
RateFormEditableType,
ContractFormEditableType,
} from './formDataTypes'

export type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const formData: ContractFormDataType = {
s3URL: 'bar',
name: 'foo',
sha256: 'fakesha',
dateAdded: new Date(),
},
],
contractType: 'BASE',
Expand Down
8 changes: 5 additions & 3 deletions services/app-api/src/postgres/contractAndRates/insertRate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { StateCodeType } from '../../../../app-web/src/common-code/healthPlanFormDataType'
import type { RateType } from '../../domain-models/contractAndRates'
import type {
RateFormEditableType,
RateType,
} from '../../domain-models/contractAndRates'
import { parseRateWithHistory } from './parseRateWithHistory'
import { includeFullRate } from './prismaSubmittedRateHelpers'
import type { PrismaClient } from '@prisma/client'
import type { RateFormEditable } from './updateDraftRate'

type InsertRateArgsType = RateFormEditable & {
type InsertRateArgsType = RateFormEditableType & {
stateCode: StateCodeType
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
import type {
ContractFormEditableType,
RateFormEditableType,
} from '../../domain-models/contractAndRates'
import type { GenericDocument } from '../../gen/gqlServer'
import { emptify, nullify } from '../prismaDomainAdaptors'

// ADD RETURN TYPES FROM PRISMA SEE "includes" "satifies"
// contractTableFullPayload - contractTableCreateArgs / contract

// Generic helpers
const formatDocsForPrisma = (docs: GenericDocument[]) => {
return docs.map((d, idx) => {
delete d['dateAdded']
return {
position: idx,
...d,
}
})
}

function formatOrderedListForPrisma<T>(list: T[]): T[] {
return list.map((item, idx) => ({
position: idx,
...item,
}))
}

// Rate helpers
function prismaRateCreateFormDataFromDomain(
rateFormData: RateFormEditableType
) {
return {
rateType: rateFormData.rateType,
rateCapitationType: rateFormData.rateCapitationType,
rateDateStart: rateFormData.rateDateStart,
rateDateEnd: rateFormData.rateDateEnd,
rateDateCertified: rateFormData.rateDateCertified,
amendmentEffectiveDateStart: rateFormData.amendmentEffectiveDateStart,
amendmentEffectiveDateEnd: rateFormData.amendmentEffectiveDateEnd,
rateProgramIDs: rateFormData.rateProgramIDs,
rateCertificationName: rateFormData.rateCertificationName,
rateDocuments: {
create:
rateFormData.rateDocuments &&
formatDocsForPrisma(rateFormData.rateDocuments),
},
supportingDocuments: {
create:
rateFormData.supportingDocuments &&
formatDocsForPrisma(rateFormData.supportingDocuments),
},
certifyingActuaryContacts: {
create:
rateFormData.certifyingActuaryContacts &&
formatOrderedListForPrisma(
rateFormData.certifyingActuaryContacts
),
},
addtlActuaryContacts: {
create:
rateFormData.addtlActuaryContacts &&
formatOrderedListForPrisma(rateFormData.addtlActuaryContacts),
},
actuaryCommunicationPreference:
rateFormData.actuaryCommunicationPreference,
}
}

function prismaUpdateRateFormDataFromDomain(
rateFormData: RateFormEditableType
) {
return {
rateType: nullify(rateFormData.rateType),
rateCapitationType: nullify(rateFormData.rateCapitationType),
rateDateStart: nullify(rateFormData.rateDateStart),
rateDateEnd: nullify(rateFormData.rateDateEnd),
rateDateCertified: nullify(rateFormData.rateDateCertified),
amendmentEffectiveDateStart: nullify(
rateFormData.amendmentEffectiveDateStart
),
amendmentEffectiveDateEnd: nullify(
rateFormData.amendmentEffectiveDateEnd
),
rateProgramIDs: emptify(rateFormData.rateProgramIDs),
rateCertificationName: nullify(rateFormData.rateCertificationName),
rateDocuments: {
deleteMany: {},
create:
rateFormData.rateDocuments &&
formatDocsForPrisma(rateFormData.rateDocuments),
},
supportingDocuments: {
deleteMany: {},
create:
rateFormData.supportingDocuments &&
formatDocsForPrisma(rateFormData.supportingDocuments),
},
certifyingActuaryContacts: {
deleteMany: {},
create:
rateFormData.certifyingActuaryContacts &&
formatOrderedListForPrisma(
rateFormData.certifyingActuaryContacts
),
},
addtlActuaryContacts: {
deleteMany: {},
create:
rateFormData.addtlActuaryContacts &&
formatOrderedListForPrisma(rateFormData.addtlActuaryContacts),
},
actuaryCommunicationPreference:
rateFormData.actuaryCommunicationPreference,
}
}

// Contract helpers
function prismaCreateContractFormDataFromDomain(
contractFormData: ContractFormEditableType
) {
const {
submissionType,
submissionDescription,
programIDs,
populationCovered,
riskBasedContract,
stateContacts,
supportingDocuments,
contractType,
contractExecutionStatus,
contractDocuments,
contractDateStart,
contractDateEnd,
managedCareEntities,
federalAuthorities,
modifiedBenefitsProvided,
modifiedGeoAreaServed,
modifiedMedicaidBeneficiaries,
modifiedRiskSharingStrategy,
modifiedIncentiveArrangements,
modifiedWitholdAgreements,
modifiedStateDirectedPayments,
modifiedPassThroughPayments,
modifiedPaymentsForMentalDiseaseInstitutions,
modifiedMedicalLossRatioStandards,
modifiedOtherFinancialPaymentIncentive,
modifiedEnrollmentProcess,
modifiedGrevienceAndAppeal,
modifiedNetworkAdequacyStandards,
modifiedLengthOfContract,
modifiedNonRiskPaymentArrangements,
inLieuServicesAndSettings,
} = contractFormData

return {
populationCovered: populationCovered,
programIDs: programIDs,
riskBasedContract: riskBasedContract,
submissionType: submissionType,
submissionDescription: submissionDescription,
contractType: contractType,
contractExecutionStatus,
contractDocuments: {
create: contractDocuments && formatDocsForPrisma(contractDocuments),
},
supportingDocuments: {
create:
supportingDocuments && formatDocsForPrisma(supportingDocuments),
},
stateContacts: {
create: stateContacts && formatOrderedListForPrisma(stateContacts),
},
contractDateStart,
contractDateEnd,
managedCareEntities,
federalAuthorities,
modifiedBenefitsProvided,
modifiedGeoAreaServed,
modifiedMedicaidBeneficiaries,
modifiedRiskSharingStrategy,
modifiedIncentiveArrangements,
modifiedWitholdAgreements,
modifiedStateDirectedPayments,
modifiedPassThroughPayments,
modifiedPaymentsForMentalDiseaseInstitutions,
modifiedMedicalLossRatioStandards,
modifiedOtherFinancialPaymentIncentive,
modifiedEnrollmentProcess,
modifiedGrevienceAndAppeal,
modifiedNetworkAdequacyStandards,
modifiedLengthOfContract,
modifiedNonRiskPaymentArrangements,
inLieuServicesAndSettings,
}
}
function prismaUpdateContractFormDataFromDomain(
contractFormData: ContractFormEditableType
) {
return {
populationCovered: nullify(contractFormData.populationCovered),
programIDs: emptify(contractFormData.programIDs),
riskBasedContract: nullify(contractFormData.riskBasedContract),
submissionType: contractFormData.submissionType,
submissionDescription: contractFormData.submissionDescription,
contractType: contractFormData.contractType,
contractExecutionStatus: nullify(
contractFormData.contractExecutionStatus
),
contractDocuments: {
deleteMany: {},
create:
contractFormData.contractDocuments &&
formatDocsForPrisma(contractFormData.contractDocuments),
},
supportingDocuments: {
deleteMany: {},
create:
contractFormData.supportingDocuments &&
formatDocsForPrisma(contractFormData.supportingDocuments),
},
stateContacts: {
deleteMany: {},
create:
contractFormData.stateContacts &&
formatOrderedListForPrisma(contractFormData.stateContacts),
},
contractDateStart: nullify(contractFormData.contractDateStart),
contractDateEnd: nullify(contractFormData.contractDateEnd),
managedCareEntities: emptify(contractFormData.managedCareEntities),
federalAuthorities: emptify(contractFormData.federalAuthorities),
inLieuServicesAndSettings: nullify(
contractFormData.inLieuServicesAndSettings
),
modifiedBenefitsProvided: nullify(
contractFormData.modifiedBenefitsProvided
),
modifiedGeoAreaServed: nullify(contractFormData.modifiedGeoAreaServed),
modifiedMedicaidBeneficiaries: nullify(
contractFormData.modifiedMedicaidBeneficiaries
),
modifiedRiskSharingStrategy: nullify(
contractFormData.modifiedRiskSharingStrategy
),
modifiedIncentiveArrangements: nullify(
contractFormData.modifiedIncentiveArrangements
),
modifiedWitholdAgreements: nullify(
contractFormData.modifiedWitholdAgreements
),
modifiedStateDirectedPayments: nullify(
contractFormData.modifiedStateDirectedPayments
),
modifiedPassThroughPayments: nullify(
contractFormData.modifiedPassThroughPayments
),
modifiedPaymentsForMentalDiseaseInstitutions: nullify(
contractFormData.modifiedPaymentsForMentalDiseaseInstitutions
),
modifiedMedicalLossRatioStandards: nullify(
contractFormData.modifiedMedicalLossRatioStandards
),
modifiedOtherFinancialPaymentIncentive: nullify(
contractFormData.modifiedOtherFinancialPaymentIncentive
),
modifiedEnrollmentProcess: nullify(
contractFormData.modifiedEnrollmentProcess
),
modifiedGrevienceAndAppeal: nullify(
contractFormData.modifiedGrevienceAndAppeal
),
modifiedNetworkAdequacyStandards: nullify(
contractFormData.modifiedNetworkAdequacyStandards
),
modifiedLengthOfContract: nullify(
contractFormData.modifiedLengthOfContract
),
modifiedNonRiskPaymentArrangements: nullify(
contractFormData.modifiedNonRiskPaymentArrangements
),
statutoryRegulatoryAttestation: nullify(
contractFormData.statutoryRegulatoryAttestation
),
statutoryRegulatoryAttestationDescription: nullify(
contractFormData.statutoryRegulatoryAttestationDescription
),
}
}
export {
prismaRateCreateFormDataFromDomain,
prismaUpdateRateFormDataFromDomain,
prismaUpdateContractFormDataFromDomain,
prismaCreateContractFormDataFromDomain,
}
Loading

0 comments on commit a9eabdd

Please sign in to comment.