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,123 @@
|
|
|
1
|
+
import { AllowedResourceType, type ResourceTypeEntryEditor } from '../models/bundle-editor-types';
|
|
2
|
+
import { BundleEntryEditor } from './bundle-entry-editor';
|
|
3
|
+
export declare class ClinicalResourceEntryEditor extends BundleEntryEditor {
|
|
4
|
+
/**
|
|
5
|
+
* Returns the best current identifier for the resource:
|
|
6
|
+
* - public `<ResourceType>.identifier` claim first
|
|
7
|
+
* - otherwise internal `resource.id`
|
|
8
|
+
* - otherwise `fullUrl`
|
|
9
|
+
*
|
|
10
|
+
* This fallback order matters because the editor may stage one new entry
|
|
11
|
+
* before the public identifier claim has been synchronized.
|
|
12
|
+
*/
|
|
13
|
+
protected getIdentifierValue(claimKey: string): string | undefined;
|
|
14
|
+
protected setIdentifierValue(claimKey: string, identifier?: string | null): this;
|
|
15
|
+
/** Writes the same subject value into both subject-style claim slots used by this resource family. */
|
|
16
|
+
protected setSubjectClaims(subjectClaimKey: string, patientClaimKey: string, subject?: string | null): this;
|
|
17
|
+
/** Reads the normalized subject value from the supported subject/patient claim aliases. */
|
|
18
|
+
protected getSubjectClaims(subjectClaimKey: string, patientClaimKey: string): string | undefined;
|
|
19
|
+
/** Writes one trimmed string claim and removes the key when the value is blank. */
|
|
20
|
+
protected setScalarClaim(claimKey: string, value?: string | null): this;
|
|
21
|
+
/** Reads one string claim using the shared blank-to-undefined normalization rule. */
|
|
22
|
+
protected getScalarClaim(claimKey: string): string | undefined;
|
|
23
|
+
/** Stores one numeric claim through the flat-claims string representation used by the bundle editors. */
|
|
24
|
+
protected setNumberClaim(claimKey: string, value?: number | null): this;
|
|
25
|
+
/** Reads one numeric flat claim and converts it back to a finite number when possible. */
|
|
26
|
+
protected getNumberClaim(claimKey: string): number | undefined;
|
|
27
|
+
/** Stores one boolean claim and removes it when the caller wants to clear the field. */
|
|
28
|
+
protected setBooleanClaim(claimKey: string, value?: boolean | null): this;
|
|
29
|
+
/** Reads one boolean claim while tolerating both real booleans and serialized `'true'` / `'false'` values. */
|
|
30
|
+
protected getBooleanClaim(claimKey: string): boolean | undefined;
|
|
31
|
+
/** Stores one multi-value flat claim using the shared CSV serialization helper. */
|
|
32
|
+
protected setCsvClaimList(claimKey: string, values: readonly string[]): this;
|
|
33
|
+
/** Reads one CSV-backed flat claim as a normalized string list. */
|
|
34
|
+
protected getCsvClaimList(claimKey: string): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Ensures one canonical identifier across:
|
|
37
|
+
* - public identifier claim
|
|
38
|
+
* - `resource.id`
|
|
39
|
+
* - `fullUrl`
|
|
40
|
+
*
|
|
41
|
+
* This is the preferred onboarding path after `newEntryAs(...)` /
|
|
42
|
+
* `newContainedResourceAs(...)` when the entry was created without an
|
|
43
|
+
* explicit id.
|
|
44
|
+
*/
|
|
45
|
+
protected ensureIdentifierValue(claimKey: string): string;
|
|
46
|
+
/** Resolves which claim stores the CSV list of linked/contained resource references for this resource type. */
|
|
47
|
+
protected getContainedReferenceListClaimKey(): string;
|
|
48
|
+
/** Builds one resource-scoped claim key such as `MedicationStatement.language`. */
|
|
49
|
+
protected getResourceScopedClaimKey(suffix: string): string;
|
|
50
|
+
/** Returns the canonical `ResourceType/<identifier>` reference for the current staged entry. */
|
|
51
|
+
protected getEntryReference(): string;
|
|
52
|
+
/** Replaces the linked child-resource reference list on the current parent resource. */
|
|
53
|
+
setContainedResourceReferenceList(references: readonly string[]): this;
|
|
54
|
+
/** Returns the normalized linked child-resource reference list for the current parent resource. */
|
|
55
|
+
getContainedResourceReferenceList(): string[];
|
|
56
|
+
/** Adds one child-resource reference to the parent list, deduplicating exact matches. */
|
|
57
|
+
addContainedResourceReference(reference: string): this;
|
|
58
|
+
/** Removes one child-resource reference from the parent list without touching any staged child entry. */
|
|
59
|
+
removeContainedResourceReference(reference: string): this;
|
|
60
|
+
/**
|
|
61
|
+
* Creates one linked child entry, then seeds it from an already prepared claims object.
|
|
62
|
+
*
|
|
63
|
+
* Keep this as a plumbing/import helper. The 101 path should prefer
|
|
64
|
+
* `newContainedResourceAs(...)` so the front edits the child through the
|
|
65
|
+
* typed editor surface instead of raw claim objects.
|
|
66
|
+
*/
|
|
67
|
+
addContainedResourceByClaims(resourceType: AllowedResourceType, claims: Record<string, unknown>, resourceIdOrReference?: string, options?: Readonly<{
|
|
68
|
+
contained?: boolean;
|
|
69
|
+
}>): BundleEntryEditor;
|
|
70
|
+
/**
|
|
71
|
+
* Opens one linked child/sibling resource through the same `BundleEditor`.
|
|
72
|
+
*
|
|
73
|
+
* Default path:
|
|
74
|
+
* - create one visible sibling resource
|
|
75
|
+
* - link it from the parent CSV reference list
|
|
76
|
+
*
|
|
77
|
+
* Advanced path:
|
|
78
|
+
* - pass `{ contained: true }` only when the FHIR export must rebuild the
|
|
79
|
+
* resource under `parent.contained[]`.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Creates one linked child entry through the same bundle editor.
|
|
83
|
+
*
|
|
84
|
+
* Default behavior:
|
|
85
|
+
* - create one visible sibling entry
|
|
86
|
+
* - add its canonical `ResourceType/<id>` reference to the parent list
|
|
87
|
+
*
|
|
88
|
+
* Advanced behavior:
|
|
89
|
+
* - `{ contained: true }` also marks the child so FHIR export can rebuild it
|
|
90
|
+
* under `parent.contained[]` instead of showing it as a normal top-level
|
|
91
|
+
* clinical resource entry.
|
|
92
|
+
*/
|
|
93
|
+
newContainedResource(resourceType: AllowedResourceType, resourceIdOrReference?: string, options?: Readonly<{
|
|
94
|
+
contained?: boolean;
|
|
95
|
+
}>): BundleEntryEditor;
|
|
96
|
+
/** Creates one linked child entry and immediately returns the typed editor for that child resource type. */
|
|
97
|
+
newContainedResourceAs<T extends AllowedResourceType>(resourceType: T, resourceIdOrReference?: string, options?: Readonly<{
|
|
98
|
+
contained?: boolean;
|
|
99
|
+
}>): ResourceTypeEntryEditor<T>;
|
|
100
|
+
/** @deprecated Use `newContainedResource(...)`. */
|
|
101
|
+
addContainedResourceEntry(resourceType: AllowedResourceType, resourceIdOrReference?: string, options?: Readonly<{
|
|
102
|
+
contained?: boolean;
|
|
103
|
+
}>): BundleEntryEditor;
|
|
104
|
+
/**
|
|
105
|
+
* Removes one linked child reference and, when the child was marked as
|
|
106
|
+
* contained under this exact parent, also removes the staged child entry.
|
|
107
|
+
*/
|
|
108
|
+
removeContainedResourceByReference(reference: string): this;
|
|
109
|
+
/** Stores the generic `<ResourceType>.language` flat claim used by multilingual resource payloads. */
|
|
110
|
+
setLanguage(value?: string | null): this;
|
|
111
|
+
/** Returns the generic `<ResourceType>.language` flat claim when present. */
|
|
112
|
+
getLanguage(): string | undefined;
|
|
113
|
+
/** Stores the generic `<ResourceType>.user-selected` flag used by self-managed user flows. */
|
|
114
|
+
setUserSelected(value?: boolean | null): this;
|
|
115
|
+
/** Returns the generic `<ResourceType>.user-selected` flag when present. */
|
|
116
|
+
getUserSelected(): boolean | undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Reduced Observation component-style editor surface.
|
|
120
|
+
*
|
|
121
|
+
* This base layer owns the reusable code/value authoring helpers shared by
|
|
122
|
+
* Vital Signs and broader Observation entry editors.
|
|
123
|
+
*/
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { cloneClaimValue, createCanonicalIdentifierUrn, normalizeContainedReference, normalizeOptionalIdentifier, resolveContainedFlagClaimKey, resolveContainedParentReferenceClaimKey, resolveContainedReferenceListClaimKey, } from './bundle-editor-helpers.js';
|
|
2
|
+
import { BundleEntryEditor } from './bundle-entry-editor.js';
|
|
3
|
+
import { getClaimValues, setClaimValues } from '../claims/claim-list-helpers.js';
|
|
4
|
+
export class ClinicalResourceEntryEditor extends BundleEntryEditor {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the best current identifier for the resource:
|
|
7
|
+
* - public `<ResourceType>.identifier` claim first
|
|
8
|
+
* - otherwise internal `resource.id`
|
|
9
|
+
* - otherwise `fullUrl`
|
|
10
|
+
*
|
|
11
|
+
* This fallback order matters because the editor may stage one new entry
|
|
12
|
+
* before the public identifier claim has been synchronized.
|
|
13
|
+
*/
|
|
14
|
+
getIdentifierValue(claimKey) {
|
|
15
|
+
return normalizeOptionalIdentifier(this.getClaim(claimKey)
|
|
16
|
+
|| this.getResourceId()
|
|
17
|
+
|| this.getFullUrl());
|
|
18
|
+
}
|
|
19
|
+
setIdentifierValue(claimKey, identifier) {
|
|
20
|
+
const normalized = normalizeOptionalIdentifier(identifier);
|
|
21
|
+
if (!normalized) {
|
|
22
|
+
this.removeClaim(claimKey);
|
|
23
|
+
this.setResourceId(undefined);
|
|
24
|
+
this.setFullUrl(undefined);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
this.setClaim(claimKey, normalized);
|
|
28
|
+
this.setResourceId(normalized);
|
|
29
|
+
this.setFullUrl(normalized);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
/** Writes the same subject value into both subject-style claim slots used by this resource family. */
|
|
33
|
+
setSubjectClaims(subjectClaimKey, patientClaimKey, subject) {
|
|
34
|
+
const normalized = normalizeOptionalIdentifier(subject);
|
|
35
|
+
if (!normalized) {
|
|
36
|
+
this.removeClaim(subjectClaimKey);
|
|
37
|
+
this.removeClaim(patientClaimKey);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
this.setClaim(subjectClaimKey, normalized);
|
|
41
|
+
this.setClaim(patientClaimKey, normalized);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/** Reads the normalized subject value from the supported subject/patient claim aliases. */
|
|
45
|
+
getSubjectClaims(subjectClaimKey, patientClaimKey) {
|
|
46
|
+
return normalizeOptionalIdentifier(this.getClaim(subjectClaimKey)
|
|
47
|
+
|| this.getClaim(patientClaimKey));
|
|
48
|
+
}
|
|
49
|
+
/** Writes one trimmed string claim and removes the key when the value is blank. */
|
|
50
|
+
setScalarClaim(claimKey, value) {
|
|
51
|
+
const normalized = normalizeOptionalIdentifier(value);
|
|
52
|
+
if (!normalized) {
|
|
53
|
+
this.removeClaim(claimKey);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
return this.setClaim(claimKey, normalized);
|
|
57
|
+
}
|
|
58
|
+
/** Reads one string claim using the shared blank-to-undefined normalization rule. */
|
|
59
|
+
getScalarClaim(claimKey) {
|
|
60
|
+
return normalizeOptionalIdentifier(this.getClaim(claimKey));
|
|
61
|
+
}
|
|
62
|
+
/** Stores one numeric claim through the flat-claims string representation used by the bundle editors. */
|
|
63
|
+
setNumberClaim(claimKey, value) {
|
|
64
|
+
if (value === undefined || value === null || Number.isNaN(value)) {
|
|
65
|
+
this.removeClaim(claimKey);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
return this.setClaim(claimKey, String(value));
|
|
69
|
+
}
|
|
70
|
+
/** Reads one numeric flat claim and converts it back to a finite number when possible. */
|
|
71
|
+
getNumberClaim(claimKey) {
|
|
72
|
+
const raw = this.getClaim(claimKey);
|
|
73
|
+
if (raw === undefined || raw === null || raw === '')
|
|
74
|
+
return undefined;
|
|
75
|
+
const numeric = Number(raw);
|
|
76
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
77
|
+
}
|
|
78
|
+
/** Stores one boolean claim and removes it when the caller wants to clear the field. */
|
|
79
|
+
setBooleanClaim(claimKey, value) {
|
|
80
|
+
if (value === undefined || value === null) {
|
|
81
|
+
this.removeClaim(claimKey);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
return this.setClaim(claimKey, value);
|
|
85
|
+
}
|
|
86
|
+
/** Reads one boolean claim while tolerating both real booleans and serialized `'true'` / `'false'` values. */
|
|
87
|
+
getBooleanClaim(claimKey) {
|
|
88
|
+
const raw = this.getClaim(claimKey);
|
|
89
|
+
if (typeof raw === 'boolean')
|
|
90
|
+
return raw;
|
|
91
|
+
if (raw === 'true')
|
|
92
|
+
return true;
|
|
93
|
+
if (raw === 'false')
|
|
94
|
+
return false;
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
/** Stores one multi-value flat claim using the shared CSV serialization helper. */
|
|
98
|
+
setCsvClaimList(claimKey, values) {
|
|
99
|
+
const next = setClaimValues({}, claimKey, values);
|
|
100
|
+
const normalized = normalizeOptionalIdentifier(next[claimKey]);
|
|
101
|
+
if (!normalized) {
|
|
102
|
+
this.removeClaim(claimKey);
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
return this.setClaim(claimKey, normalized);
|
|
106
|
+
}
|
|
107
|
+
/** Reads one CSV-backed flat claim as a normalized string list. */
|
|
108
|
+
getCsvClaimList(claimKey) {
|
|
109
|
+
return getClaimValues(this.getClaims(), claimKey);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Ensures one canonical identifier across:
|
|
113
|
+
* - public identifier claim
|
|
114
|
+
* - `resource.id`
|
|
115
|
+
* - `fullUrl`
|
|
116
|
+
*
|
|
117
|
+
* This is the preferred onboarding path after `newEntryAs(...)` /
|
|
118
|
+
* `newContainedResourceAs(...)` when the entry was created without an
|
|
119
|
+
* explicit id.
|
|
120
|
+
*/
|
|
121
|
+
ensureIdentifierValue(claimKey) {
|
|
122
|
+
const existingClaim = normalizeOptionalIdentifier(this.getClaim(claimKey));
|
|
123
|
+
if (existingClaim)
|
|
124
|
+
return existingClaim;
|
|
125
|
+
const existingResourceIdentifier = normalizeOptionalIdentifier(this.getResourceId() || this.getFullUrl());
|
|
126
|
+
if (existingResourceIdentifier) {
|
|
127
|
+
this.setIdentifierValue(claimKey, existingResourceIdentifier);
|
|
128
|
+
return existingResourceIdentifier;
|
|
129
|
+
}
|
|
130
|
+
const generated = createCanonicalIdentifierUrn();
|
|
131
|
+
this.setIdentifierValue(claimKey, generated);
|
|
132
|
+
return generated;
|
|
133
|
+
}
|
|
134
|
+
/** Resolves which claim stores the CSV list of linked/contained resource references for this resource type. */
|
|
135
|
+
getContainedReferenceListClaimKey() {
|
|
136
|
+
const resourceType = String(this.getMutableEntry().resource?.resourceType || '').trim();
|
|
137
|
+
const claimKey = resolveContainedReferenceListClaimKey(resourceType);
|
|
138
|
+
if (!claimKey) {
|
|
139
|
+
throw new Error(`Contained-reference linking is not supported for resource type: ${resourceType || '(unknown)'}`);
|
|
140
|
+
}
|
|
141
|
+
return claimKey;
|
|
142
|
+
}
|
|
143
|
+
/** Builds one resource-scoped claim key such as `MedicationStatement.language`. */
|
|
144
|
+
getResourceScopedClaimKey(suffix) {
|
|
145
|
+
const resourceType = String(this.getMutableEntry().resource?.resourceType || '').trim();
|
|
146
|
+
if (!resourceType) {
|
|
147
|
+
throw new Error('Resource-scoped claim access requires one concrete resource type.');
|
|
148
|
+
}
|
|
149
|
+
return `${resourceType}.${String(suffix || '').trim()}`;
|
|
150
|
+
}
|
|
151
|
+
/** Returns the canonical `ResourceType/<identifier>` reference for the current staged entry. */
|
|
152
|
+
getEntryReference() {
|
|
153
|
+
const resourceType = String(this.getMutableEntry().resource?.resourceType || '').trim();
|
|
154
|
+
const identifier = normalizeOptionalIdentifier(this.getResourceId() || this.getFullUrl());
|
|
155
|
+
if (!resourceType || !identifier) {
|
|
156
|
+
throw new Error('Contained-resource linking requires the parent entry to have a concrete resource type and identifier.');
|
|
157
|
+
}
|
|
158
|
+
return `${resourceType}/${identifier}`;
|
|
159
|
+
}
|
|
160
|
+
/** Replaces the linked child-resource reference list on the current parent resource. */
|
|
161
|
+
setContainedResourceReferenceList(references) {
|
|
162
|
+
return this.setCsvClaimList(this.getContainedReferenceListClaimKey(), references);
|
|
163
|
+
}
|
|
164
|
+
/** Returns the normalized linked child-resource reference list for the current parent resource. */
|
|
165
|
+
getContainedResourceReferenceList() {
|
|
166
|
+
return this.getCsvClaimList(this.getContainedReferenceListClaimKey());
|
|
167
|
+
}
|
|
168
|
+
/** Adds one child-resource reference to the parent list, deduplicating exact matches. */
|
|
169
|
+
addContainedResourceReference(reference) {
|
|
170
|
+
const next = [...this.getContainedResourceReferenceList(), String(reference || '').trim()]
|
|
171
|
+
.filter(Boolean);
|
|
172
|
+
return this.setContainedResourceReferenceList([...new Set(next)]);
|
|
173
|
+
}
|
|
174
|
+
/** Removes one child-resource reference from the parent list without touching any staged child entry. */
|
|
175
|
+
removeContainedResourceReference(reference) {
|
|
176
|
+
const normalized = String(reference || '').trim();
|
|
177
|
+
if (!normalized) {
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
return this.setContainedResourceReferenceList(this.getContainedResourceReferenceList().filter((item) => item !== normalized));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Creates one linked child entry, then seeds it from an already prepared claims object.
|
|
184
|
+
*
|
|
185
|
+
* Keep this as a plumbing/import helper. The 101 path should prefer
|
|
186
|
+
* `newContainedResourceAs(...)` so the front edits the child through the
|
|
187
|
+
* typed editor surface instead of raw claim objects.
|
|
188
|
+
*/
|
|
189
|
+
addContainedResourceByClaims(resourceType, claims, resourceIdOrReference, options) {
|
|
190
|
+
const seededIdentifier = normalizeOptionalIdentifier(resourceIdOrReference)
|
|
191
|
+
|| normalizeOptionalIdentifier(claims[`${resourceType}.identifier`])
|
|
192
|
+
|| createCanonicalIdentifierUrn();
|
|
193
|
+
const containedEntry = this.addContainedResourceEntry(resourceType, seededIdentifier, options);
|
|
194
|
+
Object.entries(claims || {}).forEach(([key, value]) => {
|
|
195
|
+
containedEntry.setClaim(key, cloneClaimValue(value));
|
|
196
|
+
});
|
|
197
|
+
return containedEntry;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Opens one linked child/sibling resource through the same `BundleEditor`.
|
|
201
|
+
*
|
|
202
|
+
* Default path:
|
|
203
|
+
* - create one visible sibling resource
|
|
204
|
+
* - link it from the parent CSV reference list
|
|
205
|
+
*
|
|
206
|
+
* Advanced path:
|
|
207
|
+
* - pass `{ contained: true }` only when the FHIR export must rebuild the
|
|
208
|
+
* resource under `parent.contained[]`.
|
|
209
|
+
*/
|
|
210
|
+
/**
|
|
211
|
+
* Creates one linked child entry through the same bundle editor.
|
|
212
|
+
*
|
|
213
|
+
* Default behavior:
|
|
214
|
+
* - create one visible sibling entry
|
|
215
|
+
* - add its canonical `ResourceType/<id>` reference to the parent list
|
|
216
|
+
*
|
|
217
|
+
* Advanced behavior:
|
|
218
|
+
* - `{ contained: true }` also marks the child so FHIR export can rebuild it
|
|
219
|
+
* under `parent.contained[]` instead of showing it as a normal top-level
|
|
220
|
+
* clinical resource entry.
|
|
221
|
+
*/
|
|
222
|
+
newContainedResource(resourceType, resourceIdOrReference, options) {
|
|
223
|
+
const parentReference = this.getEntryReference();
|
|
224
|
+
const seededIdentifier = normalizeOptionalIdentifier(resourceIdOrReference) || createCanonicalIdentifierUrn();
|
|
225
|
+
const normalizedContained = normalizeContainedReference(resourceType, seededIdentifier);
|
|
226
|
+
const containedEntry = this.bundleEditor.newEntryAs(resourceType, normalizedContained.identifier);
|
|
227
|
+
containedEntry
|
|
228
|
+
.setResourceId(normalizedContained.identifier)
|
|
229
|
+
.setFullUrl(normalizedContained.identifier)
|
|
230
|
+
.setClaim(`${resourceType}.identifier`, normalizedContained.identifier);
|
|
231
|
+
if (options?.contained) {
|
|
232
|
+
containedEntry
|
|
233
|
+
.setClaim(resolveContainedFlagClaimKey(resourceType), true)
|
|
234
|
+
.setClaim(resolveContainedParentReferenceClaimKey(resourceType), parentReference);
|
|
235
|
+
}
|
|
236
|
+
this.addContainedResourceReference(normalizedContained.reference);
|
|
237
|
+
return containedEntry;
|
|
238
|
+
}
|
|
239
|
+
/** Creates one linked child entry and immediately returns the typed editor for that child resource type. */
|
|
240
|
+
newContainedResourceAs(resourceType, resourceIdOrReference, options) {
|
|
241
|
+
return this.newContainedResource(resourceType, resourceIdOrReference, options).asResourceType(resourceType);
|
|
242
|
+
}
|
|
243
|
+
/** @deprecated Use `newContainedResource(...)`. */
|
|
244
|
+
addContainedResourceEntry(resourceType, resourceIdOrReference, options) {
|
|
245
|
+
return this.newContainedResource(resourceType, resourceIdOrReference, options);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Removes one linked child reference and, when the child was marked as
|
|
249
|
+
* contained under this exact parent, also removes the staged child entry.
|
|
250
|
+
*/
|
|
251
|
+
removeContainedResourceByReference(reference) {
|
|
252
|
+
const parentReference = this.getEntryReference();
|
|
253
|
+
const normalizedContained = normalizeContainedReference(String(reference || '').includes('/') ? String(reference || '').split('/')[0] : '', String(reference || ''));
|
|
254
|
+
const normalizedReference = normalizedContained.reference || String(reference || '').trim();
|
|
255
|
+
const normalizedIdentifier = normalizedContained.identifier || normalizedReference.split('/').pop() || '';
|
|
256
|
+
this.removeContainedResourceReference(normalizedReference);
|
|
257
|
+
const childEntryIndex = this.bundleEditor.findEntryIndexByIdentifierOrFullUrl(normalizedIdentifier);
|
|
258
|
+
if (childEntryIndex < 0) {
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
const childEntry = this.bundleEditor.getMutableEntry(childEntryIndex);
|
|
262
|
+
const childClaims = childEntry.resource?.meta?.claims || {};
|
|
263
|
+
const childResourceType = String(childEntry.resource?.resourceType || '').trim();
|
|
264
|
+
const childContainedFlagClaimKey = resolveContainedFlagClaimKey(childResourceType);
|
|
265
|
+
const childContainedParentReferenceClaimKey = resolveContainedParentReferenceClaimKey(childResourceType);
|
|
266
|
+
const isContainedChild = childClaims[childContainedFlagClaimKey] === true
|
|
267
|
+
|| childClaims[childContainedFlagClaimKey] === 'true';
|
|
268
|
+
const childParentReference = normalizeOptionalIdentifier(childClaims[childContainedParentReferenceClaimKey]);
|
|
269
|
+
if (isContainedChild && childParentReference === parentReference) {
|
|
270
|
+
this.bundleEditor.removeMutableEntry(childEntryIndex);
|
|
271
|
+
}
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
/** Stores the generic `<ResourceType>.language` flat claim used by multilingual resource payloads. */
|
|
275
|
+
setLanguage(value) {
|
|
276
|
+
return this.setScalarClaim(this.getResourceScopedClaimKey('language'), value);
|
|
277
|
+
}
|
|
278
|
+
/** Returns the generic `<ResourceType>.language` flat claim when present. */
|
|
279
|
+
getLanguage() {
|
|
280
|
+
return this.getScalarClaim(this.getResourceScopedClaimKey('language'));
|
|
281
|
+
}
|
|
282
|
+
/** Stores the generic `<ResourceType>.user-selected` flag used by self-managed user flows. */
|
|
283
|
+
setUserSelected(value) {
|
|
284
|
+
return this.setBooleanClaim(this.getResourceScopedClaimKey('user-selected'), value);
|
|
285
|
+
}
|
|
286
|
+
/** Returns the generic `<ResourceType>.user-selected` flag when present. */
|
|
287
|
+
getUserSelected() {
|
|
288
|
+
return this.getBooleanClaim(this.getResourceScopedClaimKey('user-selected'));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Reduced Observation component-style editor surface.
|
|
293
|
+
*
|
|
294
|
+
* This base layer owns the reusable code/value authoring helpers shared by
|
|
295
|
+
* Vital Signs and broader Observation entry editors.
|
|
296
|
+
*/
|
|
@@ -29,6 +29,14 @@ export type ClinicalResourceExpandedView = Readonly<{
|
|
|
29
29
|
xhtml?: string;
|
|
30
30
|
notes: string[];
|
|
31
31
|
}>;
|
|
32
|
+
/** UI-ready summary for one Composition section and its resolved entries. */
|
|
33
|
+
export type ClinicalSectionView = Readonly<{
|
|
34
|
+
code?: string;
|
|
35
|
+
title: string;
|
|
36
|
+
emptyReason?: string;
|
|
37
|
+
resources: ClinicalResourceCardView[];
|
|
38
|
+
unresolvedReferences: string[];
|
|
39
|
+
}>;
|
|
32
40
|
export type ClinicalResourceLike = Readonly<{
|
|
33
41
|
resourceType?: string;
|
|
34
42
|
text?: {
|
|
@@ -87,6 +95,14 @@ export declare function toClinicalResourceExpandedView(entry: ClinicalResourceEn
|
|
|
87
95
|
* Maps all entries from a Bundle into expanded views.
|
|
88
96
|
*/
|
|
89
97
|
export declare function toClinicalResourceExpandedViews(bundle: ClinicalResourceBundleLike): ClinicalResourceExpandedView[];
|
|
98
|
+
/**
|
|
99
|
+
* Builds section cards from the references authored in an IPS Composition.
|
|
100
|
+
*
|
|
101
|
+
* The Composition is authoritative for grouping. Resource type is deliberately
|
|
102
|
+
* not used to guess a section because Observation and supporting resources can
|
|
103
|
+
* be referenced from several IPS sections.
|
|
104
|
+
*/
|
|
105
|
+
export declare function toClinicalSectionViews(bundle: ClinicalResourceBundleLike): ClinicalSectionView[];
|
|
90
106
|
/**
|
|
91
107
|
* Returns the most useful local text plus international display pair that can
|
|
92
108
|
* be inferred from one FHIR-like resource and its `meta.claims`.
|