From 09647c75a18d04d07f08a9837a0c2961f317268a Mon Sep 17 00:00:00 2001 From: ailZhou Date: Thu, 12 Sep 2024 15:22:34 -0400 Subject: [PATCH] ComplexNoNonZeroNumOrDenom --- .../src/measures/2021/AIFHH/validation.ts | 13 +- .../src/measures/2021/IUHH/validation.ts | 13 +- .../measures/2021/globalValidations/index.ts | 2 +- .../src/measures/2022/AIFHH/validation.ts | 13 +- .../src/measures/2022/IUHH/validation.ts | 13 +- .../ComplexNoNonZeroNumOrDenom/index.tsx | 121 ------------------ .../2022/shared/globalValidations/index.ts | 2 +- .../2022/shared/util/validationsMock.tsx | 2 +- .../src/measures/2023/AIFHH/validation.ts | 8 +- .../src/measures/2023/IUHH/validation.ts | 8 +- .../ComplexNoNonZeroNumOrDenom/index.tsx | 120 ----------------- .../2023/shared/globalValidations/index.ts | 2 +- .../2023/shared/util/validationsMock.tsx | 2 +- .../src/measures/2024/AIFHH/validation.ts | 10 +- .../src/measures/2024/IUHH/validation.ts | 8 +- .../ComplexNoNonZeroNumOrDenom/index.tsx | 120 ----------------- .../2024/shared/globalValidations/index.ts | 2 +- .../2024/shared/util/validationsMock.tsx | 2 +- .../ComplexNoNonZeroNumOrDenom/index.tsx | 39 ++++-- 19 files changed, 64 insertions(+), 436 deletions(-) delete mode 100644 services/ui-src/src/measures/2022/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx delete mode 100644 services/ui-src/src/measures/2023/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx delete mode 100644 services/ui-src/src/measures/2024/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx rename services/ui-src/src/{measures/2021 => shared}/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx (79%) diff --git a/services/ui-src/src/measures/2021/AIFHH/validation.ts b/services/ui-src/src/measures/2021/AIFHH/validation.ts index 38b91c57ad..8cd995e247 100644 --- a/services/ui-src/src/measures/2021/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2021/AIFHH/validation.ts @@ -100,17 +100,13 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ locationDictionary, label, }) => { - const rates = Object.keys(rateData?.rates ?? {}).map((x) => { - return { rate: [rateData?.rates?.[x]?.OPM?.[0]] }; - }); return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, - rates ?? [], + [], ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["aifhh-rate"]?.rates ?? {}, @@ -122,10 +118,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - rates ?? [], + OPM, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2021/IUHH/validation.ts b/services/ui-src/src/measures/2021/IUHH/validation.ts index c06ce79396..5f0bc43131 100644 --- a/services/ui-src/src/measures/2021/IUHH/validation.ts +++ b/services/ui-src/src/measures/2021/IUHH/validation.ts @@ -100,17 +100,13 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ locationDictionary, label, }) => { - const rates = Object.keys(rateData?.rates ?? {}).map((x) => { - return { rate: [rateData?.rates?.[x]?.OPM?.[0]] }; - }); return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, - rates ?? [], + [], ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -128,10 +124,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - rates ?? [], + OPM, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2021/globalValidations/index.ts b/services/ui-src/src/measures/2021/globalValidations/index.ts index da16c2bb40..f0b9fb0280 100644 --- a/services/ui-src/src/measures/2021/globalValidations/index.ts +++ b/services/ui-src/src/measures/2021/globalValidations/index.ts @@ -30,7 +30,7 @@ export { ComplexAtLeastOneRateComplete } from "shared/globalValidations/ComplexV export { ComplexNoNonZeroNumOrDenom, ComplexNoNonZeroNumOrDenomOMS, -} from "./ComplexValidations/ComplexNoNonZeroNumOrDenom"; +} from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; export { ComplexValidateAtLeastOneNDRInDeviationOfMeasureSpec } from "./ComplexValidations/ComplexValidateAtLeastOneNDRInDeviationOfMeasureSpec"; export { ComplexValidateNDRTotals, diff --git a/services/ui-src/src/measures/2022/AIFHH/validation.ts b/services/ui-src/src/measures/2022/AIFHH/validation.ts index 22845adb10..cd58d752f2 100644 --- a/services/ui-src/src/measures/2022/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2022/AIFHH/validation.ts @@ -100,17 +100,13 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ locationDictionary, label, }) => { - const rates = Object.keys(rateData?.rates ?? {}).map((x) => { - return { rate: [rateData?.rates?.[x]?.OPM?.[0]] }; - }); return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, - rates ?? [], + [], ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["aifhh-rate"]?.rates ?? {}, @@ -122,10 +118,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - rates ?? [], + OPM, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2022/IUHH/validation.ts b/services/ui-src/src/measures/2022/IUHH/validation.ts index 59fb95b490..3d85b3334b 100644 --- a/services/ui-src/src/measures/2022/IUHH/validation.ts +++ b/services/ui-src/src/measures/2022/IUHH/validation.ts @@ -100,17 +100,13 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ locationDictionary, label, }) => { - const rates = Object.keys(rateData?.rates ?? {}).map((x) => { - return { rate: [rateData?.rates?.[x]?.OPM?.[0]] }; - }); return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, - rates ?? [], + [], ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -128,10 +124,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - rates ?? [], + OPM, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2022/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx b/services/ui-src/src/measures/2022/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx deleted file mode 100644 index db50aa38c1..0000000000 --- a/services/ui-src/src/measures/2022/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import { cleanString, isLegacyLabel } from "utils"; -import * as DC from "dataConstants"; - -interface NDRforumla { - numerator: number; - denominator: number; - rateIndex: number; -} - -export const ComplexNoNonZeroNumOrDenomOMS = ( - rateData: any, - OPM: any, - ndrFormulas: NDRforumla[], - errorLocation: string, - descriptions: string[] -) => { - let errorArray: any[] = []; - for (const key in rateData) { - if (OPM && OPM.length > 0) { - descriptions.forEach((description) => { - const opmKey = isLegacyLabel() - ? cleanString(description) - : `${DC.OPM_KEY}${cleanString(description)}`; - - errorArray.push( - ...ComplexNoNonZeroNumOrDenom( - [], - [ - { - rate: isLegacyLabel() - ? rateData[opmKey]["OPM"] - : rateData[key][opmKey], - }, - ], - ndrFormulas, - `${errorLocation} - ${description}` - ) - ); - }); - } else { - for (const category in rateData[key]) { - errorArray.push( - ...ComplexNoNonZeroNumOrDenom( - [rateData[key][category]], - false, - ndrFormulas, - `${errorLocation} - ${key} - ${category}` - ) - ); - } - } - } - - return errorArray; -}; - -/* Validation for manually entered rates */ -export const ComplexNoNonZeroNumOrDenom = ( - performanceMeasureArray: any, - OPM: any, - ndrFormulas: NDRforumla[], - errorLocation: string = "Performance Measure/Other Performance Measure" -) => { - let nonZeroRateError = false; - let zeroRateError = false; - let errorArray: any[] = []; - - if (!OPM) { - for (const category of performanceMeasureArray) { - if (category && category.length > 0) { - for (const qualifier of category) { - for (const formula of ndrFormulas) { - const numerator = qualifier.fields[formula.numerator]?.value; - const denominator = qualifier.fields[formula.denominator]?.value; - const rate = qualifier.fields[formula.rateIndex]?.value; - - if (numerator && denominator && rate) { - if (parseFloat(numerator) === 0 && parseFloat(rate) !== 0) - nonZeroRateError = true; - if ( - parseFloat(rate) === 0 && - parseFloat(numerator) !== 0 && - parseFloat(denominator) !== 0 - ) - zeroRateError = true; - } - } - } - } - } - } - OPM && - OPM.forEach((performanceMeasure: any) => { - performanceMeasure.rate?.forEach((rate: any) => { - if (parseFloat(rate.numerator) === 0 && parseFloat(rate.rate) !== 0) { - nonZeroRateError = true; - } - - if ( - parseFloat(rate.numerator) !== 0 && - parseFloat(rate.denominator) !== 0 && - parseFloat(rate.rate) === 0 - ) { - zeroRateError = true; - } - }); - }); - if (nonZeroRateError) { - errorArray.push({ - errorLocation: errorLocation, - errorMessage: `Manually entered rate should be 0 if numerator is 0`, - }); - } - if (zeroRateError) { - errorArray.push({ - errorLocation: errorLocation, - errorMessage: `Rate should not be 0 if numerator and denominator are not 0. If the calculated rate is less than 0.5, disregard this validation.`, - }); - } - return zeroRateError || nonZeroRateError ? 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..f0b9fb0280 100644 --- a/services/ui-src/src/measures/2022/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2022/shared/globalValidations/index.ts @@ -30,7 +30,7 @@ export { ComplexAtLeastOneRateComplete } from "shared/globalValidations/ComplexV export { ComplexNoNonZeroNumOrDenom, ComplexNoNonZeroNumOrDenomOMS, -} from "./ComplexValidations/ComplexNoNonZeroNumOrDenom"; +} from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; export { ComplexValidateAtLeastOneNDRInDeviationOfMeasureSpec } from "./ComplexValidations/ComplexValidateAtLeastOneNDRInDeviationOfMeasureSpec"; export { ComplexValidateNDRTotals, 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..9b19653f80 100644 --- a/services/ui-src/src/measures/2022/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2022/shared/util/validationsMock.tsx @@ -18,7 +18,7 @@ import * as PCRatLeastOneRateComplete from "shared/globalValidations/PCRValidati import * as PCRnoNonZeroNumOrDenom from "shared/globalValidations/PCRValidations/PCRnoNonZeroNumOrDenom"; import * as PCRvalidateAtLeastOneNDRInDeviationOfMeasureSpec from "shared/globalValidations/PCRValidations/PCRvalidateAtLeastOneNDRInDeviationOfMeasureSpec"; //pragma: allowlist secret import * as ComplexAtLeastOneRateComplete from "shared/globalValidations/ComplexValidations/ComplexAtLeastOneRateComplete"; -import * as ComplexNoNonZeroNumOrDenom from "measures/2022/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; +import * as ComplexNoNonZeroNumOrDenom from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; import * as ComplexValidateAtLeastOneNDRInDeviationOfMeasureSpec from "measures/2022/shared/globalValidations/ComplexValidations/ComplexValidateAtLeastOneNDRInDeviationOfMeasureSpec"; //pragma: allowlist secret import * as ComplexValidateNDRTotals from "measures/2022/shared/globalValidations/ComplexValidations/ComplexValidateNDRTotals"; import * as ComplexValidateDualPopInformation from "measures/2022/shared/globalValidations/ComplexValidations/ComplexValidateDualPopInformation"; diff --git a/services/ui-src/src/measures/2023/AIFHH/validation.ts b/services/ui-src/src/measures/2023/AIFHH/validation.ts index d8012b9d4d..17ae7a2a36 100644 --- a/services/ui-src/src/measures/2023/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2023/AIFHH/validation.ts @@ -104,17 +104,17 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, + [], ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ] : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, + OPM, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2023/IUHH/validation.ts b/services/ui-src/src/measures/2023/IUHH/validation.ts index 490c82e8b9..1fd29d2feb 100644 --- a/services/ui-src/src/measures/2023/IUHH/validation.ts +++ b/services/ui-src/src/measures/2023/IUHH/validation.ts @@ -104,9 +104,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, + [], ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ...GV.ComplexValueSameCrossCategoryOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -118,9 +118,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, + OPM, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx b/services/ui-src/src/measures/2023/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx deleted file mode 100644 index 3e05324d8d..0000000000 --- a/services/ui-src/src/measures/2023/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx +++ /dev/null @@ -1,120 +0,0 @@ -import { cleanString, isLegacyLabel } from "utils"; -import * as DC from "dataConstants"; - -interface NDRforumla { - numerator: number; - denominator: number; - rateIndex: number; -} - -export const ComplexNoNonZeroNumOrDenomOMS = ( - rateData: any, - ndrFormulas: NDRforumla[], - errorLocation: string, - descriptions: string[] -) => { - let errorArray: any[] = []; - for (const key in rateData) { - if (key === "OPM") { - descriptions.forEach((description) => { - const opmKey = isLegacyLabel() - ? cleanString(description) - : `${DC.OPM_KEY}${cleanString(description)}`; - - errorArray.push( - ...ComplexNoNonZeroNumOrDenom( - [], - [ - { - rate: isLegacyLabel() - ? rateData[opmKey]["OPM"] - : rateData[key][opmKey], - }, - ], - ndrFormulas, - `${errorLocation} - ${description}` - ) - ); - }); - } else { - for (const category in rateData[key]) { - errorArray.push( - ...ComplexNoNonZeroNumOrDenom( - [rateData[key][category]], - false, - ndrFormulas, - `${errorLocation} - ${key} - ${category}` - ) - ); - } - } - } - - return errorArray; -}; - -/* Validation for manually entered rates */ -export const ComplexNoNonZeroNumOrDenom = ( - performanceMeasureArray: any, - OPM: any, - ndrFormulas: NDRforumla[], - errorLocation: string = "Performance Measure/Other Performance Measure" -) => { - let nonZeroRateError = false; - let zeroRateError = false; - let errorArray: any[] = []; - - if (!OPM) { - for (const category of performanceMeasureArray) { - if (category && category.length > 0) { - for (const qualifier of category) { - for (const formula of ndrFormulas) { - const numerator = qualifier.fields[formula.numerator]?.value; - const denominator = qualifier.fields[formula.denominator]?.value; - const rate = qualifier.fields[formula.rateIndex]?.value; - - if (numerator && denominator && rate) { - if (parseFloat(numerator) === 0 && parseFloat(rate) !== 0) - nonZeroRateError = true; - if ( - parseFloat(rate) === 0 && - parseFloat(numerator) !== 0 && - parseFloat(denominator) !== 0 - ) - zeroRateError = true; - } - } - } - } - } - } - OPM && - OPM.forEach((performanceMeasure: any) => { - performanceMeasure.rate?.forEach((rate: any) => { - if (parseFloat(rate.numerator) === 0 && parseFloat(rate.rate) !== 0) { - nonZeroRateError = true; - } - - if ( - parseFloat(rate.numerator) !== 0 && - parseFloat(rate.denominator) !== 0 && - parseFloat(rate.rate) === 0 - ) { - zeroRateError = true; - } - }); - }); - if (nonZeroRateError) { - errorArray.push({ - errorLocation: errorLocation, - errorMessage: `Manually entered rate should be 0 if numerator is 0`, - }); - } - if (zeroRateError) { - errorArray.push({ - errorLocation: errorLocation, - errorMessage: `Rate should not be 0 if numerator and denominator are not 0. If the calculated rate is less than 0.5, disregard this validation.`, - }); - } - return zeroRateError || nonZeroRateError ? errorArray : []; -}; 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..f178592e25 100644 --- a/services/ui-src/src/measures/2023/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2023/shared/globalValidations/index.ts @@ -37,7 +37,7 @@ export { ComplexAtLeastOneRateComplete } from "shared/globalValidations/ComplexV export { ComplexNoNonZeroNumOrDenom, ComplexNoNonZeroNumOrDenomOMS, -} from "./ComplexValidations/ComplexNoNonZeroNumOrDenom"; +} from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; export { ComplexValidateNDRTotals, ComplexValidateNDRTotalsOMS, 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..88dc1f81e9 100644 --- a/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx @@ -21,7 +21,7 @@ import * as validateTotals from "measures/2023/shared/globalValidations/validate import * as PCRatLeastOneRateComplete from "shared/globalValidations/PCRValidations/PCRatLeastOneRateComplete"; import * as PCRnoNonZeroNumOrDenom from "shared/globalValidations/PCRValidations/PCRnoNonZeroNumOrDenom"; import * as ComplexAtLeastOneRateComplete from "shared/globalValidations/ComplexValidations/ComplexAtLeastOneRateComplete"; -import * as ComplexNoNonZeroNumOrDenom from "measures/2023/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; +import * as ComplexNoNonZeroNumOrDenom from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; import * as ComplexValidateNDRTotals from "measures/2023/shared/globalValidations/ComplexValidations/ComplexValidateNDRTotals"; import * as ComplexValidateDualPopInformation from "measures/2023/shared/globalValidations/ComplexValidations/ComplexValidateDualPopInformation"; import * as ComplexValueSameCrossCategory from "measures/2023/shared/globalValidations/ComplexValidations/ComplexValueSameCrossCategory"; diff --git a/services/ui-src/src/measures/2024/AIFHH/validation.ts b/services/ui-src/src/measures/2024/AIFHH/validation.ts index 8c61b6a882..9808a33822 100644 --- a/services/ui-src/src/measures/2024/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2024/AIFHH/validation.ts @@ -42,8 +42,6 @@ const AIFHHValidation = (data: FormData) => { OPM = data[DC.OPM_RATES]; const whyNotReporting = data[DC.WHY_ARE_YOU_NOT_REPORTING]; - console.log("OPM", OPM); - if (data[DC.DID_REPORT] === DC.NO) { errorArray = [...GV.validateReasonForNotReporting(whyNotReporting)]; return errorArray; @@ -106,17 +104,17 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, + [], ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ] : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, + OPM, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2024/IUHH/validation.ts b/services/ui-src/src/measures/2024/IUHH/validation.ts index 99c298c014..115bfaf61e 100644 --- a/services/ui-src/src/measures/2024/IUHH/validation.ts +++ b/services/ui-src/src/measures/2024/IUHH/validation.ts @@ -104,9 +104,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, + [], ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ...GV.ComplexValueSameCrossCategoryOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -118,9 +118,9 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, + OPM, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}`, - OPM.map((item: any) => item.description) + `Optional Measure Stratification: ${locationDictionary(label)}` ), ]; }; diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx b/services/ui-src/src/measures/2024/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx deleted file mode 100644 index 3e05324d8d..0000000000 --- a/services/ui-src/src/measures/2024/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx +++ /dev/null @@ -1,120 +0,0 @@ -import { cleanString, isLegacyLabel } from "utils"; -import * as DC from "dataConstants"; - -interface NDRforumla { - numerator: number; - denominator: number; - rateIndex: number; -} - -export const ComplexNoNonZeroNumOrDenomOMS = ( - rateData: any, - ndrFormulas: NDRforumla[], - errorLocation: string, - descriptions: string[] -) => { - let errorArray: any[] = []; - for (const key in rateData) { - if (key === "OPM") { - descriptions.forEach((description) => { - const opmKey = isLegacyLabel() - ? cleanString(description) - : `${DC.OPM_KEY}${cleanString(description)}`; - - errorArray.push( - ...ComplexNoNonZeroNumOrDenom( - [], - [ - { - rate: isLegacyLabel() - ? rateData[opmKey]["OPM"] - : rateData[key][opmKey], - }, - ], - ndrFormulas, - `${errorLocation} - ${description}` - ) - ); - }); - } else { - for (const category in rateData[key]) { - errorArray.push( - ...ComplexNoNonZeroNumOrDenom( - [rateData[key][category]], - false, - ndrFormulas, - `${errorLocation} - ${key} - ${category}` - ) - ); - } - } - } - - return errorArray; -}; - -/* Validation for manually entered rates */ -export const ComplexNoNonZeroNumOrDenom = ( - performanceMeasureArray: any, - OPM: any, - ndrFormulas: NDRforumla[], - errorLocation: string = "Performance Measure/Other Performance Measure" -) => { - let nonZeroRateError = false; - let zeroRateError = false; - let errorArray: any[] = []; - - if (!OPM) { - for (const category of performanceMeasureArray) { - if (category && category.length > 0) { - for (const qualifier of category) { - for (const formula of ndrFormulas) { - const numerator = qualifier.fields[formula.numerator]?.value; - const denominator = qualifier.fields[formula.denominator]?.value; - const rate = qualifier.fields[formula.rateIndex]?.value; - - if (numerator && denominator && rate) { - if (parseFloat(numerator) === 0 && parseFloat(rate) !== 0) - nonZeroRateError = true; - if ( - parseFloat(rate) === 0 && - parseFloat(numerator) !== 0 && - parseFloat(denominator) !== 0 - ) - zeroRateError = true; - } - } - } - } - } - } - OPM && - OPM.forEach((performanceMeasure: any) => { - performanceMeasure.rate?.forEach((rate: any) => { - if (parseFloat(rate.numerator) === 0 && parseFloat(rate.rate) !== 0) { - nonZeroRateError = true; - } - - if ( - parseFloat(rate.numerator) !== 0 && - parseFloat(rate.denominator) !== 0 && - parseFloat(rate.rate) === 0 - ) { - zeroRateError = true; - } - }); - }); - if (nonZeroRateError) { - errorArray.push({ - errorLocation: errorLocation, - errorMessage: `Manually entered rate should be 0 if numerator is 0`, - }); - } - if (zeroRateError) { - errorArray.push({ - errorLocation: errorLocation, - errorMessage: `Rate should not be 0 if numerator and denominator are not 0. If the calculated rate is less than 0.5, disregard this validation.`, - }); - } - return zeroRateError || nonZeroRateError ? errorArray : []; -}; 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..9f5459cf29 100644 --- a/services/ui-src/src/measures/2024/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2024/shared/globalValidations/index.ts @@ -39,7 +39,7 @@ export { ComplexAtLeastOneRateComplete } from "shared/globalValidations/ComplexV export { ComplexNoNonZeroNumOrDenom, ComplexNoNonZeroNumOrDenomOMS, -} from "./ComplexValidations/ComplexNoNonZeroNumOrDenom"; +} from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; export { ComplexValidateNDRTotals, ComplexValidateNDRTotalsOMS, 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..1bcc06a7e1 100644 --- a/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx @@ -21,7 +21,7 @@ import * as validateTotals from "measures/2024/shared/globalValidations/validate import * as PCRatLeastOneRateComplete from "shared/globalValidations/PCRValidations/PCRatLeastOneRateComplete"; import * as PCRnoNonZeroNumOrDenom from "shared/globalValidations/PCRValidations/PCRnoNonZeroNumOrDenom"; import * as ComplexAtLeastOneRateComplete from "shared/globalValidations/ComplexValidations/ComplexAtLeastOneRateComplete"; -import * as ComplexNoNonZeroNumOrDenom from "measures/2024/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; +import * as ComplexNoNonZeroNumOrDenom from "shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom"; import * as ComplexValidateNDRTotals from "measures/2024/shared/globalValidations/ComplexValidations/ComplexValidateNDRTotals"; import * as ComplexValidateDualPopInformation from "measures/2024/shared/globalValidations/ComplexValidations/ComplexValidateDualPopInformation"; import * as ComplexValueSameCrossCategory from "measures/2024/shared/globalValidations/ComplexValidations/ComplexValueSameCrossCategory"; diff --git a/services/ui-src/src/measures/2021/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx b/services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx similarity index 79% rename from services/ui-src/src/measures/2021/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx rename to services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx index db50aa38c1..61b8926ab2 100644 --- a/services/ui-src/src/measures/2021/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx +++ b/services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx @@ -1,5 +1,6 @@ import { cleanString, isLegacyLabel } from "utils"; import * as DC from "dataConstants"; +import { AnyObject } from "types"; interface NDRforumla { numerator: number; @@ -9,42 +10,52 @@ interface NDRforumla { export const ComplexNoNonZeroNumOrDenomOMS = ( rateData: any, - OPM: any, + OPM: AnyObject[], ndrFormulas: NDRforumla[], - errorLocation: string, - descriptions: string[] + errorLocation: string ) => { let errorArray: any[] = []; - for (const key in rateData) { - if (OPM && OPM.length > 0) { - descriptions.forEach((description) => { - const opmKey = isLegacyLabel() - ? cleanString(description) - : `${DC.OPM_KEY}${cleanString(description)}`; + //OMS errors for OPM data + if (OPM && OPM.length > 0) { + const keyList = OPM?.map((item: any) => { + return { + id: isLegacyLabel() + ? cleanString(item.description) + : `${DC.OPM_KEY}${cleanString(item.description)}`, + desc: item.description, + }; + }); + + for (const id of keyList.map((key) => key.id)) { + if (rateData[id]) { + const description = keyList.find((key) => key.id === id)?.desc; errorArray.push( ...ComplexNoNonZeroNumOrDenom( [], [ { rate: isLegacyLabel() - ? rateData[opmKey]["OPM"] - : rateData[key][opmKey], + ? rateData[id]["OPM"] + : rateData["OPM"][id], }, ], ndrFormulas, `${errorLocation} - ${description}` ) ); - }); - } else { + } + } + } else { + for (const key in rateData) { for (const category in rateData[key]) { + const label = rateData[key][category]?.[0]?.label; errorArray.push( ...ComplexNoNonZeroNumOrDenom( [rateData[key][category]], false, ndrFormulas, - `${errorLocation} - ${key} - ${category}` + `${errorLocation} - ${label}` ) ); }