qpp-measures-data
Advanced tools
Comparing version 1.0.0-alpha.18 to 1.0.0-alpha.19
@@ -51,2 +51,3 @@ # Contribution Guidelines | ||
To add or update benchmarks, you'll want to convert the csv file into JSON with the `scripts/benchmarks/parse-benchmarks-data.js`. `parse-benchmarks-data.js` relies on a set of columns to be present and additional empty columns can cause the parsing to fail. See that file for additional instructions on how to generate the JSON file. | ||
Also, `parse-benchmarks-data.js` cross references for measureIds in `measures/measures-data.json` for the correct usage. If none are matched, either a padded `000` digit will be used for `measureId`s with all digits or a non-spaced version of the `measureId` will be used. | ||
@@ -53,0 +54,0 @@ After you have the parsed JSON file, move the CSV and JSON into `staging/benchmarks/csv` and `staging/benchmarks/json`. We do this for auditing and regeneration purposes. You'll notice a number prepended to both files. We number each file to enforce ordering of merges. Currently, if two benchmarks have the same Measure ID, Benchmark Year, Performance Year, and Submission method, the one that exists in the larger numbered file will overwrite the smaller one. |
{ | ||
"name": "qpp-measures-data", | ||
"version": "1.0.0-alpha.18", | ||
"version": "1.0.0-alpha.19", | ||
"description": "Quality Payment Program Measures Data Repository", | ||
@@ -5,0 +5,0 @@ "repository": { |
// Utility functions for formatting the csv records | ||
// Libraries | ||
const keyBy = require('lodash/keyBy'); | ||
// Data | ||
const measures = require('../../measures/measures-data.json'); | ||
const isInverseBenchmarkRecord = require('../../util/benchmarks/is-inverse-benchmark-record'); | ||
// Constants | ||
@@ -21,2 +24,3 @@ /** | ||
}; | ||
/** | ||
@@ -33,2 +37,3 @@ * @type {{}} - mapping of integer qualityIds to corresponding measure | ||
}); | ||
// Helper Functions | ||
@@ -43,4 +48,5 @@ /** | ||
}; | ||
const isInverseBenchmarkRecord = require('../../util/benchmarks/is-inverse-benchmark-record'); | ||
const floatRegex = /([0-9]*[.]?[0-9]+)/g; | ||
/** | ||
@@ -133,2 +139,26 @@ * Generator function to create a | ||
// Looks in measures-data.json for an existing measureIds and | ||
// walks through for versions with combinations of spaces as underscores | ||
// and vice versa. | ||
// If found, returns the measureId from the measures-data.json file. | ||
// If none are found, return the padded number or non-spaced version | ||
const formatMeasureId = (measureId) => { | ||
const measureIdFuzzyMatch = measureId.replace(/(\s|_)/g, '(\\s|_)?'); | ||
const measureIdFuzzyMatchRegEx = new RegExp('^' + measureIdFuzzyMatch + '$'); | ||
for (const knownMeasureID of Object.keys(MEASURE_ID_TO_MEASURE_MAP)) { | ||
if (knownMeasureID.match(measureIdFuzzyMatchRegEx)) { | ||
return MEASURE_ID_TO_MEASURE_MAP[knownMeasureID].measureId; | ||
} | ||
} | ||
// If all digits, pad with zeros up to the hundredth place | ||
// else, return a nonspaced version | ||
if (measureId.match(/^\d+$/)) { | ||
return ('000' + measureId).slice(-3); | ||
} else { | ||
return measureId.replace(/\s/g, ''); | ||
} | ||
}; | ||
/** | ||
@@ -173,9 +203,6 @@ * | ||
*/ | ||
const measure = MEASURE_ID_TO_MEASURE_MAP[record.qualityId]; | ||
if (!measure) return; | ||
if (record.benchmark.trim() === 'N') return; | ||
if (record.benchmark.trim() !== 'Y') return; | ||
return { | ||
measureId: measure.measureId, | ||
measureId: formatMeasureId(record.qualityId), | ||
benchmarkYear: parseInt(options.benchmarkYear), | ||
@@ -201,2 +228,5 @@ performanceYear: parseInt(options.performanceYear), | ||
module.exports = formatBenchmarkRecord; | ||
module.exports = { | ||
formatBenchmarkRecord, | ||
formatMeasureId | ||
}; |
@@ -24,3 +24,3 @@ // Libraries | ||
// Utils | ||
const formatBenchmarkRecord = require('./format-benchmark-record'); | ||
const { formatBenchmarkRecord } = require('./format-benchmark-record'); | ||
// Data | ||
@@ -32,4 +32,4 @@ let benchmarksData = ''; | ||
* Script to generate benchmark.json file from csv | ||
* To run: `cat [DATA_CSV_FILE] | node scripts/parse-benchmarks-data.js [BENCHMARK_YEAR] [PERFORMANCE_YEAR]` | ||
* e.g. `cat data/historical-benchmarks/2015.csv | node scripts/parse-benchmarks-data.js 2015 2017` | ||
* To run: `cat [DATA_CSV_FILE] | node scripts/benchmarks/parse-benchmarks-data.js [BENCHMARK_YEAR] [PERFORMANCE_YEAR]` | ||
* e.g. `cat data/historical-benchmarks/2015.csv | node scripts/benchmarks/parse-benchmarks-data.js 2015 2017` | ||
*/ | ||
@@ -36,0 +36,0 @@ const benchmarks = []; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8050729
83669