gdc-common-utils-ts 2.1.0 → 2.3.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/README.md +22 -2
- package/dist/claims/claims-helpers-allergy-intolerance.d.ts +8 -0
- package/dist/claims/claims-helpers-allergy-intolerance.js +30 -12
- package/dist/claims/claims-helpers-condition.d.ts +8 -0
- package/dist/claims/claims-helpers-condition.js +30 -12
- package/dist/claims/claims-helpers-consent.d.ts +4 -0
- package/dist/claims/claims-helpers-consent.js +15 -1
- package/dist/claims/claims-helpers-diagnostic-report.d.ts +4 -0
- package/dist/claims/claims-helpers-diagnostic-report.js +17 -2
- package/dist/claims/claims-helpers-medication-statement.d.ts +10 -2
- package/dist/claims/claims-helpers-medication-statement.js +32 -14
- package/dist/constants/data-collections.js +0 -1
- package/dist/constants/didcomm.d.ts +22 -0
- package/dist/constants/didcomm.js +22 -0
- package/dist/constants/fhir-resource-types.d.ts +16 -0
- package/dist/constants/fhir-resource-types.js +7 -0
- package/dist/constants/healthcare.d.ts +348 -193
- package/dist/constants/healthcare.js +99 -37
- package/dist/constants/hl7-roles.d.ts +38 -4
- package/dist/constants/hl7-roles.js +92 -4
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/lifecycle.d.ts +2 -0
- package/dist/constants/lifecycle.js +2 -0
- package/dist/constants/verifiable-credentials.d.ts +9 -0
- package/dist/constants/verifiable-credentials.js +9 -0
- package/dist/examples/bundle-didcomm-payload.js +4 -2
- package/dist/examples/communication-attached-bundle-session.js +27 -27
- package/dist/examples/communication-didcomm-payload.d.ts +8 -4
- package/dist/examples/communication-didcomm-payload.js +17 -11
- package/dist/examples/consent-access.js +2 -1
- package/dist/examples/employee.d.ts +21 -0
- package/dist/examples/employee.js +21 -0
- package/dist/examples/individual-controller.d.ts +27 -0
- package/dist/examples/individual-controller.js +28 -1
- package/dist/examples/inter-tenant-access-contract.js +3 -2
- package/dist/examples/ips-bundle.js +17 -16
- package/dist/examples/lifecycle.js +13 -11
- package/dist/examples/profile-manager-mem.js +2 -1
- package/dist/examples/related-person.d.ts +14 -0
- package/dist/examples/related-person.js +18 -4
- package/dist/examples/shared.d.ts +12 -3
- package/dist/examples/shared.js +13 -4
- package/dist/examples/vital-signs.js +1 -1
- package/dist/examples/wallet-mem.js +4 -2
- package/dist/i18n/role-codes.i18n.d.ts +9 -1
- package/dist/i18n/role-codes.i18n.js +12 -1
- package/dist/models/authority-resolution.d.ts +56 -0
- package/dist/models/authority-resolution.js +2 -0
- package/dist/models/bundle-editor-types.d.ts +89 -0
- package/dist/models/bundle-editor-types.js +45 -0
- package/dist/models/bundle.d.ts +5 -0
- package/dist/models/communication-attached-bundle-session.d.ts +6 -4
- package/dist/models/communication-attached-bundle-session.js +6 -4
- package/dist/models/confidential-storage.d.ts +2 -1
- package/dist/models/consent-rule.d.ts +11 -1
- package/dist/models/consent-rule.js +9 -1
- package/dist/models/device-license.d.ts +20 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +2 -0
- package/dist/models/individual-onboarding.d.ts +18 -0
- package/dist/models/interoperable-claims/allergy-intolerance-claims.d.ts +12 -1
- package/dist/models/interoperable-claims/allergy-intolerance-claims.js +12 -1
- package/dist/models/interoperable-claims/condition-claims.d.ts +12 -1
- package/dist/models/interoperable-claims/condition-claims.js +12 -1
- package/dist/models/interoperable-claims/diagnostic-report-claims.d.ts +13 -2
- package/dist/models/interoperable-claims/diagnostic-report-claims.js +12 -1
- package/dist/models/interoperable-claims/document-reference-claims.d.ts +1 -0
- package/dist/models/interoperable-claims/document-reference-claims.js +3 -0
- package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
- package/dist/models/interoperable-claims/medication-statement-claims.js +17 -0
- package/dist/models/interoperable-claims/related-person-claims.d.ts +13 -0
- package/dist/models/interoperable-claims/related-person-claims.js +16 -0
- package/dist/utils/allergy-intolerance-entry-editor.d.ts +51 -0
- package/dist/utils/allergy-intolerance-entry-editor.js +55 -0
- package/dist/utils/authority-resolution.d.ts +37 -0
- package/dist/utils/authority-resolution.js +112 -0
- package/dist/utils/backend-message-manager-mem.d.ts +11 -0
- package/dist/utils/backend-message-manager-mem.js +11 -0
- package/dist/utils/bundle-didcomm-payload.js +3 -2
- package/dist/utils/bundle-document-builder.d.ts +36 -0
- package/dist/utils/bundle-document-builder.js +310 -14
- package/dist/utils/bundle-editor-core.d.ts +181 -0
- package/dist/utils/bundle-editor-core.js +467 -0
- package/dist/utils/bundle-editor-helpers.d.ts +53 -0
- package/dist/utils/bundle-editor-helpers.js +146 -0
- package/dist/utils/bundle-editor-registry.d.ts +6 -0
- package/dist/utils/bundle-editor-registry.js +14 -0
- package/dist/utils/bundle-editor.d.ts +21 -722
- package/dist/utils/bundle-editor.js +21 -1601
- package/dist/utils/bundle-entry-editor.d.ts +96 -0
- package/dist/utils/bundle-entry-editor.js +305 -0
- package/dist/utils/bundle-query.d.ts +1 -0
- package/dist/utils/bundle-query.js +12 -3
- package/dist/utils/bundle-reader.d.ts +48 -0
- package/dist/utils/bundle-reader.js +175 -1
- package/dist/utils/care-plan-entry-editor.d.ts +43 -0
- package/dist/utils/care-plan-entry-editor.js +47 -0
- package/dist/utils/client-assertion.d.ts +38 -0
- package/dist/utils/client-assertion.js +113 -0
- package/dist/utils/clinical-impression-entry-editor.d.ts +43 -0
- package/dist/utils/clinical-impression-entry-editor.js +47 -0
- package/dist/utils/clinical-resource-entry-editor.d.ts +123 -0
- package/dist/utils/clinical-resource-entry-editor.js +296 -0
- package/dist/utils/clinical-resource-view.d.ts +16 -0
- package/dist/utils/clinical-resource-view.js +267 -33
- package/dist/utils/communication-attached-bundle-session-helpers.js +8 -6
- package/dist/utils/communication-attached-bundle-session.d.ts +29 -3
- package/dist/utils/communication-attached-bundle-session.js +62 -3
- package/dist/utils/communication-consent-access-editor.d.ts +8 -4
- package/dist/utils/communication-consent-access-editor.js +8 -4
- package/dist/utils/communication-didcomm-payload.d.ts +5 -0
- package/dist/utils/communication-didcomm-payload.js +28 -18
- package/dist/utils/communication-document-reference.d.ts +23 -0
- package/dist/utils/communication-document-reference.js +89 -0
- package/dist/utils/communication-editor.d.ts +53 -0
- package/dist/utils/communication-editor.js +97 -0
- package/dist/utils/condition-entry-editor.d.ts +30 -0
- package/dist/utils/condition-entry-editor.js +34 -0
- package/dist/utils/consent-claim-helpers.d.ts +4 -0
- package/dist/utils/consent-claim-helpers.js +15 -1
- package/dist/utils/consent-duplicate-rules.js +1 -1
- package/dist/utils/coverage-entry-editor.d.ts +51 -0
- package/dist/utils/coverage-entry-editor.js +55 -0
- package/dist/utils/device-entry-editor.d.ts +59 -0
- package/dist/utils/device-entry-editor.js +63 -0
- package/dist/utils/device-use-statement-entry-editor.d.ts +43 -0
- package/dist/utils/device-use-statement-entry-editor.js +47 -0
- package/dist/utils/diagnostic-report-entry-editor.d.ts +74 -0
- package/dist/utils/diagnostic-report-entry-editor.js +136 -0
- package/dist/utils/did.d.ts +8 -0
- package/dist/utils/did.js +22 -0
- package/dist/utils/document-reference-entry-editor.d.ts +62 -0
- package/dist/utils/document-reference-entry-editor.js +66 -0
- package/dist/utils/employee-entry-editor.d.ts +36 -0
- package/dist/utils/employee-entry-editor.js +88 -0
- package/dist/utils/employee.d.ts +1 -0
- package/dist/utils/employee.js +2 -1
- package/dist/utils/encounter-entry-editor.d.ts +51 -0
- package/dist/utils/encounter-entry-editor.js +55 -0
- package/dist/utils/flag-entry-editor.d.ts +47 -0
- package/dist/utils/flag-entry-editor.js +51 -0
- package/dist/utils/immunization-entry-editor.d.ts +87 -0
- package/dist/utils/immunization-entry-editor.js +169 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/individual-onboarding-acceptance-credential.d.ts +35 -0
- package/dist/utils/individual-onboarding-acceptance-credential.js +55 -0
- package/dist/utils/individual-smart.d.ts +59 -0
- package/dist/utils/individual-smart.js +135 -0
- package/dist/utils/license-list-search.d.ts +5 -0
- package/dist/utils/license-list-search.js +9 -0
- package/dist/utils/license.d.ts +45 -1
- package/dist/utils/license.js +86 -2
- package/dist/utils/medication-statement-entry-editor.d.ts +90 -0
- package/dist/utils/medication-statement-entry-editor.js +94 -0
- package/dist/utils/observation-component-entry-editor.d.ts +57 -0
- package/dist/utils/observation-component-entry-editor.js +105 -0
- package/dist/utils/observation-entry-editor.d.ts +29 -0
- package/dist/utils/observation-entry-editor.js +68 -0
- package/dist/utils/procedure-entry-editor.d.ts +71 -0
- package/dist/utils/procedure-entry-editor.js +75 -0
- package/dist/utils/professional-smart.d.ts +87 -0
- package/dist/utils/professional-smart.js +118 -4
- package/dist/utils/related-person-list.d.ts +4 -0
- package/dist/utils/related-person-list.js +26 -6
- package/dist/utils/same-as.d.ts +40 -0
- package/dist/utils/same-as.js +72 -0
- package/dist/utils/unified-health-id.d.ts +51 -0
- package/dist/utils/unified-health-id.js +92 -0
- package/dist/utils/vital-sign-day-batch.d.ts +25 -0
- package/dist/utils/vital-sign-day-batch.js +115 -0
- package/dist/utils/vital-sign-entry-editor.d.ts +61 -0
- package/dist/utils/vital-sign-entry-editor.js +152 -0
- package/package.json +2 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { BundleEditor } from './bundle-editor-core';
|
|
2
|
+
import { AllowedResourceType, type BuiltBundleEntry, type ResourceTypeEntryEditor } from '../models/bundle-editor-types';
|
|
3
|
+
import type { AllergyIntoleranceEntryEditor } from './allergy-intolerance-entry-editor';
|
|
4
|
+
import type { CarePlanEntryEditor } from './care-plan-entry-editor';
|
|
5
|
+
import type { ClinicalImpressionEntryEditor } from './clinical-impression-entry-editor';
|
|
6
|
+
import type { ConditionEntryEditor } from './condition-entry-editor';
|
|
7
|
+
import type { CoverageEntryEditor } from './coverage-entry-editor';
|
|
8
|
+
import type { DeviceEntryEditor } from './device-entry-editor';
|
|
9
|
+
import type { DeviceUseStatementEntryEditor } from './device-use-statement-entry-editor';
|
|
10
|
+
import type { DiagnosticReportEntryEditor } from './diagnostic-report-entry-editor';
|
|
11
|
+
import type { DocumentReferenceEntryEditor } from './document-reference-entry-editor';
|
|
12
|
+
import type { EncounterEntryEditor } from './encounter-entry-editor';
|
|
13
|
+
import type { EmployeeEntryEditor } from './employee-entry-editor';
|
|
14
|
+
import type { FlagEntryEditor } from './flag-entry-editor';
|
|
15
|
+
import type { ImmunizationEntryEditor } from './immunization-entry-editor';
|
|
16
|
+
import type { MedicationStatementEntryEditor } from './medication-statement-entry-editor';
|
|
17
|
+
import type { ObservationEntryEditor } from './observation-entry-editor';
|
|
18
|
+
import type { ProcedureEntryEditor } from './procedure-entry-editor';
|
|
19
|
+
import type { VitalSignEntryEditor } from './vital-sign-entry-editor';
|
|
20
|
+
import { type EmployeeClaims } from './employee';
|
|
21
|
+
export declare class BundleEntryEditor {
|
|
22
|
+
protected readonly bundleEditor: BundleEditor;
|
|
23
|
+
protected readonly entryIndex: number;
|
|
24
|
+
constructor(bundleEditor: BundleEditor, entryIndex: number);
|
|
25
|
+
/**
|
|
26
|
+
* Reopens the current slot as one typed resource editor.
|
|
27
|
+
*
|
|
28
|
+
* Use this when the caller already knows the resource type of an existing
|
|
29
|
+
* entry and wants the typed `get...` / `set...` API back.
|
|
30
|
+
*/
|
|
31
|
+
asResourceType<T extends AllowedResourceType>(resourceType: T): ResourceTypeEntryEditor<T>;
|
|
32
|
+
/** Opens the current entry as one employee-specific resource editor. */
|
|
33
|
+
asEmployee(): EmployeeEntryEditor;
|
|
34
|
+
/** Opens the current entry as one vital-sign-specific Observation editor. */
|
|
35
|
+
asVitalSign(): VitalSignEntryEditor;
|
|
36
|
+
/** Opens the current entry as one general Observation editor. */
|
|
37
|
+
asObservation(): ObservationEntryEditor;
|
|
38
|
+
/** Opens the current entry as one AllergyIntolerance editor. */
|
|
39
|
+
asAllergy(): AllergyIntoleranceEntryEditor;
|
|
40
|
+
/** Opens the current entry as one Condition editor. */
|
|
41
|
+
asCondition(): ConditionEntryEditor;
|
|
42
|
+
/** Opens the current entry as one MedicationStatement editor. */
|
|
43
|
+
asMedicationStatement(): MedicationStatementEntryEditor;
|
|
44
|
+
/** Opens the current entry as one DocumentReference editor. */
|
|
45
|
+
asDocumentReference(): DocumentReferenceEntryEditor;
|
|
46
|
+
/** Opens the current entry as one CarePlan editor. */
|
|
47
|
+
asCarePlan(): CarePlanEntryEditor;
|
|
48
|
+
/** Opens the current entry as one Flag editor. */
|
|
49
|
+
asFlag(): FlagEntryEditor;
|
|
50
|
+
/** Opens the current entry as one ClinicalImpression editor. */
|
|
51
|
+
asClinicalImpression(): ClinicalImpressionEntryEditor;
|
|
52
|
+
/** Opens the current entry as one Device editor. */
|
|
53
|
+
asDevice(): DeviceEntryEditor;
|
|
54
|
+
/** Opens the current entry as one DeviceUseStatement editor. */
|
|
55
|
+
asDeviceUseStatement(): DeviceUseStatementEntryEditor;
|
|
56
|
+
/** Opens the current entry as one Encounter editor. */
|
|
57
|
+
asEncounter(): EncounterEntryEditor;
|
|
58
|
+
/** Opens the current entry as one Coverage editor. */
|
|
59
|
+
asCoverage(): CoverageEntryEditor;
|
|
60
|
+
/** Opens the current entry as one Immunization editor. */
|
|
61
|
+
asImmunization(): ImmunizationEntryEditor;
|
|
62
|
+
/** Opens the current entry as one Procedure editor. */
|
|
63
|
+
asProcedure(): ProcedureEntryEditor;
|
|
64
|
+
/** Opens the current entry as one DiagnosticReport editor. */
|
|
65
|
+
asDiagnosticReport(): DiagnosticReportEntryEditor;
|
|
66
|
+
/** Reads one claim from this entry. */
|
|
67
|
+
getClaim(key: string): unknown;
|
|
68
|
+
/** Checks whether this entry contains one claim key. */
|
|
69
|
+
hasClaim(key: string): boolean;
|
|
70
|
+
/** Writes one claim on this entry. */
|
|
71
|
+
setClaim(key: string, value: unknown): this;
|
|
72
|
+
/** Appends one claim value on this entry. */
|
|
73
|
+
addClaim(key: string, value: unknown): this;
|
|
74
|
+
/** Removes one claim from this entry. */
|
|
75
|
+
removeClaim(key: string): this;
|
|
76
|
+
/** Writes the staged entry `resource.id`. */
|
|
77
|
+
setResourceId(resourceId?: string | null): this;
|
|
78
|
+
/** Reads the staged entry `resource.id` when present. */
|
|
79
|
+
getResourceId(): string | undefined;
|
|
80
|
+
/** Writes the staged entry `fullUrl`. */
|
|
81
|
+
setFullUrl(fullUrl?: string | null): this;
|
|
82
|
+
/** Reads the staged entry `fullUrl` when present. */
|
|
83
|
+
getFullUrl(): string | undefined;
|
|
84
|
+
/** Returns control to the parent bundle editor. */
|
|
85
|
+
doneEntry(): BundleEditor;
|
|
86
|
+
/** Returns the mutable staged entry owned by this editor wrapper. */
|
|
87
|
+
protected getMutableEntry(): BuiltBundleEntry;
|
|
88
|
+
/** Returns a cloned claims view for safe read-modify-write helper code. */
|
|
89
|
+
protected getClaims(): EmployeeClaims;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Shared claims-first editor utilities for IPS clinical resource families.
|
|
93
|
+
*
|
|
94
|
+
* The concrete resource type changes, but the editing contract stays aligned:
|
|
95
|
+
* identifier + subject + status + date + optional CSV-backed reference lists.
|
|
96
|
+
*/
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File discipline note:
|
|
3
|
+
* - Read `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing this module.
|
|
4
|
+
* - This file owns only the generic entry-level editor surface.
|
|
5
|
+
* - Resource-specific semantics must live in the dedicated typed entry editors.
|
|
6
|
+
*/
|
|
7
|
+
import { ResourceTypesFhirR4 } from '../constants/fhir-resource-types.js';
|
|
8
|
+
import { BundleEditableResourceTypes, } from '../models/bundle-editor-types.js';
|
|
9
|
+
import { EmployeeResourceTypes, } from './employee.js';
|
|
10
|
+
import { cloneClaimValue, normalizeOptionalIdentifier } from './bundle-editor-helpers.js';
|
|
11
|
+
import { createRegisteredBundleEntryEditor } from './bundle-editor-registry.js';
|
|
12
|
+
export class BundleEntryEditor {
|
|
13
|
+
bundleEditor;
|
|
14
|
+
entryIndex;
|
|
15
|
+
constructor(bundleEditor, entryIndex) {
|
|
16
|
+
this.bundleEditor = bundleEditor;
|
|
17
|
+
this.entryIndex = entryIndex;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reopens the current slot as one typed resource editor.
|
|
21
|
+
*
|
|
22
|
+
* Use this when the caller already knows the resource type of an existing
|
|
23
|
+
* entry and wants the typed `get...` / `set...` API back.
|
|
24
|
+
*/
|
|
25
|
+
asResourceType(resourceType) {
|
|
26
|
+
const normalized = String(resourceType || '').trim();
|
|
27
|
+
switch (normalized) {
|
|
28
|
+
case BundleEditableResourceTypes.employee:
|
|
29
|
+
return this.asEmployee();
|
|
30
|
+
case BundleEditableResourceTypes.vitalSign:
|
|
31
|
+
return this.asVitalSign();
|
|
32
|
+
case BundleEditableResourceTypes.observation:
|
|
33
|
+
return this.asObservation();
|
|
34
|
+
case BundleEditableResourceTypes.allergyIntolerance:
|
|
35
|
+
return this.asAllergy();
|
|
36
|
+
case BundleEditableResourceTypes.condition:
|
|
37
|
+
return this.asCondition();
|
|
38
|
+
case BundleEditableResourceTypes.medicationStatement:
|
|
39
|
+
return this.asMedicationStatement();
|
|
40
|
+
case BundleEditableResourceTypes.documentReference:
|
|
41
|
+
return this.asDocumentReference();
|
|
42
|
+
case BundleEditableResourceTypes.carePlan:
|
|
43
|
+
return this.asCarePlan();
|
|
44
|
+
case BundleEditableResourceTypes.flag:
|
|
45
|
+
return this.asFlag();
|
|
46
|
+
case BundleEditableResourceTypes.clinicalImpression:
|
|
47
|
+
return this.asClinicalImpression();
|
|
48
|
+
case BundleEditableResourceTypes.device:
|
|
49
|
+
return this.asDevice();
|
|
50
|
+
case BundleEditableResourceTypes.deviceUseStatement:
|
|
51
|
+
return this.asDeviceUseStatement();
|
|
52
|
+
case BundleEditableResourceTypes.encounter:
|
|
53
|
+
return this.asEncounter();
|
|
54
|
+
case BundleEditableResourceTypes.coverage:
|
|
55
|
+
return this.asCoverage();
|
|
56
|
+
case BundleEditableResourceTypes.immunization:
|
|
57
|
+
return this.asImmunization();
|
|
58
|
+
case BundleEditableResourceTypes.procedure:
|
|
59
|
+
return this.asProcedure();
|
|
60
|
+
case BundleEditableResourceTypes.diagnosticReport:
|
|
61
|
+
return this.asDiagnosticReport();
|
|
62
|
+
default:
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Opens the current entry as one employee-specific resource editor. */
|
|
67
|
+
asEmployee() {
|
|
68
|
+
const entry = this.getMutableEntry();
|
|
69
|
+
if (entry.resource?.resourceType !== EmployeeResourceTypes.employee) {
|
|
70
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Employee: ${String(entry.resource?.resourceType || '')}`);
|
|
71
|
+
}
|
|
72
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.employee, this.bundleEditor, this.entryIndex);
|
|
73
|
+
}
|
|
74
|
+
/** Opens the current entry as one vital-sign-specific Observation editor. */
|
|
75
|
+
asVitalSign() {
|
|
76
|
+
const entry = this.getMutableEntry();
|
|
77
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Observation) {
|
|
78
|
+
throw new Error(`BundleEntryEditor cannot open this entry as VitalSign: ${String(entry.resource?.resourceType || '')}`);
|
|
79
|
+
}
|
|
80
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.vitalSign, this.bundleEditor, this.entryIndex);
|
|
81
|
+
}
|
|
82
|
+
/** Opens the current entry as one general Observation editor. */
|
|
83
|
+
asObservation() {
|
|
84
|
+
const entry = this.getMutableEntry();
|
|
85
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Observation) {
|
|
86
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Observation: ${String(entry.resource?.resourceType || '')}`);
|
|
87
|
+
}
|
|
88
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.observation, this.bundleEditor, this.entryIndex);
|
|
89
|
+
}
|
|
90
|
+
/** Opens the current entry as one AllergyIntolerance editor. */
|
|
91
|
+
asAllergy() {
|
|
92
|
+
const entry = this.getMutableEntry();
|
|
93
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.AllergyIntolerance) {
|
|
94
|
+
throw new Error(`BundleEntryEditor cannot open this entry as AllergyIntolerance: ${String(entry.resource?.resourceType || '')}`);
|
|
95
|
+
}
|
|
96
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.allergyIntolerance, this.bundleEditor, this.entryIndex);
|
|
97
|
+
}
|
|
98
|
+
/** Opens the current entry as one Condition editor. */
|
|
99
|
+
asCondition() {
|
|
100
|
+
const entry = this.getMutableEntry();
|
|
101
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Condition) {
|
|
102
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Condition: ${String(entry.resource?.resourceType || '')}`);
|
|
103
|
+
}
|
|
104
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.condition, this.bundleEditor, this.entryIndex);
|
|
105
|
+
}
|
|
106
|
+
/** Opens the current entry as one MedicationStatement editor. */
|
|
107
|
+
asMedicationStatement() {
|
|
108
|
+
const entry = this.getMutableEntry();
|
|
109
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.MedicationStatement) {
|
|
110
|
+
throw new Error(`BundleEntryEditor cannot open this entry as MedicationStatement: ${String(entry.resource?.resourceType || '')}`);
|
|
111
|
+
}
|
|
112
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.medicationStatement, this.bundleEditor, this.entryIndex);
|
|
113
|
+
}
|
|
114
|
+
/** Opens the current entry as one DocumentReference editor. */
|
|
115
|
+
asDocumentReference() {
|
|
116
|
+
const entry = this.getMutableEntry();
|
|
117
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.DocumentReference) {
|
|
118
|
+
throw new Error(`BundleEntryEditor cannot open this entry as DocumentReference: ${String(entry.resource?.resourceType || '')}`);
|
|
119
|
+
}
|
|
120
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.documentReference, this.bundleEditor, this.entryIndex);
|
|
121
|
+
}
|
|
122
|
+
/** Opens the current entry as one CarePlan editor. */
|
|
123
|
+
asCarePlan() {
|
|
124
|
+
const entry = this.getMutableEntry();
|
|
125
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.CarePlan) {
|
|
126
|
+
throw new Error(`BundleEntryEditor cannot open this entry as CarePlan: ${String(entry.resource?.resourceType || '')}`);
|
|
127
|
+
}
|
|
128
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.carePlan, this.bundleEditor, this.entryIndex);
|
|
129
|
+
}
|
|
130
|
+
/** Opens the current entry as one Flag editor. */
|
|
131
|
+
asFlag() {
|
|
132
|
+
const entry = this.getMutableEntry();
|
|
133
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Flag) {
|
|
134
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Flag: ${String(entry.resource?.resourceType || '')}`);
|
|
135
|
+
}
|
|
136
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.flag, this.bundleEditor, this.entryIndex);
|
|
137
|
+
}
|
|
138
|
+
/** Opens the current entry as one ClinicalImpression editor. */
|
|
139
|
+
asClinicalImpression() {
|
|
140
|
+
const entry = this.getMutableEntry();
|
|
141
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.ClinicalImpression) {
|
|
142
|
+
throw new Error(`BundleEntryEditor cannot open this entry as ClinicalImpression: ${String(entry.resource?.resourceType || '')}`);
|
|
143
|
+
}
|
|
144
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.clinicalImpression, this.bundleEditor, this.entryIndex);
|
|
145
|
+
}
|
|
146
|
+
/** Opens the current entry as one Device editor. */
|
|
147
|
+
asDevice() {
|
|
148
|
+
const entry = this.getMutableEntry();
|
|
149
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Device) {
|
|
150
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Device: ${String(entry.resource?.resourceType || '')}`);
|
|
151
|
+
}
|
|
152
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.device, this.bundleEditor, this.entryIndex);
|
|
153
|
+
}
|
|
154
|
+
/** Opens the current entry as one DeviceUseStatement editor. */
|
|
155
|
+
asDeviceUseStatement() {
|
|
156
|
+
const entry = this.getMutableEntry();
|
|
157
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.DeviceUseStatement) {
|
|
158
|
+
throw new Error(`BundleEntryEditor cannot open this entry as DeviceUseStatement: ${String(entry.resource?.resourceType || '')}`);
|
|
159
|
+
}
|
|
160
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.deviceUseStatement, this.bundleEditor, this.entryIndex);
|
|
161
|
+
}
|
|
162
|
+
/** Opens the current entry as one Encounter editor. */
|
|
163
|
+
asEncounter() {
|
|
164
|
+
const entry = this.getMutableEntry();
|
|
165
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Encounter) {
|
|
166
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Encounter: ${String(entry.resource?.resourceType || '')}`);
|
|
167
|
+
}
|
|
168
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.encounter, this.bundleEditor, this.entryIndex);
|
|
169
|
+
}
|
|
170
|
+
/** Opens the current entry as one Coverage editor. */
|
|
171
|
+
asCoverage() {
|
|
172
|
+
const entry = this.getMutableEntry();
|
|
173
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Coverage) {
|
|
174
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Coverage: ${String(entry.resource?.resourceType || '')}`);
|
|
175
|
+
}
|
|
176
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.coverage, this.bundleEditor, this.entryIndex);
|
|
177
|
+
}
|
|
178
|
+
/** Opens the current entry as one Immunization editor. */
|
|
179
|
+
asImmunization() {
|
|
180
|
+
const entry = this.getMutableEntry();
|
|
181
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Immunization) {
|
|
182
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Immunization: ${String(entry.resource?.resourceType || '')}`);
|
|
183
|
+
}
|
|
184
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.immunization, this.bundleEditor, this.entryIndex);
|
|
185
|
+
}
|
|
186
|
+
/** Opens the current entry as one Procedure editor. */
|
|
187
|
+
asProcedure() {
|
|
188
|
+
const entry = this.getMutableEntry();
|
|
189
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.Procedure) {
|
|
190
|
+
throw new Error(`BundleEntryEditor cannot open this entry as Procedure: ${String(entry.resource?.resourceType || '')}`);
|
|
191
|
+
}
|
|
192
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.procedure, this.bundleEditor, this.entryIndex);
|
|
193
|
+
}
|
|
194
|
+
/** Opens the current entry as one DiagnosticReport editor. */
|
|
195
|
+
asDiagnosticReport() {
|
|
196
|
+
const entry = this.getMutableEntry();
|
|
197
|
+
if (entry.resource?.resourceType !== ResourceTypesFhirR4.DiagnosticReport) {
|
|
198
|
+
throw new Error(`BundleEntryEditor cannot open this entry as DiagnosticReport: ${String(entry.resource?.resourceType || '')}`);
|
|
199
|
+
}
|
|
200
|
+
return createRegisteredBundleEntryEditor(BundleEditableResourceTypes.diagnosticReport, this.bundleEditor, this.entryIndex);
|
|
201
|
+
}
|
|
202
|
+
/** Reads one claim from this entry. */
|
|
203
|
+
getClaim(key) {
|
|
204
|
+
return cloneClaimValue(this.getClaims()[String(key).trim()]);
|
|
205
|
+
}
|
|
206
|
+
/** Checks whether this entry contains one claim key. */
|
|
207
|
+
hasClaim(key) {
|
|
208
|
+
return Object.prototype.hasOwnProperty.call(this.getClaims(), String(key).trim());
|
|
209
|
+
}
|
|
210
|
+
/** Writes one claim on this entry. */
|
|
211
|
+
setClaim(key, value) {
|
|
212
|
+
const entry = this.getMutableEntry();
|
|
213
|
+
entry.resource = entry.resource || {
|
|
214
|
+
resourceType: this.bundleEditor.getAllowedResourceType() || EmployeeResourceTypes.employee,
|
|
215
|
+
meta: { claims: {} },
|
|
216
|
+
};
|
|
217
|
+
entry.resource.meta = entry.resource.meta || {};
|
|
218
|
+
entry.resource.meta.claims = {
|
|
219
|
+
...(entry.resource.meta.claims || {}),
|
|
220
|
+
[String(key).trim()]: cloneClaimValue(value),
|
|
221
|
+
};
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
/** Appends one claim value on this entry. */
|
|
225
|
+
addClaim(key, value) {
|
|
226
|
+
const normalizedKey = String(key).trim();
|
|
227
|
+
const current = this.getClaim(normalizedKey);
|
|
228
|
+
if (current === undefined) {
|
|
229
|
+
return this.setClaim(normalizedKey, value);
|
|
230
|
+
}
|
|
231
|
+
if (Array.isArray(current)) {
|
|
232
|
+
return this.setClaim(normalizedKey, [...current, cloneClaimValue(value)]);
|
|
233
|
+
}
|
|
234
|
+
return this.setClaim(normalizedKey, [current, cloneClaimValue(value)]);
|
|
235
|
+
}
|
|
236
|
+
/** Removes one claim from this entry. */
|
|
237
|
+
removeClaim(key) {
|
|
238
|
+
const entry = this.getMutableEntry();
|
|
239
|
+
const claims = {
|
|
240
|
+
...(entry.resource?.meta?.claims || {}),
|
|
241
|
+
};
|
|
242
|
+
delete claims[String(key).trim()];
|
|
243
|
+
entry.resource = entry.resource || {
|
|
244
|
+
resourceType: this.bundleEditor.getAllowedResourceType() || EmployeeResourceTypes.employee,
|
|
245
|
+
meta: { claims: {} },
|
|
246
|
+
};
|
|
247
|
+
entry.resource.meta = entry.resource.meta || {};
|
|
248
|
+
entry.resource.meta.claims = claims;
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
/** Writes the staged entry `resource.id`. */
|
|
252
|
+
setResourceId(resourceId) {
|
|
253
|
+
const entry = this.getMutableEntry();
|
|
254
|
+
const normalized = normalizeOptionalIdentifier(resourceId);
|
|
255
|
+
if (!normalized) {
|
|
256
|
+
delete entry.resource?.id;
|
|
257
|
+
return this;
|
|
258
|
+
}
|
|
259
|
+
entry.resource = entry.resource || {
|
|
260
|
+
resourceType: this.bundleEditor.getAllowedResourceType() || EmployeeResourceTypes.employee,
|
|
261
|
+
meta: { claims: {} },
|
|
262
|
+
};
|
|
263
|
+
entry.resource.id = normalized;
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
/** Reads the staged entry `resource.id` when present. */
|
|
267
|
+
getResourceId() {
|
|
268
|
+
return normalizeOptionalIdentifier(this.getMutableEntry().resource?.id);
|
|
269
|
+
}
|
|
270
|
+
/** Writes the staged entry `fullUrl`. */
|
|
271
|
+
setFullUrl(fullUrl) {
|
|
272
|
+
const entry = this.getMutableEntry();
|
|
273
|
+
const normalized = normalizeOptionalIdentifier(fullUrl);
|
|
274
|
+
if (!normalized) {
|
|
275
|
+
delete entry.fullUrl;
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
entry.fullUrl = normalized;
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
/** Reads the staged entry `fullUrl` when present. */
|
|
282
|
+
getFullUrl() {
|
|
283
|
+
return normalizeOptionalIdentifier(this.getMutableEntry().fullUrl);
|
|
284
|
+
}
|
|
285
|
+
/** Returns control to the parent bundle editor. */
|
|
286
|
+
doneEntry() {
|
|
287
|
+
return this.bundleEditor;
|
|
288
|
+
}
|
|
289
|
+
/** Returns the mutable staged entry owned by this editor wrapper. */
|
|
290
|
+
getMutableEntry() {
|
|
291
|
+
return this.bundleEditor.getMutableEntry(this.entryIndex);
|
|
292
|
+
}
|
|
293
|
+
/** Returns a cloned claims view for safe read-modify-write helper code. */
|
|
294
|
+
getClaims() {
|
|
295
|
+
return {
|
|
296
|
+
...(this.getMutableEntry().resource?.meta?.claims || {}),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Shared claims-first editor utilities for IPS clinical resource families.
|
|
302
|
+
*
|
|
303
|
+
* The concrete resource type changes, but the editing contract stays aligned:
|
|
304
|
+
* identifier + subject + status + date + optional CSV-backed reference lists.
|
|
305
|
+
*/
|
|
@@ -26,6 +26,7 @@ export declare class BundleQuery {
|
|
|
26
26
|
* Resolves the entry URL (`fullUrl`) for a given entry/resource identifier.
|
|
27
27
|
*/
|
|
28
28
|
getEntryUrl(entryId: string): string | undefined;
|
|
29
|
+
private getEntries;
|
|
29
30
|
private resolveBundleEntryId;
|
|
30
31
|
private resolveIdentifierFromClaims;
|
|
31
32
|
private matchesResourceFilters;
|
|
@@ -14,7 +14,7 @@ export class BundleQuery {
|
|
|
14
14
|
* Returns stable resource IDs from bundle entries with optional filters.
|
|
15
15
|
*/
|
|
16
16
|
getResourceIds(filters = {}) {
|
|
17
|
-
return this.
|
|
17
|
+
return this.getEntries()
|
|
18
18
|
.filter((entry) => this.matchesResourceFilters(entry, filters))
|
|
19
19
|
.map((entry, index) => this.resolveBundleEntryId(entry, index));
|
|
20
20
|
}
|
|
@@ -26,7 +26,7 @@ export class BundleQuery {
|
|
|
26
26
|
if (wanted.size === 0) {
|
|
27
27
|
return [];
|
|
28
28
|
}
|
|
29
|
-
return this.
|
|
29
|
+
return this.getEntries()
|
|
30
30
|
.map((entry, index) => ({
|
|
31
31
|
entry,
|
|
32
32
|
id: this.resolveBundleEntryId(entry, index),
|
|
@@ -42,10 +42,19 @@ export class BundleQuery {
|
|
|
42
42
|
if (!wanted) {
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
|
-
const match = this.
|
|
45
|
+
const match = this.getEntries().find((entry, index) => this.resolveBundleEntryId(entry, index) === wanted);
|
|
46
46
|
const fullUrl = asTrimmedString(match?.fullUrl);
|
|
47
47
|
return fullUrl || undefined;
|
|
48
48
|
}
|
|
49
|
+
getEntries() {
|
|
50
|
+
if (Array.isArray(this.bundle.data)) {
|
|
51
|
+
return this.bundle.data;
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(this.bundle.entry)) {
|
|
54
|
+
return this.bundle.entry;
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
49
58
|
resolveBundleEntryId(entry, index) {
|
|
50
59
|
const explicitId = asTrimmedString(entry.id);
|
|
51
60
|
if (explicitId) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IssueSeverityCode } from '../models/issue';
|
|
2
|
+
import { type BundleResourceIdFilters } from './bundle-query';
|
|
2
3
|
export type BundleReaderEntry = Record<string, unknown>;
|
|
3
4
|
export type BundleReaderEntrySummary = Readonly<{
|
|
4
5
|
index: number;
|
|
@@ -29,6 +30,17 @@ export type BundleReaderResponseAnalysis = Readonly<{
|
|
|
29
30
|
success: BundleReaderSeverityBucket;
|
|
30
31
|
}>;
|
|
31
32
|
}>;
|
|
33
|
+
export type BundleDocumentSectionSummary = Readonly<{
|
|
34
|
+
index: number;
|
|
35
|
+
code?: string;
|
|
36
|
+
system?: string;
|
|
37
|
+
claim?: string;
|
|
38
|
+
entryReferences: readonly string[];
|
|
39
|
+
}>;
|
|
40
|
+
export type BundleVisibleResourceNavigation = Readonly<{
|
|
41
|
+
entryIndexes: readonly number[];
|
|
42
|
+
resourceIds: readonly string[];
|
|
43
|
+
}>;
|
|
32
44
|
/**
|
|
33
45
|
* Returns the canonical claims view for one bundle entry array index.
|
|
34
46
|
*
|
|
@@ -66,10 +78,42 @@ export declare class BundleReader {
|
|
|
66
78
|
getEntryIdentifierByArrayIndex(index: number): string | undefined;
|
|
67
79
|
/** Returns merged claims for one entry array index. */
|
|
68
80
|
getEntryClaimsByArrayIndex(index: number): Record<string, unknown>;
|
|
81
|
+
/** Returns true when the entry was imported from one parent resource `contained[]`. */
|
|
82
|
+
isContainedResourceEntryByArrayIndex(index: number): boolean;
|
|
83
|
+
/** Returns the parent resource reference for one contained resource entry. */
|
|
84
|
+
getContainedParentReferenceByArrayIndex(index: number): string | undefined;
|
|
69
85
|
/** Returns merged claims for the currently opened entry. */
|
|
70
86
|
getActiveEntryClaims(): Record<string, unknown>;
|
|
71
87
|
/** Returns the first entry array index whose resolved identifier matches the requested value. */
|
|
72
88
|
getEntryIndexByIdentifier(identifier: string): number | undefined;
|
|
89
|
+
/** Returns stable resource IDs filtered from the current bundle in memory. */
|
|
90
|
+
getResourceIds(filters?: BundleResourceIdFilters): string[];
|
|
91
|
+
/** Returns visible entry indexes after filtering out imported contained children. */
|
|
92
|
+
getVisibleEntryIndexes(filters?: BundleResourceIdFilters): number[];
|
|
93
|
+
/** Returns stable resource IDs excluding entries marked as imported `contained[]` children. */
|
|
94
|
+
getVisibleResourceIds(filters?: BundleResourceIdFilters): string[];
|
|
95
|
+
/** Returns the number of visible resources the frontend should iterate over. */
|
|
96
|
+
getVisibleResourceCount(filters?: BundleResourceIdFilters): number;
|
|
97
|
+
/** Returns one visible entry index by visible-position order. */
|
|
98
|
+
getVisibleEntryIndexByPosition(position: number, filters?: BundleResourceIdFilters): number | undefined;
|
|
99
|
+
/** Returns the next visible entry index after one raw entry index. */
|
|
100
|
+
getNextVisibleEntryIndex(currentIndex: number, filters?: BundleResourceIdFilters): number | undefined;
|
|
101
|
+
/** Returns the previous visible entry index before one raw entry index. */
|
|
102
|
+
getPreviousVisibleEntryIndex(currentIndex: number, filters?: BundleResourceIdFilters): number | undefined;
|
|
103
|
+
/** Returns bundle entries matching resource IDs produced by `getResourceIds(...)`. */
|
|
104
|
+
getEntriesByIds(resourceIds: readonly string[]): BundleReaderEntry[];
|
|
105
|
+
/** Resolves the entry URL (`fullUrl`) for a given entry/resource identifier. */
|
|
106
|
+
getEntryUrl(resourceId: string): string | undefined;
|
|
107
|
+
/** Returns the Composition-first document sections when this bundle is one document bundle. */
|
|
108
|
+
getDocumentSections(): BundleDocumentSectionSummary[];
|
|
109
|
+
/** Returns the number of Composition sections in one document bundle. */
|
|
110
|
+
getDocumentSectionCount(): number;
|
|
111
|
+
/** Returns one document section by canonical claim (`system|code`) or plain code. */
|
|
112
|
+
getDocumentSectionByCode(sectionCodeOrClaim: string): BundleDocumentSectionSummary | undefined;
|
|
113
|
+
/** Returns the number of resource references inside one document section. */
|
|
114
|
+
getDocumentSectionResourceCount(sectionCodeOrClaim: string): number;
|
|
115
|
+
/** Returns bundle resource references listed under one document section. */
|
|
116
|
+
getDocumentSectionResourceReferences(sectionCodeOrClaim: string): string[];
|
|
73
117
|
/** Returns the active entry response status when present. */
|
|
74
118
|
getEntryResponseStatus(): string | undefined;
|
|
75
119
|
/** Returns all active entry issue severities. */
|
|
@@ -77,6 +121,8 @@ export declare class BundleReader {
|
|
|
77
121
|
/** Returns all active entry issue diagnostics strings. */
|
|
78
122
|
getIssueDiagnostics(): string[];
|
|
79
123
|
/** Returns the number of bundle entries. */
|
|
124
|
+
getEntryCount(): number;
|
|
125
|
+
/** Returns the number of bundle entries. */
|
|
80
126
|
getTotalOperations(): number;
|
|
81
127
|
/** Returns the number of entries with one 2xx response status. */
|
|
82
128
|
getTotalSuccessfulOperations(): number;
|
|
@@ -97,6 +143,8 @@ export declare class BundleReader {
|
|
|
97
143
|
/** Returns one frontend-oriented response analysis for global bundle outcome rendering. */
|
|
98
144
|
getResponseAnalysis(): BundleReaderResponseAnalysis;
|
|
99
145
|
private getRequiredActiveEntry;
|
|
146
|
+
private getDocumentCompositionResource;
|
|
147
|
+
private getVisibleResourceNavigation;
|
|
100
148
|
private getActiveEntryIssues;
|
|
101
149
|
private getEntryIssues;
|
|
102
150
|
private buildEntrySummary;
|