gdc-common-utils-ts 2.0.18 → 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 (185) hide show
  1. package/README.md +18 -1
  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.d.ts +11 -0
  23. package/dist/examples/bundle-didcomm-payload.js +15 -0
  24. package/dist/examples/communication-attached-bundle-session.js +28 -27
  25. package/dist/examples/communication-didcomm-payload.d.ts +39 -0
  26. package/dist/examples/communication-didcomm-payload.js +44 -0
  27. package/dist/examples/consent-access.js +2 -1
  28. package/dist/examples/employee.d.ts +21 -0
  29. package/dist/examples/employee.js +21 -0
  30. package/dist/examples/index.d.ts +4 -0
  31. package/dist/examples/index.js +4 -0
  32. package/dist/examples/individual-controller.d.ts +27 -0
  33. package/dist/examples/individual-controller.js +28 -1
  34. package/dist/examples/inter-tenant-access-contract.js +3 -2
  35. package/dist/examples/ips-bundle.js +17 -16
  36. package/dist/examples/lifecycle.js +13 -11
  37. package/dist/examples/profile-manager-mem.d.ts +45 -0
  38. package/dist/examples/profile-manager-mem.js +30 -0
  39. package/dist/examples/related-person.d.ts +14 -0
  40. package/dist/examples/related-person.js +18 -4
  41. package/dist/examples/shared.d.ts +13 -3
  42. package/dist/examples/shared.js +14 -4
  43. package/dist/examples/vital-signs.js +1 -1
  44. package/dist/examples/wallet-mem.d.ts +38 -0
  45. package/dist/examples/wallet-mem.js +42 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.js +1 -0
  48. package/dist/interfaces/IProfileOutboxRepository.d.ts +36 -0
  49. package/dist/interfaces/IProfileOutboxRepository.js +2 -0
  50. package/dist/interfaces/IWallet.d.ts +74 -0
  51. package/dist/interfaces/IWallet.js +2 -0
  52. package/dist/interfaces/IWalletQueue.d.ts +30 -0
  53. package/dist/interfaces/IWalletQueue.js +2 -0
  54. package/dist/interfaces/index.d.ts +8 -0
  55. package/dist/interfaces/index.js +8 -0
  56. package/dist/models/authority-resolution.d.ts +56 -0
  57. package/dist/models/authority-resolution.js +2 -0
  58. package/dist/models/bundle-editor-types.d.ts +89 -0
  59. package/dist/models/bundle-editor-types.js +45 -0
  60. package/dist/models/bundle.d.ts +5 -0
  61. package/dist/models/communication-attached-bundle-session.d.ts +195 -0
  62. package/dist/models/communication-attached-bundle-session.js +36 -0
  63. package/dist/models/confidential-storage.d.ts +2 -1
  64. package/dist/models/consent-rule.d.ts +11 -1
  65. package/dist/models/consent-rule.js +9 -1
  66. package/dist/models/index.d.ts +5 -0
  67. package/dist/models/index.js +5 -0
  68. package/dist/models/individual-onboarding.d.ts +18 -0
  69. package/dist/models/interoperable-claims/allergy-intolerance-claims.d.ts +12 -1
  70. package/dist/models/interoperable-claims/allergy-intolerance-claims.js +12 -1
  71. package/dist/models/interoperable-claims/condition-claims.d.ts +12 -1
  72. package/dist/models/interoperable-claims/condition-claims.js +12 -1
  73. package/dist/models/interoperable-claims/diagnostic-report-claims.d.ts +14 -4
  74. package/dist/models/interoperable-claims/diagnostic-report-claims.js +13 -3
  75. package/dist/models/interoperable-claims/document-reference-claims.d.ts +1 -0
  76. package/dist/models/interoperable-claims/document-reference-claims.js +3 -0
  77. package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
  78. package/dist/models/interoperable-claims/medication-statement-claims.js +17 -0
  79. package/dist/models/profile-manager.d.ts +85 -0
  80. package/dist/models/profile-manager.js +2 -0
  81. package/dist/models/wallet.d.ts +59 -0
  82. package/dist/models/wallet.js +22 -0
  83. package/dist/utils/allergy-intolerance-entry-editor.d.ts +51 -0
  84. package/dist/utils/allergy-intolerance-entry-editor.js +55 -0
  85. package/dist/utils/authority-resolution.d.ts +37 -0
  86. package/dist/utils/authority-resolution.js +112 -0
  87. package/dist/utils/backend-message-manager-mem.d.ts +78 -0
  88. package/dist/utils/backend-message-manager-mem.js +238 -0
  89. package/dist/utils/bundle-didcomm-payload.d.ts +29 -0
  90. package/dist/utils/bundle-didcomm-payload.js +49 -0
  91. package/dist/utils/bundle-document-builder.d.ts +1 -0
  92. package/dist/utils/bundle-document-builder.js +134 -14
  93. package/dist/utils/bundle-editor-core.d.ts +181 -0
  94. package/dist/utils/bundle-editor-core.js +467 -0
  95. package/dist/utils/bundle-editor-helpers.d.ts +53 -0
  96. package/dist/utils/bundle-editor-helpers.js +146 -0
  97. package/dist/utils/bundle-editor-registry.d.ts +6 -0
  98. package/dist/utils/bundle-editor-registry.js +14 -0
  99. package/dist/utils/bundle-editor.d.ts +21 -722
  100. package/dist/utils/bundle-editor.js +21 -1601
  101. package/dist/utils/bundle-entry-editor.d.ts +96 -0
  102. package/dist/utils/bundle-entry-editor.js +305 -0
  103. package/dist/utils/bundle-query.d.ts +1 -0
  104. package/dist/utils/bundle-query.js +12 -3
  105. package/dist/utils/bundle-reader.d.ts +48 -0
  106. package/dist/utils/bundle-reader.js +175 -1
  107. package/dist/utils/care-plan-entry-editor.d.ts +43 -0
  108. package/dist/utils/care-plan-entry-editor.js +47 -0
  109. package/dist/utils/client-assertion.d.ts +38 -0
  110. package/dist/utils/client-assertion.js +113 -0
  111. package/dist/utils/clinical-impression-entry-editor.d.ts +43 -0
  112. package/dist/utils/clinical-impression-entry-editor.js +47 -0
  113. package/dist/utils/clinical-resource-entry-editor.d.ts +123 -0
  114. package/dist/utils/clinical-resource-entry-editor.js +296 -0
  115. package/dist/utils/communication-attached-bundle-session-helpers.d.ts +54 -0
  116. package/dist/utils/communication-attached-bundle-session-helpers.js +519 -0
  117. package/dist/utils/communication-attached-bundle-session.d.ts +87 -304
  118. package/dist/utils/communication-attached-bundle-session.js +175 -841
  119. package/dist/utils/communication-consent-access-editor.d.ts +85 -0
  120. package/dist/utils/communication-consent-access-editor.js +244 -0
  121. package/dist/utils/communication-didcomm-payload.d.ts +38 -0
  122. package/dist/utils/communication-didcomm-payload.js +85 -0
  123. package/dist/utils/communication-document-reference.d.ts +23 -0
  124. package/dist/utils/communication-document-reference.js +89 -0
  125. package/dist/utils/communication-editor.d.ts +53 -0
  126. package/dist/utils/communication-editor.js +97 -0
  127. package/dist/utils/condition-entry-editor.d.ts +30 -0
  128. package/dist/utils/condition-entry-editor.js +34 -0
  129. package/dist/utils/consent-claim-helpers.d.ts +4 -0
  130. package/dist/utils/consent-claim-helpers.js +15 -1
  131. package/dist/utils/coverage-entry-editor.d.ts +51 -0
  132. package/dist/utils/coverage-entry-editor.js +55 -0
  133. package/dist/utils/device-entry-editor.d.ts +59 -0
  134. package/dist/utils/device-entry-editor.js +63 -0
  135. package/dist/utils/device-use-statement-entry-editor.d.ts +43 -0
  136. package/dist/utils/device-use-statement-entry-editor.js +47 -0
  137. package/dist/utils/diagnostic-report-entry-editor.d.ts +74 -0
  138. package/dist/utils/diagnostic-report-entry-editor.js +136 -0
  139. package/dist/utils/did.d.ts +8 -0
  140. package/dist/utils/did.js +22 -0
  141. package/dist/utils/document-reference-entry-editor.d.ts +62 -0
  142. package/dist/utils/document-reference-entry-editor.js +66 -0
  143. package/dist/utils/employee-entry-editor.d.ts +36 -0
  144. package/dist/utils/employee-entry-editor.js +88 -0
  145. package/dist/utils/employee.d.ts +1 -0
  146. package/dist/utils/employee.js +2 -1
  147. package/dist/utils/encounter-entry-editor.d.ts +51 -0
  148. package/dist/utils/encounter-entry-editor.js +55 -0
  149. package/dist/utils/flag-entry-editor.d.ts +47 -0
  150. package/dist/utils/flag-entry-editor.js +51 -0
  151. package/dist/utils/immunization-entry-editor.d.ts +87 -0
  152. package/dist/utils/immunization-entry-editor.js +169 -0
  153. package/dist/utils/index.d.ts +15 -0
  154. package/dist/utils/index.js +15 -0
  155. package/dist/utils/individual-onboarding-acceptance-credential.d.ts +35 -0
  156. package/dist/utils/individual-onboarding-acceptance-credential.js +55 -0
  157. package/dist/utils/individual-smart.d.ts +59 -0
  158. package/dist/utils/individual-smart.js +135 -0
  159. package/dist/utils/medication-statement-entry-editor.d.ts +90 -0
  160. package/dist/utils/medication-statement-entry-editor.js +94 -0
  161. package/dist/utils/observation-component-entry-editor.d.ts +57 -0
  162. package/dist/utils/observation-component-entry-editor.js +105 -0
  163. package/dist/utils/observation-entry-editor.d.ts +29 -0
  164. package/dist/utils/observation-entry-editor.js +68 -0
  165. package/dist/utils/procedure-entry-editor.d.ts +71 -0
  166. package/dist/utils/procedure-entry-editor.js +75 -0
  167. package/dist/utils/professional-smart.d.ts +87 -0
  168. package/dist/utils/professional-smart.js +118 -4
  169. package/dist/utils/profile-manager-mem.d.ts +69 -0
  170. package/dist/utils/profile-manager-mem.js +79 -0
  171. package/dist/utils/profile-outbox-memory-repository.d.ts +34 -0
  172. package/dist/utils/profile-outbox-memory-repository.js +57 -0
  173. package/dist/utils/same-as.d.ts +40 -0
  174. package/dist/utils/same-as.js +72 -0
  175. package/dist/utils/unified-health-id.d.ts +51 -0
  176. package/dist/utils/unified-health-id.js +92 -0
  177. package/dist/utils/vital-sign-day-batch.d.ts +25 -0
  178. package/dist/utils/vital-sign-day-batch.js +115 -0
  179. package/dist/utils/vital-sign-entry-editor.d.ts +61 -0
  180. package/dist/utils/vital-sign-entry-editor.js +152 -0
  181. package/dist/utils/wallet-mem.d.ts +93 -0
  182. package/dist/utils/wallet-mem.js +277 -0
  183. package/dist/utils/wallet-memory-queue.d.ts +32 -0
  184. package/dist/utils/wallet-memory-queue.js +82 -0
  185. package/package.json +2 -1
@@ -0,0 +1,135 @@
1
+ import { ClaimsPersonSchemaorg } from '../constants/schemaorg.js';
2
+ import { IndividualCredentialTypes, W3cCredentialTypes, } from '../constants/verifiable-credentials.js';
3
+ import { normalizeSameAsHashCsv, normalizeSameAsHashList, normalizeTelephoneHash } from './same-as.js';
4
+ import { buildUnsignedVpJwt } from './jwt.js';
5
+ function getIndividualIdentitySameAs(input) {
6
+ const sameAsCandidates = [];
7
+ if (input.sameAs) {
8
+ sameAsCandidates.push(...normalizeSameAsHashList(input.sameAs));
9
+ }
10
+ if (input.email) {
11
+ sameAsCandidates.push(...normalizeSameAsHashList(input.email));
12
+ }
13
+ return [...new Set(sameAsCandidates)];
14
+ }
15
+ function getIndividualIdentityTelephone(input) {
16
+ const normalized = normalizeTelephoneHash(String(input.telephone || ''));
17
+ return normalized || undefined;
18
+ }
19
+ function buildIndividualIdentityVC(input, credentialType) {
20
+ const normalizedSameAs = getIndividualIdentitySameAs(input);
21
+ const normalizedTelephone = getIndividualIdentityTelephone(input);
22
+ const normalizedCredentialMaterial = String(input.credentialMaterial || '').trim();
23
+ const normalizedSubjectDid = String(input.subjectDid || '').trim();
24
+ const normalizedRelationship = String(input.relationship || '').trim();
25
+ const normalizedAuthorityBasis = String(input.authorityBasis || '').trim();
26
+ return {
27
+ type: [
28
+ W3cCredentialTypes.VerifiableCredential,
29
+ credentialType,
30
+ ],
31
+ credentialSubject: {
32
+ id: String(input.actorDid || '').trim(),
33
+ ...(normalizedSubjectDid ? { subject: normalizedSubjectDid } : {}),
34
+ ...(normalizedRelationship ? { relationship: normalizedRelationship } : {}),
35
+ ...(normalizedAuthorityBasis ? { authorityBasis: normalizedAuthorityBasis } : {}),
36
+ ...(normalizedSameAs.length
37
+ ? { sameAs: normalizeSameAsHashCsv(normalizedSameAs) }
38
+ : {}),
39
+ ...(normalizedTelephone
40
+ ? { [ClaimsPersonSchemaorg.telephone]: normalizedTelephone }
41
+ : {}),
42
+ ...(normalizedCredentialMaterial
43
+ ? { [ClaimsPersonSchemaorg.hasCredentialMaterial]: normalizedCredentialMaterial }
44
+ : {}),
45
+ ...(input.additionalCredentialSubject || {}),
46
+ },
47
+ ...(Array.isArray(input.evidence) && input.evidence.length
48
+ ? { evidence: [...input.evidence] }
49
+ : {}),
50
+ ...(input.additionalCredential || {}),
51
+ };
52
+ }
53
+ function buildIndividualIdentityVpPayload(input, credentialType) {
54
+ const credentials = Array.isArray(input.verifiableCredential)
55
+ ? [...input.verifiableCredential]
56
+ : input.verifiableCredential
57
+ ? [input.verifiableCredential]
58
+ : [buildIndividualIdentityVC({
59
+ actorDid: input.actorDid,
60
+ subjectDid: input.subjectDid,
61
+ relationship: input.relationship,
62
+ authorityBasis: input.authorityBasis,
63
+ email: input.email,
64
+ sameAs: input.sameAs,
65
+ telephone: input.telephone,
66
+ credentialMaterial: input.credentialMaterial,
67
+ evidence: input.evidence,
68
+ }, credentialType)];
69
+ return {
70
+ ...(input.additionalPayload || {}),
71
+ vp: {
72
+ holder: String(input.clientId || '').trim(),
73
+ verifiableCredential: credentials,
74
+ ...(input.additionalVp || {}),
75
+ },
76
+ };
77
+ }
78
+ export function getIndividualControllerIdentitySameAs(input) {
79
+ return getIndividualIdentitySameAs(input);
80
+ }
81
+ export function getIndividualControllerIdentityTelephone(input) {
82
+ return getIndividualIdentityTelephone(input);
83
+ }
84
+ export function getIndividualControllerIdentityVC(input) {
85
+ return buildIndividualIdentityVC(input, IndividualCredentialTypes.IndividualControllerCredential);
86
+ }
87
+ export function buildIndividualControllerIdentityVpPayload(input) {
88
+ return buildIndividualIdentityVpPayload(input, IndividualCredentialTypes.IndividualControllerCredential);
89
+ }
90
+ export function buildUnsignedIndividualControllerIdentityVpJwt(input, options = {}) {
91
+ return buildUnsignedVpJwt(buildIndividualControllerIdentityVpPayload(input), options);
92
+ }
93
+ export function getIndividualSubjectVC(input) {
94
+ const normalizedSameAs = getIndividualIdentitySameAs({
95
+ sameAs: input.sameAs,
96
+ });
97
+ const normalizedTelephone = getIndividualIdentityTelephone({
98
+ telephone: input.telephone,
99
+ });
100
+ return {
101
+ type: [
102
+ W3cCredentialTypes.VerifiableCredential,
103
+ IndividualCredentialTypes.IndividualSubjectCredential,
104
+ ],
105
+ credentialSubject: {
106
+ id: String(input.subjectDid || '').trim(),
107
+ ...(normalizedSameAs.length
108
+ ? { sameAs: normalizeSameAsHashCsv(normalizedSameAs) }
109
+ : {}),
110
+ ...(normalizedTelephone
111
+ ? { [ClaimsPersonSchemaorg.telephone]: normalizedTelephone }
112
+ : {}),
113
+ ...(input.additionalCredentialSubject || {}),
114
+ },
115
+ ...(Array.isArray(input.evidence) && input.evidence.length
116
+ ? { evidence: [...input.evidence] }
117
+ : {}),
118
+ ...(input.additionalCredential || {}),
119
+ };
120
+ }
121
+ export function getIndividualMemberIdentitySameAs(input) {
122
+ return getIndividualIdentitySameAs(input);
123
+ }
124
+ export function getIndividualMemberIdentityTelephone(input) {
125
+ return getIndividualIdentityTelephone(input);
126
+ }
127
+ export function getIndividualMemberIdentityVC(input) {
128
+ return buildIndividualIdentityVC(input, IndividualCredentialTypes.IndividualMemberCredential);
129
+ }
130
+ export function buildIndividualMemberIdentityVpPayload(input) {
131
+ return buildIndividualIdentityVpPayload(input, IndividualCredentialTypes.IndividualMemberCredential);
132
+ }
133
+ export function buildUnsignedIndividualMemberIdentityVpJwt(input, options = {}) {
134
+ return buildUnsignedVpJwt(buildIndividualMemberIdentityVpPayload(input), options);
135
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * File discipline note:
3
+ * - Read `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing this module.
4
+ * - Keep exactly one exported class per file.
5
+ * - Keep this file focused on one typed editor surface.
6
+ * - Move shared helpers to reusable helper/base modules instead of duplicating logic here.
7
+ */
8
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor';
9
+ /**
10
+ * Typed editor for one staged MedicationStatement resource entry.
11
+ *
12
+ * Use this surface in the frontend when the user creates, corrects, or reviews
13
+ * medication data one entry at a time before the final document is built.
14
+ */
15
+ export declare class MedicationStatementEntryEditor extends ClinicalResourceEntryEditor {
16
+ /** Overrides the canonical identifier when import or migration logic needs one explicit public id. */
17
+ setIdentifier(identifier?: string | null): this;
18
+ /** Returns the canonical identifier currently exposed for this medication entry. */
19
+ getIdentifier(): string | undefined;
20
+ /** Ensures the entry has one synchronized canonical identifier across public claim, `resource.id`, and `fullUrl`. */
21
+ ensureIdentifier(): string;
22
+ /** Sets the subject/patient reference for this medication statement. */
23
+ setSubject(subject?: string | null): this;
24
+ /** Returns the subject/patient reference for this medication statement. */
25
+ getSubject(): string | undefined;
26
+ /** Sets the medication statement status. */
27
+ setStatus(status?: string | null): this;
28
+ /** Returns the medication statement status. */
29
+ getStatus(): string | undefined;
30
+ /** Sets the effective date or period token stored in the flat-claims model. */
31
+ setEffective(value?: string | null): this;
32
+ /** Returns the effective date or period token. */
33
+ getEffective(): string | undefined;
34
+ /** Sets the coded medication identifier/value used by downstream FHIR export. */
35
+ setCode(code?: string | null): this;
36
+ /** Returns the coded medication identifier/value. */
37
+ getCode(): string | undefined;
38
+ /** Sets the human-readable medication text shown in UI cards and document narratives. */
39
+ setMedicationText(text?: string | null): this;
40
+ /** Returns the human-readable medication text. */
41
+ getMedicationText(): string | undefined;
42
+ /** Sets one free-text note attached to the medication entry. */
43
+ setNote(note?: string | null): this;
44
+ /** Returns the current medication note. */
45
+ getNote(): string | undefined;
46
+ /** Sets one flat-text dosage instruction. */
47
+ setDosageInstruction(value?: string | null): this;
48
+ /** Returns the flat-text dosage instruction. */
49
+ getDosageInstruction(): string | undefined;
50
+ /** Replaces the medication category/section tags used by document assembly and local filtering. */
51
+ setCategoryList(values: readonly string[]): this;
52
+ /** Returns the medication category/section tags. */
53
+ getCategoryList(): string[];
54
+ /** Sets the numeric dose quantity value. */
55
+ setDoseQuantityValue(value?: number | null): this;
56
+ /** Returns the numeric dose quantity value. */
57
+ getDoseQuantityValue(): number | undefined;
58
+ /** Sets the dose quantity unit token. */
59
+ setDoseQuantityUnit(value?: string | null): this;
60
+ /** Returns the dose quantity unit token. */
61
+ getDoseQuantityUnit(): string | undefined;
62
+ /** Sets the timing frequency for structured dosage authoring. */
63
+ setTimingFrequency(value?: number | null): this;
64
+ /** Returns the timing frequency. */
65
+ getTimingFrequency(): number | undefined;
66
+ /** Sets the timing period for structured dosage authoring. */
67
+ setTimingPeriod(value?: number | null): this;
68
+ /** Returns the timing period. */
69
+ getTimingPeriod(): number | undefined;
70
+ /** Sets the timing period unit token. */
71
+ setTimingPeriodUnit(value?: string | null): this;
72
+ /** Returns the timing period unit token. */
73
+ getTimingPeriodUnit(): string | undefined;
74
+ /** Marks whether this dosage is `as needed`. */
75
+ setDosageAsNeeded(value?: boolean | null): this;
76
+ /** Returns whether this dosage is `as needed`. */
77
+ getDosageAsNeeded(): boolean | undefined;
78
+ /** Replaces the linked child-resource reference list, typically `DocumentReference/...` items. */
79
+ setContainedResourceReferenceList(references: readonly string[]): this;
80
+ /** Returns the linked child-resource reference list. */
81
+ getContainedResourceReferenceList(): string[];
82
+ /** Marks whether the medication was user-entered or user-confirmed in self-managed flows. */
83
+ setUserSelected(value?: boolean | null): this;
84
+ /** Returns whether the medication was marked as user-selected. */
85
+ getUserSelected(): boolean | undefined;
86
+ /** @deprecated Use `setContainedResourceReferenceList(...)`. */
87
+ setContainedDocumentIdentifierList(identifiers: readonly string[]): this;
88
+ /** @deprecated Use `getContainedResourceReferenceList()`. */
89
+ getContainedDocumentIdentifierList(): string[];
90
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * File discipline note:
3
+ * - Read `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing this module.
4
+ * - Keep exactly one exported class per file.
5
+ * - Keep this file focused on one typed editor surface.
6
+ * - Move shared helpers to reusable helper/base modules instead of duplicating logic here.
7
+ */
8
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor.js';
9
+ import { MedicationStatementClaim, MedicationStatementClaimsFhirApiExtended } from '../models/interoperable-claims/medication-statement-claims.js';
10
+ import { BundleEditableResourceTypes } from '../models/bundle-editor-types.js';
11
+ import { registerBundleEntryEditor } from './bundle-editor-registry.js';
12
+ /**
13
+ * Typed editor for one staged MedicationStatement resource entry.
14
+ *
15
+ * Use this surface in the frontend when the user creates, corrects, or reviews
16
+ * medication data one entry at a time before the final document is built.
17
+ */
18
+ export class MedicationStatementEntryEditor extends ClinicalResourceEntryEditor {
19
+ /** Overrides the canonical identifier when import or migration logic needs one explicit public id. */
20
+ setIdentifier(identifier) { return this.setIdentifierValue(MedicationStatementClaim.Identifier, identifier); }
21
+ /** Returns the canonical identifier currently exposed for this medication entry. */
22
+ getIdentifier() { return this.getIdentifierValue(MedicationStatementClaim.Identifier); }
23
+ /** Ensures the entry has one synchronized canonical identifier across public claim, `resource.id`, and `fullUrl`. */
24
+ ensureIdentifier() { return this.ensureIdentifierValue(MedicationStatementClaim.Identifier); }
25
+ /** Sets the subject/patient reference for this medication statement. */
26
+ setSubject(subject) { return this.setSubjectClaims(MedicationStatementClaim.Subject, MedicationStatementClaim.Patient, subject); }
27
+ /** Returns the subject/patient reference for this medication statement. */
28
+ getSubject() { return this.getSubjectClaims(MedicationStatementClaim.Subject, MedicationStatementClaim.Patient); }
29
+ /** Sets the medication statement status. */
30
+ setStatus(status) { return this.setScalarClaim(MedicationStatementClaim.Status, status); }
31
+ /** Returns the medication statement status. */
32
+ getStatus() { return this.getScalarClaim(MedicationStatementClaim.Status); }
33
+ /** Sets the effective date or period token stored in the flat-claims model. */
34
+ setEffective(value) { return this.setScalarClaim(MedicationStatementClaim.Effective, value); }
35
+ /** Returns the effective date or period token. */
36
+ getEffective() { return this.getScalarClaim(MedicationStatementClaim.Effective); }
37
+ /** Sets the coded medication identifier/value used by downstream FHIR export. */
38
+ setCode(code) { return this.setScalarClaim(MedicationStatementClaim.Code, code); }
39
+ /** Returns the coded medication identifier/value. */
40
+ getCode() { return this.getScalarClaim(MedicationStatementClaim.Code); }
41
+ /** Sets the human-readable medication text shown in UI cards and document narratives. */
42
+ setMedicationText(text) { return this.setScalarClaim(MedicationStatementClaim.MedicationText, text); }
43
+ /** Returns the human-readable medication text. */
44
+ getMedicationText() { return this.getScalarClaim(MedicationStatementClaim.MedicationText); }
45
+ /** Sets one free-text note attached to the medication entry. */
46
+ setNote(note) { return this.setScalarClaim(MedicationStatementClaim.Note, note); }
47
+ /** Returns the current medication note. */
48
+ getNote() { return this.getScalarClaim(MedicationStatementClaim.Note); }
49
+ /** Sets one flat-text dosage instruction. */
50
+ setDosageInstruction(value) { return this.setScalarClaim(MedicationStatementClaim.DosageInstruction, value); }
51
+ /** Returns the flat-text dosage instruction. */
52
+ getDosageInstruction() { return this.getScalarClaim(MedicationStatementClaim.DosageInstruction); }
53
+ /** Replaces the medication category/section tags used by document assembly and local filtering. */
54
+ setCategoryList(values) { return this.setCsvClaimList(MedicationStatementClaim.Category, values); }
55
+ /** Returns the medication category/section tags. */
56
+ getCategoryList() { return this.getCsvClaimList(MedicationStatementClaim.Category); }
57
+ /** Sets the numeric dose quantity value. */
58
+ setDoseQuantityValue(value) { return this.setNumberClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityValue, value); }
59
+ /** Returns the numeric dose quantity value. */
60
+ getDoseQuantityValue() { return this.getNumberClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityValue); }
61
+ /** Sets the dose quantity unit token. */
62
+ setDoseQuantityUnit(value) { return this.setScalarClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityUnit, value); }
63
+ /** Returns the dose quantity unit token. */
64
+ getDoseQuantityUnit() { return this.getScalarClaim(MedicationStatementClaimsFhirApiExtended.DoseQuantityUnit); }
65
+ /** Sets the timing frequency for structured dosage authoring. */
66
+ setTimingFrequency(value) { return this.setNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingFrequency, value); }
67
+ /** Returns the timing frequency. */
68
+ getTimingFrequency() { return this.getNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingFrequency); }
69
+ /** Sets the timing period for structured dosage authoring. */
70
+ setTimingPeriod(value) { return this.setNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriod, value); }
71
+ /** Returns the timing period. */
72
+ getTimingPeriod() { return this.getNumberClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriod); }
73
+ /** Sets the timing period unit token. */
74
+ setTimingPeriodUnit(value) { return this.setScalarClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriodUnit, value); }
75
+ /** Returns the timing period unit token. */
76
+ getTimingPeriodUnit() { return this.getScalarClaim(MedicationStatementClaimsFhirApiExtended.TimingPeriodUnit); }
77
+ /** Marks whether this dosage is `as needed`. */
78
+ setDosageAsNeeded(value) { return this.setBooleanClaim(MedicationStatementClaimsFhirApiExtended.DosageAsNeeded, value); }
79
+ /** Returns whether this dosage is `as needed`. */
80
+ getDosageAsNeeded() { return this.getBooleanClaim(MedicationStatementClaimsFhirApiExtended.DosageAsNeeded); }
81
+ /** Replaces the linked child-resource reference list, typically `DocumentReference/...` items. */
82
+ setContainedResourceReferenceList(references) { return this.setCsvClaimList(MedicationStatementClaim.ContainedReferenceList, references); }
83
+ /** Returns the linked child-resource reference list. */
84
+ getContainedResourceReferenceList() { return this.getCsvClaimList(MedicationStatementClaim.ContainedReferenceList); }
85
+ /** Marks whether the medication was user-entered or user-confirmed in self-managed flows. */
86
+ setUserSelected(value) { return this.setBooleanClaim(MedicationStatementClaim.UserSelected, value); }
87
+ /** Returns whether the medication was marked as user-selected. */
88
+ getUserSelected() { return this.getBooleanClaim(MedicationStatementClaim.UserSelected); }
89
+ /** @deprecated Use `setContainedResourceReferenceList(...)`. */
90
+ setContainedDocumentIdentifierList(identifiers) { return this.setContainedResourceReferenceList(identifiers); }
91
+ /** @deprecated Use `getContainedResourceReferenceList()`. */
92
+ getContainedDocumentIdentifierList() { return this.getContainedResourceReferenceList(); }
93
+ }
94
+ registerBundleEntryEditor(BundleEditableResourceTypes.medicationStatement, MedicationStatementEntryEditor);
@@ -0,0 +1,57 @@
1
+ /**
2
+ * File discipline note:
3
+ * - Read `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing this module.
4
+ * - Keep exactly one exported class per file.
5
+ * - Keep this file focused on one typed editor surface.
6
+ * - Move shared helpers to reusable helper/base modules instead of duplicating logic here.
7
+ */
8
+ import { type CodingDescriptor } from '../constants/vital-signs';
9
+ import { BundleEntryEditor } from './bundle-entry-editor';
10
+ /**
11
+ * Typed editor for one staged ObservationComponent resource entry.
12
+ *
13
+ * Keep this surface thin and claim-focused so 101 tests can teach one
14
+ * resource at a time without exposing bundle-internal plumbing.
15
+ */
16
+ export declare class ObservationComponentEntryEditor extends BundleEntryEditor {
17
+ setCode(code: CodingDescriptor | string): this;
18
+ getCode(): string | undefined;
19
+ setCodeSystem(system: string): this;
20
+ getCodeSystem(): string | undefined;
21
+ setCodeValue(value: string): this;
22
+ getCodeValue(): string | undefined;
23
+ setCodeDisplay(display: string): this;
24
+ getCodeDisplay(): string | undefined;
25
+ /**
26
+ * Stores the local-language label used by forms and local UI copy.
27
+ *
28
+ * Keep this distinct from `setCodeDisplay(...)`, which is the canonical
29
+ * English/international display carried by the coded concept.
30
+ */
31
+ setCodeTextLocal(text: string): this;
32
+ /**
33
+ * Returns the local-language label used by forms and local UI copy.
34
+ *
35
+ * Keep this distinct from `getCodeDisplay()`, which returns the canonical
36
+ * English/international display when present.
37
+ */
38
+ getCodeTextLocal(): string | undefined;
39
+ /** Compatibility alias for older examples/tests. Prefer `setCodeTextLocal(...)`. */
40
+ setLocalText(text: string): this;
41
+ /** Compatibility alias for older examples/tests. Prefer `getCodeTextLocal()`. */
42
+ getLocalText(): string | undefined;
43
+ setValueQuantityNumber(value: number): this;
44
+ getValueQuantityNumber(): number | undefined;
45
+ setValueQuantityUnit(unit: CodingDescriptor | string): this;
46
+ getValueQuantityUnit(): string | undefined;
47
+ setValueString(value: string): this;
48
+ getValueString(): string | undefined;
49
+ setValueDate(value: string): this;
50
+ getValueDate(): string | undefined;
51
+ }
52
+ /**
53
+ * Vital-sign-specific editor surface for one staged Observation entry.
54
+ *
55
+ * This layer applies the visible/searchable Vital Signs claim contract on top
56
+ * of the reduced Observation component helpers.
57
+ */
@@ -0,0 +1,105 @@
1
+ import { ObservationClaim } from '../models/interoperable-claims/observation-claims.js';
2
+ import { normalizeOptionalIdentifier } from './bundle-editor-helpers.js';
3
+ import { BundleEntryEditor } from './bundle-entry-editor.js';
4
+ /**
5
+ * Typed editor for one staged ObservationComponent resource entry.
6
+ *
7
+ * Keep this surface thin and claim-focused so 101 tests can teach one
8
+ * resource at a time without exposing bundle-internal plumbing.
9
+ */
10
+ export class ObservationComponentEntryEditor extends BundleEntryEditor {
11
+ setCode(code) {
12
+ const token = typeof code === 'string' ? code.trim() : code.claim;
13
+ this.setClaim(ObservationClaim.Code, token);
14
+ if (typeof code !== 'string') {
15
+ this.setClaim(ObservationClaim.CodeSystem, code.system);
16
+ this.setClaim(ObservationClaim.CodeValue, code.code);
17
+ if (code.display) {
18
+ this.setClaim(ObservationClaim.CodeDisplay, code.display);
19
+ }
20
+ }
21
+ return this;
22
+ }
23
+ getCode() {
24
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Code));
25
+ }
26
+ setCodeSystem(system) {
27
+ return this.setClaim(ObservationClaim.CodeSystem, String(system).trim());
28
+ }
29
+ getCodeSystem() {
30
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeSystem));
31
+ }
32
+ setCodeValue(value) {
33
+ return this.setClaim(ObservationClaim.CodeValue, String(value).trim());
34
+ }
35
+ getCodeValue() {
36
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeValue));
37
+ }
38
+ setCodeDisplay(display) {
39
+ return this.setClaim(ObservationClaim.CodeDisplay, String(display).trim());
40
+ }
41
+ getCodeDisplay() {
42
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeDisplay));
43
+ }
44
+ /**
45
+ * Stores the local-language label used by forms and local UI copy.
46
+ *
47
+ * Keep this distinct from `setCodeDisplay(...)`, which is the canonical
48
+ * English/international display carried by the coded concept.
49
+ */
50
+ setCodeTextLocal(text) {
51
+ return this.setClaim(ObservationClaim.CodeText, String(text).trim());
52
+ }
53
+ /**
54
+ * Returns the local-language label used by forms and local UI copy.
55
+ *
56
+ * Keep this distinct from `getCodeDisplay()`, which returns the canonical
57
+ * English/international display when present.
58
+ */
59
+ getCodeTextLocal() {
60
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.CodeText));
61
+ }
62
+ /** Compatibility alias for older examples/tests. Prefer `setCodeTextLocal(...)`. */
63
+ setLocalText(text) {
64
+ return this.setCodeTextLocal(text);
65
+ }
66
+ /** Compatibility alias for older examples/tests. Prefer `getCodeTextLocal()`. */
67
+ getLocalText() {
68
+ return this.getCodeTextLocal();
69
+ }
70
+ setValueQuantityNumber(value) {
71
+ return this.setClaim(ObservationClaim.ValueQuantityNumber, String(value));
72
+ }
73
+ getValueQuantityNumber() {
74
+ const raw = this.getClaim(ObservationClaim.ValueQuantityNumber);
75
+ if (raw === undefined || raw === null || raw === '')
76
+ return undefined;
77
+ const numeric = Number(raw);
78
+ return Number.isFinite(numeric) ? numeric : undefined;
79
+ }
80
+ setValueQuantityUnit(unit) {
81
+ const normalized = typeof unit === 'string' ? unit.trim() : unit.claim;
82
+ return this.setClaim(ObservationClaim.ValueQuantityUnit, normalized);
83
+ }
84
+ getValueQuantityUnit() {
85
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.ValueQuantityUnit));
86
+ }
87
+ setValueString(value) {
88
+ return this.setClaim(ObservationClaim.ValueString, String(value).trim());
89
+ }
90
+ getValueString() {
91
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.ValueString));
92
+ }
93
+ setValueDate(value) {
94
+ return this.setClaim(ObservationClaim.ValueDate, String(value).trim());
95
+ }
96
+ getValueDate() {
97
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.ValueDate));
98
+ }
99
+ }
100
+ /**
101
+ * Vital-sign-specific editor surface for one staged Observation entry.
102
+ *
103
+ * This layer applies the visible/searchable Vital Signs claim contract on top
104
+ * of the reduced Observation component helpers.
105
+ */
@@ -0,0 +1,29 @@
1
+ import { VitalSignEntryEditor } from './vital-sign-entry-editor';
2
+ /**
3
+ * Typed editor for one staged Observation resource entry.
4
+ *
5
+ * Use this when a caller needs to stage one observation row with claims-first
6
+ * accessors in a bundle authoring flow.
7
+ */
8
+ export declare class ObservationEntryEditor extends VitalSignEntryEditor {
9
+ /** Writes the based-on reference. */
10
+ setBasedOn(reference: string): this;
11
+ /** Reads the based-on reference. */
12
+ getBasedOn(): string | undefined;
13
+ /** Writes the encounter reference. */
14
+ setEncounter(reference: string): this;
15
+ /** Reads the encounter reference. */
16
+ getEncounter(): string | undefined;
17
+ /** Writes the performer reference. */
18
+ setPerformer(reference: string): this;
19
+ /** Reads the performer reference. */
20
+ getPerformer(): string | undefined;
21
+ /** Writes the has-member reference. */
22
+ setHasMember(reference: string): this;
23
+ /** Reads the has-member reference. */
24
+ getHasMember(): string | undefined;
25
+ /** Writes the has-member list. */
26
+ setHasMemberList(references: readonly string[]): this;
27
+ /** Reads the has-member list. */
28
+ getHasMemberList(): string[];
29
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * File discipline note:
3
+ * - Read `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing this module.
4
+ * - Keep exactly one exported class per file.
5
+ * - Keep this file focused on one typed editor surface.
6
+ * - Move shared helpers to reusable helper/base modules instead of duplicating logic here.
7
+ */
8
+ import { ObservationClaim } from '../models/interoperable-claims/observation-claims.js';
9
+ import { BundleEditableResourceTypes } from '../models/bundle-editor-types.js';
10
+ import { normalizeOptionalIdentifier } from './bundle-editor-helpers.js';
11
+ import { VitalSignEntryEditor } from './vital-sign-entry-editor.js';
12
+ import { getClaimValues, setClaimValues } from '../claims/claim-list-helpers.js';
13
+ import { registerBundleEntryEditor } from './bundle-editor-registry.js';
14
+ /**
15
+ * Typed editor for one staged Observation resource entry.
16
+ *
17
+ * Use this when a caller needs to stage one observation row with claims-first
18
+ * accessors in a bundle authoring flow.
19
+ */
20
+ export class ObservationEntryEditor extends VitalSignEntryEditor {
21
+ /** Writes the based-on reference. */
22
+ setBasedOn(reference) {
23
+ return this.setClaim(ObservationClaim.BasedOn, String(reference).trim());
24
+ }
25
+ /** Reads the based-on reference. */
26
+ getBasedOn() {
27
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.BasedOn));
28
+ }
29
+ /** Writes the encounter reference. */
30
+ setEncounter(reference) {
31
+ return this.setClaim(ObservationClaim.Encounter, String(reference).trim());
32
+ }
33
+ /** Reads the encounter reference. */
34
+ getEncounter() {
35
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Encounter));
36
+ }
37
+ /** Writes the performer reference. */
38
+ setPerformer(reference) {
39
+ return this.setClaim(ObservationClaim.Performer, String(reference).trim());
40
+ }
41
+ /** Reads the performer reference. */
42
+ getPerformer() {
43
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Performer));
44
+ }
45
+ /** Writes the has-member reference. */
46
+ setHasMember(reference) {
47
+ return this.setClaim(ObservationClaim.HasMember, String(reference).trim());
48
+ }
49
+ /** Reads the has-member reference. */
50
+ getHasMember() {
51
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.HasMember));
52
+ }
53
+ /** Writes the has-member list. */
54
+ setHasMemberList(references) {
55
+ const next = setClaimValues({}, ObservationClaim.HasMember, references);
56
+ const normalized = normalizeOptionalIdentifier(next[ObservationClaim.HasMember]);
57
+ if (!normalized) {
58
+ this.removeClaim(ObservationClaim.HasMember);
59
+ return this;
60
+ }
61
+ return this.setClaim(ObservationClaim.HasMember, normalized);
62
+ }
63
+ /** Reads the has-member list. */
64
+ getHasMemberList() {
65
+ return getClaimValues(this.getClaims(), ObservationClaim.HasMember);
66
+ }
67
+ }
68
+ registerBundleEntryEditor(BundleEditableResourceTypes.observation, ObservationEntryEditor);
@@ -0,0 +1,71 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor';
2
+ /**
3
+ * Typed editor for one staged Procedure resource entry.
4
+ *
5
+ * Use this when a caller needs to stage one procedure row with claims-first
6
+ * accessors in a bundle authoring flow.
7
+ */
8
+ export declare class ProcedureEntryEditor extends ClinicalResourceEntryEditor {
9
+ /** Writes the canonical procedure identifier. */
10
+ setIdentifier(identifier?: string | null): this;
11
+ /** Reads the canonical procedure identifier. */
12
+ getIdentifier(): string | undefined;
13
+ /** Ensures the procedure entry has one canonical `urn:uuid:*` identifier. */
14
+ ensureIdentifier(): string;
15
+ /** Writes the subject/patient reference. */
16
+ setSubject(subject?: string | null): this;
17
+ /** Reads the subject/patient reference. */
18
+ getSubject(): string | undefined;
19
+ /** Writes the procedure status. */
20
+ setStatus(status?: string | null): this;
21
+ /** Reads the procedure status. */
22
+ getStatus(): string | undefined;
23
+ /** Writes the procedure date. */
24
+ setDate(date?: string | null): this;
25
+ /** Reads the procedure date. */
26
+ getDate(): string | undefined;
27
+ /** Writes the procedure code. */
28
+ setCode(code?: string | null): this;
29
+ /** Reads the procedure code. */
30
+ getCode(): string | undefined;
31
+ /** Writes the local code text. */
32
+ setCodeTextLocal(text?: string | null): this;
33
+ /** Reads the local code text. */
34
+ getCodeTextLocal(): string | undefined;
35
+ /** Writes the code display text. */
36
+ setCodeDisplay(display?: string | null): this;
37
+ /** Reads the code display text. */
38
+ getCodeDisplay(): string | undefined;
39
+ /** Writes the encounter reference. */
40
+ setEncounter(reference?: string | null): this;
41
+ /** Reads the encounter reference. */
42
+ getEncounter(): string | undefined;
43
+ /** Writes the location reference. */
44
+ setLocation(reference?: string | null): this;
45
+ /** Reads the location reference. */
46
+ getLocation(): string | undefined;
47
+ /** Writes the reason code. */
48
+ setReasonCode(code?: string | null): this;
49
+ /** Reads the reason code. */
50
+ getReasonCode(): string | undefined;
51
+ /** Writes the note text. */
52
+ setNote(note?: string | null): this;
53
+ /** Reads the note text. */
54
+ getNote(): string | undefined;
55
+ /** Alias for `setNote(...)` used by callers that expect clinical wording. */
56
+ setClinicalNote(note?: string | null): this;
57
+ /** Alias for `getNote()` used by callers that expect clinical wording. */
58
+ getClinicalNote(): string | undefined;
59
+ /** Writes the performer list. */
60
+ setPerformerList(references: readonly string[]): this;
61
+ /** Reads the performer list. */
62
+ getPerformerList(): string[];
63
+ /** Writes the based-on list. */
64
+ setBasedOnList(references: readonly string[]): this;
65
+ /** Reads the based-on list. */
66
+ getBasedOnList(): string[];
67
+ /** Writes the reason-reference list. */
68
+ setReasonReferenceList(references: readonly string[]): this;
69
+ /** Reads the reason-reference list. */
70
+ getReasonReferenceList(): string[];
71
+ }