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.
Files changed (92) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/library/cron-utilities.js +136 -0
  4. package/library/html-server.js +13 -29
  5. package/library/html.js +3 -8
  6. package/library/languages.js +160 -37
  7. package/library/package-manager.js +48 -1
  8. package/library/utilities.js +100 -19
  9. package/package.json +2 -2
  10. package/packages/package-crawler.js +6 -1
  11. package/packages/packages.js +38 -54
  12. package/publisher/publisher.js +19 -27
  13. package/registry/api.js +11 -10
  14. package/registry/crawler.js +31 -29
  15. package/registry/model.js +5 -26
  16. package/registry/registry.js +32 -41
  17. package/server.js +53 -5
  18. package/shl/shl.js +0 -18
  19. package/static/assets/js/statuspage.js +1 -9
  20. package/stats.js +39 -1
  21. package/token/token.js +14 -9
  22. package/translations/Messages.properties +2 -1
  23. package/tx/README.md +17 -6
  24. package/tx/cs/cs-api.js +19 -1
  25. package/tx/cs/cs-base.js +77 -0
  26. package/tx/cs/cs-country.js +46 -0
  27. package/tx/cs/cs-cpt.js +9 -5
  28. package/tx/cs/cs-cs.js +27 -13
  29. package/tx/cs/cs-lang.js +60 -22
  30. package/tx/cs/cs-loinc.js +69 -98
  31. package/tx/cs/cs-mimetypes.js +4 -0
  32. package/tx/cs/cs-ndc.js +6 -0
  33. package/tx/cs/cs-omop.js +16 -15
  34. package/tx/cs/cs-rxnorm.js +23 -1
  35. package/tx/cs/cs-snomed.js +283 -40
  36. package/tx/cs/cs-ucum.js +90 -70
  37. package/tx/importers/import-sct.module.js +371 -35
  38. package/tx/importers/readme.md +117 -7
  39. package/tx/library/bundle.js +5 -0
  40. package/tx/library/capabilitystatement.js +3 -142
  41. package/tx/library/codesystem.js +19 -173
  42. package/tx/library/conceptmap.js +4 -218
  43. package/tx/library/designations.js +14 -1
  44. package/tx/library/extensions.js +7 -0
  45. package/tx/library/namingsystem.js +3 -89
  46. package/tx/library/operation-outcome.js +8 -3
  47. package/tx/library/parameters.js +3 -2
  48. package/tx/library/renderer.js +10 -6
  49. package/tx/library/terminologycapabilities.js +3 -243
  50. package/tx/library/valueset.js +3 -235
  51. package/tx/library.js +100 -13
  52. package/tx/operation-context.js +23 -4
  53. package/tx/params.js +35 -38
  54. package/tx/provider.js +6 -5
  55. package/tx/sct/expressions.js +12 -3
  56. package/tx/tx-html.js +80 -89
  57. package/tx/tx.fhir.org.yml +6 -5
  58. package/tx/tx.js +163 -13
  59. package/tx/vs/vs-database.js +56 -39
  60. package/tx/vs/vs-package.js +21 -2
  61. package/tx/vs/vs-vsac.js +175 -39
  62. package/tx/workers/batch-validate.js +2 -0
  63. package/tx/workers/batch.js +2 -0
  64. package/tx/workers/expand.js +132 -112
  65. package/tx/workers/lookup.js +33 -14
  66. package/tx/workers/metadata.js +2 -2
  67. package/tx/workers/read.js +3 -2
  68. package/tx/workers/related.js +574 -0
  69. package/tx/workers/search.js +46 -9
  70. package/tx/workers/subsumes.js +13 -3
  71. package/tx/workers/translate.js +7 -3
  72. package/tx/workers/validate.js +258 -285
  73. package/tx/workers/worker.js +43 -39
  74. package/tx/xml/bundle-xml.js +237 -0
  75. package/tx/xml/xml-base.js +215 -64
  76. package/tx/xversion/xv-bundle.js +71 -0
  77. package/tx/xversion/xv-capabiliityStatement.js +137 -0
  78. package/tx/xversion/xv-codesystem.js +169 -0
  79. package/tx/xversion/xv-conceptmap.js +224 -0
  80. package/tx/xversion/xv-namingsystem.js +88 -0
  81. package/tx/xversion/xv-operationoutcome.js +27 -0
  82. package/tx/xversion/xv-parameters.js +87 -0
  83. package/tx/xversion/xv-resource.js +45 -0
  84. package/tx/xversion/xv-terminologyCapabilities.js +214 -0
  85. package/tx/xversion/xv-valueset.js +234 -0
  86. package/utilities/dev-proxy-server.js +126 -0
  87. package/utilities/explode-results.js +58 -0
  88. package/utilities/split-by-system.js +198 -0
  89. package/utilities/vsac-cs-fetcher.js +0 -0
  90. package/{windows-install.js → utilities/windows-install.js} +2 -0
  91. package/vcl/vcl.js +0 -18
  92. package/xig/xig.js +108 -99
@@ -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'], true);
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(404).json(this.operationOutcome('error', 'not-found', msg));
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
- const message = locateResult?.message ||
253
- `Unable to find code '${code}' in ${csProvider.system()} version ${csProvider.version() || 'unknown'}`;
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.property || [], responseParams);
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
- diagnostics: message
420
+ details: {text : message}
402
421
  }]
403
422
  };
404
423
  }
@@ -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.toJSON(endpoint.fhirVersion));
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.toJSON(endpoint.fhirVersion));
46
+ return res.json(cs.jsonObj);
47
47
  }
48
48
 
49
49
  /**
@@ -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 = "conplete",
108
+ json.content = "complete",
108
109
  json.concept = [];
109
110
  let csp = cs.build(this.opContext, []);
110
111
  let iter = await csp.iteratorAll();