Skip to content

Commit

Permalink
WIP: Fix rates dashboard (#1975)
Browse files Browse the repository at this point in the history
* Log errors only, no error state, just do fallbacks.
* Fix contract revisions logic
  • Loading branch information
haworku authored Oct 13, 2023
1 parent 6afdf09 commit e330466
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/technical-design/creating-and-testing-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ 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`

### Generating graphql types
_**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
Expand Down
4 changes: 2 additions & 2 deletions services/app-api/src/domain-models/healthPlanPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {
Expand Down
12 changes: 6 additions & 6 deletions services/app-graphql/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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!]!
Expand Down
15 changes: 7 additions & 8 deletions services/app-web/src/pages/CMSDashboard/CMSDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -247,20 +246,18 @@ 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 ||
!displayRateFormData.rateDateStart ||
!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 <GenericErrorPage />
}

if (!lastUpdated) {
Expand All @@ -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 &&
Expand All @@ -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'
Expand Down

0 comments on commit e330466

Please sign in to comment.