Skip to content

Commit

Permalink
Merge pull request #719 from CMSgov/QPPA-7298-ingestion-script-updates
Browse files Browse the repository at this point in the history
QPPA-7298: adds validation to measures ingestion script
  • Loading branch information
nicholas-gates authored Oct 26, 2023
2 parents 716adc2 + a58c3aa commit 1065768
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/measures/2024/update-measures-util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'; however either the metricType is not 'costScore' and/or isInverse is 'false'. Was this deliberate?`);
});

it('throws if eCQM but has no eMeasureId', () => {

jest.spyOn(csvConverter, 'convertCsvToJson').mockReturnValue([{
Expand Down
5 changes: 5 additions & 0 deletions scripts/measures/2024/update-measures-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'; 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.`);
change.strata = PLACEHOLDER_STRATA;
Expand Down Expand Up @@ -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 });

Expand Down

0 comments on commit 1065768

Please sign in to comment.