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,8 +1,9 @@
1
1
  // Copyright 2026 Conectate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
2
+ import { DidcommMessageTypes } from '../constants/didcomm.js';
2
3
  import { CommunicationClaim } from '../models/interoperable-claims/communication-claims.js';
3
4
  import { transformCommunicationClaimsToResourceFhirR4 } from './communication-fhir-r4.js';
4
5
  export const CommunicationDidcommEntryTypes = Object.freeze({
5
- AttachedBundle: 'Communication-attached-bundle-v1.0',
6
+ AttachedBundle: DidcommMessageTypes.CommunicationAttachedBundle,
6
7
  });
7
8
  function clone(value) {
8
9
  return JSON.parse(JSON.stringify(value));
@@ -45,23 +46,32 @@ export function buildDidcommPayloadFromCommunicationClaims(input) {
45
46
  * one DIDComm-style payload.
46
47
  */
47
48
  export function getFirstCommunicationClaimsFromDidcommPayload(payload) {
48
- const first = Array.isArray(payload?.body?.data) ? payload.body.data[0] : undefined;
49
- const metaClaims = first?.meta && typeof first.meta === 'object'
50
- ? first.meta['claims']
51
- : undefined;
52
- if (metaClaims && typeof metaClaims === 'object') {
53
- return clone(metaClaims);
54
- }
55
- const resource = first?.resource && typeof first.resource === 'object'
56
- ? first.resource
57
- : {};
58
- const meta = resource.meta && typeof resource.meta === 'object'
59
- ? resource.meta
60
- : {};
61
- const claims = meta.claims && typeof meta.claims === 'object'
62
- ? meta.claims
63
- : {};
64
- return clone(claims);
49
+ return getCommunicationClaimsListFromDidcommPayload(payload)[0] || {};
50
+ }
51
+ /**
52
+ * Reads canonical communication claims from every `body.data[]` entry of one
53
+ * DIDComm-style payload.
54
+ */
55
+ export function getCommunicationClaimsListFromDidcommPayload(payload) {
56
+ const entries = Array.isArray(payload?.body?.data) ? payload.body.data : [];
57
+ return entries.map((first) => {
58
+ const metaClaims = first?.meta && typeof first.meta === 'object'
59
+ ? first.meta['claims']
60
+ : undefined;
61
+ if (metaClaims && typeof metaClaims === 'object') {
62
+ return clone(metaClaims);
63
+ }
64
+ const resource = first?.resource && typeof first.resource === 'object'
65
+ ? first.resource
66
+ : {};
67
+ const meta = resource.meta && typeof resource.meta === 'object'
68
+ ? resource.meta
69
+ : {};
70
+ const claims = meta.claims && typeof meta.claims === 'object'
71
+ ? meta.claims
72
+ : {};
73
+ return clone(claims);
74
+ });
65
75
  }
66
76
  /**
67
77
  * Decodes the attached bundle carried in `Communication.content-attachment-data`.
@@ -25,6 +25,18 @@ export type BuildDocumentReferenceResult = {
25
25
  evidence: EvidenceObjectDLT[];
26
26
  warnings: string[];
27
27
  };
28
+ export type BlockchainArtifactDocumentReferenceInput = Readonly<{
29
+ subject: string;
30
+ resource?: Record<string, unknown>;
31
+ contentDataBase64?: string;
32
+ contentType?: string;
33
+ identifier?: string;
34
+ title?: string;
35
+ description?: string;
36
+ date?: string;
37
+ location?: string;
38
+ language?: string;
39
+ }>;
28
40
  /**
29
41
  * Detects the logical attachment kind from a MIME type.
30
42
  *
@@ -39,3 +51,14 @@ export declare function detectAttachmentKind(contentType?: string): AttachmentKi
39
51
  * @param options.mode `strict` throws on invalid input, `normalize` applies best-effort defaults.
40
52
  */
41
53
  export declare function buildDocumentReferenceFromCommunicationPayload(communication: Record<string, any>, options?: BuildDocumentReferenceOptions): BuildDocumentReferenceResult;
54
+ /**
55
+ * Builds a blockchain-ready `DocumentReference` projection from either a FHIR
56
+ * resource or already-encoded attachment bytes.
57
+ *
58
+ * The resulting projection keeps two identifiers distinct:
59
+ * - `contentCid`: canonical content address used for blockchain registration
60
+ * - `documentReference.identifier`: optional business identifier supplied by the caller
61
+ *
62
+ * @param input Source artifact data to wrap.
63
+ */
64
+ export declare function buildBlockchainArtifactDocumentReference(input: BlockchainArtifactDocumentReferenceInput): BuildDocumentReferenceResult;
@@ -38,6 +38,9 @@ function cidFromBytes(bytes) {
38
38
  function decodeBase64(data) {
39
39
  return Uint8Array.from(Buffer.from(data, 'base64'));
40
40
  }
41
+ function encodeBase64Utf8(data) {
42
+ return Buffer.from(data, 'utf8').toString('base64');
43
+ }
41
44
  function toStringOrUndefined(value) {
42
45
  if (value === undefined || value === null)
43
46
  return undefined;
@@ -168,3 +171,89 @@ export function buildDocumentReferenceFromCommunicationPayload(communication, op
168
171
  warnings,
169
172
  };
170
173
  }
174
+ /**
175
+ * Builds a blockchain-ready `DocumentReference` projection from either a FHIR
176
+ * resource or already-encoded attachment bytes.
177
+ *
178
+ * The resulting projection keeps two identifiers distinct:
179
+ * - `contentCid`: canonical content address used for blockchain registration
180
+ * - `documentReference.identifier`: optional business identifier supplied by the caller
181
+ *
182
+ * @param input Source artifact data to wrap.
183
+ */
184
+ export function buildBlockchainArtifactDocumentReference(input) {
185
+ const subject = toStringOrUndefined(input.subject);
186
+ if (!subject) {
187
+ throw new Error('buildBlockchainArtifactDocumentReference requires subject.');
188
+ }
189
+ const resource = input.resource;
190
+ const hasResource = !!resource && typeof resource === 'object' && !Array.isArray(resource);
191
+ const contentType = toStringOrUndefined(input.contentType) || (hasResource ? 'application/fhir+json' : 'application/octet-stream');
192
+ const title = toStringOrUndefined(input.title) || (hasResource
193
+ ? `${String(resource.resourceType || 'resource').toLowerCase()}.json`
194
+ : 'artifact.bin');
195
+ let contentDataBase64 = toStringOrUndefined(input.contentDataBase64);
196
+ let contentCid;
197
+ let communicationLike;
198
+ if (hasResource) {
199
+ const serialized = JSON.stringify(resource);
200
+ contentDataBase64 = encodeBase64Utf8(serialized);
201
+ contentCid = fhirResourceToCid(resource).cid;
202
+ communicationLike = {
203
+ resourceType: 'Communication',
204
+ meta: { claims: { [CommunicationClaim.Subject]: subject } },
205
+ payload: [{ contentAttachment: { contentType, data: contentDataBase64, title } }],
206
+ };
207
+ }
208
+ else {
209
+ if (!contentDataBase64) {
210
+ throw new Error('buildBlockchainArtifactDocumentReference requires contentDataBase64 when resource is absent.');
211
+ }
212
+ contentCid = cidFromBytes(decodeBase64(contentDataBase64));
213
+ communicationLike = {
214
+ resourceType: 'Communication',
215
+ meta: { claims: { [CommunicationClaim.Subject]: subject } },
216
+ payload: [{ contentAttachment: { contentType, data: contentDataBase64, title, url: input.location } }],
217
+ };
218
+ }
219
+ const result = buildDocumentReferenceFromCommunicationPayload(communicationLike, { mode: 'strict' });
220
+ const logicalIdentifier = toStringOrUndefined(input.identifier) || contentCid;
221
+ const documentReference = {
222
+ ...result.documentReference,
223
+ identifier: logicalIdentifier ? [{ value: logicalIdentifier }] : undefined,
224
+ description: toStringOrUndefined(input.description) || result.documentReference.description,
225
+ date: toStringOrUndefined(input.date) || result.documentReference.date,
226
+ content: [{
227
+ attachment: {
228
+ ...(result.documentReference.content?.[0]?.attachment || {}),
229
+ contentType,
230
+ data: contentDataBase64,
231
+ url: toStringOrUndefined(input.location) || result.documentReference.content?.[0]?.attachment?.url,
232
+ title,
233
+ language: toStringOrUndefined(input.language) || result.documentReference.content?.[0]?.attachment?.language,
234
+ hash: contentCid,
235
+ },
236
+ }],
237
+ meta: {
238
+ ...(result.documentReference.meta || {}),
239
+ versionId: contentCid,
240
+ claims: {
241
+ ...((result.documentReference.meta || {}).claims || {}),
242
+ [DocumentReferenceClaim.Identifier]: logicalIdentifier,
243
+ [DocumentReferenceClaim.ContentHash]: contentCid,
244
+ [DocumentReferenceClaim.ContentData]: contentDataBase64,
245
+ [DocumentReferenceClaim.ContentType]: contentType,
246
+ [DocumentReferenceClaim.Subject]: subject,
247
+ ...(toStringOrUndefined(input.description) ? { [DocumentReferenceClaim.Description]: input.description } : {}),
248
+ ...(toStringOrUndefined(input.date) ? { [DocumentReferenceClaim.Date]: input.date } : {}),
249
+ ...(toStringOrUndefined(input.location) ? { [DocumentReferenceClaim.Location]: input.location } : {}),
250
+ ...(toStringOrUndefined(input.language) ? { [DocumentReferenceClaim.Language]: input.language } : {}),
251
+ },
252
+ },
253
+ };
254
+ return {
255
+ ...result,
256
+ contentCid,
257
+ documentReference,
258
+ };
259
+ }
@@ -0,0 +1,53 @@
1
+ import type { BundleEntry, BundleJsonApi } from '../models/bundle';
2
+ import type { BundleResourceIdFilters } from './bundle-query';
3
+ import { type CommunicationAttachedBundleSessionMode } from '../models/communication-attached-bundle-session';
4
+ import { BundleReader } from './bundle-reader';
5
+ import { CommunicationAttachedBundleSession } from './communication-attached-bundle-session';
6
+ import type { IDecodedDidcommPayload } from '../models/confidential-message';
7
+ export type CommunicationEditorOptions = Readonly<{
8
+ initialBundle?: BundleJsonApi<BundleEntry>;
9
+ mode?: CommunicationAttachedBundleSessionMode;
10
+ communicationClaims?: Record<string, unknown>;
11
+ }>;
12
+ /**
13
+ * Public high-level editor for one delivery `Communication`.
14
+ *
15
+ * Teaching contract:
16
+ * - use this name in tutorials when the caller is authoring one outer
17
+ * `Communication`
18
+ * - keep `CommunicationAttachedBundleSession` as the lower-level compatibility
19
+ * implementation detail underneath
20
+ */
21
+ export declare class CommunicationEditor extends CommunicationAttachedBundleSession {
22
+ constructor(options?: CommunicationEditorOptions);
23
+ /** Materializes one immutable snapshot of the current Communication claims. */
24
+ done(): Record<string, unknown>;
25
+ /** Returns one reader over the current Communication snapshot. */
26
+ toReader(): CommunicationReader;
27
+ }
28
+ /**
29
+ * Public high-level reader for one delivery `Communication`.
30
+ */
31
+ export declare class CommunicationReader {
32
+ private readonly session;
33
+ constructor(communicationClaims: Record<string, unknown>);
34
+ /** Reads the first delivery `Communication` carried in one DIDComm/plain payload. */
35
+ static fromDidcommPayload(payload: IDecodedDidcommPayload): CommunicationReader;
36
+ /** Reads every delivery `Communication` carried in one DIDComm/plain payload. */
37
+ static listFromDidcommPayload(payload: IDecodedDidcommPayload): CommunicationReader[];
38
+ getCommunicationClaims(): Record<string, unknown>;
39
+ getCommunicationIdentifier(): string;
40
+ getCommunicationSubject(): string;
41
+ getCommunicationCategoryList(): string[];
42
+ getCommunicationTopic(): string;
43
+ getCommunicationText(): string;
44
+ getAttachmentContentType(): string;
45
+ getAttachmentTitle(): string;
46
+ getAttachmentUrl(): string;
47
+ getAttachmentDataBase64(): string;
48
+ getAttachedBundle(): BundleJsonApi<BundleEntry>;
49
+ getAttachedBundleReader(): BundleReader;
50
+ getAttachedBundleResourceIds(filters?: BundleResourceIdFilters): string[];
51
+ getAttachedBundleEntriesByIds(resourceIds: readonly string[]): BundleEntry[];
52
+ getAttachedBundleEntryUrl(resourceId: string): string | undefined;
53
+ }
@@ -0,0 +1,97 @@
1
+ // Copyright 2026 Conectate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
2
+ import { CommunicationClaimsContext, } from '../models/communication-attached-bundle-session.js';
3
+ import { BundleReader } from './bundle-reader.js';
4
+ import { CommunicationAttachedBundleSession } from './communication-attached-bundle-session.js';
5
+ import { getCommunicationClaimsListFromDidcommPayload, getFirstCommunicationClaimsFromDidcommPayload, } from './communication-didcomm-payload.js';
6
+ import { CommunicationClaim } from '../models/interoperable-claims/communication-claims.js';
7
+ /**
8
+ * Public high-level editor for one delivery `Communication`.
9
+ *
10
+ * Teaching contract:
11
+ * - use this name in tutorials when the caller is authoring one outer
12
+ * `Communication`
13
+ * - keep `CommunicationAttachedBundleSession` as the lower-level compatibility
14
+ * implementation detail underneath
15
+ */
16
+ export class CommunicationEditor extends CommunicationAttachedBundleSession {
17
+ constructor(options = {}) {
18
+ super({
19
+ ...options,
20
+ communicationClaims: {
21
+ '@context': CommunicationClaimsContext,
22
+ ...(options.communicationClaims || {}),
23
+ },
24
+ });
25
+ }
26
+ /** Materializes one immutable snapshot of the current Communication claims. */
27
+ done() {
28
+ return this.getCommunicationClaims();
29
+ }
30
+ /** Returns one reader over the current Communication snapshot. */
31
+ toReader() {
32
+ return new CommunicationReader(this.getCommunicationClaims());
33
+ }
34
+ }
35
+ /**
36
+ * Public high-level reader for one delivery `Communication`.
37
+ */
38
+ export class CommunicationReader {
39
+ session;
40
+ constructor(communicationClaims) {
41
+ this.session = new CommunicationAttachedBundleSession({ communicationClaims });
42
+ }
43
+ /** Reads the first delivery `Communication` carried in one DIDComm/plain payload. */
44
+ static fromDidcommPayload(payload) {
45
+ return new CommunicationReader(getFirstCommunicationClaimsFromDidcommPayload(payload));
46
+ }
47
+ /** Reads every delivery `Communication` carried in one DIDComm/plain payload. */
48
+ static listFromDidcommPayload(payload) {
49
+ return getCommunicationClaimsListFromDidcommPayload(payload)
50
+ .map((communicationClaims) => new CommunicationReader(communicationClaims));
51
+ }
52
+ getCommunicationClaims() {
53
+ return this.session.getCommunicationClaims();
54
+ }
55
+ getCommunicationIdentifier() {
56
+ return this.session.getCommunicationIdentifier();
57
+ }
58
+ getCommunicationSubject() {
59
+ return this.session.getCommunicationSubject();
60
+ }
61
+ getCommunicationCategoryList() {
62
+ return this.session.getCommunicationCategoryList();
63
+ }
64
+ getCommunicationTopic() {
65
+ return this.session.getCommunicationTopic();
66
+ }
67
+ getCommunicationText() {
68
+ return this.session.getCommunicationText();
69
+ }
70
+ getAttachmentContentType() {
71
+ return String(this.getCommunicationClaims()[CommunicationClaim.ContentAttachmentType] || '').trim();
72
+ }
73
+ getAttachmentTitle() {
74
+ return String(this.getCommunicationClaims()[CommunicationClaim.ContentAttachmentTitle] || '').trim();
75
+ }
76
+ getAttachmentUrl() {
77
+ return String(this.getCommunicationClaims()[CommunicationClaim.ContentAttachmentUrl] || '').trim();
78
+ }
79
+ getAttachmentDataBase64() {
80
+ return String(this.getCommunicationClaims()[CommunicationClaim.ContentAttachmentData] || '').trim();
81
+ }
82
+ getAttachedBundle() {
83
+ return this.session.getAttachedBundle();
84
+ }
85
+ getAttachedBundleReader() {
86
+ return new BundleReader(this.getAttachedBundle());
87
+ }
88
+ getAttachedBundleResourceIds(filters = {}) {
89
+ return this.getAttachedBundleReader().getResourceIds(filters);
90
+ }
91
+ getAttachedBundleEntriesByIds(resourceIds) {
92
+ return this.getAttachedBundleReader().getEntriesByIds(resourceIds);
93
+ }
94
+ getAttachedBundleEntryUrl(resourceId) {
95
+ return this.getAttachedBundleReader().getEntryUrl(resourceId);
96
+ }
97
+ }
@@ -0,0 +1,30 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor';
2
+ /**
3
+ * Typed editor for one staged Condition resource entry.
4
+ *
5
+ * Use this when a caller needs to stage one condition row with claims-first
6
+ * accessors in a bundle authoring flow.
7
+ */
8
+ export declare class ConditionEntryEditor extends ClinicalResourceEntryEditor {
9
+ setIdentifier(identifier?: string | null): this;
10
+ getIdentifier(): string | undefined;
11
+ ensureIdentifier(): string;
12
+ setSubject(subject?: string | null): this;
13
+ getSubject(): string | undefined;
14
+ setCode(code?: string | null): this;
15
+ getCode(): string | undefined;
16
+ setClinicalStatus(status?: string | null): this;
17
+ getClinicalStatus(): string | undefined;
18
+ setVerificationStatus(status?: string | null): this;
19
+ getVerificationStatus(): string | undefined;
20
+ setCategory(category?: string | null): this;
21
+ getCategory(): string | undefined;
22
+ setSeverity(severity?: string | null): this;
23
+ getSeverity(): string | undefined;
24
+ setOnsetDateTime(value?: string | null): this;
25
+ getOnsetDateTime(): string | undefined;
26
+ setRecorder(reference?: string | null): this;
27
+ getRecorder(): string | undefined;
28
+ setContainedDocumentIdentifierList(identifiers: readonly string[]): this;
29
+ getContainedDocumentIdentifierList(): string[];
30
+ }
@@ -0,0 +1,34 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor.js';
2
+ import { ConditionClaim } from '../models/interoperable-claims/condition-claims.js';
3
+ import { BundleEditableResourceTypes } from '../models/bundle-editor-types.js';
4
+ import { registerBundleEntryEditor } from './bundle-editor-registry.js';
5
+ /**
6
+ * Typed editor for one staged Condition resource entry.
7
+ *
8
+ * Use this when a caller needs to stage one condition row with claims-first
9
+ * accessors in a bundle authoring flow.
10
+ */
11
+ export class ConditionEntryEditor extends ClinicalResourceEntryEditor {
12
+ setIdentifier(identifier) { return this.setIdentifierValue(ConditionClaim.Identifier, identifier); }
13
+ getIdentifier() { return this.getIdentifierValue(ConditionClaim.Identifier); }
14
+ ensureIdentifier() { return this.ensureIdentifierValue(ConditionClaim.Identifier); }
15
+ setSubject(subject) { return this.setSubjectClaims(ConditionClaim.Subject, ConditionClaim.Subject, subject); }
16
+ getSubject() { return this.getSubjectClaims(ConditionClaim.Subject, ConditionClaim.Subject); }
17
+ setCode(code) { return this.setScalarClaim(ConditionClaim.Code, code); }
18
+ getCode() { return this.getScalarClaim(ConditionClaim.Code); }
19
+ setClinicalStatus(status) { return this.setScalarClaim(ConditionClaim.ClinicalStatus, status); }
20
+ getClinicalStatus() { return this.getScalarClaim(ConditionClaim.ClinicalStatus); }
21
+ setVerificationStatus(status) { return this.setScalarClaim(ConditionClaim.VerificationStatus, status); }
22
+ getVerificationStatus() { return this.getScalarClaim(ConditionClaim.VerificationStatus); }
23
+ setCategory(category) { return this.setScalarClaim(ConditionClaim.Category, category); }
24
+ getCategory() { return this.getScalarClaim(ConditionClaim.Category); }
25
+ setSeverity(severity) { return this.setScalarClaim(ConditionClaim.Severity, severity); }
26
+ getSeverity() { return this.getScalarClaim(ConditionClaim.Severity); }
27
+ setOnsetDateTime(value) { return this.setScalarClaim(ConditionClaim.OnsetDateTime, value); }
28
+ getOnsetDateTime() { return this.getScalarClaim(ConditionClaim.OnsetDateTime); }
29
+ setRecorder(reference) { return this.setScalarClaim(ConditionClaim.Recorder, reference); }
30
+ getRecorder() { return this.getScalarClaim(ConditionClaim.Recorder); }
31
+ setContainedDocumentIdentifierList(identifiers) { return this.setCsvClaimList(ConditionClaim.ContainedDocuments, identifiers); }
32
+ getContainedDocumentIdentifierList() { return this.getCsvClaimList(ConditionClaim.ContainedDocuments); }
33
+ }
34
+ registerBundleEntryEditor(BundleEditableResourceTypes.condition, ConditionEntryEditor);
@@ -77,9 +77,13 @@ export declare function removeSectors(claims: InteroperableClaims, values: strin
77
77
  * Returns linked DocumentReference identifiers carried by the consent.
78
78
  */
79
79
  export declare function getContainedDocumentIdentifierList(claims: InteroperableClaims): string[];
80
+ export declare function getContainedResourceReferenceList(claims: InteroperableClaims): string[];
80
81
  export declare function setContainedDocumentIdentifierList(claims: InteroperableClaims, values: string | readonly string[]): InteroperableClaims;
82
+ export declare function setContainedResourceReferenceList(claims: InteroperableClaims, values: string | readonly string[]): InteroperableClaims;
81
83
  export declare function addContainedDocumentIdentifierList(claims: InteroperableClaims, values: string | readonly string[]): InteroperableClaims;
82
84
  export declare function removeContainedDocumentIdentifierList(claims: InteroperableClaims, values: string | readonly string[]): InteroperableClaims;
85
+ export declare function addContainedResourceReferenceList(claims: InteroperableClaims, values: string | readonly string[]): InteroperableClaims;
86
+ export declare function removeContainedResourceReferenceList(claims: InteroperableClaims, values: string | readonly string[]): InteroperableClaims;
83
87
  /**
84
88
  * Reads the canonical consent date claim.
85
89
  */
@@ -167,13 +167,20 @@ export function removeSectors(claims, values) {
167
167
  */
168
168
  export function getContainedDocumentIdentifierList(claims) {
169
169
  return uniqueCsvLists([
170
+ getClaimValues(claims, ClaimConsent.containedReferenceList),
170
171
  getClaimValues(claims, ClaimConsent.containedDocuments),
171
172
  getClaimValues(claims, ClaimConsent.attachmentContentIds),
172
173
  ]);
173
174
  }
175
+ export function getContainedResourceReferenceList(claims) {
176
+ return getContainedDocumentIdentifierList(claims);
177
+ }
174
178
  export function setContainedDocumentIdentifierList(claims, values) {
175
179
  return setContainedDocuments(claims, values);
176
180
  }
181
+ export function setContainedResourceReferenceList(claims, values) {
182
+ return setContainedDocuments(claims, values);
183
+ }
177
184
  export function addContainedDocumentIdentifierList(claims, values) {
178
185
  return setContainedDocuments(claims, uniqueCsvLists([
179
186
  getContainedDocumentIdentifierList(claims),
@@ -186,11 +193,18 @@ export function removeContainedDocumentIdentifierList(claims, values) {
186
193
  .filter(Boolean));
187
194
  return setContainedDocuments(claims, getContainedDocumentIdentifierList(claims).filter((item) => !toRemove.has(item)));
188
195
  }
196
+ export function addContainedResourceReferenceList(claims, values) {
197
+ return addContainedDocumentIdentifierList(claims, values);
198
+ }
199
+ export function removeContainedResourceReferenceList(claims, values) {
200
+ return removeContainedDocumentIdentifierList(claims, values);
201
+ }
189
202
  function setContainedDocuments(claims, values) {
190
- const next = setClaimValues(claims, ClaimConsent.containedDocuments, values);
203
+ const next = setClaimValues(claims, ClaimConsent.containedReferenceList, values);
191
204
  const cleaned = {
192
205
  ...next,
193
206
  };
207
+ delete cleaned[ClaimConsent.containedDocuments];
194
208
  delete cleaned[ClaimConsent.attachmentContentIds];
195
209
  return cleaned;
196
210
  }
@@ -0,0 +1,51 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor';
2
+ /**
3
+ * Typed editor for one staged Coverage resource entry.
4
+ *
5
+ * Use this when a caller needs to stage one coverage row with claims-first
6
+ * accessors in a bundle authoring flow.
7
+ */
8
+ export declare class CoverageEntryEditor extends ClinicalResourceEntryEditor {
9
+ /** Writes the canonical coverage identifier. */
10
+ setIdentifier(identifier?: string | null): this;
11
+ /** Reads the canonical coverage identifier. */
12
+ getIdentifier(): string | undefined;
13
+ /** Ensures the coverage entry has one canonical `urn:uuid:*` identifier. */
14
+ ensureIdentifier(): string;
15
+ /** Writes the coverage status. */
16
+ setStatus(value?: string | null): this;
17
+ /** Reads the coverage status. */
18
+ getStatus(): string | undefined;
19
+ /** Writes the coverage type. */
20
+ setType(value?: string | null): this;
21
+ /** Reads the coverage type. */
22
+ getType(): string | undefined;
23
+ /** Writes the policy-holder reference. */
24
+ setPolicyHolder(value?: string | null): this;
25
+ /** Reads the policy-holder reference. */
26
+ getPolicyHolder(): string | undefined;
27
+ /** Writes the subscriber reference. */
28
+ setSubscriber(value?: string | null): this;
29
+ /** Reads the subscriber reference. */
30
+ getSubscriber(): string | undefined;
31
+ /** Writes the beneficiary reference. */
32
+ setBeneficiary(value?: string | null): this;
33
+ /** Reads the beneficiary reference. */
34
+ getBeneficiary(): string | undefined;
35
+ /** Writes the subscriber relationship. */
36
+ setRelationship(value?: string | null): this;
37
+ /** Reads the subscriber relationship. */
38
+ getRelationship(): string | undefined;
39
+ /** Writes the coverage period start. */
40
+ setPeriodStart(value?: string | null): this;
41
+ /** Reads the coverage period start. */
42
+ getPeriodStart(): string | undefined;
43
+ /** Writes the coverage period end. */
44
+ setPeriodEnd(value?: string | null): this;
45
+ /** Reads the coverage period end. */
46
+ getPeriodEnd(): string | undefined;
47
+ /** Writes the payor list. */
48
+ setPayorList(values: readonly string[]): this;
49
+ /** Reads the payor list. */
50
+ getPayorList(): string[];
51
+ }
@@ -0,0 +1,55 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor.js';
2
+ import { CoverageClaim } from '../models/interoperable-claims/coverage-claims.js';
3
+ import { BundleEditableResourceTypes } from '../models/bundle-editor-types.js';
4
+ import { registerBundleEntryEditor } from './bundle-editor-registry.js';
5
+ /**
6
+ * Typed editor for one staged Coverage resource entry.
7
+ *
8
+ * Use this when a caller needs to stage one coverage row with claims-first
9
+ * accessors in a bundle authoring flow.
10
+ */
11
+ export class CoverageEntryEditor extends ClinicalResourceEntryEditor {
12
+ /** Writes the canonical coverage identifier. */
13
+ setIdentifier(identifier) { return this.setIdentifierValue(CoverageClaim.Identifier, identifier); }
14
+ /** Reads the canonical coverage identifier. */
15
+ getIdentifier() { return this.getIdentifierValue(CoverageClaim.Identifier); }
16
+ /** Ensures the coverage entry has one canonical `urn:uuid:*` identifier. */
17
+ ensureIdentifier() { return this.ensureIdentifierValue(CoverageClaim.Identifier); }
18
+ /** Writes the coverage status. */
19
+ setStatus(value) { return this.setScalarClaim(CoverageClaim.Status, value); }
20
+ /** Reads the coverage status. */
21
+ getStatus() { return this.getScalarClaim(CoverageClaim.Status); }
22
+ /** Writes the coverage type. */
23
+ setType(value) { return this.setScalarClaim(CoverageClaim.Type, value); }
24
+ /** Reads the coverage type. */
25
+ getType() { return this.getScalarClaim(CoverageClaim.Type); }
26
+ /** Writes the policy-holder reference. */
27
+ setPolicyHolder(value) { return this.setScalarClaim(CoverageClaim.PolicyHolder, value); }
28
+ /** Reads the policy-holder reference. */
29
+ getPolicyHolder() { return this.getScalarClaim(CoverageClaim.PolicyHolder); }
30
+ /** Writes the subscriber reference. */
31
+ setSubscriber(value) { return this.setScalarClaim(CoverageClaim.Subscriber, value); }
32
+ /** Reads the subscriber reference. */
33
+ getSubscriber() { return this.getScalarClaim(CoverageClaim.Subscriber); }
34
+ /** Writes the beneficiary reference. */
35
+ setBeneficiary(value) { return this.setScalarClaim(CoverageClaim.Beneficiary, value); }
36
+ /** Reads the beneficiary reference. */
37
+ getBeneficiary() { return this.getScalarClaim(CoverageClaim.Beneficiary); }
38
+ /** Writes the subscriber relationship. */
39
+ setRelationship(value) { return this.setScalarClaim(CoverageClaim.Relationship, value); }
40
+ /** Reads the subscriber relationship. */
41
+ getRelationship() { return this.getScalarClaim(CoverageClaim.Relationship); }
42
+ /** Writes the coverage period start. */
43
+ setPeriodStart(value) { return this.setScalarClaim(CoverageClaim.PeriodStart, value); }
44
+ /** Reads the coverage period start. */
45
+ getPeriodStart() { return this.getScalarClaim(CoverageClaim.PeriodStart); }
46
+ /** Writes the coverage period end. */
47
+ setPeriodEnd(value) { return this.setScalarClaim(CoverageClaim.PeriodEnd, value); }
48
+ /** Reads the coverage period end. */
49
+ getPeriodEnd() { return this.getScalarClaim(CoverageClaim.PeriodEnd); }
50
+ /** Writes the payor list. */
51
+ setPayorList(values) { return this.setCsvClaimList(CoverageClaim.Payor, values); }
52
+ /** Reads the payor list. */
53
+ getPayorList() { return this.getCsvClaimList(CoverageClaim.Payor); }
54
+ }
55
+ registerBundleEntryEditor(BundleEditableResourceTypes.coverage, CoverageEntryEditor);
@@ -0,0 +1,59 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor';
2
+ /**
3
+ * Typed editor for one staged Device resource entry.
4
+ *
5
+ * Use this when a caller needs to stage one device row with claims-first
6
+ * accessors in a bundle authoring flow.
7
+ */
8
+ export declare class DeviceEntryEditor extends ClinicalResourceEntryEditor {
9
+ /** Writes the canonical device identifier. */
10
+ setIdentifier(identifier?: string | null): this;
11
+ /** Reads the canonical device identifier. */
12
+ getIdentifier(): string | undefined;
13
+ /** Ensures the device entry has one canonical `urn:uuid:*` identifier. */
14
+ ensureIdentifier(): string;
15
+ /** Writes the patient reference for the device. */
16
+ setPatient(value?: string | null): this;
17
+ /** Reads the patient reference for the device. */
18
+ getPatient(): string | undefined;
19
+ /** Writes the device status. */
20
+ setStatus(value?: string | null): this;
21
+ /** Reads the device status. */
22
+ getStatus(): string | undefined;
23
+ /** Writes the device type. */
24
+ setType(value?: string | null): this;
25
+ /** Reads the device type. */
26
+ getType(): string | undefined;
27
+ /** Writes the manufacturer reference. */
28
+ setManufacturer(value?: string | null): this;
29
+ /** Reads the manufacturer reference. */
30
+ getManufacturer(): string | undefined;
31
+ /** Writes the model. */
32
+ setModel(value?: string | null): this;
33
+ /** Reads the model. */
34
+ getModel(): string | undefined;
35
+ /** Writes the human-readable device name. */
36
+ setDeviceName(value?: string | null): this;
37
+ /** Reads the human-readable device name. */
38
+ getDeviceName(): string | undefined;
39
+ /** Writes the serial number. */
40
+ setSerialNumber(value?: string | null): this;
41
+ /** Reads the serial number. */
42
+ getSerialNumber(): string | undefined;
43
+ /** Writes the owning organization. */
44
+ setOrganization(value?: string | null): this;
45
+ /** Reads the owning organization. */
46
+ getOrganization(): string | undefined;
47
+ /** Writes the location reference. */
48
+ setLocation(value?: string | null): this;
49
+ /** Reads the location reference. */
50
+ getLocation(): string | undefined;
51
+ /** Writes the URL reference. */
52
+ setUrl(value?: string | null): this;
53
+ /** Reads the URL reference. */
54
+ getUrl(): string | undefined;
55
+ /** Writes the note text. */
56
+ setNote(value?: string | null): this;
57
+ /** Reads the note text. */
58
+ getNote(): string | undefined;
59
+ }