@aehrc/ecl-core 1.3.1 → 1.4.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/dist/canonical/canonical-printer.d.ts +15 -0
- package/dist/canonical/canonical-printer.d.ts.map +1 -0
- package/dist/canonical/comparator.d.ts +27 -0
- package/dist/canonical/comparator.d.ts.map +1 -0
- package/dist/canonical/normaliser.d.ts +8 -0
- package/dist/canonical/normaliser.d.ts.map +1 -0
- package/dist/completion/context-detector.d.ts +51 -0
- package/dist/completion/context-detector.d.ts.map +1 -0
- package/dist/completion/context-items.d.ts +50 -0
- package/dist/completion/context-items.d.ts.map +1 -0
- package/dist/completion/filter-cache.d.ts +14 -0
- package/dist/completion/filter-cache.d.ts.map +1 -0
- package/dist/completion/provider.d.ts +38 -0
- package/dist/completion/provider.d.ts.map +1 -0
- package/dist/completion/snippets.d.ts +11 -0
- package/dist/completion/snippets.d.ts.map +1 -0
- package/dist/formatter/ast-printer.d.ts +12 -0
- package/dist/formatter/ast-printer.d.ts.map +1 -0
- package/dist/formatter/comments.d.ts +14 -0
- package/dist/formatter/comments.d.ts.map +1 -0
- package/dist/formatter/config.d.ts +5 -0
- package/dist/formatter/config.d.ts.map +1 -0
- package/dist/formatter/formatter.d.ts +3 -0
- package/dist/formatter/formatter.d.ts.map +1 -0
- package/dist/formatter/index.d.ts +6 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/options.d.ts +47 -0
- package/dist/formatter/options.d.ts.map +1 -0
- package/dist/formatter/range.d.ts +16 -0
- package/dist/formatter/range.d.ts.map +1 -0
- package/dist/formatter/rules.d.ts +8 -0
- package/dist/formatter/rules.d.ts.map +1 -0
- package/dist/formatter/semantic-guard.d.ts +10 -0
- package/dist/formatter/semantic-guard.d.ts.map +1 -0
- package/dist/grammar/ECLLexer.d.ts +122 -0
- package/dist/grammar/ECLLexer.d.ts.map +1 -0
- package/dist/grammar/ECLParser.d.ts +2905 -0
- package/dist/grammar/ECLParser.d.ts.map +1 -0
- package/dist/grammar/ECLVisitor.d.ts +1038 -0
- package/dist/grammar/ECLVisitor.d.ts.map +1 -0
- package/dist/index.cjs +48619 -57274
- package/dist/index.d.ts +45 -1326
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +48622 -57338
- package/dist/knowledge/filters.d.ts +6 -0
- package/dist/knowledge/filters.d.ts.map +1 -0
- package/dist/knowledge/grammar.d.ts +7 -0
- package/dist/knowledge/grammar.d.ts.map +1 -0
- package/dist/knowledge/index.d.ts +24 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/operators.d.ts +10 -0
- package/dist/knowledge/operators.d.ts.map +1 -0
- package/dist/knowledge/patterns.d.ts +6 -0
- package/dist/knowledge/patterns.d.ts.map +1 -0
- package/dist/knowledge/refinements.d.ts +6 -0
- package/dist/knowledge/refinements.d.ts.map +1 -0
- package/dist/knowledge/types.d.ts +41 -0
- package/dist/knowledge/types.d.ts.map +1 -0
- package/dist/parser/ast.d.ts +162 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/concept-extractor.d.ts +21 -0
- package/dist/parser/concept-extractor.d.ts.map +1 -0
- package/dist/parser/error-analysis.d.ts +54 -0
- package/dist/parser/error-analysis.d.ts.map +1 -0
- package/dist/parser/error-listener.d.ts +14 -0
- package/dist/parser/error-listener.d.ts.map +1 -0
- package/dist/parser/expression-grouper.d.ts +20 -0
- package/dist/parser/expression-grouper.d.ts.map +1 -0
- package/dist/parser/generated/grammar/ECLLexer.d.ts +122 -0
- package/dist/parser/generated/grammar/ECLLexer.d.ts.map +1 -0
- package/dist/parser/generated/grammar/ECLParser.d.ts +2905 -0
- package/dist/parser/generated/grammar/ECLParser.d.ts.map +1 -0
- package/dist/parser/generated/grammar/ECLVisitor.d.ts +1038 -0
- package/dist/parser/generated/grammar/ECLVisitor.d.ts.map +1 -0
- package/dist/parser/index.d.ts +26 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/position-detector.d.ts +45 -0
- package/dist/parser/position-detector.d.ts.map +1 -0
- package/dist/parser/refinement-check.d.ts +22 -0
- package/dist/parser/refinement-check.d.ts.map +1 -0
- package/dist/parser/visitor.d.ts +56 -0
- package/dist/parser/visitor.d.ts.map +1 -0
- package/dist/refactoring/add-description-filter.d.ts +8 -0
- package/dist/refactoring/add-description-filter.d.ts.map +1 -0
- package/dist/refactoring/add-display-terms.d.ts +20 -0
- package/dist/refactoring/add-display-terms.d.ts.map +1 -0
- package/dist/refactoring/add-history-supplement.d.ts +13 -0
- package/dist/refactoring/add-history-supplement.d.ts.map +1 -0
- package/dist/refactoring/add-parentheses.d.ts +14 -0
- package/dist/refactoring/add-parentheses.d.ts.map +1 -0
- package/dist/refactoring/index.d.ts +27 -0
- package/dist/refactoring/index.d.ts.map +1 -0
- package/dist/refactoring/remove-parentheses.d.ts +8 -0
- package/dist/refactoring/remove-parentheses.d.ts.map +1 -0
- package/dist/refactoring/replace-inactive-concept.d.ts +15 -0
- package/dist/refactoring/replace-inactive-concept.d.ts.map +1 -0
- package/dist/refactoring/simplify-expression.d.ts +15 -0
- package/dist/refactoring/simplify-expression.d.ts.map +1 -0
- package/dist/refactoring/strip-display-terms.d.ts +8 -0
- package/dist/refactoring/strip-display-terms.d.ts.map +1 -0
- package/dist/semantic/ecl-text.d.ts +35 -0
- package/dist/semantic/ecl-text.d.ts.map +1 -0
- package/dist/semantic/validator.d.ts +14 -0
- package/dist/semantic/validator.d.ts.map +1 -0
- package/dist/semantic-tokens.d.ts +12 -0
- package/dist/semantic-tokens.d.ts.map +1 -0
- package/dist/terminology/errors.d.ts +119 -0
- package/dist/terminology/errors.d.ts.map +1 -0
- package/dist/terminology/fetch-compat-browser.d.ts +3 -0
- package/dist/terminology/fetch-compat-browser.d.ts.map +1 -0
- package/dist/terminology/fetch-compat.d.ts +4 -0
- package/dist/terminology/fetch-compat.d.ts.map +1 -0
- package/dist/terminology/fhir-service.d.ts +195 -0
- package/dist/terminology/fhir-service.d.ts.map +1 -0
- package/dist/terminology/index.d.ts +5 -0
- package/dist/terminology/index.d.ts.map +1 -0
- package/dist/terminology/mock-service.d.ts +22 -0
- package/dist/terminology/mock-service.d.ts.map +1 -0
- package/dist/terminology/types.d.ts +79 -0
- package/dist/terminology/types.d.ts.map +1 -0
- package/dist/terminology/verhoeff.d.ts +38 -0
- package/dist/terminology/verhoeff.d.ts.map +1 -0
- package/dist/text-utils.d.ts +17 -0
- package/dist/text-utils.d.ts.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validation/error-refinement.d.ts +31 -0
- package/dist/validation/error-refinement.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { ITerminologyService, ConceptInfo, SearchResponse, EvaluationResponse, HistoricalAssociation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* How {@link FhirTerminologyService.evaluateEcl} carries the ECL to the terminology server.
|
|
4
|
+
*
|
|
5
|
+
* - `'auto'` (default) — try the implicit ValueSet URL `GET` first and fall back to
|
|
6
|
+
* `POST ValueSet/$expand` when the server shows it cannot serve implicit ValueSets.
|
|
7
|
+
* - `'implicit-url'` — only ever use the implicit ValueSet URL `GET`.
|
|
8
|
+
* - `'post'` — always `POST ValueSet/$expand` with a `constraint` filter.
|
|
9
|
+
*/
|
|
10
|
+
export type EclEvaluationStrategy = 'auto' | 'implicit-url' | 'post';
|
|
11
|
+
/** Type guard for {@link EclEvaluationStrategy} (unknown values degrade to `'auto'`). */
|
|
12
|
+
export declare function isEclEvaluationStrategy(value: unknown): value is EclEvaluationStrategy;
|
|
13
|
+
export interface FhirTerminologyServiceOptions {
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
userAgent?: string;
|
|
17
|
+
snomedVersion?: string;
|
|
18
|
+
/** ECL evaluation transport; defaults to `'auto'`. See {@link EclEvaluationStrategy}. */
|
|
19
|
+
evaluationStrategy?: EclEvaluationStrategy;
|
|
20
|
+
onResolvedVersion?: (versionUri: string) => void;
|
|
21
|
+
maxConcurrency?: number;
|
|
22
|
+
}
|
|
23
|
+
/** A version of a SNOMED CT edition available on the server. */
|
|
24
|
+
export interface SnomedVersion {
|
|
25
|
+
uri: string;
|
|
26
|
+
date: string;
|
|
27
|
+
}
|
|
28
|
+
/** A SNOMED CT edition with its available versions. */
|
|
29
|
+
export interface SnomedEdition {
|
|
30
|
+
moduleId: string;
|
|
31
|
+
versions: SnomedVersion[];
|
|
32
|
+
}
|
|
33
|
+
export declare class FhirTerminologyService implements ITerminologyService {
|
|
34
|
+
private readonly cache;
|
|
35
|
+
private readonly searchCache;
|
|
36
|
+
private readonly baseUrl;
|
|
37
|
+
private readonly timeout;
|
|
38
|
+
private readonly userAgent;
|
|
39
|
+
private readonly evaluationTimeout;
|
|
40
|
+
private readonly searchTimeout;
|
|
41
|
+
private readonly searchCacheTTL;
|
|
42
|
+
private readonly snomedVersion;
|
|
43
|
+
private readonly evaluationStrategy;
|
|
44
|
+
private readonly onResolvedVersion;
|
|
45
|
+
private resolvedVersion;
|
|
46
|
+
/**
|
|
47
|
+
* Latched once a POST `ValueSet/$expand` fallback has succeeded in `'auto'` mode: the
|
|
48
|
+
* server has demonstrated it cannot serve the implicit ValueSet URL form, so subsequent
|
|
49
|
+
* evaluations skip the wasted round-trip for the lifetime of this instance.
|
|
50
|
+
*/
|
|
51
|
+
private usePostExpand;
|
|
52
|
+
/**
|
|
53
|
+
* Latched once a bulk `ValueSet/$expand` has been rejected with a 4xx: the server does
|
|
54
|
+
* not accept a POSTed ValueSet enumerating concepts in `compose.include.concept`, and
|
|
55
|
+
* the request shape never varies, so retrying it on every validation pass only costs a
|
|
56
|
+
* wasted round-trip and a console warning (issue #55). 5xx responses are treated as
|
|
57
|
+
* transient and do not latch.
|
|
58
|
+
*/
|
|
59
|
+
private bulkExpandUnsupported;
|
|
60
|
+
private readonly queue;
|
|
61
|
+
constructor(options?: FhirTerminologyServiceOptions);
|
|
62
|
+
/** The SNOMED CT system URL base for implicit ValueSet URLs. */
|
|
63
|
+
private get snomedSystemUrl();
|
|
64
|
+
/** Get the resolved version URI from the most recent FHIR response, if captured. */
|
|
65
|
+
getResolvedVersion(): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Extract a SNOMED version URI from an $expand parameter array.
|
|
68
|
+
*
|
|
69
|
+
* FHIR servers may report the resolved version as:
|
|
70
|
+
* - `{ name: "version", valueUri: "http://snomed.info/sct/.../version/..." }`
|
|
71
|
+
* - `{ name: "used-codesystem", valueUri: "http://snomed.info/sct|http://snomed.info/sct/.../version/..." }`
|
|
72
|
+
* - Either field as `valueString` instead of `valueUri`
|
|
73
|
+
*/
|
|
74
|
+
private captureResolvedVersion;
|
|
75
|
+
/** Extract resolved version from a $lookup Parameters response. */
|
|
76
|
+
private captureResolvedVersionFromLookup;
|
|
77
|
+
/** Search expansion parameters for a SNOMED version URI. */
|
|
78
|
+
private extractSnomedVersionFromParams;
|
|
79
|
+
/**
|
|
80
|
+
* Parse a SNOMED version URI from a raw parameter value.
|
|
81
|
+
* Handles plain URIs and pipe-delimited `system|version` format.
|
|
82
|
+
*/
|
|
83
|
+
private parseSnomedVersionValue;
|
|
84
|
+
private fetchWithTimeout;
|
|
85
|
+
/**
|
|
86
|
+
* Perform a request, translating any network-level failure (connection
|
|
87
|
+
* refused, DNS failure, timeout/abort) into a {@link TerminologyTransportError}
|
|
88
|
+
* so callers can tell "server unreachable" from "server said no".
|
|
89
|
+
*/
|
|
90
|
+
private request;
|
|
91
|
+
/** Read the body of an error response, extracting a FHIR OperationOutcome if present. */
|
|
92
|
+
private static readErrorBody;
|
|
93
|
+
/** Issue codes a FHIR server uses to say "this code is not in the code system". */
|
|
94
|
+
private static readonly UNKNOWN_CODE_ISSUE_CODES;
|
|
95
|
+
/** Phrases servers use in OperationOutcome prose when a code is unknown. */
|
|
96
|
+
private static readonly UNKNOWN_CODE_PHRASES;
|
|
97
|
+
/**
|
|
98
|
+
* True when an error response is the server's well-formed way of saying
|
|
99
|
+
* "I do not know this code" — the one case that maps to `null` rather than
|
|
100
|
+
* an exception.
|
|
101
|
+
*
|
|
102
|
+
* A 404 is only accepted as such when the body is a real FHIR
|
|
103
|
+
* OperationOutcome; a bare 404 (wrong base URL, proxy page) is a fault.
|
|
104
|
+
*/
|
|
105
|
+
private static isUnknownCodeResponse;
|
|
106
|
+
/**
|
|
107
|
+
* Look up a single concept.
|
|
108
|
+
*
|
|
109
|
+
* @returns the concept, or `null` when the terminology server gave a
|
|
110
|
+
* well-formed answer saying the code is unknown to it.
|
|
111
|
+
* @throws {TerminologyTransportError} when the server could not be reached,
|
|
112
|
+
* the request timed out, or the response body was unusable.
|
|
113
|
+
* @throws {TerminologyHttpError} when the server answered with an error
|
|
114
|
+
* status that is not an "unknown code" response.
|
|
115
|
+
*/
|
|
116
|
+
private fetchWithRetry;
|
|
117
|
+
private fetchQueued;
|
|
118
|
+
getConceptInfo(conceptId: string): Promise<ConceptInfo | null>;
|
|
119
|
+
/** Map of SNOMED CT historical association reference set IDs to association types. */
|
|
120
|
+
private static readonly ASSOCIATION_REFSETS;
|
|
121
|
+
getHistoricalAssociations(conceptId: string): Promise<HistoricalAssociation[]>;
|
|
122
|
+
/** Query a single implicit ConceptMap for historical association targets. */
|
|
123
|
+
private translateAssociation;
|
|
124
|
+
/**
|
|
125
|
+
* Validate a batch of concepts.
|
|
126
|
+
*
|
|
127
|
+
* A `null` map value means the terminology server positively reported the
|
|
128
|
+
* code as unknown. Failures are never reported as `null` — they reject.
|
|
129
|
+
*
|
|
130
|
+
* @throws {TerminologyTransportError} when the server could not be reached.
|
|
131
|
+
* @throws {TerminologyHttpError} when the server answered with an error status.
|
|
132
|
+
*/
|
|
133
|
+
validateConcepts(conceptIds: string[]): Promise<Map<string, ConceptInfo | null>>;
|
|
134
|
+
/**
|
|
135
|
+
* Move concepts found in a bulk expansion into `results` (and the cache),
|
|
136
|
+
* returning the IDs that were absent and still need an individual lookup.
|
|
137
|
+
*/
|
|
138
|
+
private mergeExpandResults;
|
|
139
|
+
/**
|
|
140
|
+
* Move already-cached concepts into `results`, returning the IDs still to fetch.
|
|
141
|
+
*/
|
|
142
|
+
private partitionCached;
|
|
143
|
+
/** Look each concept up individually, recording the result (or `null` if absent). */
|
|
144
|
+
private lookupEach;
|
|
145
|
+
private bulkExpand;
|
|
146
|
+
/**
|
|
147
|
+
* Search for concepts by text or SCTID.
|
|
148
|
+
*
|
|
149
|
+
* An empty result set means the server found no matches.
|
|
150
|
+
*
|
|
151
|
+
* @throws {TerminologyTransportError} when the server could not be reached.
|
|
152
|
+
* @throws {TerminologyHttpError} when the server answered with an error status.
|
|
153
|
+
*/
|
|
154
|
+
searchConcepts(query: string): Promise<SearchResponse>;
|
|
155
|
+
private lookupById;
|
|
156
|
+
evaluateEcl(expression: string, limit?: number): Promise<EvaluationResponse>;
|
|
157
|
+
/**
|
|
158
|
+
* Transport selection for {@link evaluateEcl}.
|
|
159
|
+
*
|
|
160
|
+
* A forced `'post'` strategy — or a latched successful POST fallback — goes straight to
|
|
161
|
+
* `POST ValueSet/$expand`. Otherwise the implicit ValueSet URL GET runs first, and in
|
|
162
|
+
* `'auto'` mode a failure whose *shape* says the server cannot serve implicit ValueSets
|
|
163
|
+
* (issue #55) is retried over POST.
|
|
164
|
+
*/
|
|
165
|
+
private runEvaluationStrategy;
|
|
166
|
+
/** `GET ValueSet/$expand?url=<canonical implicit ECL ValueSet>` — see {@link encodeEclForCanonicalUrl}. */
|
|
167
|
+
private buildImplicitEvaluationUrl;
|
|
168
|
+
/**
|
|
169
|
+
* `POST ValueSet/$expand` carrying the ECL in `compose.include.filter` with
|
|
170
|
+
* `property: "constraint"` — the form requested in issue #55. The expression travels in a
|
|
171
|
+
* JSON body, so it needs no escaping at all.
|
|
172
|
+
*/
|
|
173
|
+
private evaluateViaPostExpand;
|
|
174
|
+
/**
|
|
175
|
+
* True when an implicit-URL failure indicates the implicit ValueSet *form* is unsupported
|
|
176
|
+
* rather than the expression being invalid.
|
|
177
|
+
*
|
|
178
|
+
* Deliberately excludes a bare HTTP 422: that is also how a genuine ECL syntax error
|
|
179
|
+
* presents, and retrying those over POST would only turn one clear error into two requests
|
|
180
|
+
* and a muddled message. The `'not-found'` OperationOutcome code is still honoured on any
|
|
181
|
+
* status, which covers servers that report a missing implicit ValueSet as 422.
|
|
182
|
+
*/
|
|
183
|
+
private shouldFallbackToPostExpand;
|
|
184
|
+
/** Remaining milliseconds in the shared evaluation budget; throws once it is spent. */
|
|
185
|
+
private remainingTimeout;
|
|
186
|
+
/** The machine-readable code and human-readable text of a FHIR error response. */
|
|
187
|
+
private readOperationOutcome;
|
|
188
|
+
/** Shared expansion mapping for both the implicit-URL and POST evaluation transports. */
|
|
189
|
+
private parseEvaluationResponse;
|
|
190
|
+
private createEvaluationError;
|
|
191
|
+
private searchByFilter;
|
|
192
|
+
/** Fetch available SNOMED CT editions and versions from the FHIR server. */
|
|
193
|
+
getSnomedEditions(): Promise<SnomedEdition[]>;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=fhir-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fhir-service.d.ts","sourceRoot":"","sources":["../../src/terminology/fhir-service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,cAAc,EAEd,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AAuFjB;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC;AAErE,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAEtF;AA+BD,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa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IAoB/E;;;;;;;OAOG;YACW,qBAAqB;IAuCnC,2GAA2G;IAC3G,OAAO,CAAC,0BAA0B;IAKlC;;;;OAIG;YACW,qBAAqB;IA4BnC;;;;;;;;OAQG;IACH,OAAO,CAAC,0BAA0B;IAUlC,uFAAuF;IACvF,OAAO,CAAC,gBAAgB;IAQxB,kFAAkF;YACpE,oBAAoB;IASlC,yFAAyF;IACzF,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,qBAAqB;YAkBf,cAAc;IAsC5B,4EAA4E;IACtE,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAgDpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/terminology/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ITerminologyService, ConceptInfo, SearchResponse, EvaluationResponse, HistoricalAssociation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory terminology service for tests.
|
|
4
|
+
*
|
|
5
|
+
* Conformant with the {@link ITerminologyService} failure contract: it never
|
|
6
|
+
* fails, so it only ever returns `null` for a concept that is genuinely absent
|
|
7
|
+
* from its fixture data.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MockTerminologyService implements ITerminologyService {
|
|
10
|
+
private readonly mockData;
|
|
11
|
+
/** @returns the fixture concept, or `null` when it is genuinely not in the fixture data. */
|
|
12
|
+
getConceptInfo(conceptId: string): Promise<ConceptInfo | null>;
|
|
13
|
+
validateConcepts(conceptIds: string[]): Promise<Map<string, ConceptInfo | null>>;
|
|
14
|
+
searchConcepts(query: string): Promise<SearchResponse>;
|
|
15
|
+
/** Mock historical association data for inactive concepts. */
|
|
16
|
+
private readonly mockAssociations;
|
|
17
|
+
getHistoricalAssociations(conceptId: string): Promise<HistoricalAssociation[]>;
|
|
18
|
+
/** Mock results for filter ECL constraint expansions. */
|
|
19
|
+
private readonly filterResults;
|
|
20
|
+
evaluateEcl(expression: string, limit?: number): Promise<EvaluationResponse>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=mock-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-service.d.ts","sourceRoot":"","sources":["../../src/terminology/mock-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGtH;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAmBtB;IAEH,4FAA4F;IACtF,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAI9D,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IAQhF,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAmB5D,8DAA8D;IAC9D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAW9B;IAEG,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIpF,yDAAyD;IACzD,OAAO,CAAC,QAAQ,CAAC,aAAa,CA4B3B;IAEG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA6BhF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface ConceptInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
fsn: string;
|
|
4
|
+
pt: string;
|
|
5
|
+
active: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ConceptSearchResult {
|
|
8
|
+
id: string;
|
|
9
|
+
fsn: string;
|
|
10
|
+
pt: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SearchResponse {
|
|
13
|
+
results: ConceptSearchResult[];
|
|
14
|
+
hasMore: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface EvaluationConcept {
|
|
17
|
+
code: string;
|
|
18
|
+
display: string;
|
|
19
|
+
}
|
|
20
|
+
export interface EvaluationResponse {
|
|
21
|
+
total: number;
|
|
22
|
+
concepts: EvaluationConcept[];
|
|
23
|
+
truncated: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type HistoricalAssociationType = 'same-as' | 'replaced-by' | 'possibly-equivalent-to' | 'alternative';
|
|
26
|
+
export interface HistoricalAssociation {
|
|
27
|
+
type: HistoricalAssociationType;
|
|
28
|
+
refsetId: string;
|
|
29
|
+
targets: {
|
|
30
|
+
code: string;
|
|
31
|
+
display: string;
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A source of SNOMED CT terminology facts.
|
|
36
|
+
*
|
|
37
|
+
* **Failure contract.** Implementations MUST distinguish "the server told me
|
|
38
|
+
* this concept does not exist" from "I could not ask the server". A `null`
|
|
39
|
+
* result is a factual claim about SNOMED CT content and is only permitted for
|
|
40
|
+
* the former; every failure — connection refused, DNS failure, timeout, HTTP
|
|
41
|
+
* error status, unreadable body — MUST reject with a `TerminologyError`
|
|
42
|
+
* (`TerminologyTransportError` or `TerminologyHttpError`), so that callers can
|
|
43
|
+
* classify it structurally via its `kind` discriminant and `status`, rather
|
|
44
|
+
* than rendering an outage as "concept not found".
|
|
45
|
+
*/
|
|
46
|
+
export interface ITerminologyService {
|
|
47
|
+
/**
|
|
48
|
+
* Look up a single concept.
|
|
49
|
+
*
|
|
50
|
+
* @returns the concept, or `null` ONLY when the terminology server gave a
|
|
51
|
+
* well-formed answer saying the code is unknown to it.
|
|
52
|
+
* @throws `TerminologyTransportError` when the server could not be reached,
|
|
53
|
+
* the request timed out, or the response was unusable.
|
|
54
|
+
* @throws `TerminologyHttpError` when the server answered with an error status.
|
|
55
|
+
*/
|
|
56
|
+
getConceptInfo(conceptId: string): Promise<ConceptInfo | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Validate a batch of concepts.
|
|
59
|
+
*
|
|
60
|
+
* @returns a map from concept ID to its info, or to `null` ONLY when the
|
|
61
|
+
* server positively reported that code as unknown.
|
|
62
|
+
* @throws `TerminologyTransportError` / `TerminologyHttpError` on failure —
|
|
63
|
+
* never a map full of `null`s.
|
|
64
|
+
*/
|
|
65
|
+
validateConcepts(conceptIds: string[]): Promise<Map<string, ConceptInfo | null>>;
|
|
66
|
+
/**
|
|
67
|
+
* Search for concepts by text or SCTID.
|
|
68
|
+
*
|
|
69
|
+
* @returns matches; an empty result set means the server found none.
|
|
70
|
+
* @throws `TerminologyTransportError` / `TerminologyHttpError` on failure —
|
|
71
|
+
* never an empty result set, and never an opaque generic `Error`.
|
|
72
|
+
*/
|
|
73
|
+
searchConcepts(query: string): Promise<SearchResponse>;
|
|
74
|
+
/** Expand an ECL expression. Throws on failure. */
|
|
75
|
+
evaluateEcl(expression: string, limit?: number): Promise<EvaluationResponse>;
|
|
76
|
+
/** Historical associations for an inactive concept, if the source supports them. */
|
|
77
|
+
getHistoricalAssociations?(conceptId: string): Promise<HistoricalAssociation[]>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/terminology/types.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG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AC,qBAAqB,EAAE,CAAC,CAAC;CACjF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a string using the Verhoeff algorithm.
|
|
3
|
+
*
|
|
4
|
+
* @param num - The numeric string to validate (must contain only digits)
|
|
5
|
+
* @returns true if the check digit is valid, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function verhoeffCheck(num: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Validates a SNOMED CT identifier format.
|
|
10
|
+
*
|
|
11
|
+
* Rules:
|
|
12
|
+
* - Must be 6-18 digits long
|
|
13
|
+
* - Must pass Verhoeff check digit validation
|
|
14
|
+
* - Penultimate two digits are the partition identifier
|
|
15
|
+
*
|
|
16
|
+
* @param conceptId - The SNOMED CT concept ID to validate
|
|
17
|
+
* @returns true if the ID is a valid SNOMED CT identifier, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function isValidSnomedId(conceptId: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Validates that a SNOMED CT identifier is a concept ID.
|
|
22
|
+
*
|
|
23
|
+
* Concept IDs use partition identifiers 00 (core) or 10 (extension with namespace).
|
|
24
|
+
*
|
|
25
|
+
* @param sctid - The SNOMED CT identifier to validate
|
|
26
|
+
* @returns true if the ID is a valid SNOMED CT concept identifier
|
|
27
|
+
*/
|
|
28
|
+
export declare function isValidConceptId(sctid: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Validates that a SNOMED CT identifier is a description ID.
|
|
31
|
+
*
|
|
32
|
+
* Description IDs use partition identifiers 01 (core) or 11 (extension).
|
|
33
|
+
*
|
|
34
|
+
* @param sctid - The SNOMED CT identifier to validate
|
|
35
|
+
* @returns true if the ID is a valid SNOMED CT description identifier
|
|
36
|
+
*/
|
|
37
|
+
export declare function isValidDescriptionId(sctid: string): boolean;
|
|
38
|
+
//# sourceMappingURL=verhoeff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verhoeff.d.ts","sourceRoot":"","sources":["../../src/terminology/verhoeff.ts"],"names":[],"mappings":"AAqCA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAalD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAuB1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOvD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO3D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CorePosition, CoreRange } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a 0-based offset in a text string to a CorePosition (line, character).
|
|
4
|
+
* Equivalent to TextDocument.positionAt().
|
|
5
|
+
*/
|
|
6
|
+
export declare function positionAt(text: string, offset: number): CorePosition;
|
|
7
|
+
/**
|
|
8
|
+
* Convert a CorePosition (line, character) to a 0-based offset in a text string.
|
|
9
|
+
* Equivalent to TextDocument.offsetAt().
|
|
10
|
+
*/
|
|
11
|
+
export declare function offsetAt(text: string, position: CorePosition): number;
|
|
12
|
+
/**
|
|
13
|
+
* Get a substring from text using a CoreRange.
|
|
14
|
+
* Equivalent to TextDocument.getText(range).
|
|
15
|
+
*/
|
|
16
|
+
export declare function getText(text: string, range?: CoreRange): string;
|
|
17
|
+
//# sourceMappingURL=text-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-utils.d.ts","sourceRoot":"","sources":["../src/text-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAUrE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAUrE;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAK/D"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Position in a text document (0-based line and character). */
|
|
2
|
+
export interface CorePosition {
|
|
3
|
+
line: number;
|
|
4
|
+
character: number;
|
|
5
|
+
}
|
|
6
|
+
/** Range in a text document. */
|
|
7
|
+
export interface CoreRange {
|
|
8
|
+
start: CorePosition;
|
|
9
|
+
end: CorePosition;
|
|
10
|
+
}
|
|
11
|
+
/** A text edit to apply to a document. */
|
|
12
|
+
export interface CoreTextEdit {
|
|
13
|
+
range: CoreRange;
|
|
14
|
+
newText: string;
|
|
15
|
+
}
|
|
16
|
+
/** A text edit that inserts at a position (convenience). */
|
|
17
|
+
export declare function coreInsert(position: CorePosition, newText: string): CoreTextEdit;
|
|
18
|
+
/** A text edit that replaces a range (convenience). */
|
|
19
|
+
export declare function coreReplace(range: CoreRange, newText: string): CoreTextEdit;
|
|
20
|
+
/** A code action (refactoring or quick fix). */
|
|
21
|
+
export interface CoreCodeAction {
|
|
22
|
+
title: string;
|
|
23
|
+
kind: 'quickfix' | 'refactor';
|
|
24
|
+
edits?: CoreTextEdit[];
|
|
25
|
+
/** URI of the document these edits apply to. */
|
|
26
|
+
documentUri?: string;
|
|
27
|
+
/** Opaque data for deferred resolution (e.g., FHIR lookups). */
|
|
28
|
+
data?: unknown;
|
|
29
|
+
}
|
|
30
|
+
/** Insert text format for completions. */
|
|
31
|
+
export type CoreInsertTextFormat = 'plainText' | 'snippet';
|
|
32
|
+
/** Completion item kind. */
|
|
33
|
+
export type CoreCompletionItemKind = 'keyword' | 'operator' | 'snippet' | 'value' | 'concept' | 'property' | 'text' | 'function';
|
|
34
|
+
/** A completion item. */
|
|
35
|
+
export interface CoreCompletionItem {
|
|
36
|
+
label: string;
|
|
37
|
+
kind: CoreCompletionItemKind;
|
|
38
|
+
detail?: string;
|
|
39
|
+
documentation?: string;
|
|
40
|
+
insertText?: string;
|
|
41
|
+
insertTextFormat?: CoreInsertTextFormat;
|
|
42
|
+
/** Text edit to apply instead of insertText. */
|
|
43
|
+
textEdit?: CoreTextEdit;
|
|
44
|
+
/** Sort order string. */
|
|
45
|
+
sortText?: string;
|
|
46
|
+
/** Filter text for matching. */
|
|
47
|
+
filterText?: string;
|
|
48
|
+
/** Command to execute after insertion. */
|
|
49
|
+
command?: {
|
|
50
|
+
command: string;
|
|
51
|
+
title: string;
|
|
52
|
+
arguments?: unknown[];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Diagnostic severity levels. */
|
|
56
|
+
export type CoreDiagnosticSeverity = 'error' | 'warning' | 'information' | 'hint';
|
|
57
|
+
/** A diagnostic (error, warning, etc.). */
|
|
58
|
+
export interface CoreDiagnostic {
|
|
59
|
+
range: CoreRange;
|
|
60
|
+
message: string;
|
|
61
|
+
severity: CoreDiagnosticSeverity;
|
|
62
|
+
source?: string;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,gCAAgC;AAChC,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,YAAY,CAAC;CACnB;AAED,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,QA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AAM,sBAAsB,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,CAAC;AAElF,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ParseError } from '../parser/error-listener';
|
|
2
|
+
/**
|
|
3
|
+
* Context needed to refine a raw ANTLR parse error into a user-friendly diagnostic.
|
|
4
|
+
*/
|
|
5
|
+
export interface ErrorContext {
|
|
6
|
+
/** The ANTLR parse error. */
|
|
7
|
+
error: ParseError;
|
|
8
|
+
/** All document lines (for EOF relocation). */
|
|
9
|
+
lines: string[];
|
|
10
|
+
/** The document line index where the error was reported. */
|
|
11
|
+
docLineIndex: number;
|
|
12
|
+
/** Line offsets mapping expression-local lines to document lines. */
|
|
13
|
+
lineOffsets: number[];
|
|
14
|
+
/** Start line of the expression in the document. */
|
|
15
|
+
startLine: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The refined error message and highlight range.
|
|
19
|
+
*/
|
|
20
|
+
export interface RefinedError {
|
|
21
|
+
message: string;
|
|
22
|
+
startChar: number;
|
|
23
|
+
endChar: number;
|
|
24
|
+
docLineIndex: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Refine a raw ANTLR parse error into a user-friendly message with accurate
|
|
28
|
+
* highlight positions. This is a pure function — no side effects.
|
|
29
|
+
*/
|
|
30
|
+
export declare function refineParseError(ctx: ErrorContext): RefinedError;
|
|
31
|
+
//# sourceMappingURL=error-refinement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-refinement.d.ts","sourceRoot":"","sources":["../../src/validation/error-refinement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAYtD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,KAAK,EAAE,UAAU,CAAC;IAClB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,4DAA4D;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAeD;;;GAGG;AAEH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CA4IhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aehrc/ecl-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"node-fetch": "^2.7.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^26.4.0",
|
|
54
54
|
"@types/node-fetch": "^2.6.9",
|
|
55
55
|
"antlr4ts-cli": "^0.5.0-alpha.4",
|
|
56
56
|
"rimraf": "^5.0.5",
|
|
57
57
|
"typescript": "^6.0.2",
|
|
58
|
-
"vite": "^
|
|
59
|
-
"vite-plugin-dts": "^
|
|
58
|
+
"vite": "^8.2.2",
|
|
59
|
+
"vite-plugin-dts": "^5.0.3",
|
|
60
60
|
"vite-plugin-node-polyfills": "^0.28.0"
|
|
61
61
|
}
|
|
62
62
|
}
|