-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
services/app-api/src/postgres/contractAndRates/migrateContractData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
PrismaClient, | ||
ContractRevisionTable, | ||
HealthPlanRevisionTable, | ||
ManagedCareEntity, | ||
} from '@prisma/client' | ||
import { UnlockedHealthPlanFormDataType } from 'app-web/src/common-code/healthPlanFormDataType' | ||
import { toDomain } from 'app-web/src/common-code/proto/healthPlanFormDataProto' | ||
|
||
async function createContractRevision( | ||
client: PrismaClient, | ||
revision: HealthPlanRevisionTable | ||
): Promise<ContractRevisionTable | Error> { | ||
try { | ||
// Decode the formDataProto | ||
const decodedFormDataProto = toDomain(revision.formDataProto) | ||
if (decodedFormDataProto instanceof Error) throw decodedFormDataProto | ||
const formData = decodedFormDataProto as UnlockedHealthPlanFormDataType | ||
|
||
// Create ContractRevisionTable entry from HealthPlanRevisionTable entry | ||
const contractRevision: ContractRevisionTable = { | ||
id: formData.id, | ||
contractID: revision.id, // Set contractID as revision.id | ||
unlockInfoID: null, | ||
submitInfoID: null, | ||
createdAt: formData.createdAt, | ||
updatedAt: formData.updatedAt, | ||
submissionType: formData.submissionType, | ||
submissionDescription: formData.submissionDescription, | ||
programIDs: formData.programIDs, | ||
populationCovered: formData.populationCovered || null, | ||
riskBasedContract: formData.riskBasedContract || null, | ||
contractType: formData.contractType || 'BASE', | ||
contractExecutionStatus: formData.contractExecutionStatus || null, | ||
contractDateStart: formData.contractDateStart || null, | ||
contractDateEnd: formData.contractDateEnd || null, | ||
managedCareEntities: | ||
formData.managedCareEntities as ManagedCareEntity[], | ||
federalAuthorities: formData.federalAuthorities, | ||
modifiedBenefitsProvided: null, | ||
modifiedGeoAreaServed: null, | ||
modifiedMedicaidBeneficiaries: null, | ||
modifiedRiskSharingStrategy: null, | ||
modifiedIncentiveArrangements: null, | ||
modifiedWitholdAgreements: null, | ||
modifiedStateDirectedPayments: null, | ||
modifiedPassThroughPayments: null, | ||
modifiedPaymentsForMentalDiseaseInstitutions: null, | ||
modifiedMedicalLossRatioStandards: null, | ||
modifiedOtherFinancialPaymentIncentive: null, | ||
modifiedEnrollmentProcess: null, | ||
modifiedGrevienceAndAppeal: null, | ||
modifiedNetworkAdequacyStandards: null, | ||
modifiedLengthOfContract: null, | ||
modifiedNonRiskPaymentArrangements: null, | ||
inLieuServicesAndSettings: null, | ||
} | ||
|
||
const createdContractRevision = | ||
await client.contractRevisionTable.create({ | ||
data: contractRevision, | ||
}) | ||
|
||
return createdContractRevision | ||
} catch (error) { | ||
console.error( | ||
`Error creating contract revision ${JSON.stringify(error)}` | ||
) | ||
return new Error('Error creating contract revision') | ||
} | ||
} | ||
|
||
export { createContractRevision } |