@aehrc/ecl-core 1.8.0 → 1.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.
- package/README.md +59 -5
- package/dist/derive/compress-expression.d.ts +2 -0
- package/dist/derive/compress-expression.d.ts.map +1 -1
- package/dist/derive/derive-ecl.d.ts +62 -3
- package/dist/derive/derive-ecl.d.ts.map +1 -1
- package/dist/derive/refinements.d.ts +1 -1
- package/dist/derive/refinements.d.ts.map +1 -1
- package/dist/derive/set-queries.d.ts +72 -1
- package/dist/derive/set-queries.d.ts.map +1 -1
- package/dist/derive/taxonomy-graph.d.ts +58 -0
- package/dist/derive/taxonomy-graph.d.ts.map +1 -1
- package/dist/index.cjs +1086 -140
- package/dist/index.mjs +1086 -140
- package/dist/terminology/fhir-service.d.ts +49 -0
- package/dist/terminology/fhir-service.d.ts.map +1 -1
- package/dist/terminology/types.d.ts +26 -0
- package/dist/terminology/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,6 +138,7 @@ const fhir = new FhirTerminologyService({
|
|
|
138
138
|
baseUrl: 'https://tx.ontoserver.csiro.au/fhir', // default
|
|
139
139
|
timeout: 2000, // lookup timeout (ms)
|
|
140
140
|
snomedVersion: '', // SNOMED version URI (empty = server default)
|
|
141
|
+
rateLimitWaitMs: 60_000, // how long one request may wait out HTTP 429s
|
|
141
142
|
});
|
|
142
143
|
|
|
143
144
|
const concept = await fhir.getConceptInfo('404684003');
|
|
@@ -147,6 +148,15 @@ const results = await fhir.evaluateEcl('< 404684003');
|
|
|
147
148
|
// { concepts: [...], total }
|
|
148
149
|
```
|
|
149
150
|
|
|
151
|
+
Rate limits: when the server says its allowance is spent (a 429, or
|
|
152
|
+
`x-ratelimit-remaining: 0`), every request of the service waits for the reset
|
|
153
|
+
it gives (`Retry-After` or `x-ratelimit-reset`), up to `rateLimitWaitMs` per
|
|
154
|
+
request, rather than failing. When the limit resets, held requests go oldest
|
|
155
|
+
first, as many at a time as the server says it has room for. This applies to
|
|
156
|
+
every user of the service (hovers, diagnostics, derive), so a request can take
|
|
157
|
+
that long on a rate-limited server, or longer when many are queued: the budget
|
|
158
|
+
is checked after each 429, not while a request waits its turn.
|
|
159
|
+
|
|
150
160
|
### Deriving ECL from a Concept List
|
|
151
161
|
|
|
152
162
|
The opposite of `$expand`: given a code list or a reference set, propose ECL
|
|
@@ -173,11 +183,15 @@ additions reported), a greedy grouping, a cost-based cover, and always the
|
|
|
173
183
|
enumeration or `^ refset` itself. They are ranked by clauses + additions +
|
|
174
184
|
misses.
|
|
175
185
|
|
|
176
|
-
The hierarchy candidates are built from one IS-A subgraph around the set
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
The hierarchy candidates are built from one IS-A subgraph around the set. For
|
|
187
|
+
a list (`walkGraph`, the default) it is walked: the codes are looked up in
|
|
188
|
+
chunks of 10,000 with their activity, parents and children (`expandCompose`
|
|
189
|
+
with `parents`/`children`, FHIR `property=parent`/`property=child`), then each
|
|
190
|
+
new level of ancestors, and then below the ancestors worth trying as groupers,
|
|
191
|
+
level by level. No request carries the list as ECL. A server that does not
|
|
192
|
+
return children, or does not flag inactive concepts in an expansion, gets the
|
|
193
|
+
older path: about four expansions that carry the set as ECL and return
|
|
194
|
+
parents. Candidates are built and ranked on that graph without further
|
|
181
195
|
requests, and only the best are counted again on the server, so every count
|
|
182
196
|
reported comes from the server. A graph candidate that by its local counts
|
|
183
197
|
costs at least as much as the input itself (listing every member, or the
|
|
@@ -220,6 +234,46 @@ value, a range with `>=` and `<=`, or `= *`) and cardinalities
|
|
|
220
234
|
(`[2..*] attribute = *`). When no refinement is exact, a subtraction
|
|
221
235
|
`(C) MINUS (D)` is also tried, with D describing what the refinement C adds.
|
|
222
236
|
|
|
237
|
+
Lists that are one slice of a hierarchy, such as an AMT list of MPUUs under
|
|
238
|
+
its drug classes, also get a **restricted cover**, `(<< A OR << B …) AND ^ R`,
|
|
239
|
+
exact by construction: the groupers alone would add concepts outside the
|
|
240
|
+
slice, and `R` removes them. `restrictTo: 'auto'` (the default) uses the AMT
|
|
241
|
+
level reference set that holds every member when all of them are medicinal
|
|
242
|
+
products, and does nothing otherwise; give an expression to use it instead, or
|
|
243
|
+
`''` to turn the cover off. Once this cover is exact, the attribute-refinement
|
|
244
|
+
search is skipped in `'auto'` mode.
|
|
245
|
+
|
|
246
|
+
#### Incomplete results
|
|
247
|
+
|
|
248
|
+
Derive goes on when a server request fails (times out, is rate-limited past
|
|
249
|
+
`rateLimitWaitMs`, or answers 5xx): it drops what the request was for and adds
|
|
250
|
+
a note. `result.failures` counts the requests whose loss changed the result,
|
|
251
|
+
and `formatDeriveReport` then starts with "Incomplete: N server queries
|
|
252
|
+
failed". A request whose failure derive makes up for with others is not
|
|
253
|
+
counted. Check `failures` before treating a long enumeration as "no rule
|
|
254
|
+
exists": with every count failing, the enumeration is all that is left.
|
|
255
|
+
`compressExpression` reports `failures` the same way.
|
|
256
|
+
|
|
257
|
+
#### Large lists
|
|
258
|
+
|
|
259
|
+
These options keep large lists cheap for the server and for memory. All but
|
|
260
|
+
`localScoring` are on by default.
|
|
261
|
+
|
|
262
|
+
| Option | Default | Effect |
|
|
263
|
+
| ------------------ | ------- | ----------------------------------------------------------------------------------------------------- |
|
|
264
|
+
| `walkGraph` | `true` | Build the graph by looking codes up in chunks, as above |
|
|
265
|
+
| `batchLookups` | `true` | Read the refinement sample's relationships in one FHIR batch request (`getDefiningRelationshipsMany`) |
|
|
266
|
+
| `scopedExclusions` | `true` | Count a near miss's additions excluding only the members below it, not the whole list |
|
|
267
|
+
| `parallelPages` | `true` | Ask for the later pages of a multi-page expansion at once |
|
|
268
|
+
| `localScoring` | `false` | Count graph candidates on the graph and check only the best on the server |
|
|
269
|
+
|
|
270
|
+
Measured on `tx.ontoserver.csiro.au` with an 87,000-code list, all to the same
|
|
271
|
+
result: with the defaults, 32–40 s, 37 requests and 22 MB uploaded (most of it
|
|
272
|
+
the list, sent with each candidate's server count); with `localScoring` on,
|
|
273
|
+
11–13 s, 29 requests and 2.5 MB; before these options, 207 s and 69 MB. In a 512 MiB container (`node:20-alpine`) that list peaks at 136 MB of
|
|
274
|
+
heap and a 195,000-code list at 164 MB. Above `maxGraphConcepts` (200,000)
|
|
275
|
+
derive falls back to a query per count, which is slow.
|
|
276
|
+
|
|
223
277
|
`deriveEcl({ ecl }, terminology)` takes the set an expression selects. For
|
|
224
278
|
pasted text, `deriveInputFromText(text)` picks the input: a list of bare
|
|
225
279
|
concepts joined by OR, AND or commas becomes `{ conceptIds }` (so inactive and
|
|
@@ -42,6 +42,8 @@ export interface CompressResult {
|
|
|
42
42
|
notes: string[];
|
|
43
43
|
/** Syntax errors; the expression is not compressed when there are any. */
|
|
44
44
|
errors: string[];
|
|
45
|
+
/** Server requests that failed; above 0 a shorter form may be missing (see `DeriveResult.failures`). */
|
|
46
|
+
failures: number;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Propose shorter forms of an ECL expression, each with exact counts and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress-expression.d.ts","sourceRoot":"","sources":["../../src/derive/compress-expression.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"compress-expression.d.ts","sourceRoot":"","sources":["../../src/derive/compress-expression.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAKL,KAAK,qBAAqB,EAE1B,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyD,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1G,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,SAAS,EAAE,aAAa,CAAC;IACzB,sDAAsD;IACtD,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC;IAC9C,kEAAkE;IAClE,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3D,yEAAyE;IACzE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,wGAAwG;IACxG,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,mBAAmB,EAChC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAKzB;AAmMD,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAqBnE"}
|
|
@@ -39,12 +39,13 @@ export interface DeriveOptions {
|
|
|
39
39
|
/**
|
|
40
40
|
* Attribute refinement candidates (`focus : attribute = value`):
|
|
41
41
|
* `'auto'` builds them when the set cuts across the IS-A hierarchy: more than
|
|
42
|
-
* 20 roots, or more than 3 with no exact IS-A candidate of 3 clauses or fewer
|
|
42
|
+
* 20 roots, or more than 3 with no exact IS-A candidate of 3 clauses or fewer;
|
|
43
|
+
* never when an exact cover within a reference set was found (see `restrictTo`).
|
|
43
44
|
* Default `'auto'`. Needs `getDefiningRelationships`.
|
|
44
45
|
*/
|
|
45
46
|
refinements?: 'auto' | 'always' | 'never';
|
|
46
47
|
/**
|
|
47
|
-
* The focus for refinement candidates, e.g. `^
|
|
48
|
+
* The focus for refinement candidates, e.g. `^ 929360071000036103` for AMT
|
|
48
49
|
* MPUUs. Default: `<<` the most specific concept above every member.
|
|
49
50
|
*/
|
|
50
51
|
refinementFocus?: string;
|
|
@@ -80,6 +81,42 @@ export interface DeriveOptions {
|
|
|
80
81
|
* `true` uses the defaults of {@link CritiqueOptions}. Default false.
|
|
81
82
|
*/
|
|
82
83
|
critique?: boolean | CritiqueOptions;
|
|
84
|
+
/**
|
|
85
|
+
* Build a cover that is exact within this expression, `(<< A OR << B …) AND R`,
|
|
86
|
+
* for sets that are one slice of a hierarchy: a reference set's members under
|
|
87
|
+
* a few groupers, where the groupers alone add the concepts outside it (an
|
|
88
|
+
* AMT list of MPUUs under its drug classes). `'auto'` uses the AMT level
|
|
89
|
+
* reference set holding every member when all of them are medicinal
|
|
90
|
+
* products, and is a no-op otherwise; `''` turns the cover off. Graph path
|
|
91
|
+
* only. Default `'auto'`.
|
|
92
|
+
*/
|
|
93
|
+
restrictTo?: string;
|
|
94
|
+
/** Fetch the later pages of a multi-page expansion concurrently. Default true. */
|
|
95
|
+
parallelPages?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Take graph candidates' counts from the graph instead of the server, and
|
|
98
|
+
* check only the best candidate on the server (falling back to server counts
|
|
99
|
+
* for all when its count differs). Default false.
|
|
100
|
+
*/
|
|
101
|
+
localScoring?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* When counting what a grouper adds (near misses), exclude only the members
|
|
104
|
+
* below it, which the graph knows, not the whole set. Default true.
|
|
105
|
+
*/
|
|
106
|
+
scopedExclusions?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Resolve a list by looking its codes up in chunks, with parents and
|
|
109
|
+
* children, and build the IS-A graph by walking from there instead of with
|
|
110
|
+
* queries that carry the list as ECL. Falls back to those queries on a
|
|
111
|
+
* server that does not return `property=child`, or does not flag inactive
|
|
112
|
+
* concepts in an expansion. Default true.
|
|
113
|
+
*/
|
|
114
|
+
walkGraph?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Read the refinement sample's relationships in one FHIR batch request,
|
|
117
|
+
* falling back to one lookup each when the server refuses it. Default true.
|
|
118
|
+
*/
|
|
119
|
+
batchLookups?: boolean;
|
|
83
120
|
}
|
|
84
121
|
/** Limits for {@link CodelistCritique}. */
|
|
85
122
|
export interface CritiqueOptions {
|
|
@@ -187,6 +224,12 @@ export type CandidateConstruction = {
|
|
|
187
224
|
includes: HierarchyClause[];
|
|
188
225
|
/** Clauses subtracted with MINUS. */
|
|
189
226
|
exclusions: HierarchyClause[];
|
|
227
|
+
} | {
|
|
228
|
+
/** A cover exact within `restrictTo`: the clauses ORed, then `AND restrictTo`. */
|
|
229
|
+
kind: 'restricted-cover';
|
|
230
|
+
restrictTo: string;
|
|
231
|
+
/** The highest concepts with no non-member of `restrictTo` below them, as `<< x`; a member that has one, as `= x`. */
|
|
232
|
+
includes: HierarchyClause[];
|
|
190
233
|
} | {
|
|
191
234
|
kind: 'ancestor-cover';
|
|
192
235
|
/** The clauses, in the order chosen: `<< member` or `< ancestor` (a non-member). */
|
|
@@ -243,6 +286,14 @@ export interface DeriveResult {
|
|
|
243
286
|
notes: string[];
|
|
244
287
|
/** Structural checks on the list, when the `critique` option asks for them. */
|
|
245
288
|
critique?: CodelistCritique;
|
|
289
|
+
/**
|
|
290
|
+
* Server requests that failed (unreachable, timed out, rate-limited, 5xx).
|
|
291
|
+
* Each drops a candidate or a check rather than the result, so above 0 the
|
|
292
|
+
* result is incomplete: a candidate the server could not count is missing,
|
|
293
|
+
* and the best one left may be far worse than the best that exists. `notes`
|
|
294
|
+
* says what was lost.
|
|
295
|
+
*/
|
|
296
|
+
failures: number;
|
|
246
297
|
}
|
|
247
298
|
/**
|
|
248
299
|
* Propose ECL expressions for a set of concepts, ranked, each with exact counts
|
|
@@ -252,10 +303,16 @@ export interface DeriveResult {
|
|
|
252
303
|
* @throws `TerminologyTransportError` / `TerminologyHttpError` when the server fails.
|
|
253
304
|
*/
|
|
254
305
|
export declare function deriveEcl(input: DeriveInput, terminology: ITerminologyService, options?: DeriveOptions): Promise<DeriveResult>;
|
|
306
|
+
/**
|
|
307
|
+
* Preferred terms for the ids in the candidates worth decorating. Terms are
|
|
308
|
+
* decoration: when the lookup fails, the candidates go out with bare ids and,
|
|
309
|
+
* given `notes`, a note says why (the failure itself is counted by the caller's
|
|
310
|
+
* service), rather than losing a finished result.
|
|
311
|
+
*/
|
|
255
312
|
export declare function displayTerms(candidates: {
|
|
256
313
|
ecl: string;
|
|
257
314
|
clauses: number;
|
|
258
|
-
}[], terminology: ITerminologyService): Promise<Map<string, string>>;
|
|
315
|
+
}[], terminology: ITerminologyService, notes?: string[]): Promise<Map<string, string>>;
|
|
259
316
|
/** Add display terms and format, unless the candidate is too long to be worth it. */
|
|
260
317
|
export declare function decorate(ecl: string, terms: Map<string, string>): string;
|
|
261
318
|
/**
|
|
@@ -275,4 +332,6 @@ export declare function parseConceptIdList(text: string): string[];
|
|
|
275
332
|
export declare function deriveInputFromText(text: string): DeriveInput;
|
|
276
333
|
/** A plain-text report of a {@link DeriveResult}, for an output channel or a chat message. */
|
|
277
334
|
export declare function formatDeriveReport(result: DeriveResult): string;
|
|
335
|
+
/** The first line of a report whose result lost candidates or checks to server failures. */
|
|
336
|
+
export declare function incompleteLine(failures: number): string;
|
|
278
337
|
//# sourceMappingURL=derive-ecl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-ecl.d.ts","sourceRoot":"","sources":["../../src/derive/derive-ecl.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"derive-ecl.d.ts","sourceRoot":"","sources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;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAczD;AAeD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAW7D;AAuBD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAuC/D;AA0CD,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKvD"}
|
|
@@ -18,7 +18,7 @@ export interface RefinementClause {
|
|
|
18
18
|
export declare function refinementCandidates(members: MemberSet, roots: {
|
|
19
19
|
codes: string[];
|
|
20
20
|
total: number;
|
|
21
|
-
}, givenFoci: string[], fixedFocus: boolean, q: SetQueries, terminology: ITerminologyService, notes: string[]): Promise<{
|
|
21
|
+
}, givenFoci: string[], fixedFocus: boolean, q: SetQueries, terminology: ITerminologyService, notes: string[], batch?: boolean): Promise<{
|
|
22
22
|
focus: string;
|
|
23
23
|
clauses: RefinementClause[];
|
|
24
24
|
}[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refinements.d.ts","sourceRoot":"","sources":["../../src/derive/refinements.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAwB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAML,KAAK,SAAS,EACd,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"refinements.d.ts","sourceRoot":"","sources":["../../src/derive/refinements.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAwB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAML,KAAK,SAAS,EACd,KAAK,UAAU,EAEhB,MAAM,eAAe,CAAC;AAEvB,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9B,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAoFD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACzC,SAAS,EAAE,MAAM,EAAE,EACnB,UAAU,EAAE,OAAO,EACnB,CAAC,EAAE,UAAU,EACb,WAAW,EAAE,mBAAmB,EAChC,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,UAAQ,GACZ,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAAE,EAAE,CAAC,CA+C3D;AAED,iCAAiC;AACjC,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAEjF;AAqLD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBhD;AAED,2FAA2F;AAC3F,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AA4BD;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAMhG"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { EvaluationConcept, ITerminologyService, ValueSetClause, ValueSetCompose } from '../terminology/types';
|
|
2
|
+
import { Walk } from './taxonomy-graph';
|
|
2
3
|
export interface SetDifference {
|
|
3
4
|
count: number;
|
|
4
5
|
/** Up to `sampleSize` of the concepts, as the server returned them. */
|
|
5
6
|
sample: EvaluationConcept[];
|
|
6
7
|
}
|
|
7
8
|
export declare const SNOMED_ROOT = "138875005";
|
|
9
|
+
/**
|
|
10
|
+
* Codes per request when looking concepts up by code. The server's cost grows
|
|
11
|
+
* with the codes in a request, and is paid again for every page of it, so a
|
|
12
|
+
* long list costs least as many small requests rather than one paged one.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LOOKUP_CHUNK = 10000;
|
|
8
15
|
/** Concurrent set queries; see {@link SetQueries}. */
|
|
9
16
|
export declare const MAX_IN_FLIGHT = 8;
|
|
10
17
|
/** Numeric order for SCTIDs, so output does not depend on input or server order. */
|
|
@@ -20,11 +27,28 @@ export declare function orGroup(terms: string[]): string;
|
|
|
20
27
|
export declare function stripTermsAndComments(ecl: string): string;
|
|
21
28
|
export declare function countClauses(ecl: string): number;
|
|
22
29
|
export type ExpandCompose = NonNullable<ITerminologyService['expandCompose']>;
|
|
30
|
+
/**
|
|
31
|
+
* The service behind a {@link countingFailures} wrapper (or `terminology`
|
|
32
|
+
* itself), for a request whose failure the caller recovers from by other
|
|
33
|
+
* requests, which are counted: a failure there loses nothing, so it must not
|
|
34
|
+
* mark the result incomplete.
|
|
35
|
+
*/
|
|
36
|
+
export declare function uncounted(terminology: ITerminologyService): ITerminologyService;
|
|
37
|
+
export declare function countingFailures(terminology: ITerminologyService): {
|
|
38
|
+
service: ITerminologyService;
|
|
39
|
+
failures: () => number;
|
|
40
|
+
};
|
|
23
41
|
/** The set under study, as a compose clause and as an ECL operand. */
|
|
24
42
|
export interface MemberSet {
|
|
25
43
|
clause: ValueSetClause;
|
|
26
44
|
ecl: string;
|
|
27
45
|
size: number;
|
|
46
|
+
/** The members with their terms, when resolving the input already listed them. */
|
|
47
|
+
concepts?: EvaluationConcept[];
|
|
48
|
+
/** The members looked up with their parents and children, when resolving the input did that, for the graph. */
|
|
49
|
+
walk?: Walk;
|
|
50
|
+
/** Resolving the input found that the server gives no parents or children, so the graph cannot be walked. */
|
|
51
|
+
walkUnsupported?: boolean;
|
|
28
52
|
}
|
|
29
53
|
/**
|
|
30
54
|
* Set queries against the server. At most {@link MAX_IN_FLIGHT} run at once:
|
|
@@ -32,9 +56,25 @@ export interface MemberSet {
|
|
|
32
56
|
*/
|
|
33
57
|
export declare class SetQueries {
|
|
34
58
|
private readonly expandCompose;
|
|
59
|
+
private readonly parallelPages;
|
|
35
60
|
private inFlight;
|
|
36
61
|
private readonly waiting;
|
|
37
|
-
constructor(expandCompose: ExpandCompose);
|
|
62
|
+
constructor(expandCompose: ExpandCompose, parallelPages?: boolean);
|
|
63
|
+
/**
|
|
64
|
+
* The rest of an expansion whose first `first.length` concepts have been
|
|
65
|
+
* read, up to `until`, in order. Pages step by the first page's length, which
|
|
66
|
+
* is the server's page cap when it returned fewer than asked (Ontoserver
|
|
67
|
+
* caps at 50,000; other servers lower). With `parallelPages` those pages are
|
|
68
|
+
* asked for at once. Whatever is still missing after that (a server whose
|
|
69
|
+
* pages shrink) is read one page after another, advancing by what each page
|
|
70
|
+
* actually held, so a smaller cap never silently drops concepts.
|
|
71
|
+
*/
|
|
72
|
+
private rest;
|
|
73
|
+
/**
|
|
74
|
+
* Append the pages from `step` to `until`, `step` apart, asked for at once.
|
|
75
|
+
* Only the run of full pages is kept: after a short one the offsets no longer line up.
|
|
76
|
+
*/
|
|
77
|
+
private pagesAtOnce;
|
|
38
78
|
private expand;
|
|
39
79
|
count(compose: ValueSetCompose): Promise<number>;
|
|
40
80
|
sample(compose: ValueSetCompose, count: number, activeOnly?: boolean): Promise<SetDifference>;
|
|
@@ -48,6 +88,37 @@ export declare class SetQueries {
|
|
|
48
88
|
concepts: EvaluationConcept[];
|
|
49
89
|
total: number;
|
|
50
90
|
}>;
|
|
91
|
+
/**
|
|
92
|
+
* The concepts of `codes` the server knows, in chunks of {@link LOOKUP_CHUNK}
|
|
93
|
+
* run concurrently, with their terms and, as asked, parents and children.
|
|
94
|
+
* With `activeOnly: false` inactive ones come back flagged `inactive`.
|
|
95
|
+
*/
|
|
96
|
+
lookup(codes: readonly string[], options?: {
|
|
97
|
+
activeOnly?: boolean;
|
|
98
|
+
parents?: boolean;
|
|
99
|
+
children?: boolean;
|
|
100
|
+
activity?: boolean;
|
|
101
|
+
}): Promise<EvaluationConcept[]>;
|
|
102
|
+
/**
|
|
103
|
+
* {@link lookup}, with each chunk's answer passed through `each` as it
|
|
104
|
+
* arrives, so a caller that keeps less than the server sends need not hold
|
|
105
|
+
* every answer at once. The results are in chunk order.
|
|
106
|
+
*/
|
|
107
|
+
lookupEach<T>(codes: readonly string[], options: {
|
|
108
|
+
activeOnly?: boolean;
|
|
109
|
+
parents?: boolean;
|
|
110
|
+
children?: boolean;
|
|
111
|
+
activity?: boolean;
|
|
112
|
+
}, each: (concepts: EvaluationConcept[]) => T): Promise<T[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Up to `max` concepts of a set known to have at most `max`, such as a list
|
|
115
|
+
* of codes: with `parallelPages` every page is asked for at once, since the
|
|
116
|
+
* offsets do not depend on the first page's total.
|
|
117
|
+
*/
|
|
118
|
+
conceptsUpTo(compose: ValueSetCompose, max: number, activeOnly?: boolean): Promise<{
|
|
119
|
+
concepts: EvaluationConcept[];
|
|
120
|
+
total: number;
|
|
121
|
+
}>;
|
|
51
122
|
/**
|
|
52
123
|
* Every concept of the set with its direct parents, or why not: the set has
|
|
53
124
|
* more than `max` concepts, or the server does not return parents.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-queries.d.ts","sourceRoot":"","sources":["../../src/derive/set-queries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-queries.d.ts","sourceRoot":"","sources":["../../src/derive/set-queries.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,MAAM,EAAE,iBAAiB,EA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,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAC5F,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,CAAC,GACzC,OAAO,CAAC,CAAC,EAAE,CAAC;IAef;;;;OAIG;IACG,YAAY,CAChB,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,MAAM,EACX,UAAU,UAAO,GAChB,OAAO,CAAC;QAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAc5D;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,GAAG,YAAY,CAAC;IAW/G,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGvC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EvaluationConcept } from '../terminology/types';
|
|
1
2
|
import { MemberSet, SetQueries } from './set-queries';
|
|
2
3
|
export interface TaxonomyGraph {
|
|
3
4
|
readonly members: ReadonlySet<string>;
|
|
@@ -13,10 +14,20 @@ export interface TaxonomyGraph {
|
|
|
13
14
|
hasDescendants(id: string): boolean;
|
|
14
15
|
/** Members at or below `id`. */
|
|
15
16
|
truePos(id: string): number;
|
|
17
|
+
/** The members at or below `id`, sorted byId; complete, since every member's ancestors are loaded. */
|
|
18
|
+
membersBelow(id: string): string[];
|
|
16
19
|
/** Members with no member ancestor, sorted byId. */
|
|
17
20
|
roots(): string[];
|
|
18
21
|
/** Concepts in `>> list` except the SNOMED root, sorted byId. */
|
|
19
22
|
ancestors(): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Walked graphs only: load the descendants of `ids` by walking
|
|
25
|
+
* down, looking up only concepts not yet seen. False when they are too many
|
|
26
|
+
* or the server cannot say; the graph is then unchanged.
|
|
27
|
+
*/
|
|
28
|
+
loadBelow?(ids: string[]): Promise<boolean>;
|
|
29
|
+
/** Walked graphs only: a concept's term, when a lookup returned it. */
|
|
30
|
+
term?(id: string): string | undefined;
|
|
20
31
|
}
|
|
21
32
|
/** What was too large to fetch, or `'parents'` when the server does not return them. */
|
|
22
33
|
export interface GraphUnavailable {
|
|
@@ -33,6 +44,53 @@ export interface TaxonomyGraphOptions {
|
|
|
33
44
|
* graph partial. Default: none, the graph is unavailable.
|
|
34
45
|
*/
|
|
35
46
|
fallbackDescend?: TaxonomyGraphOptions['descend'];
|
|
47
|
+
/** The set's active codes when already known, so they are not fetched again. */
|
|
48
|
+
memberCodes?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Build the graph by walking: look the members up with their
|
|
51
|
+
* parents and children, then each new level of ancestors, in chunks, and
|
|
52
|
+
* below the picked groupers the same way, level by level. No query carries
|
|
53
|
+
* the set as ECL. Needs a server that returns `property=child`; without it
|
|
54
|
+
* the ECL queries are used.
|
|
55
|
+
*/
|
|
56
|
+
walk?: boolean;
|
|
57
|
+
/** The active members as already looked up, with parents and children, so they are not looked up again. */
|
|
58
|
+
seed?: Walk;
|
|
59
|
+
/**
|
|
60
|
+
* Queries for `loadBelow` once the graph is built. Its caller falls back to
|
|
61
|
+
* server counts when it fails, so derive passes queries whose failures are
|
|
62
|
+
* not counted (see `uncounted`). Default: the graph's own.
|
|
63
|
+
*/
|
|
64
|
+
belowQueries?: SetQueries;
|
|
36
65
|
}
|
|
37
66
|
export declare function loadTaxonomyGraph(members: MemberSet, q: SetQueries, options: TaxonomyGraphOptions): Promise<TaxonomyGraph | GraphUnavailable>;
|
|
67
|
+
/** Concept ids, each numbered once, shared by a walk and the graph built from it. */
|
|
68
|
+
declare class Ids {
|
|
69
|
+
readonly list: string[];
|
|
70
|
+
private readonly index;
|
|
71
|
+
get(id: string): number | undefined;
|
|
72
|
+
/** The number of `id`, given one if it has none. */
|
|
73
|
+
at(id: string): number;
|
|
74
|
+
}
|
|
75
|
+
/** A looked-up concept, with its parents and children by number. */
|
|
76
|
+
export interface Node {
|
|
77
|
+
parents: number[];
|
|
78
|
+
children: number[];
|
|
79
|
+
display: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Concepts looked up with their parents and children, by number. Resolving a
|
|
83
|
+
* list can start one, converting each chunk as it arrives, so the server's
|
|
84
|
+
* answers are not all held at once (see {@link TaxonomyGraphOptions.seed}).
|
|
85
|
+
*/
|
|
86
|
+
export declare class Walk {
|
|
87
|
+
readonly ids: Ids;
|
|
88
|
+
readonly nodes: Map<number, Node>;
|
|
89
|
+
/** The nodes for `concepts`, not yet added; null when one came back without the parents or children asked for. */
|
|
90
|
+
nodesFor(concepts: EvaluationConcept[]): [number, Node][] | null;
|
|
91
|
+
add(nodes: [number, Node][]): void;
|
|
92
|
+
/** True when every one of `codes` has been looked up. */
|
|
93
|
+
has(codes: Iterable<string>): boolean;
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
38
96
|
//# sourceMappingURL=taxonomy-graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxonomy-graph.d.ts","sourceRoot":"","sources":["../../src/derive/taxonomy-graph.ts"],"names":[],"mappings":"AAYA,OAAO,EAA8B,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE5F,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uFAAuF;IACvF,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B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