Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission Summary V2 with FetchContract #2350

Merged
merged 58 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f8fc4e2
initial commit of resolvers working
macrael Apr 1, 2024
b355084
submitContract can only be called by state user
mojotalantikite Apr 1, 2024
ce369d7
create submissionsummaryv2
pearl-truss Apr 2, 2024
3e45343
create and use v2 version of contract details summary section component
pearl-truss Apr 2, 2024
5836518
temp comment out reviewsubmitv2 for testing
pearl-truss Apr 2, 2024
e2dd1b0
get submitContract working
macrael Apr 2, 2024
a36eb52
add test helpers for contracts, test single linked rate
macrael Apr 3, 2024
0cd849c
fix after linting
macrael Apr 3, 2024
a42ea4b
fix some bugs
macrael Apr 4, 2024
1686aa9
get setup of scenario working
macrael Apr 4, 2024
8201ea0
Wip with handling submit
pearl-truss Apr 4, 2024
0696cae
fix some of the api test
pearl-truss Apr 4, 2024
aa2e7c9
Remove console logs
pearl-truss Apr 4, 2024
ec4cd34
unlock child rates
macrael Apr 4, 2024
609af02
fix linting to deploy review app
pearl-truss Apr 5, 2024
ff4d5b9
add 90% of jason's diagram to test
mojotalantikite Apr 5, 2024
24f8970
get parentContractID into rate and check it
macrael Apr 6, 2024
1b05f8d
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
macrael Apr 6, 2024
c66526b
Create graphql for submitContract and new fetchSubmittedContract
pearl-truss Apr 8, 2024
8dd9b62
remove changes to submitContract postgres func
pearl-truss Apr 8, 2024
c5a1653
remove unneeded changes for this pr
pearl-truss Apr 8, 2024
8a5ca31
remove submitContract graphql from this pr
pearl-truss Apr 8, 2024
9cd0a58
remove submitContract.graphql
pearl-truss Apr 8, 2024
ec9bbc0
fix unlockRate
mojotalantikite Apr 8, 2024
c6ef2c9
assert length
mojotalantikite Apr 8, 2024
cc74d8c
cleaning up tests, adds asserts
mojotalantikite Apr 8, 2024
c342a11
remove fetchSubmittedContract
pearl-truss Apr 9, 2024
5aee09a
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 9, 2024
c6516bf
add loading and error states
pearl-truss Apr 9, 2024
b37f87f
Merge branch 'main' into wml-db-history
macrael Apr 10, 2024
5b28925
migrate to new draftRates
macrael Apr 10, 2024
8d26735
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 15, 2024
7ebbba6
wow everything passes
macrael Apr 15, 2024
f589287
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 15, 2024
4fe6252
code clean up
pearl-truss Apr 15, 2024
dc11a52
fix import
macrael Apr 15, 2024
af49041
comments and fix a hidden build issue
macrael Apr 15, 2024
745da54
skip unmigrated rates
mojotalantikite Apr 16, 2024
23eb6ff
reimplmeent submit
macrael Apr 18, 2024
9f83988
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
macrael Apr 18, 2024
acc5249
rate data mocks
macrael Apr 18, 2024
1d96a2d
add mccrsID to fetchContract query
pearl-truss Apr 18, 2024
78dc953
update v2 unlocksubmit modal to work with unlock contract
pearl-truss Apr 18, 2024
c82d4dc
create changeHistory V2 to use fetchContract, resolve errors
pearl-truss Apr 18, 2024
18043fc
Merge branch 'main' of https://github.com/Enterprise-CMCS/managed-car…
pearl-truss Apr 18, 2024
c456132
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
pearl-truss Apr 18, 2024
3b6ac15
get submit working on ReviewSubmit page
pearl-truss Apr 18, 2024
57e2b4a
update contractPackageDataMock
pearl-truss Apr 18, 2024
37c9b04
remove references to packages in unlockSubmitModalV2
pearl-truss Apr 18, 2024
2252971
remove access optioinal chanining
pearl-truss Apr 18, 2024
e3ae827
update changehistoryv2 language and logic
pearl-truss Apr 18, 2024
7ee8429
add submissionsummartV2 for cmsRoutes
pearl-truss Apr 18, 2024
8b09893
fix reviewsubmit test
pearl-truss Apr 18, 2024
7784374
Merge branch 'main' of https://github.com/Enterprise-CMCS/managed-car…
pearl-truss Apr 18, 2024
f555a3b
pr updates
pearl-truss Apr 18, 2024
11d0268
restrict change history to contract actions for now
pearl-truss Apr 18, 2024
5bc2584
fix resubmit
pearl-truss Apr 18, 2024
d9c1df9
add reverse
pearl-truss Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
BEGIN;
-- DropEnum
DROP TYPE "DocumentCategory";

-- CreateTable
CREATE TABLE "SubmissionPackageJoinTable" (
"submissionID" TEXT NOT NULL,
"contractRevisionID" TEXT NOT NULL,
"rateRevisionID" TEXT NOT NULL,
"ratePosition" INTEGER NOT NULL,

CONSTRAINT "SubmissionPackageJoinTable_pkey" PRIMARY KEY ("submissionID","contractRevisionID","rateRevisionID")
);

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

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

-- CreateIndex
CREATE UNIQUE INDEX "_ContractRevisionTableToUpdateInfoTable_AB_unique" ON "_ContractRevisionTableToUpdateInfoTable"("A", "B");

-- CreateIndex
CREATE INDEX "_ContractRevisionTableToUpdateInfoTable_B_index" ON "_ContractRevisionTableToUpdateInfoTable"("B");

-- CreateIndex
CREATE UNIQUE INDEX "_RateRevisionTableToUpdateInfoTable_AB_unique" ON "_RateRevisionTableToUpdateInfoTable"("A", "B");

-- CreateIndex
CREATE INDEX "_RateRevisionTableToUpdateInfoTable_B_index" ON "_RateRevisionTableToUpdateInfoTable"("B");

-- AddForeignKey
ALTER TABLE "SubmissionPackageJoinTable" ADD CONSTRAINT "SubmissionPackageJoinTable_submissionID_fkey" FOREIGN KEY ("submissionID") REFERENCES "UpdateInfoTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "SubmissionPackageJoinTable" ADD CONSTRAINT "SubmissionPackageJoinTable_contractRevisionID_fkey" FOREIGN KEY ("contractRevisionID") REFERENCES "ContractRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "SubmissionPackageJoinTable" ADD CONSTRAINT "SubmissionPackageJoinTable_rateRevisionID_fkey" FOREIGN KEY ("rateRevisionID") REFERENCES "RateRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_ContractRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_ContractRevisionTableToUpdateInfoTable_A_fkey" FOREIGN KEY ("A") REFERENCES "ContractRevisionTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_ContractRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_ContractRevisionTableToUpdateInfoTable_B_fkey" FOREIGN KEY ("B") REFERENCES "UpdateInfoTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_RateRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_RateRevisionTableToUpdateInfoTable_A_fkey" FOREIGN KEY ("A") REFERENCES "RateRevisionTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_RateRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_RateRevisionTableToUpdateInfoTable_B_fkey" FOREIGN KEY ("B") REFERENCES "UpdateInfoTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BEGIN;
-- CreateTable
CREATE TABLE "DraftRateJoinTable" (
"contractID" TEXT NOT NULL,
"rateID" TEXT NOT NULL,
"ratePosition" INTEGER NOT NULL,

CONSTRAINT "DraftRateJoinTable_pkey" PRIMARY KEY ("contractID","rateID")
);

-- AddForeignKey
ALTER TABLE "DraftRateJoinTable" ADD CONSTRAINT "DraftRateJoinTable_contractID_fkey" FOREIGN KEY ("contractID") REFERENCES "ContractTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "DraftRateJoinTable" ADD CONSTRAINT "DraftRateJoinTable_rateID_fkey" FOREIGN KEY ("rateID") REFERENCES "RateTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;
-- DropForeignKey
ALTER TABLE "DraftRateJoinTable" DROP CONSTRAINT "DraftRateJoinTable_rateID_fkey";

-- AddForeignKey
ALTER TABLE "DraftRateJoinTable" ADD CONSTRAINT "DraftRateJoinTable_rateID_fkey" FOREIGN KEY ("rateID") REFERENCES "RateTable"("id") ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BEGIN;
-- This migration finds all draft contract and rate revisions and makes entries in
-- the DraftRateJoinTable, with their order defined by RANK
INSERT INTO "DraftRateJoinTable" ("contractID", "rateID", "ratePosition")
SELECT "ContractRevisionTable"."contractID", "RateRevisionTable"."rateID", RANK() OVER (
PARTITION BY "ContractRevisionTable".id
ORDER BY "RateRevisionTable"."createdAt" DESC
) from "ContractRevisionTable", "_ContractRevisionTableToRateTable", "RateRevisionTable" WHERE
"ContractRevisionTable".id = "_ContractRevisionTableToRateTable"."A" AND
"_ContractRevisionTableToRateTable"."B" = "RateRevisionTable"."rateID" AND
"RateRevisionTable"."submitInfoID" IS NULL AND
"ContractRevisionTable"."submitInfoID" IS NULL
ON CONFLICT DO NOTHING;
COMMIT;
48 changes: 46 additions & 2 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 {

questions Question[]

draftRates DraftRateJoinTable[]

revisions ContractRevisionTable[]
// This relationship is a scam. We never call it in our code but Prisma
// requires that there be an inverse to RateRevision.draftContracts which we do use
Expand All @@ -62,12 +64,25 @@ model RateTable {
state State @relation(fields: [stateCode], references: [stateCode])
stateNumber Int

draftContracts DraftRateJoinTable[]

revisions RateRevisionTable[]
// This relationship is a scam. We never call it in our code but Prisma
// requires that there be an inverse to ContractRevision.draftRates which we do use
draftContractRevisions ContractRevisionTable[]
}

// DraftRateJoinTable links a draft contract to a set of rates, draft or submitted.
model DraftRateJoinTable {
contractID String
contract ContractTable @relation(fields: [contractID], references: [id])
rateID String
rate RateTable @relation(fields: [rateID], references: [id], onDelete: Cascade)
ratePosition Int

@@id([contractID, rateID])
}

model ContractRevisionTable {
id String @id @default(uuid())
contractID String
Expand All @@ -81,6 +96,9 @@ model ContractRevisionTable {
submitInfoID String?
submitInfo UpdateInfoTable? @relation("submitContractInfo", fields: [submitInfoID], references: [id])

relatedSubmisions UpdateInfoTable[]
submissionPackages SubmissionPackageJoinTable[] @relation("contractRevision")

createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt

Expand Down Expand Up @@ -133,6 +151,9 @@ model RateRevisionTable {
submitInfoID String?
submitInfo UpdateInfoTable? @relation("submitRateInfo", fields: [submitInfoID], references: [id], onDelete: Cascade)

relatedSubmissions UpdateInfoTable[]
submissionPackages SubmissionPackageJoinTable[] @relation("rateRevision")

rateType RateType?
rateCapitationType RateCapitationType?
rateDocuments RateDocument[]
Expand Down Expand Up @@ -169,10 +190,33 @@ model UpdateInfoTable {
updatedByID String
updatedBy User @relation(fields: [updatedByID], references: [id])
updatedReason String
unlockedContracts ContractRevisionTable[] @relation("unlockContractInfo")

// the actually submitted contract/rates for this submission
submittedContracts ContractRevisionTable[] @relation("submitContractInfo")
unlockedRates RateRevisionTable[] @relation("unlockRateInfo")
submittedRates RateRevisionTable[] @relation("submitRateInfo")

// These relations are inverse 1:1 relations that are not really used.
unlockedContracts ContractRevisionTable[] @relation("unlockContractInfo")
unlockedRates RateRevisionTable[] @relation("unlockRateInfo")
submissionPackages SubmissionPackageJoinTable[] @relation("submission")

// these get ALL related contracts + revisions for given update.
relatedContracts ContractRevisionTable[]
relatedRates RateRevisionTable[]
}

// SubmissionPackageJoinTable records the set of related rate and contracts for a given submission.
model SubmissionPackageJoinTable {
submissionID String
submission UpdateInfoTable @relation("submission", fields: [submissionID], references: [id])
contractRevisionID String
contractRevision ContractRevisionTable @relation("contractRevision", fields: [contractRevisionID], references: [id])
rateRevisionID String
rateRevision RateRevisionTable @relation("rateRevision", fields: [rateRevisionID], references: [id])
// this number indicates the position of the rate in this contract
ratePosition Int

@@id([submissionID, contractRevisionID, rateRevisionID])
}

model ActuaryContact {
Expand Down
2 changes: 1 addition & 1 deletion services/app-api/src/dataMigrations/_sampleTest.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sharedTestPrismaClient } from '../testHelpers/storeHelpers'
import { migrate } from './migrations/20231106200334_fix_empty_rates'
import { migrate } from './migrations/20231026123042_test_migrator_works'

/*
Demo of how to test a data migration - can run and test locally with this test.
Expand Down
7 changes: 0 additions & 7 deletions services/app-api/src/dataMigrations/dataMigrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { PrismaTransactionType } from '../postgres/prismaTypes'
import { migrate as migrate1 } from './migrations/20231026123042_test_migrator_works'
import { migrate as migrate2 } from './migrations/20231026124442_fix_rate_submittedat'
import { migrate as migrate3 } from './migrations/20231026124542_fix_erroneous_rates'
import { migrate as migrate4 } from './migrations/20231106200334_fix_empty_rates'

// MigrationType describes a single migration with a name and a callable function called migrateProto
interface DBMigrationType {
Expand Down Expand Up @@ -104,12 +103,6 @@ export async function migrate(
migrate: migrate3,
},
},
{
name: 'migrations/20231106200334_fix_empty_rates',
module: {
migrate: migrate4,
},
},
]
// for (const migrationFile of migrationFiles) {
// // const fullPath = './migrations/0001_test_migration'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { contractRevisionWithRatesSchema } from './revisionTypes'
import { statusSchema } from './statusType'
import { pruneDuplicateEmails } from '../../emailer/formatters'
import { rateSchema } from './rateTypes'
import { contractPackageSubmissionSchema } from './packageSubmissions'

// 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
Expand All @@ -20,6 +21,8 @@ const contractSchema = z.object({
draftRates: z.array(rateSchema).optional(),
// All revisions are submitted and in reverse chronological order
revisions: z.array(contractRevisionWithRatesSchema),

packageSubmissions: z.array(contractPackageSubmissionSchema),
})

const draftContractSchema = contractSchema.extend({
Expand Down
5 changes: 5 additions & 0 deletions services/app-api/src/domain-models/contractAndRates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ export type {
RateRevisionWithContractsType,
ContractRevisionWithRatesType,
} from './revisionTypes'

export type {
ContractPackageSubmissionType,
ContractPackageSubmissionWithCauseType,
} from './packageSubmissions'
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { z } from 'zod'
import { contractRevisionSchema, rateRevisionSchema } from './revisionTypes'
import { updateInfoSchema } from './updateInfoType'

const contractPackageSubmissionSchema = z.object({
submitInfo: updateInfoSchema,
submittedRevisions: z.array(
z.union([contractRevisionSchema, rateRevisionSchema])
),
contractRevision: contractRevisionSchema,
rateRevisions: z.array(rateRevisionSchema),
})

const packgeSubmissionCause = z.union([
z.literal('CONTRACT_SUBMISSION'),
z.literal('RATE_SUBMISSION'),
z.literal('RATE_UNLINK'),
z.literal('RATE_LINK'),
])

const contractPackageSubmissionWithCauseSchema =
contractPackageSubmissionSchema.extend({
cause: packgeSubmissionCause,
})

type ContractPackageSubmissionType = z.infer<
typeof contractPackageSubmissionSchema
>

type ContractPackageSubmissionWithCauseType = z.infer<
typeof contractPackageSubmissionWithCauseSchema
>

export {
contractPackageSubmissionSchema,
contractPackageSubmissionWithCauseSchema,
}

export type {
ContractPackageSubmissionType,
ContractPackageSubmissionWithCauseType,
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const rateSchema = z.object({
updatedAt: z.date(),
status: statusSchema,
stateCode: z.string(),
parentContractID: z.string().uuid(),
stateNumber: z.number().min(1),
// If this rate is in a DRAFT or UNLOCKED status, there will be a draftRevision
draftRevision: rateRevisionWithContractsSchema.optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ const contractRevisionSchema = z.object({

const rateRevisionSchema = z.object({
id: z.string().uuid(),
rate: z.object({
id: z.string().uuid(),
stateCode: z.string(),
stateNumber: z.number().min(1),
createdAt: z.date(),
}),
rateID: z.string().uuid(),
submitInfo: updateInfoSchema.optional(),
unlockInfo: updateInfoSchema.optional(),
createdAt: z.date(),
Expand Down
2 changes: 2 additions & 0 deletions services/app-api/src/domain-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export type {
RateRevisionWithContractsType,
RateFormDataType,
PackageStatusType,
ContractPackageSubmissionType,
ContractPackageSubmissionWithCauseType,
} from './contractAndRates'

export type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async function findAllContractsWithHistoryBySubmitInfo(
where: {
revisions: {
some: {
submitInfo: {
isNot: null,
submitInfoID: {
not: null,
},
},
},
Expand Down
Loading
Loading