fhirsmith 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/library/cron-utilities.js +136 -0
- package/library/html-server.js +13 -29
- package/library/html.js +3 -8
- package/library/languages.js +160 -37
- package/library/package-manager.js +48 -1
- package/library/utilities.js +100 -19
- package/package.json +2 -2
- package/packages/package-crawler.js +6 -1
- package/packages/packages.js +38 -54
- package/publisher/publisher.js +19 -27
- package/registry/api.js +11 -10
- package/registry/crawler.js +31 -29
- package/registry/model.js +5 -26
- package/registry/registry.js +32 -41
- package/server.js +53 -5
- package/shl/shl.js +0 -18
- package/static/assets/js/statuspage.js +1 -9
- package/stats.js +39 -1
- package/token/token.js +14 -9
- package/translations/Messages.properties +2 -1
- package/tx/README.md +17 -6
- package/tx/cs/cs-api.js +19 -1
- package/tx/cs/cs-base.js +77 -0
- package/tx/cs/cs-country.js +46 -0
- package/tx/cs/cs-cpt.js +9 -5
- package/tx/cs/cs-cs.js +27 -13
- package/tx/cs/cs-lang.js +60 -22
- package/tx/cs/cs-loinc.js +69 -98
- package/tx/cs/cs-mimetypes.js +4 -0
- package/tx/cs/cs-ndc.js +6 -0
- package/tx/cs/cs-omop.js +16 -15
- package/tx/cs/cs-rxnorm.js +23 -1
- package/tx/cs/cs-snomed.js +283 -40
- package/tx/cs/cs-ucum.js +90 -70
- package/tx/importers/import-sct.module.js +371 -35
- package/tx/importers/readme.md +117 -7
- package/tx/library/bundle.js +5 -0
- package/tx/library/capabilitystatement.js +3 -142
- package/tx/library/codesystem.js +19 -173
- package/tx/library/conceptmap.js +4 -218
- package/tx/library/designations.js +14 -1
- package/tx/library/extensions.js +7 -0
- package/tx/library/namingsystem.js +3 -89
- package/tx/library/operation-outcome.js +8 -3
- package/tx/library/parameters.js +3 -2
- package/tx/library/renderer.js +10 -6
- package/tx/library/terminologycapabilities.js +3 -243
- package/tx/library/valueset.js +3 -235
- package/tx/library.js +100 -13
- package/tx/operation-context.js +23 -4
- package/tx/params.js +35 -38
- package/tx/provider.js +6 -5
- package/tx/sct/expressions.js +12 -3
- package/tx/tx-html.js +80 -89
- package/tx/tx.fhir.org.yml +6 -5
- package/tx/tx.js +163 -13
- package/tx/vs/vs-database.js +56 -39
- package/tx/vs/vs-package.js +21 -2
- package/tx/vs/vs-vsac.js +175 -39
- package/tx/workers/batch-validate.js +2 -0
- package/tx/workers/batch.js +2 -0
- package/tx/workers/expand.js +132 -112
- package/tx/workers/lookup.js +33 -14
- package/tx/workers/metadata.js +2 -2
- package/tx/workers/read.js +3 -2
- package/tx/workers/related.js +574 -0
- package/tx/workers/search.js +46 -9
- package/tx/workers/subsumes.js +13 -3
- package/tx/workers/translate.js +7 -3
- package/tx/workers/validate.js +258 -285
- package/tx/workers/worker.js +43 -39
- package/tx/xml/bundle-xml.js +237 -0
- package/tx/xml/xml-base.js +215 -64
- package/tx/xversion/xv-bundle.js +71 -0
- package/tx/xversion/xv-capabiliityStatement.js +137 -0
- package/tx/xversion/xv-codesystem.js +169 -0
- package/tx/xversion/xv-conceptmap.js +224 -0
- package/tx/xversion/xv-namingsystem.js +88 -0
- package/tx/xversion/xv-operationoutcome.js +27 -0
- package/tx/xversion/xv-parameters.js +87 -0
- package/tx/xversion/xv-resource.js +45 -0
- package/tx/xversion/xv-terminologyCapabilities.js +214 -0
- package/tx/xversion/xv-valueset.js +234 -0
- package/utilities/dev-proxy-server.js +126 -0
- package/utilities/explode-results.js +58 -0
- package/utilities/split-by-system.js +198 -0
- package/utilities/vsac-cs-fetcher.js +0 -0
- package/{windows-install.js → utilities/windows-install.js} +2 -0
- package/vcl/vcl.js +0 -18
- package/xig/xig.js +108 -99
package/tx/workers/lookup.js
CHANGED
|
@@ -44,9 +44,9 @@ class LookupWorker extends TerminologyWorker {
|
|
|
44
44
|
try {
|
|
45
45
|
await this.handleTypeLevelLookup(req, res);
|
|
46
46
|
} catch (error) {
|
|
47
|
-
console.log(error);
|
|
48
|
-
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
49
47
|
this.log.error(error);
|
|
48
|
+
this.debugLog(error);
|
|
49
|
+
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
50
50
|
const statusCode = error.statusCode || 500;
|
|
51
51
|
const issueCode = error.issueCode || 'exception';
|
|
52
52
|
return res.status(statusCode).json({
|
|
@@ -71,8 +71,9 @@ class LookupWorker extends TerminologyWorker {
|
|
|
71
71
|
try {
|
|
72
72
|
await this.handleInstanceLevelLookup(req, res);
|
|
73
73
|
} catch (error) {
|
|
74
|
-
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
75
74
|
this.log.error(error);
|
|
75
|
+
this.debugLog(error);
|
|
76
|
+
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
76
77
|
const issueCode = error.issueCode || 'exception';
|
|
77
78
|
return res.status(400).json({
|
|
78
79
|
resourceType: 'OperationOutcome',
|
|
@@ -126,7 +127,8 @@ class LookupWorker extends TerminologyWorker {
|
|
|
126
127
|
|
|
127
128
|
} else if (params.has('system') && params.has('code')) {
|
|
128
129
|
// system + code parameters
|
|
129
|
-
csProvider = await this.findCodeSystem(params.get('system'), params.get('version') || '', txp, ['complete', 'fragment'],
|
|
130
|
+
csProvider = await this.findCodeSystem(params.get('system'), params.get('version') || '', txp, ['complete', 'fragment'],
|
|
131
|
+
null, true, false, false, txp.supplements);
|
|
130
132
|
this.seeSourceProvider(csProvider, params.get('system'));
|
|
131
133
|
code = params.get('code');
|
|
132
134
|
|
|
@@ -141,15 +143,24 @@ class LookupWorker extends TerminologyWorker {
|
|
|
141
143
|
const msg = versionStr
|
|
142
144
|
? `CodeSystem not found: ${systemUrl} version ${versionStr}`
|
|
143
145
|
: `CodeSystem not found: ${systemUrl}`;
|
|
144
|
-
return res.status(
|
|
146
|
+
return res.status(422).json(this.operationOutcome('error', 'not-found', msg));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// check supplements
|
|
150
|
+
const used = new Set();
|
|
151
|
+
this.checkSupplements(csProvider, null, txp.supplements, used);
|
|
152
|
+
const unused = new Set([...txp.supplements].filter(s => !used.has(s)));
|
|
153
|
+
if (unused.size > 0) {
|
|
154
|
+
throw new Issue('error', 'not-found', null, 'VALUESET_SUPPLEMENT_MISSING', this.i18n.translatePlural(unused.size, 'VALUESET_SUPPLEMENT_MISSING', txp.HTTPLanguages, [[...unused].join(',')]), 'not-found').handleAsOO(400);
|
|
145
155
|
}
|
|
146
156
|
|
|
147
157
|
// Perform the lookup
|
|
148
158
|
const result = await this.doLookup(csProvider, code, txp);
|
|
149
159
|
return res.status(200).json(result);
|
|
150
160
|
} catch (error) {
|
|
151
|
-
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
152
161
|
this.log.error(error);
|
|
162
|
+
this.debugLog(error);
|
|
163
|
+
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
153
164
|
if (error instanceof Issue) {
|
|
154
165
|
let oo = new OperationOutcome();
|
|
155
166
|
oo.addIssue(error);
|
|
@@ -202,7 +213,7 @@ class LookupWorker extends TerminologyWorker {
|
|
|
202
213
|
}
|
|
203
214
|
|
|
204
215
|
// Load any supplements
|
|
205
|
-
const supplements = this.loadSupplements(codeSystem.url, codeSystem.version);
|
|
216
|
+
const supplements = this.loadSupplements(codeSystem.url, codeSystem.version, txp.supplements);
|
|
206
217
|
|
|
207
218
|
// Create a FhirCodeSystemProvider for this CodeSystem
|
|
208
219
|
const csProvider = new FhirCodeSystemProvider(this.opContext, codeSystem, supplements);
|
|
@@ -211,8 +222,9 @@ class LookupWorker extends TerminologyWorker {
|
|
|
211
222
|
const result = await this.doLookup(csProvider, code, txp);
|
|
212
223
|
return res.status(200).json(result);
|
|
213
224
|
} catch (error) {
|
|
214
|
-
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
215
225
|
this.log.error(error);
|
|
226
|
+
this.debugLog(error);
|
|
227
|
+
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
216
228
|
if (error instanceof Issue) {
|
|
217
229
|
let oo = new OperationOutcome();
|
|
218
230
|
oo.addIssue(error);
|
|
@@ -234,6 +246,8 @@ class LookupWorker extends TerminologyWorker {
|
|
|
234
246
|
async doLookup(csProvider, code, params) {
|
|
235
247
|
this.deadCheck('doLookup');
|
|
236
248
|
|
|
249
|
+
await this.checkSupplements(csProvider, null, params.supplements);
|
|
250
|
+
|
|
237
251
|
// Helper to check if a property should be included
|
|
238
252
|
const hasProp = (name, defaultValue = true) => {
|
|
239
253
|
if (!params.properties || params.properties.length === 0) {
|
|
@@ -249,8 +263,10 @@ class LookupWorker extends TerminologyWorker {
|
|
|
249
263
|
const locateResult = await csProvider.locate(code);
|
|
250
264
|
|
|
251
265
|
if (!locateResult || !locateResult.context) {
|
|
252
|
-
|
|
253
|
-
|
|
266
|
+
let message = `Unable to find code '${code}' in ${csProvider.system()} version ${csProvider.version() || 'unknown'}`
|
|
267
|
+
if (locateResult?.message) {
|
|
268
|
+
message += ' ('+locateResult.message+')';
|
|
269
|
+
}
|
|
254
270
|
throw new Issue('error', 'not-found', null, null, message, null, 404);
|
|
255
271
|
}
|
|
256
272
|
|
|
@@ -285,9 +301,13 @@ class LookupWorker extends TerminologyWorker {
|
|
|
285
301
|
|
|
286
302
|
// display (required)
|
|
287
303
|
const display = await csProvider.display(ctxt);
|
|
304
|
+
const designations = new Designations(this.languages);
|
|
305
|
+
await csProvider.designations(ctxt, designations);
|
|
306
|
+
const pd = designations.preferredDesignation(params.workingLanguages());
|
|
307
|
+
const disp = pd ? pd.value : undefined;
|
|
288
308
|
responseParams.push({
|
|
289
309
|
name: 'display',
|
|
290
|
-
valueString: display || code
|
|
310
|
+
valueString: disp || display || code
|
|
291
311
|
});
|
|
292
312
|
|
|
293
313
|
// definition (optional) - top-level parameter
|
|
@@ -359,7 +379,7 @@ class LookupWorker extends TerminologyWorker {
|
|
|
359
379
|
}
|
|
360
380
|
|
|
361
381
|
// Let the provider add additional properties
|
|
362
|
-
await csProvider.extendLookup(ctxt, params.
|
|
382
|
+
await csProvider.extendLookup(ctxt, params.properties || [], responseParams);
|
|
363
383
|
|
|
364
384
|
return {
|
|
365
385
|
resourceType: 'Parameters',
|
|
@@ -384,7 +404,6 @@ class LookupWorker extends TerminologyWorker {
|
|
|
384
404
|
});
|
|
385
405
|
}
|
|
386
406
|
|
|
387
|
-
|
|
388
407
|
/**
|
|
389
408
|
* Build an OperationOutcome
|
|
390
409
|
* @param {string} severity - error, warning, information
|
|
@@ -398,7 +417,7 @@ class LookupWorker extends TerminologyWorker {
|
|
|
398
417
|
issue: [{
|
|
399
418
|
severity,
|
|
400
419
|
code,
|
|
401
|
-
|
|
420
|
+
details: {text : message}
|
|
402
421
|
}]
|
|
403
422
|
};
|
|
404
423
|
}
|
package/tx/workers/metadata.js
CHANGED
|
@@ -37,13 +37,13 @@ class MetadataHandler {
|
|
|
37
37
|
if (mode === 'terminology') {
|
|
38
38
|
this.logInfo = 'termcaps';
|
|
39
39
|
const tc = new TerminologyCapabilities(await this.buildTerminologyCapabilities(endpoint, provider));
|
|
40
|
-
return res.json(tc.
|
|
40
|
+
return res.json(tc.jsonObj);
|
|
41
41
|
}
|
|
42
42
|
this.logInfo = 'metadata';
|
|
43
43
|
|
|
44
44
|
// Default: return CapabilityStatement
|
|
45
45
|
const cs = new CapabilityStatement(this.buildCapabilityStatement(endpoint, provider));
|
|
46
|
-
return res.json(cs.
|
|
46
|
+
return res.json(cs.jsonObj);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
package/tx/workers/read.js
CHANGED
|
@@ -66,8 +66,9 @@ class ReadWorker extends TerminologyWorker {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
} catch (error) {
|
|
69
|
-
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
70
69
|
this.log.error(error);
|
|
70
|
+
this.debugLog(error);
|
|
71
|
+
req.logInfo = this.usedSources.join("|")+" - error"+(error.msgId ? " "+error.msgId : "");
|
|
71
72
|
return res.status(500).json({
|
|
72
73
|
resourceType: 'OperationOutcome',
|
|
73
74
|
issue: [{
|
|
@@ -104,7 +105,7 @@ class ReadWorker extends TerminologyWorker {
|
|
|
104
105
|
json.version = cs.version();
|
|
105
106
|
}
|
|
106
107
|
if (cs.iteratable()) {
|
|
107
|
-
json.content = "
|
|
108
|
+
json.content = "complete",
|
|
108
109
|
json.concept = [];
|
|
109
110
|
let csp = cs.build(this.opContext, []);
|
|
110
111
|
let iter = await csp.iteratorAll();
|