From 75cdb78481e29cd66196b7d87f43b6e1a512d843 Mon Sep 17 00:00:00 2001 From: John Manack Date: Wed, 25 Oct 2023 15:26:33 -0400 Subject: [PATCH 1/3] feat: QPPA-7298 adds validation to measures ingestion script --- .../2024/update-measures-util.spec.ts | 28 +++++++++++++++++++ scripts/measures/2024/update-measures-util.ts | 5 ++++ 2 files changed, 33 insertions(+) diff --git a/scripts/measures/2024/update-measures-util.spec.ts b/scripts/measures/2024/update-measures-util.spec.ts index b1c3623d..74189acb 100644 --- a/scripts/measures/2024/update-measures-util.spec.ts +++ b/scripts/measures/2024/update-measures-util.spec.ts @@ -91,6 +91,15 @@ const allowedQualityChange = { overallAlgorithm: 'overallStratumOnly', }; +const allowedCostScoreQualityChange = { + measureId: '002', + firstPerformanceYear: 2020, + isInverse: false, + metricType: 'costScore', + overallAlgorithm: 'overallStratumOnly', + submissionMethods: ['administrativeClaims'], +}; + const allowedQcdrChange = { measureId: 'AQI49', title: 'testTitle', @@ -316,6 +325,25 @@ describe('#update-measures-util', () => { expect(infoSpy).toBeCalledWith(`File 'test.csv' successfully ingested into measures-data 2023`); }); + it('logs warnings when certain fields are changed', () => { + + jest.spyOn(csvConverter, 'convertCsvToJson').mockReturnValue([{ + ...allowedCostScoreQualityChange, + category: 'quality', + }]); + + const warningSpy = jest.spyOn(logger, 'warning').mockImplementation(jest.fn()); + UpdateMeasuresUtil.updateMeasuresWithChangeFile( + 'test.csv', + 'fakepath/', + '2023', + volatileMeasures, + ); + expect(addSpy).not.toBeCalled(); + expect(deleteSpy).not.toBeCalled(); + expect(warningSpy).toBeCalledWith(`'002': this measure's only submissionMethod is 'administrativeClaims', the metricType is not 'costScore', and isInverse is false. Was this deliberate?`); + }); + it('throws if eCQM but has no eMeasureId', () => { jest.spyOn(csvConverter, 'convertCsvToJson').mockReturnValue([{ diff --git a/scripts/measures/2024/update-measures-util.ts b/scripts/measures/2024/update-measures-util.ts index 81ba14fa..d0fe714b 100644 --- a/scripts/measures/2024/update-measures-util.ts +++ b/scripts/measures/2024/update-measures-util.ts @@ -21,6 +21,7 @@ import { COST_MEASURES_ORDER, IA_DEFAULT_VALUES, IA_MEASURES_ORDER, + METRIC_TYPES, PI_DEFAULT_VALUES, PI_MEASURES_ORDER, QCDR_MEASURES_ORDER, @@ -96,6 +97,9 @@ export function updateMeasuresWithChangeFile( if (!isOutcomeHighPriority(change, measuresJson)) { throw new DataValidationError(measureId, `'outcome' and 'intermediateOutcome' measures must always be High Priority.`); } + if (isOnlyAdminClaims(change) && (change.metricType !== 'costScore' || !change.isInverse)) warning( + `'${measureId}': this measure's only submissionMethod is 'administrativeClaims', the metricType is not 'costScore', and isInverse is false. Was this deliberate?` + ); if (isNew && change.metricType?.includes('ultiPerformanceRate')) { warning(`'${measureId}': 'New MultiPerformanceRate measures require an update to the strata file.\n Update strata file with new measure strata before merging into the repo.`); change.strata = PLACEHOLDER_STRATA; @@ -325,6 +329,7 @@ function isOutcomeHighPriority(change: MeasuresChange, measuresJson: any): boole return true; } + function isMultiPerfRateChanged(change: MeasuresChange, measuresJson: any): boolean { const currentMeasure = _.find(measuresJson, { 'measureId': change.measureId }); From 6e23d642e570c58102bf762ec7146afe71f19e77 Mon Sep 17 00:00:00 2001 From: John Manack Date: Wed, 25 Oct 2023 16:19:19 -0400 Subject: [PATCH 2/3] feat: QPPA-7298 updates warning message --- scripts/measures/2024/update-measures-util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/measures/2024/update-measures-util.ts b/scripts/measures/2024/update-measures-util.ts index d0fe714b..bf564956 100644 --- a/scripts/measures/2024/update-measures-util.ts +++ b/scripts/measures/2024/update-measures-util.ts @@ -98,7 +98,7 @@ export function updateMeasuresWithChangeFile( throw new DataValidationError(measureId, `'outcome' and 'intermediateOutcome' measures must always be High Priority.`); } if (isOnlyAdminClaims(change) && (change.metricType !== 'costScore' || !change.isInverse)) warning( - `'${measureId}': this measure's only submissionMethod is 'administrativeClaims', the metricType is not 'costScore', and isInverse is false. Was this deliberate?` + `'${measureId}': this measure's only submissionMethod is 'administrativeClaims'; however either the metricType is not 'costScore' and/or isInverse is 'false'. Was this deliberate?` ); if (isNew && change.metricType?.includes('ultiPerformanceRate')) { warning(`'${measureId}': 'New MultiPerformanceRate measures require an update to the strata file.\n Update strata file with new measure strata before merging into the repo.`); From a58c3aae9ed091ff487e12aaa16ed3782372c1f5 Mon Sep 17 00:00:00 2001 From: John Manack Date: Wed, 25 Oct 2023 16:23:05 -0400 Subject: [PATCH 3/3] test: QPPA-7298 updates test suite --- scripts/measures/2024/update-measures-util.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/measures/2024/update-measures-util.spec.ts b/scripts/measures/2024/update-measures-util.spec.ts index 74189acb..4a90f0f2 100644 --- a/scripts/measures/2024/update-measures-util.spec.ts +++ b/scripts/measures/2024/update-measures-util.spec.ts @@ -341,7 +341,7 @@ describe('#update-measures-util', () => { ); expect(addSpy).not.toBeCalled(); expect(deleteSpy).not.toBeCalled(); - expect(warningSpy).toBeCalledWith(`'002': this measure's only submissionMethod is 'administrativeClaims', the metricType is not 'costScore', and isInverse is false. Was this deliberate?`); + expect(warningSpy).toBeCalledWith(`'002': this measure's only submissionMethod is 'administrativeClaims'; however either the metricType is not 'costScore' and/or isInverse is 'false'. Was this deliberate?`); }); it('throws if eCQM but has no eMeasureId', () => {