fhir-runtime 0.2.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/CHANGELOG.md +211 -0
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/dist/cjs/index.cjs +7368 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/cjs/index.d.ts +4224 -0
- package/dist/cjs/package.json +5 -0
- package/dist/esm/index.d.ts +4224 -0
- package/dist/esm/index.mjs +7250 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/index.d.ts +4224 -0
- package/dist/lib/context/bundle-loader.d.ts +124 -0
- package/dist/lib/context/bundle-loader.d.ts.map +1 -0
- package/dist/lib/context/core-definitions/index.d.ts +72 -0
- package/dist/lib/context/core-definitions/index.d.ts.map +1 -0
- package/dist/lib/context/errors.d.ts +114 -0
- package/dist/lib/context/errors.d.ts.map +1 -0
- package/dist/lib/context/fhir-context.d.ts +72 -0
- package/dist/lib/context/fhir-context.d.ts.map +1 -0
- package/dist/lib/context/index.d.ts +21 -0
- package/dist/lib/context/index.d.ts.map +1 -0
- package/dist/lib/context/inheritance-resolver.d.ts +98 -0
- package/dist/lib/context/inheritance-resolver.d.ts.map +1 -0
- package/dist/lib/context/inner-type-extractor.d.ts +80 -0
- package/dist/lib/context/inner-type-extractor.d.ts.map +1 -0
- package/dist/lib/context/loaders/composite-loader.d.ts +47 -0
- package/dist/lib/context/loaders/composite-loader.d.ts.map +1 -0
- package/dist/lib/context/loaders/file-loader.d.ts +47 -0
- package/dist/lib/context/loaders/file-loader.d.ts.map +1 -0
- package/dist/lib/context/loaders/index.d.ts +11 -0
- package/dist/lib/context/loaders/index.d.ts.map +1 -0
- package/dist/lib/context/loaders/memory-loader.d.ts +42 -0
- package/dist/lib/context/loaders/memory-loader.d.ts.map +1 -0
- package/dist/lib/context/registry.d.ts +116 -0
- package/dist/lib/context/registry.d.ts.map +1 -0
- package/dist/lib/context/types.d.ts +266 -0
- package/dist/lib/context/types.d.ts.map +1 -0
- package/dist/lib/fhirpath/atoms.d.ts +228 -0
- package/dist/lib/fhirpath/atoms.d.ts.map +1 -0
- package/dist/lib/fhirpath/cache.d.ts +79 -0
- package/dist/lib/fhirpath/cache.d.ts.map +1 -0
- package/dist/lib/fhirpath/date.d.ts +17 -0
- package/dist/lib/fhirpath/date.d.ts.map +1 -0
- package/dist/lib/fhirpath/functions.d.ts +28 -0
- package/dist/lib/fhirpath/functions.d.ts.map +1 -0
- package/dist/lib/fhirpath/index.d.ts +20 -0
- package/dist/lib/fhirpath/index.d.ts.map +1 -0
- package/dist/lib/fhirpath/lexer/parse.d.ts +100 -0
- package/dist/lib/fhirpath/lexer/parse.d.ts.map +1 -0
- package/dist/lib/fhirpath/lexer/tokenize.d.ts +80 -0
- package/dist/lib/fhirpath/lexer/tokenize.d.ts.map +1 -0
- package/dist/lib/fhirpath/parse.d.ts +101 -0
- package/dist/lib/fhirpath/parse.d.ts.map +1 -0
- package/dist/lib/fhirpath/tokenize.d.ts +20 -0
- package/dist/lib/fhirpath/tokenize.d.ts.map +1 -0
- package/dist/lib/fhirpath/types.d.ts +111 -0
- package/dist/lib/fhirpath/types.d.ts.map +1 -0
- package/dist/lib/fhirpath/utils.d.ts +81 -0
- package/dist/lib/fhirpath/utils.d.ts.map +1 -0
- package/dist/lib/index.d.ts +24 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/model/canonical-profile.d.ts +381 -0
- package/dist/lib/model/canonical-profile.d.ts.map +1 -0
- package/dist/lib/model/element-definition.d.ts +503 -0
- package/dist/lib/model/element-definition.d.ts.map +1 -0
- package/dist/lib/model/index.d.ts +14 -0
- package/dist/lib/model/index.d.ts.map +1 -0
- package/dist/lib/model/primitives.d.ts +464 -0
- package/dist/lib/model/primitives.d.ts.map +1 -0
- package/dist/lib/model/structure-definition.d.ts +263 -0
- package/dist/lib/model/structure-definition.d.ts.map +1 -0
- package/dist/lib/parser/choice-type-parser.d.ts +182 -0
- package/dist/lib/parser/choice-type-parser.d.ts.map +1 -0
- package/dist/lib/parser/index.d.ts +16 -0
- package/dist/lib/parser/index.d.ts.map +1 -0
- package/dist/lib/parser/json-parser.d.ts +171 -0
- package/dist/lib/parser/json-parser.d.ts.map +1 -0
- package/dist/lib/parser/parse-error.d.ts +146 -0
- package/dist/lib/parser/parse-error.d.ts.map +1 -0
- package/dist/lib/parser/primitive-parser.d.ts +136 -0
- package/dist/lib/parser/primitive-parser.d.ts.map +1 -0
- package/dist/lib/parser/serializer.d.ts +64 -0
- package/dist/lib/parser/serializer.d.ts.map +1 -0
- package/dist/lib/parser/structure-definition-parser.d.ts +63 -0
- package/dist/lib/parser/structure-definition-parser.d.ts.map +1 -0
- package/dist/lib/profile/canonical-builder.d.ts +87 -0
- package/dist/lib/profile/canonical-builder.d.ts.map +1 -0
- package/dist/lib/profile/constraint-merger.d.ts +100 -0
- package/dist/lib/profile/constraint-merger.d.ts.map +1 -0
- package/dist/lib/profile/element-merger.d.ts +80 -0
- package/dist/lib/profile/element-merger.d.ts.map +1 -0
- package/dist/lib/profile/element-sorter.d.ts +81 -0
- package/dist/lib/profile/element-sorter.d.ts.map +1 -0
- package/dist/lib/profile/errors.d.ts +150 -0
- package/dist/lib/profile/errors.d.ts.map +1 -0
- package/dist/lib/profile/index.d.ts +27 -0
- package/dist/lib/profile/index.d.ts.map +1 -0
- package/dist/lib/profile/path-utils.d.ts +180 -0
- package/dist/lib/profile/path-utils.d.ts.map +1 -0
- package/dist/lib/profile/slicing-handler.d.ts +121 -0
- package/dist/lib/profile/slicing-handler.d.ts.map +1 -0
- package/dist/lib/profile/snapshot-generator.d.ts +73 -0
- package/dist/lib/profile/snapshot-generator.d.ts.map +1 -0
- package/dist/lib/profile/types.d.ts +220 -0
- package/dist/lib/profile/types.d.ts.map +1 -0
- package/dist/lib/validator/errors.d.ts +83 -0
- package/dist/lib/validator/errors.d.ts.map +1 -0
- package/dist/lib/validator/index.d.ts +23 -0
- package/dist/lib/validator/index.d.ts.map +1 -0
- package/dist/lib/validator/invariant-validator.d.ts +62 -0
- package/dist/lib/validator/invariant-validator.d.ts.map +1 -0
- package/dist/lib/validator/path-extractor.d.ts +123 -0
- package/dist/lib/validator/path-extractor.d.ts.map +1 -0
- package/dist/lib/validator/slicing-validator.d.ts +119 -0
- package/dist/lib/validator/slicing-validator.d.ts.map +1 -0
- package/dist/lib/validator/structure-validator.d.ts +74 -0
- package/dist/lib/validator/structure-validator.d.ts.map +1 -0
- package/dist/lib/validator/types.d.ts +288 -0
- package/dist/lib/validator/types.d.ts.map +1 -0
- package/dist/lib/validator/validation-rules.d.ts +198 -0
- package/dist/lib/validator/validation-rules.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +76 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FHIRPath Parser
|
|
3
|
+
*
|
|
4
|
+
* Builds a Pratt parser configured with FHIRPath-specific parselets,
|
|
5
|
+
* and provides the public API for parsing and evaluating FHIRPath expressions.
|
|
6
|
+
*
|
|
7
|
+
* @module fhirpath
|
|
8
|
+
*/
|
|
9
|
+
import type { TypedValue } from './types.js';
|
|
10
|
+
import { ParserBuilder } from './lexer/parse.js';
|
|
11
|
+
import { FhirPathAtom } from './atoms.js';
|
|
12
|
+
/**
|
|
13
|
+
* FHIRPath operator precedence levels.
|
|
14
|
+
* Lower number = tighter binding.
|
|
15
|
+
* @see https://hl7.org/fhirpath/#operator-precedence
|
|
16
|
+
*/
|
|
17
|
+
export declare const OperatorPrecedence: {
|
|
18
|
+
readonly FunctionCall: 0;
|
|
19
|
+
readonly Dot: 1;
|
|
20
|
+
readonly Indexer: 2;
|
|
21
|
+
readonly UnaryAdd: 3;
|
|
22
|
+
readonly UnarySubtract: 3;
|
|
23
|
+
readonly Multiply: 4;
|
|
24
|
+
readonly Divide: 4;
|
|
25
|
+
readonly IntegerDivide: 4;
|
|
26
|
+
readonly Modulo: 4;
|
|
27
|
+
readonly Add: 5;
|
|
28
|
+
readonly Subtract: 5;
|
|
29
|
+
readonly Ampersand: 5;
|
|
30
|
+
readonly Is: 6;
|
|
31
|
+
readonly As: 6;
|
|
32
|
+
readonly Union: 7;
|
|
33
|
+
readonly GreaterThan: 8;
|
|
34
|
+
readonly GreaterThanOrEquals: 8;
|
|
35
|
+
readonly LessThan: 8;
|
|
36
|
+
readonly LessThanOrEquals: 8;
|
|
37
|
+
readonly Equals: 9;
|
|
38
|
+
readonly Equivalent: 9;
|
|
39
|
+
readonly NotEquals: 9;
|
|
40
|
+
readonly NotEquivalent: 9;
|
|
41
|
+
readonly In: 10;
|
|
42
|
+
readonly Contains: 10;
|
|
43
|
+
readonly And: 11;
|
|
44
|
+
readonly Xor: 12;
|
|
45
|
+
readonly Or: 12;
|
|
46
|
+
readonly Implies: 13;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Initialize the FHIRPath parser builder with all prefix and infix parselets.
|
|
50
|
+
*/
|
|
51
|
+
export declare function initFhirPathParserBuilder(): ParserBuilder;
|
|
52
|
+
/**
|
|
53
|
+
* Parse a FHIRPath expression string into an AST.
|
|
54
|
+
* Results are cached in the global expression cache for reuse.
|
|
55
|
+
*
|
|
56
|
+
* @param input - The FHIRPath expression string.
|
|
57
|
+
* @returns The parsed AST as a {@link FhirPathAtom}.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseFhirPath(input: string): FhirPathAtom;
|
|
60
|
+
/**
|
|
61
|
+
* Evaluate a FHIRPath expression against a resource or other object.
|
|
62
|
+
* Accepts raw values (auto-wrapped in TypedValue) or pre-wrapped TypedValue arrays.
|
|
63
|
+
*
|
|
64
|
+
* @param expression - The FHIRPath expression string or pre-parsed AST.
|
|
65
|
+
* @param input - The resource or object to evaluate against.
|
|
66
|
+
* @returns Array of result values (unwrapped from TypedValue).
|
|
67
|
+
*/
|
|
68
|
+
export declare function evalFhirPath(expression: string | FhirPathAtom, input: unknown): unknown[];
|
|
69
|
+
/**
|
|
70
|
+
* Evaluate a FHIRPath expression against typed input values.
|
|
71
|
+
*
|
|
72
|
+
* @param expression - The FHIRPath expression string or pre-parsed AST.
|
|
73
|
+
* @param input - Array of TypedValue inputs.
|
|
74
|
+
* @param variables - Optional variable bindings.
|
|
75
|
+
* @returns Array of TypedValue results.
|
|
76
|
+
*/
|
|
77
|
+
export declare function evalFhirPathTyped(expression: string | FhirPathAtom, input: TypedValue[], variables?: Record<string, TypedValue>): TypedValue[];
|
|
78
|
+
/**
|
|
79
|
+
* Evaluate a FHIRPath expression and return a boolean result.
|
|
80
|
+
*
|
|
81
|
+
* Useful for invariant validation where the expression must evaluate to `true`.
|
|
82
|
+
* Uses FHIRPath boolean semantics: empty → false, single truthy → true.
|
|
83
|
+
*
|
|
84
|
+
* @param expression - FHIRPath expression string or pre-parsed AST.
|
|
85
|
+
* @param input - The resource or typed values to evaluate against.
|
|
86
|
+
* @param variables - Optional variable bindings.
|
|
87
|
+
* @returns Boolean result of the expression.
|
|
88
|
+
*/
|
|
89
|
+
export declare function evalFhirPathBoolean(expression: string | FhirPathAtom, input: unknown, variables?: Record<string, TypedValue>): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Evaluate a FHIRPath expression and return the first result as a string.
|
|
92
|
+
*
|
|
93
|
+
* Useful for extracting display values, identifiers, etc.
|
|
94
|
+
*
|
|
95
|
+
* @param expression - FHIRPath expression string or pre-parsed AST.
|
|
96
|
+
* @param input - The resource or typed values to evaluate against.
|
|
97
|
+
* @param variables - Optional variable bindings.
|
|
98
|
+
* @returns The first result value as a string, or `undefined` if empty.
|
|
99
|
+
*/
|
|
100
|
+
export declare function evalFhirPathString(expression: string | FhirPathAtom, input: unknown, variables?: Record<string, TypedValue>): string | undefined;
|
|
101
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/fhirpath/parse.ts"],"names":[],"mappings":"AAAA;;;;;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
+
*
|
|
7
|
+
* @module fhirpath
|
|
8
|
+
*/
|
|
9
|
+
import type { Token } from './lexer/tokenize.js';
|
|
10
|
+
/** FHIRPath keywords that are treated as their own token type. */
|
|
11
|
+
export declare const FHIRPATH_KEYWORDS: string[];
|
|
12
|
+
/** FHIRPath multi-character operators. */
|
|
13
|
+
export declare const FHIRPATH_OPERATORS: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Tokenize a FHIRPath expression string into a token array.
|
|
16
|
+
* @param str - The FHIRPath expression.
|
|
17
|
+
* @returns Array of tokens.
|
|
18
|
+
*/
|
|
19
|
+
export declare function tokenize(str: string): Token[];
|
|
20
|
+
//# sourceMappingURL=tokenize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenize.d.ts","sourceRoot":"","sources":["../../../src/fhirpath/tokenize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGjD,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,UAAoB,CAAC;AAEnD,0CAA0C;AAC1C,eAAO,MAAM,kBAAkB,UAAuC,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,EAAE,CAE7C"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FHIRPath Core Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the fundamental types used throughout the FHIRPath engine:
|
|
5
|
+
* - {@link TypedValue} — A value paired with its FHIR type
|
|
6
|
+
* - {@link PropertyType} — Enum of all FHIR property types
|
|
7
|
+
* - {@link Atom} — AST node interface for parsed expressions
|
|
8
|
+
* - {@link AtomContext} — Evaluation context with variable scoping
|
|
9
|
+
*
|
|
10
|
+
* @module fhirpath
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Enum of FHIR property type identifiers used in {@link TypedValue}.
|
|
14
|
+
* Covers all FHIR R4 primitive types and commonly used complex types.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PropertyType: {
|
|
17
|
+
readonly boolean: "boolean";
|
|
18
|
+
readonly integer: "integer";
|
|
19
|
+
readonly decimal: "decimal";
|
|
20
|
+
readonly string: "string";
|
|
21
|
+
readonly uri: "uri";
|
|
22
|
+
readonly url: "url";
|
|
23
|
+
readonly canonical: "canonical";
|
|
24
|
+
readonly base64Binary: "base64Binary";
|
|
25
|
+
readonly instant: "instant";
|
|
26
|
+
readonly date: "date";
|
|
27
|
+
readonly dateTime: "dateTime";
|
|
28
|
+
readonly time: "time";
|
|
29
|
+
readonly code: "code";
|
|
30
|
+
readonly oid: "oid";
|
|
31
|
+
readonly id: "id";
|
|
32
|
+
readonly markdown: "markdown";
|
|
33
|
+
readonly unsignedInt: "unsignedInt";
|
|
34
|
+
readonly positiveInt: "positiveInt";
|
|
35
|
+
readonly uuid: "uuid";
|
|
36
|
+
readonly xhtml: "xhtml";
|
|
37
|
+
readonly BackboneElement: "BackboneElement";
|
|
38
|
+
readonly CodeableConcept: "CodeableConcept";
|
|
39
|
+
readonly Coding: "Coding";
|
|
40
|
+
readonly Quantity: "Quantity";
|
|
41
|
+
readonly Reference: "Reference";
|
|
42
|
+
readonly Period: "Period";
|
|
43
|
+
readonly Identifier: "Identifier";
|
|
44
|
+
readonly HumanName: "HumanName";
|
|
45
|
+
readonly Address: "Address";
|
|
46
|
+
readonly ContactPoint: "ContactPoint";
|
|
47
|
+
readonly Attachment: "Attachment";
|
|
48
|
+
readonly Extension: "Extension";
|
|
49
|
+
};
|
|
50
|
+
export type PropertyType = (typeof PropertyType)[keyof typeof PropertyType];
|
|
51
|
+
/**
|
|
52
|
+
* A value paired with its FHIR type identifier.
|
|
53
|
+
* This is the fundamental unit of data flowing through the FHIRPath engine.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const tv: TypedValue = { type: PropertyType.string, value: 'hello' };
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export interface TypedValue {
|
|
61
|
+
readonly type: string;
|
|
62
|
+
readonly value: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Evaluation context for FHIRPath expressions.
|
|
66
|
+
* Supports nested scoping via the `parent` chain, used by functions
|
|
67
|
+
* like `where()` and `select()` that introduce `$this`.
|
|
68
|
+
*/
|
|
69
|
+
export interface AtomContext {
|
|
70
|
+
readonly parent?: AtomContext;
|
|
71
|
+
readonly variables: Record<string, TypedValue>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Interface for all AST nodes in the FHIRPath expression tree.
|
|
75
|
+
* Each node can evaluate itself given a context and input collection.
|
|
76
|
+
*/
|
|
77
|
+
export interface Atom {
|
|
78
|
+
/**
|
|
79
|
+
* Evaluate this atom against the given input collection.
|
|
80
|
+
* @param context - The evaluation context (variables, parent scope).
|
|
81
|
+
* @param input - The input collection of typed values.
|
|
82
|
+
* @returns The result collection.
|
|
83
|
+
*/
|
|
84
|
+
eval(context: AtomContext, input: TypedValue[]): TypedValue[];
|
|
85
|
+
/** Returns a string representation of this atom (for debugging). */
|
|
86
|
+
toString(): string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Base class for prefix (unary) operator atoms.
|
|
90
|
+
* Examples: unary `-`, unary `+`
|
|
91
|
+
*/
|
|
92
|
+
export declare abstract class PrefixOperatorAtom implements Atom {
|
|
93
|
+
readonly operator: string;
|
|
94
|
+
readonly child: Atom;
|
|
95
|
+
constructor(operator: string, child: Atom);
|
|
96
|
+
abstract eval(context: AtomContext, input: TypedValue[]): TypedValue[];
|
|
97
|
+
toString(): string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Base class for infix (binary) operator atoms.
|
|
101
|
+
* Examples: `+`, `-`, `=`, `and`, `or`
|
|
102
|
+
*/
|
|
103
|
+
export declare abstract class InfixOperatorAtom implements Atom {
|
|
104
|
+
readonly operator: string;
|
|
105
|
+
readonly left: Atom;
|
|
106
|
+
readonly right: Atom;
|
|
107
|
+
constructor(operator: string, left: Atom, right: Atom);
|
|
108
|
+
abstract eval(context: AtomContext, input: TypedValue[]): TypedValue[];
|
|
109
|
+
toString(): string;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fhirpath/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAM5E;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAMD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAChD;AAMD;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;IAE9D,oEAAoE;IACpE,QAAQ,IAAI,MAAM,CAAC;CACpB;AAMD;;;GAGG;AACH,8BAAsB,kBAAmB,YAAW,IAAI;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;gBAET,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI;IAKzC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE;IAEtE,QAAQ,IAAI,MAAM;CAGnB;AAED;;;GAGG;AACH,8BAAsB,iBAAkB,YAAW,IAAI;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;gBAET,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI;IAMrD,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE;IAEtE,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FHIRPath utility functions.
|
|
3
|
+
*
|
|
4
|
+
* Provides type conversion, equality/equivalence comparison,
|
|
5
|
+
* and helper functions used by atoms and the function library.
|
|
6
|
+
*
|
|
7
|
+
* @module fhirpath
|
|
8
|
+
*/
|
|
9
|
+
import type { Quantity } from '../model/primitives.js';
|
|
10
|
+
import type { TypedValue } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Returns a single-element array with a typed boolean value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function booleanToTypedValue(value: boolean): [TypedValue];
|
|
15
|
+
/**
|
|
16
|
+
* Returns a "best guess" TypedValue for a given unknown value.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toTypedValue(value: unknown): TypedValue;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a TypedValue collection to a JavaScript boolean.
|
|
21
|
+
* Empty collection → false; otherwise truthy check on first element.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toJsBoolean(obj: TypedValue[]): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the single element from a collection, or undefined if empty.
|
|
26
|
+
* Throws if the collection has more than one element.
|
|
27
|
+
*/
|
|
28
|
+
export declare function singleton(collection: TypedValue[], type?: string): TypedValue | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Extract a typed property value from a TypedValue without schema.
|
|
31
|
+
* Handles simple paths and choice-type paths (value[x]).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getTypedPropertyValue(input: TypedValue, path: string): TypedValue[] | TypedValue | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* FHIRPath equality comparison for two TypedValue elements.
|
|
36
|
+
* Returns `[{type:'boolean', value:true/false}]` or `[]` for incomparable.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fhirPathEquals(x: TypedValue, y: TypedValue): TypedValue[];
|
|
39
|
+
/**
|
|
40
|
+
* FHIRPath array equality: both arrays must have same length and pairwise equal elements.
|
|
41
|
+
* Returns `[]` if either side is empty.
|
|
42
|
+
*/
|
|
43
|
+
export declare function fhirPathArrayEquals(x: TypedValue[], y: TypedValue[]): TypedValue[];
|
|
44
|
+
/**
|
|
45
|
+
* FHIRPath array not-equals.
|
|
46
|
+
*/
|
|
47
|
+
export declare function fhirPathArrayNotEquals(x: TypedValue[], y: TypedValue[]): TypedValue[];
|
|
48
|
+
/**
|
|
49
|
+
* FHIRPath equivalence comparison for two TypedValue elements.
|
|
50
|
+
* More lenient than equality (case-insensitive strings, rounded decimals, etc.).
|
|
51
|
+
*/
|
|
52
|
+
export declare function fhirPathEquivalent(x: TypedValue, y: TypedValue): TypedValue[];
|
|
53
|
+
/**
|
|
54
|
+
* FHIRPath array equivalence: sorted pairwise equivalence.
|
|
55
|
+
*/
|
|
56
|
+
export declare function fhirPathArrayEquivalent(x: TypedValue[], y: TypedValue[]): TypedValue[];
|
|
57
|
+
/**
|
|
58
|
+
* Negate a FHIRPath boolean result.
|
|
59
|
+
*/
|
|
60
|
+
export declare function fhirPathNot(input: TypedValue[]): TypedValue[];
|
|
61
|
+
/**
|
|
62
|
+
* Remove duplicates using FHIRPath equality rules.
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
|
|
65
|
+
/**
|
|
66
|
+
* Determines if a typed value matches the desired FHIRPath type name.
|
|
67
|
+
*/
|
|
68
|
+
export declare function fhirPathIs(typedValue: TypedValue, desiredType: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Heuristic check for Quantity objects.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isQuantity(input: unknown): input is Quantity;
|
|
73
|
+
/**
|
|
74
|
+
* Heuristic check for FHIR Resource objects.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isResource(input: unknown): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a value is a FHIR Resource with a specific resourceType.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isResourceType(input: unknown, resourceType: string): boolean;
|
|
81
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fhirpath/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAO7C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,UAAU,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAkBvD;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAEtD;AAMD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAQzF;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,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* `@medxai/fhir-core` — Public API (Frozen at v0.1.0)
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all public types and functions from the six core modules:
|
|
5
|
+
* model → parser → context → profile → validator (+ fhirpath internal)
|
|
6
|
+
*
|
|
7
|
+
* This file defines the frozen public API surface for @medxai/fhir-core v0.1.
|
|
8
|
+
* Any symbol exported here is subject to the v0.1 compatibility contract.
|
|
9
|
+
* See: docs/specs/engine-capability-contract-v0.1.md
|
|
10
|
+
* docs/api/fhir-core-api-v0.1.md
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
export type { ParseSeverity, ParseErrorCode, ParseIssue, ParseResult, ChoiceValue, ChoiceTypeField, } from './parser/index.js';
|
|
15
|
+
export { parseFhirJson, parseFhirObject, parseStructureDefinition, parseElementDefinition, serializeToFhirJson, serializeToFhirObject, parseSuccess, parseFailure, createIssue, hasErrors, } from './parser/index.js';
|
|
16
|
+
export type { FhirBoolean, FhirInteger, FhirString, FhirDecimal, FhirUri, FhirUrl, FhirCanonical, FhirBase64Binary, FhirInstant, FhirDate, FhirDateTime, FhirTime, FhirCode, FhirOid, FhirId, FhirMarkdown, FhirUnsignedInt, FhirPositiveInt, FhirUuid, FhirXhtml, PublicationStatus, StructureDefinitionKind, TypeDerivationRule, ExtensionContextType, FhirVersionCode, PropertyRepresentation, SlicingRules, DiscriminatorType, AggregationMode, ReferenceVersionRules, ConstraintSeverity, BindingStrength, NarrativeStatus, Element, Extension, Coding, CodeableConcept, Identifier, Period, Reference, ContactDetail, ContactPoint, UsageContext, Quantity, Narrative, Meta, Resource, DomainResource, BackboneElement, ElementDefinition, ElementDefinitionSlicing, SlicingDiscriminator, ElementDefinitionBase, ElementDefinitionType, ElementDefinitionConstraint, ElementDefinitionBinding, ElementDefinitionExample, ElementDefinitionMapping, StructureDefinition, StructureDefinitionMapping, StructureDefinitionContext, StructureDefinitionSnapshot, StructureDefinitionDifferential, CanonicalProfile, CanonicalElement, TypeConstraint, BindingConstraint, Invariant, SlicingDefinition, SlicingDiscriminatorDef, } from './model/index.js';
|
|
17
|
+
export type { FhirContext, FhirContextOptions, StructureDefinitionLoader, LoaderOptions, ContextStatistics, BundleLoadOptions, BundleLoadResult, BundleLoadError, } from './context/index.js';
|
|
18
|
+
export { FhirContextImpl, createEmptyStatistics, MemoryLoader, FileSystemLoader, CompositeLoader, ContextError, ResourceNotFoundError, CircularDependencyError, LoaderError, InvalidStructureDefinitionError, loadBundleFromObject, loadBundleFromFile, loadBundlesFromFiles, BASE_RESOURCES, PRIMITIVE_TYPES, COMPLEX_TYPES, CORE_RESOURCES, ALL_CORE_DEFINITIONS, loadAllCoreDefinitions, loadCoreDefinition, loadCoreDefinitionSync, getCoreDefinitionsDir, extractInnerTypes, buildTypeName, isBackboneElementType, } from './context/index.js';
|
|
19
|
+
export type { SnapshotGeneratorOptions, SnapshotResult, SnapshotIssue, SnapshotIssueCode, DiffElementTracker, TraversalScope, MergeContext, } from './profile/index.js';
|
|
20
|
+
export { SnapshotGenerator, buildCanonicalProfile, buildCanonicalElement, buildTypeConstraints, buildBindingConstraint, buildInvariants, buildSlicingDefinition, ProfileError, SnapshotCircularDependencyError, BaseNotFoundError, ConstraintViolationError, UnconsumedDifferentialError, createSnapshotIssue, createDiffTracker, pathMatches, isDirectChild, isDescendant, pathDepth, parentPath, tailSegment, isChoiceTypePath, matchesChoiceType, extractChoiceTypeName, hasSliceName, extractSliceName, findBaseIndex, sortDifferential, validateElementOrder, ensureElementIds, mergeConstraints, setBaseTraceability, mergeCardinality, mergeTypes, mergeBinding, mergeConstraintList, isLargerMax, createMergeContext, processPaths, mergeSnapshot, makeExtensionSlicing, getSliceSiblings, validateSlicingCompatibility, diffsConstrainTypes, handleNewSlicing, handleExistingSlicing, } from './profile/index.js';
|
|
21
|
+
export type { ValidationOptions, ValidationResult, ValidationIssue, ValidationIssueCode, } from './validator/index.js';
|
|
22
|
+
export { StructureValidator, createValidationIssue, resolveValidationOptions, hasValidationErrors, extractValues, ProfileNotFoundError, ValidationFailedError, } from './validator/index.js';
|
|
23
|
+
export { evalFhirPath, evalFhirPathBoolean, evalFhirPathTyped, evalFhirPathString, } from './fhirpath/index.js';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,SAAS,GACV,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAEV,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,YAAY,EACZ,eAAe,EACf,eAAe,EACf,QAAQ,EACR,SAAS,EAGT,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAGf,OAAO,EACP,SAAS,EACT,MAAM,EACN,eAAe,EACf,UAAU,EACV,MAAM,EACN,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,EAGf,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,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