From 915fc6eca10d20f478d781b32da785f7853cbd6a Mon Sep 17 00:00:00 2001 From: haworku Date: Thu, 13 Jul 2023 15:48:17 -0500 Subject: [PATCH] MR03434 Move addtl actuary to rate revision, remove from contract (#1812) * Prisma schema update - clarify naming between certifying and addtl - move actuary related fields off contacts entirely and onto rates - fix typo with submitted on UpdateInfoTable --- .../migration.sql | 30 +++++++++++++++++++ services/app-api/prisma/schema.prisma | 17 +++++------ .../contractAndRates/contractType.ts | 4 --- .../findContractWithHistory.ts | 1 - .../contractAndRates/findDraftRate.ts | 1 - .../contractAndRates/findRateWithHistory.ts | 1 - .../postgres/contractAndRates/insertRate.ts | 1 - .../prismaToDomainModel.test.ts | 2 -- .../contractAndRates/prismaToDomainModel.ts | 13 -------- .../app-api/src/postgres/prismaHelpers.ts | 1 - services/app-api/src/postgres/prismaTypes.ts | 2 -- 11 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql diff --git a/services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql b/services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql new file mode 100644 index 0000000000..a4042373da --- /dev/null +++ b/services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql @@ -0,0 +1,30 @@ +BEGIN; +/* + Warnings: + + - You are about to drop the column `contractRevisionID` on the `ActuaryContact` table. All the data in the column will be lost. + - You are about to drop the column `rateRevisionID` on the `ActuaryContact` table. All the data in the column will be lost. + - You are about to drop the column `addtlActuaryCommunicationPreference` on the `ContractRevisionTable` table. All the data in the column will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "ActuaryContact" DROP CONSTRAINT "ActuaryContact_contractRevisionID_fkey"; + +-- DropForeignKey +ALTER TABLE "ActuaryContact" DROP CONSTRAINT "ActuaryContact_rateRevisionID_fkey"; + +-- AlterTable +ALTER TABLE "ActuaryContact" DROP COLUMN "contractRevisionID", +DROP COLUMN "rateRevisionID", +ADD COLUMN "rateWithAddtlActuaryID" TEXT, +ADD COLUMN "rateWithCertifyingActuaryID" TEXT; + +-- AlterTable +ALTER TABLE "ContractRevisionTable" DROP COLUMN "addtlActuaryCommunicationPreference"; + +-- AddForeignKey +ALTER TABLE "ActuaryContact" ADD CONSTRAINT "ActuaryContact_rateWithCertifyingActuaryID_fkey" FOREIGN KEY ("rateWithCertifyingActuaryID") REFERENCES "RateRevisionTable"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ActuaryContact" ADD CONSTRAINT "ActuaryContact_rateWithAddtlActuaryID_fkey" FOREIGN KEY ("rateWithAddtlActuaryID") REFERENCES "RateRevisionTable"("id") ON DELETE SET NULL ON UPDATE CASCADE; +COMMIT; diff --git a/services/app-api/prisma/schema.prisma b/services/app-api/prisma/schema.prisma index f3de8ff158..e3ffbe5692 100644 --- a/services/app-api/prisma/schema.prisma +++ b/services/app-api/prisma/schema.prisma @@ -83,8 +83,6 @@ model ContractRevisionTable { populationCovered PopulationCoverageType? riskBasedContract Boolean? stateContacts StateContact[] - addtlActuaryContacts ActuaryContact[] - addtlActuaryCommunicationPreference ActuaryCommunication? supportingDocuments ContractSupportingDocument[] contractType ContractType contractExecutionStatus ContractExecutionStatus? @@ -138,7 +136,8 @@ model RateRevisionTable { amendmentEffectiveDateEnd DateTime? @db.Date rateProgramIDs String[] rateCertificationName String? - actuaryContacts ActuaryContact[] + certifyingActuaryContacts ActuaryContact[] @relation(name: "CertifyingActuaryOnRateRevision") + addtlActuaryContacts ActuaryContact[] @relation(name: "AddtlActuaryOnRateRevision") actuaryCommunicationPreference ActuaryCommunication? packagesWithSharedRateCerts SharedRateCertifications[] } @@ -163,9 +162,9 @@ model UpdateInfoTable { updatedBy User @relation(fields: [updatedByID], references: [id]) updatedReason String unlockedContracts ContractRevisionTable[] @relation("unlockContractInfo") - submitedContracts ContractRevisionTable[] @relation("submitContractInfo") + submittedContracts ContractRevisionTable[] @relation("submitContractInfo") unlockedRates RateRevisionTable[] @relation("unlockRateInfo") - submitedRates RateRevisionTable[] @relation("submitRateInfo") + submittedRates RateRevisionTable[] @relation("submitRateInfo") } model SharedRateCertifications { @@ -185,10 +184,10 @@ model ActuaryContact { email String actuarialFirm ActuarialFirm actuarialFirmOther String? - contractRevisionID String? - contractRevision ContractRevisionTable? @relation(fields: [contractRevisionID], references: [id]) - rateRevisionID String? - rateRevision RateRevisionTable? @relation(fields: [rateRevisionID], references: [id]) + rateWithCertifyingActuaryID String? + rateWithAddtlActuaryID String? + rateActuaryCertifying RateRevisionTable? @relation(name: "CertifyingActuaryOnRateRevision", fields: [ rateWithCertifyingActuaryID ], references: [id]) + rateActuaryAddtl RateRevisionTable? @relation(name: "AddtlActuaryOnRateRevision", fields: [ rateWithAddtlActuaryID ], references: [id]) } model ContractDocument { diff --git a/services/app-api/src/domain-models/contractAndRates/contractType.ts b/services/app-api/src/domain-models/contractAndRates/contractType.ts index 2c11066316..6fc0a085dc 100644 --- a/services/app-api/src/domain-models/contractAndRates/contractType.ts +++ b/services/app-api/src/domain-models/contractAndRates/contractType.ts @@ -1,7 +1,6 @@ import { UpdateInfoType } from '../index' import { RateRevision } from './rateType' import { - ActuaryCommunicationType, ContractExecutionStatus, ContractType, PopulationCoveredType, @@ -9,7 +8,6 @@ import { SubmissionDocument, SubmissionType, FederalAuthority, - ActuaryContact, } from 'app-web/src/common-code/healthPlanFormDataType' // Contract represents the contract specific information in a submission package @@ -44,8 +42,6 @@ type ContractFormData = { riskBasedContract?: boolean submissionDescription?: string stateContacts: StateContact[] - addtlActuaryContacts: ActuaryContact[] - addtlActuaryCommunicationPreference?: ActuaryCommunicationType supportingDocuments: SubmissionDocument[] contractType?: ContractType contractExecutionStatus?: ContractExecutionStatus diff --git a/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts b/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts index 3de72378c0..65cde7c84c 100644 --- a/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts +++ b/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts @@ -56,7 +56,6 @@ async function findContractWithHistory( }, }, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, contract: true, diff --git a/services/app-api/src/postgres/contractAndRates/findDraftRate.ts b/services/app-api/src/postgres/contractAndRates/findDraftRate.ts index 35e76085f3..31175a2dd6 100644 --- a/services/app-api/src/postgres/contractAndRates/findDraftRate.ts +++ b/services/app-api/src/postgres/contractAndRates/findDraftRate.ts @@ -24,7 +24,6 @@ async function findDraftRate( submitInfo: updateInfoIncludeUpdater, unlockInfo: updateInfoIncludeUpdater, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, rateRevisions: { diff --git a/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts b/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts index 224e671986..9f92559253 100644 --- a/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts +++ b/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts @@ -42,7 +42,6 @@ async function findRateWithHistory( submitInfo: updateInfoIncludeUpdater, unlockInfo: updateInfoIncludeUpdater, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, rateRevisions: { diff --git a/services/app-api/src/postgres/contractAndRates/insertRate.ts b/services/app-api/src/postgres/contractAndRates/insertRate.ts index 5dd06b3958..621b2d44b3 100644 --- a/services/app-api/src/postgres/contractAndRates/insertRate.ts +++ b/services/app-api/src/postgres/contractAndRates/insertRate.ts @@ -48,7 +48,6 @@ async function insertDraftRate( }, }, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, }, diff --git a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts index b14eba87ad..03b21eb07f 100644 --- a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts +++ b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts @@ -18,8 +18,6 @@ describe('prismaToDomainModel', () => { riskBasedContract: false, submissionDescription: 'Test', stateContacts: [], - addtlActuaryContacts: [], - addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY', supportingDocuments: [ { id: 'contractSupportingDocID', diff --git a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts index da5a1d0f1c..64ae8952cc 100644 --- a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts +++ b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts @@ -2,7 +2,6 @@ import { ContractFormData } from '../../domain-models/contractAndRates/contractT import { UpdateInfoTableWithUpdater } from '../prismaTypes' import { UpdateInfoType } from '../../domain-models/HealthPlanPackageType' import { - ActuaryContact, ContractDocument, ContractRevisionTable, ContractSupportingDocument, @@ -13,7 +12,6 @@ import { type ContractFormDataType = ContractRevisionTable & { stateContacts: StateContact[] - addtlActuaryContacts: ActuaryContact[] contractDocuments: ContractDocument[] supportingDocuments: ContractSupportingDocument[] managedCareEntities: ManagedCareEntity[] @@ -34,17 +32,6 @@ function contractFormDataToDomainModel( titleRole: contact.titleRole, email: contact.email, })), - addtlActuaryContacts: contractRevision.addtlActuaryContacts.map( - (contact) => ({ - name: contact.name, - titleRole: contact.titleRole, - email: contact.email, - actuarialFirm: contact.actuarialFirm, - actuarialFirmOther: contact.actuarialFirmOther ?? undefined, - }) - ), - addtlActuaryCommunicationPreference: - contractRevision.addtlActuaryCommunicationPreference ?? undefined, supportingDocuments: contractRevision.supportingDocuments.map( (doc) => ({ name: doc.name, diff --git a/services/app-api/src/postgres/prismaHelpers.ts b/services/app-api/src/postgres/prismaHelpers.ts index 02a96fd42a..a08fbc8b49 100644 --- a/services/app-api/src/postgres/prismaHelpers.ts +++ b/services/app-api/src/postgres/prismaHelpers.ts @@ -6,7 +6,6 @@ const updateInfoIncludeUpdater = { const draftContractRevisionsWithDraftRates = { stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, draftRates: { diff --git a/services/app-api/src/postgres/prismaTypes.ts b/services/app-api/src/postgres/prismaTypes.ts index 763b0bb9a4..3de68797ba 100644 --- a/services/app-api/src/postgres/prismaTypes.ts +++ b/services/app-api/src/postgres/prismaTypes.ts @@ -1,5 +1,4 @@ import { - ActuaryContact, ContractDocument, ContractRevisionTable, ContractSupportingDocument, @@ -23,7 +22,6 @@ type ContractRevisionTableWithRelations = ContractRevisionTable & { submitInfo?: UpdateInfoTableWithUpdater | null unlockInfo?: UpdateInfoTableWithUpdater | null stateContacts: StateContact[] - addtlActuaryContacts: ActuaryContact[] contractDocuments: ContractDocument[] supportingDocuments: ContractSupportingDocument[] managedCareEntities: ManagedCareEntity[]