Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…e-review into ma_3212_migration_lambda
  • Loading branch information
rswerve committed Jul 22, 2023
2 parents 9a23d3c + 5f34b25 commit b82feb9
Show file tree
Hide file tree
Showing 53 changed files with 1,152 additions and 947 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { HealthPlanPackageType } from '../../domain-models'
import { toDomain } from '../../../../app-web/src/common-code/proto/healthPlanFormDataProto'
import { sharedTestPrismaClient } from '../../testHelpers/storeHelpers'
import { insertHealthPlanPackage } from './insertHealthPlanPackage'
import {
insertHealthPlanPackage,
InsertHealthPlanPackageArgsType,
} from './insertHealthPlanPackage'
import { isStoreError } from '../storeError'

describe('insertHealthPlanPackage', () => {
Expand All @@ -13,14 +16,14 @@ describe('insertHealthPlanPackage', () => {

const client = await sharedTestPrismaClient()

const args = {
const args: InsertHealthPlanPackageArgsType = {
stateCode: 'FL',
populationCovered: 'MEDICAID',
programIDs: ['smmc'],
riskBasedContract: false,
submissionType: 'CONTRACT_ONLY' as const,
submissionType: 'CONTRACT_ONLY',
submissionDescription: 'concurrency state code test',
contractType: 'BASE' as const,
populationCovered: 'MEDICAID' as const,
contractType: 'BASE',
}

const resultPromises = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { PopulationCoveredType } from '../../gen/gqlServer'

export type InsertHealthPlanPackageArgsType = {
stateCode: string
populationCovered?: PopulationCoveredType
populationCovered: PopulationCoveredType
programIDs: string[]
riskBasedContract?: boolean
submissionType: SubmissionType
Expand Down
3 changes: 1 addition & 2 deletions services/app-api/src/resolvers/configureResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export function configureResolvers(
submitHealthPlanPackage: submitHealthPlanPackageResolver(
store,
emailer,
emailParameterStore,
launchDarkly
emailParameterStore
),
unlockHealthPlanPackage: unlockHealthPlanPackageResolver(
store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe.each(flagValueTestParameters)(
})

const input: CreateHealthPlanPackageInput = {
populationCovered: 'MEDICAID',
programIDs: [
'5c10fe9f-bec9-416f-a20c-718b152ad633',
'037af66b-81eb-4472-8b80-01edf17d12d9',
Expand Down Expand Up @@ -74,6 +75,7 @@ describe.each(flagValueTestParameters)(
ldService: mockLDService,
})
const input: CreateHealthPlanPackageInput = {
populationCovered: 'MEDICAID',
programIDs: ['xyz123'],
riskBasedContract: false,
submissionType: 'CONTRACT_ONLY',
Expand All @@ -100,6 +102,7 @@ describe.each(flagValueTestParameters)(
})

const input: CreateHealthPlanPackageInput = {
populationCovered: 'MEDICAID',
programIDs: ['xyz123'],
riskBasedContract: false,
submissionType: 'CONTRACT_ONLY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
getTestStateAnalystsEmails,
} from '../../testHelpers/parameterStoreHelpers'
import * as awsSESHelpers from '../../testHelpers/awsSESHelpers'
import { testLDService } from '../../testHelpers/launchDarklyHelpers'
import { testCMSUser, testStateUser } from '../../testHelpers/userHelpers'

describe('submitHealthPlanPackage', () => {
Expand Down Expand Up @@ -903,10 +902,7 @@ describe('submitHealthPlanPackage', () => {

describe('Feature flagged population coverage question test', () => {
it('errors when population coverage question is undefined', async () => {
const mockLDService = testLDService({ 'chip-only-form': true })
const server = await constructTestPostgresServer({
ldService: mockLDService,
})
const server = await constructTestPostgresServer()

// setup
const initialPkg = await createAndUpdateTestHealthPlanPackage(server, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
hasAnyValidRateData,
isContractAndRates,
removeRatesData,
hasValidPopulationCoverage,
removeInvalidProvisionsAndAuthorities,
isValidAndCurrentLockedHealthPlanFormData,
hasValidSupportingDocumentCategories,
Expand All @@ -29,9 +28,7 @@ import {
} from '../attributeHelper'
import { toDomain } from '../../../../app-web/src/common-code/proto/healthPlanFormDataProto'
import { EmailParameterStore } from '../../parameterStore'
import { LDService } from '../../launchDarkly/launchDarkly'
import { GraphQLError } from 'graphql'
import { FeatureFlagSettings } from 'app-web/src/common-code/featureFlags'

import type {
UnlockedHealthPlanFormDataType,
Expand Down Expand Up @@ -70,29 +67,17 @@ export function isSubmissionError(err: unknown): err is SubmissionError {
// This strategy (returning a different type from validation) is taken from the
// "parse, don't validate" article: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
function submit(
draft: UnlockedHealthPlanFormDataType,
featureFlags?: FeatureFlagSettings
draft: UnlockedHealthPlanFormDataType
): LockedHealthPlanFormDataType | SubmissionError {
const maybeStateSubmission: Record<string, unknown> = {
...draft,
status: 'SUBMITTED',
submittedAt: new Date(),
}

// move this check into isValidContract when feature flag is removed
const validPopulationCovered = featureFlags?.['chip-only-form']
? hasValidPopulationCoverage(
maybeStateSubmission as LockedHealthPlanFormDataType
)
: true

if (
isValidAndCurrentLockedHealthPlanFormData(maybeStateSubmission) &&
validPopulationCovered
)
if (isValidAndCurrentLockedHealthPlanFormData(maybeStateSubmission))
return maybeStateSubmission
else if (
!validPopulationCovered ||
!hasValidContract(maybeStateSubmission as LockedHealthPlanFormDataType)
) {
return {
Expand Down Expand Up @@ -139,20 +124,14 @@ function submit(
export function submitHealthPlanPackageResolver(
store: Store,
emailer: Emailer,
emailParameterStore: EmailParameterStore,
launchDarkly: LDService
emailParameterStore: EmailParameterStore
): MutationResolvers['submitHealthPlanPackage'] {
return async (_parent, { input }, context) => {
const { user, span } = context
const { submittedReason, pkgID } = input
setResolverDetailsOnActiveSpan('submitHealthPlanPackage', user, span)
span?.setAttribute('mcreview.package_id', pkgID)

const chipOnlyFormFlag = await launchDarkly.getFeatureFlag(
context,
'chip-only-form'
)

// This resolver is only callable by state users
if (!isStateUser(user)) {
logError(
Expand Down Expand Up @@ -284,9 +263,7 @@ export function submitHealthPlanPackageResolver(
}

// attempt to parse into a StateSubmission
const submissionResult = submit(draftResult, {
'chip-only-form': chipOnlyFormFlag,
})
const submissionResult = submit(draftResult)

if (isSubmissionError(submissionResult)) {
const errMessage = submissionResult.message
Expand Down
3 changes: 2 additions & 1 deletion services/app-api/src/testHelpers/gqlHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ const createTestHealthPlanPackage = async (
const programIDs = programs.map((program) => program.id)
const input: CreateHealthPlanPackageInput = {
programIDs: programIDs,
populationCovered: 'MEDICAID',
riskBasedContract: false,
submissionType: 'CONTRACT_ONLY' as const,
submissionType: 'CONTRACT_ONLY',
submissionDescription: 'A created submission',
contractType: 'BASE',
}
Expand Down
2 changes: 1 addition & 1 deletion services/app-graphql/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ type Mutation {

input CreateHealthPlanPackageInput {
"Population that the contract covers"
populationCovered: PopulationCoveredType
populationCovered: PopulationCoveredType!
"An array of managed care program IDs this package covers"
programIDs: [ID!]!
"Whether or not this contract is risk based"
Expand Down
7 changes: 0 additions & 7 deletions services/app-web/src/common-code/featureFlags/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ const featureFlags = {
flag: 'packages-with-shared-rates',
defaultValue: false,
},
/**
* Enables Chip-only form changes
*/
CHIP_ONLY_FORM: {
flag: 'chip-only-form',
defaultValue: false,
},
/**
* Enables supporting documents to be associated with a specific rate certification on the Rate Details page
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function newHealthPlanFormData(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_AND_RATES',
riskBasedContract: true,
Expand All @@ -68,6 +69,7 @@ function basicHealthPlanFormData(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_AND_RATES',
riskBasedContract: true,
Expand All @@ -94,6 +96,7 @@ function contractOnly(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_ONLY',
riskBasedContract: false,
Expand All @@ -120,6 +123,7 @@ function contractAmendedOnly(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_ONLY',
riskBasedContract: false,
Expand Down Expand Up @@ -167,6 +171,7 @@ function unlockedWithContacts(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_AND_RATES',
riskBasedContract: true,
Expand Down Expand Up @@ -254,6 +259,7 @@ function unlockedWithDocuments(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_AND_RATES',
riskBasedContract: true,
Expand Down Expand Up @@ -364,6 +370,7 @@ function unlockedWithFullRates(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_AND_RATES',
riskBasedContract: true,
Expand Down Expand Up @@ -409,7 +416,7 @@ function unlockedWithFullRates(): UnlockedHealthPlanFormDataType {
documentCategories: ['RATES'],
},
],
supportingDocuments: [],
supportingDocuments: [],
actuaryContacts: [
{
name: 'foo bar',
Expand Down Expand Up @@ -468,6 +475,7 @@ function unlockedWithFullContracts(): UnlockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_AND_RATES',
riskBasedContract: true,
Expand Down Expand Up @@ -540,7 +548,7 @@ function unlockedWithFullContracts(): UnlockedHealthPlanFormDataType {
documentCategories: ['RATES'],
},
],
supportingDocuments: [],
supportingDocuments: [],
actuaryContacts: [
{
name: 'foo bar',
Expand Down Expand Up @@ -599,6 +607,7 @@ function unlockedWithALittleBitOfEverything(): UnlockedHealthPlanFormDataType {
status: 'DRAFT',
stateCode: 'MN',
stateNumber: 5,
populationCovered: 'MEDICAID',
programIDs: [
mockMNState().programs[0].id,
mockMNState().programs[1].id,
Expand Down Expand Up @@ -735,6 +744,7 @@ function basicLockedHealthPlanFormData(): LockedHealthPlanFormDataType {
stateNumber: 5,
id: 'test-abc-123',
stateCode: 'MN',
populationCovered: 'MEDICAID',
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_ONLY',
riskBasedContract: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const hasValidContract = (sub: LockedHealthPlanFormDataType): boolean =>
sub.managedCareEntities.length !== 0 &&
sub.federalAuthorities.length !== 0 &&
sub.riskBasedContract !== undefined &&
hasValidModifiedProvisions(sub)
hasValidModifiedProvisions(sub) &&
hasValidPopulationCoverage(sub)

const hasValidPopulationCoverage = (
sub: LockedHealthPlanFormDataType
Expand Down Expand Up @@ -305,7 +306,7 @@ const generateRateName = (
return rateName
}

// This logic is no longer needed once SUPPORTING_DOCS_BY_RATE flag is on in production
// This logic is no longer needed once SUPPORTING_DOCS_BY_RATE flag is on in production
const convertRateSupportingDocs = (
documents: SubmissionDocument[]
): SubmissionDocument[] => {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const DemoListUploadSuccess = (): React.ReactElement => {
await fakeRequest<S3FileData>(true, resolveData)
return
}}
onFileItemsUpdate={() => console.log('Async load complete')}
onFileItemsUpdate={() => console.info('Async load complete')}
isContractOnly={false}
/>
)
Expand All @@ -50,7 +50,7 @@ export const DemoTableUploadSuccess = (): React.ReactElement => {
await fakeRequest<S3FileData>(true, resolveData)
return
}}
onFileItemsUpdate={() => console.log('Async load complete')}
onFileItemsUpdate={() => console.info('Async load complete')}
isContractOnly={false}
/>
)
Expand All @@ -74,7 +74,7 @@ export const DemoListUploadFailure = (): React.ReactElement => {
await fakeRequest<S3FileData>(true, resolveData)
return
}}
onFileItemsUpdate={() => console.log('Async load complete')}
onFileItemsUpdate={() => console.info('Async load complete')}
isContractOnly={false}
/>
)
Expand All @@ -98,7 +98,7 @@ export const DemoTableUploadFailure = (): React.ReactElement => {
await fakeRequest<S3FileData>(true, resolveData)
return
}}
onFileItemsUpdate={() => console.log('Async load complete')}
onFileItemsUpdate={() => console.info('Async load complete')}
isContractOnly={false}
/>
)
Expand All @@ -122,7 +122,7 @@ export const DemoListScanFailure = (): React.ReactElement => {
await fakeRequest<S3FileData>(true, resolveData)
return
}}
onFileItemsUpdate={() => console.log('Async load complete')}
onFileItemsUpdate={() => console.info('Async load complete')}
isContractOnly={false}
/>
)
Expand All @@ -146,7 +146,7 @@ export const DemoTableScanFailure = (): React.ReactElement => {
await fakeRequest<S3FileData>(true, resolveData)
return
}}
onFileItemsUpdate={() => console.log('Async load complete')}
onFileItemsUpdate={() => console.info('Async load complete')}
isContractOnly={false}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
const Template: Story<FieldCheckboxProps> = (args) => (
<Formik
initialValues={{ input1: '' }}
onSubmit={(e) => console.log('submitted')}
onSubmit={(e) => console.info('submitted')}
>
<FieldCheckbox {...args} />
</Formik>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Template: Story<FieldDropdownProps> = (args) => (
initialValues={{ program: '' }}
validationSchema={schema}
validateOnMount={true}
onSubmit={(e) => console.log('submitted')}
onSubmit={(e) => console.info('submitted')}
>
<FieldDropdown {...args} />
</Formik>
Expand Down
Loading

0 comments on commit b82feb9

Please sign in to comment.