Skip to content

Commit

Permalink
MCR-3557: Cms sees link to submission on rate summary page and shared…
Browse files Browse the repository at this point in the history
… rate submissions (#1977)

* Add contractID to contractRevision data everywhere.

* Remove unused contractRevisions field.

* Add contract data to contractRevision.

* Display parent submission link.

* Display shared submission link in documents.

* Add packageStatus to packagesWithSharedRateCerts.

* Append draft to shared rate submission links.

* Fix things from merge.
  • Loading branch information
JasonLin0991 authored Oct 16, 2023
1 parent 3b92af2 commit 972ba67
Show file tree
Hide file tree
Showing 15 changed files with 403 additions and 233 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { z } from 'zod'
import { contractRevisionWithRatesSchema } from './revisionTypes'
import { statusSchema } from './statusType'

// Contract represents the contract specific information in a submission package
// All that data is contained in revisions, each revision represents the data in a single submission
// submissions are kept intact here across time
const contractSchema = z.object({
id: z.string().uuid(),
status: z.union([
z.literal('SUBMITTED'),
z.literal('DRAFT'),
z.literal('UNLOCKED'),
z.literal('RESUBMITTED'),
]),
status: statusSchema,
stateCode: z.string(),
mccrsID: z.string().optional(),
stateNumber: z.number().min(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
populationCoveredSchema,
rateCapitationTypeSchema,
rateTypeSchema,
sharedRateCertDisplay,
stateContactSchema,
submissionTypeSchema,
} from '../../../../app-web/src/common-code/proto/healthPlanFormDataProto/zodSchemas'
import { statusSchema } from './statusType'

const documentSchema = z.object({
name: z.string(),
Expand All @@ -26,6 +26,12 @@ const managedCareEntitiesSchema = z.union([
z.literal('PCCM'),
])

const packagesWithSharedRateCerts = z.object({
packageName: z.string(),
packageId: z.string(),
packageStatus: statusSchema.optional(),
})

const contractFormDataSchema = z.object({
programIDs: z.array(z.string()),
populationCovered: populationCoveredSchema.optional(),
Expand Down Expand Up @@ -77,7 +83,9 @@ const rateFormDataSchema = z.object({
certifyingActuaryContacts: z.array(actuaryContactSchema).optional(),
addtlActuaryContacts: z.array(actuaryContactSchema).optional(),
actuaryCommunicationPreference: actuaryCommunicationTypeSchema.optional(),
packagesWithSharedRateCerts: z.array(sharedRateCertDisplay).optional(),
packagesWithSharedRateCerts: z
.array(packagesWithSharedRateCerts)
.optional(),
})

type ContractFormDataType = z.infer<typeof contractFormDataSchema>
Expand Down
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 @@ -11,6 +11,8 @@ export {
rateRevisionSchema,
} from './revisionTypes'

export { statusSchema } from './statusType'

export {
convertContractWithRatesRevtoHPPRev,
convertContractWithRatesToUnlockedHPP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ import {
rateRevisionWithContractsSchema,
rateRevisionSchema,
} from './revisionTypes'
import { statusSchema } from './statusType'

const rateSchema = z.object({
id: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
status: z.union([
z.literal('SUBMITTED'),
z.literal('DRAFT'),
z.literal('UNLOCKED'),
z.literal('RESUBMITTED'),
]),
status: statusSchema,
stateCode: z.string(),
stateNumber: z.number().min(1),
// If this rate is in a DRAFT or UNLOCKED status, there will be a draftRevision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { contractFormDataSchema, rateFormDataSchema } from './formDataTypes'

const contractRevisionSchema = z.object({
id: z.string().uuid(),
contractID: z.string(),
contract: z.object({
id: z.string().uuid(),
stateCode: z.string(),
stateNumber: z.number().min(1),
}),
submitInfo: updateInfoSchema.optional(),
unlockInfo: updateInfoSchema.optional(),
createdAt: z.date(),
Expand Down
10 changes: 10 additions & 0 deletions services/app-api/src/domain-models/contractAndRates/statusType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { z } from 'zod'

const statusSchema = z.union([
z.literal('SUBMITTED'),
z.literal('DRAFT'),
z.literal('UNLOCKED'),
z.literal('RESUBMITTED'),
])

export { statusSchema }
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import type { ContractTableFullPayload } from './prismaSubmittedContractHelpers'

describe('parseDomainData', () => {
describe('parseDraftContract', () => {
const draftContract = createDraftContractData()
it('can parse valid draft domain data with no errors', () => {
const draftData = createDraftContractData()
const validatedDraft = parseContractWithHistory(draftData)
const validatedDraft = parseContractWithHistory(draftContract)
expect(validatedDraft).not.toBeInstanceOf(Error)
})

Expand All @@ -37,7 +37,7 @@ describe('parseDomainData', () => {
contract: createDraftContractData({
stateCode: undefined,
revisions: [
createContractRevision({
createContractRevision(draftContract, {
submitInfo: {
id: uuidv4(),
updatedAt: new Date(),
Expand Down Expand Up @@ -69,11 +69,10 @@ describe('parseDomainData', () => {
)
})
describe('parseDraftContractRevision', () => {
const contract = createContractData()

it('cant parse valid contract revision with no errors', () => {
const contractRevision = createContractData()
expect(
parseContractWithHistory(contractRevision)
).not.toBeInstanceOf(Error)
expect(parseContractWithHistory(contract)).not.toBeInstanceOf(Error)
})
const draftContractRevisionsWithInvalidData: {
contract: ContractTableFullPayload
Expand All @@ -82,7 +81,7 @@ describe('parseDomainData', () => {
{
contract: createContractData({
revisions: [
createContractRevision({
createContractRevision(contract, {
submissionType: undefined,
}),
],
Expand All @@ -92,7 +91,7 @@ describe('parseDomainData', () => {
{
contract: createContractData({
revisions: [
createContractRevision({
createContractRevision(contract, {
submissionDescription: undefined,
}),
],
Expand All @@ -102,7 +101,7 @@ describe('parseDomainData', () => {
{
contract: createContractData({
revisions: [
createContractRevision({
createContractRevision(contract, {
contractType: undefined,
}),
],
Expand All @@ -112,7 +111,7 @@ describe('parseDomainData', () => {
{
contract: createContractData({
revisions: [
createContractRevision({
createContractRevision(contract, {
managedCareEntities: undefined,
}),
],
Expand All @@ -128,9 +127,9 @@ describe('parseDomainData', () => {
)
})
describe('parseContractWithHistory', () => {
const contract = createContractData()
it('can parse valid contract domain data with no errors', () => {
const contractData = createContractData()
const validatedContract = parseContractWithHistory(contractData)
const validatedContract = parseContractWithHistory(contract)
expect(validatedContract).not.toBeInstanceOf(Error)
})

Expand All @@ -153,7 +152,7 @@ describe('parseDomainData', () => {
{
contract: createContractData({
revisions: [
createContractRevision({
createContractRevision(contract, {
rateRevisions: [
{
rateRevisionID: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function contractRevisionToDomainModel(
): ContractRevisionType {
return {
id: revision.id,
contractID: revision.contractID,
contract: revision.contract,
createdAt: revision.createdAt,
updatedAt: revision.updatedAt,
submitInfo: convertUpdateInfoToDomainModel(revision.submitInfo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,14 @@ import type {
import {
contractFormDataToDomainModel,
convertUpdateInfoToDomainModel,
includeUpdateInfo,
includeRateFormData,
rateRevisionToDomainModel,
} from './prismaSharedContractRateHelpers'
import type { ContractRevisionTableWithRates } from './prismaSubmittedContractHelpers'

const includeDraftRates = {
revisions: {
include: {
rateDocuments: {
orderBy: {
position: 'asc',
},
},
supportingDocuments: {
orderBy: {
position: 'asc',
},
},
certifyingActuaryContacts: {
orderBy: {
position: 'asc',
},
},
addtlActuaryContacts: {
orderBy: {
position: 'asc',
},
},
submitInfo: includeUpdateInfo,
unlockInfo: includeUpdateInfo,
contractsWithSharedRateRevision: {
include: {
revisions: {
take: 1,
orderBy: {
createdAt: 'desc',
},
},
},
},
},
include: includeRateFormData,
take: 1,
orderBy: {
createdAt: 'desc',
Expand Down Expand Up @@ -89,7 +56,7 @@ function draftContractRevToDomainModel(

return {
id: revision.id,
contractID: revision.contractID,
contract: revision.contract,
createdAt: revision.createdAt,
updatedAt: revision.updatedAt,
unlockInfo: convertUpdateInfoToDomainModel(revision.unlockInfo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ type UpdateInfoTableWithUpdater = Prisma.UpdateInfoTableGetPayload<{
include: typeof subincludeUpdateInfo
}>

const includeContractFormData = {
unlockInfo: includeUpdateInfo,
submitInfo: includeUpdateInfo,
contract: true,

stateContacts: {
orderBy: {
position: 'asc',
},
},
contractDocuments: {
orderBy: {
position: 'asc',
},
},
supportingDocuments: {
orderBy: {
position: 'asc',
},
},
} satisfies Prisma.ContractRevisionTableInclude

function convertUpdateInfoToDomainModel(
info?: UpdateInfoTableWithUpdater | null
): UpdateInfoType | undefined {
Expand Down Expand Up @@ -91,7 +113,7 @@ const includeRateFormData = {
contractsWithSharedRateRevision: {
include: {
revisions: {
take: 1,
include: includeContractFormData,
orderBy: {
createdAt: 'desc',
},
Expand Down Expand Up @@ -131,6 +153,7 @@ function rateFormDataToDomainModel(
contractPrograms,
statePrograms
),
packageStatus: getContractRateStatus(contract.revisions),
})
}

Expand Down Expand Up @@ -233,27 +256,6 @@ function ratesRevisionsToDomainModel(

// ------

const includeContractFormData = {
unlockInfo: includeUpdateInfo,
submitInfo: includeUpdateInfo,

stateContacts: {
orderBy: {
position: 'asc',
},
},
contractDocuments: {
orderBy: {
position: 'asc',
},
},
supportingDocuments: {
orderBy: {
position: 'asc',
},
},
} satisfies Prisma.ContractRevisionTableInclude

type ContractRevisionTableWithFormData =
Prisma.ContractRevisionTableGetPayload<{
include: typeof includeContractFormData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import type { ContractFormDataType } from '../../domain-models/contractAndRates'
import { findStatePrograms } from '../../postgres'
import { must } from '../errorHelpers'

const defaultContractData = () => ({
id: '24fb2a5f-6d0d-4e26-9906-4de28927c882',
createdAt: new Date(),
updatedAt: new Date(),
mccrsID: null,
stateCode: 'MN',
stateNumber: 111,
})

const createInsertContractData = ({
stateCode = 'MN',
...formData
Expand Down Expand Up @@ -40,6 +49,7 @@ const createDraftContractData = (
stateNumber: 111,
revisions: contract?.revisions ?? [
createContractRevision(
contract,
{
rateRevisions: undefined,
submitInfo: null,
Expand All @@ -61,6 +71,7 @@ const createContractData = (
stateNumber: 111,
revisions: contract?.revisions ?? [
createContractRevision(
contract,
{
draftRates: undefined,
},
Expand All @@ -71,13 +82,18 @@ const createContractData = (
})

const createContractRevision = (
contract?: Partial<ContractTableFullPayload>,
revision?: Partial<ContractRevisionTableWithRates>,
stateCode: StateCodeType = 'MN'
): ContractRevisionTableWithRates => {
const statePrograms = must(findStatePrograms(stateCode))

return {
id: uuidv4(),
contract: {
...defaultContractData(),
...contract,
},
createdAt: new Date(),
updatedAt: new Date(),
submitInfo: {
Expand Down
Loading

0 comments on commit 972ba67

Please sign in to comment.