Skip to content

Commit

Permalink
Remove Population Covered Feature Flag
Browse files Browse the repository at this point in the history
  • Loading branch information
macrael committed Jul 18, 2023
1 parent e72775d commit 96c77fc
Show file tree
Hide file tree
Showing 14 changed files with 377 additions and 454 deletions.
15 changes: 1 addition & 14 deletions services/app-api/src/handlers/apollo_gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ import {
newAWSEmailParameterStore,
newLocalEmailParameterStore,
} from '../parameterStore'
import {
LDService,
ldService,
offlineLDService,
} from '../launchDarkly/launchDarkly'
import { LDClient } from 'launchdarkly-node-server-sdk'
import * as ld from 'launchdarkly-node-server-sdk'
import {
Expand Down Expand Up @@ -291,18 +286,15 @@ async function initializeGQLHandler(): Promise<Handler> {
eventsUri: 'https://events.launchdarkly.us',
}
ldClient = ld.init(ldSDKKey, ldOptions)
let launchDarkly: LDService

// Wait for initialization. On initialization failure default to offlineLDService and close ldClient.
try {
await ldClient.waitForInitialization()
launchDarkly = ldService(ldClient)
} catch (err) {
console.error(
`LaunchDarkly Error: ${err.message} Falling back to LaunchDarkly offline service.`
)
ldClient.close()
launchDarkly = offlineLDService()
}

// Configure Apollo sandbox plugin
Expand Down Expand Up @@ -353,12 +345,7 @@ async function initializeGQLHandler(): Promise<Handler> {
})

// Resolvers are defined and tested in the resolvers package
const resolvers = configureResolvers(
store,
emailer,
emailParameterStore,
launchDarkly
)
const resolvers = configureResolvers(store, emailer, emailParameterStore)

const userFetcher =
authMode === 'LOCAL'
Expand Down
7 changes: 2 additions & 5 deletions services/app-api/src/resolvers/configureResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import {
indexUsersResolver,
} from './user'
import { EmailParameterStore } from '../parameterStore'
import { LDService } from '../launchDarkly/launchDarkly'
import { fetchEmailSettingsResolver } from './email/fetchEmailSettings'

export function configureResolvers(
store: Store,
emailer: Emailer,
emailParameterStore: EmailParameterStore,
launchDarkly: LDService
emailParameterStore: EmailParameterStore
): Resolvers {
const resolvers: Resolvers = {
Date: GraphQLDate,
Expand All @@ -54,8 +52,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 @@ -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 @@ -29,9 +29,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,8 +68,7 @@ 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,
Expand All @@ -80,11 +77,9 @@ function submit(
}

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

if (
isValidAndCurrentLockedHealthPlanFormData(maybeStateSubmission) &&
Expand Down Expand Up @@ -139,20 +134,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 +273,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
5 changes: 1 addition & 4 deletions services/app-api/src/testHelpers/gqlHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
EmailParameterStore,
} from '../parameterStore'
import statePrograms from 'app-web/src/common-code/data/statePrograms.json'
import { testLDService } from './launchDarklyHelpers'
import { LDService } from '../launchDarkly/launchDarkly'
import { insertUserToLocalAurora } from '../authn'
import { testStateUser } from './userHelpers'
Expand Down Expand Up @@ -84,7 +83,6 @@ const constructTestPostgresServer = async (opts?: {
const emailer = opts?.emailer || constructTestEmailer()
const parameterStore =
opts?.emailParameterStore || newLocalEmailParameterStore()
const ldService = opts?.ldService || testLDService()

const prismaClient = await sharedTestPrismaClient()
const postgresStore = opts?.store || NewPostgresStore(prismaClient)
Expand All @@ -94,8 +92,7 @@ const constructTestPostgresServer = async (opts?: {
const postgresResolvers = configureResolvers(
postgresStore,
emailer,
parameterStore,
ldService
parameterStore
)

return new ApolloServer({
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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { screen } from '@testing-library/react'
import {
ldUseClientSpy,
renderWithProviders,
} from '../../../testHelpers/jestHelpers'
import { renderWithProviders } from '../../../testHelpers/jestHelpers'
import { SubmissionTypeSummarySection } from './SubmissionTypeSummarySection'
import {
mockContractAndRatesDraft,
Expand Down Expand Up @@ -69,7 +66,6 @@ describe('SubmissionTypeSummarySection', () => {
})

it('renders expected fields for draft package on review and submit', () => {
ldUseClientSpy({ 'chip-only-form': true })
renderWithProviders(
<SubmissionTypeSummarySection
submission={draftSubmission}
Expand Down Expand Up @@ -104,7 +100,6 @@ describe('SubmissionTypeSummarySection', () => {
})

it('renders missing field message for population coverage question when expected', () => {
ldUseClientSpy({ 'chip-only-form': true })
renderWithProviders(
<SubmissionTypeSummarySection
submission={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { Program } from '../../../gen/gqlClient'
import { usePreviousSubmission } from '../../../hooks/usePreviousSubmission'
import { booleanAsYesNoUserValue } from '../../../components/Form/FieldYesNo/FieldYesNo'
import styles from '../SubmissionSummarySection.module.scss'
import { useLDClient } from 'launchdarkly-react-client-sdk'
import { featureFlags } from '../../../common-code/featureFlags'

export type SubmissionTypeSummarySectionProps = {
submission: HealthPlanFormDataType
Expand All @@ -39,12 +37,6 @@ export const SubmissionTypeSummarySection = ({
.map((p) => p.name)
const isSubmitted = submission.status === 'SUBMITTED'

const ldClient = useLDClient()
const showCHIPOnlyForm = ldClient?.variation(
featureFlags.CHIP_ONLY_FORM.flag,
featureFlags.CHIP_ONLY_FORM.defaultValue
)

return (
<section id="submissionTypeSection" className={styles.summarySection}>
<SectionHeader
Expand Down Expand Up @@ -105,19 +97,17 @@ export const SubmissionTypeSummarySection = ({
submission.riskBasedContract
)}
/>
{showCHIPOnlyForm && (
<DataDetail
id="populationCoverage"
label="Which populations does this contract action cover?"
explainMissingData={!isSubmitted}
children={
submission.populationCovered &&
PopulationCoveredRecord[
submission.populationCovered
]
}
/>
)}
<DataDetail
id="populationCoverage"
label="Which populations does this contract action cover?"
explainMissingData={!isSubmitted}
children={
submission.populationCovered &&
PopulationCoveredRecord[
submission.populationCovered
]
}
/>
</DoubleColumnGrid>

<Grid row gap className={styles.reviewDataRow}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ describe('NewStateSubmissionForm', () => {
screen.getByRole('form', { name: 'New Submission Form' })
).toBeInTheDocument()

const medicaid = await screen.findByText('Medicaid')
await userEvent.click(medicaid)

const comboBox = await screen.findByRole('combobox', {
name: 'Programs this contract action covers (required)',
})
Expand Down
Loading

0 comments on commit 96c77fc

Please sign in to comment.