Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QPPA-7298: adds validation to measures ingestion script #719

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading