Skip to content

Commit

Permalink
MR-2364: Dealt with packages with shared rates in the current UI (#1945)
Browse files Browse the repository at this point in the history
* Update packagesWithSharedRateCerts to contractsWithSharedRateRevision.

* Refactor packageName parameters to only accept what is used and move hanlding of no rate programs.

* Add real packagesWithSharedRateCerts data from db to rateFormDataToDomainModel. Update conversion functions to return error types.

* Refactor variable sub with pkg for less confusion. Replace setting value with formData id to pkg id.

* Replace using getProgramsFromState with findStatePrograms and throwing errors in tests if programs are not found.

* Fix imports

* Update contractsWithSharedRateRevision

* Update tests for packages with shared rate certs.

* cypress re-run

* cypress re-run

* Fix some merging stuff.

* cypress re-run
  • Loading branch information
JasonLin0991 authored and haworku committed Oct 16, 2023
1 parent 2d796f0 commit 469a39f
Show file tree
Hide file tree
Showing 54 changed files with 918 additions and 423 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
BEGIN;
/*
Warnings:
- You are about to drop the `SharedRateCertifications` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_ContractRevisionTableToSharedRateCertifications` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_RateRevisionTableToSharedRateCertifications` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "_ContractRevisionTableToSharedRateCertifications" DROP CONSTRAINT "_ContractRevisionTableToSharedRateCertifications_A_fkey";

-- DropForeignKey
ALTER TABLE "_ContractRevisionTableToSharedRateCertifications" DROP CONSTRAINT "_ContractRevisionTableToSharedRateCertifications_B_fkey";

-- DropForeignKey
ALTER TABLE "_RateRevisionTableToSharedRateCertifications" DROP CONSTRAINT "_RateRevisionTableToSharedRateCertifications_A_fkey";

-- DropForeignKey
ALTER TABLE "_RateRevisionTableToSharedRateCertifications" DROP CONSTRAINT "_RateRevisionTableToSharedRateCertifications_B_fkey";

-- DropTable
DROP TABLE "SharedRateCertifications";

-- DropTable
DROP TABLE "_ContractRevisionTableToSharedRateCertifications";

-- DropTable
DROP TABLE "_RateRevisionTableToSharedRateCertifications";

-- CreateTable
CREATE TABLE "_SharedRateRevisions" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "_SharedRateRevisions_AB_unique" ON "_SharedRateRevisions"("A", "B");

-- CreateIndex
CREATE INDEX "_SharedRateRevisions_B_index" ON "_SharedRateRevisions"("B");

-- AddForeignKey
ALTER TABLE "_SharedRateRevisions" ADD CONSTRAINT "_SharedRateRevisions_A_fkey" FOREIGN KEY ("A") REFERENCES "ContractTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_SharedRateRevisions" ADD CONSTRAINT "_SharedRateRevisions_B_fkey" FOREIGN KEY ("B") REFERENCES "RateRevisionTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
13 changes: 3 additions & 10 deletions services/app-api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ model ContractTable {
revisions ContractRevisionTable[]
draftRateRevisions RateRevisionTable[]
sharedRateRevisions RateRevisionTable[] @relation(name: "SharedRateRevisions")
}

model RateTable {
Expand All @@ -66,7 +68,6 @@ model ContractRevisionTable {
contract ContractTable @relation(fields: [contractID], references: [id])
rateRevisions RateRevisionsOnContractRevisionsTable[]
sharedRateRevisions SharedRateCertifications[]
draftRates RateTable[]
unlockInfoID String?
Expand Down Expand Up @@ -138,7 +139,7 @@ model RateRevisionTable {
certifyingActuaryContacts ActuaryContact[] @relation(name: "CertifyingActuaryOnRateRevision")
addtlActuaryContacts ActuaryContact[] @relation(name: "AddtlActuaryOnRateRevision")
actuaryCommunicationPreference ActuaryCommunication?
packagesWithSharedRateCerts SharedRateCertifications[]
contractsWithSharedRateRevision ContractTable[] @relation(name: "SharedRateRevisions")
}

model RateRevisionsOnContractRevisionsTable {
Expand Down Expand Up @@ -166,14 +167,6 @@ model UpdateInfoTable {
submittedRates RateRevisionTable[] @relation("submitRateInfo")
}

model SharedRateCertifications {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
contract ContractRevisionTable[]
rateRevision RateRevisionTable[]
}

model ActuaryContact {
id String @id @default(uuid())
createdAt DateTime @default(now())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ const updateInfoSchema = z.object({
type UpdateInfoType = z.infer<typeof updateInfoSchema>
type PackageStatusType = z.infer<typeof contractSchema.shape.status>

export type { PackageStatusType , UpdateInfoType }
export type { PackageStatusType, UpdateInfoType }

export { updateInfoSchema }
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ test('to addresses list does not include duplicate review email addresses', asyn
test('subject line is correct', async () => {
const sub = mockContractOnlyFormData()
const statePrograms = mockMNState().programs
const name = packageName(sub, statePrograms)
const name = packageName(
sub.stateCode,
sub.stateNumber,
sub.programIDs,
statePrograms
)

const template = await newPackageCMSEmail(
sub,
Expand Down
7 changes: 6 additions & 1 deletion services/app-api/src/emailer/emails/newPackageCMSEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export const newPackageCMSEmail = async (
return packagePrograms
}

const packageName = generatePackageName(pkg, packagePrograms)
const packageName = generatePackageName(
pkg.stateCode,
pkg.stateNumber,
pkg.programIDs,
packagePrograms
)

const packageURL = submissionSummaryURL(pkg.id, config.baseUrl)

Expand Down
14 changes: 12 additions & 2 deletions services/app-api/src/emailer/emails/newPackageStateEmail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ test('to addresses list does not include duplicate state receiver emails on subm
test('subject line is correct and clearly states submission is complete', async () => {
const sub = mockContractOnlyFormData()
const defaultStatePrograms = mockMNState().programs
const name = packageName(sub, defaultStatePrograms)
const name = packageName(
sub.stateCode,
sub.stateNumber,
sub.programIDs,
defaultStatePrograms
)

const template = await newPackageStateEmail(
sub,
Expand All @@ -141,7 +146,12 @@ test('subject line is correct and clearly states submission is complete', async
test('includes mcog, rate, and team email addresses', async () => {
const sub = mockContractOnlyFormData()
const defaultStatePrograms = mockMNState().programs
const name = packageName(sub, defaultStatePrograms)
const name = packageName(
sub.stateCode,
sub.stateNumber,
sub.programIDs,
defaultStatePrograms
)

const template = await newPackageStateEmail(
sub,
Expand Down
7 changes: 6 additions & 1 deletion services/app-api/src/emailer/emails/newPackageStateEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export const newPackageStateEmail = async (
return packagePrograms
}

const packageName = generatePackageName(formData, packagePrograms)
const packageName = generatePackageName(
formData.stateCode,
formData.stateNumber,
formData.programIDs,
packagePrograms
)

const isContractAndRates =
formData.submissionType === 'CONTRACT_AND_RATES' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ describe('with rates', () => {
const defaultStatePrograms = mockMNState().programs

it('contains correct subject and clearly states submission edits are completed', async () => {
const name = packageName(submission, defaultStatePrograms)
const name = packageName(
submission.stateCode,
submission.stateNumber,
submission.programIDs,
defaultStatePrograms
)
const template = await resubmitPackageCMSEmail(
submission,
resubmitData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export const resubmitPackageCMSEmail = async (
return packagePrograms
}

const packageName = generatePackageName(pkg, packagePrograms)
const packageName = generatePackageName(
pkg.stateCode,
pkg.stateNumber,
pkg.programIDs,
packagePrograms
)

const isContractAndRates =
pkg.submissionType === 'CONTRACT_AND_RATES' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
mockMNState,
} from '../../testHelpers/emailerHelpers'
import { resubmitPackageStateEmail } from './index'
import type { LockedHealthPlanFormDataType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { LockedHealthPlanFormDataType } from '../../../../app-web/src/common-code/healthPlanFormDataType'
import {
generateRateName,
packageName,
} from 'app-web/src/common-code/healthPlanFormDataType'
} from '../../../../app-web/src/common-code/healthPlanFormDataType'

const resubmitData = {
updatedBy: 'bob@example.com',
Expand Down Expand Up @@ -53,7 +53,12 @@ const defaultStatePrograms = mockMNState().programs
const defaultSubmitters = ['test1@example.com', 'test2@example.com']

test('contains correct subject and clearly states successful resubmission', async () => {
const name = packageName(submission, defaultStatePrograms)
const name = packageName(
submission.stateCode,
submission.stateNumber,
submission.programIDs,
defaultStatePrograms
)
const template = await resubmitPackageStateEmail(
submission,
defaultSubmitters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const resubmitPackageStateEmail = async (
return packagePrograms
}

const packageName = generatePackageName(formData, packagePrograms)
const packageName = generatePackageName(
formData.stateCode,
formData.stateNumber,
formData.programIDs,
packagePrograms
)

const isContractAndRates =
formData.submissionType === 'CONTRACT_AND_RATES' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
mockMSState,
} from '../../testHelpers/emailerHelpers'
import { unlockPackageCMSEmail } from './index'
import type { UnlockedHealthPlanFormDataType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { UnlockedHealthPlanFormDataType } from '../../../../app-web/src/common-code/healthPlanFormDataType'
import {
generateRateName,
packageName,
} from 'app-web/src/common-code/healthPlanFormDataType'
} from '../../../../app-web/src/common-code/healthPlanFormDataType'

const unlockData = {
updatedBy: 'leslie@example.com',
Expand Down Expand Up @@ -59,7 +59,12 @@ const defaultStatePrograms = mockMNState().programs

describe('unlockPackageCMSEmail', () => {
test('subject line is correct and clearly states submission is unlocked', async () => {
const name = packageName(sub, defaultStatePrograms)
const name = packageName(
sub.stateCode,
sub.stateNumber,
sub.programIDs,
defaultStatePrograms
)
const template = await unlockPackageCMSEmail(
sub,
unlockData,
Expand Down
7 changes: 6 additions & 1 deletion services/app-api/src/emailer/emails/unlockPackageCMSEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export const unlockPackageCMSEmail = async (
return packagePrograms
}

const packageName = generatePackageName(pkg, packagePrograms)
const packageName = generatePackageName(
pkg.stateCode,
pkg.stateNumber,
pkg.programIDs,
packagePrograms
)

const isContractAndRates = pkg.submissionType === 'CONTRACT_AND_RATES'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
mockMNState,
} from '../../testHelpers/emailerHelpers'
import { unlockPackageStateEmail } from './index'
import type { UnlockedHealthPlanFormDataType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { UnlockedHealthPlanFormDataType } from '../../../../app-web/src/common-code/healthPlanFormDataType'
import {
generateRateName,
packageName,
} from 'app-web/src/common-code/healthPlanFormDataType'
} from '../../../../app-web/src/common-code/healthPlanFormDataType'

const unlockData = {
updatedBy: 'josh@example.com',
Expand Down Expand Up @@ -56,7 +56,12 @@ const defaultStatePrograms = mockMNState().programs
const defaultSubmitters = ['test1@example.com', 'test2@example.com']

test('subject line is correct and clearly states submission is unlocked', async () => {
const name = packageName(sub, defaultStatePrograms)
const name = packageName(
sub.stateCode,
sub.stateNumber,
sub.programIDs,
defaultStatePrograms
)
const template = await unlockPackageStateEmail(
sub,
unlockData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const unlockPackageStateEmail = async (
return packagePrograms
}

const packageName = generatePackageName(formData, packagePrograms)
const packageName = generatePackageName(
formData.stateCode,
formData.stateNumber,
formData.programIDs,
packagePrograms
)

const isContractAndRates =
formData.submissionType === 'CONTRACT_AND_RATES' &&
Expand Down
2 changes: 1 addition & 1 deletion services/app-api/src/emailer/templateHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
generateCMSReviewerEmails,
handleAsCHIPSubmission,
} from './templateHelpers'
import type { UnlockedHealthPlanFormDataType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { UnlockedHealthPlanFormDataType } from '../../../app-web/src/common-code/healthPlanFormDataType'
import {
mockUnlockedContractAndRatesFormData,
mockUnlockedContractOnlyFormData,
Expand Down
6 changes: 5 additions & 1 deletion services/app-api/src/handlers/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ export const main: APIGatewayProxyHandler = async (event, context) => {
)
} else {
// add the package name to the revision
const { stateCode, stateNumber, programIDs } =
revision.formDataProto
revision.packageName = packageName(
revision.formDataProto,
stateCode,
stateNumber,
programIDs,
programList
)
// add the rateInfo fields to the revision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../../testHelpers'
import { insertDraftContract } from './insertContract'
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'
import type { StateCodeType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { StateCodeType } from '../../../../app-web/src/common-code/healthPlanFormDataType'

describe('insertContract', () => {
afterEach(() => {
Expand Down Expand Up @@ -82,9 +82,12 @@ describe('insertContract', () => {
const client = await sharedTestPrismaClient()

const draftContractData = createInsertContractData({
stateCode: 'CANADA' as StateCodeType,
stateCode: 'MN' as StateCodeType,
programIDs: [],
})

draftContractData.stateCode = 'CANADA'

const draftContract = await insertDraftContract(
client,
draftContractData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { must, getStateRecord } from '../../testHelpers'
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'
import { createInsertRateData } from '../../testHelpers/contractAndRates/rateHelpers'
import { insertDraftRate } from './insertRate'
import type { StateCodeType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { StateCodeType } from '../../../../app-web/src/common-code/healthPlanFormDataType'

describe('insertRate', () => {
afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StateCodeType } from 'app-web/src/common-code/healthPlanFormDataType'
import type { StateCodeType } from '../../../../app-web/src/common-code/healthPlanFormDataType'
import type { RateType } from '../../domain-models/contractAndRates'
import { parseRateWithHistory } from './parseRateWithHistory'
import { includeFullRate } from './prismaSubmittedRateHelpers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ describe('parseDomainData', () => {
rateProgramIDs: [],
rateCertificationName: null,
actuaryCommunicationPreference: null,
contractsWithSharedRateRevision: [],
},
},
],
Expand Down
Loading

0 comments on commit 469a39f

Please sign in to comment.