fhirsmith 0.17.0 → 0.18.1
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 +113 -0
- package/README.md +80 -13
- package/config-template.json +106 -1
- package/ips/ai-client.js +263 -0
- package/ips/composer.js +805 -0
- package/ips/editor-schema.js +289 -0
- package/ips/editor.js +290 -0
- package/ips/fhirpath-ips.js +397 -0
- package/ips/ips-codeable-concepts.md +1742 -0
- package/ips/ips-template.html +125 -0
- package/ips/ips-valuesets.js +159 -0
- package/ips/ips.js +1736 -0
- package/ips/membership.js +179 -0
- package/ips/pipeline.js +1012 -0
- package/ips/presenter.js +974 -0
- package/ips/profile-editor.js +578 -0
- package/ips/profiles.js +506 -0
- package/ips/readme.md +460 -0
- package/ips/render.js +1482 -0
- package/ips/search-params.js +83 -0
- package/ips/search.js +667 -0
- package/ips/share.js +178 -0
- package/ips/store.js +650 -0
- package/ips/terminology.js +395 -0
- package/ips/tx-client.js +202 -0
- package/ips/valuesets/CodeSystem-absent-unknown-uv-ips.json +206 -0
- package/ips/valuesets/ValueSet-absent-or-unknown-immunizations-uv-ips.json +59 -0
- package/ips/valuesets/ValueSet-ips-allergy-code.json +59 -0
- package/ips/valuesets/ValueSet-ips-allergy-manifestation.json +356 -0
- package/ips/valuesets/ValueSet-ips-allergy-substance.json +37 -0
- package/ips/valuesets/ValueSet-ips-body-site.json +26 -0
- package/ips/valuesets/ValueSet-ips-clinical-finding-or-none.json +35 -0
- package/ips/valuesets/ValueSet-ips-clinical-finding.json +26 -0
- package/ips/valuesets/ValueSet-ips-condition-code.json +72 -0
- package/ips/valuesets/ValueSet-ips-condition-severity.json +30 -0
- package/ips/valuesets/ValueSet-ips-condition-stage.json +26 -0
- package/ips/valuesets/ValueSet-ips-exposure-route.json +26 -0
- package/ips/valuesets/ValueSet-ips-imaging-procedure.json +25 -0
- package/ips/valuesets/ValueSet-ips-immunization-status-reason.json +43 -0
- package/ips/valuesets/ValueSet-ips-international-codes.json +25 -0
- package/ips/valuesets/ValueSet-ips-medication-ingredient.json +26 -0
- package/ips/valuesets/ValueSet-ips-medication-status-reason.json +37 -0
- package/ips/valuesets/ValueSet-ips-medication.json +50 -0
- package/ips/valuesets/ValueSet-ips-observation-code.json +18 -0
- package/ips/valuesets/ValueSet-ips-observation-interpretation.json +18 -0
- package/ips/valuesets/ValueSet-ips-procedure-followup.json +51 -0
- package/ips/valuesets/ValueSet-ips-procedure-outcome.json +30 -0
- package/ips/valuesets/ValueSet-ips-procedure-reason.json +37 -0
- package/ips/valuesets/ValueSet-ips-procedure.json +116 -0
- package/ips/valuesets/ValueSet-ips-route.json +46 -0
- package/ips/valuesets/ValueSet-ips-target-disease.json +171 -0
- package/ips/valuesets/ValueSet-ips-vaccine.json +31 -0
- package/ips/valuesets/elements.json +44 -0
- package/library/daily-report.js +432 -0
- package/library/fhir-search-values.js +138 -0
- package/library/html-server.js +32 -23
- package/library/mailer.js +77 -0
- package/library/narrative-check.js +21 -2
- package/library/npm-audit.js +25 -0
- package/library/package-manager.js +4 -2
- package/library/sqlite-session-store.js +29 -1
- package/package.json +8 -3
- package/packages/packages.js +34 -3
- package/publisher/publisher.js +29 -0
- package/registry/auth-store.js +366 -0
- package/registry/auth.js +872 -0
- package/registry/crawler.js +41 -1
- package/registry/documentation/api.md +162 -0
- package/registry/documentation/configuration.md +93 -0
- package/registry/documentation/documents.md +74 -0
- package/registry/documentation/internals.md +151 -0
- package/registry/documentation/readme.md +100 -0
- package/registry/documentation/security.md +199 -0
- package/registry/documents.js +309 -0
- package/registry/openapi.yaml +30 -0
- package/registry/registry-template.html +1 -1
- package/registry/registry.js +230 -44
- package/registry/uptime.js +154 -0
- package/server.js +105 -44
- package/shl/shl.js +64 -9
- package/stats-db.js +93 -0
- package/stats.js +158 -1
- package/testing/search.js +2 -108
- package/testing/store.js +5 -0
- package/testing/testing.js +20 -0
- package/token/token-template.html +5 -4
- package/token/token.js +17 -10
- package/translations/Messages.properties +10 -0
- package/tx/README.md +52 -0
- package/tx/closure/closure-store.js +14 -0
- package/tx/cs/cs-api.js +92 -14
- package/tx/cs/cs-cs.js +64 -3
- package/tx/cs/cs-icd11.js +366 -112
- package/tx/cs/cs-icf.js +431 -0
- package/tx/cs/cs-loinc.js +296 -27
- package/tx/cs/cs-omop.js +10 -3
- package/tx/cs/cs-snomed.js +1210 -80
- package/tx/cs/cs-ucum.js +6 -0
- package/tx/cs/icd11-expressions.js +191 -78
- package/tx/importers/csv-records.js +35 -0
- package/tx/importers/export-icd11-codesystem.js +58 -12
- package/tx/importers/icd11-schema.md +9 -5
- package/tx/importers/import-loinc.module.js +177 -41
- package/tx/importers/import-sct.module.js +66 -1
- package/tx/importers/subset-loinc.module.js +25 -6
- package/tx/library/codesystem.js +4 -1
- package/tx/library/designations.js +23 -30
- package/tx/library.js +98 -4
- package/tx/openapi-operations.js +6 -1
- package/tx/params.js +8 -1
- package/tx/provider.js +24 -6
- package/tx/sct/documentation.md +251 -0
- package/tx/sct/ecl.js +758 -46
- package/tx/sct/expressions.js +113 -52
- package/tx/sct/structures.js +8 -2
- package/tx/syndication/syndication-feed.js +218 -0
- package/tx/syndication/syndication-store.js +415 -0
- package/tx/tx-html.js +15 -1
- package/tx/tx.fhir.org.yml +3 -4
- package/tx/tx.js +144 -2
- package/tx/vs/vs-vsac.js +25 -6
- package/tx/workers/closure.js +20 -0
- package/tx/workers/expand.js +35 -8
- package/tx/workers/lookup.js +61 -6
- package/tx/workers/subsumes.js +1 -1
- package/tx/workers/translate.js +166 -15
- package/tx/workers/validate.js +138 -6
- package/utilities/make-sct-loinc-subset.js +250 -0
- package/utilities/make-sct-test-extension.js +264 -0
- package/xig/xig.js +32 -0
- package/registry/readme.md +0 -124
package/tx/cs/cs-api.js
CHANGED
|
@@ -67,19 +67,89 @@ class CodeSystemProvider {
|
|
|
67
67
|
*/
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* The
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* The name of the code system (CodeSystem.name, or the provider's equivalent). Every
|
|
71
|
+
* provider should override this; the fallback is the versioned uri, which is not a name,
|
|
72
|
+
* and a provider that forgets ends up reporting
|
|
73
73
|
* "http://snomed.info/sct|http://snomed.info/sct/731000124108/version/20230301" where
|
|
74
74
|
* the others report "LOINC".
|
|
75
|
+
* @returns {string} name of the code system
|
|
76
|
+
*/
|
|
77
|
+
name() { return this.system() + (this.version() ? "|"+this.version() : "") }
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* What $lookup reports as its `name` parameter - "a display name for the code system".
|
|
81
|
+
* That is the title, translated into the request's language where the provider can,
|
|
82
|
+
* falling back to name(). Only $lookup uses this; everything else keeps using name().
|
|
83
|
+
* The default has no title to offer, so it is name().
|
|
84
|
+
* @param {Languages} [languages] - the request's working languages (displayLanguage, else
|
|
85
|
+
* Accept-Language)
|
|
75
86
|
* @returns {string} display name for the code system
|
|
76
87
|
*/
|
|
88
|
+
// eslint-disable-next-line no-unused-vars
|
|
89
|
+
lookupName(languages) { return this.name(); }
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A second, shorter form of the code that some code systems also carry - ICD-11's short
|
|
93
|
+
* classification code (1A00) beside its code, the entity uri. $validate-code reports it as
|
|
94
|
+
* the classificationCode output parameter when the request used the code itself, and
|
|
95
|
+
* $expand always reports it as a contains property. Null (the default) when there is none.
|
|
96
|
+
* @param {CodeSystemProviderContext} context
|
|
97
|
+
* @returns {Promise<string|null>}
|
|
98
|
+
*/
|
|
99
|
+
// eslint-disable-next-line no-unused-vars
|
|
100
|
+
async classificationCode(context) { return null; }
|
|
101
|
+
|
|
77
102
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
103
|
+
* The classificationCode $validate-code reports for a code as it was given: by default the
|
|
104
|
+
* concept's classificationCode, whatever spelling was used.
|
|
105
|
+
* @param {CodeSystemProviderContext} context the concept the code located
|
|
106
|
+
* @param {string} code the code as given
|
|
107
|
+
* @returns {Promise<string|null>}
|
|
80
108
|
*/
|
|
81
109
|
// eslint-disable-next-line no-unused-vars
|
|
82
|
-
|
|
110
|
+
async reportedClassificationCode(context, code) { return this.classificationCode(context); }
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The code to put in an expansion for a concept the value set enumerated as `requested`.
|
|
114
|
+
* The default keeps the value set's own spelling; a code system whose normal form differs
|
|
115
|
+
* from what a value set may write (ICD-11: short code vs entity uri) returns code().
|
|
116
|
+
* @param {CodeSystemProviderContext} context
|
|
117
|
+
* @param {string} requested - the code as the value set wrote it
|
|
118
|
+
* @returns {Promise<string>}
|
|
119
|
+
*/
|
|
120
|
+
// eslint-disable-next-line no-unused-vars
|
|
121
|
+
async expansionCode(context, requested) { return requested; }
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Properties an expansion carries on every contains entry whatever the request asked
|
|
125
|
+
* for (each must also come back from properties()). None by default.
|
|
126
|
+
* @returns {string[]}
|
|
127
|
+
*/
|
|
128
|
+
mandatoryExpansionProperties() { return []; }
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Check the extensions on a Coding that this code system defines - ICD-11's
|
|
132
|
+
* classificationCode, say. Called by $validate-code once the coding's code has validated.
|
|
133
|
+
* Extensions the code system does not define are not its business, and are ignored.
|
|
134
|
+
*
|
|
135
|
+
* @param {Object} coding the Coding as given
|
|
136
|
+
* @param {CodeSystemProviderContext} context the concept the code located
|
|
137
|
+
* @returns {Promise<{index: number, msgId: string, params: string[]}[]>} one entry per problem,
|
|
138
|
+
* naming the extension (its index in coding.extension) and the message; none by default
|
|
139
|
+
*/
|
|
140
|
+
// eslint-disable-next-line no-unused-vars
|
|
141
|
+
async checkCodingExtensions(coding, context) { return []; }
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Things $validate-code should say about a code that is valid - for a postcoordinated
|
|
145
|
+
* expression, say, a qualifier the grammar allows but a rule of the code system does not
|
|
146
|
+
* (ICD-11: two values on an axis that takes one).
|
|
147
|
+
*
|
|
148
|
+
* @param {CodeSystemProviderContext} context the concept the code located
|
|
149
|
+
* @returns {Promise<{severity: string, msgId: string, params: string[]}[]>} none by default
|
|
150
|
+
*/
|
|
151
|
+
// eslint-disable-next-line no-unused-vars
|
|
152
|
+
async codeIssues(context) { return []; }
|
|
83
153
|
|
|
84
154
|
/**
|
|
85
155
|
* @returns {string} uri for the code system
|
|
@@ -540,9 +610,11 @@ class CodeSystemProvider {
|
|
|
540
610
|
* @param {CodeSystemProviderContext} ctxt the context to add properties for
|
|
541
611
|
* @param {string[]} props the properties requested
|
|
542
612
|
* @param {Parameters} params the parameters response to add to
|
|
613
|
+
* @param {TxParameters} [txParams] the parsed request parameters, for providers whose output
|
|
614
|
+
* depends on more than the property list (ICD-11's post-coordination-metadata)
|
|
543
615
|
*/
|
|
544
|
-
|
|
545
|
-
async extendLookup(ctxt, props, params) { }
|
|
616
|
+
// eslint-disable-next-line no-unused-vars
|
|
617
|
+
async extendLookup(ctxt, props, params, txParams) { }
|
|
546
618
|
|
|
547
619
|
// procedure getCDSInfo(card : TCDSHookCard; langList : THTTPLanguageList; baseURL, code, display : String); virtual;
|
|
548
620
|
|
|
@@ -954,15 +1026,21 @@ class CodeSystemFactoryProvider {
|
|
|
954
1026
|
}
|
|
955
1027
|
|
|
956
1028
|
/**
|
|
957
|
-
*
|
|
1029
|
+
* Add any concept maps this code system implies for translating from source
|
|
1030
|
+
* (a system URI, with the version of the source coding, which may be empty)
|
|
1031
|
+
* to dest (a system URI, possibly with |version).
|
|
958
1032
|
*
|
|
959
|
-
*
|
|
1033
|
+
* The conceptmap is never visible to a user; if it has an internalSource, then
|
|
960
1034
|
* provider.getTranslations will be called when it's actually used
|
|
961
|
-
* @param
|
|
962
|
-
* @param
|
|
963
|
-
* @
|
|
1035
|
+
* @param conceptMaps - the list to add to
|
|
1036
|
+
* @param source - the source system URI
|
|
1037
|
+
* @param sourceVersion - the version of the source coding (may be null)
|
|
1038
|
+
* @param dest - the target system URI, possibly with |version
|
|
1039
|
+
* @param code - the code being translated, if known (under reverse, the target concept's
|
|
1040
|
+
* code), so a provider can leave out a map that has nothing to say about it
|
|
964
1041
|
*/
|
|
965
|
-
|
|
1042
|
+
// eslint-disable-next-line no-unused-vars
|
|
1043
|
+
async findImplicitConceptMaps(conceptMaps, source, sourceVersion, dest, code = null) {
|
|
966
1044
|
return null;
|
|
967
1045
|
}
|
|
968
1046
|
|
package/tx/cs/cs-cs.js
CHANGED
|
@@ -171,7 +171,35 @@ class FhirCodeSystemProviderFilterContext {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
// Code systems loaded as ordinary CodeSystem resources (from a package, or supplied by a
|
|
175
|
+
// client) that need behaviour beyond the resource: a grammar, say. Keyed on the CodeSystem
|
|
176
|
+
// url; the class extends FhirCodeSystemProvider, so the content still comes from the
|
|
177
|
+
// resource. Required lazily, because the subclasses require this module.
|
|
178
|
+
let specialisedProviders = null;
|
|
179
|
+
|
|
180
|
+
function providerClassFor(url) {
|
|
181
|
+
if (specialisedProviders === null) {
|
|
182
|
+
specialisedProviders = new Map([
|
|
183
|
+
['http://hl7.org/fhir/sid/icf', require('./cs-icf').IcfCodeSystemProvider]
|
|
184
|
+
]);
|
|
185
|
+
}
|
|
186
|
+
return specialisedProviders.get(url) || FhirCodeSystemProvider;
|
|
187
|
+
}
|
|
188
|
+
|
|
174
189
|
class FhirCodeSystemProvider extends BaseCSServices {
|
|
190
|
+
/**
|
|
191
|
+
* The provider for a CodeSystem resource: a FhirCodeSystemProvider, or the subclass
|
|
192
|
+
* registered for its url. Always use this rather than the constructor.
|
|
193
|
+
* @param {OperationContext} opContext
|
|
194
|
+
* @param {CodeSystem} codeSystem
|
|
195
|
+
* @param {CodeSystem[]} supplements
|
|
196
|
+
* @returns {FhirCodeSystemProvider}
|
|
197
|
+
*/
|
|
198
|
+
static create(opContext, codeSystem, supplements) {
|
|
199
|
+
const cls = providerClassFor(codeSystem.url);
|
|
200
|
+
return new cls(opContext, codeSystem, supplements);
|
|
201
|
+
}
|
|
202
|
+
|
|
175
203
|
/**
|
|
176
204
|
* @param {CodeSystem} codeSystem - The primary CodeSystem
|
|
177
205
|
* @param {CodeSystem[]} supplements - Array of supplement CodeSystems
|
|
@@ -197,6 +225,33 @@ class FhirCodeSystemProvider extends BaseCSServices {
|
|
|
197
225
|
return this.codeSystem.jsonObj.name || '';
|
|
198
226
|
}
|
|
199
227
|
|
|
228
|
+
/**
|
|
229
|
+
* $lookup's display name: CodeSystem.title, translated where the resource carries a
|
|
230
|
+
* translation for one of the request's languages, else the title as written, else name.
|
|
231
|
+
* @param {Languages} [languages] - the request's working languages
|
|
232
|
+
* @returns {string}
|
|
233
|
+
*/
|
|
234
|
+
lookupName(languages) {
|
|
235
|
+
const cs = this.codeSystem.jsonObj;
|
|
236
|
+
if (!cs.title) return this.name();
|
|
237
|
+
const base = (c) => String(c || '').toLowerCase().split('-')[0];
|
|
238
|
+
const translations = (cs._title?.extension || [])
|
|
239
|
+
.filter(e => e.url === 'http://hl7.org/fhir/StructureDefinition/translation')
|
|
240
|
+
.map(e => ({
|
|
241
|
+
lang: (e.extension || []).find(x => x.url === 'lang')?.valueCode,
|
|
242
|
+
content: (e.extension || []).find(x => x.url === 'content')?.valueString,
|
|
243
|
+
}))
|
|
244
|
+
.filter(t => t.lang && t.content);
|
|
245
|
+
for (const l of languages || []) {
|
|
246
|
+
const want = base(l.language || l.code);
|
|
247
|
+
if (!want) continue;
|
|
248
|
+
if (cs.language && base(cs.language) === want) return cs.title;
|
|
249
|
+
const t = translations.find(t => base(t.lang) === want);
|
|
250
|
+
if (t) return t.content;
|
|
251
|
+
}
|
|
252
|
+
return cs.title;
|
|
253
|
+
}
|
|
254
|
+
|
|
200
255
|
/**
|
|
201
256
|
* @returns {string} URI for the code system
|
|
202
257
|
*/
|
|
@@ -972,11 +1027,17 @@ class FhirCodeSystemProvider extends BaseCSServices {
|
|
|
972
1027
|
return;
|
|
973
1028
|
}
|
|
974
1029
|
|
|
975
|
-
// Add properties if
|
|
976
|
-
|
|
1030
|
+
// Add the concept's properties: each one if it was asked for by its code (or '*', or nothing
|
|
1031
|
+
// was asked for). 'property' asks for all of them - it used to be the only thing that did, so
|
|
1032
|
+
// asking for a property by its own code returned nothing. A code the server doesn't know is
|
|
1033
|
+
// simply not matched
|
|
1034
|
+
{
|
|
977
1035
|
const properties = await this.properties(ctxt);
|
|
978
1036
|
if (properties) {
|
|
979
1037
|
for (const property of properties) {
|
|
1038
|
+
if (!this._hasProp(props, property.code, true) && !this._hasProp(props, 'property', true)) {
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
980
1041
|
let parts = [];
|
|
981
1042
|
parts.push({ name: 'code', valueCode: property.code });
|
|
982
1043
|
|
|
@@ -1747,7 +1808,7 @@ class FhirCodeSystemFactory extends CodeSystemFactoryProvider {
|
|
|
1747
1808
|
});
|
|
1748
1809
|
}
|
|
1749
1810
|
|
|
1750
|
-
return
|
|
1811
|
+
return FhirCodeSystemProvider.create(opContext, codeSystem, supplements);
|
|
1751
1812
|
}
|
|
1752
1813
|
|
|
1753
1814
|
// eslint-disable-next-line no-unused-vars
|