forked from CMSgov/qpp-measures-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (60 loc) · 2.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Libraries
const fs = require('fs');
const path = require('path');
const YAML = require('yamljs');
const yearRegEx = /^[0-9]{4}/;
const benchmarkJsonFileRegEx = /^[0-9]{4}\.json$/;
const Constants = require('./constants.js');
/**
*
* @return {{}} - benchmarks data -
* An object keyed by performance year with array values
* containing the benchmarks for that performance year
*/
exports.getBenchmarksData = function() {
const benchmarksByYear = {};
fs.readdirSync(path.join(__dirname, 'benchmarks')).forEach(function(file) {
if (benchmarkJsonFileRegEx.test(file)) {
benchmarksByYear[file.match(yearRegEx)[0]] = require(path.join(__dirname, 'benchmarks', file));
}
});
return benchmarksByYear;
};
/**
* @return {{}} - Object representation of the Benchmarks Schema
*/
exports.getBenchmarksSchema = function(performanceYear = Constants.currentPerformanceYear) {
return YAML.load(path.join(__dirname, 'benchmarks', performanceYear.toString(), 'benchmarks-schema.yaml'));
};
/**
* @return {Array<Measure>}
*/
exports.getMeasuresData = function(performanceYear = 2017) {
return JSON.parse(
fs.readFileSync(path.join(__dirname, 'measures', performanceYear.toString(), 'measures-data.json')));
};
/**
* @return {{}} - Object representation of the Measures Schema
*/
exports.getMeasuresSchema = function(performanceYear = 2017) {
return YAML.load(path.join(__dirname, 'measures', performanceYear.toString(), 'measures-schema.yaml'));
};
/**
* @return {Array<ClinicalCluster>}
*/
exports.getClinicalClusterData = function(performanceYear = 2017) {
let clusterData = [];
try {
clusterData = JSON.parse(
fs.readFileSync(path.join(__dirname, 'clinical-clusters', performanceYear.toString(), 'clinical-clusters.json')));
} catch (e) {
console.log('QPP measures data not found for year: ' + performanceYear + ' --> ' + e);
}
return clusterData;
};
/**
* @return {{}} - Object representation of the Clinical Cluster Schema
*/
exports.getClinicalClusterSchema = function(performanceYear = 2017) {
return YAML.load(path.join(__dirname, 'clinical-clusters', performanceYear.toString(), 'clinical-clusters-schema.yaml'));
};