-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MCR-3772 MCR-3771 Edit and submit standalone rate (#2238)
- Loading branch information
Showing
33 changed files
with
1,478 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ tsconfig.tsbuildinfo | |
.serverless | ||
.eslintcache | ||
/.env | ||
.nx | ||
tests_output | ||
*.log | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Recursively replaces all nulls with undefineds | ||
GQL return <Maybe> types are T | null instead of T | undefined which match our zod .optional() domain types | ||
This functions allows us convert GQL to zod-friendly types to type match zod and apollo server types | ||
and avoid manual type casting or null coalescing work | ||
Adapted from https://github.com/apollographql/apollo-client/issues/2412 | ||
*/ | ||
|
||
type RecursivelyReplaceNullWithUndefined<T> = T extends null | ||
? undefined | ||
: T extends Date | ||
? T | ||
: { | ||
[K in keyof T]: T[K] extends (infer U)[] | ||
? RecursivelyReplaceNullWithUndefined<U>[] | ||
: RecursivelyReplaceNullWithUndefined<T[K]> | ||
} | ||
|
||
export function nullsToUndefined<T>( | ||
obj: T | ||
): RecursivelyReplaceNullWithUndefined<T> { | ||
if (obj === null) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return undefined as any | ||
} | ||
|
||
// object check based on: https://stackoverflow.com/a/51458052/6489012 | ||
if (obj?.constructor.name === 'Object') { | ||
for (const key in obj) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
obj[key] = nullsToUndefined(obj[key]) as any | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return obj as any | ||
} |
56 changes: 56 additions & 0 deletions
56
services/app-api/src/resolvers/rate/generateRateCertificationName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { formatRateNameDate } from '../../../../app-web/src/common-code/dateHelpers' | ||
import { packageName } from '../../../../app-web/src/common-code/healthPlanFormDataType' | ||
import type { ProgramArgType } from '../../../../app-web/src/common-code/healthPlanFormDataType' | ||
import type { RateFormDataType } from '../../domain-models/contractAndRates' | ||
|
||
const generateRateCertificationName = ( | ||
rateFormData: RateFormDataType, | ||
stateCode: string, | ||
stateNumber: number, | ||
statePrograms: ProgramArgType[] | ||
): string => { | ||
const { | ||
rateType, | ||
rateProgramIDs, | ||
amendmentEffectiveDateEnd, | ||
amendmentEffectiveDateStart, | ||
rateDateCertified, | ||
rateDateEnd, | ||
rateDateStart, | ||
} = rateFormData | ||
|
||
let rateName = `${packageName( | ||
stateCode, | ||
stateNumber, | ||
rateProgramIDs ?? [], | ||
statePrograms | ||
)}-RATE` | ||
if (rateType === 'NEW' && rateDateStart) { | ||
rateName = rateName.concat( | ||
'-', | ||
formatRateNameDate(rateDateStart), | ||
'-', | ||
formatRateNameDate(rateDateEnd), | ||
'-', | ||
'CERTIFICATION' | ||
) | ||
} | ||
|
||
if (rateType === 'AMENDMENT') { | ||
rateName = rateName.concat( | ||
'-', | ||
formatRateNameDate(amendmentEffectiveDateStart), | ||
'-', | ||
formatRateNameDate(amendmentEffectiveDateEnd), | ||
'-', | ||
'AMENDMENT' | ||
) | ||
} | ||
|
||
if (rateDateCertified) { | ||
rateName = rateName.concat('-', formatRateNameDate(rateDateCertified)) | ||
} | ||
return rateName | ||
} | ||
|
||
export { generateRateCertificationName } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.