Skip to content

Commit

Permalink
Merge pull request #709 from CMSgov/feat/QPPA-8035
Browse files Browse the repository at this point in the history
QPPA-8035, QPPA-7417 add AveragePerformanceRate field and remove deciles for PY 2023 onward
  • Loading branch information
ckawell-sb authored Sep 11, 2023
2 parents 9e05389 + c603053 commit 1df5c4b
Show file tree
Hide file tree
Showing 11 changed files with 4,611 additions and 10,510 deletions.
4,095 changes: 546 additions & 3,549 deletions benchmarks/2023.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions benchmarks/2023/benchmarks-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ definitions:
submissionMethod:
description: The method for submitting the measure performance data to which this benchmark applies.
enum: [claims, registry, cmsWebInterface, administrativeClaims, electronicHealthRecord, certifiedSurveyVendor]
averagePerformanceRate:
description: The Average Performance Rate for the Measure and CollectionType.
type: [number, 'null']
required: [measureId, performanceYear, benchmarkYear, submissionMethod, percentiles]
84 changes: 42 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/benchmarks/benchmarks.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export type Benchmark = {
metricType?: string,
isToppedOutByProgram?: boolean,
percentiles?: object,
averagePerformanceRate?: number | null
}

export type BenchmarkList = {
Expand Down
3 changes: 1 addition & 2 deletions scripts/benchmarks/build-benchmarks
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ if (( $currentPerformanceYear >= 2023 )) && (( $currentPerformanceYear <= $maxPe
if [[ $FILE =~ $re ]]; then
echo -e "Converting $FILE.csv to JSON..."
node dist/scripts/benchmarks/csv-json-converter.js \
staging/$currentPerformanceYear/benchmarks/${BASH_REMATCH[2]}.csv $currentPerformanceYear \
> staging/$currentPerformanceYear/benchmarks/json/${BASH_REMATCH[2]}.json
staging/$currentPerformanceYear/benchmarks/${BASH_REMATCH[2]}.csv $currentPerformanceYear ${BASH_REMATCH[2]}

# validate the JSON files before combining
node dist/scripts/benchmarks/validation.business.js \
Expand Down
19 changes: 13 additions & 6 deletions scripts/benchmarks/csv-json-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import { Benchmark } from './benchmarks.types';

// command to use this file:
// node ./dist/benchmarks/csv-json-converter.js ./util/2023/benchmarks/[fileName].csv [year] > ./util/2023/benchmarks/json/[fileName].json
function convertCsvToJson(csvPath: string, performanceYear: number) {
function convertCsvToJson(csvPath: string, performanceYear: number, jsonFileName: string) {
const csv = fetchCSV(csvPath);
const parsedCsv = prepareCsv(csv);
const jsonPath = `staging/${performanceYear}/benchmarks/json/${jsonFileName}.json`;

const mappedCsv = parsedCsv.map((row) => {
const measure: Benchmark = {
Expand Down Expand Up @@ -60,24 +61,30 @@ function convertCsvToJson(csvPath: string, performanceYear: number) {
}
}

//populate with False if it wasn't found in the csv.
//populate some default values if they are not found in the csv.
measure.isToppedOutByProgram = measure.isToppedOutByProgram || false;
measure.averagePerformanceRate = measure.averagePerformanceRate || null;

return orderFields(measure);
});

// output to [filename].json
process.stdout.write(JSON.stringify(mappedCsv, null, 2));
// write to [filename].json
writeToFile(mappedCsv, jsonPath);
}

function fetchCSV(filePath: string) {
return fs.readFileSync(path.join(appRoot + '', `${filePath}`), 'utf8');
}

export function writeToFile(file: any, filePath: string) {
fs.writeFileSync(path.join(appRoot + '', filePath), JSON.stringify(file, null, 2));
}

function orderFields(benchmark: Benchmark) {
//reorder the fields to stay consistent.
const orderedValues = Object.assign({}, BENCHMARKS_ORDER, benchmark)
//remove undefined fields.
return _.omitBy(orderedValues, _.isNil);
return _.omitBy(orderedValues, _.isUndefined);
}

function mapInput(columnName: string, csvRow: any) {
Expand Down Expand Up @@ -130,4 +137,4 @@ function prepareCsv(csv: any) {
return parsedCsv;
}

convertCsvToJson(process.argv[2], parseInt(process.argv[3]));
convertCsvToJson(process.argv[2], parseInt(process.argv[3]), process.argv[4]);
4 changes: 2 additions & 2 deletions scripts/benchmarks/validation.business.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ describe('validation.business', () => {
it('throws an error if a benchmark has mismatched data with isHighPriority', () => {
testErrorsThrown(
'Property mismatch for isHighPrority between Benchmark of id 127 and its Measure\'s data. Measure expected false received true.',
{42: { isHighPriority: true }},
{2: { isHighPriority: true }},
)
})

it('throws an error if a benchmark has mismatched data with isInverse', () => {
testErrorsThrown(
'Property mismatch for isInverse between Benchmark of id 127 its Measure\'s data. Measure expected false received true.',
{42: {isInverse: true}});
{2: {isInverse: true}});
})

it('throws an error if a benchmark has no measure data for the requested PY', () => {
Expand Down
1 change: 1 addition & 0 deletions scripts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const BENCHMARKS_COLUMN_NAMES = {
'submissionMethod': 'submissionMethod',
'isInverse': 'isInverse',
'metricType': 'metricType',
'averagePerformanceRate': 'averagePerformanceRate',
};

export const SUBMISSION_METHOD_MAP = {
Expand Down
Loading

0 comments on commit 1df5c4b

Please sign in to comment.