fhirsmith 0.8.5 → 0.9.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 (41) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +52 -22
  3. package/extension-tracker/extension-tracker-template.html +3 -1
  4. package/library/html-server.js +7 -0
  5. package/library/logger.js +234 -194
  6. package/library/regex-utilities.js +13 -0
  7. package/package.json +4 -2
  8. package/packages/packages-template.html +3 -1
  9. package/publisher/publisher-template.html +1 -0
  10. package/publisher/publisher.js +28 -7
  11. package/registry/registry-template.html +3 -1
  12. package/root-bare-template.html +9759 -37
  13. package/root-template.html +3 -2
  14. package/server.js +48 -12
  15. package/translations/Messages.properties +2 -1
  16. package/translations/rendering-phrases.properties +3 -1
  17. package/tx/cs/cs-api.js +4 -0
  18. package/tx/cs/cs-country.js +2 -1
  19. package/tx/cs/cs-cs.js +9 -4
  20. package/tx/cs/cs-loinc.js +2 -1
  21. package/tx/cs/cs-snomed.js +5 -1
  22. package/tx/data/OperationDefinition-ValueSet-related.json +133 -0
  23. package/tx/html/tx-template.html +3 -2
  24. package/tx/importers/atc-to-fhir.js +27 -27
  25. package/tx/library/codesystem.js +4 -0
  26. package/tx/library/renderer.js +20 -4
  27. package/tx/library/ucum-parsers.js +2 -1
  28. package/tx/ocl/cs-ocl.cjs +48 -15
  29. package/tx/ocl/vs-ocl.cjs +57 -34
  30. package/tx/operation-context.js +74 -19
  31. package/tx/tx-html.js +5 -5
  32. package/tx/tx.fhir.org.yml +4 -4
  33. package/tx/tx.js +1 -0
  34. package/tx/vs/vs-database.js +150 -100
  35. package/tx/vs/vs-vsac.js +90 -31
  36. package/tx/workers/expand.js +154 -113
  37. package/tx/workers/metadata.js +6 -3
  38. package/tx/workers/read.js +6 -3
  39. package/tx/workers/related.js +228 -87
  40. package/xig/xig-template.html +3 -1
  41. package/library/logger-telnet.js +0 -205
@@ -207,6 +207,7 @@ class ValueSetExpander {
207
207
  reportedSupplements = new Set();
208
208
  internalLimit = INTERNAL_DEFAULT_LIMIT;
209
209
  externalLimit = EXTERNAL_DEFAULT_LIMIT;
210
+ noDetails = false;
210
211
 
211
212
  constructor(worker, params) {
212
213
  this.worker = worker;
@@ -336,7 +337,7 @@ class ValueSetExpander {
336
337
  }
337
338
  }
338
339
 
339
- if (expansion) {
340
+ if (expansion && !this.noDetails) {
340
341
  const s = this.canonical(system, version);
341
342
  this.addParamUri(expansion, 'used-codesystem', s);
342
343
  if (cs != null) {
@@ -362,113 +363,115 @@ class ValueSetExpander {
362
363
  if (isInactive) {
363
364
  n.inactive = true;
364
365
  }
366
+ if (!this.noDetails) {
367
+ if (status && status.toLowerCase() !== 'active') {
368
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#status', 'status', "valueCode", status);
369
+ } else if (deprecated) {
370
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#status', 'status', "valueCode", 'deprecated');
371
+ }
365
372
 
366
- if (status && status.toLowerCase() !== 'active') {
367
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#status', 'status', "valueCode", status);
368
- } else if (deprecated) {
369
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#status', 'status', "valueCode", 'deprecated');
370
- }
371
-
372
- if (Extensions.has(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-label')) {
373
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#label', 'label', "valueString", Extensions.readString(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-label'));
374
- }
375
- if (Extensions.has(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-label')) {
376
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#label', 'label', "valueString", Extensions.readString(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-label'));
377
- }
373
+ if (Extensions.has(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-label')) {
374
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#label', 'label', "valueString", Extensions.readString(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-label'));
375
+ }
376
+ if (Extensions.has(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-label')) {
377
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#label', 'label', "valueString", Extensions.readString(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-label'));
378
+ }
378
379
 
379
- if (Extensions.has(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-conceptOrder')) {
380
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#order', 'order', "valueDecimal", Extensions.readNumber(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-conceptOrder', undefined));
381
- }
382
- if (Extensions.has(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-conceptOrder')) {
383
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#order', 'order', "valueDecimal", Extensions.readNumber(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-conceptOrder', undefined));
384
- }
380
+ if (Extensions.has(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-conceptOrder')) {
381
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#order', 'order', "valueDecimal", Extensions.readNumber(csExtList, 'http://hl7.org/fhir/StructureDefinition/codesystem-conceptOrder', undefined));
382
+ }
383
+ if (Extensions.has(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-conceptOrder')) {
384
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#order', 'order', "valueDecimal", Extensions.readNumber(vsExtList, 'http://hl7.org/fhir/StructureDefinition/valueset-conceptOrder', undefined));
385
+ }
385
386
 
386
- if (Extensions.has(csExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight')) {
387
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#itemWeight', 'weight', "valueDecimal", Extensions.readNumber(csExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight', undefined));
388
- }
389
- if (Extensions.has(vsExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight')) {
390
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#itemWeight', 'weight', "valueDecimal", Extensions.readNumber(vsExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight', undefined));
391
- }
387
+ if (Extensions.has(csExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight')) {
388
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#itemWeight', 'weight', "valueDecimal", Extensions.readNumber(csExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight', undefined));
389
+ }
390
+ if (Extensions.has(vsExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight')) {
391
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#itemWeight', 'weight', "valueDecimal", Extensions.readNumber(vsExtList, 'http://hl7.org/fhir/StructureDefinition/itemWeight', undefined));
392
+ }
392
393
 
393
- if (csExtList != null) {
394
- for (const ext of csExtList) {
395
- if (['http://hl7.org/fhir/StructureDefinition/coding-sctdescid', 'http://hl7.org/fhir/StructureDefinition/rendering-style',
396
- 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml', 'http://hl7.org/fhir/StructureDefinition/codesystem-alternate'].includes(ext.url)) {
397
- if (!n.extension) {n.extension = []}
398
- n.extension.push(ext);
399
- }
400
- if (['http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status'].includes(ext.url)) {
401
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#status', 'status', "valueCode", getValuePrimitive(ext));
394
+ if (csExtList != null) {
395
+ for (const ext of csExtList) {
396
+ if (['http://hl7.org/fhir/StructureDefinition/coding-sctdescid', 'http://hl7.org/fhir/StructureDefinition/rendering-style',
397
+ 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml', 'http://hl7.org/fhir/StructureDefinition/codesystem-alternate'].includes(ext.url)) {
398
+ if (!n.extension) {
399
+ n.extension = []
400
+ }
401
+ n.extension.push(ext);
402
+ }
403
+ if (['http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status'].includes(ext.url)) {
404
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#status', 'status', "valueCode", getValuePrimitive(ext));
405
+ }
402
406
  }
403
407
  }
404
- }
405
408
 
406
- if (vsExtList != null) {
407
- for (const ext of vsExtList || []) {
408
- if (['http://hl7.org/fhir/StructureDefinition/valueset-supplement', 'http://hl7.org/fhir/StructureDefinition/valueset-deprecated',
409
- 'http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status',
410
- 'http://hl7.org/fhir/StructureDefinition/valueset-concept-definition', 'http://hl7.org/fhir/StructureDefinition/coding-sctdescid',
411
- 'http://hl7.org/fhir/StructureDefinition/rendering-style', 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml'].includes(ext.url)) {
412
- if (!n.extension) {n.extension = []}
413
- n.extension.push(ext);
409
+ if (vsExtList != null) {
410
+ for (const ext of vsExtList || []) {
411
+ if (['http://hl7.org/fhir/StructureDefinition/valueset-supplement', 'http://hl7.org/fhir/StructureDefinition/valueset-deprecated',
412
+ 'http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status',
413
+ 'http://hl7.org/fhir/StructureDefinition/valueset-concept-definition', 'http://hl7.org/fhir/StructureDefinition/coding-sctdescid',
414
+ 'http://hl7.org/fhir/StructureDefinition/rendering-style', 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml'].includes(ext.url)) {
415
+ if (!n.extension) {
416
+ n.extension = []
417
+ }
418
+ n.extension.push(ext);
419
+ }
414
420
  }
415
421
  }
416
- }
417
422
 
418
- // display and designations
419
- const pref = displays.preferredDesignation(this.params.workingLanguages(), this.reportedSupplements);
420
- if (pref && pref.value) {
421
- n.display = pref.value;
422
- }
423
+ // display and designations
424
+ const pref = displays.preferredDesignation(this.params.workingLanguages(), this.reportedSupplements);
425
+ if (pref && pref.value) {
426
+ n.display = pref.value;
427
+ }
423
428
 
424
- if (this.params.includeDesignations) {
425
- for (const t of displays.designations) {
426
- if (t !== pref && this.useDesignation(t) && t.value != null && !this.redundantDisplay(n, t.language, t.use, t.value)) {
427
- if (!n.designation) {
428
- n.designation = [];
429
- }
430
- if (t.source) {
431
- this.reportedSupplements.add(t.source);
429
+ if (this.params.includeDesignations) {
430
+ for (const t of displays.designations) {
431
+ if (t !== pref && this.useDesignation(t) && t.value != null && !this.redundantDisplay(n, t.language, t.use, t.value)) {
432
+ if (!n.designation) {
433
+ n.designation = [];
434
+ }
435
+ if (t.source) {
436
+ this.reportedSupplements.add(t.source);
437
+ }
438
+ n.designation.push(t.asObject());
432
439
  }
433
- n.designation.push(t.asObject());
434
440
  }
435
441
  }
436
- }
437
442
 
438
- for (const pn of this.params.properties) {
439
- if (pn === 'definition') {
440
- if (definition) {
441
- this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#definition', pn, "valueString", definition);
442
- }
443
- } else if (pn === 'usage-count') {
444
- let counter = cs.usages().get(code);
445
- this.defineProperty(expansion, n, 'http://fhir.org/FHIRsmith/CodeSystem/concept-properties#usage-count', pn, "valueInteger", counter ? counter.count : 0);
446
- } else if (csProps != null && cs != null) {
447
- for (const cp of csProps) {
448
- if (cp.code === pn) {
449
- let vn = getValueName(cp);
450
- let v = cp[vn];
451
- this.defineProperty(expansion, n, this.getPropUrl(cs, pn, cp), pn, vn, v);
443
+ for (const pn of this.params.properties) {
444
+ if (pn === 'definition') {
445
+ if (definition) {
446
+ this.defineProperty(expansion, n, 'http://hl7.org/fhir/concept-properties#definition', pn, "valueString", definition);
447
+ }
448
+ } else if (pn === 'usage-count') {
449
+ let counter = cs.usages().get(code);
450
+ this.defineProperty(expansion, n, 'http://fhir.org/FHIRsmith/CodeSystem/concept-properties#usage-count', pn, "valueInteger", counter ? counter.count : 0);
451
+ } else if (csProps != null && cs != null) {
452
+ for (const cp of csProps) {
453
+ if (cp.code === pn) {
454
+ let vn = getValueName(cp);
455
+ let v = cp[vn];
456
+ this.defineProperty(expansion, n, this.getPropUrl(cs, pn, cp), pn, vn, v);
457
+ }
452
458
  }
453
459
  }
454
460
  }
455
461
  }
456
-
457
- if (!this.map.has(s)) {
458
- this.fullList.push(n);
459
- this.map.set(s, n);
460
- if (parent != null) {
461
- if (!parent.contains) {
462
- parent.contains = [];
463
- }
464
- parent.contains.push(n);
465
- } else {
466
- this.rootList.push(n);
462
+ this.fullList.push(n);
463
+ this.map.set(s, n);
464
+ if (parent != null && !this.noDetails) {
465
+ if (!parent.contains) {
466
+ parent.contains = [];
467
467
  }
468
+ parent.contains.push(n);
468
469
  } else {
469
- this.canBeHierarchy = false;
470
+ this.rootList.push(n);
470
471
  }
471
472
  result = n;
473
+ } else {
474
+ this.canBeHierarchy = false;
472
475
  }
473
476
  return result;
474
477
  }
@@ -643,6 +646,10 @@ class ValueSetExpander {
643
646
  throw new Issue('error', 'business-rule', null, null, 'The code system definition for ' + cset.system + ' has no content, so this expansion cannot be performed', 'invalid');
644
647
  } else if (cs.contentMode() === 'supplement') {
645
648
  throw new Issue('error', 'business-rule', null, null, 'The code system definition for ' + cset.system + ' defines a supplement, so this expansion cannot be performed', 'invalid');
649
+ } else if (cs.contentMode() === 'fragment') {
650
+ this.addParamUri(exp, 'used-fragment', cs.system() + '|' + cs.version());
651
+ Extensions.addBoolean(exp, "http://hl7.org/fhir/StructureDefinition/valueset-unclosed", true);
652
+ Extensions.addString(exp, "http://hl7.org/fhir/StructureDefinition/valueset-unclosed-reason","This extension is based on a fragment of the code system " + cset.system);
646
653
  } else {
647
654
  this.addParamUri(exp, cs.contentMode(), cs.system() + '|' + cs.version());
648
655
  Extensions.addBoolean(exp, "http://hl7.org/fhir/StructureDefinition/valueset-unclosed", true);
@@ -777,9 +784,17 @@ class ValueSetExpander {
777
784
  const c = await cs.filterConcept(ctxt, set[0]);
778
785
  if (await this.passesFilters(cs, c, prep, set, 1)) {
779
786
  const cds = new Designations(this.worker.i18n.languageDefinitions);
780
- await this.listDisplaysFromProvider(cds, cs, c);
781
- let added = await this.includeCode(cs, null, await cs.system(), await cs.version(), await cs.code(c), await cs.isAbstract(c), await cs.isInactive(c), await cs.isDeprecated(c), await cs.getStatus(c),
782
- cds, await cs.definition(c), await cs.itemWeight(c), expansion, valueSets, await cs.extensions(c), null, await cs.properties(c), null, excludeInactive, vsSrc.url);
787
+ let added;
788
+ if (this.noDetails) {
789
+ await this.listDisplaysFromProvider(cds, cs, c);
790
+ added = await this.includeCode(cs, null, await cs.system(), await cs.version(), await cs.code(c), await cs.isAbstract(c), await cs.isInactive(c), false, null,
791
+ cds, null, null, expansion, valueSets, null, null, null, null, excludeInactive, vsSrc.url);
792
+
793
+ } else {
794
+ await this.listDisplaysFromProvider(cds, cs, c);
795
+ added = await this.includeCode(cs, null, await cs.system(), await cs.version(), await cs.code(c), await cs.isAbstract(c), await cs.isInactive(c), await cs.isDeprecated(c), await cs.getStatus(c),
796
+ cds, await cs.definition(c), await cs.itemWeight(c), expansion, valueSets, await cs.extensions(c), null, await cs.properties(c), null, excludeInactive, vsSrc.url);
797
+ }
783
798
  if (added) {
784
799
  this.addToTotal();
785
800
  }
@@ -799,15 +814,21 @@ class ValueSetExpander {
799
814
  Extensions.checkNoModifiers(cc, 'ValueSetExpander.processCodes', 'set concept reference', vsSrc.vurl);
800
815
  const cctxt = await cs.locate(cc.code, this.allAltCodes);
801
816
  if (cctxt && cctxt.context && (!this.params.activeOnly || !await cs.isInactive(cctxt.context)) && await this.passesFilters(cs, cctxt.context, prep, filters, 0)) {
802
- await this.listDisplaysFromProvider(cds, cs, cctxt.context);
803
- this.listDisplaysFromIncludeConcept(cds, cc, vsSrc);
804
- if (filter.passesDesignations(cds) || filter.passes(cc.code)) {
805
- let ov = Extensions.readString(cc, 'http://hl7.org/fhir/StructureDefinition/itemWeight');
806
- if (!ov) {
807
- ov = await cs.itemWeight(cctxt.context);
817
+ let added;
818
+ if (this.noDetails) {
819
+ added = await this.includeCode(cs, null, cs.system(), cs.version(), cc.code, await cs.isAbstract(cctxt.context), await cs.isInactive(cctxt.context), null, null, cds,
820
+ null, null, expansion, valueSets, null, null, null, null, excludeInactive, vsSrc.url);
821
+ } else {
822
+ await this.listDisplaysFromProvider(cds, cs, cctxt.context);
823
+ this.listDisplaysFromIncludeConcept(cds, cc, vsSrc);
824
+ if (filter.passesDesignations(cds) || filter.passes(cc.code)) {
825
+ let ov = Extensions.readString(cc, 'http://hl7.org/fhir/StructureDefinition/itemWeight');
826
+ if (!ov) {
827
+ ov = await cs.itemWeight(cctxt.context);
828
+ }
829
+ added = await this.includeCode(cs, null, cs.system(), cs.version(), cc.code, await cs.isAbstract(cctxt.context), await cs.isInactive(cctxt.context), await cs.isDeprecated(cctxt.context), await cs.getStatus(cctxt.context), cds,
830
+ await cs.definition(cctxt.context), ov, expansion, valueSets, await cs.extensions(cctxt.context), cc.extension, await cs.properties(cctxt.context), null, excludeInactive, vsSrc.url);
808
831
  }
809
- let added = await this.includeCode(cs, null, cs.system(), cs.version(), cc.code, await cs.isAbstract(cctxt.context), await cs.isInactive(cctxt.context), await cs.isDeprecated(cctxt.context), await cs.getStatus(cctxt.context), cds,
810
- await cs.definition(cctxt.context), ov, expansion, valueSets, await cs.extensions(cctxt.context), cc.extension, await cs.properties(cctxt.context), null, excludeInactive, vsSrc.url);
811
832
  if (added) {
812
833
  this.addToTotal();
813
834
  }
@@ -850,24 +871,33 @@ class ValueSetExpander {
850
871
  }
851
872
 
852
873
  this.worker.opContext.log('iterate filters');
874
+ const cds = new Designations(this.worker.i18n.languageDefinitions);
853
875
  while (await cs.filterMore(prep, fset[0])) {
854
876
  this.worker.deadCheck('processCodes#5');
855
877
  const c = await cs.filterConcept(prep, fset[0]);
856
878
  const ok = (!this.params.activeOnly || !await cs.isInactive(c)) && (await this.passesFilters(cs, c, prep, fset, 1));
857
879
  if (ok) {
880
+ cds.clear();
858
881
  // count++;
859
- const cds = new Designations(this.worker.i18n.languageDefinitions);
860
882
  if (this.passesImports(valueSets, cs.system(), await cs.code(c), 0)) {
861
- await this.listDisplaysFromProvider(cds, cs, c);
862
- let parent = null;
863
- if (cs.hasParents()) {
864
- parent = this.map.get(this.keyS(cs.system(), cs.version(), await cs.parent(c)));
883
+ let added;
884
+ if (this.noDetails) {
885
+ added = await this.includeCode(cs, null, await cs.system(), await cs.version(), await cs.code(c), await cs.isAbstract(c), await cs.isInactive(c),
886
+ null, null, cds, null, null,
887
+ expansion, null, null, null, null, null, excludeInactive, vsSrc.url);
888
+
865
889
  } else {
866
- this.canBeHierarchy = false;
890
+ await this.listDisplaysFromProvider(cds, cs, c);
891
+ let parent = null;
892
+ if (cs.hasParents()) {
893
+ parent = this.map.get(this.keyS(cs.system(), cs.version(), await cs.parent(c)));
894
+ } else {
895
+ this.canBeHierarchy = false;
896
+ }
897
+ added = await this.includeCode(cs, parent, await cs.system(), await cs.version(), await cs.code(c), await cs.isAbstract(c), await cs.isInactive(c),
898
+ await cs.isDeprecated(c), await cs.getStatus(c), cds, await cs.definition(c), await cs.itemWeight(c),
899
+ expansion, null, await cs.extensions(c), null, await cs.properties(c), null, excludeInactive, vsSrc.url);
867
900
  }
868
- let added = await this.includeCode(cs, parent, await cs.system(), await cs.version(), await cs.code(c), await cs.isAbstract(c), await cs.isInactive(c),
869
- await cs.isDeprecated(c), await cs.getStatus(c), cds, await cs.definition(c), await cs.itemWeight(c),
870
- expansion, null, await cs.extensions(c), null, await cs.properties(c), null, excludeInactive, vsSrc.url);
871
901
  if (added) {
872
902
  this.addToTotal();
873
903
  }
@@ -984,7 +1014,7 @@ class ValueSetExpander {
984
1014
  cds.clear();
985
1015
  Extensions.checkNoModifiers(cc, 'ValueSetExpander.processCodes', 'set concept reference', vsSrc.vurl);
986
1016
  const cctxt = await cs.locate(cc.code, this.allAltCodes);
987
- if (cctxt && cctxt.context && (!this.params.activeOnly || !await cs.isInactive(cctxt)) && await this.passesFilters(cs, cctxt, prep, filters, 0)) {
1017
+ if (cctxt && cctxt.context && (!this.params.activeOnly || !await cs.isInactive(cctxt.context)) && await this.passesFilters(cs, cctxt.context, prep, filters, 0)) {
988
1018
  if (filter.passesDesignations(cds) || filter.passes(cc.code)) {
989
1019
  let ov = Extensions.readString(cc, 'http://hl7.org/fhir/StructureDefinition/itemWeight');
990
1020
  if (!ov) {
@@ -1053,9 +1083,16 @@ class ValueSetExpander {
1053
1083
  let n = null;
1054
1084
  if ((!this.params.excludeNotForUI || !await cs.isAbstract(context)) && (!this.params.activeOnly || !await cs.isInactive(context))) {
1055
1085
  const cds = new Designations(this.worker.i18n.languageDefinitions);
1056
- await this.listDisplaysFromProvider(cds, cs, context);
1057
- const t = await this.includeCode(cs, parent, await cs.system(), await cs.version(), context.code, await cs.isAbstract(context), await cs.isInactive(context), await cs.isDeprecated(context), await cs.getStatus(context), cds, await cs.definition(context),
1058
- await cs.itemWeight(context), expansion, imports, await cs.extensions(context), null, await cs.properties(context), null, excludeInactive, srcUrl);
1086
+ let t;
1087
+ if (this.noDetails) {
1088
+ t = await this.includeCode(cs, null, await cs.system(), await cs.version(), context.code, await cs.isAbstract(context), await cs.isInactive(context), null, null, null,
1089
+ null, expansion, imports, null, null, null, null, excludeInactive, srcUrl);
1090
+
1091
+ } else {
1092
+ await this.listDisplaysFromProvider(cds, cs, context);
1093
+ t = await this.includeCode(cs, parent, await cs.system(), await cs.version(), context.code, await cs.isAbstract(context), await cs.isInactive(context), await cs.isDeprecated(context), await cs.getStatus(context), cds, await cs.definition(context),
1094
+ await cs.itemWeight(context), expansion, imports, await cs.extensions(context), null, await cs.properties(context), null, excludeInactive, srcUrl);
1095
+ }
1059
1096
  if (t != null) {
1060
1097
  result++;
1061
1098
  }
@@ -1189,7 +1226,7 @@ class ValueSetExpander {
1189
1226
  return result; // just return the expansion
1190
1227
  }
1191
1228
 
1192
- if (this.params.generateNarrative) {
1229
+ if (this.params.generateNarrative && !this.noDetails) {
1193
1230
  div_ = div();
1194
1231
  table = div_.table("grid");
1195
1232
  } else {
@@ -1203,8 +1240,10 @@ class ValueSetExpander {
1203
1240
 
1204
1241
  if (this.params.limit <= 0) {
1205
1242
  this.limitCount = this.externalLimit;
1206
- } else {
1243
+ } else if (this.externalLimit) {
1207
1244
  this.limitCount = Math.min(this.params.limit, this.externalLimit);
1245
+ } else {
1246
+ this.limitCount = this.params.limit;
1208
1247
  }
1209
1248
  this.offset = this.params.offset;
1210
1249
  this.count = this.params.count;
@@ -1321,8 +1360,10 @@ class ValueSetExpander {
1321
1360
  exp.total = this.total;
1322
1361
  }
1323
1362
  list = this.fullList;
1324
- for (const c of this.fullList) {
1325
- c.contains = undefined;
1363
+ if (!this.noDetails) {
1364
+ for (const c of this.fullList) {
1365
+ c.contains = undefined;
1366
+ }
1326
1367
  }
1327
1368
  if (table != null) {
1328
1369
  div_.addTag('p').setAttribute('style', 'color: Navy').tx('Because of the way that this value set is defined, not all the possible codes can be listed in advance');
@@ -107,10 +107,11 @@ class MetadataHandler {
107
107
  * @returns {Object} CapabilityStatement resource
108
108
  */
109
109
  buildCapabilityStatement(endpoint) {
110
+
110
111
  const now = new Date().toISOString();
111
112
  const fhirVersion = this.mapFhirVersion(endpoint.fhirVersion);
112
113
  const baseUrl = this.config.baseUrl || `https://${this.host}${endpoint.path}`;
113
- const serverVersion = this.config.serverVersion || '1.0.0';
114
+ const serverVersion = this.config.serverVersion;
114
115
 
115
116
  return {
116
117
  resourceType: 'CapabilityStatement',
@@ -124,7 +125,7 @@ class MetadataHandler {
124
125
  },
125
126
  {
126
127
  'url' : 'value',
127
- 'valueCode' : '1.8.0'
128
+ 'valueCode' : this.config.txVersion
128
129
  },
129
130
  {
130
131
  'extension' : [
@@ -231,7 +232,8 @@ class MetadataHandler {
231
232
  ],
232
233
  operation: [
233
234
  { name: 'expand', definition: 'http://hl7.org/fhir/OperationDefinition/ValueSet-expand' },
234
- { name: 'validate-code', definition: 'http://hl7.org/fhir/OperationDefinition/ValueSet-validate-code' }
235
+ { name: 'validate-code', definition: 'http://hl7.org/fhir/OperationDefinition/ValueSet-validate-code' },
236
+ { name: 'related', definition: 'https://raw.githubusercontent.com/HealthIntersections/FHIRsmith/refs/heads/main/tx/data/OperationDefinition-ValueSet-related.json' }
235
237
  ]
236
238
  },
237
239
  {
@@ -264,6 +266,7 @@ class MetadataHandler {
264
266
  { name: 'validate-code', definition: 'http://hl7.org/fhir/OperationDefinition/Resource-validate-code' },
265
267
  { name: 'translate', definition: 'http://hl7.org/fhir/OperationDefinition/ConceptMap-translate' },
266
268
  { name: 'closure', definition: 'http://hl7.org/fhir/OperationDefinition/ConceptMap-closure' },
269
+ { name: 'related', definition: 'https://raw.githubusercontent.com/HealthIntersections/FHIRsmith/refs/heads/main/tx/data/OperationDefinition-ValueSet-related.json' },
267
270
  { name: 'versions', definition: 'http://hl7.org/fhir/OperationDefinition/fhir-versions' }
268
271
  ]
269
272
  }
@@ -80,6 +80,7 @@ class ReadWorker extends TerminologyWorker {
80
80
  async handleCodeSystem(req, res, id) {
81
81
  let cs = this.provider.getCodeSystemById(this.opContext, id);
82
82
  if (cs != null) {
83
+ req.sourcePackage = cs.sourcePackage;
83
84
  return res.json(cs.jsonObj);
84
85
  }
85
86
 
@@ -145,6 +146,7 @@ class ReadWorker extends TerminologyWorker {
145
146
  this.deadCheck('handleValueSet-loop');
146
147
  const vs = await vsp.fetchValueSetById(id);
147
148
  if (vs) {
149
+ req.sourcePackage = vs.sourcePackage;
148
150
  return res.json(vs.jsonObj);
149
151
  }
150
152
  }
@@ -165,9 +167,10 @@ class ReadWorker extends TerminologyWorker {
165
167
  // Iterate through valueSetProviders in order
166
168
  for (const cmsp of this.provider.conceptMapProviders) {
167
169
  this.deadCheck('handleConceptMap-loop');
168
- const vs = await cmsp.fetchConceptMapById(id);
169
- if (vs) {
170
- return res.json(vs.jsonObj);
170
+ const cm = await cmsp.fetchConceptMapById(id);
171
+ if (cm) {
172
+ req.sourcePackage = cm.sourcePackage;
173
+ return res.json(cm.jsonObj);
171
174
  }
172
175
  }
173
176