Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…e-review into mcr-3547-ui-regression-fix
  • Loading branch information
pearl-truss committed Nov 9, 2023
2 parents e508a92 + 0dcfbc7 commit 5bfd29a
Show file tree
Hide file tree
Showing 50 changed files with 5,970 additions and 619 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand Down
5 changes: 3 additions & 2 deletions docs/technical-design/howto-update-state-programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The source of truth for that file comes from a CSV maintained by product and des

1. Download the latest version of csv from google docs when prompted by product/design.
2. Run the script following the command listed in the `import-programs.ts`.
3. Overwrite existing state programs JSON with the new output. Your usage of the script will likely look something like this: `cd scripts && yarn tsc && node import-programs.js ~/Desktop/State\ programs,\ population,\ and\ nicknames.csv > ../services/app-web/src/common-code/data/statePrograms.json`
3. Overwrite existing state programs JSON with the new output. Your usage of the script will likely look something like this: `cd scripts && yarn tsc && node import-programs.js path/to/data.csv > ../services/app-web/src/common-code/data/statePrograms.json`
4. Double check the diff. It's important not to delete any programs that have already been used for a submission because although programs are not in the database, we still store references to the program ID in postgres as if they are stable. Also, we want to be sure we are only changing programs expected to change.
5. Make a PR to update the statePrograms file in the codebase
5. For any newly created programs, manually populate the `id` field usings a UUID generator
6. Make a PR to update the statePrograms file in the codebase
5 changes: 4 additions & 1 deletion scripts/import-programs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
This script is used to generate a list of MC-Review state programs. To read more about this script and why it's used see "How to update state programs" technical design docs.
To run:
yarn tsc && node ./import-programs.js path/to/data.csv
yarn tsc && node ./import-programs.js path/to/data.csv > ../services/app-web/src/common-code/data/statePrograms.json
The input file is expected to be a valid CSV with at least the following columns:
1 State (two-character state code, uppercase)
2 Program (full program name)
3 Nickname (acronym or abbreviation e.g. "CME")
Documentation for this script can be found here:
https://github.com/Enterprise-CMCS/managed-care-review/blob/main/docs/technical-design/howto-update-state-programs.md
Additional columns aren't used and should be ignored.
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ describe('findRate', () => {
const draftRateTwo = must(
await insertDraftRate(client, {
stateCode: 'MN',
rateCertificationName: 'first submission rate revision',
rateCertificationName: 'second submission rate revision',
})
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ const sortRatesForUpdate = (
ratesFromClient: RateFormDataType[]
): {
upsertRates: RateFormEditable[]
disconnectRateIDs: string[]
disconnectRates: {
rateID: string
revisionID: string
}[]
} => {
const upsertRates = []
const disconnectRateIDs = []
const disconnectRates = []

// Find rates to create or update
for (const clientRateData of ratesFromClient) {
Expand Down Expand Up @@ -65,21 +68,25 @@ const sortRatesForUpdate = (
}

// Find rates to disconnect
for (const dbRate of ratesFromDB) {
for (const dbRateRev of ratesFromDB) {
//Find a matching rate revision id in the ratesFromClient
const matchingHPPRate = ratesFromClient.find(
(clientRateData) => clientRateData.id === dbRate.formData.rateID
(clientRateData) => clientRateData.id === dbRateRev.formData.rateID
)

// If convertedRateData does not contain the rate revision id from DB, we push these revisions rateID in disconnectRateIDs
if (!matchingHPPRate && dbRate.formData.rateID) {
disconnectRateIDs.push(dbRate.formData.rateID)
// If convertedRateData does not contain the rate revision id from DB, we push these revisions id and rate id
// in disconnectRates
if (!matchingHPPRate && dbRateRev.formData.rateID) {
disconnectRates.push({
rateID: dbRateRev.formData.rateID,
revisionID: dbRateRev.id,
})
}
}

return {
upsertRates,
disconnectRateIDs,
disconnectRates,
}
}

Expand Down Expand Up @@ -498,12 +505,25 @@ async function updateDraftContractWithRates(
modifiedNonRiskPaymentArrangements
),
draftRates: {
disconnect: updateRates?.disconnectRateIDs
? updateRates.disconnectRateIDs.map((rateID) => ({
id: rateID,
disconnect: updateRates?.disconnectRates
? updateRates.disconnectRates.map((rate) => ({
id: rate.rateID,
}))
: [],
},
contract: {
update: {
draftRateRevisions: {
disconnect: updateRates?.disconnectRates
? updateRates.disconnectRates.map(
(rate) => ({
id: rate.revisionID,
})
)
: [],
},
},
},
},
})

Expand Down
5 changes: 4 additions & 1 deletion services/app-api/src/resolvers/attributeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export function setResolverDetailsOnActiveSpan(
user: Context['user'],
span: Context['span']
): void {
if (!span) return
if (!span) {
console.info(`No span set on ${name} call`)
return
}
span.setAttributes({
[SemanticAttributes.ENDUSER_ID]: user.email,
[SemanticAttributes.ENDUSER_ROLE]: user.role,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export function indexHealthPlanPackagesResolver(
): QueryResolvers['indexHealthPlanPackages'] {
return async (_parent, _args, context) => {
const { user, span } = context
setResolverDetailsOnActiveSpan('fetchHealthPlanPackage', user, span)

setResolverDetailsOnActiveSpan('indexHealthPlanPackages', user, span)

const ratesDatabaseRefactor = await launchDarkly.getFeatureFlag(
context,
Expand All @@ -70,7 +71,7 @@ export function indexHealthPlanPackagesResolver(

if (contractsWithHistory instanceof Error) {
const errMessage = `Issue finding contracts with history by stateCode: ${user.stateCode}. Message: ${contractsWithHistory.message}`
logError('fetchHealthPlanPackage', errMessage)
logError('indexHealthPlanPackages', errMessage)
setErrorAttributesOnActiveSpan(errMessage, span)

if (contractsWithHistory instanceof NotFoundError) {
Expand Down Expand Up @@ -111,7 +112,7 @@ export function indexHealthPlanPackagesResolver(

if (contractsWithHistory instanceof Error) {
const errMessage = `Issue finding contracts with history by submit info. Message: ${contractsWithHistory.message}`
logError('fetchHealthPlanPackage', errMessage)
logError('indexHealthPlanPackages', errMessage)
setErrorAttributesOnActiveSpan(errMessage, span)

if (contractsWithHistory instanceof NotFoundError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('currentUser', () => {

expect(res.data?.fetchCurrentUser.email).toBe('james@example.com')
expect(res.data?.fetchCurrentUser.state.code).toBe('FL')
expect(res.data?.fetchCurrentUser.state.programs).toHaveLength(6)
expect(res.data?.fetchCurrentUser.state.programs).toHaveLength(5)
})

it('returns programs for MI', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,69 @@ const createInsertContractData = ({

const createDraftContractData = (
contract?: Partial<ContractTableFullPayload>
): ContractTableFullPayload => ({
id: uuidv4(),
createdAt: new Date(),
updatedAt: new Date(),
mccrsID: null,
stateCode: 'MN',
stateNumber: 111,
revisions: contract?.revisions ?? [
createContractRevision(
contract,
{
rateRevisions: undefined,
submitInfo: null,
},
contract?.stateCode as StateCodeType
) as ContractRevisionTableWithRates,
],
...contract,
})
): ContractTableFullPayload => {
const contractData = {
id: uuidv4(),
createdAt: new Date(),
updatedAt: new Date(),
mccrsID: null,
stateCode: 'MN',
stateNumber: 111,
revisions: [],
...contract,
}

Object.assign(contractData, {
revisions: contract?.revisions ?? [
createContractRevision(
{
...contractData,
...contract,
},
{
draftRates: [],
rateRevisions: [],
submitInfo: null,
},
contract?.stateCode as StateCodeType
) as ContractRevisionTableWithRates,
],
})

return contractData
}

const createContractData = (
contract?: Partial<ContractTableFullPayload>
): ContractTableFullPayload => ({
id: uuidv4(),
createdAt: new Date(),
updatedAt: new Date(),
mccrsID: null,
stateCode: 'MN',
stateNumber: 111,
revisions: contract?.revisions ?? [
createContractRevision(
contract,
{
draftRates: undefined,
},
contract?.stateCode as StateCodeType
) as ContractRevisionTableWithRates,
],
...contract,
})
): ContractTableFullPayload => {
const contractData = {
id: uuidv4(),
createdAt: new Date(),
updatedAt: new Date(),
mccrsID: null,
stateCode: 'MN',
stateNumber: 111,
revisions: [],
...contract,
}

Object.assign(contractData, {
revisions: contract?.revisions ?? [
createContractRevision(
{
...contractData,
...contract,
},
{
draftRates: [],
},
contract?.stateCode as StateCodeType
) as ContractRevisionTableWithRates,
],
})

return contractData
}

const createContractRevision = (
contract?: Partial<ContractTableFullPayload>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createDraftRateData = (
createRateRevision(
rate,
{
contractRevisions: undefined,
contractRevisions: [],
submitInfo: null,
},
rate?.stateCode as StateCodeType
Expand All @@ -58,7 +58,7 @@ const createRateData = (
createRateRevision(
rate,
{
draftContracts: undefined,
draftContracts: [],
},
rate?.stateCode as StateCodeType
) as RateRevisionTableWithContracts,
Expand Down
1 change: 1 addition & 0 deletions services/app-proto/src/health_plan_form_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,5 @@ enum StateCode {
STATE_CODE_WI = 50;
STATE_CODE_WV = 51;
STATE_CODE_WY= 52;
STATE_CODE_KY = 53;
}
4 changes: 4 additions & 0 deletions services/app-web/src/assets/icons/ky-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5bfd29a

Please sign in to comment.