From 904d91bb7a8cc7e7e75aede1a55517d34a40f948 Mon Sep 17 00:00:00 2001 From: ailZhou Date: Tue, 17 Sep 2024 14:02:22 -0400 Subject: [PATCH] consolidate --- .../measures/2021/globalValidations/index.ts | 2 +- .../validateDualPopInformation/index.test.ts | 137 ------------------ .../validateDualPopInformation/index.ts | 62 -------- .../2022/shared/globalValidations/index.ts | 2 +- .../validateDualPopInformation/index.test.ts | 137 ------------------ .../validateDualPopInformation/index.ts | 62 -------- .../2022/shared/util/validationsMock.tsx | 2 +- .../2023/shared/globalValidations/index.ts | 2 +- .../validateDualPopInformation/index.test.ts | 137 ------------------ .../validateDualPopInformation/index.ts | 62 -------- .../2023/shared/util/validationsMock.tsx | 2 +- .../2024/shared/globalValidations/index.ts | 2 +- .../validateDualPopInformation/index.ts | 43 ------ .../2024/shared/util/validationsMock.tsx | 2 +- .../validateDualPopInformation/index.test.ts | 0 .../validateDualPopInformation/index.ts | 70 +++++++++ 16 files changed, 77 insertions(+), 647 deletions(-) delete mode 100644 services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.test.ts delete mode 100644 services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.ts delete mode 100644 services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.test.ts delete mode 100644 services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.ts delete mode 100644 services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.test.ts delete mode 100644 services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.ts delete mode 100644 services/ui-src/src/measures/2024/shared/globalValidations/validateDualPopInformation/index.ts rename services/ui-src/src/{measures/2024 => }/shared/globalValidations/validateDualPopInformation/index.test.ts (100%) create mode 100644 services/ui-src/src/shared/globalValidations/validateDualPopInformation/index.ts diff --git a/services/ui-src/src/measures/2021/globalValidations/index.ts b/services/ui-src/src/measures/2021/globalValidations/index.ts index da16c2bb40..7c0a4a1fdd 100644 --- a/services/ui-src/src/measures/2021/globalValidations/index.ts +++ b/services/ui-src/src/measures/2021/globalValidations/index.ts @@ -6,7 +6,7 @@ export * from "shared/globalValidations/validateAtLeastOneDataSource"; export * from "./validateAtLeastOneDeviationFieldFilled"; export * from "shared/globalValidations/validateAtLeastOneRateComplete"; export * from "shared/globalValidations/validateBothDatesInRange"; -export * from "./validateDualPopInformation"; +export * from "shared/globalValidations/validateDualPopInformation"; export * from "./validateEqualCategoryDenominators"; export * from "shared/globalValidations/validateEqualQualifierDenominators"; export * from "./validateRateNotZero"; diff --git a/services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.test.ts b/services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.test.ts deleted file mode 100644 index a7a289a2c9..0000000000 --- a/services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import * as DC from "dataConstants"; -import { simpleRate, partialRate } from "utils/testUtils/validationHelpers"; -import { validateDualPopInformationPM } from "."; - -describe("Testing Dual Population Selection Validation", () => { - it("should be no errors", () => { - const errors = validateDualPopInformationPM([], undefined, 0, []); - - expect(errors.length).toBe(0); - }); - - it("should be no errors - partial data", () => { - const errors = validateDualPopInformationPM( - [[partialRate, partialRate]], - undefined, - 0, - [] - ); - - expect(errors.length).toBe(0); - }); - - it("should be no errors - OPM", () => { - const errors = validateDualPopInformationPM([], [], 0, []); - - expect(errors.length).toBe(0); - }); - - it("should be errors for no checkbox selections", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no matching checkbox selection", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - [] - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no matching checkbox selection - specified string", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - [], - "TestLabel" - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the TestLabel Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no data", () => { - const errors = validateDualPopInformationPM([], undefined, 0, [ - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE, - ]); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for Age 65 and Older` - ); - }); - - it("should be errors for no data - specified string", () => { - const errors = validateDualPopInformationPM( - [], - undefined, - 0, - [DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE], - "TestLabel" - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for TestLabel` - ); - }); - - it("Error message text should match default errorMessage", () => { - const errorArray = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined - ); - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - "Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing" - ); - }); - - it("Error message text should match provided errorMessage", () => { - const errorMessageFunc = ( - _dualEligible: boolean, - errorReplacementText: string - ) => { - return `Another ${errorReplacementText} bites the dust`; - }; - - const errorArray = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined, - undefined, - errorMessageFunc - ); - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - errorMessageFunc(true, "Age 65 and Older") - ); - }); -}); diff --git a/services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.ts b/services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.ts deleted file mode 100644 index 18a57160e9..0000000000 --- a/services/ui-src/src/measures/2021/globalValidations/validateDualPopInformation/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as DC from "dataConstants"; -import { FormRateField } from "../types"; - -const validateDualPopInformationPMErrorMessage = ( - dualEligible: boolean, - errorReplacementText: string -) => { - if (!dualEligible) { - return `Information has been included in the ${errorReplacementText} Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing`; - } else { - return `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for ${errorReplacementText}`; - } -}; - -export const validateDualPopInformationPM = ( - performanceMeasureArray: FormRateField[][], - OPM: any, - age65PlusIndex: number, - DefinitionOfDenominator: string[] | undefined, - errorReplacementText: string = "Age 65 and Older", - errorMessageFunc = validateDualPopInformationPMErrorMessage -) => { - if (OPM) { - return []; - } - - const dualEligible = DefinitionOfDenominator - ? DefinitionOfDenominator.indexOf( - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE - ) !== -1 - : false; - - const errorArray: FormError[] = []; - const filledInData: FormRateField[] = []; - performanceMeasureArray?.forEach((performanceMeasure) => { - if ( - performanceMeasure && - performanceMeasure[age65PlusIndex] && - performanceMeasure[age65PlusIndex].denominator && - performanceMeasure[age65PlusIndex].numerator && - performanceMeasure[age65PlusIndex].rate - ) { - filledInData.push(performanceMeasure[age65PlusIndex]); - } - }); - - if (!dualEligible && filledInData.length > 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: errorMessageFunc(dualEligible, errorReplacementText), - errorType: "Warning", - }); - } - if (dualEligible && filledInData.length === 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: errorMessageFunc(dualEligible, errorReplacementText), - errorType: "Warning", - }); - } - return errorArray; -}; diff --git a/services/ui-src/src/measures/2022/shared/globalValidations/index.ts b/services/ui-src/src/measures/2022/shared/globalValidations/index.ts index da16c2bb40..7c0a4a1fdd 100644 --- a/services/ui-src/src/measures/2022/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2022/shared/globalValidations/index.ts @@ -6,7 +6,7 @@ export * from "shared/globalValidations/validateAtLeastOneDataSource"; export * from "./validateAtLeastOneDeviationFieldFilled"; export * from "shared/globalValidations/validateAtLeastOneRateComplete"; export * from "shared/globalValidations/validateBothDatesInRange"; -export * from "./validateDualPopInformation"; +export * from "shared/globalValidations/validateDualPopInformation"; export * from "./validateEqualCategoryDenominators"; export * from "shared/globalValidations/validateEqualQualifierDenominators"; export * from "./validateRateNotZero"; diff --git a/services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.test.ts b/services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.test.ts deleted file mode 100644 index a7a289a2c9..0000000000 --- a/services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import * as DC from "dataConstants"; -import { simpleRate, partialRate } from "utils/testUtils/validationHelpers"; -import { validateDualPopInformationPM } from "."; - -describe("Testing Dual Population Selection Validation", () => { - it("should be no errors", () => { - const errors = validateDualPopInformationPM([], undefined, 0, []); - - expect(errors.length).toBe(0); - }); - - it("should be no errors - partial data", () => { - const errors = validateDualPopInformationPM( - [[partialRate, partialRate]], - undefined, - 0, - [] - ); - - expect(errors.length).toBe(0); - }); - - it("should be no errors - OPM", () => { - const errors = validateDualPopInformationPM([], [], 0, []); - - expect(errors.length).toBe(0); - }); - - it("should be errors for no checkbox selections", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no matching checkbox selection", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - [] - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no matching checkbox selection - specified string", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - [], - "TestLabel" - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the TestLabel Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no data", () => { - const errors = validateDualPopInformationPM([], undefined, 0, [ - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE, - ]); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for Age 65 and Older` - ); - }); - - it("should be errors for no data - specified string", () => { - const errors = validateDualPopInformationPM( - [], - undefined, - 0, - [DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE], - "TestLabel" - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for TestLabel` - ); - }); - - it("Error message text should match default errorMessage", () => { - const errorArray = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined - ); - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - "Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing" - ); - }); - - it("Error message text should match provided errorMessage", () => { - const errorMessageFunc = ( - _dualEligible: boolean, - errorReplacementText: string - ) => { - return `Another ${errorReplacementText} bites the dust`; - }; - - const errorArray = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined, - undefined, - errorMessageFunc - ); - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - errorMessageFunc(true, "Age 65 and Older") - ); - }); -}); diff --git a/services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.ts b/services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.ts deleted file mode 100644 index 18a57160e9..0000000000 --- a/services/ui-src/src/measures/2022/shared/globalValidations/validateDualPopInformation/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as DC from "dataConstants"; -import { FormRateField } from "../types"; - -const validateDualPopInformationPMErrorMessage = ( - dualEligible: boolean, - errorReplacementText: string -) => { - if (!dualEligible) { - return `Information has been included in the ${errorReplacementText} Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing`; - } else { - return `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for ${errorReplacementText}`; - } -}; - -export const validateDualPopInformationPM = ( - performanceMeasureArray: FormRateField[][], - OPM: any, - age65PlusIndex: number, - DefinitionOfDenominator: string[] | undefined, - errorReplacementText: string = "Age 65 and Older", - errorMessageFunc = validateDualPopInformationPMErrorMessage -) => { - if (OPM) { - return []; - } - - const dualEligible = DefinitionOfDenominator - ? DefinitionOfDenominator.indexOf( - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE - ) !== -1 - : false; - - const errorArray: FormError[] = []; - const filledInData: FormRateField[] = []; - performanceMeasureArray?.forEach((performanceMeasure) => { - if ( - performanceMeasure && - performanceMeasure[age65PlusIndex] && - performanceMeasure[age65PlusIndex].denominator && - performanceMeasure[age65PlusIndex].numerator && - performanceMeasure[age65PlusIndex].rate - ) { - filledInData.push(performanceMeasure[age65PlusIndex]); - } - }); - - if (!dualEligible && filledInData.length > 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: errorMessageFunc(dualEligible, errorReplacementText), - errorType: "Warning", - }); - } - if (dualEligible && filledInData.length === 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: errorMessageFunc(dualEligible, errorReplacementText), - errorType: "Warning", - }); - } - return errorArray; -}; diff --git a/services/ui-src/src/measures/2022/shared/util/validationsMock.tsx b/services/ui-src/src/measures/2022/shared/util/validationsMock.tsx index ce6b071d9f..f91738440e 100644 --- a/services/ui-src/src/measures/2022/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2022/shared/util/validationsMock.tsx @@ -2,7 +2,7 @@ import * as validateAtLeastOneDataSource from "shared/globalValidations/validate import * as validateAtLeastOneDeviationFieldFilled from "measures/2022/shared/globalValidations/validateAtLeastOneDeviationFieldFilled"; import * as validateAtLeastOneRateComplete from "shared/globalValidations/validateAtLeastOneRateComplete"; import * as validateBothDatesInRange from "shared/globalValidations/validateBothDatesInRange"; -import * as validateDualPopInformation from "measures/2022/shared/globalValidations/validateDualPopInformation"; +import * as validateDualPopInformation from "shared/globalValidations/validateDualPopInformation"; import * as validateEqualCategoryDenominators from "measures/2022/shared/globalValidations/validateEqualCategoryDenominators"; import * as validateEqualQualifierDenominators from "shared/globalValidations/validateEqualQualifierDenominators"; import * as validateRateNotZero from "measures/2022/shared/globalValidations/validateRateNotZero"; diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/index.ts b/services/ui-src/src/measures/2023/shared/globalValidations/index.ts index 3381a22ba8..a74a36ef9b 100644 --- a/services/ui-src/src/measures/2023/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2023/shared/globalValidations/index.ts @@ -10,7 +10,7 @@ export * from "./validateAtLeastOneDeviationFieldFilled"; export * from "shared/globalValidations/validateAtLeastOneRateComplete"; export * from "shared/globalValidations/validateBothDatesInRange"; export * from "shared/globalValidations/validateDateRangeRadioButtonCompletion"; -export * from "./validateDualPopInformation"; +export * from "shared/globalValidations/validateDualPopInformation"; export * from "./validateEqualCategoryDenominators"; export * from "shared/globalValidations/validateEqualQualifierDenominators"; export * from "./validateFfsRadioButtonCompletion"; diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.test.ts b/services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.test.ts deleted file mode 100644 index a7a289a2c9..0000000000 --- a/services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import * as DC from "dataConstants"; -import { simpleRate, partialRate } from "utils/testUtils/validationHelpers"; -import { validateDualPopInformationPM } from "."; - -describe("Testing Dual Population Selection Validation", () => { - it("should be no errors", () => { - const errors = validateDualPopInformationPM([], undefined, 0, []); - - expect(errors.length).toBe(0); - }); - - it("should be no errors - partial data", () => { - const errors = validateDualPopInformationPM( - [[partialRate, partialRate]], - undefined, - 0, - [] - ); - - expect(errors.length).toBe(0); - }); - - it("should be no errors - OPM", () => { - const errors = validateDualPopInformationPM([], [], 0, []); - - expect(errors.length).toBe(0); - }); - - it("should be errors for no checkbox selections", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no matching checkbox selection", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - [] - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no matching checkbox selection - specified string", () => { - const errors = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - [], - "TestLabel" - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `Information has been included in the TestLabel Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing` - ); - }); - - it("should be errors for no data", () => { - const errors = validateDualPopInformationPM([], undefined, 0, [ - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE, - ]); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for Age 65 and Older` - ); - }); - - it("should be errors for no data - specified string", () => { - const errors = validateDualPopInformationPM( - [], - undefined, - 0, - [DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE], - "TestLabel" - ); - - expect(errors.length).toBe(1); - expect(errors[0].errorLocation).toBe("Performance Measure"); - expect(errors[0].errorMessage).toBe( - `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for TestLabel` - ); - }); - - it("Error message text should match default errorMessage", () => { - const errorArray = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined - ); - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - "Information has been included in the Age 65 and Older Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing" - ); - }); - - it("Error message text should match provided errorMessage", () => { - const errorMessageFunc = ( - _dualEligible: boolean, - errorReplacementText: string - ) => { - return `Another ${errorReplacementText} bites the dust`; - }; - - const errorArray = validateDualPopInformationPM( - [[simpleRate, simpleRate]], - undefined, - 0, - undefined, - undefined, - errorMessageFunc - ); - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - errorMessageFunc(true, "Age 65 and Older") - ); - }); -}); diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.ts b/services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.ts deleted file mode 100644 index 18a57160e9..0000000000 --- a/services/ui-src/src/measures/2023/shared/globalValidations/validateDualPopInformation/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as DC from "dataConstants"; -import { FormRateField } from "../types"; - -const validateDualPopInformationPMErrorMessage = ( - dualEligible: boolean, - errorReplacementText: string -) => { - if (!dualEligible) { - return `Information has been included in the ${errorReplacementText} Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing`; - } else { - return `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for ${errorReplacementText}`; - } -}; - -export const validateDualPopInformationPM = ( - performanceMeasureArray: FormRateField[][], - OPM: any, - age65PlusIndex: number, - DefinitionOfDenominator: string[] | undefined, - errorReplacementText: string = "Age 65 and Older", - errorMessageFunc = validateDualPopInformationPMErrorMessage -) => { - if (OPM) { - return []; - } - - const dualEligible = DefinitionOfDenominator - ? DefinitionOfDenominator.indexOf( - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE - ) !== -1 - : false; - - const errorArray: FormError[] = []; - const filledInData: FormRateField[] = []; - performanceMeasureArray?.forEach((performanceMeasure) => { - if ( - performanceMeasure && - performanceMeasure[age65PlusIndex] && - performanceMeasure[age65PlusIndex].denominator && - performanceMeasure[age65PlusIndex].numerator && - performanceMeasure[age65PlusIndex].rate - ) { - filledInData.push(performanceMeasure[age65PlusIndex]); - } - }); - - if (!dualEligible && filledInData.length > 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: errorMessageFunc(dualEligible, errorReplacementText), - errorType: "Warning", - }); - } - if (dualEligible && filledInData.length === 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: errorMessageFunc(dualEligible, errorReplacementText), - errorType: "Warning", - }); - } - return errorArray; -}; diff --git a/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx b/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx index b96fbd0309..ae6d05bfd1 100644 --- a/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx @@ -5,7 +5,7 @@ import * as validateAtLeastOneDeliverySystem from "shared/globalValidations/vali import * as validateAtLeastOneDeviationFieldFilled from "measures/2023/shared/globalValidations/validateAtLeastOneDeviationFieldFilled"; import * as validateAtLeastOneRateComplete from "shared/globalValidations/validateAtLeastOneRateComplete"; import * as validateBothDatesInRange from "shared/globalValidations/validateBothDatesInRange"; -import * as validateDualPopInformation from "measures/2023/shared/globalValidations/validateDualPopInformation"; +import * as validateDualPopInformation from "shared/globalValidations/validateDualPopInformation"; import * as validateEqualCategoryDenominators from "measures/2023/shared/globalValidations/validateEqualCategoryDenominators"; import * as validateEqualQualifierDenominators from "shared/globalValidations/validateEqualQualifierDenominators"; import * as validateFfsRadioButtonCompletion from "measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion"; diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/index.ts b/services/ui-src/src/measures/2024/shared/globalValidations/index.ts index 9ebc576fec..944e32c7e7 100644 --- a/services/ui-src/src/measures/2024/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2024/shared/globalValidations/index.ts @@ -11,7 +11,7 @@ export * from "./validateAtLeastOneDeviationFieldFilled"; export * from "shared/globalValidations/validateAtLeastOneRateComplete"; export * from "shared/globalValidations/validateBothDatesInRange"; export * from "shared/globalValidations/validateDateRangeRadioButtonCompletion"; -export * from "./validateDualPopInformation"; +export * from "shared/globalValidations/validateDualPopInformation"; export * from "./validateEqualCategoryDenominators"; export * from "shared/globalValidations/validateEqualQualifierDenominators"; export * from "./validateFfsRadioButtonCompletion"; diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/validateDualPopInformation/index.ts b/services/ui-src/src/measures/2024/shared/globalValidations/validateDualPopInformation/index.ts deleted file mode 100644 index 8696045a50..0000000000 --- a/services/ui-src/src/measures/2024/shared/globalValidations/validateDualPopInformation/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -import * as DC from "dataConstants"; -import { FormRateField } from "../types"; - -export const validateDualPopInformationPM = ( - performanceMeasureArray: FormRateField[][], - OPM: any, - age65PlusIndex: number, - DefinitionOfDenominator: string[] | undefined, - errorReplacementText: string = "Age 65 and Older" -) => { - if (OPM) { - return []; - } - - const dualEligible = DefinitionOfDenominator - ? DefinitionOfDenominator.indexOf( - DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE - ) !== -1 - : false; - - const errorArray: FormError[] = []; - const filledInData: FormRateField[] = []; - performanceMeasureArray?.forEach((performanceMeasure) => { - if ( - performanceMeasure && - performanceMeasure[age65PlusIndex] && - performanceMeasure[age65PlusIndex].denominator && - performanceMeasure[age65PlusIndex].numerator && - performanceMeasure[age65PlusIndex].rate - ) { - filledInData.push(performanceMeasure[age65PlusIndex]); - } - }); - - if (dualEligible && filledInData.length === 0) { - errorArray.push({ - errorLocation: "Performance Measure", - errorMessage: `"Individuals Dually Eligible for Medicare and Medicaid" is selected in the "Definition of Denominator" question but you are missing performance measure data for ${errorReplacementText}`, - errorType: "Warning", - }); - } - return errorArray; -}; diff --git a/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx b/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx index eb4ebce901..9aa6f393b6 100644 --- a/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx @@ -5,7 +5,7 @@ import * as validateAtLeastOneDeliverySystem from "shared/globalValidations/vali import * as validateAtLeastOneDeviationFieldFilled from "measures/2024/shared/globalValidations/validateAtLeastOneDeviationFieldFilled"; import * as validateAtLeastOneRateComplete from "shared/globalValidations/validateAtLeastOneRateComplete"; import * as validateBothDatesInRange from "shared/globalValidations/validateBothDatesInRange"; -import * as validateDualPopInformation from "measures/2024/shared/globalValidations/validateDualPopInformation"; +import * as validateDualPopInformation from "shared/globalValidations/validateDualPopInformation"; import * as validateEqualCategoryDenominators from "measures/2024/shared/globalValidations/validateEqualCategoryDenominators"; import * as validateEqualQualifierDenominators from "shared/globalValidations/validateEqualQualifierDenominators"; import * as validateFfsRadioButtonCompletion from "measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion"; diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/validateDualPopInformation/index.test.ts b/services/ui-src/src/shared/globalValidations/validateDualPopInformation/index.test.ts similarity index 100% rename from services/ui-src/src/measures/2024/shared/globalValidations/validateDualPopInformation/index.test.ts rename to services/ui-src/src/shared/globalValidations/validateDualPopInformation/index.test.ts diff --git a/services/ui-src/src/shared/globalValidations/validateDualPopInformation/index.ts b/services/ui-src/src/shared/globalValidations/validateDualPopInformation/index.ts new file mode 100644 index 0000000000..30e2d0c56f --- /dev/null +++ b/services/ui-src/src/shared/globalValidations/validateDualPopInformation/index.ts @@ -0,0 +1,70 @@ +import * as DC from "dataConstants"; +import { FormRateField } from "shared/types/TypeValidations"; +import { getMeasureYear } from "utils/getMeasureYear"; + +export const getLabels = (year: number, errorReplacementText: string) => { + switch (year) { + case 2021: + case 2022: + case 2023: + return { + checkmarkWarning: `Information has been included in the ${errorReplacementText} Performance Measure but the checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is missing`, + missingDataWarning: `The checkmark for (Denominator Includes Medicare and Medicaid Dually-Eligible population) is checked but you are missing performance measure data for ${errorReplacementText}`, + }; + default: + return { + missingDataWarning: `"Individuals Dually Eligible for Medicare and Medicaid" is selected in the "Definition of Denominator" question but you are missing performance measure data for ${errorReplacementText}`, + }; + } +}; + +export const validateDualPopInformationPM = ( + performanceMeasureArray: FormRateField[][], + OPM: any, + age65PlusIndex: number, + DefinitionOfDenominator: string[] | undefined, + errorReplacementText: string = "Age 65 and Older" +) => { + if (OPM) { + return []; + } + + const year = getMeasureYear(); + const labels = getLabels(year, errorReplacementText); + + const dualEligible = DefinitionOfDenominator + ? DefinitionOfDenominator.indexOf( + DC.DENOMINATOR_INC_MEDICAID_DUAL_ELIGIBLE + ) !== -1 + : false; + + const errorArray: FormError[] = []; + const filledInData: FormRateField[] = []; + performanceMeasureArray?.forEach((performanceMeasure) => { + if ( + performanceMeasure && + performanceMeasure[age65PlusIndex] && + performanceMeasure[age65PlusIndex].denominator && + performanceMeasure[age65PlusIndex].numerator && + performanceMeasure[age65PlusIndex].rate + ) { + filledInData.push(performanceMeasure[age65PlusIndex]); + } + }); + + if (!dualEligible && filledInData.length > 0 && labels.checkmarkWarning) { + errorArray.push({ + errorLocation: "Performance Measure", + errorMessage: labels.checkmarkWarning, + errorType: "Warning", + }); + } + if (dualEligible && filledInData.length === 0 && labels.missingDataWarning) { + errorArray.push({ + errorLocation: "Performance Measure", + errorMessage: labels.missingDataWarning, + errorType: "Warning", + }); + } + return errorArray; +};