From e330466e540a5ddfd0300c077091c136c73a701f Mon Sep 17 00:00:00 2001 From: haworku Date: Fri, 13 Oct 2023 11:43:48 -0500 Subject: [PATCH] WIP: Fix rates dashboard (#1975) * Log errors only, no error state, just do fallbacks. * Fix contract revisions logic --- .../creating-and-testing-endpoints.md | 4 ++-- .../src/domain-models/healthPlanPackage.ts | 4 ++-- .../resolvers/contractAndRates/indexRates.test.ts | 1 - .../resolvers/contractAndRates/rateResolver.ts | 4 ++-- services/app-graphql/src/schema.graphql | 12 ++++++------ .../src/pages/CMSDashboard/CMSDashboard.tsx | 15 +++++++-------- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/docs/technical-design/creating-and-testing-endpoints.md b/docs/technical-design/creating-and-testing-endpoints.md index 9cefd84ae5..c692a4d40e 100644 --- a/docs/technical-design/creating-and-testing-endpoints.md +++ b/docs/technical-design/creating-and-testing-endpoints.md @@ -228,7 +228,7 @@ Once we have our backend code in place, if we've modified the prisma schema (we _**On the command line, navigate to `/services/app-api`**_ _**Run `yarn prisma generate`**_ -or from the root run `.dev local --postgres --api` which includes prisma code generation +or from the root run `./dev generate` which includes prisma code generation This command will create `node_modules/.prisma/client/index.d.ts` @@ -236,7 +236,7 @@ This command will create `node_modules/.prisma/client/index.d.ts` _**On the command line, navigate to `/services/app-graphql`**_ _**Run `yarn gqlgen`**_ -or from the root frun `./dev local` which includes graphql types code generation +or from the root run `./dev generate` which includes graphql types code generation Either set of commands will create `app-api/gen/gqlServer.d.ts` used for types on backend as well as `app-web/gen/gqlClient.d.ts` used for types on frontend. The tool for this is set up in the `app-graphql` service. ### Getting data on the front end diff --git a/services/app-api/src/domain-models/healthPlanPackage.ts b/services/app-api/src/domain-models/healthPlanPackage.ts index 1fa26d4044..c0a1086865 100644 --- a/services/app-api/src/domain-models/healthPlanPackage.ts +++ b/services/app-api/src/domain-models/healthPlanPackage.ts @@ -37,8 +37,8 @@ function packageStatus( // submission has been unlocked and resubmitted the submission date is always the original submit date // This method relies on revisions always being presented in most-recent-first order function packageSubmittedAt(pkg: HealthPlanPackageType): Date | undefined { - const lastSubmittedRev = pkg.revisions[pkg.revisions.length - 1] - return lastSubmittedRev?.submitInfo?.updatedAt + const firstSubmittedRev = pkg.revisions[pkg.revisions.length - 1] + return firstSubmittedRev?.submitInfo?.updatedAt } // submissionCurrentRevision returns the most recent revision diff --git a/services/app-api/src/resolvers/contractAndRates/indexRates.test.ts b/services/app-api/src/resolvers/contractAndRates/indexRates.test.ts index 002c3327b2..308d632b7f 100644 --- a/services/app-api/src/resolvers/contractAndRates/indexRates.test.ts +++ b/services/app-api/src/resolvers/contractAndRates/indexRates.test.ts @@ -47,7 +47,6 @@ describe('indexRates', () => { const submit1 = await createAndSubmitTestHealthPlanPackage(stateServer) const submit2 = await createAndSubmitTestHealthPlanPackage(stateServer) const update1 = await createAndUpdateTestHealthPlanPackage(stateServer) - await new Promise((resolve) => setTimeout(resolve, 2000)) // index rates const result = await cmsServer.executeOperation({ diff --git a/services/app-api/src/resolvers/contractAndRates/rateResolver.ts b/services/app-api/src/resolvers/contractAndRates/rateResolver.ts index 6270aa76ea..ba16001ec0 100644 --- a/services/app-api/src/resolvers/contractAndRates/rateResolver.ts +++ b/services/app-api/src/resolvers/contractAndRates/rateResolver.ts @@ -6,8 +6,8 @@ import type { RateType } from '../../domain-models' // Return the date of the first submission for a rate // This method relies on revisions always being presented in most-recent-first order function initialSubmitDate(rate: RateType): Date | undefined { - const lastSubmittedRev = rate.revisions[rate.revisions.length - 1] - return lastSubmittedRev?.submitInfo?.updatedAt + const firstSubmittedRev = rate.revisions[rate.revisions.length - 1] + return firstSubmittedRev?.submitInfo?.updatedAt } export const rateResolver: Resolvers['Rate'] = { diff --git a/services/app-graphql/src/schema.graphql b/services/app-graphql/src/schema.graphql index 8f54d77fa5..abe3713c04 100644 --- a/services/app-graphql/src/schema.graphql +++ b/services/app-graphql/src/schema.graphql @@ -133,7 +133,7 @@ type Mutation { ): UpdateHealthPlanFormDataPayload! """ - updateContract can be used to update fields on the contract + updateContract can be used to update fields on the contract as oppossed to an individual revision """ updateContract( @@ -775,11 +775,11 @@ type RateFormData { rateCapitationType: RateCapitationType rateDocuments: [GenericDocument!]! supportingDocuments: [GenericDocument!]! - rateDateStart: DateTime - rateDateEnd: DateTime - rateDateCertified: DateTime - amendmentEffectiveDateStart: DateTime - amendmentEffectiveDateEnd: DateTime + rateDateStart: Date + rateDateEnd: Date + rateDateCertified: Date + amendmentEffectiveDateStart: Date + amendmentEffectiveDateEnd: Date rateProgramIDs: [String!]! rateCertificationName: String certifyingActuaryContacts: [ActuaryContact!]! diff --git a/services/app-web/src/pages/CMSDashboard/CMSDashboard.tsx b/services/app-web/src/pages/CMSDashboard/CMSDashboard.tsx index e1a913582d..222280e4d5 100644 --- a/services/app-web/src/pages/CMSDashboard/CMSDashboard.tsx +++ b/services/app-web/src/pages/CMSDashboard/CMSDashboard.tsx @@ -24,7 +24,6 @@ import { ErrorFailedRequestPage } from '../Errors/ErrorFailedRequestPage' import { RoutesRecord } from '../../constants' import { featureFlags } from '../../common-code/featureFlags' import { RateInDashboardType, RateReviewsTable } from './RateReviewsTable' -import { GenericErrorPage } from '../Errors/GenericErrorPage' /** * We only pull a subset of data out of the submission and revisions for display in Dashboard @@ -247,10 +246,7 @@ const RateReviewsDashboard = (): React.ReactElement => { previousRevision?.unlockInfo?.updatedAt, ]) } - - // Type guards - graphql has loose types with form data, let's narrow in now if ( - !displayRateFormData || !displayRateFormData.rateProgramIDs || !displayRateFormData.rateType || !displayRateFormData.rateDateEnd || @@ -258,9 +254,10 @@ const RateReviewsDashboard = (): React.ReactElement => { !displayRateFormData.rateCertificationName ) { recordJSException( - `CMSDashboard: Cannot calculate display rate for rate reviews. This is unexpected and needs investigation. ID: ${rate.id}` + `CMSDashboard: Cannot calculate one of the required fields displaying rate reviews. This is unexpected and needs investigation. ID: ${ + rate.id + } formData: ${JSON.stringify(displayRateFormData)})}` ) - return } if (!lastUpdated) { @@ -272,9 +269,11 @@ const RateReviewsDashboard = (): React.ReactElement => { const programs = rate.state.programs + const missingField = 'Missing field' + reviewRows.push({ id: rate.id, - name: displayRateFormData.rateCertificationName, + name: displayRateFormData.rateCertificationName || missingField, programs: programs.filter( (program) => displayRateFormData?.rateProgramIDs && @@ -285,7 +284,7 @@ const RateReviewsDashboard = (): React.ReactElement => { rateDateEnd: displayRateFormData.rateDateEnd, status: rate.status, updatedAt: lastUpdated, - rateType: displayRateFormData.rateType, + rateType: displayRateFormData.rateType || 'NEW', stateName: rate.state.name, contractRevisions: rate.status === 'UNLOCKED'