@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
package/dist/index.d.ts
CHANGED
|
@@ -1,1326 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* A conjunction (`,` or `AND`) or disjunction (`OR`) of refinement members.
|
|
47
|
-
*
|
|
48
|
-
* The ECL grammar forbids mixing conjunction and disjunction at the same level,
|
|
49
|
-
* so every set is homogeneous; mixed expressions nest sets inside one another
|
|
50
|
-
* via parentheses.
|
|
51
|
-
*/
|
|
52
|
-
export declare interface AttributeSetNode extends ASTNode {
|
|
53
|
-
type: NodeType.AttributeSet;
|
|
54
|
-
operator: 'AND' | 'OR';
|
|
55
|
-
/** How a conjunction was written in the source. Always ',' for disjunctions. */
|
|
56
|
-
conjunctionStyle: ',' | 'AND';
|
|
57
|
-
/**
|
|
58
|
-
* True when the source wrote this set inside `( )`.
|
|
59
|
-
*
|
|
60
|
-
* The grammar nests attribute sets inside refinements even without
|
|
61
|
-
* parentheses, so this distinguishes real source parentheses from the
|
|
62
|
-
* implicit nesting a parser introduces.
|
|
63
|
-
*/
|
|
64
|
-
parenthesized?: boolean;
|
|
65
|
-
members: RefinementMemberNode[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare interface AttributeValueNode extends ASTNode {
|
|
69
|
-
type: NodeType.AttributeValue;
|
|
70
|
-
expression?: SubExpressionNode;
|
|
71
|
-
rawValue?: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Build a replacement ECL fragment for an inactive concept based on a historical association.
|
|
76
|
-
*
|
|
77
|
-
* - SAME AS / REPLACED BY: direct 1:1 replacement
|
|
78
|
-
* - POSSIBLY EQUIVALENT TO / ALTERNATIVE: parenthesized OR disjunction (or bare if single target)
|
|
79
|
-
*
|
|
80
|
-
* Display terms are included in the replacement when available.
|
|
81
|
-
*/
|
|
82
|
-
export declare function buildReplacementText(association: HistoricalAssociation): ReplacementResult;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Returns a canonical string form of the given ECL expression.
|
|
86
|
-
*
|
|
87
|
-
* Applies deterministic ordering (AND/OR operands, refinement attributes),
|
|
88
|
-
* strips display terms, removes redundant parentheses, and normalises whitespace.
|
|
89
|
-
*
|
|
90
|
-
* Throws `CanonicaliseError` if the expression cannot be parsed.
|
|
91
|
-
*/
|
|
92
|
-
export declare function canonicalise(expression: string): string;
|
|
93
|
-
|
|
94
|
-
export declare class CanonicaliseError extends Error {
|
|
95
|
-
readonly parseErrors: ParseError[];
|
|
96
|
-
constructor(message: string, parseErrors: ParseError[]);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Check an expression for mixed AND/OR operators in refinement clauses.
|
|
101
|
-
*
|
|
102
|
-
* The ECL 2.2 specification requires that AND and OR not be mixed without
|
|
103
|
-
* parentheses at any level. The official ANTLR grammar has a known defect
|
|
104
|
-
* (https://github.com/IHTSDO/snomed-expression-constraint-language/issues/12)
|
|
105
|
-
* that allows mixing at the attribute refinement level via two-layer nesting.
|
|
106
|
-
*
|
|
107
|
-
* This function detects that pattern and returns warnings.
|
|
108
|
-
*/
|
|
109
|
-
export declare function checkMixedRefinementOperators(ast: ExpressionNode, sourceText: string): RefinementWarning[];
|
|
110
|
-
|
|
111
|
-
/** Clear all cached filter completions (e.g. on edition change). */
|
|
112
|
-
export declare function clearFilterCache(): void;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Compares two ECL expressions.
|
|
116
|
-
*
|
|
117
|
-
* Returns 'identical' if the trimmed input strings are equal.
|
|
118
|
-
* Returns 'structurally_equivalent' if they differ but canonicalise to the same form.
|
|
119
|
-
* Returns 'different' otherwise.
|
|
120
|
-
*
|
|
121
|
-
* Both expressions must be syntactically valid. If either fails to parse,
|
|
122
|
-
* a CanonicaliseError is thrown.
|
|
123
|
-
*/
|
|
124
|
-
export declare function compareExpressions(a: string, b: string): ComparisonResult;
|
|
125
|
-
|
|
126
|
-
export declare type ComparisonResult = 'identical' | 'structurally_equivalent' | 'different';
|
|
127
|
-
|
|
128
|
-
export declare interface CompoundExpressionNode extends ASTNode {
|
|
129
|
-
type: NodeType.CompoundExpression;
|
|
130
|
-
operator: LogicalOperatorNode;
|
|
131
|
-
operands: SubExpressionNode[];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export declare function computeSemanticTokens(text: string): SemanticToken[];
|
|
135
|
-
|
|
136
|
-
export declare interface ConceptInfo {
|
|
137
|
-
id: string;
|
|
138
|
-
fsn: string;
|
|
139
|
-
pt: string;
|
|
140
|
-
active: boolean;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export declare interface ConceptReference {
|
|
144
|
-
id: string;
|
|
145
|
-
range: Range;
|
|
146
|
-
term?: string;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
declare interface ConceptReferenceNode extends ASTNode {
|
|
150
|
-
type: NodeType.ConceptReference;
|
|
151
|
-
conceptId: string;
|
|
152
|
-
term?: string;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
declare interface ConceptSearchResult {
|
|
156
|
-
id: string;
|
|
157
|
-
fsn: string;
|
|
158
|
-
pt: string;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** A code action (refactoring or quick fix). */
|
|
162
|
-
export declare interface CoreCodeAction {
|
|
163
|
-
title: string;
|
|
164
|
-
kind: 'quickfix' | 'refactor';
|
|
165
|
-
edits?: CoreTextEdit[];
|
|
166
|
-
/** URI of the document these edits apply to. */
|
|
167
|
-
documentUri?: string;
|
|
168
|
-
/** Opaque data for deferred resolution (e.g., FHIR lookups). */
|
|
169
|
-
data?: unknown;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** A completion item. */
|
|
173
|
-
export declare interface CoreCompletionItem {
|
|
174
|
-
label: string;
|
|
175
|
-
kind: CoreCompletionItemKind;
|
|
176
|
-
detail?: string;
|
|
177
|
-
documentation?: string;
|
|
178
|
-
insertText?: string;
|
|
179
|
-
insertTextFormat?: CoreInsertTextFormat;
|
|
180
|
-
/** Text edit to apply instead of insertText. */
|
|
181
|
-
textEdit?: CoreTextEdit;
|
|
182
|
-
/** Sort order string. */
|
|
183
|
-
sortText?: string;
|
|
184
|
-
/** Filter text for matching. */
|
|
185
|
-
filterText?: string;
|
|
186
|
-
/** Command to execute after insertion. */
|
|
187
|
-
command?: {
|
|
188
|
-
command: string;
|
|
189
|
-
title: string;
|
|
190
|
-
arguments?: unknown[];
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** Completion item kind. */
|
|
195
|
-
export declare type CoreCompletionItemKind = 'keyword' | 'operator' | 'snippet' | 'value' | 'concept' | 'property' | 'text' | 'function';
|
|
196
|
-
|
|
197
|
-
/** A diagnostic (error, warning, etc.). */
|
|
198
|
-
export declare interface CoreDiagnostic {
|
|
199
|
-
range: CoreRange;
|
|
200
|
-
message: string;
|
|
201
|
-
severity: CoreDiagnosticSeverity;
|
|
202
|
-
source?: string;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/** Diagnostic severity levels. */
|
|
206
|
-
export declare type CoreDiagnosticSeverity = 'error' | 'warning' | 'information' | 'hint';
|
|
207
|
-
|
|
208
|
-
/** A text edit that inserts at a position (convenience). */
|
|
209
|
-
export declare function coreInsert(position: CorePosition, newText: string): CoreTextEdit;
|
|
210
|
-
|
|
211
|
-
/** Insert text format for completions. */
|
|
212
|
-
export declare type CoreInsertTextFormat = 'plainText' | 'snippet';
|
|
213
|
-
|
|
214
|
-
/** Position in a text document (0-based line and character). */
|
|
215
|
-
export declare interface CorePosition {
|
|
216
|
-
line: number;
|
|
217
|
-
character: number;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** Range in a text document. */
|
|
221
|
-
export declare interface CoreRange {
|
|
222
|
-
start: CorePosition;
|
|
223
|
-
end: CorePosition;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/** A text edit that replaces a range (convenience). */
|
|
227
|
-
export declare function coreReplace(range: CoreRange, newText: string): CoreTextEdit;
|
|
228
|
-
|
|
229
|
-
/** A text edit to apply to a document. */
|
|
230
|
-
export declare interface CoreTextEdit {
|
|
231
|
-
range: CoreRange;
|
|
232
|
-
newText: string;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** Discriminated union of all cursor contexts for ECL completion. */
|
|
236
|
-
export declare type CursorContext = {
|
|
237
|
-
kind: 'expression-start';
|
|
238
|
-
} | {
|
|
239
|
-
kind: 'after-operator';
|
|
240
|
-
operator: string;
|
|
241
|
-
} | {
|
|
242
|
-
kind: 'after-concept';
|
|
243
|
-
} | {
|
|
244
|
-
kind: 'after-logical-operator';
|
|
245
|
-
operator: string;
|
|
246
|
-
} | {
|
|
247
|
-
kind: 'refinement-start';
|
|
248
|
-
} | {
|
|
249
|
-
kind: 'after-attribute-name';
|
|
250
|
-
} | {
|
|
251
|
-
kind: 'after-comparison-operator';
|
|
252
|
-
} | {
|
|
253
|
-
kind: 'after-cardinality';
|
|
254
|
-
} | {
|
|
255
|
-
kind: 'dotted-awaiting-attribute';
|
|
256
|
-
} | {
|
|
257
|
-
kind: 'filter-block';
|
|
258
|
-
filterType: FilterType;
|
|
259
|
-
subContext: FilterSubContext;
|
|
260
|
-
} | {
|
|
261
|
-
kind: 'inside-display-term';
|
|
262
|
-
} | {
|
|
263
|
-
kind: 'unknown';
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export declare const defaultFormattingOptions: FormattingOptions;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Detect the cursor context for ECL completion.
|
|
270
|
-
*
|
|
271
|
-
* 1. Checks for filter block context first via text scan (filters are opaque to ANTLR)
|
|
272
|
-
* 2. Parses with parseECL() and inspects the partial AST for everything else
|
|
273
|
-
*/
|
|
274
|
-
export declare function detectCursorContext(textBeforeCursor: string): CursorContext;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Detect if the cursor is inside a filter block by scanning for unmatched `{{`.
|
|
278
|
-
*
|
|
279
|
-
* Returns a filter-block CursorContext if inside one, or null otherwise.
|
|
280
|
-
*/
|
|
281
|
-
export declare function detectFilterContext(text: string): CursorContext | null;
|
|
282
|
-
|
|
283
|
-
declare interface DottedAttributeNode extends ASTNode {
|
|
284
|
-
type: NodeType.DottedAttribute;
|
|
285
|
-
attributeName: SubExpressionNode;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
declare interface DottedExpressionNode extends ASTNode {
|
|
289
|
-
type: NodeType.DottedExpression;
|
|
290
|
-
source: SubExpressionNode;
|
|
291
|
-
attributes: DottedAttributeNode[];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* How {@link FhirTerminologyService.evaluateEcl} carries the ECL to the terminology server.
|
|
296
|
-
*
|
|
297
|
-
* - `'auto'` (default) — try the implicit ValueSet URL `GET` first and fall back to
|
|
298
|
-
* `POST ValueSet/$expand` when the server shows it cannot serve implicit ValueSets.
|
|
299
|
-
* - `'implicit-url'` — only ever use the implicit ValueSet URL `GET`.
|
|
300
|
-
* - `'post'` — always `POST ValueSet/$expand` with a `constraint` filter.
|
|
301
|
-
*/
|
|
302
|
-
export declare type EclEvaluationStrategy = 'auto' | 'implicit-url' | 'post';
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* ECL snippet completions for common expression patterns.
|
|
306
|
-
* These are offered when the cursor is between expressions or at the
|
|
307
|
-
* start of an expression where constraint operators are valid.
|
|
308
|
-
*
|
|
309
|
-
* All snippets use `sortText` starting with 'z' so they sort after
|
|
310
|
-
* keyword/operator completions.
|
|
311
|
-
*/
|
|
312
|
-
export declare const eclSnippetCompletions: CoreCompletionItem[];
|
|
313
|
-
|
|
314
|
-
export declare const eclTokenModifiers: string[];
|
|
315
|
-
|
|
316
|
-
/** Standard ECL semantic token type names. */
|
|
317
|
-
export declare const eclTokenTypes: readonly ["keyword", "operator", "number", "string", "comment", "property", "type", "variable", "macro"];
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Context needed to refine a raw ANTLR parse error into a user-friendly diagnostic.
|
|
321
|
-
*/
|
|
322
|
-
declare interface ErrorContext {
|
|
323
|
-
/** The ANTLR parse error. */
|
|
324
|
-
error: ParseError;
|
|
325
|
-
/** All document lines (for EOF relocation). */
|
|
326
|
-
lines: string[];
|
|
327
|
-
/** The document line index where the error was reported. */
|
|
328
|
-
docLineIndex: number;
|
|
329
|
-
/** Line offsets mapping expression-local lines to document lines. */
|
|
330
|
-
lineOffsets: number[];
|
|
331
|
-
/** Start line of the expression in the document. */
|
|
332
|
-
startLine: number;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
declare interface EvaluationConcept {
|
|
336
|
-
code: string;
|
|
337
|
-
display: string;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export declare interface EvaluationResponse {
|
|
341
|
-
total: number;
|
|
342
|
-
concepts: EvaluationConcept[];
|
|
343
|
-
truncated: boolean;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export declare function expandToExpressionBoundaries(text: string, range: CoreRange): CoreRange;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Represents a single ECL expression in a document.
|
|
350
|
-
* Expressions are separated by ECL-END comment delimiters.
|
|
351
|
-
*/
|
|
352
|
-
declare interface Expression {
|
|
353
|
-
text: string;
|
|
354
|
-
startLine: number;
|
|
355
|
-
endLine: number;
|
|
356
|
-
lineOffsets: number[];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Single-pass error analysis for ECL expressions.
|
|
361
|
-
*
|
|
362
|
-
* Replaces 7 independent character-scanning heuristics with:
|
|
363
|
-
* 1. groupTokens() — one pass to produce logical tokens
|
|
364
|
-
* 2. analyzeExpression() — one iteration over tokens for all checks
|
|
365
|
-
*/
|
|
366
|
-
declare interface ExpressionIssues {
|
|
367
|
-
mixedOperator: {
|
|
368
|
-
firstOp: string;
|
|
369
|
-
conflictOp: string;
|
|
370
|
-
line: number;
|
|
371
|
-
column: number;
|
|
372
|
-
} | null;
|
|
373
|
-
missingColonBeforeBrace: {
|
|
374
|
-
line: number;
|
|
375
|
-
column: number;
|
|
376
|
-
} | null;
|
|
377
|
-
trailingOperator: {
|
|
378
|
-
op: string;
|
|
379
|
-
line: number;
|
|
380
|
-
column: number;
|
|
381
|
-
} | null;
|
|
382
|
-
duplicateOperator: {
|
|
383
|
-
op: string;
|
|
384
|
-
line: number;
|
|
385
|
-
column: number;
|
|
386
|
-
} | null;
|
|
387
|
-
danglingEquals: {
|
|
388
|
-
line: number;
|
|
389
|
-
column: number;
|
|
390
|
-
} | null;
|
|
391
|
-
unclosedParen: {
|
|
392
|
-
line: number;
|
|
393
|
-
column: number;
|
|
394
|
-
} | null;
|
|
395
|
-
missingWhitespace: {
|
|
396
|
-
op: string;
|
|
397
|
-
side: 'before' | 'after';
|
|
398
|
-
line: number;
|
|
399
|
-
column: number;
|
|
400
|
-
} | null;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export declare interface ExpressionNode extends ASTNode {
|
|
404
|
-
type: NodeType.ExpressionConstraint;
|
|
405
|
-
expression: SubExpressionNode | CompoundExpressionNode | RefinedExpressionNode | DottedExpressionNode;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
export declare function extractCompoundOperands(sourceText: string, operands: SubExpressionNode[]): OperandInfo[];
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Extracts all concept IDs from an ECL AST.
|
|
412
|
-
* @param ast The root expression node
|
|
413
|
-
* @returns Array of concept references with their positions
|
|
414
|
-
*/
|
|
415
|
-
export declare function extractConceptIds(ast: ExpressionNode, options?: {
|
|
416
|
-
deduplicate?: boolean;
|
|
417
|
-
}): ConceptReference[];
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Extract structured refinement info from a RefinedExpressionNode.
|
|
421
|
-
*/
|
|
422
|
-
export declare function extractRefinementInfo(node: RefinedExpressionNode, sourceText: string): RefinementInfo;
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Extract the original ECL text for an AST node using its range offsets.
|
|
426
|
-
*/
|
|
427
|
-
export declare function extractText(sourceText: string, range: Range): string;
|
|
428
|
-
|
|
429
|
-
export declare class FhirTerminologyService implements ITerminologyService {
|
|
430
|
-
private readonly cache;
|
|
431
|
-
private readonly searchCache;
|
|
432
|
-
private readonly baseUrl;
|
|
433
|
-
private readonly timeout;
|
|
434
|
-
private readonly userAgent;
|
|
435
|
-
private readonly evaluationTimeout;
|
|
436
|
-
private readonly searchTimeout;
|
|
437
|
-
private readonly searchCacheTTL;
|
|
438
|
-
private readonly snomedVersion;
|
|
439
|
-
private readonly evaluationStrategy;
|
|
440
|
-
private readonly onResolvedVersion;
|
|
441
|
-
private resolvedVersion;
|
|
442
|
-
/**
|
|
443
|
-
* Latched once a POST `ValueSet/$expand` fallback has succeeded in `'auto'` mode: the
|
|
444
|
-
* server has demonstrated it cannot serve the implicit ValueSet URL form, so subsequent
|
|
445
|
-
* evaluations skip the wasted round-trip for the lifetime of this instance.
|
|
446
|
-
*/
|
|
447
|
-
private usePostExpand;
|
|
448
|
-
/**
|
|
449
|
-
* Latched once a bulk `ValueSet/$expand` has been rejected with a 4xx: the server does
|
|
450
|
-
* not accept a POSTed ValueSet enumerating concepts in `compose.include.concept`, and
|
|
451
|
-
* the request shape never varies, so retrying it on every validation pass only costs a
|
|
452
|
-
* wasted round-trip and a console warning (issue #55). 5xx responses are treated as
|
|
453
|
-
* transient and do not latch.
|
|
454
|
-
*/
|
|
455
|
-
private bulkExpandUnsupported;
|
|
456
|
-
private readonly queue;
|
|
457
|
-
constructor(options?: FhirTerminologyServiceOptions);
|
|
458
|
-
/** The SNOMED CT system URL base for implicit ValueSet URLs. */
|
|
459
|
-
private get snomedSystemUrl();
|
|
460
|
-
/** Get the resolved version URI from the most recent FHIR response, if captured. */
|
|
461
|
-
getResolvedVersion(): string | null;
|
|
462
|
-
/**
|
|
463
|
-
* Extract a SNOMED version URI from an $expand parameter array.
|
|
464
|
-
*
|
|
465
|
-
* FHIR servers may report the resolved version as:
|
|
466
|
-
* - `{ name: "version", valueUri: "http://snomed.info/sct/.../version/..." }`
|
|
467
|
-
* - `{ name: "used-codesystem", valueUri: "http://snomed.info/sct|http://snomed.info/sct/.../version/..." }`
|
|
468
|
-
* - Either field as `valueString` instead of `valueUri`
|
|
469
|
-
*/
|
|
470
|
-
private captureResolvedVersion;
|
|
471
|
-
/** Extract resolved version from a $lookup Parameters response. */
|
|
472
|
-
private captureResolvedVersionFromLookup;
|
|
473
|
-
/** Search expansion parameters for a SNOMED version URI. */
|
|
474
|
-
private extractSnomedVersionFromParams;
|
|
475
|
-
/**
|
|
476
|
-
* Parse a SNOMED version URI from a raw parameter value.
|
|
477
|
-
* Handles plain URIs and pipe-delimited `system|version` format.
|
|
478
|
-
*/
|
|
479
|
-
private parseSnomedVersionValue;
|
|
480
|
-
private fetchWithTimeout;
|
|
481
|
-
/**
|
|
482
|
-
* Perform a request, translating any network-level failure (connection
|
|
483
|
-
* refused, DNS failure, timeout/abort) into a {@link TerminologyTransportError}
|
|
484
|
-
* so callers can tell "server unreachable" from "server said no".
|
|
485
|
-
*/
|
|
486
|
-
private request;
|
|
487
|
-
/** Read the body of an error response, extracting a FHIR OperationOutcome if present. */
|
|
488
|
-
private static readErrorBody;
|
|
489
|
-
/** Issue codes a FHIR server uses to say "this code is not in the code system". */
|
|
490
|
-
private static readonly UNKNOWN_CODE_ISSUE_CODES;
|
|
491
|
-
/** Phrases servers use in OperationOutcome prose when a code is unknown. */
|
|
492
|
-
private static readonly UNKNOWN_CODE_PHRASES;
|
|
493
|
-
/**
|
|
494
|
-
* True when an error response is the server's well-formed way of saying
|
|
495
|
-
* "I do not know this code" — the one case that maps to `null` rather than
|
|
496
|
-
* an exception.
|
|
497
|
-
*
|
|
498
|
-
* A 404 is only accepted as such when the body is a real FHIR
|
|
499
|
-
* OperationOutcome; a bare 404 (wrong base URL, proxy page) is a fault.
|
|
500
|
-
*/
|
|
501
|
-
private static isUnknownCodeResponse;
|
|
502
|
-
/**
|
|
503
|
-
* Look up a single concept.
|
|
504
|
-
*
|
|
505
|
-
* @returns the concept, or `null` when the terminology server gave a
|
|
506
|
-
* well-formed answer saying the code is unknown to it.
|
|
507
|
-
* @throws {TerminologyTransportError} when the server could not be reached,
|
|
508
|
-
* the request timed out, or the response body was unusable.
|
|
509
|
-
* @throws {TerminologyHttpError} when the server answered with an error
|
|
510
|
-
* status that is not an "unknown code" response.
|
|
511
|
-
*/
|
|
512
|
-
private fetchWithRetry;
|
|
513
|
-
private fetchQueued;
|
|
514
|
-
getConceptInfo(conceptId: string): Promise<ConceptInfo | null>;
|
|
515
|
-
/** Map of SNOMED CT historical association reference set IDs to association types. */
|
|
516
|
-
private static readonly ASSOCIATION_REFSETS;
|
|
517
|
-
getHistoricalAssociations(conceptId: string): Promise<HistoricalAssociation[]>;
|
|
518
|
-
/** Query a single implicit ConceptMap for historical association targets. */
|
|
519
|
-
private translateAssociation;
|
|
520
|
-
/**
|
|
521
|
-
* Validate a batch of concepts.
|
|
522
|
-
*
|
|
523
|
-
* A `null` map value means the terminology server positively reported the
|
|
524
|
-
* code as unknown. Failures are never reported as `null` — they reject.
|
|
525
|
-
*
|
|
526
|
-
* @throws {TerminologyTransportError} when the server could not be reached.
|
|
527
|
-
* @throws {TerminologyHttpError} when the server answered with an error status.
|
|
528
|
-
*/
|
|
529
|
-
validateConcepts(conceptIds: string[]): Promise<Map<string, ConceptInfo | null>>;
|
|
530
|
-
/**
|
|
531
|
-
* Move concepts found in a bulk expansion into `results` (and the cache),
|
|
532
|
-
* returning the IDs that were absent and still need an individual lookup.
|
|
533
|
-
*/
|
|
534
|
-
private mergeExpandResults;
|
|
535
|
-
/**
|
|
536
|
-
* Move already-cached concepts into `results`, returning the IDs still to fetch.
|
|
537
|
-
*/
|
|
538
|
-
private partitionCached;
|
|
539
|
-
/** Look each concept up individually, recording the result (or `null` if absent). */
|
|
540
|
-
private lookupEach;
|
|
541
|
-
private bulkExpand;
|
|
542
|
-
/**
|
|
543
|
-
* Search for concepts by text or SCTID.
|
|
544
|
-
*
|
|
545
|
-
* An empty result set means the server found no matches.
|
|
546
|
-
*
|
|
547
|
-
* @throws {TerminologyTransportError} when the server could not be reached.
|
|
548
|
-
* @throws {TerminologyHttpError} when the server answered with an error status.
|
|
549
|
-
*/
|
|
550
|
-
searchConcepts(query: string): Promise<SearchResponse>;
|
|
551
|
-
private lookupById;
|
|
552
|
-
evaluateEcl(expression: string, limit?: number): Promise<EvaluationResponse>;
|
|
553
|
-
/**
|
|
554
|
-
* Transport selection for {@link evaluateEcl}.
|
|
555
|
-
*
|
|
556
|
-
* A forced `'post'` strategy — or a latched successful POST fallback — goes straight to
|
|
557
|
-
* `POST ValueSet/$expand`. Otherwise the implicit ValueSet URL GET runs first, and in
|
|
558
|
-
* `'auto'` mode a failure whose *shape* says the server cannot serve implicit ValueSets
|
|
559
|
-
* (issue #55) is retried over POST.
|
|
560
|
-
*/
|
|
561
|
-
private runEvaluationStrategy;
|
|
562
|
-
/** `GET ValueSet/$expand?url=<canonical implicit ECL ValueSet>` — see {@link encodeEclForCanonicalUrl}. */
|
|
563
|
-
private buildImplicitEvaluationUrl;
|
|
564
|
-
/**
|
|
565
|
-
* `POST ValueSet/$expand` carrying the ECL in `compose.include.filter` with
|
|
566
|
-
* `property: "constraint"` — the form requested in issue #55. The expression travels in a
|
|
567
|
-
* JSON body, so it needs no escaping at all.
|
|
568
|
-
*/
|
|
569
|
-
private evaluateViaPostExpand;
|
|
570
|
-
/**
|
|
571
|
-
* True when an implicit-URL failure indicates the implicit ValueSet *form* is unsupported
|
|
572
|
-
* rather than the expression being invalid.
|
|
573
|
-
*
|
|
574
|
-
* Deliberately excludes a bare HTTP 422: that is also how a genuine ECL syntax error
|
|
575
|
-
* presents, and retrying those over POST would only turn one clear error into two requests
|
|
576
|
-
* and a muddled message. The `'not-found'` OperationOutcome code is still honoured on any
|
|
577
|
-
* status, which covers servers that report a missing implicit ValueSet as 422.
|
|
578
|
-
*/
|
|
579
|
-
private shouldFallbackToPostExpand;
|
|
580
|
-
/** Remaining milliseconds in the shared evaluation budget; throws once it is spent. */
|
|
581
|
-
private remainingTimeout;
|
|
582
|
-
/** The machine-readable code and human-readable text of a FHIR error response. */
|
|
583
|
-
private readOperationOutcome;
|
|
584
|
-
/** Shared expansion mapping for both the implicit-URL and POST evaluation transports. */
|
|
585
|
-
private parseEvaluationResponse;
|
|
586
|
-
private createEvaluationError;
|
|
587
|
-
private searchByFilter;
|
|
588
|
-
/** Fetch available SNOMED CT editions and versions from the FHIR server. */
|
|
589
|
-
getSnomedEditions(): Promise<SnomedEdition[]>;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
export declare interface FhirTerminologyServiceOptions {
|
|
593
|
-
baseUrl?: string;
|
|
594
|
-
timeout?: number;
|
|
595
|
-
userAgent?: string;
|
|
596
|
-
snomedVersion?: string;
|
|
597
|
-
/** ECL evaluation transport; defaults to `'auto'`. See {@link EclEvaluationStrategy}. */
|
|
598
|
-
evaluationStrategy?: EclEvaluationStrategy;
|
|
599
|
-
onResolvedVersion?: (versionUri: string) => void;
|
|
600
|
-
maxConcurrency?: number;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
export declare interface FilterConstraintNode extends ASTNode {
|
|
604
|
-
type: NodeType.FilterConstraint;
|
|
605
|
-
filterType: 'description' | 'concept' | 'member';
|
|
606
|
-
conceptExpressions: SubExpressionNode[];
|
|
607
|
-
conceptReferences: ConceptReferenceNode[];
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/** Sub-context within a filter block. */
|
|
611
|
-
export declare type FilterSubContext = 'after-opening' | 'after-keyword' | {
|
|
612
|
-
kind: 'after-equals';
|
|
613
|
-
keyword: string | null;
|
|
614
|
-
} | 'after-value';
|
|
615
|
-
|
|
616
|
-
/** Filter type character for filter blocks. */
|
|
617
|
-
export declare type FilterType = 'D' | 'C' | 'M' | '+';
|
|
618
|
-
|
|
619
|
-
export declare function formatDocument(text: string, options: FormattingOptions): string;
|
|
620
|
-
|
|
621
|
-
export declare function formatRangeExpressions(expressions: {
|
|
622
|
-
start: number;
|
|
623
|
-
end: number;
|
|
624
|
-
text: string;
|
|
625
|
-
}[], text: string, formatFunction: (text: string) => string): {
|
|
626
|
-
range: CoreRange;
|
|
627
|
-
newText: string;
|
|
628
|
-
}[];
|
|
629
|
-
|
|
630
|
-
export declare interface FormattingOptions {
|
|
631
|
-
indentSize: number;
|
|
632
|
-
indentStyle: 'space' | 'tab';
|
|
633
|
-
/**
|
|
634
|
-
* Accepted for backwards compatibility, but has no effect.
|
|
635
|
-
*
|
|
636
|
-
* It only ever applied to the AND, OR and MINUS keywords, and the ECL grammar
|
|
637
|
-
* requires mandatory whitespace around those. Setting it to `false` produced
|
|
638
|
-
* output that no longer parsed (`< 404684003AND< 19829001`), so keyword
|
|
639
|
-
* operators now always keep their spaces. Constraint operators (`<`, `<<`,
|
|
640
|
-
* `^`) were never affected by this option.
|
|
641
|
-
*/
|
|
642
|
-
spaceAroundOperators: boolean;
|
|
643
|
-
maxLineLength: number;
|
|
644
|
-
alignTerms: boolean;
|
|
645
|
-
/** Wrap comment text that exceeds maxLineLength. Defaults to false. */
|
|
646
|
-
wrapComments: boolean;
|
|
647
|
-
/**
|
|
648
|
-
* Force a newline before every AND, OR, or MINUS operator.
|
|
649
|
-
* When true, each logical operator begins on its own continuation line,
|
|
650
|
-
* indented one level from the expression start.
|
|
651
|
-
* Defaults to false (operators are kept on the same line up to maxLineLength).
|
|
652
|
-
*/
|
|
653
|
-
breakOnOperators: boolean;
|
|
654
|
-
/**
|
|
655
|
-
* Force a newline after every comma inside a refinement attribute list.
|
|
656
|
-
* When true, each attribute starts on its own line, indented appropriately.
|
|
657
|
-
* Defaults to false.
|
|
658
|
-
*/
|
|
659
|
-
breakOnRefinementComma: boolean;
|
|
660
|
-
/**
|
|
661
|
-
* Force a newline after the refinement colon (:).
|
|
662
|
-
* When true, the attributes or attribute group following a colon start on
|
|
663
|
-
* a new line, indented one level from the focus concept.
|
|
664
|
-
* Defaults to false.
|
|
665
|
-
*/
|
|
666
|
-
breakAfterColon: boolean;
|
|
667
|
-
/**
|
|
668
|
-
* Remove parentheses that don't change the meaning of the expression.
|
|
669
|
-
* Removes parens around non-compound expressions (e.g. `(404684003)` → `404684003`)
|
|
670
|
-
* and flattens same-operator nesting (e.g. `(A AND B) AND C` → `A AND B AND C`).
|
|
671
|
-
* Defaults to false.
|
|
672
|
-
*/
|
|
673
|
-
removeRedundantParentheses: boolean;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
/** Look up an article by its ID */
|
|
677
|
-
export declare function getArticle(id: string): KnowledgeArticle | undefined;
|
|
678
|
-
|
|
679
|
-
/** Get all articles in a category */
|
|
680
|
-
export declare function getArticlesByCategory(category: string): KnowledgeArticle[];
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* Determines which completion items to return given cursor context.
|
|
684
|
-
*
|
|
685
|
-
* Pure function — no LSP dependencies — so it can be unit-tested.
|
|
686
|
-
*
|
|
687
|
-
* @param inExpression Whether the cursor is inside a recognised expression
|
|
688
|
-
* @param textBeforeCursor Full text from expression start to cursor (multi-line)
|
|
689
|
-
* @param currentLine Text of the current line only
|
|
690
|
-
* @param cursorColumn Column position of cursor within the current line
|
|
691
|
-
* @returns Array of CompletionItem to present
|
|
692
|
-
*/
|
|
693
|
-
export declare function getCompletionItems(inExpression: boolean, textBeforeCursor: string, _currentLine: string, _cursorColumn: number): CoreCompletionItem[];
|
|
694
|
-
|
|
695
|
-
/**
|
|
696
|
-
* Async wrapper around getCompletionItems that also searches for concepts
|
|
697
|
-
* via the terminology service when the user appears to be typing a term.
|
|
698
|
-
*/
|
|
699
|
-
export declare function getCompletionItemsWithSearch(inExpression: boolean, textBeforeCursor: string, currentLine: string, cursorColumn: number, lineNumber: number, terminologyService: ITerminologyService | null): Promise<CoreCompletionItem[]>;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Determines the priority/context for concept search in completion.
|
|
703
|
-
*
|
|
704
|
-
* @param line - The text of the current line
|
|
705
|
-
* @param cursorPosition - The character position of the cursor
|
|
706
|
-
* @returns 'high' if search should be prioritized, 'low' if operators should be prioritized
|
|
707
|
-
*/
|
|
708
|
-
export declare function getConceptSearchPriority(line: string, cursorPosition: number): 'high' | 'low';
|
|
709
|
-
|
|
710
|
-
export declare function getExpressionsInRange(text: string, range: CoreRange): {
|
|
711
|
-
start: number;
|
|
712
|
-
end: number;
|
|
713
|
-
text: string;
|
|
714
|
-
}[];
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Get FHIR-powered completion items for a filter keyword.
|
|
718
|
-
*
|
|
719
|
-
* Evaluates the ECL constraint for the keyword against the terminology server,
|
|
720
|
-
* caches the result, and returns CompletionItems. Returns [] on FHIR errors.
|
|
721
|
-
*/
|
|
722
|
-
export declare function getFhirFilterCompletions(keyword: string, terminologyService: ITerminologyService): Promise<CoreCompletionItem[]>;
|
|
723
|
-
|
|
724
|
-
/** Look up a knowledge guide by URI */
|
|
725
|
-
export declare function getGuide(uri: string): KnowledgeGuide | undefined;
|
|
726
|
-
|
|
727
|
-
/** Get hover markdown for an operator symbol or keyword (case-insensitive for keywords) */
|
|
728
|
-
export declare function getOperatorHoverDoc(operator: string): string | undefined;
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* Returns refactoring code actions for the given document and cursor range.
|
|
732
|
-
* Called from the onCodeAction handler alongside diagnostic quick fixes.
|
|
733
|
-
*
|
|
734
|
-
* Finds the full (possibly multi-line) expression containing the cursor,
|
|
735
|
-
* offers whole-expression refactorings, and also offers sub-expression
|
|
736
|
-
* refactorings when the cursor is inside a parenthesized group.
|
|
737
|
-
*/
|
|
738
|
-
export declare function getRefactoringActions(documentUri: string, documentText: string, range: CoreRange): CoreCodeAction[];
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Get a substring from text using a CoreRange.
|
|
742
|
-
* Equivalent to TextDocument.getText(range).
|
|
743
|
-
*/
|
|
744
|
-
export declare function getText(text: string, range?: CoreRange): string;
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* Determines which ECL operators are syntactically valid at the cursor position.
|
|
748
|
-
* Uses regex pattern matching to analyze the context before the cursor.
|
|
749
|
-
*
|
|
750
|
-
* Context detection patterns:
|
|
751
|
-
* 1. After complete constraint → logical operators (AND, OR, MINUS) + refinement (:)
|
|
752
|
-
* 2. After constraint operator → no operators (concept expected)
|
|
753
|
-
* 3. After logical operator → constraint operators (<, <<, >, >>)
|
|
754
|
-
* 4. Start of expression → constraint operators
|
|
755
|
-
* 5. After refinement/attribute operators → constraint operators
|
|
756
|
-
* 6. Ambiguous context → all operators (fail open)
|
|
757
|
-
*
|
|
758
|
-
* @param line - The text of the current line
|
|
759
|
-
* @param position - The character position of the cursor (0-indexed)
|
|
760
|
-
* @returns Array of valid operator strings at this position
|
|
761
|
-
*/
|
|
762
|
-
export declare function getValidOperatorsAtPosition(line: string, position: number): string[];
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Groups document lines into ECL expressions.
|
|
766
|
-
* Expressions are separated by ECL-END comment delimiters.
|
|
767
|
-
* Each expression can be multi-line.
|
|
768
|
-
*
|
|
769
|
-
* @param text - The full document text
|
|
770
|
-
* @returns Array of expressions with their positions in the document
|
|
771
|
-
*/
|
|
772
|
-
export declare function groupIntoExpressions(text: string): Expression[];
|
|
773
|
-
|
|
774
|
-
export declare interface HistoricalAssociation {
|
|
775
|
-
type: HistoricalAssociationType;
|
|
776
|
-
refsetId: string;
|
|
777
|
-
targets: {
|
|
778
|
-
code: string;
|
|
779
|
-
display: string;
|
|
780
|
-
}[];
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
export declare type HistoricalAssociationType = 'same-as' | 'replaced-by' | 'possibly-equivalent-to' | 'alternative';
|
|
784
|
-
|
|
785
|
-
export declare interface HistorySupplementNode extends ASTNode {
|
|
786
|
-
type: NodeType.HistorySupplement;
|
|
787
|
-
profile?: 'MIN' | 'MOD' | 'MAX';
|
|
788
|
-
subsetExpression?: ExpressionNode;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* Detects if a cursor position in ECL syntax is valid for concept insertion.
|
|
793
|
-
*
|
|
794
|
-
* Valid concept positions occur after:
|
|
795
|
-
* - Constraint operators: < << > >>
|
|
796
|
-
* - Logical operators: AND OR MINUS
|
|
797
|
-
* - Refinement separator: :
|
|
798
|
-
* - Attribute value separator: =
|
|
799
|
-
* - Start of line
|
|
800
|
-
* - Opening parenthesis: (
|
|
801
|
-
*/
|
|
802
|
-
/**
|
|
803
|
-
* Determines if the cursor position is valid for inserting a concept ID.
|
|
804
|
-
*
|
|
805
|
-
* @param line - The text of the current line
|
|
806
|
-
* @param cursorPosition - The character position of the cursor (0-indexed)
|
|
807
|
-
* @returns true if a concept ID can be inserted at this position
|
|
808
|
-
*/
|
|
809
|
-
export declare function isConceptPositionValid(line: string, cursorPosition: number): boolean;
|
|
810
|
-
|
|
811
|
-
/** Type guard for {@link EclEvaluationStrategy} (unknown values degrade to `'auto'`). */
|
|
812
|
-
export declare function isEclEvaluationStrategy(value: unknown): value is EclEvaluationStrategy;
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* True when `value` is a terminology failure.
|
|
816
|
-
*
|
|
817
|
-
* Checks structurally as well as by `instanceof`, so it still works when a dual
|
|
818
|
-
* CJS/ESM build loads two copies of this module.
|
|
819
|
-
*/
|
|
820
|
-
export declare function isTerminologyError(value: unknown): value is TerminologyError;
|
|
821
|
-
|
|
822
|
-
/** True when `value` is an HTTP error response from the terminology server. */
|
|
823
|
-
export declare function isTerminologyHttpError(value: unknown): value is TerminologyHttpError;
|
|
824
|
-
|
|
825
|
-
/** True when `value` is a transport failure — the server was not reached. */
|
|
826
|
-
export declare function isTerminologyTransportError(value: unknown): value is TerminologyTransportError;
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Validates that a SNOMED CT identifier is a concept ID.
|
|
830
|
-
*
|
|
831
|
-
* Concept IDs use partition identifiers 00 (core) or 10 (extension with namespace).
|
|
832
|
-
*
|
|
833
|
-
* @param sctid - The SNOMED CT identifier to validate
|
|
834
|
-
* @returns true if the ID is a valid SNOMED CT concept identifier
|
|
835
|
-
*/
|
|
836
|
-
export declare function isValidConceptId(sctid: string): boolean;
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
* Validates that a SNOMED CT identifier is a description ID.
|
|
840
|
-
*
|
|
841
|
-
* Description IDs use partition identifiers 01 (core) or 11 (extension).
|
|
842
|
-
*
|
|
843
|
-
* @param sctid - The SNOMED CT identifier to validate
|
|
844
|
-
* @returns true if the ID is a valid SNOMED CT description identifier
|
|
845
|
-
*/
|
|
846
|
-
export declare function isValidDescriptionId(sctid: string): boolean;
|
|
847
|
-
|
|
848
|
-
/**
|
|
849
|
-
* Validates a SNOMED CT identifier format.
|
|
850
|
-
*
|
|
851
|
-
* Rules:
|
|
852
|
-
* - Must be 6-18 digits long
|
|
853
|
-
* - Must pass Verhoeff check digit validation
|
|
854
|
-
* - Penultimate two digits are the partition identifier
|
|
855
|
-
*
|
|
856
|
-
* @param conceptId - The SNOMED CT concept ID to validate
|
|
857
|
-
* @returns true if the ID is a valid SNOMED CT identifier, false otherwise
|
|
858
|
-
*/
|
|
859
|
-
export declare function isValidSnomedId(conceptId: string): boolean;
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* A source of SNOMED CT terminology facts.
|
|
863
|
-
*
|
|
864
|
-
* **Failure contract.** Implementations MUST distinguish "the server told me
|
|
865
|
-
* this concept does not exist" from "I could not ask the server". A `null`
|
|
866
|
-
* result is a factual claim about SNOMED CT content and is only permitted for
|
|
867
|
-
* the former; every failure — connection refused, DNS failure, timeout, HTTP
|
|
868
|
-
* error status, unreadable body — MUST reject with a `TerminologyError`
|
|
869
|
-
* (`TerminologyTransportError` or `TerminologyHttpError`), so that callers can
|
|
870
|
-
* classify it structurally via its `kind` discriminant and `status`, rather
|
|
871
|
-
* than rendering an outage as "concept not found".
|
|
872
|
-
*/
|
|
873
|
-
export declare interface ITerminologyService {
|
|
874
|
-
/**
|
|
875
|
-
* Look up a single concept.
|
|
876
|
-
*
|
|
877
|
-
* @returns the concept, or `null` ONLY when the terminology server gave a
|
|
878
|
-
* well-formed answer saying the code is unknown to it.
|
|
879
|
-
* @throws `TerminologyTransportError` when the server could not be reached,
|
|
880
|
-
* the request timed out, or the response was unusable.
|
|
881
|
-
* @throws `TerminologyHttpError` when the server answered with an error status.
|
|
882
|
-
*/
|
|
883
|
-
getConceptInfo(conceptId: string): Promise<ConceptInfo | null>;
|
|
884
|
-
/**
|
|
885
|
-
* Validate a batch of concepts.
|
|
886
|
-
*
|
|
887
|
-
* @returns a map from concept ID to its info, or to `null` ONLY when the
|
|
888
|
-
* server positively reported that code as unknown.
|
|
889
|
-
* @throws `TerminologyTransportError` / `TerminologyHttpError` on failure —
|
|
890
|
-
* never a map full of `null`s.
|
|
891
|
-
*/
|
|
892
|
-
validateConcepts(conceptIds: string[]): Promise<Map<string, ConceptInfo | null>>;
|
|
893
|
-
/**
|
|
894
|
-
* Search for concepts by text or SCTID.
|
|
895
|
-
*
|
|
896
|
-
* @returns matches; an empty result set means the server found none.
|
|
897
|
-
* @throws `TerminologyTransportError` / `TerminologyHttpError` on failure —
|
|
898
|
-
* never an empty result set, and never an opaque generic `Error`.
|
|
899
|
-
*/
|
|
900
|
-
searchConcepts(query: string): Promise<SearchResponse>;
|
|
901
|
-
/** Expand an ECL expression. Throws on failure. */
|
|
902
|
-
evaluateEcl(expression: string, limit?: number): Promise<EvaluationResponse>;
|
|
903
|
-
/** Historical associations for an inactive concept, if the source supports them. */
|
|
904
|
-
getHistoricalAssociations?(conceptId: string): Promise<HistoricalAssociation[]>;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
/** A single knowledge article (e.g., one operator, one pattern) */
|
|
908
|
-
export declare interface KnowledgeArticle {
|
|
909
|
-
/** Unique identifier (e.g., 'op:descendantOf', 'pattern:disorders-by-site') */
|
|
910
|
-
id: string;
|
|
911
|
-
/** Category for grouping */
|
|
912
|
-
category: KnowledgeCategory;
|
|
913
|
-
/** Short human-readable name */
|
|
914
|
-
name: string;
|
|
915
|
-
/** One-line description */
|
|
916
|
-
summary: string;
|
|
917
|
-
/** Full Markdown documentation */
|
|
918
|
-
content: string;
|
|
919
|
-
/** ECL example expressions */
|
|
920
|
-
examples: string[];
|
|
921
|
-
/** Related article IDs */
|
|
922
|
-
related: string[];
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* Knowledge module types for structured ECL reference documentation.
|
|
927
|
-
*/
|
|
928
|
-
/** Category of knowledge content */
|
|
929
|
-
export declare type KnowledgeCategory = 'operator' | 'refinement' | 'filter' | 'pattern' | 'grammar' | 'history';
|
|
930
|
-
|
|
931
|
-
/** A knowledge guide — a curated collection of articles on a topic */
|
|
932
|
-
export declare interface KnowledgeGuide {
|
|
933
|
-
/** URI identifier (e.g., 'ecl://guide/operators') */
|
|
934
|
-
uri: string;
|
|
935
|
-
/** Display name */
|
|
936
|
-
name: string;
|
|
937
|
-
/** Brief description */
|
|
938
|
-
description: string;
|
|
939
|
-
/** Full Markdown content */
|
|
940
|
-
content: string;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
/** Pre-built knowledge guides, keyed by URI */
|
|
944
|
-
export declare const knowledgeGuides: readonly KnowledgeGuide[];
|
|
945
|
-
|
|
946
|
-
declare interface LogicalOperatorNode extends ASTNode {
|
|
947
|
-
type: NodeType.LogicalOperator;
|
|
948
|
-
operator: 'AND' | 'OR' | 'MINUS';
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
declare enum NodeType {
|
|
952
|
-
ExpressionConstraint = "ExpressionConstraint",
|
|
953
|
-
SubExpressionConstraint = "SubExpressionConstraint",
|
|
954
|
-
CompoundExpression = "CompoundExpression",
|
|
955
|
-
RefinedExpression = "RefinedExpression",
|
|
956
|
-
DottedExpression = "DottedExpression",
|
|
957
|
-
DottedAttribute = "DottedAttribute",
|
|
958
|
-
ConceptReference = "ConceptReference",
|
|
959
|
-
ConstraintOperator = "ConstraintOperator",
|
|
960
|
-
LogicalOperator = "LogicalOperator",
|
|
961
|
-
Refinement = "Refinement",
|
|
962
|
-
AttributeSet = "AttributeSet",
|
|
963
|
-
AttributeGroup = "AttributeGroup",
|
|
964
|
-
Attribute = "Attribute",
|
|
965
|
-
AttributeName = "AttributeName",
|
|
966
|
-
AttributeValue = "AttributeValue",
|
|
967
|
-
Wildcard = "Wildcard",
|
|
968
|
-
FilterConstraint = "FilterConstraint",
|
|
969
|
-
HistorySupplement = "HistorySupplement"
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Convert a CorePosition (line, character) to a 0-based offset in a text string.
|
|
974
|
-
* Equivalent to TextDocument.offsetAt().
|
|
975
|
-
*/
|
|
976
|
-
export declare function offsetAt(text: string, position: CorePosition): number;
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Extract ECL text for each operand in a compound expression.
|
|
980
|
-
*/
|
|
981
|
-
declare interface OperandInfo {
|
|
982
|
-
ecl: string;
|
|
983
|
-
range: Range;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
/** Operator hover documentation — concise markdown for IDE hover tooltips */
|
|
987
|
-
export declare interface OperatorHoverDoc {
|
|
988
|
-
/** The operator symbol or keyword (e.g., '<', '<<', 'AND') */
|
|
989
|
-
operator: string;
|
|
990
|
-
/** Markdown hover content */
|
|
991
|
-
markdown: string;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* Hover documentation for all operators — concise markdown for IDE tooltips.
|
|
996
|
-
*/
|
|
997
|
-
export declare const operatorHoverDocs: OperatorHoverDoc[];
|
|
998
|
-
|
|
999
|
-
declare interface OperatorNode extends ASTNode {
|
|
1000
|
-
type: NodeType.ConstraintOperator;
|
|
1001
|
-
operator: '<' | '<<' | '>' | '>>' | '<!' | '<<!' | '>!' | '>>!';
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
export declare function parseECL(input: string): ParseResult;
|
|
1005
|
-
|
|
1006
|
-
export declare interface ParseError {
|
|
1007
|
-
line: number;
|
|
1008
|
-
column: number;
|
|
1009
|
-
message: string;
|
|
1010
|
-
offendingSymbol?: any;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
export declare interface ParseResult {
|
|
1014
|
-
ast: ExpressionNode | null;
|
|
1015
|
-
errors: ParseError[];
|
|
1016
|
-
/**
|
|
1017
|
-
* Warnings about spec-compliance issues that the ANTLR grammar accepts
|
|
1018
|
-
* but the ECL specification does not allow.
|
|
1019
|
-
*
|
|
1020
|
-
* Currently detects mixed AND/OR in refinements (IHTSDO/snomed-expression-constraint-language#12).
|
|
1021
|
-
* This field can be removed once the upstream grammar is fixed.
|
|
1022
|
-
*/
|
|
1023
|
-
warnings: RefinementWarning[];
|
|
1024
|
-
tokens: TokenInfo[];
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
declare interface Position {
|
|
1028
|
-
line: number;
|
|
1029
|
-
column: number;
|
|
1030
|
-
offset: number;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* Convert a 0-based offset in a text string to a CorePosition (line, character).
|
|
1035
|
-
* Equivalent to TextDocument.positionAt().
|
|
1036
|
-
*/
|
|
1037
|
-
export declare function positionAt(text: string, offset: number): CorePosition;
|
|
1038
|
-
|
|
1039
|
-
declare interface Range {
|
|
1040
|
-
start: Position;
|
|
1041
|
-
end: Position;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
/** Marker for code actions that need async resolution (FHIR lookups) */
|
|
1045
|
-
export declare const REFACTORING_RESOLVE_KIND = "ecl.refactoring.resolve";
|
|
1046
|
-
|
|
1047
|
-
export declare interface RefactoringContext {
|
|
1048
|
-
documentText: string;
|
|
1049
|
-
documentUri: string;
|
|
1050
|
-
range: CoreRange;
|
|
1051
|
-
/** The full text of the line (or expression) under the cursor */
|
|
1052
|
-
expressionText: string;
|
|
1053
|
-
/** The range of the expression in the document */
|
|
1054
|
-
expressionRange: CoreRange;
|
|
1055
|
-
/** Parsed AST, if available */
|
|
1056
|
-
ast?: ExpressionNode;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
/**
|
|
1060
|
-
* The refined error message and highlight range.
|
|
1061
|
-
*/
|
|
1062
|
-
declare interface RefinedError {
|
|
1063
|
-
message: string;
|
|
1064
|
-
startChar: number;
|
|
1065
|
-
endChar: number;
|
|
1066
|
-
docLineIndex: number;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
export declare interface RefinedExpressionNode extends ASTNode {
|
|
1070
|
-
type: NodeType.RefinedExpression;
|
|
1071
|
-
expression: SubExpressionNode;
|
|
1072
|
-
refinement: RefinementNode;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
/**
|
|
1076
|
-
* Information extracted from a refined expression for semantic validation.
|
|
1077
|
-
*/
|
|
1078
|
-
declare interface RefinementInfo {
|
|
1079
|
-
focusEcl: string;
|
|
1080
|
-
focusRange: Range;
|
|
1081
|
-
attributes: AttributeInfo[];
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* A member of a refinement tree: a single attribute, a `{ }` attribute group,
|
|
1086
|
-
* or a conjunction/disjunction set of members.
|
|
1087
|
-
*/
|
|
1088
|
-
export declare type RefinementMemberNode = AttributeNode | AttributeGroupNode | AttributeSetNode;
|
|
1089
|
-
|
|
1090
|
-
export declare interface RefinementNode extends ASTNode {
|
|
1091
|
-
type: NodeType.Refinement;
|
|
1092
|
-
/**
|
|
1093
|
-
* Every attribute in the refinement, in source order.
|
|
1094
|
-
*
|
|
1095
|
-
* This is a flattened convenience view that carries NO operator or grouping
|
|
1096
|
-
* information — use `content` when the distinction between `,`/`AND`
|
|
1097
|
-
* (conjunction) and `OR` (disjunction) matters, e.g. when printing.
|
|
1098
|
-
*/
|
|
1099
|
-
attributes: AttributeNode[];
|
|
1100
|
-
/**
|
|
1101
|
-
* The refinement tree, preserving the conjunction/disjunction operators and
|
|
1102
|
-
* the grouping (parentheses and `{ }` attribute groups) written in the source.
|
|
1103
|
-
* `null` only when the refinement contains no attributes at all.
|
|
1104
|
-
*/
|
|
1105
|
-
content: RefinementMemberNode | null;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
declare interface RefinementWarning {
|
|
1109
|
-
line: number;
|
|
1110
|
-
column: number;
|
|
1111
|
-
message: string;
|
|
1112
|
-
/** The operator that conflicts with the first one seen. */
|
|
1113
|
-
conflictOp: string;
|
|
1114
|
-
/** Range covering the refinement text for positioning. */
|
|
1115
|
-
range: Range;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/**
|
|
1119
|
-
* Refine a raw ANTLR parse error into a user-friendly message with accurate
|
|
1120
|
-
* highlight positions. This is a pure function — no side effects.
|
|
1121
|
-
*/
|
|
1122
|
-
export declare function refineParseError(ctx: ErrorContext): RefinedError;
|
|
1123
|
-
|
|
1124
|
-
export declare interface ReplacementResult {
|
|
1125
|
-
replacement: string;
|
|
1126
|
-
label: string;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* Resolves an "Add display terms" code action by performing FHIR lookups
|
|
1131
|
-
* for each bare concept ID and inserting display terms into the expression.
|
|
1132
|
-
*
|
|
1133
|
-
* @param codeAction - The unresolved code action (with data attached)
|
|
1134
|
-
* @param terminologyService - FHIR terminology service for concept lookups
|
|
1135
|
-
* @returns The code action with an edit applied, or unchanged on failure
|
|
1136
|
-
*/
|
|
1137
|
-
export declare function resolveAddDisplayTerms(codeAction: CoreCodeAction, terminologyService: ITerminologyService): Promise<CoreCodeAction>;
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* Resolves the unified "Simplify" code action by running the full
|
|
1141
|
-
* bottom-up engine with all techniques including FHIR subsumption.
|
|
1142
|
-
*/
|
|
1143
|
-
export declare function resolveUnifiedSimplify(codeAction: CoreCodeAction, terminologyService: ITerminologyService): Promise<CoreCodeAction>;
|
|
1144
|
-
|
|
1145
|
-
declare interface SearchResponse {
|
|
1146
|
-
results: ConceptSearchResult[];
|
|
1147
|
-
hasMore: boolean;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
export declare interface SemanticDiagnostic {
|
|
1151
|
-
range: Range;
|
|
1152
|
-
message: string;
|
|
1153
|
-
severity: 'warning' | 'info';
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
export declare interface SemanticToken {
|
|
1157
|
-
line: number;
|
|
1158
|
-
character: number;
|
|
1159
|
-
length: number;
|
|
1160
|
-
tokenType: number;
|
|
1161
|
-
tokenModifiers: number;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
/** A SNOMED CT edition with its available versions. */
|
|
1165
|
-
declare interface SnomedEdition {
|
|
1166
|
-
moduleId: string;
|
|
1167
|
-
versions: SnomedVersion[];
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
/** A version of a SNOMED CT edition available on the server. */
|
|
1171
|
-
declare interface SnomedVersion {
|
|
1172
|
-
uri: string;
|
|
1173
|
-
date: string;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
export declare interface SubExpressionNode extends ASTNode {
|
|
1177
|
-
type: NodeType.SubExpressionConstraint;
|
|
1178
|
-
operator?: OperatorNode;
|
|
1179
|
-
memberOf?: boolean;
|
|
1180
|
-
focus: ConceptReferenceNode | WildcardNode | ExpressionNode;
|
|
1181
|
-
filters?: FilterConstraintNode[];
|
|
1182
|
-
historySupplement?: HistorySupplementNode;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
/**
|
|
1186
|
-
* Base class for terminology server failures.
|
|
1187
|
-
*
|
|
1188
|
-
* Never thrown directly — use {@link TerminologyTransportError} or
|
|
1189
|
-
* {@link TerminologyHttpError}, and discriminate on {@link kind}.
|
|
1190
|
-
*/
|
|
1191
|
-
export declare abstract class TerminologyError extends Error {
|
|
1192
|
-
/** Discriminant identifying the class of failure. */
|
|
1193
|
-
abstract readonly kind: TerminologyErrorKind;
|
|
1194
|
-
/**
|
|
1195
|
-
* The underlying failure.
|
|
1196
|
-
*
|
|
1197
|
-
* Declared explicitly (rather than relying on `Error.cause`) so it is part of
|
|
1198
|
-
* the emitted type declarations and is present on every runtime.
|
|
1199
|
-
*/
|
|
1200
|
-
readonly cause: unknown;
|
|
1201
|
-
/** The request URL, when known. */
|
|
1202
|
-
readonly url: string | undefined;
|
|
1203
|
-
/** The HTTP status, present only on {@link TerminologyHttpError}. */
|
|
1204
|
-
readonly status: number | undefined;
|
|
1205
|
-
protected constructor(message: string, options?: TerminologyErrorOptions & {
|
|
1206
|
-
status?: number;
|
|
1207
|
-
});
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
/**
|
|
1211
|
-
* Typed errors for terminology server failures.
|
|
1212
|
-
*
|
|
1213
|
-
* A failure to reach a terminology server is NOT a statement about SNOMED CT.
|
|
1214
|
-
* These types let callers tell the two apart structurally — by the `kind`
|
|
1215
|
-
* discriminant and the HTTP `status` — instead of parsing prose, so a socket
|
|
1216
|
-
* error is never rendered to a user (or an LLM) as "concept not found".
|
|
1217
|
-
*/
|
|
1218
|
-
/**
|
|
1219
|
-
* What went wrong.
|
|
1220
|
-
*
|
|
1221
|
-
* - `transport` — the request never produced an HTTP response: connection
|
|
1222
|
-
* refused, DNS failure, TLS failure, timeout/abort, or an unreadable body.
|
|
1223
|
-
* - `http` — the server answered, but with an error status.
|
|
1224
|
-
*/
|
|
1225
|
-
export declare type TerminologyErrorKind = 'transport' | 'http';
|
|
1226
|
-
|
|
1227
|
-
/** Options common to all terminology errors. */
|
|
1228
|
-
export declare interface TerminologyErrorOptions {
|
|
1229
|
-
/** The underlying failure (network error, abort error, parse error). */
|
|
1230
|
-
cause?: unknown;
|
|
1231
|
-
/** The request URL, when known. */
|
|
1232
|
-
url?: string;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
/**
|
|
1236
|
-
* The terminology server answered with an error status.
|
|
1237
|
-
*
|
|
1238
|
-
* An error status is a statement about the request or the server, not about
|
|
1239
|
-
* SNOMED CT content — with the sole exception of a well-formed "unknown code"
|
|
1240
|
-
* response, which the service converts into `null` rather than an error.
|
|
1241
|
-
*/
|
|
1242
|
-
export declare class TerminologyHttpError extends TerminologyError {
|
|
1243
|
-
readonly kind: "http";
|
|
1244
|
-
/** The HTTP status returned by the server. Always present. */
|
|
1245
|
-
readonly status: number;
|
|
1246
|
-
/** The HTTP reason phrase, when the client exposes one. */
|
|
1247
|
-
readonly statusText: string | undefined;
|
|
1248
|
-
constructor(message: string, options: TerminologyHttpErrorOptions);
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
/** Options for {@link TerminologyHttpError}. */
|
|
1252
|
-
export declare interface TerminologyHttpErrorOptions extends TerminologyErrorOptions {
|
|
1253
|
-
/** The HTTP status returned by the terminology server. */
|
|
1254
|
-
status: number;
|
|
1255
|
-
/** The HTTP reason phrase, when the client exposes one. */
|
|
1256
|
-
statusText?: string;
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
/**
|
|
1260
|
-
* The terminology server could not be reached, or produced no usable response.
|
|
1261
|
-
*
|
|
1262
|
-
* There is no HTTP status: the request never completed. Callers must treat this
|
|
1263
|
-
* as "unknown" — never as evidence that a concept is absent.
|
|
1264
|
-
*/
|
|
1265
|
-
export declare class TerminologyTransportError extends TerminologyError {
|
|
1266
|
-
readonly kind: "transport";
|
|
1267
|
-
/** True when the failure was a client-side timeout rather than a hard failure. */
|
|
1268
|
-
readonly timedOut: boolean;
|
|
1269
|
-
constructor(message: string, options?: TerminologyTransportErrorOptions);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
/** Options for {@link TerminologyTransportError}. */
|
|
1273
|
-
export declare interface TerminologyTransportErrorOptions extends TerminologyErrorOptions {
|
|
1274
|
-
/** True when the request was aborted because it exceeded its timeout. */
|
|
1275
|
-
timedOut?: boolean;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
/**
|
|
1279
|
-
* Build a {@link TerminologyHttpError} for an error response, keeping any
|
|
1280
|
-
* detail the server supplied (e.g. an OperationOutcome diagnostic).
|
|
1281
|
-
*/
|
|
1282
|
-
export declare function toHttpError(options: {
|
|
1283
|
-
status: number;
|
|
1284
|
-
statusText?: string;
|
|
1285
|
-
url?: string;
|
|
1286
|
-
operation: string;
|
|
1287
|
-
detail?: string;
|
|
1288
|
-
cause?: unknown;
|
|
1289
|
-
}): TerminologyHttpError;
|
|
1290
|
-
|
|
1291
|
-
declare interface TokenInfo {
|
|
1292
|
-
type: number;
|
|
1293
|
-
text: string;
|
|
1294
|
-
range: Range;
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* Wrap a network-level failure as a {@link TerminologyTransportError},
|
|
1299
|
-
* preserving the original as `cause`.
|
|
1300
|
-
*/
|
|
1301
|
-
export declare function toTransportError(error: unknown, options: {
|
|
1302
|
-
url?: string;
|
|
1303
|
-
operation: string;
|
|
1304
|
-
timeoutMs?: number;
|
|
1305
|
-
}): TerminologyTransportError;
|
|
1306
|
-
|
|
1307
|
-
export declare function validateBoolean(value: unknown, defaultValue: boolean): boolean;
|
|
1308
|
-
|
|
1309
|
-
export declare function validateIndentSize(value: unknown): number;
|
|
1310
|
-
|
|
1311
|
-
export declare function validateIndentStyle(value: unknown): 'space' | 'tab';
|
|
1312
|
-
|
|
1313
|
-
export declare function validateMaxLineLength(value: unknown): number;
|
|
1314
|
-
|
|
1315
|
-
/**
|
|
1316
|
-
* Validate semantic correctness of an ECL expression.
|
|
1317
|
-
* Returns diagnostics for attribute scope issues, value constraint issues,
|
|
1318
|
-
* empty sub-expressions, and impossible refinements.
|
|
1319
|
-
*/
|
|
1320
|
-
export declare function validateSemantics(ast: ExpressionNode, sourceText: string, terminologyService: ITerminologyService): Promise<SemanticDiagnostic[]>;
|
|
1321
|
-
|
|
1322
|
-
declare interface WildcardNode extends ASTNode {
|
|
1323
|
-
type: NodeType.Wildcard;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
export { }
|
|
1
|
+
export * from './types';
|
|
2
|
+
export { positionAt, offsetAt, getText } from './text-utils';
|
|
3
|
+
export { parseECL } from './parser';
|
|
4
|
+
export type { ParseResult, ParseError } from './parser';
|
|
5
|
+
export type { ExpressionNode, CompoundExpressionNode, RefinedExpressionNode, SubExpressionNode, RefinementNode, RefinementMemberNode, AttributeSetNode, AttributeGroupNode, AttributeNode, FilterConstraintNode, HistorySupplementNode, } from './parser/ast';
|
|
6
|
+
export { extractConceptIds } from './parser/concept-extractor';
|
|
7
|
+
export type { ConceptReference } from './parser/concept-extractor';
|
|
8
|
+
export { groupIntoExpressions } from './parser/expression-grouper';
|
|
9
|
+
export { checkMixedRefinementOperators } from './parser/refinement-check';
|
|
10
|
+
export { analyzeExpression } from './parser/error-analysis';
|
|
11
|
+
export { isConceptPositionValid, getConceptSearchPriority, getValidOperatorsAtPosition, } from './parser/position-detector';
|
|
12
|
+
export { FhirTerminologyService } from './terminology/fhir-service';
|
|
13
|
+
export type { FhirTerminologyServiceOptions, EclEvaluationStrategy } from './terminology/fhir-service';
|
|
14
|
+
export { isEclEvaluationStrategy } from './terminology/fhir-service';
|
|
15
|
+
export type { ITerminologyService, ConceptInfo, EvaluationResponse, HistoricalAssociation, HistoricalAssociationType, } from './terminology/types';
|
|
16
|
+
export { isValidSnomedId, isValidConceptId, isValidDescriptionId } from './terminology/verhoeff';
|
|
17
|
+
export { TerminologyError, TerminologyTransportError, TerminologyHttpError, isTerminologyError, isTerminologyTransportError, isTerminologyHttpError, toTransportError, toHttpError, } from './terminology/errors';
|
|
18
|
+
export type { TerminologyErrorKind, TerminologyErrorOptions, TerminologyTransportErrorOptions, TerminologyHttpErrorOptions, } from './terminology/errors';
|
|
19
|
+
export { refineParseError } from './validation/error-refinement';
|
|
20
|
+
export { validateSemantics } from './semantic/validator';
|
|
21
|
+
export type { SemanticDiagnostic } from './semantic/validator';
|
|
22
|
+
export { extractText, extractRefinementInfo, extractCompoundOperands } from './semantic/ecl-text';
|
|
23
|
+
export { formatDocument } from './formatter/formatter';
|
|
24
|
+
export type { FormattingOptions } from './formatter/options';
|
|
25
|
+
export { defaultFormattingOptions } from './formatter/options';
|
|
26
|
+
export { expandToExpressionBoundaries, getExpressionsInRange, formatRangeExpressions } from './formatter/range';
|
|
27
|
+
export { validateIndentSize, validateIndentStyle, validateMaxLineLength, validateBoolean } from './formatter/config';
|
|
28
|
+
export { getRefactoringActions, REFACTORING_RESOLVE_KIND } from './refactoring';
|
|
29
|
+
export type { RefactoringContext } from './refactoring';
|
|
30
|
+
export { resolveAddDisplayTerms } from './refactoring/add-display-terms';
|
|
31
|
+
export { resolveUnifiedSimplify } from './refactoring/simplify-expression';
|
|
32
|
+
export { buildReplacementText } from './refactoring/replace-inactive-concept';
|
|
33
|
+
export type { ReplacementResult } from './refactoring/replace-inactive-concept';
|
|
34
|
+
export { getCompletionItems, getCompletionItemsWithSearch } from './completion/provider';
|
|
35
|
+
export { detectCursorContext, detectFilterContext } from './completion/context-detector';
|
|
36
|
+
export type { CursorContext, FilterSubContext, FilterType } from './completion/context-detector';
|
|
37
|
+
export { eclSnippetCompletions } from './completion/snippets';
|
|
38
|
+
export { getFhirFilterCompletions, clearFilterCache } from './completion/filter-cache';
|
|
39
|
+
export { computeSemanticTokens, eclTokenTypes, eclTokenModifiers } from './semantic-tokens';
|
|
40
|
+
export type { SemanticToken } from './semantic-tokens';
|
|
41
|
+
export { canonicalise, compareExpressions, CanonicaliseError } from './canonical/comparator';
|
|
42
|
+
export type { ComparisonResult } from './canonical/comparator';
|
|
43
|
+
export { allArticles, getArticle, getArticlesByCategory, operatorHoverDocs, getOperatorHoverDoc, knowledgeGuides, getGuide, } from './knowledge';
|
|
44
|
+
export type { KnowledgeArticle, KnowledgeGuide, KnowledgeCategory, OperatorHoverDoc } from './knowledge';
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|