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,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Profile — Internal Semantic Model
|
|
3
|
+
*
|
|
4
|
+
* Defines the internal, post-snapshot-generation representation of a FHIR
|
|
5
|
+
* StructureDefinition. This is NOT a FHIR-specified type — it is MedXAI's
|
|
6
|
+
* own semantic abstraction designed for efficient downstream consumption
|
|
7
|
+
* by the validation, runtime, and application layers.
|
|
8
|
+
*
|
|
9
|
+
* ## Relationship to FHIR types
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* StructureDefinition (FHIR R4, raw)
|
|
13
|
+
* → snapshot generation (fhir-profile module)
|
|
14
|
+
* → CanonicalProfile (internal, resolved)
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Design Principles
|
|
18
|
+
*
|
|
19
|
+
* 1. **Pre-resolved** — all inheritance is flattened; no need to chase
|
|
20
|
+
* `baseDefinition` chains at query time.
|
|
21
|
+
* 2. **Semantic types** — `max` is `number | 'unbounded'` instead of
|
|
22
|
+
* FHIR's raw `"*"` string, eliminating repeated parsing.
|
|
23
|
+
* 3. **Non-optional flags** — `mustSupport`, `isModifier`, `isSummary`
|
|
24
|
+
* always have a value (default `false`), and `constraints` is always
|
|
25
|
+
* an array (possibly empty), removing undefined checks downstream.
|
|
26
|
+
* 4. **O(1) element lookup** — `elements` is a `Map<string, CanonicalElement>`
|
|
27
|
+
* keyed by element path. JavaScript `Map` preserves insertion order,
|
|
28
|
+
* so iteration yields elements in definition order (matching the
|
|
29
|
+
* snapshot element array order).
|
|
30
|
+
*
|
|
31
|
+
* @module fhir-model
|
|
32
|
+
*/
|
|
33
|
+
import type { BindingStrength, ConstraintSeverity, DiscriminatorType, SlicingRules, StructureDefinitionKind, TypeDerivationRule } from './primitives.js';
|
|
34
|
+
/**
|
|
35
|
+
* A resolved type constraint on a canonical element.
|
|
36
|
+
*
|
|
37
|
+
* Corresponds to a simplified, pre-validated version of
|
|
38
|
+
* `ElementDefinition.type` from the FHIR spec.
|
|
39
|
+
*/
|
|
40
|
+
export interface TypeConstraint {
|
|
41
|
+
/**
|
|
42
|
+
* The data type or resource name (e.g., `string`, `Reference`, `Patient`).
|
|
43
|
+
*
|
|
44
|
+
* Unlike `ElementDefinitionType.code` (which is a URI), this is the
|
|
45
|
+
* resolved short name used for runtime dispatch.
|
|
46
|
+
*/
|
|
47
|
+
code: string;
|
|
48
|
+
/**
|
|
49
|
+
* Profiles that the type must conform to (resolved canonical URLs).
|
|
50
|
+
*
|
|
51
|
+
* Corresponds to `ElementDefinitionType.profile`.
|
|
52
|
+
*/
|
|
53
|
+
profiles?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* For Reference/canonical types, profiles that the target must conform to.
|
|
56
|
+
*
|
|
57
|
+
* Corresponds to `ElementDefinitionType.targetProfile`.
|
|
58
|
+
*/
|
|
59
|
+
targetProfiles?: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A resolved value set binding on a canonical element.
|
|
63
|
+
*
|
|
64
|
+
* Corresponds to a simplified version of `ElementDefinition.binding`.
|
|
65
|
+
*/
|
|
66
|
+
export interface BindingConstraint {
|
|
67
|
+
/**
|
|
68
|
+
* required | extensible | preferred | example
|
|
69
|
+
*
|
|
70
|
+
* Indicates the degree of conformance expectation.
|
|
71
|
+
* @see https://hl7.org/fhir/R4/valueset-binding-strength.html
|
|
72
|
+
*/
|
|
73
|
+
strength: BindingStrength;
|
|
74
|
+
/**
|
|
75
|
+
* Canonical URL of the bound value set.
|
|
76
|
+
*
|
|
77
|
+
* Resolved from `ElementDefinitionBinding.valueSet`.
|
|
78
|
+
*/
|
|
79
|
+
valueSetUrl?: string;
|
|
80
|
+
/** Human-readable description of the binding. */
|
|
81
|
+
description?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A resolved constraint (invariant) on a canonical element.
|
|
85
|
+
*
|
|
86
|
+
* Corresponds to a simplified version of `ElementDefinition.constraint`.
|
|
87
|
+
*/
|
|
88
|
+
export interface Invariant {
|
|
89
|
+
/** Unique key identifying this constraint. */
|
|
90
|
+
key: string;
|
|
91
|
+
/**
|
|
92
|
+
* error | warning
|
|
93
|
+
* @see https://hl7.org/fhir/R4/valueset-constraint-severity.html
|
|
94
|
+
*/
|
|
95
|
+
severity: ConstraintSeverity;
|
|
96
|
+
/** Human-readable description of the constraint. */
|
|
97
|
+
human: string;
|
|
98
|
+
/** FHIRPath expression that must evaluate to `true`. */
|
|
99
|
+
expression?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Canonical URL of the StructureDefinition where this constraint
|
|
102
|
+
* was originally defined.
|
|
103
|
+
*/
|
|
104
|
+
source?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A resolved slicing definition on a canonical element.
|
|
108
|
+
*
|
|
109
|
+
* Corresponds to a simplified version of `ElementDefinition.slicing`.
|
|
110
|
+
* Unlike the FHIR version, `ordered` is always a boolean (default `false`).
|
|
111
|
+
*/
|
|
112
|
+
export interface SlicingDefinition {
|
|
113
|
+
/** Discriminators used to match slices. */
|
|
114
|
+
discriminators: SlicingDiscriminatorDef[];
|
|
115
|
+
/**
|
|
116
|
+
* closed | open | openAtEnd
|
|
117
|
+
* @see https://hl7.org/fhir/R4/valueset-resource-slicing-rules.html
|
|
118
|
+
*/
|
|
119
|
+
rules: SlicingRules;
|
|
120
|
+
/**
|
|
121
|
+
* Whether elements must appear in the same order as slices.
|
|
122
|
+
*
|
|
123
|
+
* Always has a value (default `false`), unlike the FHIR spec where
|
|
124
|
+
* this is optional.
|
|
125
|
+
*/
|
|
126
|
+
ordered: boolean;
|
|
127
|
+
/** Human-readable description of the slicing. */
|
|
128
|
+
description?: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A single discriminator within a slicing definition.
|
|
132
|
+
*
|
|
133
|
+
* Corresponds to `ElementDefinition.slicing.discriminator`.
|
|
134
|
+
*/
|
|
135
|
+
export interface SlicingDiscriminatorDef {
|
|
136
|
+
/**
|
|
137
|
+
* value | exists | pattern | type | profile
|
|
138
|
+
* @see https://hl7.org/fhir/R4/valueset-discriminator-type.html
|
|
139
|
+
*/
|
|
140
|
+
type: DiscriminatorType;
|
|
141
|
+
/**
|
|
142
|
+
* FHIRPath expression identifying the discriminating element.
|
|
143
|
+
*/
|
|
144
|
+
path: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A single resolved element within a CanonicalProfile.
|
|
148
|
+
*
|
|
149
|
+
* This is the internal, pre-resolved representation of an
|
|
150
|
+
* `ElementDefinition` from a StructureDefinition snapshot.
|
|
151
|
+
* All values are resolved and normalized for efficient downstream use.
|
|
152
|
+
*
|
|
153
|
+
* ## Key differences from ElementDefinition
|
|
154
|
+
*
|
|
155
|
+
* | Aspect | ElementDefinition (FHIR) | CanonicalElement (internal) |
|
|
156
|
+
* |--------|--------------------------|----------------------------|
|
|
157
|
+
* | `max` | `string` (`"1"`, `"*"`) | `number \| 'unbounded'` |
|
|
158
|
+
* | `mustSupport` | `boolean \| undefined` | `boolean` (always present) |
|
|
159
|
+
* | `isModifier` | `boolean \| undefined` | `boolean` (always present) |
|
|
160
|
+
* | `isSummary` | `boolean \| undefined` | `boolean` (always present) |
|
|
161
|
+
* | `constraints` | `array \| undefined` | `array` (always present, may be empty) |
|
|
162
|
+
* | `types` | `array \| undefined` | `array` (always present, may be empty) |
|
|
163
|
+
*/
|
|
164
|
+
export interface CanonicalElement {
|
|
165
|
+
/** Element path (e.g., `Patient.name.given`). */
|
|
166
|
+
path: string;
|
|
167
|
+
/**
|
|
168
|
+
* Element id (e.g., `Patient.name.given`).
|
|
169
|
+
*
|
|
170
|
+
* In most cases identical to `path`, but may differ for sliced elements
|
|
171
|
+
* (e.g., `Patient.identifier:MRN`).
|
|
172
|
+
*/
|
|
173
|
+
id: string;
|
|
174
|
+
/**
|
|
175
|
+
* Minimum cardinality.
|
|
176
|
+
*
|
|
177
|
+
* Resolved from `ElementDefinition.min`. Always a non-negative integer.
|
|
178
|
+
*/
|
|
179
|
+
min: number;
|
|
180
|
+
/**
|
|
181
|
+
* Maximum cardinality.
|
|
182
|
+
*
|
|
183
|
+
* **Design decision:** Uses `number | 'unbounded'` instead of FHIR's
|
|
184
|
+
* `string` representation. The `"*"` from FHIR is converted to
|
|
185
|
+
* `'unbounded'` during snapshot resolution, eliminating the need for
|
|
186
|
+
* downstream code to repeatedly parse the string.
|
|
187
|
+
*/
|
|
188
|
+
max: number | 'unbounded';
|
|
189
|
+
/**
|
|
190
|
+
* Allowed types for this element.
|
|
191
|
+
*
|
|
192
|
+
* Always an array (possibly empty). Empty means the element is a
|
|
193
|
+
* backbone element whose children define its structure.
|
|
194
|
+
*/
|
|
195
|
+
types: TypeConstraint[];
|
|
196
|
+
/**
|
|
197
|
+
* Value set binding, if this element is coded.
|
|
198
|
+
*/
|
|
199
|
+
binding?: BindingConstraint;
|
|
200
|
+
/**
|
|
201
|
+
* Formal constraints (invariants) on this element.
|
|
202
|
+
*
|
|
203
|
+
* **Design decision:** Always an array (possibly empty), never
|
|
204
|
+
* `undefined`. This simplifies downstream iteration — no need to
|
|
205
|
+
* check for `undefined` before looping.
|
|
206
|
+
*/
|
|
207
|
+
constraints: Invariant[];
|
|
208
|
+
/**
|
|
209
|
+
* Slicing definition, if this element is a slicing root.
|
|
210
|
+
*/
|
|
211
|
+
slicing?: SlicingDefinition;
|
|
212
|
+
/**
|
|
213
|
+
* Whether implementations must meaningfully support this element.
|
|
214
|
+
*
|
|
215
|
+
* **Design decision:** Always `boolean`, never `undefined`.
|
|
216
|
+
* Defaults to `false` during snapshot resolution.
|
|
217
|
+
*/
|
|
218
|
+
mustSupport: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Whether this element can modify the meaning of other elements.
|
|
221
|
+
*
|
|
222
|
+
* **Design decision:** Always `boolean`, never `undefined`.
|
|
223
|
+
* Defaults to `false` during snapshot resolution.
|
|
224
|
+
*/
|
|
225
|
+
isModifier: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Whether this element is included in summary views.
|
|
228
|
+
*
|
|
229
|
+
* **Design decision:** Always `boolean`, never `undefined`.
|
|
230
|
+
* Defaults to `false` during snapshot resolution.
|
|
231
|
+
*/
|
|
232
|
+
isSummary: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Slice name for this element, if it is a named slice.
|
|
235
|
+
*
|
|
236
|
+
* Corresponds to `ElementDefinition.sliceName`. Only present on
|
|
237
|
+
* elements that represent a specific slice within a sliced array.
|
|
238
|
+
*
|
|
239
|
+
* @example `'MRN'` for `Patient.identifier:MRN`
|
|
240
|
+
*/
|
|
241
|
+
sliceName?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Fixed value constraint for this element.
|
|
244
|
+
*
|
|
245
|
+
* When present, the element value MUST exactly equal this value.
|
|
246
|
+
* Corresponds to `ElementDefinition.fixed[x]` in the FHIR spec.
|
|
247
|
+
*
|
|
248
|
+
* **Design decision:** Stored as `unknown` because fixed values can
|
|
249
|
+
* be any FHIR type (primitive or complex). The validator performs
|
|
250
|
+
* deep equality comparison at runtime.
|
|
251
|
+
*/
|
|
252
|
+
fixed?: unknown;
|
|
253
|
+
/**
|
|
254
|
+
* Pattern value constraint for this element.
|
|
255
|
+
*
|
|
256
|
+
* When present, the element value must be a superset of this pattern —
|
|
257
|
+
* all fields in the pattern must exist in the value with matching values,
|
|
258
|
+
* but the value may contain additional fields.
|
|
259
|
+
* Corresponds to `ElementDefinition.pattern[x]` in the FHIR spec.
|
|
260
|
+
*
|
|
261
|
+
* **Design decision:** Stored as `unknown` for the same reason as `fixed`.
|
|
262
|
+
*/
|
|
263
|
+
pattern?: unknown;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The internal, resolved representation of a FHIR StructureDefinition.
|
|
267
|
+
*
|
|
268
|
+
* A CanonicalProfile is produced by the snapshot generation algorithm
|
|
269
|
+
* (fhir-profile module) from a StructureDefinition. It flattens the
|
|
270
|
+
* inheritance chain and resolves all element constraints into a single,
|
|
271
|
+
* self-contained structure optimized for validation and runtime use.
|
|
272
|
+
*
|
|
273
|
+
* ## Usage
|
|
274
|
+
*
|
|
275
|
+
* ```typescript
|
|
276
|
+
* // Produced by fhir-profile (Phase 4):
|
|
277
|
+
* const profile: CanonicalProfile = snapshotGenerator.generate(structureDef);
|
|
278
|
+
*
|
|
279
|
+
* // O(1) element lookup:
|
|
280
|
+
* const nameElement = profile.elements.get('Patient.name');
|
|
281
|
+
*
|
|
282
|
+
* // Iteration in definition order (Map preserves insertion order):
|
|
283
|
+
* for (const [path, element] of profile.elements) { ... }
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
* ## Design note on `elements` ordering
|
|
287
|
+
*
|
|
288
|
+
* JavaScript `Map` preserves insertion order (ES2015+). The fhir-profile
|
|
289
|
+
* module MUST insert elements in the same order as the snapshot element
|
|
290
|
+
* array, so that iteration over `elements` yields elements in definition
|
|
291
|
+
* order. This is important for rendering and for algorithms that depend
|
|
292
|
+
* on element ordering (e.g., slicing evaluation).
|
|
293
|
+
*/
|
|
294
|
+
export interface CanonicalProfile {
|
|
295
|
+
/**
|
|
296
|
+
* Canonical URL of this profile.
|
|
297
|
+
*
|
|
298
|
+
* Corresponds to `StructureDefinition.url`.
|
|
299
|
+
*/
|
|
300
|
+
url: string;
|
|
301
|
+
/**
|
|
302
|
+
* Business version of this profile.
|
|
303
|
+
*
|
|
304
|
+
* Corresponds to `StructureDefinition.version`.
|
|
305
|
+
*/
|
|
306
|
+
version?: string;
|
|
307
|
+
/**
|
|
308
|
+
* Computer-readable name.
|
|
309
|
+
*
|
|
310
|
+
* Corresponds to `StructureDefinition.name`.
|
|
311
|
+
*/
|
|
312
|
+
name: string;
|
|
313
|
+
/**
|
|
314
|
+
* The kind of structure: primitive-type | complex-type | resource | logical.
|
|
315
|
+
*
|
|
316
|
+
* Corresponds to `StructureDefinition.kind`.
|
|
317
|
+
*/
|
|
318
|
+
kind: StructureDefinitionKind;
|
|
319
|
+
/**
|
|
320
|
+
* The type defined or constrained (e.g., `Patient`, `Observation`).
|
|
321
|
+
*
|
|
322
|
+
* Corresponds to `StructureDefinition.type`.
|
|
323
|
+
*/
|
|
324
|
+
type: string;
|
|
325
|
+
/**
|
|
326
|
+
* Canonical URL of the base profile, if any.
|
|
327
|
+
*
|
|
328
|
+
* Corresponds to `StructureDefinition.baseDefinition`.
|
|
329
|
+
*/
|
|
330
|
+
baseProfile?: string;
|
|
331
|
+
/**
|
|
332
|
+
* Whether this type is abstract.
|
|
333
|
+
*
|
|
334
|
+
* Corresponds to `StructureDefinition.abstract`.
|
|
335
|
+
*/
|
|
336
|
+
abstract: boolean;
|
|
337
|
+
/**
|
|
338
|
+
* specialization | constraint
|
|
339
|
+
*
|
|
340
|
+
* Corresponds to `StructureDefinition.derivation`.
|
|
341
|
+
*/
|
|
342
|
+
derivation?: TypeDerivationRule;
|
|
343
|
+
/**
|
|
344
|
+
* All resolved elements, keyed by element path.
|
|
345
|
+
*
|
|
346
|
+
* **Design decision:** Uses `Map<string, CanonicalElement>` instead of
|
|
347
|
+
* an array for O(1) path lookup. `Map` preserves insertion order
|
|
348
|
+
* (ES2015+), so iteration yields elements in definition order matching
|
|
349
|
+
* the original snapshot element array.
|
|
350
|
+
*
|
|
351
|
+
* The fhir-profile module is responsible for populating this Map in
|
|
352
|
+
* the correct order during snapshot generation.
|
|
353
|
+
*/
|
|
354
|
+
elements: Map<string, CanonicalElement>;
|
|
355
|
+
/**
|
|
356
|
+
* Inner types extracted from BackboneElement elements.
|
|
357
|
+
*
|
|
358
|
+
* Keyed by generated type name (e.g., `'PatientContact'`).
|
|
359
|
+
* Each inner type is itself a `CanonicalProfile` containing only
|
|
360
|
+
* the direct child elements of the BackboneElement.
|
|
361
|
+
*
|
|
362
|
+
* Populated by {@link extractInnerTypes} after snapshot generation.
|
|
363
|
+
* Inspired by Medplum's `InternalTypeSchema.innerTypes`.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```typescript
|
|
367
|
+
* const patientProfile = ...;
|
|
368
|
+
* const contactType = patientProfile.innerTypes?.get('PatientContact');
|
|
369
|
+
* // contactType.elements has: Patient.contact.relationship, Patient.contact.name, ...
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
innerTypes?: Map<string, CanonicalProfile>;
|
|
373
|
+
/**
|
|
374
|
+
* If this profile is an inner type, the generated type name of its parent.
|
|
375
|
+
*
|
|
376
|
+
* For example, `PatientContact` has `parentType: 'Patient'`.
|
|
377
|
+
* Top-level profiles have `parentType` as `undefined`.
|
|
378
|
+
*/
|
|
379
|
+
parentType?: string;
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=canonical-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-profile.d.ts","sourceRoot":"","sources":["../../../src/model/canonical-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAMzB;;;;;GAKG;AACH,MAAM,WAAW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