From bc4b21d1cac3e72d1042183e83e9cf31394239ce Mon Sep 17 00:00:00 2001 From: ailZhou Date: Fri, 13 Sep 2024 10:22:33 -0400 Subject: [PATCH] tried again but with thought --- .../src/measures/2021/AIFHH/validation.ts | 11 +-- .../src/measures/2021/IUHH/validation.ts | 12 ++-- .../src/measures/2022/AIFHH/validation.ts | 11 +-- .../src/measures/2022/IUHH/validation.ts | 12 ++-- .../src/measures/2023/AIFHH/validation.ts | 11 +-- .../src/measures/2023/IUHH/validation.ts | 12 ++-- .../src/measures/2024/AIFHH/validation.ts | 11 +-- .../src/measures/2024/IUHH/validation.ts | 12 ++-- .../ComplexNoNonZeroNumOrDenom/index.tsx | 68 ++++++------------- 9 files changed, 81 insertions(+), 79 deletions(-) diff --git a/services/ui-src/src/measures/2021/AIFHH/validation.ts b/services/ui-src/src/measures/2021/AIFHH/validation.ts index 8cd995e24..cca0ad39b 100644 --- a/services/ui-src/src/measures/2021/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2021/AIFHH/validation.ts @@ -99,14 +99,16 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, - [], + false, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["aifhh-rate"]?.rates ?? {}, @@ -118,9 +120,10 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2021/IUHH/validation.ts b/services/ui-src/src/measures/2021/IUHH/validation.ts index 5f0bc4313..ea1cac83b 100644 --- a/services/ui-src/src/measures/2021/IUHH/validation.ts +++ b/services/ui-src/src/measures/2021/IUHH/validation.ts @@ -99,14 +99,17 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + categories, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, - [], + false, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + categories ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -124,9 +127,10 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2022/AIFHH/validation.ts b/services/ui-src/src/measures/2022/AIFHH/validation.ts index cd58d752f..71395192c 100644 --- a/services/ui-src/src/measures/2022/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2022/AIFHH/validation.ts @@ -99,14 +99,16 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, - [], + false, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["aifhh-rate"]?.rates ?? {}, @@ -118,9 +120,10 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2022/IUHH/validation.ts b/services/ui-src/src/measures/2022/IUHH/validation.ts index 3d85b3334..38f408df7 100644 --- a/services/ui-src/src/measures/2022/IUHH/validation.ts +++ b/services/ui-src/src/measures/2022/IUHH/validation.ts @@ -99,14 +99,17 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + categories, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, - [], + false, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + categories ), ...GV.ComplexValidateNDRTotalsOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -124,9 +127,10 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2023/AIFHH/validation.ts b/services/ui-src/src/measures/2023/AIFHH/validation.ts index 17ae7a2a3..aeea56896 100644 --- a/services/ui-src/src/measures/2023/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2023/AIFHH/validation.ts @@ -99,22 +99,25 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, - [], + false, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ] : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2023/IUHH/validation.ts b/services/ui-src/src/measures/2023/IUHH/validation.ts index 1fd29d2fe..109308ef0 100644 --- a/services/ui-src/src/measures/2023/IUHH/validation.ts +++ b/services/ui-src/src/measures/2023/IUHH/validation.ts @@ -99,14 +99,17 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + categories, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, - [], + false, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + categories ), ...GV.ComplexValueSameCrossCategoryOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -118,9 +121,10 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2024/AIFHH/validation.ts b/services/ui-src/src/measures/2024/AIFHH/validation.ts index 9808a3382..1fe5e99df 100644 --- a/services/ui-src/src/measures/2024/AIFHH/validation.ts +++ b/services/ui-src/src/measures/2024/AIFHH/validation.ts @@ -99,22 +99,25 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["aifhh-rate"]?.rates ?? {}, - [], + false, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ] : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrFormulas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/measures/2024/IUHH/validation.ts b/services/ui-src/src/measures/2024/IUHH/validation.ts index 115bfaf61..b668df34e 100644 --- a/services/ui-src/src/measures/2024/IUHH/validation.ts +++ b/services/ui-src/src/measures/2024/IUHH/validation.ts @@ -99,14 +99,17 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ rateData, locationDictionary, label, + categories, + qualifiers, }) => { return OPM === undefined ? [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.["iuhh-rate"]?.rates ?? {}, - [], + false, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + categories ), ...GV.ComplexValueSameCrossCategoryOMS( rateData?.["iuhh-rate"]?.rates ?? {}, @@ -118,9 +121,10 @@ const OMSValidations: GV.Types.OmsValidationCallback = ({ : [ ...GV.ComplexNoNonZeroNumOrDenomOMS( rateData?.rates, - OPM, + true, ndrForumlas, - `Optional Measure Stratification: ${locationDictionary(label)}` + `Optional Measure Stratification: ${locationDictionary(label)}`, + qualifiers ), ]; }; diff --git a/services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx b/services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx index 61b8926ab..b197513a6 100644 --- a/services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx +++ b/services/ui-src/src/shared/globalValidations/ComplexValidations/ComplexNoNonZeroNumOrDenom/index.tsx @@ -1,6 +1,4 @@ -import { cleanString, isLegacyLabel } from "utils"; -import * as DC from "dataConstants"; -import { AnyObject } from "types"; +import { LabelData } from "utils"; interface NDRforumla { numerator: number; @@ -10,55 +8,31 @@ interface NDRforumla { export const ComplexNoNonZeroNumOrDenomOMS = ( rateData: any, - OPM: AnyObject[], + isOPM: boolean, ndrFormulas: NDRforumla[], - errorLocation: string + errorLocation: string, + rateLabel: LabelData[] ) => { let errorArray: any[] = []; - //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, - }; - }); + //key for 2023+ = category id and for 2022- = qualifier id + for (const key in rateData) { + //opmKey for 2023+ = qualifer id and for 2022- = category id + for (const opmKey in rateData[key]) { + const rate = rateData[key][opmKey]; + //rateLabel is either the categories array or the qualifiers array and since we don't know which one it could be, we search with key and opmKey + const desc = rateLabel.find( + (_rateLabel) => _rateLabel.id === key || _rateLabel.id === opmKey + ); - 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[id]["OPM"] - : rateData["OPM"][id], - }, - ], - ndrFormulas, - `${errorLocation} - ${description}` - ) - ); - } - } - } 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} - ${label}` - ) - ); - } + errorArray.push( + ...ComplexNoNonZeroNumOrDenom( + isOPM ? [] : [rate], + isOPM ? [{ rate: rate }] : false, + ndrFormulas, + `${errorLocation} - ${desc?.label}` + ) + ); } }