ecqm-bundler
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.generateMeasureBundle = exports.generateValueSetRelatedArtifact = exports.generateLibraryRelatedArtifact = exports.generateRelatedArtifact = exports.generateLibraryResource = exports.generateMeasureResource = exports.combineURLs = exports.PopulationCode = exports.Scoring = exports.ImprovementNotation = void 0; | ||
const uuid_1 = require("uuid"); | ||
const elm_1 = require("./elm"); | ||
@@ -36,2 +37,5 @@ const logger_1 = __importDefault(require("./logger")); | ||
logger_1.default.info(`Creating Measure/${measureId}`); | ||
const ippId = (0, uuid_1.v4)(); | ||
const denomId = (0, uuid_1.v4)(); | ||
const numerId = (0, uuid_1.v4)(); | ||
return { | ||
@@ -61,4 +65,6 @@ resourceType: 'Measure', | ||
{ | ||
id: (0, uuid_1.v4)(), | ||
population: [ | ||
{ | ||
id: ippId, | ||
code: { | ||
@@ -78,2 +84,3 @@ coding: [ | ||
{ | ||
id: denomId, | ||
code: { | ||
@@ -93,2 +100,3 @@ coding: [ | ||
{ | ||
id: numerId, | ||
code: { | ||
@@ -113,3 +121,3 @@ coding: [ | ||
exports.generateMeasureResource = generateMeasureResource; | ||
function generateLibraryResource(libraryId, elm, canonicalBase) { | ||
function generateLibraryResource(libraryId, elm, canonicalBase, cqlLookup) { | ||
logger_1.default.info(`Creating Library/${libraryId}`); | ||
@@ -125,2 +133,6 @@ return Object.assign(Object.assign({ resourceType: 'Library', id: libraryId, url: combineURLs(canonicalBase, `/Library/${libraryId}`) }, (elm.library.identifier.version ? { version: elm.library.identifier.version } : {})), { type: { | ||
{ | ||
contentType: 'text/cql', | ||
data: Buffer.from(cqlLookup[elm.library.identifier.id] || '').toString('base64') | ||
}, | ||
{ | ||
contentType: 'application/elm+json', | ||
@@ -127,0 +139,0 @@ data: Buffer.from(JSON.stringify(elm)).toString('base64') |
@@ -51,2 +51,3 @@ "use strict"; | ||
]; | ||
const cqlReturn = {}; | ||
// Only include cql files that are explicitly included by the dependency chain | ||
@@ -57,5 +58,10 @@ Object.keys(cqlRequestBody).forEach(k => { | ||
} | ||
else { | ||
cqlReturn[k] = cqlRequestBody[k].cql; | ||
} | ||
}); | ||
const elm = yield client.convertCQL(cqlRequestBody); | ||
return elm; | ||
const elmOrError = yield client.convertCQL(cqlRequestBody); | ||
if (elmOrError instanceof Error) | ||
throw elmOrError; | ||
return { elm: elmOrError, cql: cqlReturn }; | ||
}); | ||
@@ -78,8 +84,6 @@ } | ||
const client = new cql_translation_service_client_1.Client(`${translatorUrl}?annotations=true&locators=true`); | ||
const librariesOrError = yield translateCQL(cqlPaths, client, mainLibraryId); | ||
if (librariesOrError instanceof Error) | ||
throw librariesOrError; | ||
const { elm: libraries, cql } = yield translateCQL(cqlPaths, client, mainLibraryId); | ||
const allELM = []; | ||
for (const key in librariesOrError) { | ||
const elm = librariesOrError[key]; | ||
for (const key in libraries) { | ||
const elm = libraries[key]; | ||
const errors = processErrors(elm); | ||
@@ -93,5 +97,5 @@ if (errors.length === 0) { | ||
} | ||
return [allELM, null]; | ||
return [{ elm: allELM, cqlLookup: cql }, null]; | ||
}); | ||
} | ||
exports.getELM = getELM; |
@@ -86,2 +86,3 @@ #!/usr/bin/env node | ||
let elm; | ||
let cqlLookup = {}; | ||
let mainLibraryId = null; | ||
@@ -114,3 +115,4 @@ if (opts.elmFile) { | ||
} | ||
elm = result; | ||
elm = result.elm; | ||
cqlLookup = result.cqlLookup; | ||
} | ||
@@ -142,3 +144,3 @@ catch (e) { | ||
const libraryFHIRId = `library-${mainLibraryId}`; | ||
const library = (0, fhir_1.generateLibraryResource)(libraryFHIRId, mainLibELM, opts.canonicalBase); | ||
const library = (0, fhir_1.generateLibraryResource)(libraryFHIRId, mainLibELM, opts.canonicalBase, cqlLookup); | ||
const measureFHIRId = `measure-${mainLibraryId}`; | ||
@@ -158,3 +160,3 @@ const measure = (0, fhir_1.generateMeasureResource)(measureFHIRId, libraryFHIRId, opts.improvementNotation, opts.scoringCode, opts.canonicalBase, { | ||
const remainingDeps = elm.filter(e => allUsedDependencies.includes(e.library.identifier.id)); | ||
const depLibraries = remainingDeps.map(d => (Object.assign(Object.assign({}, (0, fhir_1.generateLibraryResource)(`library-${d.library.identifier.id}`, d, opts.canonicalBase)), { relatedArtifact: [ | ||
const depLibraries = remainingDeps.map(d => (Object.assign(Object.assign({}, (0, fhir_1.generateLibraryResource)(`library-${d.library.identifier.id}`, d, opts.canonicalBase, cqlLookup)), { relatedArtifact: [ | ||
...(0, elm_1.getDependencyInfo)(d).map(dep => (0, fhir_1.generateLibraryRelatedArtifact)(dep, remainingDeps, opts.canonicalBase)), | ||
@@ -161,0 +163,0 @@ ...(0, elm_1.getValueSetInfo)(d).map(vs => (0, fhir_1.generateValueSetRelatedArtifact)(vs)) |
{ | ||
"name": "ecqm-bundler", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "CLI for bundling FHIR-based eCQMs", | ||
@@ -29,2 +29,3 @@ "main": "dist/index.js", | ||
"@types/node": "^17.0.29", | ||
"@types/uuid": "^8.3.4", | ||
"@types/winston": "^2.4.4", | ||
@@ -43,4 +44,5 @@ "@typescript-eslint/eslint-plugin": "^5.21.0", | ||
"cql-translation-service-client": "^0.6.1", | ||
"uuid": "^9.0.0", | ||
"winston": "^3.7.2" | ||
} | ||
} |
@@ -112,1 +112,9 @@ # ecqm-bundler | ||
``` | ||
# Simple Example | ||
See the `example` directory for example inputs and outputs to `ecqm-bundler`. The `example-measure-bundle.json` file in this directory was generated using the following command: | ||
``` bash | ||
ecqm-bundler -c example/cql/MainLib.cql --deps-directory example/cql -v example/valuesets | ||
``` |
41818
512
120
4
13
+ Addeduuid@^9.0.0
+ Addeduuid@9.0.1(transitive)