gdc-common-utils-ts 2.1.0 → 2.2.2

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.
Files changed (154) hide show
  1. package/README.md +18 -0
  2. package/dist/claims/claims-helpers-allergy-intolerance.d.ts +8 -0
  3. package/dist/claims/claims-helpers-allergy-intolerance.js +30 -12
  4. package/dist/claims/claims-helpers-condition.d.ts +8 -0
  5. package/dist/claims/claims-helpers-condition.js +30 -12
  6. package/dist/claims/claims-helpers-consent.d.ts +4 -0
  7. package/dist/claims/claims-helpers-consent.js +15 -1
  8. package/dist/claims/claims-helpers-diagnostic-report.d.ts +4 -0
  9. package/dist/claims/claims-helpers-diagnostic-report.js +17 -2
  10. package/dist/claims/claims-helpers-medication-statement.d.ts +10 -2
  11. package/dist/claims/claims-helpers-medication-statement.js +32 -14
  12. package/dist/constants/didcomm.d.ts +22 -0
  13. package/dist/constants/didcomm.js +22 -0
  14. package/dist/constants/fhir-resource-types.d.ts +2 -0
  15. package/dist/constants/fhir-resource-types.js +1 -0
  16. package/dist/constants/index.d.ts +1 -0
  17. package/dist/constants/index.js +1 -0
  18. package/dist/constants/lifecycle.d.ts +2 -0
  19. package/dist/constants/lifecycle.js +2 -0
  20. package/dist/constants/verifiable-credentials.d.ts +9 -0
  21. package/dist/constants/verifiable-credentials.js +9 -0
  22. package/dist/examples/bundle-didcomm-payload.js +4 -2
  23. package/dist/examples/communication-attached-bundle-session.js +27 -27
  24. package/dist/examples/communication-didcomm-payload.d.ts +8 -4
  25. package/dist/examples/communication-didcomm-payload.js +17 -11
  26. package/dist/examples/consent-access.js +2 -1
  27. package/dist/examples/employee.d.ts +21 -0
  28. package/dist/examples/employee.js +21 -0
  29. package/dist/examples/individual-controller.d.ts +27 -0
  30. package/dist/examples/individual-controller.js +28 -1
  31. package/dist/examples/inter-tenant-access-contract.js +3 -2
  32. package/dist/examples/ips-bundle.js +17 -16
  33. package/dist/examples/lifecycle.js +13 -11
  34. package/dist/examples/profile-manager-mem.js +2 -1
  35. package/dist/examples/related-person.d.ts +14 -0
  36. package/dist/examples/related-person.js +18 -4
  37. package/dist/examples/shared.d.ts +12 -3
  38. package/dist/examples/shared.js +13 -4
  39. package/dist/examples/vital-signs.js +1 -1
  40. package/dist/examples/wallet-mem.js +4 -2
  41. package/dist/models/authority-resolution.d.ts +56 -0
  42. package/dist/models/authority-resolution.js +2 -0
  43. package/dist/models/bundle-editor-types.d.ts +89 -0
  44. package/dist/models/bundle-editor-types.js +45 -0
  45. package/dist/models/bundle.d.ts +5 -0
  46. package/dist/models/communication-attached-bundle-session.d.ts +6 -4
  47. package/dist/models/communication-attached-bundle-session.js +6 -4
  48. package/dist/models/confidential-storage.d.ts +2 -1
  49. package/dist/models/consent-rule.d.ts +11 -1
  50. package/dist/models/consent-rule.js +9 -1
  51. package/dist/models/index.d.ts +2 -0
  52. package/dist/models/index.js +2 -0
  53. package/dist/models/individual-onboarding.d.ts +18 -0
  54. package/dist/models/interoperable-claims/allergy-intolerance-claims.d.ts +12 -1
  55. package/dist/models/interoperable-claims/allergy-intolerance-claims.js +12 -1
  56. package/dist/models/interoperable-claims/condition-claims.d.ts +12 -1
  57. package/dist/models/interoperable-claims/condition-claims.js +12 -1
  58. package/dist/models/interoperable-claims/diagnostic-report-claims.d.ts +13 -2
  59. package/dist/models/interoperable-claims/diagnostic-report-claims.js +12 -1
  60. package/dist/models/interoperable-claims/document-reference-claims.d.ts +1 -0
  61. package/dist/models/interoperable-claims/document-reference-claims.js +3 -0
  62. package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
  63. package/dist/models/interoperable-claims/medication-statement-claims.js +17 -0
  64. package/dist/utils/allergy-intolerance-entry-editor.d.ts +51 -0
  65. package/dist/utils/allergy-intolerance-entry-editor.js +55 -0
  66. package/dist/utils/authority-resolution.d.ts +37 -0
  67. package/dist/utils/authority-resolution.js +112 -0
  68. package/dist/utils/backend-message-manager-mem.d.ts +11 -0
  69. package/dist/utils/backend-message-manager-mem.js +11 -0
  70. package/dist/utils/bundle-didcomm-payload.js +3 -2
  71. package/dist/utils/bundle-document-builder.d.ts +1 -0
  72. package/dist/utils/bundle-document-builder.js +134 -14
  73. package/dist/utils/bundle-editor-core.d.ts +181 -0
  74. package/dist/utils/bundle-editor-core.js +467 -0
  75. package/dist/utils/bundle-editor-helpers.d.ts +53 -0
  76. package/dist/utils/bundle-editor-helpers.js +146 -0
  77. package/dist/utils/bundle-editor-registry.d.ts +6 -0
  78. package/dist/utils/bundle-editor-registry.js +14 -0
  79. package/dist/utils/bundle-editor.d.ts +21 -722
  80. package/dist/utils/bundle-editor.js +21 -1601
  81. package/dist/utils/bundle-entry-editor.d.ts +96 -0
  82. package/dist/utils/bundle-entry-editor.js +305 -0
  83. package/dist/utils/bundle-query.d.ts +1 -0
  84. package/dist/utils/bundle-query.js +12 -3
  85. package/dist/utils/bundle-reader.d.ts +48 -0
  86. package/dist/utils/bundle-reader.js +175 -1
  87. package/dist/utils/care-plan-entry-editor.d.ts +43 -0
  88. package/dist/utils/care-plan-entry-editor.js +47 -0
  89. package/dist/utils/client-assertion.d.ts +38 -0
  90. package/dist/utils/client-assertion.js +113 -0
  91. package/dist/utils/clinical-impression-entry-editor.d.ts +43 -0
  92. package/dist/utils/clinical-impression-entry-editor.js +47 -0
  93. package/dist/utils/clinical-resource-entry-editor.d.ts +123 -0
  94. package/dist/utils/clinical-resource-entry-editor.js +296 -0
  95. package/dist/utils/communication-attached-bundle-session-helpers.js +8 -6
  96. package/dist/utils/communication-attached-bundle-session.d.ts +29 -3
  97. package/dist/utils/communication-attached-bundle-session.js +62 -3
  98. package/dist/utils/communication-didcomm-payload.d.ts +5 -0
  99. package/dist/utils/communication-didcomm-payload.js +28 -18
  100. package/dist/utils/communication-document-reference.d.ts +23 -0
  101. package/dist/utils/communication-document-reference.js +89 -0
  102. package/dist/utils/communication-editor.d.ts +53 -0
  103. package/dist/utils/communication-editor.js +97 -0
  104. package/dist/utils/condition-entry-editor.d.ts +30 -0
  105. package/dist/utils/condition-entry-editor.js +34 -0
  106. package/dist/utils/consent-claim-helpers.d.ts +4 -0
  107. package/dist/utils/consent-claim-helpers.js +15 -1
  108. package/dist/utils/coverage-entry-editor.d.ts +51 -0
  109. package/dist/utils/coverage-entry-editor.js +55 -0
  110. package/dist/utils/device-entry-editor.d.ts +59 -0
  111. package/dist/utils/device-entry-editor.js +63 -0
  112. package/dist/utils/device-use-statement-entry-editor.d.ts +43 -0
  113. package/dist/utils/device-use-statement-entry-editor.js +47 -0
  114. package/dist/utils/diagnostic-report-entry-editor.d.ts +74 -0
  115. package/dist/utils/diagnostic-report-entry-editor.js +136 -0
  116. package/dist/utils/did.d.ts +8 -0
  117. package/dist/utils/did.js +22 -0
  118. package/dist/utils/document-reference-entry-editor.d.ts +62 -0
  119. package/dist/utils/document-reference-entry-editor.js +66 -0
  120. package/dist/utils/employee-entry-editor.d.ts +36 -0
  121. package/dist/utils/employee-entry-editor.js +88 -0
  122. package/dist/utils/employee.d.ts +1 -0
  123. package/dist/utils/employee.js +2 -1
  124. package/dist/utils/encounter-entry-editor.d.ts +51 -0
  125. package/dist/utils/encounter-entry-editor.js +55 -0
  126. package/dist/utils/flag-entry-editor.d.ts +47 -0
  127. package/dist/utils/flag-entry-editor.js +51 -0
  128. package/dist/utils/immunization-entry-editor.d.ts +87 -0
  129. package/dist/utils/immunization-entry-editor.js +169 -0
  130. package/dist/utils/index.d.ts +7 -0
  131. package/dist/utils/index.js +7 -0
  132. package/dist/utils/individual-onboarding-acceptance-credential.d.ts +35 -0
  133. package/dist/utils/individual-onboarding-acceptance-credential.js +55 -0
  134. package/dist/utils/individual-smart.d.ts +59 -0
  135. package/dist/utils/individual-smart.js +135 -0
  136. package/dist/utils/medication-statement-entry-editor.d.ts +90 -0
  137. package/dist/utils/medication-statement-entry-editor.js +94 -0
  138. package/dist/utils/observation-component-entry-editor.d.ts +57 -0
  139. package/dist/utils/observation-component-entry-editor.js +105 -0
  140. package/dist/utils/observation-entry-editor.d.ts +29 -0
  141. package/dist/utils/observation-entry-editor.js +68 -0
  142. package/dist/utils/procedure-entry-editor.d.ts +71 -0
  143. package/dist/utils/procedure-entry-editor.js +75 -0
  144. package/dist/utils/professional-smart.d.ts +87 -0
  145. package/dist/utils/professional-smart.js +118 -4
  146. package/dist/utils/same-as.d.ts +40 -0
  147. package/dist/utils/same-as.js +72 -0
  148. package/dist/utils/unified-health-id.d.ts +51 -0
  149. package/dist/utils/unified-health-id.js +92 -0
  150. package/dist/utils/vital-sign-day-batch.d.ts +25 -0
  151. package/dist/utils/vital-sign-day-batch.js +115 -0
  152. package/dist/utils/vital-sign-entry-editor.d.ts +61 -0
  153. package/dist/utils/vital-sign-entry-editor.js +152 -0
  154. package/package.json +2 -1
@@ -1,1601 +1,21 @@
1
- import { ClaimsPersonSchemaorg } from '../constants/schemaorg.js';
2
- import { ResourceTypesFhirR4 } from '../constants/fhir-resource-types.js';
3
- import { ObservationCategoryCodes, VitalSignsCodes, VitalSignsUnits } from '../constants/vital-signs.js';
4
- import { AllergyIntoleranceClaim } from '../models/interoperable-claims/allergy-intolerance-claims.js';
5
- import { CarePlanClaim } from '../models/interoperable-claims/care-plan-claims.js';
6
- import { ClinicalImpressionClaim } from '../models/interoperable-claims/clinical-impression-claims.js';
7
- import { ConditionClaim } from '../models/interoperable-claims/condition-claims.js';
8
- import { CoverageClaim } from '../models/interoperable-claims/coverage-claims.js';
9
- import { DeviceClaim } from '../models/interoperable-claims/device-claims.js';
10
- import { DeviceUseStatementClaim } from '../models/interoperable-claims/device-use-statement-claims.js';
11
- import { DiagnosticReportClaim } from '../models/interoperable-claims/diagnostic-report-claims.js';
12
- import { DocumentReferenceClaim } from '../models/interoperable-claims/document-reference-claims.js';
13
- import { EncounterClaim } from '../models/interoperable-claims/encounter-claims.js';
14
- import { FlagClaim } from '../models/interoperable-claims/flag-claims.js';
15
- import { ImmunizationClaim } from '../models/interoperable-claims/immunization-claims.js';
16
- import { MedicationStatementClaim, MedicationStatementClaimsFhirApiExtended, } from '../models/interoperable-claims/medication-statement-claims.js';
17
- import { ObservationClaim } from '../models/interoperable-claims/observation-claims.js';
18
- import { ProcedureClaim } from '../models/interoperable-claims/procedure-claims.js';
19
- import { getClaimValues, setClaimValues } from '../claims/claim-list-helpers.js';
20
- import { buildEmployeeBatchEntry, buildEmployeePurgeBundle, buildEmployeeSearchBundle, EmployeeBatchEntryTypes, EmployeeBundleMethods, EmployeeBundleOperations, EmployeeResourceTypes, } from './employee.js';
21
- export const BundleEditableResourceTypes = Object.freeze({
22
- employee: EmployeeResourceTypes.employee,
23
- consent: ResourceTypesFhirR4.Consent,
24
- observation: ResourceTypesFhirR4.Observation,
25
- vitalSign: ResourceTypesFhirR4.Observation,
26
- allergyIntolerance: ResourceTypesFhirR4.AllergyIntolerance,
27
- condition: ResourceTypesFhirR4.Condition,
28
- medicationStatement: ResourceTypesFhirR4.MedicationStatement,
29
- documentReference: ResourceTypesFhirR4.DocumentReference,
30
- carePlan: ResourceTypesFhirR4.CarePlan,
31
- flag: ResourceTypesFhirR4.Flag,
32
- clinicalImpression: ResourceTypesFhirR4.ClinicalImpression,
33
- device: ResourceTypesFhirR4.Device,
34
- deviceUseStatement: ResourceTypesFhirR4.DeviceUseStatement,
35
- encounter: ResourceTypesFhirR4.Encounter,
36
- coverage: ResourceTypesFhirR4.Coverage,
37
- immunization: ResourceTypesFhirR4.Immunization,
38
- procedure: ResourceTypesFhirR4.Procedure,
39
- diagnosticReport: ResourceTypesFhirR4.DiagnosticReport,
40
- });
41
- function cloneEntry(value) {
42
- return JSON.parse(JSON.stringify(value));
43
- }
44
- function cloneClaimValue(value) {
45
- if (Array.isArray(value)) {
46
- return [...value];
47
- }
48
- return value;
49
- }
50
- function normalizeOptionalIdentifier(value) {
51
- if (value === undefined || value === null) {
52
- return undefined;
53
- }
54
- const normalized = String(value).trim();
55
- return normalized ? normalized : undefined;
56
- }
57
- function createCanonicalIdentifierUrn() {
58
- const cryptoLike = globalThis;
59
- const uuid = typeof cryptoLike.crypto?.randomUUID === 'function'
60
- ? cryptoLike.crypto.randomUUID()
61
- : `resource-${Date.now()}-${Math.random().toString(16).slice(2)}`;
62
- return `urn:uuid:${uuid}`;
63
- }
64
- function resolveRequestMethodForOperation(operation) {
65
- switch (operation) {
66
- case EmployeeBundleOperations.disable:
67
- return EmployeeBundleMethods.disable;
68
- case EmployeeBundleOperations.search:
69
- case EmployeeBundleOperations.create:
70
- case EmployeeBundleOperations.purge:
71
- default:
72
- return EmployeeBundleMethods.create;
73
- }
74
- }
75
- function resolveEntryTypeForOperation(operation) {
76
- switch (operation) {
77
- case EmployeeBundleOperations.disable:
78
- return EmployeeBatchEntryTypes.disable;
79
- case EmployeeBundleOperations.purge:
80
- return EmployeeBatchEntryTypes.purge;
81
- case EmployeeBundleOperations.search:
82
- return EmployeeBatchEntryTypes.search;
83
- case EmployeeBundleOperations.create:
84
- default:
85
- return EmployeeBatchEntryTypes.create;
86
- }
87
- }
88
- function inferGenericEntryType(resourceType, operation) {
89
- const normalizedResourceType = String(resourceType || '').trim();
90
- if (normalizedResourceType === EmployeeResourceTypes.employee) {
91
- return resolveEntryTypeForOperation(operation);
92
- }
93
- return `${normalizedResourceType}-${operation}-request-v1.0`;
94
- }
95
- /**
96
- * Generic bundle editor for FHIR-like bundle payloads assembled in memory.
97
- *
98
- * This class owns bundle-level concerns:
99
- * - which business operation the bundle represents
100
- * - which resource type the bundle allows
101
- * - which entries belong to the bundle
102
- * - when the final bundle is materialized through `build()`
103
- *
104
- * Resource-specific semantics belong to resource entry editors such as
105
- * `EmployeeEntryEditor`.
106
- */
107
- export class BundleEditor {
108
- bundleOperation = null;
109
- allowedResourceType = null;
110
- entries = [];
111
- /**
112
- * Declares which business action this in-memory bundle is staging.
113
- *
114
- * Important distinction:
115
- * - this is **not** the same concept as FHIR `Bundle.entry.request.method`
116
- * - this is the higher-level action the editor is helping to assemble, for
117
- * example `create`, `search`, `disable`, or `purge`
118
- * - the lower-level transport/request method may later be derived from that
119
- * action, and may differ by backend contract
120
- *
121
- * Example:
122
- * - bundle operation `disable`
123
- * - current employee GW contract -> inner `entry.request.method = DELETE`
124
- * - current individual organization GW contract -> explicit `/_disable`
125
- * route with inner `entry.request.method = POST`
126
- */
127
- setBundleOperation(operation) {
128
- this.bundleOperation = operation;
129
- return this;
130
- }
131
- /**
132
- * Returns the current high-level business action assigned to the bundle.
133
- *
134
- * Read this as:
135
- * - "what am I trying to do?"
136
- *
137
- * not as:
138
- * - "which HTTP/FHIR request method will the final entry use?"
139
- */
140
- getBundleOperation() {
141
- return this.bundleOperation;
142
- }
143
- /**
144
- * Restricts the bundle to one resource type.
145
- *
146
- * For employee batch bundles this should be fixed to
147
- * `EmployeeResourceTypes.employee` so the editor cannot mix unrelated
148
- * resource kinds.
149
- */
150
- setAllowedResourceType(resourceType) {
151
- this.allowedResourceType = resourceType;
152
- return this;
153
- }
154
- /** Returns the bundle resource type restriction when already declared. */
155
- getAllowedResourceType() {
156
- return this.allowedResourceType;
157
- }
158
- /**
159
- * Opens one new entry and returns a generic entry editor for that slot.
160
- *
161
- * The entry editor can later expose resource-specific semantics through
162
- * methods such as `asEmployee()`.
163
- */
164
- newEntry(resourceId) {
165
- const operation = this.requireBundleOperation();
166
- const resourceType = this.requireAllowedResourceType();
167
- const entry = this.createEntryDraft(operation, resourceType, resourceId);
168
- this.entries.push(entry);
169
- return new BundleEntryEditor(this, this.entries.length - 1);
170
- }
171
- /** Reopens one existing entry by `resource.id` or `fullUrl`. */
172
- openEntry(resourceIdOrFullUrl) {
173
- const normalizedIdentifier = normalizeOptionalIdentifier(resourceIdOrFullUrl);
174
- if (!normalizedIdentifier) {
175
- throw new Error('openEntry requires a non-empty resource identifier or fullUrl.');
176
- }
177
- const entryIndex = this.entries.findIndex((entry) => {
178
- return normalizeOptionalIdentifier(entry.resource?.id) === normalizedIdentifier
179
- || normalizeOptionalIdentifier(entry.fullUrl) === normalizedIdentifier;
180
- });
181
- if (entryIndex < 0) {
182
- throw new Error(`openEntry could not find resource identifier or fullUrl: ${normalizedIdentifier}`);
183
- }
184
- return new BundleEntryEditor(this, entryIndex);
185
- }
186
- /** Returns cloned staged entries for inspection or debugging. */
187
- getEntries() {
188
- return this.entries.map((entry) => cloneEntry(entry));
189
- }
190
- /**
191
- * Materializes the final bundle payload from the editor state.
192
- *
193
- * `build()` does not send, sign, or wrap the payload. It only returns the
194
- * final bundle object for the declared operation and staged entries.
195
- */
196
- build() {
197
- const operation = this.requireBundleOperation();
198
- const resourceType = this.requireAllowedResourceType();
199
- if (operation === EmployeeBundleOperations.search) {
200
- if (resourceType !== EmployeeResourceTypes.employee) {
201
- throw new Error(`BundleEditor search currently supports only resource type: ${EmployeeResourceTypes.employee}`);
202
- }
203
- return buildEmployeeSearchBundle({
204
- claims: this.getSingleSearchClaims(),
205
- resourceType,
206
- });
207
- }
208
- if (operation === EmployeeBundleOperations.purge) {
209
- if (resourceType !== EmployeeResourceTypes.employee) {
210
- throw new Error(`BundleEditor purge currently supports only resource type: ${EmployeeResourceTypes.employee}`);
211
- }
212
- return {
213
- resourceType: EmployeeResourceTypes.bundle,
214
- type: EmployeeResourceTypes.batch,
215
- entry: this.entries.map((entry) => {
216
- const identifier = normalizeOptionalIdentifier(entry.resource?.meta?.claims?.[ClaimsPersonSchemaorg.identifier]
217
- || entry.resource?.id
218
- || entry.fullUrl);
219
- if (!identifier) {
220
- throw new Error('Every purge entry requires one canonical employee identifier.');
221
- }
222
- return buildEmployeePurgeBundle({
223
- identifier,
224
- resourceType,
225
- }).entry[0];
226
- }),
227
- };
228
- }
229
- return {
230
- resourceType: ResourceTypesFhirR4.Bundle,
231
- type: EmployeeResourceTypes.batch,
232
- entry: this.entries.map((entry) => cloneEntry(entry)),
233
- };
234
- }
235
- /**
236
- * Materializes the staged entries as the `BundleJsonApi` shape used by
237
- * `CommunicationAttachedBundleSession` and `ConsentAccessEditor`.
238
- *
239
- * Use this when the next layer edits bundle entries in-memory before another
240
- * runtime wraps or sends the bundle.
241
- */
242
- buildJsonApi() {
243
- return {
244
- resourceType: ResourceTypesFhirR4.Bundle,
245
- type: EmployeeResourceTypes.batch,
246
- data: this.entries.map((entry) => {
247
- const clonedEntry = cloneEntry(entry);
248
- const { request: _requestIgnored, ...clonedEntryWithoutRequest } = clonedEntry;
249
- const normalizedRequest = clonedEntry.request
250
- ? {
251
- method: clonedEntry.request.method,
252
- url: clonedEntry.request.url || '',
253
- }
254
- : undefined;
255
- return normalizedRequest
256
- ? {
257
- ...clonedEntryWithoutRequest,
258
- request: normalizedRequest,
259
- }
260
- : clonedEntryWithoutRequest;
261
- }),
262
- };
263
- }
264
- /** @internal */
265
- getMutableEntry(entryIndex) {
266
- if (!Number.isInteger(entryIndex) || entryIndex < 0 || entryIndex >= this.entries.length) {
267
- throw new Error(`BundleEditor could not open entry index: ${entryIndex}`);
268
- }
269
- return this.entries[entryIndex];
270
- }
271
- createEntryDraft(operation, resourceType, resourceId) {
272
- const normalizedIdentifier = operation === EmployeeBundleOperations.search
273
- ? normalizeOptionalIdentifier(resourceId)
274
- : (normalizeOptionalIdentifier(resourceId) || createCanonicalIdentifierUrn());
275
- const claims = {
276
- '@context': 'org.schema',
277
- ...(normalizedIdentifier ? { [ClaimsPersonSchemaorg.identifier]: normalizedIdentifier } : {}),
278
- };
279
- if (resourceType !== EmployeeResourceTypes.employee) {
280
- return {
281
- type: inferGenericEntryType(resourceType, operation),
282
- request: { method: resolveRequestMethodForOperation(operation) },
283
- fullUrl: normalizedIdentifier,
284
- resource: {
285
- resourceType,
286
- ...(normalizedIdentifier ? { id: normalizedIdentifier } : {}),
287
- meta: { claims: {} },
288
- },
289
- };
290
- }
291
- const entry = buildEmployeeBatchEntry({
292
- type: resolveEntryTypeForOperation(operation),
293
- method: resolveRequestMethodForOperation(operation),
294
- resourceId: normalizedIdentifier,
295
- resourceType,
296
- claims,
297
- });
298
- if (normalizedIdentifier) {
299
- entry.fullUrl = normalizedIdentifier;
300
- }
301
- return entry;
302
- }
303
- getSingleSearchClaims() {
304
- if (this.entries.length === 0) {
305
- return {};
306
- }
307
- if (this.entries.length > 1) {
308
- throw new Error('Search bundles currently support one entry per bundle.');
309
- }
310
- const claims = this.entries[0].resource?.meta?.claims || {};
311
- const searchClaims = {};
312
- for (const [key, value] of Object.entries(claims)) {
313
- if (value === undefined
314
- || value === null
315
- || typeof value === 'string'
316
- || typeof value === 'number'
317
- || typeof value === 'boolean') {
318
- searchClaims[key] = value;
319
- }
320
- }
321
- return searchClaims;
322
- }
323
- requireBundleOperation() {
324
- if (!this.bundleOperation) {
325
- throw new Error('BundleEditor requires setBundleOperation(...) before newEntry() or build().');
326
- }
327
- return this.bundleOperation;
328
- }
329
- requireAllowedResourceType() {
330
- if (!this.allowedResourceType) {
331
- throw new Error('BundleEditor requires setAllowedResourceType(...) before newEntry() or build().');
332
- }
333
- return this.allowedResourceType;
334
- }
335
- }
336
- /**
337
- * Generic editor for one staged bundle entry.
338
- *
339
- * This class only knows generic entry concerns such as:
340
- * - resource id
341
- * - fullUrl
342
- * - meta claims
343
- * - conversion to one resource-specific entry editor
344
- */
345
- export class BundleEntryEditor {
346
- bundleEditor;
347
- entryIndex;
348
- constructor(bundleEditor, entryIndex) {
349
- this.bundleEditor = bundleEditor;
350
- this.entryIndex = entryIndex;
351
- }
352
- /** Opens the current entry as one employee-specific resource editor. */
353
- asEmployee() {
354
- const entry = this.getMutableEntry();
355
- if (entry.resource?.resourceType !== EmployeeResourceTypes.employee) {
356
- throw new Error(`BundleEntryEditor cannot open this entry as Employee: ${String(entry.resource?.resourceType || '')}`);
357
- }
358
- return new EmployeeEntryEditor(this.bundleEditor, this.entryIndex);
359
- }
360
- /** Opens the current entry as one vital-sign-specific Observation editor. */
361
- asVitalSign() {
362
- const entry = this.getMutableEntry();
363
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Observation) {
364
- throw new Error(`BundleEntryEditor cannot open this entry as VitalSign: ${String(entry.resource?.resourceType || '')}`);
365
- }
366
- return new VitalSignEntryEditor(this.bundleEditor, this.entryIndex);
367
- }
368
- /** Opens the current entry as one general Observation editor. */
369
- asObservation() {
370
- const entry = this.getMutableEntry();
371
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Observation) {
372
- throw new Error(`BundleEntryEditor cannot open this entry as Observation: ${String(entry.resource?.resourceType || '')}`);
373
- }
374
- return new ObservationEntryEditor(this.bundleEditor, this.entryIndex);
375
- }
376
- /** Opens the current entry as one AllergyIntolerance editor. */
377
- asAllergy() {
378
- const entry = this.getMutableEntry();
379
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.AllergyIntolerance) {
380
- throw new Error(`BundleEntryEditor cannot open this entry as AllergyIntolerance: ${String(entry.resource?.resourceType || '')}`);
381
- }
382
- return new AllergyIntoleranceEntryEditor(this.bundleEditor, this.entryIndex);
383
- }
384
- /** Opens the current entry as one Condition editor. */
385
- asCondition() {
386
- const entry = this.getMutableEntry();
387
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Condition) {
388
- throw new Error(`BundleEntryEditor cannot open this entry as Condition: ${String(entry.resource?.resourceType || '')}`);
389
- }
390
- return new ConditionEntryEditor(this.bundleEditor, this.entryIndex);
391
- }
392
- /** Opens the current entry as one MedicationStatement editor. */
393
- asMedicationStatement() {
394
- const entry = this.getMutableEntry();
395
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.MedicationStatement) {
396
- throw new Error(`BundleEntryEditor cannot open this entry as MedicationStatement: ${String(entry.resource?.resourceType || '')}`);
397
- }
398
- return new MedicationStatementEntryEditor(this.bundleEditor, this.entryIndex);
399
- }
400
- /** Opens the current entry as one DocumentReference editor. */
401
- asDocumentReference() {
402
- const entry = this.getMutableEntry();
403
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.DocumentReference) {
404
- throw new Error(`BundleEntryEditor cannot open this entry as DocumentReference: ${String(entry.resource?.resourceType || '')}`);
405
- }
406
- return new DocumentReferenceEntryEditor(this.bundleEditor, this.entryIndex);
407
- }
408
- /** Opens the current entry as one CarePlan editor. */
409
- asCarePlan() {
410
- const entry = this.getMutableEntry();
411
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.CarePlan) {
412
- throw new Error(`BundleEntryEditor cannot open this entry as CarePlan: ${String(entry.resource?.resourceType || '')}`);
413
- }
414
- return new CarePlanEntryEditor(this.bundleEditor, this.entryIndex);
415
- }
416
- /** Opens the current entry as one Flag editor. */
417
- asFlag() {
418
- const entry = this.getMutableEntry();
419
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Flag) {
420
- throw new Error(`BundleEntryEditor cannot open this entry as Flag: ${String(entry.resource?.resourceType || '')}`);
421
- }
422
- return new FlagEntryEditor(this.bundleEditor, this.entryIndex);
423
- }
424
- /** Opens the current entry as one ClinicalImpression editor. */
425
- asClinicalImpression() {
426
- const entry = this.getMutableEntry();
427
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.ClinicalImpression) {
428
- throw new Error(`BundleEntryEditor cannot open this entry as ClinicalImpression: ${String(entry.resource?.resourceType || '')}`);
429
- }
430
- return new ClinicalImpressionEntryEditor(this.bundleEditor, this.entryIndex);
431
- }
432
- /** Opens the current entry as one Device editor. */
433
- asDevice() {
434
- const entry = this.getMutableEntry();
435
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Device) {
436
- throw new Error(`BundleEntryEditor cannot open this entry as Device: ${String(entry.resource?.resourceType || '')}`);
437
- }
438
- return new DeviceEntryEditor(this.bundleEditor, this.entryIndex);
439
- }
440
- /** Opens the current entry as one DeviceUseStatement editor. */
441
- asDeviceUseStatement() {
442
- const entry = this.getMutableEntry();
443
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.DeviceUseStatement) {
444
- throw new Error(`BundleEntryEditor cannot open this entry as DeviceUseStatement: ${String(entry.resource?.resourceType || '')}`);
445
- }
446
- return new DeviceUseStatementEntryEditor(this.bundleEditor, this.entryIndex);
447
- }
448
- /** Opens the current entry as one Encounter editor. */
449
- asEncounter() {
450
- const entry = this.getMutableEntry();
451
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Encounter) {
452
- throw new Error(`BundleEntryEditor cannot open this entry as Encounter: ${String(entry.resource?.resourceType || '')}`);
453
- }
454
- return new EncounterEntryEditor(this.bundleEditor, this.entryIndex);
455
- }
456
- /** Opens the current entry as one Coverage editor. */
457
- asCoverage() {
458
- const entry = this.getMutableEntry();
459
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Coverage) {
460
- throw new Error(`BundleEntryEditor cannot open this entry as Coverage: ${String(entry.resource?.resourceType || '')}`);
461
- }
462
- return new CoverageEntryEditor(this.bundleEditor, this.entryIndex);
463
- }
464
- /** Opens the current entry as one Immunization editor. */
465
- asImmunization() {
466
- const entry = this.getMutableEntry();
467
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Immunization) {
468
- throw new Error(`BundleEntryEditor cannot open this entry as Immunization: ${String(entry.resource?.resourceType || '')}`);
469
- }
470
- return new ImmunizationEntryEditor(this.bundleEditor, this.entryIndex);
471
- }
472
- /** Opens the current entry as one Procedure editor. */
473
- asProcedure() {
474
- const entry = this.getMutableEntry();
475
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.Procedure) {
476
- throw new Error(`BundleEntryEditor cannot open this entry as Procedure: ${String(entry.resource?.resourceType || '')}`);
477
- }
478
- return new ProcedureEntryEditor(this.bundleEditor, this.entryIndex);
479
- }
480
- /** Opens the current entry as one DiagnosticReport editor. */
481
- asDiagnosticReport() {
482
- const entry = this.getMutableEntry();
483
- if (entry.resource?.resourceType !== ResourceTypesFhirR4.DiagnosticReport) {
484
- throw new Error(`BundleEntryEditor cannot open this entry as DiagnosticReport: ${String(entry.resource?.resourceType || '')}`);
485
- }
486
- return new DiagnosticReportEntryEditor(this.bundleEditor, this.entryIndex);
487
- }
488
- /** Reads one claim from this entry. */
489
- getClaim(key) {
490
- return cloneClaimValue(this.getClaims()[String(key).trim()]);
491
- }
492
- /** Checks whether this entry contains one claim key. */
493
- hasClaim(key) {
494
- return Object.prototype.hasOwnProperty.call(this.getClaims(), String(key).trim());
495
- }
496
- /** Writes one claim on this entry. */
497
- setClaim(key, value) {
498
- const entry = this.getMutableEntry();
499
- entry.resource = entry.resource || {
500
- resourceType: this.bundleEditor.getAllowedResourceType() || EmployeeResourceTypes.employee,
501
- meta: { claims: {} },
502
- };
503
- entry.resource.meta = entry.resource.meta || {};
504
- entry.resource.meta.claims = {
505
- ...(entry.resource.meta.claims || {}),
506
- [String(key).trim()]: cloneClaimValue(value),
507
- };
508
- return this;
509
- }
510
- /** Appends one claim value on this entry. */
511
- addClaim(key, value) {
512
- const normalizedKey = String(key).trim();
513
- const current = this.getClaim(normalizedKey);
514
- if (current === undefined) {
515
- return this.setClaim(normalizedKey, value);
516
- }
517
- if (Array.isArray(current)) {
518
- return this.setClaim(normalizedKey, [...current, cloneClaimValue(value)]);
519
- }
520
- return this.setClaim(normalizedKey, [current, cloneClaimValue(value)]);
521
- }
522
- /** Removes one claim from this entry. */
523
- removeClaim(key) {
524
- const entry = this.getMutableEntry();
525
- const claims = {
526
- ...(entry.resource?.meta?.claims || {}),
527
- };
528
- delete claims[String(key).trim()];
529
- entry.resource = entry.resource || {
530
- resourceType: this.bundleEditor.getAllowedResourceType() || EmployeeResourceTypes.employee,
531
- meta: { claims: {} },
532
- };
533
- entry.resource.meta = entry.resource.meta || {};
534
- entry.resource.meta.claims = claims;
535
- return this;
536
- }
537
- /** Writes the staged entry `resource.id`. */
538
- setResourceId(resourceId) {
539
- const entry = this.getMutableEntry();
540
- const normalized = normalizeOptionalIdentifier(resourceId);
541
- if (!normalized) {
542
- delete entry.resource?.id;
543
- return this;
544
- }
545
- entry.resource = entry.resource || {
546
- resourceType: this.bundleEditor.getAllowedResourceType() || EmployeeResourceTypes.employee,
547
- meta: { claims: {} },
548
- };
549
- entry.resource.id = normalized;
550
- return this;
551
- }
552
- /** Reads the staged entry `resource.id` when present. */
553
- getResourceId() {
554
- return normalizeOptionalIdentifier(this.getMutableEntry().resource?.id);
555
- }
556
- /** Writes the staged entry `fullUrl`. */
557
- setFullUrl(fullUrl) {
558
- const entry = this.getMutableEntry();
559
- const normalized = normalizeOptionalIdentifier(fullUrl);
560
- if (!normalized) {
561
- delete entry.fullUrl;
562
- return this;
563
- }
564
- entry.fullUrl = normalized;
565
- return this;
566
- }
567
- /** Reads the staged entry `fullUrl` when present. */
568
- getFullUrl() {
569
- return normalizeOptionalIdentifier(this.getMutableEntry().fullUrl);
570
- }
571
- /** Returns control to the parent bundle editor. */
572
- doneEntry() {
573
- return this.bundleEditor;
574
- }
575
- getMutableEntry() {
576
- return this.bundleEditor.getMutableEntry(this.entryIndex);
577
- }
578
- getClaims() {
579
- return {
580
- ...(this.getMutableEntry().resource?.meta?.claims || {}),
581
- };
582
- }
583
- }
584
- /**
585
- * Shared claims-first editor utilities for IPS clinical resource families.
586
- *
587
- * The concrete resource type changes, but the editing contract stays aligned:
588
- * identifier + subject + status + date + optional CSV-backed reference lists.
589
- */
590
- class ClinicalResourceEntryEditor extends BundleEntryEditor {
591
- getIdentifierValue(claimKey) {
592
- return normalizeOptionalIdentifier(this.getClaim(claimKey)
593
- || this.getResourceId()
594
- || this.getFullUrl());
595
- }
596
- setIdentifierValue(claimKey, identifier) {
597
- const normalized = normalizeOptionalIdentifier(identifier);
598
- if (!normalized) {
599
- this.removeClaim(claimKey);
600
- this.setResourceId(undefined);
601
- this.setFullUrl(undefined);
602
- return this;
603
- }
604
- this.setClaim(claimKey, normalized);
605
- this.setResourceId(normalized);
606
- this.setFullUrl(normalized);
607
- return this;
608
- }
609
- setSubjectClaims(subjectClaimKey, patientClaimKey, subject) {
610
- const normalized = normalizeOptionalIdentifier(subject);
611
- if (!normalized) {
612
- this.removeClaim(subjectClaimKey);
613
- this.removeClaim(patientClaimKey);
614
- return this;
615
- }
616
- this.setClaim(subjectClaimKey, normalized);
617
- this.setClaim(patientClaimKey, normalized);
618
- return this;
619
- }
620
- getSubjectClaims(subjectClaimKey, patientClaimKey) {
621
- return normalizeOptionalIdentifier(this.getClaim(subjectClaimKey)
622
- || this.getClaim(patientClaimKey));
623
- }
624
- setScalarClaim(claimKey, value) {
625
- const normalized = normalizeOptionalIdentifier(value);
626
- if (!normalized) {
627
- this.removeClaim(claimKey);
628
- return this;
629
- }
630
- return this.setClaim(claimKey, normalized);
631
- }
632
- getScalarClaim(claimKey) {
633
- return normalizeOptionalIdentifier(this.getClaim(claimKey));
634
- }
635
- setNumberClaim(claimKey, value) {
636
- if (value === undefined || value === null || Number.isNaN(value)) {
637
- this.removeClaim(claimKey);
638
- return this;
639
- }
640
- return this.setClaim(claimKey, String(value));
641
- }
642
- getNumberClaim(claimKey) {
643
- const raw = this.getClaim(claimKey);
644
- if (raw === undefined || raw === null || raw === '')
645
- return undefined;
646
- const numeric = Number(raw);
647
- return Number.isFinite(numeric) ? numeric : undefined;
648
- }
649
- setBooleanClaim(claimKey, value) {
650
- if (value === undefined || value === null) {
651
- this.removeClaim(claimKey);
652
- return this;
653
- }
654
- return this.setClaim(claimKey, value);
655
- }
656
- getBooleanClaim(claimKey) {
657
- const raw = this.getClaim(claimKey);
658
- if (typeof raw === 'boolean')
659
- return raw;
660
- if (raw === 'true')
661
- return true;
662
- if (raw === 'false')
663
- return false;
664
- return undefined;
665
- }
666
- setCsvClaimList(claimKey, values) {
667
- const next = setClaimValues({}, claimKey, values);
668
- const normalized = normalizeOptionalIdentifier(next[claimKey]);
669
- if (!normalized) {
670
- this.removeClaim(claimKey);
671
- return this;
672
- }
673
- return this.setClaim(claimKey, normalized);
674
- }
675
- getCsvClaimList(claimKey) {
676
- return getClaimValues(this.getClaims(), claimKey);
677
- }
678
- ensureIdentifierValue(claimKey) {
679
- const existing = this.getIdentifierValue(claimKey);
680
- if (existing)
681
- return existing;
682
- const generated = createCanonicalIdentifierUrn();
683
- this.setIdentifierValue(claimKey, generated);
684
- return generated;
685
- }
686
- }
687
- /**
688
- * Reduced Observation component-style editor surface.
689
- *
690
- * This base layer owns the reusable code/value authoring helpers shared by
691
- * Vital Signs and broader Observation entry editors.
692
- */
693
- export class ObservationComponentEntryEditor extends BundleEntryEditor {
694
- setCode(code) {
695
- const token = typeof code === 'string' ? code.trim() : code.claim;
696
- this.setClaim(ObservationClaim.Code, token);
697
- if (typeof code !== 'string') {
698
- this.setClaim(ObservationClaim.CodeSystem, code.system);
699
- this.setClaim(ObservationClaim.CodeValue, code.code);
700
- if (code.display) {
701
- this.setClaim(ObservationClaim.CodeDisplay, code.display);
702
- }
703
- }
704
- return this;
705
- }
706
- getCode() {
707
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Code));
708
- }
709
- setCodeSystem(system) {
710
- return this.setClaim(ObservationClaim.CodeSystem, String(system).trim());
711
- }
712
- getCodeSystem() {
713
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeSystem));
714
- }
715
- setCodeValue(value) {
716
- return this.setClaim(ObservationClaim.CodeValue, String(value).trim());
717
- }
718
- getCodeValue() {
719
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeValue));
720
- }
721
- setCodeDisplay(display) {
722
- return this.setClaim(ObservationClaim.CodeDisplay, String(display).trim());
723
- }
724
- getCodeDisplay() {
725
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeDisplay));
726
- }
727
- /**
728
- * Stores the local-language label used by forms and local UI copy.
729
- *
730
- * Keep this distinct from `setCodeDisplay(...)`, which is the canonical
731
- * English/international display carried by the coded concept.
732
- */
733
- setCodeTextLocal(text) {
734
- return this.setClaim(ObservationClaim.CodeText, String(text).trim());
735
- }
736
- /**
737
- * Returns the local-language label used by forms and local UI copy.
738
- *
739
- * Keep this distinct from `getCodeDisplay()`, which returns the canonical
740
- * English/international display when present.
741
- */
742
- getCodeTextLocal() {
743
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeText));
744
- }
745
- /** Compatibility alias for older examples/tests. Prefer `setCodeTextLocal(...)`. */
746
- setLocalText(text) {
747
- return this.setCodeTextLocal(text);
748
- }
749
- /** Compatibility alias for older examples/tests. Prefer `getCodeTextLocal()`. */
750
- getLocalText() {
751
- return this.getCodeTextLocal();
752
- }
753
- setValueQuantityNumber(value) {
754
- return this.setClaim(ObservationClaim.ValueQuantityNumber, String(value));
755
- }
756
- getValueQuantityNumber() {
757
- const raw = this.getClaim(ObservationClaim.ValueQuantityNumber);
758
- if (raw === undefined || raw === null || raw === '')
759
- return undefined;
760
- const numeric = Number(raw);
761
- return Number.isFinite(numeric) ? numeric : undefined;
762
- }
763
- setValueQuantityUnit(unit) {
764
- const normalized = typeof unit === 'string' ? unit.trim() : unit.claim;
765
- return this.setClaim(ObservationClaim.ValueQuantityUnit, normalized);
766
- }
767
- getValueQuantityUnit() {
768
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.ValueQuantityUnit));
769
- }
770
- setValueString(value) {
771
- return this.setClaim(ObservationClaim.ValueString, String(value).trim());
772
- }
773
- getValueString() {
774
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.ValueString));
775
- }
776
- setValueDate(value) {
777
- return this.setClaim(ObservationClaim.ValueDate, String(value).trim());
778
- }
779
- getValueDate() {
780
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.ValueDate));
781
- }
782
- }
783
- /**
784
- * Vital-sign-specific editor surface for one staged Observation entry.
785
- *
786
- * This layer applies the visible/searchable Vital Signs claim contract on top
787
- * of the reduced Observation component helpers.
788
- */
789
- export class VitalSignEntryEditor extends ObservationComponentEntryEditor {
790
- setIdentifier(identifier) {
791
- const normalized = normalizeOptionalIdentifier(identifier);
792
- if (!normalized) {
793
- this.removeClaim(ObservationClaim.Identifier);
794
- this.setResourceId(undefined);
795
- this.setFullUrl(undefined);
796
- return this;
797
- }
798
- this.setClaim(ObservationClaim.Identifier, normalized);
799
- this.setResourceId(normalized);
800
- this.setFullUrl(normalized);
801
- return this;
802
- }
803
- getIdentifier() {
804
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Identifier)
805
- || this.getResourceId()
806
- || this.getFullUrl());
807
- }
808
- ensureIdentifier() {
809
- const existing = this.getIdentifier();
810
- if (existing)
811
- return existing;
812
- const generated = createCanonicalIdentifierUrn();
813
- this.setIdentifier(generated);
814
- return generated;
815
- }
816
- setSubject(subject) {
817
- const normalized = String(subject).trim();
818
- this.setClaim(ObservationClaim.Subject, normalized);
819
- this.setClaim(ObservationClaim.Patient, normalized);
820
- return this;
821
- }
822
- getSubject() {
823
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Subject)
824
- || this.getClaim(ObservationClaim.Patient));
825
- }
826
- setStatus(status) {
827
- return this.setClaim(ObservationClaim.Status, String(status).trim());
828
- }
829
- getStatus() {
830
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Status));
831
- }
832
- setCategory(category) {
833
- const normalized = typeof category === 'string' ? category.trim() : category.claim;
834
- return this.setClaim(ObservationClaim.Category, normalized);
835
- }
836
- getCategory() {
837
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Category));
838
- }
839
- setDate(date) {
840
- const normalized = String(date).trim();
841
- this.setClaim(ObservationClaim.Date, normalized);
842
- this.setClaim(ObservationClaim.EffectiveDateTime, normalized);
843
- return this;
844
- }
845
- getDate() {
846
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Date)
847
- || this.getClaim(ObservationClaim.EffectiveDateTime));
848
- }
849
- setNote(note) {
850
- return this.setClaim(ObservationClaim.Note, String(note).trim());
851
- }
852
- getNote() {
853
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Note));
854
- }
855
- setVitalSignType(code, unit) {
856
- this.setCategory(ObservationCategoryCodes.VitalSigns);
857
- this.setStatus(this.getStatus() || 'final');
858
- this.setCode(code);
859
- this.setCodeSystem(code.system);
860
- this.setCodeValue(code.code);
861
- if (code.display) {
862
- this.setCodeDisplay(code.display);
863
- this.setCodeTextLocal(code.display);
864
- }
865
- if (unit) {
866
- this.setValueQuantityUnit(unit);
867
- }
868
- return this;
869
- }
870
- setHeartRate(value) {
871
- return this
872
- .setVitalSignType(VitalSignsCodes.HeartRate, VitalSignsUnits.BeatsPerMinute)
873
- .setValueQuantityNumber(value);
874
- }
875
- getHeartRate() {
876
- return this.getCodeValue() === VitalSignsCodes.HeartRate.code
877
- ? this.getValueQuantityNumber()
878
- : undefined;
879
- }
880
- setBodyTemperature(value) {
881
- return this
882
- .setVitalSignType(VitalSignsCodes.BodyTemperature, VitalSignsUnits.Celsius)
883
- .setValueQuantityNumber(value);
884
- }
885
- getBodyTemperature() {
886
- return this.getCodeValue() === VitalSignsCodes.BodyTemperature.code
887
- ? this.getValueQuantityNumber()
888
- : undefined;
889
- }
890
- setSystolicBloodPressure(value) {
891
- return this
892
- .setVitalSignType(VitalSignsCodes.SystolicBloodPressure, VitalSignsUnits.MillimeterOfMercury)
893
- .setValueQuantityNumber(value);
894
- }
895
- getSystolicBloodPressure() {
896
- return this.getCodeValue() === VitalSignsCodes.SystolicBloodPressure.code
897
- ? this.getValueQuantityNumber()
898
- : undefined;
899
- }
900
- setDiastolicBloodPressure(value) {
901
- return this
902
- .setVitalSignType(VitalSignsCodes.DiastolicBloodPressure, VitalSignsUnits.MillimeterOfMercury)
903
- .setValueQuantityNumber(value);
904
- }
905
- getDiastolicBloodPressure() {
906
- return this.getCodeValue() === VitalSignsCodes.DiastolicBloodPressure.code
907
- ? this.getValueQuantityNumber()
908
- : undefined;
909
- }
910
- }
911
- /**
912
- * General Observation editor surface.
913
- *
914
- * This extends the Vital Sign editor so generic Observation rows can reuse the
915
- * same code/date/value helpers while adding broader Observation references.
916
- */
917
- export class ObservationEntryEditor extends VitalSignEntryEditor {
918
- setBasedOn(reference) {
919
- return this.setClaim(ObservationClaim.BasedOn, String(reference).trim());
920
- }
921
- getBasedOn() {
922
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.BasedOn));
923
- }
924
- setEncounter(reference) {
925
- return this.setClaim(ObservationClaim.Encounter, String(reference).trim());
926
- }
927
- getEncounter() {
928
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Encounter));
929
- }
930
- setPerformer(reference) {
931
- return this.setClaim(ObservationClaim.Performer, String(reference).trim());
932
- }
933
- getPerformer() {
934
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Performer));
935
- }
936
- setHasMember(reference) {
937
- return this.setClaim(ObservationClaim.HasMember, String(reference).trim());
938
- }
939
- getHasMember() {
940
- return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.HasMember));
941
- }
942
- setHasMemberList(references) {
943
- const next = setClaimValues({}, ObservationClaim.HasMember, references);
944
- const normalized = normalizeOptionalIdentifier(next[ObservationClaim.HasMember]);
945
- if (!normalized) {
946
- this.removeClaim(ObservationClaim.HasMember);
947
- return this;
948
- }
949
- return this.setClaim(ObservationClaim.HasMember, normalized);
950
- }
951
- getHasMemberList() {
952
- return getClaimValues(this.getClaims(), ObservationClaim.HasMember);
953
- }
954
- }
955
- /** Claims-first editor for one staged AllergyIntolerance entry. */
956
- export class AllergyIntoleranceEntryEditor extends ClinicalResourceEntryEditor {
957
- setIdentifier(identifier) { return this.setIdentifierValue(AllergyIntoleranceClaim.Identifier, identifier); }
958
- getIdentifier() { return this.getIdentifierValue(AllergyIntoleranceClaim.Identifier); }
959
- ensureIdentifier() { return this.ensureIdentifierValue(AllergyIntoleranceClaim.Identifier); }
960
- setSubject(subject) { return this.setSubjectClaims(AllergyIntoleranceClaim.Subject, AllergyIntoleranceClaim.Patient, subject); }
961
- getSubject() { return this.getSubjectClaims(AllergyIntoleranceClaim.Subject, AllergyIntoleranceClaim.Patient); }
962
- setCode(code) { return this.setScalarClaim(AllergyIntoleranceClaim.Code, code); }
963
- getCode() { return this.getScalarClaim(AllergyIntoleranceClaim.Code); }
964
- setClinicalStatus(status) { return this.setScalarClaim(AllergyIntoleranceClaim.ClinicalStatus, status); }
965
- getClinicalStatus() { return this.getScalarClaim(AllergyIntoleranceClaim.ClinicalStatus); }
966
- setVerificationStatus(status) { return this.setScalarClaim(AllergyIntoleranceClaim.VerificationStatus, status); }
967
- getVerificationStatus() { return this.getScalarClaim(AllergyIntoleranceClaim.VerificationStatus); }
968
- setCategory(category) { return this.setScalarClaim(AllergyIntoleranceClaim.Category, category); }
969
- getCategory() { return this.getScalarClaim(AllergyIntoleranceClaim.Category); }
970
- setCriticality(criticality) { return this.setScalarClaim(AllergyIntoleranceClaim.Criticality, criticality); }
971
- getCriticality() { return this.getScalarClaim(AllergyIntoleranceClaim.Criticality); }
972
- setOnsetDateTime(value) { return this.setScalarClaim(AllergyIntoleranceClaim.OnsetDateTime, value); }
973
- getOnsetDateTime() { return this.getScalarClaim(AllergyIntoleranceClaim.OnsetDateTime); }
974
- setRecorder(reference) { return this.setScalarClaim(AllergyIntoleranceClaim.Recorder, reference); }
975
- getRecorder() { return this.getScalarClaim(AllergyIntoleranceClaim.Recorder); }
976
- setContainedDocumentIdentifierList(identifiers) { return this.setCsvClaimList(AllergyIntoleranceClaim.ContainedDocuments, identifiers); }
977
- getContainedDocumentIdentifierList() { return this.getCsvClaimList(AllergyIntoleranceClaim.ContainedDocuments); }
978
- }
979
- /** Claims-first editor for one staged Condition entry. */
980
- export class ConditionEntryEditor extends ClinicalResourceEntryEditor {
981
- setIdentifier(identifier) { return this.setIdentifierValue(ConditionClaim.Identifier, identifier); }
982
- getIdentifier() { return this.getIdentifierValue(ConditionClaim.Identifier); }
983
- ensureIdentifier() { return this.ensureIdentifierValue(ConditionClaim.Identifier); }
984
- setSubject(subject) { return this.setSubjectClaims(ConditionClaim.Subject, ConditionClaim.Subject, subject); }
985
- getSubject() { return this.getSubjectClaims(ConditionClaim.Subject, ConditionClaim.Subject); }
986
- setCode(code) { return this.setScalarClaim(ConditionClaim.Code, code); }
987
- getCode() { return this.getScalarClaim(ConditionClaim.Code); }
988
- setClinicalStatus(status) { return this.setScalarClaim(ConditionClaim.ClinicalStatus, status); }
989
- getClinicalStatus() { return this.getScalarClaim(ConditionClaim.ClinicalStatus); }
990
- setVerificationStatus(status) { return this.setScalarClaim(ConditionClaim.VerificationStatus, status); }
991
- getVerificationStatus() { return this.getScalarClaim(ConditionClaim.VerificationStatus); }
992
- setCategory(category) { return this.setScalarClaim(ConditionClaim.Category, category); }
993
- getCategory() { return this.getScalarClaim(ConditionClaim.Category); }
994
- setSeverity(severity) { return this.setScalarClaim(ConditionClaim.Severity, severity); }
995
- getSeverity() { return this.getScalarClaim(ConditionClaim.Severity); }
996
- setOnsetDateTime(value) { return this.setScalarClaim(ConditionClaim.OnsetDateTime, value); }
997
- getOnsetDateTime() { return this.getScalarClaim(ConditionClaim.OnsetDateTime); }
998
- setRecorder(reference) { return this.setScalarClaim(ConditionClaim.Recorder, reference); }
999
- getRecorder() { return this.getScalarClaim(ConditionClaim.Recorder); }
1000
- setContainedDocumentIdentifierList(identifiers) { return this.setCsvClaimList(ConditionClaim.ContainedDocuments, identifiers); }
1001
- getContainedDocumentIdentifierList() { return this.getCsvClaimList(ConditionClaim.ContainedDocuments); }
1002
- }
1003
- /** Claims-first editor for one staged MedicationStatement entry. */
1004
- export class MedicationStatementEntryEditor extends ClinicalResourceEntryEditor {
1005
- setIdentifier(identifier) { return this.setIdentifierValue(MedicationStatementClaim.Identifier, identifier); }
1006
- getIdentifier() { return this.getIdentifierValue(MedicationStatementClaim.Identifier); }
1007
- ensureIdentifier() { return this.ensureIdentifierValue(MedicationStatementClaim.Identifier); }
1008
- setSubject(subject) { return this.setSubjectClaims(MedicationStatementClaim.Subject, MedicationStatementClaim.Patient, subject); }
1009
- getSubject() { return this.getSubjectClaims(MedicationStatementClaim.Subject, MedicationStatementClaim.Patient); }
1010
- setStatus(status) { return this.setScalarClaim(MedicationStatementClaim.Status, status); }
1011
- getStatus() { return this.getScalarClaim(MedicationStatementClaim.Status); }
1012
- setEffective(value) { return this.setScalarClaim(MedicationStatementClaim.Effective, value); }
1013
- getEffective() { return this.getScalarClaim(MedicationStatementClaim.Effective); }
1014
- setCode(code) { return this.setScalarClaim(MedicationStatementClaim.Code, code); }
1015
- getCode() { return this.getScalarClaim(MedicationStatementClaim.Code); }
1016
- setMedicationText(text) { return this.setScalarClaim(MedicationStatementClaim.MedicationText, text); }
1017
- getMedicationText() { return this.getScalarClaim(MedicationStatementClaim.MedicationText); }
1018
- setNote(note) { return this.setScalarClaim(MedicationStatementClaim.Note, note); }
1019
- getNote() { return this.getScalarClaim(MedicationStatementClaim.Note); }
1020
- setDosageInstruction(value) { return this.setScalarClaim(MedicationStatementClaim.DosageInstruction, value); }
1021
- getDosageInstruction() { return this.getScalarClaim(MedicationStatementClaim.DosageInstruction); }
1022
- setCategoryList(values) { return this.setCsvClaimList(MedicationStatementClaim.Category, values); }
1023
- getCategoryList() { return this.getCsvClaimList(MedicationStatementClaim.Category); }
1024
- setDoseQuantityValue(value) { return this.setNumberClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityValue, value); }
1025
- getDoseQuantityValue() { return this.getNumberClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityValue); }
1026
- setDoseQuantityUnit(value) { return this.setScalarClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityUnit, value); }
1027
- getDoseQuantityUnit() { return this.getScalarClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityUnit); }
1028
- setTimingFrequency(value) { return this.setNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingFrequency, value); }
1029
- getTimingFrequency() { return this.getNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingFrequency); }
1030
- setTimingPeriod(value) { return this.setNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriod, value); }
1031
- getTimingPeriod() { return this.getNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriod); }
1032
- setTimingPeriodUnit(value) { return this.setScalarClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriodUnit, value); }
1033
- getTimingPeriodUnit() { return this.getScalarClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriodUnit); }
1034
- setDosageAsNeeded(value) { return this.setBooleanClaim(MedicationStatementClaimsFhirApiExtended.DosageAsNeeded, value); }
1035
- getDosageAsNeeded() { return this.getBooleanClaim(MedicationStatementClaimsFhirApiExtended.DosageAsNeeded); }
1036
- }
1037
- /** Claims-first editor for one staged DocumentReference entry. */
1038
- export class DocumentReferenceEntryEditor extends ClinicalResourceEntryEditor {
1039
- setIdentifier(identifier) { return this.setIdentifierValue(DocumentReferenceClaim.Identifier, identifier); }
1040
- getIdentifier() { return this.getIdentifierValue(DocumentReferenceClaim.Identifier); }
1041
- ensureIdentifier() { return this.ensureIdentifierValue(DocumentReferenceClaim.Identifier); }
1042
- setSubject(subject) { return this.setScalarClaim(DocumentReferenceClaim.Subject, subject); }
1043
- getSubject() { return this.getScalarClaim(DocumentReferenceClaim.Subject); }
1044
- setType(value) { return this.setScalarClaim(DocumentReferenceClaim.Type, value); }
1045
- getType() { return this.getScalarClaim(DocumentReferenceClaim.Type); }
1046
- setCategory(value) { return this.setScalarClaim(DocumentReferenceClaim.Category, value); }
1047
- getCategory() { return this.getScalarClaim(DocumentReferenceClaim.Category); }
1048
- setContentType(value) { return this.setScalarClaim(DocumentReferenceClaim.ContentType, value); }
1049
- getContentType() { return this.getScalarClaim(DocumentReferenceClaim.ContentType); }
1050
- setContentData(value) { return this.setScalarClaim(DocumentReferenceClaim.ContentData, value); }
1051
- getContentData() { return this.getScalarClaim(DocumentReferenceClaim.ContentData); }
1052
- setContentHash(value) { return this.setScalarClaim(DocumentReferenceClaim.ContentHash, value); }
1053
- getContentHash() { return this.getScalarClaim(DocumentReferenceClaim.ContentHash); }
1054
- setLocation(value) { return this.setScalarClaim(DocumentReferenceClaim.Location, value); }
1055
- getLocation() { return this.getScalarClaim(DocumentReferenceClaim.Location); }
1056
- setDescription(value) { return this.setScalarClaim(DocumentReferenceClaim.Description, value); }
1057
- getDescription() { return this.getScalarClaim(DocumentReferenceClaim.Description); }
1058
- setDate(value) { return this.setScalarClaim(DocumentReferenceClaim.Date, value); }
1059
- getDate() { return this.getScalarClaim(DocumentReferenceClaim.Date); }
1060
- setAuthor(value) { return this.setScalarClaim(DocumentReferenceClaim.Author, value); }
1061
- getAuthor() { return this.getScalarClaim(DocumentReferenceClaim.Author); }
1062
- }
1063
- /** Claims-first editor for one staged CarePlan entry. */
1064
- export class CarePlanEntryEditor extends ClinicalResourceEntryEditor {
1065
- setIdentifier(identifier) { return this.setIdentifierValue(CarePlanClaim.Identifier, identifier); }
1066
- getIdentifier() { return this.getIdentifierValue(CarePlanClaim.Identifier); }
1067
- ensureIdentifier() { return this.ensureIdentifierValue(CarePlanClaim.Identifier); }
1068
- setSubject(subject) { return this.setSubjectClaims(CarePlanClaim.Subject, CarePlanClaim.Patient, subject); }
1069
- getSubject() { return this.getSubjectClaims(CarePlanClaim.Subject, CarePlanClaim.Patient); }
1070
- setStatus(value) { return this.setScalarClaim(CarePlanClaim.Status, value); }
1071
- getStatus() { return this.getScalarClaim(CarePlanClaim.Status); }
1072
- setIntent(value) { return this.setScalarClaim(CarePlanClaim.Intent, value); }
1073
- getIntent() { return this.getScalarClaim(CarePlanClaim.Intent); }
1074
- setCategory(value) { return this.setScalarClaim(CarePlanClaim.Category, value); }
1075
- getCategory() { return this.getScalarClaim(CarePlanClaim.Category); }
1076
- setEncounter(value) { return this.setScalarClaim(CarePlanClaim.Encounter, value); }
1077
- getEncounter() { return this.getScalarClaim(CarePlanClaim.Encounter); }
1078
- setDate(value) { return this.setScalarClaim(CarePlanClaim.Date, value); }
1079
- getDate() { return this.getScalarClaim(CarePlanClaim.Date); }
1080
- setNote(value) { return this.setScalarClaim(CarePlanClaim.Note, value); }
1081
- getNote() { return this.getScalarClaim(CarePlanClaim.Note); }
1082
- }
1083
- /** Claims-first editor for one staged Flag entry. */
1084
- export class FlagEntryEditor extends ClinicalResourceEntryEditor {
1085
- setIdentifier(identifier) { return this.setIdentifierValue(FlagClaim.Identifier, identifier); }
1086
- getIdentifier() { return this.getIdentifierValue(FlagClaim.Identifier); }
1087
- ensureIdentifier() { return this.ensureIdentifierValue(FlagClaim.Identifier); }
1088
- setSubject(subject) { return this.setSubjectClaims(FlagClaim.Subject, FlagClaim.Patient, subject); }
1089
- getSubject() { return this.getSubjectClaims(FlagClaim.Subject, FlagClaim.Patient); }
1090
- setStatus(value) { return this.setScalarClaim(FlagClaim.Status, value); }
1091
- getStatus() { return this.getScalarClaim(FlagClaim.Status); }
1092
- setCategory(value) { return this.setScalarClaim(FlagClaim.Category, value); }
1093
- getCategory() { return this.getScalarClaim(FlagClaim.Category); }
1094
- setCode(value) { return this.setScalarClaim(FlagClaim.Code, value); }
1095
- getCode() { return this.getScalarClaim(FlagClaim.Code); }
1096
- setDate(value) { return this.setScalarClaim(FlagClaim.Date, value); }
1097
- getDate() { return this.getScalarClaim(FlagClaim.Date); }
1098
- setEncounter(value) { return this.setScalarClaim(FlagClaim.Encounter, value); }
1099
- getEncounter() { return this.getScalarClaim(FlagClaim.Encounter); }
1100
- setPeriodStart(value) { return this.setScalarClaim(FlagClaim.PeriodStart, value); }
1101
- getPeriodStart() { return this.getScalarClaim(FlagClaim.PeriodStart); }
1102
- setPeriodEnd(value) { return this.setScalarClaim(FlagClaim.PeriodEnd, value); }
1103
- getPeriodEnd() { return this.getScalarClaim(FlagClaim.PeriodEnd); }
1104
- }
1105
- /** Claims-first editor for one staged ClinicalImpression entry. */
1106
- export class ClinicalImpressionEntryEditor extends ClinicalResourceEntryEditor {
1107
- setIdentifier(identifier) { return this.setIdentifierValue(ClinicalImpressionClaim.Identifier, identifier); }
1108
- getIdentifier() { return this.getIdentifierValue(ClinicalImpressionClaim.Identifier); }
1109
- ensureIdentifier() { return this.ensureIdentifierValue(ClinicalImpressionClaim.Identifier); }
1110
- setSubject(subject) { return this.setSubjectClaims(ClinicalImpressionClaim.Subject, ClinicalImpressionClaim.Subject, subject); }
1111
- getSubject() { return this.getSubjectClaims(ClinicalImpressionClaim.Subject, ClinicalImpressionClaim.Subject); }
1112
- setStatus(value) { return this.setScalarClaim(ClinicalImpressionClaim.Status, value); }
1113
- getStatus() { return this.getScalarClaim(ClinicalImpressionClaim.Status); }
1114
- setDescription(value) { return this.setScalarClaim(ClinicalImpressionClaim.Description, value); }
1115
- getDescription() { return this.getScalarClaim(ClinicalImpressionClaim.Description); }
1116
- setEncounter(value) { return this.setScalarClaim(ClinicalImpressionClaim.Encounter, value); }
1117
- getEncounter() { return this.getScalarClaim(ClinicalImpressionClaim.Encounter); }
1118
- setEffectiveDateTime(value) { return this.setScalarClaim(ClinicalImpressionClaim.EffectiveDateTime, value); }
1119
- getEffectiveDateTime() { return this.getScalarClaim(ClinicalImpressionClaim.EffectiveDateTime); }
1120
- setAssessor(value) { return this.setScalarClaim(ClinicalImpressionClaim.Assessor, value); }
1121
- getAssessor() { return this.getScalarClaim(ClinicalImpressionClaim.Assessor); }
1122
- setSummary(value) { return this.setScalarClaim(ClinicalImpressionClaim.Summary, value); }
1123
- getSummary() { return this.getScalarClaim(ClinicalImpressionClaim.Summary); }
1124
- }
1125
- /** Claims-first editor for one staged Device entry. */
1126
- export class DeviceEntryEditor extends ClinicalResourceEntryEditor {
1127
- setIdentifier(identifier) { return this.setIdentifierValue(DeviceClaim.Identifier, identifier); }
1128
- getIdentifier() { return this.getIdentifierValue(DeviceClaim.Identifier); }
1129
- ensureIdentifier() { return this.ensureIdentifierValue(DeviceClaim.Identifier); }
1130
- setPatient(value) { return this.setScalarClaim(DeviceClaim.Patient, value); }
1131
- getPatient() { return this.getScalarClaim(DeviceClaim.Patient); }
1132
- setStatus(value) { return this.setScalarClaim(DeviceClaim.Status, value); }
1133
- getStatus() { return this.getScalarClaim(DeviceClaim.Status); }
1134
- setType(value) { return this.setScalarClaim(DeviceClaim.Type, value); }
1135
- getType() { return this.getScalarClaim(DeviceClaim.Type); }
1136
- setManufacturer(value) { return this.setScalarClaim(DeviceClaim.Manufacturer, value); }
1137
- getManufacturer() { return this.getScalarClaim(DeviceClaim.Manufacturer); }
1138
- setModel(value) { return this.setScalarClaim(DeviceClaim.Model, value); }
1139
- getModel() { return this.getScalarClaim(DeviceClaim.Model); }
1140
- setDeviceName(value) { return this.setScalarClaim(DeviceClaim.DeviceName, value); }
1141
- getDeviceName() { return this.getScalarClaim(DeviceClaim.DeviceName); }
1142
- setSerialNumber(value) { return this.setScalarClaim(DeviceClaim.SerialNumber, value); }
1143
- getSerialNumber() { return this.getScalarClaim(DeviceClaim.SerialNumber); }
1144
- setOrganization(value) { return this.setScalarClaim(DeviceClaim.Organization, value); }
1145
- getOrganization() { return this.getScalarClaim(DeviceClaim.Organization); }
1146
- setLocation(value) { return this.setScalarClaim(DeviceClaim.Location, value); }
1147
- getLocation() { return this.getScalarClaim(DeviceClaim.Location); }
1148
- setUrl(value) { return this.setScalarClaim(DeviceClaim.Url, value); }
1149
- getUrl() { return this.getScalarClaim(DeviceClaim.Url); }
1150
- setNote(value) { return this.setScalarClaim(DeviceClaim.Note, value); }
1151
- getNote() { return this.getScalarClaim(DeviceClaim.Note); }
1152
- }
1153
- /** Claims-first editor for one staged DeviceUseStatement entry. */
1154
- export class DeviceUseStatementEntryEditor extends ClinicalResourceEntryEditor {
1155
- setIdentifier(identifier) { return this.setIdentifierValue(DeviceUseStatementClaim.Identifier, identifier); }
1156
- getIdentifier() { return this.getIdentifierValue(DeviceUseStatementClaim.Identifier); }
1157
- ensureIdentifier() { return this.ensureIdentifierValue(DeviceUseStatementClaim.Identifier); }
1158
- setSubject(subject) { return this.setSubjectClaims(DeviceUseStatementClaim.Subject, DeviceUseStatementClaim.Subject, subject); }
1159
- getSubject() { return this.getSubjectClaims(DeviceUseStatementClaim.Subject, DeviceUseStatementClaim.Subject); }
1160
- setStatus(value) { return this.setScalarClaim(DeviceUseStatementClaim.Status, value); }
1161
- getStatus() { return this.getScalarClaim(DeviceUseStatementClaim.Status); }
1162
- setDevice(value) { return this.setScalarClaim(DeviceUseStatementClaim.Device, value); }
1163
- getDevice() { return this.getScalarClaim(DeviceUseStatementClaim.Device); }
1164
- setRecordedOn(value) { return this.setScalarClaim(DeviceUseStatementClaim.RecordedOn, value); }
1165
- getRecordedOn() { return this.getScalarClaim(DeviceUseStatementClaim.RecordedOn); }
1166
- setTimingDateTime(value) { return this.setScalarClaim(DeviceUseStatementClaim.TimingDateTime, value); }
1167
- getTimingDateTime() { return this.getScalarClaim(DeviceUseStatementClaim.TimingDateTime); }
1168
- setReasonCode(value) { return this.setScalarClaim(DeviceUseStatementClaim.ReasonCode, value); }
1169
- getReasonCode() { return this.getScalarClaim(DeviceUseStatementClaim.ReasonCode); }
1170
- setSource(value) { return this.setScalarClaim(DeviceUseStatementClaim.Source, value); }
1171
- getSource() { return this.getScalarClaim(DeviceUseStatementClaim.Source); }
1172
- }
1173
- /** Claims-first editor for one staged Encounter entry. */
1174
- export class EncounterEntryEditor extends ClinicalResourceEntryEditor {
1175
- setIdentifier(identifier) { return this.setIdentifierValue(EncounterClaim.Identifier, identifier); }
1176
- getIdentifier() { return this.getIdentifierValue(EncounterClaim.Identifier); }
1177
- ensureIdentifier() { return this.ensureIdentifierValue(EncounterClaim.Identifier); }
1178
- setSubject(subject) { return this.setSubjectClaims(EncounterClaim.Subject, EncounterClaim.Patient, subject); }
1179
- getSubject() { return this.getSubjectClaims(EncounterClaim.Subject, EncounterClaim.Patient); }
1180
- setStatus(value) { return this.setScalarClaim(EncounterClaim.Status, value); }
1181
- getStatus() { return this.getScalarClaim(EncounterClaim.Status); }
1182
- setClass(value) { return this.setScalarClaim(EncounterClaim.Class, value); }
1183
- getClass() { return this.getScalarClaim(EncounterClaim.Class); }
1184
- setType(value) { return this.setScalarClaim(EncounterClaim.Type, value); }
1185
- getType() { return this.getScalarClaim(EncounterClaim.Type); }
1186
- setParticipantList(values) { return this.setCsvClaimList(EncounterClaim.Participant, values); }
1187
- getParticipantList() { return this.getCsvClaimList(EncounterClaim.Participant); }
1188
- setServiceProvider(value) { return this.setScalarClaim(EncounterClaim.ServiceProvider, value); }
1189
- getServiceProvider() { return this.getScalarClaim(EncounterClaim.ServiceProvider); }
1190
- setPeriodStart(value) { return this.setScalarClaim(EncounterClaim.PeriodStart, value); }
1191
- getPeriodStart() { return this.getScalarClaim(EncounterClaim.PeriodStart); }
1192
- setPeriodEnd(value) { return this.setScalarClaim(EncounterClaim.PeriodEnd, value); }
1193
- getPeriodEnd() { return this.getScalarClaim(EncounterClaim.PeriodEnd); }
1194
- setReasonCode(value) { return this.setScalarClaim(EncounterClaim.ReasonCode, value); }
1195
- getReasonCode() { return this.getScalarClaim(EncounterClaim.ReasonCode); }
1196
- }
1197
- /** Claims-first editor for one staged Coverage entry. */
1198
- export class CoverageEntryEditor extends ClinicalResourceEntryEditor {
1199
- setIdentifier(identifier) { return this.setIdentifierValue(CoverageClaim.Identifier, identifier); }
1200
- getIdentifier() { return this.getIdentifierValue(CoverageClaim.Identifier); }
1201
- ensureIdentifier() { return this.ensureIdentifierValue(CoverageClaim.Identifier); }
1202
- setStatus(value) { return this.setScalarClaim(CoverageClaim.Status, value); }
1203
- getStatus() { return this.getScalarClaim(CoverageClaim.Status); }
1204
- setType(value) { return this.setScalarClaim(CoverageClaim.Type, value); }
1205
- getType() { return this.getScalarClaim(CoverageClaim.Type); }
1206
- setPolicyHolder(value) { return this.setScalarClaim(CoverageClaim.PolicyHolder, value); }
1207
- getPolicyHolder() { return this.getScalarClaim(CoverageClaim.PolicyHolder); }
1208
- setSubscriber(value) { return this.setScalarClaim(CoverageClaim.Subscriber, value); }
1209
- getSubscriber() { return this.getScalarClaim(CoverageClaim.Subscriber); }
1210
- setBeneficiary(value) { return this.setScalarClaim(CoverageClaim.Beneficiary, value); }
1211
- getBeneficiary() { return this.getScalarClaim(CoverageClaim.Beneficiary); }
1212
- setRelationship(value) { return this.setScalarClaim(CoverageClaim.Relationship, value); }
1213
- getRelationship() { return this.getScalarClaim(CoverageClaim.Relationship); }
1214
- setPeriodStart(value) { return this.setScalarClaim(CoverageClaim.PeriodStart, value); }
1215
- getPeriodStart() { return this.getScalarClaim(CoverageClaim.PeriodStart); }
1216
- setPeriodEnd(value) { return this.setScalarClaim(CoverageClaim.PeriodEnd, value); }
1217
- getPeriodEnd() { return this.getScalarClaim(CoverageClaim.PeriodEnd); }
1218
- setPayorList(values) { return this.setCsvClaimList(CoverageClaim.Payor, values); }
1219
- getPayorList() { return this.getCsvClaimList(CoverageClaim.Payor); }
1220
- }
1221
- /** Claims-first editor for one staged Immunization entry. */
1222
- export class ImmunizationEntryEditor extends ClinicalResourceEntryEditor {
1223
- setIdentifier(identifier) {
1224
- return this.setIdentifierValue(ImmunizationClaim.Identifier, identifier);
1225
- }
1226
- getIdentifier() {
1227
- return this.getIdentifierValue(ImmunizationClaim.Identifier);
1228
- }
1229
- ensureIdentifier() {
1230
- return this.ensureIdentifierValue(ImmunizationClaim.Identifier);
1231
- }
1232
- setSubject(subject) {
1233
- return this.setSubjectClaims(ImmunizationClaim.Subject, ImmunizationClaim.Patient, subject);
1234
- }
1235
- getSubject() {
1236
- return this.getSubjectClaims(ImmunizationClaim.Subject, ImmunizationClaim.Patient);
1237
- }
1238
- setStatus(status) {
1239
- return this.setScalarClaim(ImmunizationClaim.Status, status);
1240
- }
1241
- getStatus() {
1242
- return this.getScalarClaim(ImmunizationClaim.Status);
1243
- }
1244
- setDate(date) {
1245
- return this.setScalarClaim(ImmunizationClaim.Date, date);
1246
- }
1247
- getDate() {
1248
- return this.getScalarClaim(ImmunizationClaim.Date);
1249
- }
1250
- setVaccineCode(code) {
1251
- return this.setScalarClaim(ImmunizationClaim.VaccineCode, code);
1252
- }
1253
- getVaccineCode() {
1254
- return this.getScalarClaim(ImmunizationClaim.VaccineCode);
1255
- }
1256
- setVaccineCodeTextLocal(text) {
1257
- return this.setScalarClaim(ImmunizationClaim.VaccineCodeText, text);
1258
- }
1259
- getVaccineCodeTextLocal() {
1260
- return this.getScalarClaim(ImmunizationClaim.VaccineCodeText);
1261
- }
1262
- setVaccineCodeDisplay(display) {
1263
- return this.setScalarClaim(ImmunizationClaim.VaccineCodeDisplay, display);
1264
- }
1265
- getVaccineCodeDisplay() {
1266
- return this.getScalarClaim(ImmunizationClaim.VaccineCodeDisplay);
1267
- }
1268
- setLocation(reference) {
1269
- return this.setScalarClaim(ImmunizationClaim.Location, reference);
1270
- }
1271
- getLocation() {
1272
- return this.getScalarClaim(ImmunizationClaim.Location);
1273
- }
1274
- setManufacturer(reference) {
1275
- return this.setScalarClaim(ImmunizationClaim.Manufacturer, reference);
1276
- }
1277
- getManufacturer() {
1278
- return this.getScalarClaim(ImmunizationClaim.Manufacturer);
1279
- }
1280
- setLotNumber(lotNumber) {
1281
- return this.setScalarClaim(ImmunizationClaim.LotNumber, lotNumber);
1282
- }
1283
- getLotNumber() {
1284
- return this.getScalarClaim(ImmunizationClaim.LotNumber);
1285
- }
1286
- setPerformerList(references) {
1287
- return this.setCsvClaimList(ImmunizationClaim.Performer, references);
1288
- }
1289
- getPerformerList() {
1290
- return this.getCsvClaimList(ImmunizationClaim.Performer);
1291
- }
1292
- setReasonCode(code) {
1293
- return this.setScalarClaim(ImmunizationClaim.ReasonCode, code);
1294
- }
1295
- getReasonCode() {
1296
- return this.getScalarClaim(ImmunizationClaim.ReasonCode);
1297
- }
1298
- setStatusReason(reason) {
1299
- return this.setScalarClaim(ImmunizationClaim.StatusReason, reason);
1300
- }
1301
- getStatusReason() {
1302
- return this.getScalarClaim(ImmunizationClaim.StatusReason);
1303
- }
1304
- setTargetDisease(code) {
1305
- return this.setScalarClaim(ImmunizationClaim.TargetDisease, code);
1306
- }
1307
- getTargetDisease() {
1308
- return this.getScalarClaim(ImmunizationClaim.TargetDisease);
1309
- }
1310
- setDoseSequence(sequence) {
1311
- return this.setScalarClaim(ImmunizationClaim.DoseSequence, sequence);
1312
- }
1313
- getDoseSequence() {
1314
- return this.getScalarClaim(ImmunizationClaim.DoseSequence);
1315
- }
1316
- setSeries(series) {
1317
- return this.setScalarClaim(ImmunizationClaim.Series, series);
1318
- }
1319
- getSeries() {
1320
- return this.getScalarClaim(ImmunizationClaim.Series);
1321
- }
1322
- setReactionDate(date) {
1323
- return this.setScalarClaim(ImmunizationClaim.ReactionDate, date);
1324
- }
1325
- getReactionDate() {
1326
- return this.getScalarClaim(ImmunizationClaim.ReactionDate);
1327
- }
1328
- setNote(note) {
1329
- return this.setScalarClaim(ImmunizationClaim.Note, note);
1330
- }
1331
- getNote() {
1332
- return this.getScalarClaim(ImmunizationClaim.Note);
1333
- }
1334
- setClinicalNote(note) {
1335
- return this.setNote(note);
1336
- }
1337
- getClinicalNote() {
1338
- return this.getNote();
1339
- }
1340
- }
1341
- /** Claims-first editor for one staged Procedure entry. */
1342
- export class ProcedureEntryEditor extends ClinicalResourceEntryEditor {
1343
- setIdentifier(identifier) {
1344
- return this.setIdentifierValue(ProcedureClaim.Identifier, identifier);
1345
- }
1346
- getIdentifier() {
1347
- return this.getIdentifierValue(ProcedureClaim.Identifier);
1348
- }
1349
- ensureIdentifier() {
1350
- return this.ensureIdentifierValue(ProcedureClaim.Identifier);
1351
- }
1352
- setSubject(subject) {
1353
- return this.setSubjectClaims(ProcedureClaim.Subject, ProcedureClaim.Patient, subject);
1354
- }
1355
- getSubject() {
1356
- return this.getSubjectClaims(ProcedureClaim.Subject, ProcedureClaim.Patient);
1357
- }
1358
- setStatus(status) {
1359
- return this.setScalarClaim(ProcedureClaim.Status, status);
1360
- }
1361
- getStatus() {
1362
- return this.getScalarClaim(ProcedureClaim.Status);
1363
- }
1364
- setDate(date) {
1365
- return this.setScalarClaim(ProcedureClaim.Date, date);
1366
- }
1367
- getDate() {
1368
- return this.getScalarClaim(ProcedureClaim.Date);
1369
- }
1370
- setCode(code) {
1371
- return this.setScalarClaim(ProcedureClaim.Code, code);
1372
- }
1373
- getCode() {
1374
- return this.getScalarClaim(ProcedureClaim.Code);
1375
- }
1376
- setCodeTextLocal(text) {
1377
- return this.setScalarClaim(ProcedureClaim.CodeText, text);
1378
- }
1379
- getCodeTextLocal() {
1380
- return this.getScalarClaim(ProcedureClaim.CodeText);
1381
- }
1382
- setCodeDisplay(display) {
1383
- return this.setScalarClaim(ProcedureClaim.CodeDisplay, display);
1384
- }
1385
- getCodeDisplay() {
1386
- return this.getScalarClaim(ProcedureClaim.CodeDisplay);
1387
- }
1388
- setEncounter(reference) {
1389
- return this.setScalarClaim(ProcedureClaim.Encounter, reference);
1390
- }
1391
- getEncounter() {
1392
- return this.getScalarClaim(ProcedureClaim.Encounter);
1393
- }
1394
- setLocation(reference) {
1395
- return this.setScalarClaim(ProcedureClaim.Location, reference);
1396
- }
1397
- getLocation() {
1398
- return this.getScalarClaim(ProcedureClaim.Location);
1399
- }
1400
- setReasonCode(code) {
1401
- return this.setScalarClaim(ProcedureClaim.ReasonCode, code);
1402
- }
1403
- getReasonCode() {
1404
- return this.getScalarClaim(ProcedureClaim.ReasonCode);
1405
- }
1406
- setNote(note) {
1407
- return this.setScalarClaim(ProcedureClaim.Note, note);
1408
- }
1409
- getNote() {
1410
- return this.getScalarClaim(ProcedureClaim.Note);
1411
- }
1412
- setClinicalNote(note) {
1413
- return this.setNote(note);
1414
- }
1415
- getClinicalNote() {
1416
- return this.getNote();
1417
- }
1418
- setPerformerList(references) {
1419
- return this.setCsvClaimList(ProcedureClaim.Performer, references);
1420
- }
1421
- getPerformerList() {
1422
- return this.getCsvClaimList(ProcedureClaim.Performer);
1423
- }
1424
- setBasedOnList(references) {
1425
- return this.setCsvClaimList(ProcedureClaim.BasedOn, references);
1426
- }
1427
- getBasedOnList() {
1428
- return this.getCsvClaimList(ProcedureClaim.BasedOn);
1429
- }
1430
- setReasonReferenceList(references) {
1431
- return this.setCsvClaimList(ProcedureClaim.ReasonReference, references);
1432
- }
1433
- getReasonReferenceList() {
1434
- return this.getCsvClaimList(ProcedureClaim.ReasonReference);
1435
- }
1436
- }
1437
- /** Claims-first editor for one staged DiagnosticReport entry. */
1438
- export class DiagnosticReportEntryEditor extends ClinicalResourceEntryEditor {
1439
- setIdentifier(identifier) {
1440
- return this.setIdentifierValue(DiagnosticReportClaim.Identifier, identifier);
1441
- }
1442
- getIdentifier() {
1443
- return this.getIdentifierValue(DiagnosticReportClaim.Identifier);
1444
- }
1445
- ensureIdentifier() {
1446
- return this.ensureIdentifierValue(DiagnosticReportClaim.Identifier);
1447
- }
1448
- setSubject(subject) {
1449
- return this.setSubjectClaims(DiagnosticReportClaim.Subject, DiagnosticReportClaim.Patient, subject);
1450
- }
1451
- getSubject() {
1452
- return this.getSubjectClaims(DiagnosticReportClaim.Subject, DiagnosticReportClaim.Patient);
1453
- }
1454
- setStatus(status) {
1455
- return this.setScalarClaim(DiagnosticReportClaim.Status, status);
1456
- }
1457
- getStatus() {
1458
- return this.getScalarClaim(DiagnosticReportClaim.Status);
1459
- }
1460
- setDate(date) {
1461
- return this.setScalarClaim(DiagnosticReportClaim.Date, date);
1462
- }
1463
- getDate() {
1464
- return this.getScalarClaim(DiagnosticReportClaim.Date);
1465
- }
1466
- setCategory(category) {
1467
- return this.setScalarClaim(DiagnosticReportClaim.Category, category);
1468
- }
1469
- getCategory() {
1470
- return this.getScalarClaim(DiagnosticReportClaim.Category);
1471
- }
1472
- setCode(code) {
1473
- return this.setScalarClaim(DiagnosticReportClaim.Code, code);
1474
- }
1475
- getCode() {
1476
- return this.getScalarClaim(DiagnosticReportClaim.Code);
1477
- }
1478
- setEncounter(reference) {
1479
- return this.setScalarClaim(DiagnosticReportClaim.Encounter, reference);
1480
- }
1481
- getEncounter() {
1482
- return this.getScalarClaim(DiagnosticReportClaim.Encounter);
1483
- }
1484
- setPerformerList(references) {
1485
- return this.setCsvClaimList(DiagnosticReportClaim.Performer, references);
1486
- }
1487
- getPerformerList() {
1488
- return this.getCsvClaimList(DiagnosticReportClaim.Performer);
1489
- }
1490
- setResultList(references) {
1491
- return this.setCsvClaimList(DiagnosticReportClaim.Result, references);
1492
- }
1493
- getResultList() {
1494
- return this.getCsvClaimList(DiagnosticReportClaim.Result);
1495
- }
1496
- setSpecimenList(references) {
1497
- return this.setCsvClaimList(DiagnosticReportClaim.Specimen, references);
1498
- }
1499
- getSpecimenList() {
1500
- return this.getCsvClaimList(DiagnosticReportClaim.Specimen);
1501
- }
1502
- setContainedDocumentIdentifierList(identifiers) {
1503
- return this.setCsvClaimList(DiagnosticReportClaim.ContainedDocuments, identifiers);
1504
- }
1505
- getContainedDocumentIdentifierList() {
1506
- return this.getCsvClaimList(DiagnosticReportClaim.ContainedDocuments);
1507
- }
1508
- setPresentedFormContentType(contentType) {
1509
- return this.setScalarClaim(DiagnosticReportClaim.PresentedFormContentType, contentType);
1510
- }
1511
- getPresentedFormContentType() {
1512
- return this.getScalarClaim(DiagnosticReportClaim.PresentedFormContentType);
1513
- }
1514
- setPresentedFormData(data) {
1515
- return this.setScalarClaim(DiagnosticReportClaim.PresentedFormData, data);
1516
- }
1517
- getPresentedFormData() {
1518
- return this.getScalarClaim(DiagnosticReportClaim.PresentedFormData);
1519
- }
1520
- setPresentedFormUrl(url) {
1521
- return this.setScalarClaim(DiagnosticReportClaim.PresentedFormUrl, url);
1522
- }
1523
- getPresentedFormUrl() {
1524
- return this.getScalarClaim(DiagnosticReportClaim.PresentedFormUrl);
1525
- }
1526
- }
1527
- /**
1528
- * Employee-specific editor for one staged bundle entry.
1529
- *
1530
- * Use this class after `bundle.newEntry().asEmployee()` or
1531
- * `bundle.openEntry(...).asEmployee()`.
1532
- */
1533
- export class EmployeeEntryEditor extends BundleEntryEditor {
1534
- /**
1535
- * Writes the canonical employee identifier.
1536
- *
1537
- * The identifier is synchronized across:
1538
- * - `entry.fullUrl`
1539
- * - `resource.id`
1540
- * - `org.schema.Person.identifier`
1541
- */
1542
- setIdentifier(identifier) {
1543
- const normalized = normalizeOptionalIdentifier(identifier);
1544
- if (!normalized) {
1545
- this.removeClaim(ClaimsPersonSchemaorg.identifier);
1546
- this.setResourceId(undefined);
1547
- this.setFullUrl(undefined);
1548
- return this;
1549
- }
1550
- this.setClaim(ClaimsPersonSchemaorg.identifier, normalized);
1551
- this.setResourceId(normalized);
1552
- this.setFullUrl(normalized);
1553
- return this;
1554
- }
1555
- /** Reads the canonical employee identifier from claims, resource id, or fullUrl. */
1556
- getIdentifier() {
1557
- return normalizeOptionalIdentifier(this.getClaim(ClaimsPersonSchemaorg.identifier)
1558
- || this.getResourceId()
1559
- || this.getFullUrl());
1560
- }
1561
- /** Ensures the employee entry carries one canonical `urn:uuid:*` identifier. */
1562
- ensureIdentifier() {
1563
- const existing = this.getIdentifier();
1564
- if (existing) {
1565
- return existing;
1566
- }
1567
- const generated = createCanonicalIdentifierUrn();
1568
- this.setIdentifier(generated);
1569
- return generated;
1570
- }
1571
- /** Writes the canonical employee email claim on this entry. */
1572
- setEmail(email) {
1573
- return this.setClaim(ClaimsPersonSchemaorg.email, String(email).trim());
1574
- }
1575
- /** Reads the canonical employee email claim from this entry. */
1576
- getEmail() {
1577
- const email = this.getClaim(ClaimsPersonSchemaorg.email);
1578
- return typeof email === 'string' && email.trim() ? email.trim() : undefined;
1579
- }
1580
- /** Writes the canonical employee occupational role claim on this entry. */
1581
- setRole(role) {
1582
- return this.setClaim(ClaimsPersonSchemaorg.hasOccupationalRoleValue, String(role).trim());
1583
- }
1584
- /** Reads the canonical employee occupational role claim from this entry. */
1585
- getRole() {
1586
- const role = this.getClaim(ClaimsPersonSchemaorg.hasOccupationalRoleValue);
1587
- return typeof role === 'string' && role.trim() ? role.trim() : undefined;
1588
- }
1589
- /** Writes the canonical employee `worksFor` claim on this entry. */
1590
- setWorksFor(worksFor) {
1591
- return this.setClaim(ClaimsPersonSchemaorg.worksFor, String(worksFor).trim());
1592
- }
1593
- /** Writes the canonical employee `memberOf` claim on this entry. */
1594
- setMemberOf(memberOf) {
1595
- return this.setClaim(ClaimsPersonSchemaorg.memberOf, String(memberOf).trim());
1596
- }
1597
- /** Writes the canonical employee organization tax id claim on this entry. */
1598
- setMemberOfOrgTaxId(taxId) {
1599
- return this.setClaim(ClaimsPersonSchemaorg.memberOfOrgTaxId, String(taxId).trim());
1600
- }
1601
- }
1
+ export * from '../models/bundle-editor-types.js';
2
+ export * from './bundle-editor-core.js';
3
+ export * from './bundle-entry-editor.js';
4
+ export * from './observation-component-entry-editor.js';
5
+ export * from './vital-sign-entry-editor.js';
6
+ export * from './observation-entry-editor.js';
7
+ export * from './allergy-intolerance-entry-editor.js';
8
+ export * from './condition-entry-editor.js';
9
+ export * from './medication-statement-entry-editor.js';
10
+ export * from './document-reference-entry-editor.js';
11
+ export * from './care-plan-entry-editor.js';
12
+ export * from './flag-entry-editor.js';
13
+ export * from './clinical-impression-entry-editor.js';
14
+ export * from './device-entry-editor.js';
15
+ export * from './device-use-statement-entry-editor.js';
16
+ export * from './encounter-entry-editor.js';
17
+ export * from './coverage-entry-editor.js';
18
+ export * from './immunization-entry-editor.js';
19
+ export * from './procedure-entry-editor.js';
20
+ export * from './diagnostic-report-entry-editor.js';
21
+ export * from './employee-entry-editor.js';