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.
Files changed (175) hide show
  1. package/README.md +22 -2
  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/data-collections.js +0 -1
  13. package/dist/constants/didcomm.d.ts +22 -0
  14. package/dist/constants/didcomm.js +22 -0
  15. package/dist/constants/fhir-resource-types.d.ts +16 -0
  16. package/dist/constants/fhir-resource-types.js +7 -0
  17. package/dist/constants/healthcare.d.ts +348 -193
  18. package/dist/constants/healthcare.js +99 -37
  19. package/dist/constants/hl7-roles.d.ts +38 -4
  20. package/dist/constants/hl7-roles.js +92 -4
  21. package/dist/constants/index.d.ts +1 -0
  22. package/dist/constants/index.js +1 -0
  23. package/dist/constants/lifecycle.d.ts +2 -0
  24. package/dist/constants/lifecycle.js +2 -0
  25. package/dist/constants/verifiable-credentials.d.ts +9 -0
  26. package/dist/constants/verifiable-credentials.js +9 -0
  27. package/dist/examples/bundle-didcomm-payload.js +4 -2
  28. package/dist/examples/communication-attached-bundle-session.js +27 -27
  29. package/dist/examples/communication-didcomm-payload.d.ts +8 -4
  30. package/dist/examples/communication-didcomm-payload.js +17 -11
  31. package/dist/examples/consent-access.js +2 -1
  32. package/dist/examples/employee.d.ts +21 -0
  33. package/dist/examples/employee.js +21 -0
  34. package/dist/examples/individual-controller.d.ts +27 -0
  35. package/dist/examples/individual-controller.js +28 -1
  36. package/dist/examples/inter-tenant-access-contract.js +3 -2
  37. package/dist/examples/ips-bundle.js +17 -16
  38. package/dist/examples/lifecycle.js +13 -11
  39. package/dist/examples/profile-manager-mem.js +2 -1
  40. package/dist/examples/related-person.d.ts +14 -0
  41. package/dist/examples/related-person.js +18 -4
  42. package/dist/examples/shared.d.ts +12 -3
  43. package/dist/examples/shared.js +13 -4
  44. package/dist/examples/vital-signs.js +1 -1
  45. package/dist/examples/wallet-mem.js +4 -2
  46. package/dist/i18n/role-codes.i18n.d.ts +9 -1
  47. package/dist/i18n/role-codes.i18n.js +12 -1
  48. package/dist/models/authority-resolution.d.ts +56 -0
  49. package/dist/models/authority-resolution.js +2 -0
  50. package/dist/models/bundle-editor-types.d.ts +89 -0
  51. package/dist/models/bundle-editor-types.js +45 -0
  52. package/dist/models/bundle.d.ts +5 -0
  53. package/dist/models/communication-attached-bundle-session.d.ts +6 -4
  54. package/dist/models/communication-attached-bundle-session.js +6 -4
  55. package/dist/models/confidential-storage.d.ts +2 -1
  56. package/dist/models/consent-rule.d.ts +11 -1
  57. package/dist/models/consent-rule.js +9 -1
  58. package/dist/models/device-license.d.ts +20 -0
  59. package/dist/models/index.d.ts +2 -0
  60. package/dist/models/index.js +2 -0
  61. package/dist/models/individual-onboarding.d.ts +18 -0
  62. package/dist/models/interoperable-claims/allergy-intolerance-claims.d.ts +12 -1
  63. package/dist/models/interoperable-claims/allergy-intolerance-claims.js +12 -1
  64. package/dist/models/interoperable-claims/condition-claims.d.ts +12 -1
  65. package/dist/models/interoperable-claims/condition-claims.js +12 -1
  66. package/dist/models/interoperable-claims/diagnostic-report-claims.d.ts +13 -2
  67. package/dist/models/interoperable-claims/diagnostic-report-claims.js +12 -1
  68. package/dist/models/interoperable-claims/document-reference-claims.d.ts +1 -0
  69. package/dist/models/interoperable-claims/document-reference-claims.js +3 -0
  70. package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
  71. package/dist/models/interoperable-claims/medication-statement-claims.js +17 -0
  72. package/dist/models/interoperable-claims/related-person-claims.d.ts +13 -0
  73. package/dist/models/interoperable-claims/related-person-claims.js +16 -0
  74. package/dist/utils/allergy-intolerance-entry-editor.d.ts +51 -0
  75. package/dist/utils/allergy-intolerance-entry-editor.js +55 -0
  76. package/dist/utils/authority-resolution.d.ts +37 -0
  77. package/dist/utils/authority-resolution.js +112 -0
  78. package/dist/utils/backend-message-manager-mem.d.ts +11 -0
  79. package/dist/utils/backend-message-manager-mem.js +11 -0
  80. package/dist/utils/bundle-didcomm-payload.js +3 -2
  81. package/dist/utils/bundle-document-builder.d.ts +36 -0
  82. package/dist/utils/bundle-document-builder.js +310 -14
  83. package/dist/utils/bundle-editor-core.d.ts +181 -0
  84. package/dist/utils/bundle-editor-core.js +467 -0
  85. package/dist/utils/bundle-editor-helpers.d.ts +53 -0
  86. package/dist/utils/bundle-editor-helpers.js +146 -0
  87. package/dist/utils/bundle-editor-registry.d.ts +6 -0
  88. package/dist/utils/bundle-editor-registry.js +14 -0
  89. package/dist/utils/bundle-editor.d.ts +21 -722
  90. package/dist/utils/bundle-editor.js +21 -1601
  91. package/dist/utils/bundle-entry-editor.d.ts +96 -0
  92. package/dist/utils/bundle-entry-editor.js +305 -0
  93. package/dist/utils/bundle-query.d.ts +1 -0
  94. package/dist/utils/bundle-query.js +12 -3
  95. package/dist/utils/bundle-reader.d.ts +48 -0
  96. package/dist/utils/bundle-reader.js +175 -1
  97. package/dist/utils/care-plan-entry-editor.d.ts +43 -0
  98. package/dist/utils/care-plan-entry-editor.js +47 -0
  99. package/dist/utils/client-assertion.d.ts +38 -0
  100. package/dist/utils/client-assertion.js +113 -0
  101. package/dist/utils/clinical-impression-entry-editor.d.ts +43 -0
  102. package/dist/utils/clinical-impression-entry-editor.js +47 -0
  103. package/dist/utils/clinical-resource-entry-editor.d.ts +123 -0
  104. package/dist/utils/clinical-resource-entry-editor.js +296 -0
  105. package/dist/utils/clinical-resource-view.d.ts +16 -0
  106. package/dist/utils/clinical-resource-view.js +267 -33
  107. package/dist/utils/communication-attached-bundle-session-helpers.js +8 -6
  108. package/dist/utils/communication-attached-bundle-session.d.ts +29 -3
  109. package/dist/utils/communication-attached-bundle-session.js +62 -3
  110. package/dist/utils/communication-consent-access-editor.d.ts +8 -4
  111. package/dist/utils/communication-consent-access-editor.js +8 -4
  112. package/dist/utils/communication-didcomm-payload.d.ts +5 -0
  113. package/dist/utils/communication-didcomm-payload.js +28 -18
  114. package/dist/utils/communication-document-reference.d.ts +23 -0
  115. package/dist/utils/communication-document-reference.js +89 -0
  116. package/dist/utils/communication-editor.d.ts +53 -0
  117. package/dist/utils/communication-editor.js +97 -0
  118. package/dist/utils/condition-entry-editor.d.ts +30 -0
  119. package/dist/utils/condition-entry-editor.js +34 -0
  120. package/dist/utils/consent-claim-helpers.d.ts +4 -0
  121. package/dist/utils/consent-claim-helpers.js +15 -1
  122. package/dist/utils/consent-duplicate-rules.js +1 -1
  123. package/dist/utils/coverage-entry-editor.d.ts +51 -0
  124. package/dist/utils/coverage-entry-editor.js +55 -0
  125. package/dist/utils/device-entry-editor.d.ts +59 -0
  126. package/dist/utils/device-entry-editor.js +63 -0
  127. package/dist/utils/device-use-statement-entry-editor.d.ts +43 -0
  128. package/dist/utils/device-use-statement-entry-editor.js +47 -0
  129. package/dist/utils/diagnostic-report-entry-editor.d.ts +74 -0
  130. package/dist/utils/diagnostic-report-entry-editor.js +136 -0
  131. package/dist/utils/did.d.ts +8 -0
  132. package/dist/utils/did.js +22 -0
  133. package/dist/utils/document-reference-entry-editor.d.ts +62 -0
  134. package/dist/utils/document-reference-entry-editor.js +66 -0
  135. package/dist/utils/employee-entry-editor.d.ts +36 -0
  136. package/dist/utils/employee-entry-editor.js +88 -0
  137. package/dist/utils/employee.d.ts +1 -0
  138. package/dist/utils/employee.js +2 -1
  139. package/dist/utils/encounter-entry-editor.d.ts +51 -0
  140. package/dist/utils/encounter-entry-editor.js +55 -0
  141. package/dist/utils/flag-entry-editor.d.ts +47 -0
  142. package/dist/utils/flag-entry-editor.js +51 -0
  143. package/dist/utils/immunization-entry-editor.d.ts +87 -0
  144. package/dist/utils/immunization-entry-editor.js +169 -0
  145. package/dist/utils/index.d.ts +7 -0
  146. package/dist/utils/index.js +7 -0
  147. package/dist/utils/individual-onboarding-acceptance-credential.d.ts +35 -0
  148. package/dist/utils/individual-onboarding-acceptance-credential.js +55 -0
  149. package/dist/utils/individual-smart.d.ts +59 -0
  150. package/dist/utils/individual-smart.js +135 -0
  151. package/dist/utils/license-list-search.d.ts +5 -0
  152. package/dist/utils/license-list-search.js +9 -0
  153. package/dist/utils/license.d.ts +45 -1
  154. package/dist/utils/license.js +86 -2
  155. package/dist/utils/medication-statement-entry-editor.d.ts +90 -0
  156. package/dist/utils/medication-statement-entry-editor.js +94 -0
  157. package/dist/utils/observation-component-entry-editor.d.ts +57 -0
  158. package/dist/utils/observation-component-entry-editor.js +105 -0
  159. package/dist/utils/observation-entry-editor.d.ts +29 -0
  160. package/dist/utils/observation-entry-editor.js +68 -0
  161. package/dist/utils/procedure-entry-editor.d.ts +71 -0
  162. package/dist/utils/procedure-entry-editor.js +75 -0
  163. package/dist/utils/professional-smart.d.ts +87 -0
  164. package/dist/utils/professional-smart.js +118 -4
  165. package/dist/utils/related-person-list.d.ts +4 -0
  166. package/dist/utils/related-person-list.js +26 -6
  167. package/dist/utils/same-as.d.ts +40 -0
  168. package/dist/utils/same-as.js +72 -0
  169. package/dist/utils/unified-health-id.d.ts +51 -0
  170. package/dist/utils/unified-health-id.js +92 -0
  171. package/dist/utils/vital-sign-day-batch.d.ts +25 -0
  172. package/dist/utils/vital-sign-day-batch.js +115 -0
  173. package/dist/utils/vital-sign-entry-editor.d.ts +61 -0
  174. package/dist/utils/vital-sign-entry-editor.js +152 -0
  175. package/package.json +2 -1
@@ -0,0 +1,115 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { createCanonicalIdentifierUrn } from './bundle-editor-helpers.js';
3
+ import { BundleQuery } from './bundle-query.js';
4
+ export const VitalSignDayBatchClaim = Object.freeze({
5
+ Identifier: 'VitalSignDayBatch.identifier',
6
+ Subject: 'VitalSignDayBatch.subject',
7
+ Actor: 'VitalSignDayBatch.actor',
8
+ Day: 'VitalSignDayBatch.day',
9
+ CreatedAtTimestamp: 'VitalSignDayBatch.createdAtTimestamp',
10
+ });
11
+ export function buildVitalSignDayBatchClaims(input) {
12
+ const day = resolveDayKey(input.date);
13
+ const claims = {
14
+ [VitalSignDayBatchClaim.Subject]: asTrimmedString(input.subject),
15
+ [VitalSignDayBatchClaim.Actor]: asTrimmedString(input.actor),
16
+ [VitalSignDayBatchClaim.Day]: day,
17
+ };
18
+ if (typeof input.createdAtTimestamp === 'number' && Number.isFinite(input.createdAtTimestamp)) {
19
+ claims[VitalSignDayBatchClaim.CreatedAtTimestamp] = input.createdAtTimestamp;
20
+ }
21
+ return claims;
22
+ }
23
+ export function resolveVitalSignDayBatchId(input) {
24
+ const baseBundle = cloneBundle(input.bundle || createEmptyBundle());
25
+ const day = resolveDayKey(input.date);
26
+ const dayRange = resolveDayRange(day);
27
+ const existingClaims = asRecord(baseBundle.meta?.claims);
28
+ const query = new BundleQuery(baseBundle);
29
+ const dayEntryIds = query.getResourceIds({ dateFrom: dayRange.from, dateTo: dayRange.to });
30
+ const dayEntries = query.getResourceEntriesByIds(dayEntryIds);
31
+ const matchingDayEntry = dayEntries.find((entry) => matchesBatchOwner(entry, input.subject, input.actor));
32
+ const sameOwner = matchesBatchOwnerClaims(existingClaims, input.subject, input.actor);
33
+ const sameDay = asTrimmedString(existingClaims[VitalSignDayBatchClaim.Day]) === day;
34
+ const existingBatchId = asTrimmedString(baseBundle.id || existingClaims[VitalSignDayBatchClaim.Identifier]);
35
+ const reused = Boolean(existingBatchId && sameOwner && sameDay && (dayEntryIds.length > 0 || matchingDayEntry));
36
+ const batchId = reused ? existingBatchId : createCanonicalIdentifierUrn();
37
+ const bundle = {
38
+ ...baseBundle,
39
+ id: batchId,
40
+ meta: {
41
+ ...(baseBundle.meta || {}),
42
+ claims: {
43
+ ...existingClaims,
44
+ ...buildVitalSignDayBatchClaims(input),
45
+ [VitalSignDayBatchClaim.Identifier]: batchId,
46
+ },
47
+ },
48
+ data: [...(baseBundle.data || [])],
49
+ };
50
+ if (input.entry) {
51
+ bundle.data.push(cloneEntry(input.entry));
52
+ }
53
+ return {
54
+ batchId,
55
+ day,
56
+ reused,
57
+ bundle,
58
+ };
59
+ }
60
+ export function openOrCreateVitalSignDayBatchBundle(input) {
61
+ return resolveVitalSignDayBatchId(input).bundle;
62
+ }
63
+ function matchesBatchOwner(entry, subject, actor) {
64
+ const claims = asRecord(entry.resource?.meta?.claims || entry.meta?.claims);
65
+ return matchesBatchOwnerClaims(claims, subject, actor);
66
+ }
67
+ function matchesBatchOwnerClaims(claims, subject, actor) {
68
+ return asTrimmedString(claims[VitalSignDayBatchClaim.Subject]) === asTrimmedString(subject)
69
+ && asTrimmedString(claims[VitalSignDayBatchClaim.Actor]) === asTrimmedString(actor);
70
+ }
71
+ function resolveDayKey(value) {
72
+ if (value instanceof Date) {
73
+ return value.toISOString().slice(0, 10);
74
+ }
75
+ const raw = asTrimmedString(value);
76
+ if (!raw) {
77
+ return new Date().toISOString().slice(0, 10);
78
+ }
79
+ const parsed = Date.parse(raw);
80
+ if (Number.isNaN(parsed)) {
81
+ return raw.slice(0, 10);
82
+ }
83
+ return new Date(parsed).toISOString().slice(0, 10);
84
+ }
85
+ function resolveDayRange(day) {
86
+ return {
87
+ from: `${day}T00:00:00.000Z`,
88
+ to: `${day}T23:59:59.999Z`,
89
+ };
90
+ }
91
+ function asTrimmedString(value) {
92
+ if (value === undefined || value === null) {
93
+ return '';
94
+ }
95
+ return String(value).trim();
96
+ }
97
+ function asRecord(value) {
98
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
99
+ return {};
100
+ }
101
+ return value;
102
+ }
103
+ function cloneBundle(bundle) {
104
+ return JSON.parse(JSON.stringify(bundle));
105
+ }
106
+ function cloneEntry(entry) {
107
+ return JSON.parse(JSON.stringify(entry));
108
+ }
109
+ function createEmptyBundle() {
110
+ return {
111
+ resourceType: 'Bundle',
112
+ type: 'collection',
113
+ data: [],
114
+ };
115
+ }
@@ -0,0 +1,61 @@
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 { ObservationComponentEntryEditor } from './observation-component-entry-editor';
10
+ /**
11
+ * Typed editor for one staged VitalSign resource entry.
12
+ *
13
+ * Use this surface when the frontend needs a simple authoring path for common
14
+ * measurements such as heart rate, temperature, or blood pressure.
15
+ */
16
+ export declare class VitalSignEntryEditor extends ObservationComponentEntryEditor {
17
+ /** Overrides the canonical identifier when import or migration logic needs one explicit public id. */
18
+ setIdentifier(identifier?: string | null): this;
19
+ /** Returns the canonical identifier currently exposed for this vital-sign entry. */
20
+ getIdentifier(): string | undefined;
21
+ /** Ensures the entry has one synchronized canonical identifier across public claim, `resource.id`, and `fullUrl`. */
22
+ ensureIdentifier(): string;
23
+ /** Sets the subject/patient reference for this vital-sign observation. */
24
+ setSubject(subject: string): this;
25
+ /** Returns the subject/patient reference for this vital-sign observation. */
26
+ getSubject(): string | undefined;
27
+ /** Sets the observation status. */
28
+ setStatus(status: string): this;
29
+ /** Returns the observation status. */
30
+ getStatus(): string | undefined;
31
+ /** Sets the observation category, usually one of the shared vital-sign category descriptors. */
32
+ setCategory(category: CodingDescriptor | string): this;
33
+ /** Returns the observation category token. */
34
+ getCategory(): string | undefined;
35
+ /** Sets the observation date/effective time. */
36
+ setDate(date: string): this;
37
+ /** Returns the observation date/effective time. */
38
+ getDate(): string | undefined;
39
+ /** Sets one free-text note for the vital sign. */
40
+ setNote(note: string): this;
41
+ /** Returns the free-text note for the vital sign. */
42
+ getNote(): string | undefined;
43
+ /** Seeds the observation code and optional quantity unit for the selected vital-sign family. */
44
+ setVitalSignType(code: CodingDescriptor, unit?: CodingDescriptor): this;
45
+ /** Convenience helper for heart-rate authoring using the shared code/unit catalog. */
46
+ setHeartRate(value: number): this;
47
+ /** Returns the heart-rate numeric value. */
48
+ getHeartRate(): number | undefined;
49
+ /** Convenience helper for body-temperature authoring using the shared code/unit catalog. */
50
+ setBodyTemperature(value: number): this;
51
+ /** Returns the body-temperature numeric value. */
52
+ getBodyTemperature(): number | undefined;
53
+ /** Convenience helper for systolic blood-pressure authoring. */
54
+ setSystolicBloodPressure(value: number): this;
55
+ /** Returns the systolic blood-pressure numeric value. */
56
+ getSystolicBloodPressure(): number | undefined;
57
+ /** Convenience helper for diastolic blood-pressure authoring. */
58
+ setDiastolicBloodPressure(value: number): this;
59
+ /** Returns the diastolic blood-pressure numeric value. */
60
+ getDiastolicBloodPressure(): number | undefined;
61
+ }
@@ -0,0 +1,152 @@
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 { ObservationCategoryCodes, VitalSignsCodes, VitalSignsUnits } from '../constants/vital-signs.js';
9
+ import { ObservationClaim } from '../models/interoperable-claims/observation-claims.js';
10
+ import { BundleEditableResourceTypes } from '../models/bundle-editor-types.js';
11
+ import { createCanonicalIdentifierUrn, normalizeOptionalIdentifier } from './bundle-editor-helpers.js';
12
+ import { ObservationComponentEntryEditor } from './observation-component-entry-editor.js';
13
+ import { registerBundleEntryEditor } from './bundle-editor-registry.js';
14
+ /**
15
+ * Typed editor for one staged VitalSign resource entry.
16
+ *
17
+ * Use this surface when the frontend needs a simple authoring path for common
18
+ * measurements such as heart rate, temperature, or blood pressure.
19
+ */
20
+ export class VitalSignEntryEditor extends ObservationComponentEntryEditor {
21
+ /** Overrides the canonical identifier when import or migration logic needs one explicit public id. */
22
+ setIdentifier(identifier) {
23
+ const normalized = normalizeOptionalIdentifier(identifier);
24
+ if (!normalized) {
25
+ this.removeClaim(ObservationClaim.Identifier);
26
+ this.setResourceId(undefined);
27
+ this.setFullUrl(undefined);
28
+ return this;
29
+ }
30
+ this.setClaim(ObservationClaim.Identifier, normalized);
31
+ this.setResourceId(normalized);
32
+ this.setFullUrl(normalized);
33
+ return this;
34
+ }
35
+ /** Returns the canonical identifier currently exposed for this vital-sign entry. */
36
+ getIdentifier() {
37
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Identifier)
38
+ || this.getResourceId()
39
+ || this.getFullUrl());
40
+ }
41
+ /** Ensures the entry has one synchronized canonical identifier across public claim, `resource.id`, and `fullUrl`. */
42
+ ensureIdentifier() {
43
+ const existing = this.getIdentifier();
44
+ if (existing)
45
+ return existing;
46
+ const generated = createCanonicalIdentifierUrn();
47
+ this.setIdentifier(generated);
48
+ return generated;
49
+ }
50
+ /** Sets the subject/patient reference for this vital-sign observation. */
51
+ setSubject(subject) {
52
+ const normalized = String(subject).trim();
53
+ this.setClaim(ObservationClaim.Subject, normalized);
54
+ this.setClaim(ObservationClaim.Patient, normalized);
55
+ return this;
56
+ }
57
+ /** Returns the subject/patient reference for this vital-sign observation. */
58
+ getSubject() {
59
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Subject)
60
+ || this.getClaim(ObservationClaim.Patient));
61
+ }
62
+ /** Sets the observation status. */
63
+ setStatus(status) {
64
+ return this.setClaim(ObservationClaim.Status, String(status).trim());
65
+ }
66
+ /** Returns the observation status. */
67
+ getStatus() {
68
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Status));
69
+ }
70
+ /** Sets the observation category, usually one of the shared vital-sign category descriptors. */
71
+ setCategory(category) {
72
+ const normalized = typeof category === 'string' ? category.trim() : category.claim;
73
+ return this.setClaim(ObservationClaim.Category, normalized);
74
+ }
75
+ /** Returns the observation category token. */
76
+ getCategory() {
77
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Category));
78
+ }
79
+ /** Sets the observation date/effective time. */
80
+ setDate(date) {
81
+ const normalized = String(date).trim();
82
+ this.setClaim(ObservationClaim.Date, normalized);
83
+ this.setClaim(ObservationClaim.EffectiveDateTime, normalized);
84
+ return this;
85
+ }
86
+ /** Returns the observation date/effective time. */
87
+ getDate() {
88
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Date)
89
+ || this.getClaim(ObservationClaim.EffectiveDateTime));
90
+ }
91
+ /** Sets one free-text note for the vital sign. */
92
+ setNote(note) {
93
+ return this.setClaim(ObservationClaim.Note, String(note).trim());
94
+ }
95
+ /** Returns the free-text note for the vital sign. */
96
+ getNote() {
97
+ return normalizeOptionalIdentifier(this.getClaim(ObservationClaim.Note));
98
+ }
99
+ /** Seeds the observation code and optional quantity unit for the selected vital-sign family. */
100
+ setVitalSignType(code, unit) {
101
+ this.setCategory(ObservationCategoryCodes.VitalSigns);
102
+ this.setStatus(this.getStatus() || 'final');
103
+ this.setCode(code);
104
+ this.setCodeSystem(code.system);
105
+ this.setCodeValue(code.code);
106
+ if (code.display) {
107
+ this.setCodeDisplay(code.display);
108
+ this.setCodeTextLocal(code.display);
109
+ }
110
+ if (unit) {
111
+ this.setValueQuantityUnit(unit);
112
+ }
113
+ return this;
114
+ }
115
+ /** Convenience helper for heart-rate authoring using the shared code/unit catalog. */
116
+ setHeartRate(value) {
117
+ this.setVitalSignType(VitalSignsCodes.HeartRate, VitalSignsUnits.BeatsPerMinute);
118
+ return this.setValueQuantityNumber(value);
119
+ }
120
+ /** Returns the heart-rate numeric value. */
121
+ getHeartRate() {
122
+ return this.getValueQuantityNumber();
123
+ }
124
+ /** Convenience helper for body-temperature authoring using the shared code/unit catalog. */
125
+ setBodyTemperature(value) {
126
+ this.setVitalSignType(VitalSignsCodes.BodyTemperature, VitalSignsUnits.Celsius);
127
+ return this.setValueQuantityNumber(value);
128
+ }
129
+ /** Returns the body-temperature numeric value. */
130
+ getBodyTemperature() {
131
+ return this.getValueQuantityNumber();
132
+ }
133
+ /** Convenience helper for systolic blood-pressure authoring. */
134
+ setSystolicBloodPressure(value) {
135
+ this.setVitalSignType(VitalSignsCodes.SystolicBloodPressure, VitalSignsUnits.MillimeterOfMercury);
136
+ return this.setValueQuantityNumber(value);
137
+ }
138
+ /** Returns the systolic blood-pressure numeric value. */
139
+ getSystolicBloodPressure() {
140
+ return this.getValueQuantityNumber();
141
+ }
142
+ /** Convenience helper for diastolic blood-pressure authoring. */
143
+ setDiastolicBloodPressure(value) {
144
+ this.setVitalSignType(VitalSignsCodes.DiastolicBloodPressure, VitalSignsUnits.MillimeterOfMercury);
145
+ return this.setValueQuantityNumber(value);
146
+ }
147
+ /** Returns the diastolic blood-pressure numeric value. */
148
+ getDiastolicBloodPressure() {
149
+ return this.getValueQuantityNumber();
150
+ }
151
+ }
152
+ registerBundleEntryEditor(BundleEditableResourceTypes.vitalSign, VitalSignEntryEditor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-common-utils-ts",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,6 +11,7 @@
11
11
  "@stablelib/utf8": "^1.0.2",
12
12
  "base-x": "^4.0.0",
13
13
  "gdc-common-utils-ts": "^2.0.1",
14
+ "jose": "^4.15.9",
14
15
  "pako": "^2.1.0"
15
16
  },
16
17
  "scripts": {