gdc-common-utils-ts 1.20.2 → 1.23.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 (86) hide show
  1. package/README.md +2 -2
  2. package/dist/claims/claims-helpers-related-person.d.ts +14 -0
  3. package/dist/claims/claims-helpers-related-person.js +28 -0
  4. package/dist/constants/Schemas.d.ts +3 -0
  5. package/dist/constants/Schemas.js +3 -0
  6. package/dist/constants/fhir-code-systems.d.ts +1 -0
  7. package/dist/constants/fhir-code-systems.js +1 -0
  8. package/dist/constants/fhir-resource-types.d.ts +2 -0
  9. package/dist/constants/fhir-resource-types.js +1 -0
  10. package/dist/constants/index.d.ts +3 -0
  11. package/dist/constants/index.js +3 -0
  12. package/dist/constants/individual-sections.d.ts +210 -0
  13. package/dist/constants/individual-sections.js +35 -0
  14. package/dist/constants/lifecycle.d.ts +17 -0
  15. package/dist/constants/lifecycle.js +18 -0
  16. package/dist/constants/observation-category.d.ts +72 -0
  17. package/dist/constants/observation-category.js +30 -0
  18. package/dist/constants/schemaorg.d.ts +4 -0
  19. package/dist/constants/schemaorg.js +4 -0
  20. package/dist/constants/vital-signs.d.ts +2 -17
  21. package/dist/constants/vital-signs.js +1 -6
  22. package/dist/convert/convert-observation.d.ts +20 -2
  23. package/dist/convert/convert-observation.js +80 -9
  24. package/dist/examples/index.d.ts +2 -0
  25. package/dist/examples/index.js +2 -0
  26. package/dist/examples/invoice.d.ts +37 -0
  27. package/dist/examples/invoice.js +72 -0
  28. package/dist/examples/license.d.ts +161 -0
  29. package/dist/examples/license.js +136 -7
  30. package/dist/examples/lifecycle.d.ts +44 -0
  31. package/dist/examples/lifecycle.js +25 -0
  32. package/dist/examples/related-person.d.ts +348 -0
  33. package/dist/examples/related-person.js +184 -2
  34. package/dist/examples/shared.d.ts +110 -8
  35. package/dist/examples/shared.js +129 -17
  36. package/dist/examples/vital-signs.d.ts +56 -0
  37. package/dist/examples/vital-signs.js +159 -0
  38. package/dist/models/fhir-documents.d.ts +35 -0
  39. package/dist/models/indexing.d.ts +68 -6
  40. package/dist/models/indexing.js +294 -11
  41. package/dist/models/interoperable-claims/index.d.ts +1 -0
  42. package/dist/models/interoperable-claims/index.js +1 -0
  43. package/dist/models/interoperable-claims/invoice-claims.d.ts +277 -0
  44. package/dist/models/interoperable-claims/invoice-claims.js +353 -0
  45. package/dist/models/interoperable-claims/observation-claims.d.ts +253 -1
  46. package/dist/models/interoperable-claims/observation-claims.js +249 -3
  47. package/dist/models/interoperable-claims.d.ts +1 -1
  48. package/dist/models/interoperable-claims.js +1 -1
  49. package/dist/models/urlPath.d.ts +3 -1
  50. package/dist/models/urlPath.js +2 -0
  51. package/dist/utils/bundle-document-builder.js +22 -4
  52. package/dist/utils/bundle-editor.d.ts +105 -2
  53. package/dist/utils/bundle-editor.js +282 -2
  54. package/dist/utils/clinical-resource-converters.d.ts +4 -4
  55. package/dist/utils/clinical-resource-converters.js +5 -5
  56. package/dist/utils/communication-attached-bundle-session.d.ts +11 -0
  57. package/dist/utils/communication-attached-bundle-session.js +29 -0
  58. package/dist/utils/consent-lifecycle-result-reader.d.ts +24 -0
  59. package/dist/utils/consent-lifecycle-result-reader.js +27 -0
  60. package/dist/utils/employee.d.ts +25 -0
  61. package/dist/utils/employee.js +57 -0
  62. package/dist/utils/gw-core-path.d.ts +24 -0
  63. package/dist/utils/gw-core-path.js +21 -0
  64. package/dist/utils/index.d.ts +11 -0
  65. package/dist/utils/index.js +11 -0
  66. package/dist/utils/individual-bundle-vault.d.ts +144 -0
  67. package/dist/utils/individual-bundle-vault.js +455 -0
  68. package/dist/utils/individual-organization-lifecycle.d.ts +104 -0
  69. package/dist/utils/individual-organization-lifecycle.js +179 -0
  70. package/dist/utils/interoperable-resource-operation.d.ts +158 -0
  71. package/dist/utils/interoperable-resource-operation.js +244 -0
  72. package/dist/utils/invoice-bundle.d.ts +82 -0
  73. package/dist/utils/invoice-bundle.js +240 -0
  74. package/dist/utils/license-commercial-search.d.ts +118 -0
  75. package/dist/utils/license-commercial-search.js +228 -0
  76. package/dist/utils/license-list-search.d.ts +105 -0
  77. package/dist/utils/license-list-search.js +209 -0
  78. package/dist/utils/license-offer-order.d.ts +107 -0
  79. package/dist/utils/license-offer-order.js +262 -0
  80. package/dist/utils/license.d.ts +6 -0
  81. package/dist/utils/license.js +6 -0
  82. package/dist/utils/lifecycle-result-reader.d.ts +33 -0
  83. package/dist/utils/lifecycle-result-reader.js +99 -0
  84. package/dist/utils/related-person-list.d.ts +20 -0
  85. package/dist/utils/related-person-list.js +54 -0
  86. package/package.json +2 -1
@@ -1,26 +1,278 @@
1
1
  import type { ClaimSpec } from './types';
2
+ /**
3
+ * Canonical flat claims for a persisted Observation.
4
+ *
5
+ * Naming contract:
6
+ * - version-specific suffixes go at the end of helper names, e.g.
7
+ * `observationToFlatFhirR4`, not `observationFhirR4ToFlat`
8
+ * - short canonical keys use `Observation.<concrete-param>`
9
+ * - scalarized extended keys use `org.hl7.fhir.api.Observation.<concrete-param>`
10
+ * - concrete parameters must stay kebab-case
11
+ *
12
+ * Observation scope reference:
13
+ * - https://hl7.org/fhir/observation.html
14
+ * - HL7 uses Observation for vital signs, laboratory data, imaging results,
15
+ * clinical findings, device measurements, device settings, assessment tools,
16
+ * personal characteristics, social history, core characteristics, and
17
+ * product quality tests.
18
+ *
19
+ * Important runtime distinction used by local-first Vital Signs storage:
20
+ * - a visible/primary vital-sign Observation carries `Observation.status`
21
+ * - a reduced indexed component derived from FHIR `component` may carry only
22
+ * `identifier` and `subject` plus its own component/value claims, but no
23
+ * `status`; those reduced rows are kept for reconstruction/export and must be
24
+ * ignored by normal Vital Signs list/search operations.
25
+ *
26
+ * TODO Extensions:
27
+ * - Observation.apgar-appearance-number
28
+ * - Observation.apgar-pulse-number
29
+ * - Observation.apgar-grimace-number
30
+ * - Observation.apgar-activity-number
31
+ * - Observation.apgar-respiration-number
32
+ */
2
33
  export declare const ObservationClaim: {
34
+ /** Upstream order/request reference list. Example: `ServiceRequest/sr-1`. */
3
35
  readonly BasedOn: "Observation.based-on";
36
+ /** Observation category token list. Example: `http://terminology.hl7.org/CodeSystem/observation-category|vital-signs`. */
4
37
  readonly Category: "Observation.category";
38
+ /** Observation/category/code system URL. Example: `http://loinc.org`. */
39
+ readonly CodeSystem: "Observation.code-system";
40
+ /** Observation/category/code value. Example: `8867-4`. */
41
+ readonly CodeValue: "Observation.code-value";
42
+ /** Local-language label used by UI/forms. Example: `Heart rate`. */
43
+ readonly CodeText: "Observation.code-text";
44
+ /** Canonical English/international display. Example: `Heart rate`. */
45
+ readonly CodeDisplay: "Observation.code-display";
46
+ /** Observation or component code as `system|code`. Example: `http://loinc.org|8867-4`. */
5
47
  readonly Code: "Observation.code";
48
+ /** Effective clinical date/dateTime when stored as one scalar string. Example: `2026-06-01T10:00:00Z`. */
6
49
  readonly Date: "Observation.date";
50
+ /** Device reference. Example: `Device/dev-1`. */
7
51
  readonly Device: "Observation.device";
52
+ /** Encounter reference. Example: `Encounter/enc-1`. */
8
53
  readonly Encounter: "Observation.encounter";
54
+ /** Focus reference list. Example: `Condition/cond-1`. */
9
55
  readonly Focus: "Observation.focus";
56
+ /** Child Observation references for panels/groups. Example: `Observation/hr-1,Observation/temp-1`. */
10
57
  readonly HasMember: "Observation.has-member";
58
+ /** Optional synthetic tags summarizing component presence on a composite observation. Example: `bp-systolic,bp-diastolic`. */
59
+ readonly ComponentTags: "Observation.component-tags";
60
+ /** Optional component code values present on a composite observation. Example: `8480-6,8462-4`. */
61
+ readonly ComponentCodeValues: "Observation.component-code-values";
62
+ /** Optional human-readable component names. Example: `Systolic blood pressure,Diastolic blood pressure`. */
63
+ readonly ComponentNames: "Observation.component-names";
64
+ /** Business/local identifier. Example: `hr-1`. */
11
65
  readonly Identifier: "Observation.identifier";
66
+ /** BCP-47 language tag. Example: `en`, `es`. */
67
+ readonly Language: "Observation.language";
68
+ /** Observation method token. Example: `http://snomed.info/sct|252465000`. */
12
69
  readonly Method: "Observation.method";
70
+ /** Optional compatibility alias of `Observation.subject`. Example: `did:web:patient.example.org:individual:123`. */
13
71
  readonly Patient: "Observation.patient";
72
+ /** Performer reference list. Example: `Practitioner/prac-1`. */
14
73
  readonly Performer: "Observation.performer";
74
+ /** Specimen reference. Example: `Specimen/spec-1`. */
15
75
  readonly Specimen: "Observation.specimen";
76
+ /** Observation status. Presence marks one visible/searchable main observation. Example: `final`. */
16
77
  readonly Status: "Observation.status";
78
+ /** Canonical subject reference. Example: `did:web:patient.example.org:individual:123`. */
17
79
  readonly Subject: "Observation.subject";
80
+ /** Value as coded concept token. Example: `http://terminology.hl7.org/CodeSystem/data-absent-reason|not-performed`. */
18
81
  readonly ValueConcept: "Observation.value-concept";
82
+ /** Value concept system URL. Example: `http://snomed.info/sct`. */
83
+ readonly ValueConceptSystem: "Observation.value-concept-system";
84
+ /** Value concept code value. Example: `373066001`. */
85
+ readonly ValueConceptValue: "Observation.value-concept-value";
86
+ /** Local-language label for the coded value. Example: `Never smoker`. */
87
+ readonly ValueConceptText: "Observation.value-concept-text";
88
+ /** Canonical English/international display for the coded value. Example: `Absent`. */
89
+ readonly ValueConceptDisplay: "Observation.value-concept-display";
90
+ /** Value when the result itself is a date/dateTime. Example: `2026-06-01`. */
19
91
  readonly ValueDate: "Observation.value-date";
92
+ /** Optional FHIR Quantity comparator. Allowed: `<`, `<=`, `>=`, `>`. Example: `>=`. */
93
+ readonly ValueQuantityComparator: "Observation.value-quantity-comparator";
94
+ /** Numeric scalar of the observation value. Example heart rate: `72`. Example temperature: `38.4`. */
95
+ readonly ValueQuantityNumber: "Observation.value-quantity-number";
96
+ /** Human-readable quantity unit. Example: `/min`, `mmHg`, `Cel`. */
97
+ readonly ValueQuantityUnit: "Observation.value-quantity-unit";
98
+ /** Aggregated score total for composite assessment observations when present. Example: `8`. */
99
+ readonly ScoreTotalNumber: "Observation.score-total-number";
100
+ /** Indexed systolic scalar copied onto the parent blood pressure observation. Example: `120`. */
101
+ readonly BloodPressureSystolicNumber: "Observation.bp-systolic-number";
102
+ /** Indexed diastolic scalar copied onto the parent blood pressure observation. Example: `78`. */
103
+ readonly BloodPressureDiastolicNumber: "Observation.bp-diastolic-number";
104
+ /** Free-text value when the result is narrative. Example: `Former smoker`. */
20
105
  readonly ValueString: "Observation.value-string";
21
- readonly ComponentCode: "Observation.component-code";
106
+ /** User-authored note. Example: `Measured after resting 5 minutes.` */
22
107
  readonly Note: "Observation.note";
108
+ /** FHIR-compatible explicit `effectiveDateTime` fallback. Example: `2026-06-01T10:00:00Z`. */
23
109
  readonly EffectiveDateTime: "Observation.effectiveDateTime";
24
110
  };
25
111
  export type ObservationClaimKey = typeof ObservationClaim[keyof typeof ObservationClaim];
112
+ export type SplitCodingClaims = Readonly<{
113
+ system?: string;
114
+ value?: string;
115
+ text?: string;
116
+ display?: string;
117
+ }>;
118
+ /**
119
+ * Builds the legacy compact `system|code` token from split claims.
120
+ *
121
+ * Use this only for compatibility/export. Frontend authoring should prefer the
122
+ * split fields such as `code-value`, `code-text`, and `value-concept-value`.
123
+ */
124
+ export declare function buildObservationCodingClaim(input: SplitCodingClaims): string | undefined;
125
+ /**
126
+ * Splits a compact token such as `http://loinc.org|8867-4` into separate
127
+ * claims that are easier for forms, local storage, and numeric/text filters.
128
+ */
129
+ export declare function splitObservationCodingClaim(value: unknown): SplitCodingClaims;
130
+ /**
131
+ * Reduced claim surface that mirrors FHIR `Observation.component`.
132
+ *
133
+ * By design this shape does not include `status`, `subject`, or other
134
+ * top-level Observation context fields from FHIR. When a component needs to be
135
+ * persisted/indexed locally, the transformer may add only the minimum
136
+ * operational fields (`identifier`, `subject`) in a separate indexed shape.
137
+ */
138
+ export interface ClaimsObservationComponent {
139
+ /** Code system URL. Example: `http://loinc.org`. The SDK can derive the compact token from this and `code-value`. */
140
+ [ObservationClaim.CodeSystem]?: string;
141
+ /** Code value. Example: `8480-6`. This is the main code field for UI authoring and search. */
142
+ [ObservationClaim.CodeValue]?: string;
143
+ /** Local-language human label used by forms. Example: `Presión arterial sistólica`. */
144
+ [ObservationClaim.CodeText]?: string;
145
+ /** Canonical English/international display. Example: `Systolic blood pressure`. */
146
+ [ObservationClaim.CodeDisplay]?: string;
147
+ /** Component/observation code as `system|code`. Example: `http://loinc.org|8480-6`. */
148
+ [ObservationClaim.Code]?: string;
149
+ /** Value concept system URL. Example: `http://terminology.hl7.org/CodeSystem/data-absent-reason`. */
150
+ [ObservationClaim.ValueConceptSystem]?: string;
151
+ /** Value concept code value. Example: `not-performed`. */
152
+ [ObservationClaim.ValueConceptValue]?: string;
153
+ /** Local-language label for the value concept. Example: `No realizado`. */
154
+ [ObservationClaim.ValueConceptText]?: string;
155
+ /** Canonical English/international display for the value concept. Example: `Not performed`. */
156
+ [ObservationClaim.ValueConceptDisplay]?: string;
157
+ /** Value as coded concept token. Example: `http://terminology.hl7.org/CodeSystem/data-absent-reason|not-performed`. */
158
+ [ObservationClaim.ValueConcept]?: string;
159
+ /** Value when the observation result itself is one date/dateTime. Example: `2026-06-01T10:00:00Z`. */
160
+ [ObservationClaim.ValueDate]?: string;
161
+ /** Free-text value when the result is narrative rather than coded/quantified. Example: `Former smoker`. */
162
+ [ObservationClaim.ValueString]?: string;
163
+ /** Optional FHIR Quantity comparator. Allowed values: `<`, `<=`, `>=`, `>`. Example: `>=`. */
164
+ [ObservationClaim.ValueQuantityComparator]?: string;
165
+ /** Numeric scalar of the observed value. Example heart rate: `72`. Example temperature: `38.4`. */
166
+ [ObservationClaim.ValueQuantityNumber]?: string | number;
167
+ /** Human-readable quantity unit. Example: `/min`, `mmHg`, `Cel`. */
168
+ [ObservationClaim.ValueQuantityUnit]?: string;
169
+ }
170
+ /**
171
+ * Reduced component claims after local indexing adds only the minimal locator
172
+ * information required by vault persistence and parent/child traversal.
173
+ */
174
+ export interface ClaimsObservationComponentIndexed extends ClaimsObservationComponent {
175
+ /** Synthetic/local identifier added during indexing of a reduced imported component. Example: `bp-systolic-1`. */
176
+ [ObservationClaim.Identifier]: string;
177
+ /** Subject inherited from the parent observation so the reduced row can be indexed and located locally. */
178
+ [ObservationClaim.Subject]: string;
179
+ /** Optional compatibility alias of `Observation.subject`. */
180
+ [ObservationClaim.Patient]?: string;
181
+ }
182
+ /**
183
+ * Minimal visible Vital Signs Observation claims.
184
+ *
185
+ * This is the practical authoring/search surface for local-first individual
186
+ * apps. A row without `Observation.status` is not considered a visible vital
187
+ * sign result and should be ignored by normal section list/search operations.
188
+ */
189
+ export interface ClaimsObservationVitalSigns extends ClaimsObservationComponentIndexed {
190
+ /** Required for visible/searchable vital signs. If missing, treat the row as internal/supporting only. Example: `final`. */
191
+ [ObservationClaim.Status]: string;
192
+ /** Must contain the vital-signs category token for visible Vital Signs rows. */
193
+ [ObservationClaim.Category]: string;
194
+ /** Vital Sign LOINC code. Example heart rate: `http://loinc.org|8867-4`. */
195
+ [ObservationClaim.Code]: string;
196
+ /** Clinical time of the observation when represented as one scalar date/dateTime. */
197
+ [ObservationClaim.Date]?: string;
198
+ /** FHIR-compatible explicit `effectiveDateTime` fallback. Example: `2026-06-01T10:00:00Z`. */
199
+ [ObservationClaim.EffectiveDateTime]?: string;
200
+ /** Language of authored text/narrative. Example: `en`, `es`. */
201
+ [ObservationClaim.Language]?: string;
202
+ /** Observation method token when relevant. Example: `http://snomed.info/sct|252465000`. */
203
+ [ObservationClaim.Method]?: string;
204
+ /** User-authored note. Example: `Measured after resting 5 minutes.` */
205
+ [ObservationClaim.Note]?: string;
206
+ }
207
+ /**
208
+ * General Observation claims for persisted/searchable clinical resources.
209
+ *
210
+ * This is the widest flat contract currently used by the package. It extends
211
+ * the Vital Signs-visible shape so consumers can reuse one traversal/query
212
+ * model while adding broader Observation fields such as encounter, performer,
213
+ * specimen, focus, and group membership.
214
+ */
215
+ export interface ClaimsObservationGeneral extends ClaimsObservationVitalSigns {
216
+ /** Upstream order/request reference list. Example: `ServiceRequest/sr-1`. */
217
+ [ObservationClaim.BasedOn]?: string;
218
+ /** Device reference. Example: `Device/dev-1`. */
219
+ [ObservationClaim.Device]?: string;
220
+ /** Encounter reference. Example: `Encounter/enc-1`. */
221
+ [ObservationClaim.Encounter]?: string;
222
+ /** Focus reference list when the observation is about another target. Example: `Condition/cond-1`. */
223
+ [ObservationClaim.Focus]?: string;
224
+ /** Child Observation references for panels/groups. Example: `Observation/hr-1,Observation/temp-1`. */
225
+ [ObservationClaim.HasMember]?: string;
226
+ /** Synthetic tags summarizing component presence on a composite observation. Example: `bp-systolic,bp-diastolic`. */
227
+ [ObservationClaim.ComponentTags]?: string;
228
+ /** Component code values summarized on the parent observation. Example: `8480-6,8462-4`. */
229
+ [ObservationClaim.ComponentCodeValues]?: string;
230
+ /** Human-readable component names summarized on the parent observation. Example: `Systolic blood pressure,Diastolic blood pressure`. */
231
+ [ObservationClaim.ComponentNames]?: string;
232
+ /** Performer reference list. Example: `Practitioner/prac-1`. */
233
+ [ObservationClaim.Performer]?: string;
234
+ /** Specimen reference. Example: `Specimen/spec-1`. */
235
+ [ObservationClaim.Specimen]?: string;
236
+ /** Total assessment score summarized on the parent observation when applicable. Example: `8`. */
237
+ [ObservationClaim.ScoreTotalNumber]?: string | number;
238
+ /** Parent blood pressure panel copy of the systolic numeric value. Example: `120`. */
239
+ [ObservationClaim.BloodPressureSystolicNumber]?: string | number;
240
+ /** Parent blood pressure panel copy of the diastolic numeric value. Example: `78`. */
241
+ [ObservationClaim.BloodPressureDiastolicNumber]?: string | number;
242
+ }
243
+ /**
244
+ * Backwards-compatible alias kept during the current refactor.
245
+ *
246
+ * Prefer `ClaimsObservationVitalSigns` in new code when the row is expected to
247
+ * be one visible/searchable vital-sign Observation.
248
+ */
249
+ export type ClaimsVitalSign = ClaimsObservationVitalSigns;
250
+ /**
251
+ * Full persisted claim surface for a general Observation row in local storage.
252
+ *
253
+ * This list is intentionally broader than the searchable/indexable subset.
254
+ * Free-text or UI-only fields may exist here even when they must stay out of
255
+ * blind-query/search indexes.
256
+ */
257
+ export declare const ObservationGeneralClaimsList: readonly ["Observation.based-on", "Observation.category", "Observation.code-system", "Observation.code-value", "Observation.code-text", "Observation.code-display", "Observation.code", "Observation.date", "Observation.device", "Observation.encounter", "Observation.effectiveDateTime", "Observation.focus", "Observation.has-member", "Observation.component-tags", "Observation.component-code-values", "Observation.component-names", "Observation.identifier", "Observation.language", "Observation.method", "Observation.note", "Observation.patient", "Observation.performer", "Observation.specimen", "Observation.status", "Observation.subject", "Observation.value-concept-system", "Observation.value-concept-value", "Observation.value-concept-text", "Observation.value-concept-display", "Observation.value-concept", "Observation.value-date", "Observation.value-quantity-comparator", "Observation.value-quantity-number", "Observation.value-quantity-unit", "Observation.score-total-number", "Observation.bp-systolic-number", "Observation.bp-diastolic-number", "Observation.value-string"];
258
+ /**
259
+ * Full persisted claim surface for visible/searchable Vital Signs rows.
260
+ *
261
+ * This keeps the claims-first authoring fields but still avoids introducing
262
+ * fields that only belong to broader Observation families.
263
+ */
264
+ export declare const ObservationVitalSignsClaimsList: readonly ["Observation.category", "Observation.code-system", "Observation.code-value", "Observation.code-text", "Observation.code-display", "Observation.code", "Observation.date", "Observation.effectiveDateTime", "Observation.has-member", "Observation.component-tags", "Observation.component-code-values", "Observation.component-names", "Observation.identifier", "Observation.language", "Observation.method", "Observation.note", "Observation.patient", "Observation.status", "Observation.subject", "Observation.value-concept-system", "Observation.value-concept-value", "Observation.value-concept-text", "Observation.value-concept-display", "Observation.value-concept", "Observation.value-date", "Observation.value-quantity-comparator", "Observation.value-quantity-number", "Observation.value-quantity-unit", "Observation.score-total-number", "Observation.bp-systolic-number", "Observation.bp-diastolic-number", "Observation.value-string"];
26
265
  export declare const ObservationClaimSpecs: ClaimSpec[];
266
+ /**
267
+ * Returns `true` when the flat claims represent one visible/searchable vital
268
+ * sign Observation row.
269
+ *
270
+ * Current rule:
271
+ * - must be categorized as `vital-signs`
272
+ * - must carry `Observation.status`
273
+ *
274
+ * Reduced indexed component rows derived from FHIR `component` intentionally do
275
+ * not carry `Observation.status`, so they are excluded from normal UI list and
276
+ * search results even though they remain persisted for reconstruction/export.
277
+ */
278
+ export declare function isDisplayableVitalSignObservationClaims(claims: Record<string, unknown> | undefined): boolean;
@@ -1,48 +1,294 @@
1
1
  // Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
2
2
  // File: src/models/interoperable-claims/observation-claims.ts
3
+ import { ObservationCategoryCodes } from '../../constants/observation-category.js';
4
+ /**
5
+ * Canonical flat claims for a persisted Observation.
6
+ *
7
+ * Naming contract:
8
+ * - version-specific suffixes go at the end of helper names, e.g.
9
+ * `observationToFlatFhirR4`, not `observationFhirR4ToFlat`
10
+ * - short canonical keys use `Observation.<concrete-param>`
11
+ * - scalarized extended keys use `org.hl7.fhir.api.Observation.<concrete-param>`
12
+ * - concrete parameters must stay kebab-case
13
+ *
14
+ * Observation scope reference:
15
+ * - https://hl7.org/fhir/observation.html
16
+ * - HL7 uses Observation for vital signs, laboratory data, imaging results,
17
+ * clinical findings, device measurements, device settings, assessment tools,
18
+ * personal characteristics, social history, core characteristics, and
19
+ * product quality tests.
20
+ *
21
+ * Important runtime distinction used by local-first Vital Signs storage:
22
+ * - a visible/primary vital-sign Observation carries `Observation.status`
23
+ * - a reduced indexed component derived from FHIR `component` may carry only
24
+ * `identifier` and `subject` plus its own component/value claims, but no
25
+ * `status`; those reduced rows are kept for reconstruction/export and must be
26
+ * ignored by normal Vital Signs list/search operations.
27
+ *
28
+ * TODO Extensions:
29
+ * - Observation.apgar-appearance-number
30
+ * - Observation.apgar-pulse-number
31
+ * - Observation.apgar-grimace-number
32
+ * - Observation.apgar-activity-number
33
+ * - Observation.apgar-respiration-number
34
+ */
3
35
  export const ObservationClaim = {
36
+ /** Upstream order/request reference list. Example: `ServiceRequest/sr-1`. */
4
37
  BasedOn: 'Observation.based-on',
38
+ /** Observation category token list. Example: `http://terminology.hl7.org/CodeSystem/observation-category|vital-signs`. */
5
39
  Category: 'Observation.category',
40
+ /** Observation/category/code system URL. Example: `http://loinc.org`. */
41
+ CodeSystem: 'Observation.code-system',
42
+ /** Observation/category/code value. Example: `8867-4`. */
43
+ CodeValue: 'Observation.code-value',
44
+ /** Local-language label used by UI/forms. Example: `Heart rate`. */
45
+ CodeText: 'Observation.code-text',
46
+ /** Canonical English/international display. Example: `Heart rate`. */
47
+ CodeDisplay: 'Observation.code-display',
48
+ /** Observation or component code as `system|code`. Example: `http://loinc.org|8867-4`. */
6
49
  Code: 'Observation.code',
50
+ /** Effective clinical date/dateTime when stored as one scalar string. Example: `2026-06-01T10:00:00Z`. */
7
51
  Date: 'Observation.date',
52
+ /** Device reference. Example: `Device/dev-1`. */
8
53
  Device: 'Observation.device',
54
+ /** Encounter reference. Example: `Encounter/enc-1`. */
9
55
  Encounter: 'Observation.encounter',
56
+ /** Focus reference list. Example: `Condition/cond-1`. */
10
57
  Focus: 'Observation.focus',
58
+ /** Child Observation references for panels/groups. Example: `Observation/hr-1,Observation/temp-1`. */
11
59
  HasMember: 'Observation.has-member',
60
+ /** Optional synthetic tags summarizing component presence on a composite observation. Example: `bp-systolic,bp-diastolic`. */
61
+ ComponentTags: 'Observation.component-tags',
62
+ /** Optional component code values present on a composite observation. Example: `8480-6,8462-4`. */
63
+ ComponentCodeValues: 'Observation.component-code-values',
64
+ /** Optional human-readable component names. Example: `Systolic blood pressure,Diastolic blood pressure`. */
65
+ ComponentNames: 'Observation.component-names',
66
+ /** Business/local identifier. Example: `hr-1`. */
12
67
  Identifier: 'Observation.identifier',
68
+ /** BCP-47 language tag. Example: `en`, `es`. */
69
+ Language: 'Observation.language',
70
+ /** Observation method token. Example: `http://snomed.info/sct|252465000`. */
13
71
  Method: 'Observation.method',
72
+ /** Optional compatibility alias of `Observation.subject`. Example: `did:web:patient.example.org:individual:123`. */
14
73
  Patient: 'Observation.patient',
74
+ /** Performer reference list. Example: `Practitioner/prac-1`. */
15
75
  Performer: 'Observation.performer',
76
+ /** Specimen reference. Example: `Specimen/spec-1`. */
16
77
  Specimen: 'Observation.specimen',
78
+ /** Observation status. Presence marks one visible/searchable main observation. Example: `final`. */
17
79
  Status: 'Observation.status',
80
+ /** Canonical subject reference. Example: `did:web:patient.example.org:individual:123`. */
18
81
  Subject: 'Observation.subject',
82
+ /** Value as coded concept token. Example: `http://terminology.hl7.org/CodeSystem/data-absent-reason|not-performed`. */
19
83
  ValueConcept: 'Observation.value-concept',
84
+ /** Value concept system URL. Example: `http://snomed.info/sct`. */
85
+ ValueConceptSystem: 'Observation.value-concept-system',
86
+ /** Value concept code value. Example: `373066001`. */
87
+ ValueConceptValue: 'Observation.value-concept-value',
88
+ /** Local-language label for the coded value. Example: `Never smoker`. */
89
+ ValueConceptText: 'Observation.value-concept-text',
90
+ /** Canonical English/international display for the coded value. Example: `Absent`. */
91
+ ValueConceptDisplay: 'Observation.value-concept-display',
92
+ /** Value when the result itself is a date/dateTime. Example: `2026-06-01`. */
20
93
  ValueDate: 'Observation.value-date',
94
+ /** Optional FHIR Quantity comparator. Allowed: `<`, `<=`, `>=`, `>`. Example: `>=`. */
95
+ ValueQuantityComparator: 'Observation.value-quantity-comparator',
96
+ /** Numeric scalar of the observation value. Example heart rate: `72`. Example temperature: `38.4`. */
97
+ ValueQuantityNumber: 'Observation.value-quantity-number',
98
+ /** Human-readable quantity unit. Example: `/min`, `mmHg`, `Cel`. */
99
+ ValueQuantityUnit: 'Observation.value-quantity-unit',
100
+ /** Aggregated score total for composite assessment observations when present. Example: `8`. */
101
+ ScoreTotalNumber: 'Observation.score-total-number',
102
+ /** Indexed systolic scalar copied onto the parent blood pressure observation. Example: `120`. */
103
+ BloodPressureSystolicNumber: 'Observation.bp-systolic-number',
104
+ /** Indexed diastolic scalar copied onto the parent blood pressure observation. Example: `78`. */
105
+ BloodPressureDiastolicNumber: 'Observation.bp-diastolic-number',
106
+ /** Free-text value when the result is narrative. Example: `Former smoker`. */
21
107
  ValueString: 'Observation.value-string',
22
- ComponentCode: 'Observation.component-code',
108
+ /** User-authored note. Example: `Measured after resting 5 minutes.` */
23
109
  Note: 'Observation.note',
110
+ /** FHIR-compatible explicit `effectiveDateTime` fallback. Example: `2026-06-01T10:00:00Z`. */
24
111
  EffectiveDateTime: 'Observation.effectiveDateTime',
25
112
  };
113
+ /**
114
+ * Builds the legacy compact `system|code` token from split claims.
115
+ *
116
+ * Use this only for compatibility/export. Frontend authoring should prefer the
117
+ * split fields such as `code-value`, `code-text`, and `value-concept-value`.
118
+ */
119
+ export function buildObservationCodingClaim(input) {
120
+ const value = String(input.value || '').trim();
121
+ const system = String(input.system || '').trim();
122
+ if (!value)
123
+ return undefined;
124
+ return system ? `${system}|${value}` : value;
125
+ }
126
+ /**
127
+ * Splits a compact token such as `http://loinc.org|8867-4` into separate
128
+ * claims that are easier for forms, local storage, and numeric/text filters.
129
+ */
130
+ export function splitObservationCodingClaim(value) {
131
+ const token = String(value || '').trim();
132
+ if (!token) {
133
+ return {};
134
+ }
135
+ const separatorIndex = token.indexOf('|');
136
+ if (separatorIndex < 0) {
137
+ return { value: token };
138
+ }
139
+ return {
140
+ system: token.slice(0, separatorIndex) || undefined,
141
+ value: token.slice(separatorIndex + 1) || undefined,
142
+ };
143
+ }
144
+ /**
145
+ * Full persisted claim surface for a general Observation row in local storage.
146
+ *
147
+ * This list is intentionally broader than the searchable/indexable subset.
148
+ * Free-text or UI-only fields may exist here even when they must stay out of
149
+ * blind-query/search indexes.
150
+ */
151
+ export const ObservationGeneralClaimsList = [
152
+ ObservationClaim.BasedOn,
153
+ ObservationClaim.Category,
154
+ ObservationClaim.CodeSystem,
155
+ ObservationClaim.CodeValue,
156
+ ObservationClaim.CodeText,
157
+ ObservationClaim.CodeDisplay,
158
+ ObservationClaim.Code,
159
+ ObservationClaim.Date,
160
+ ObservationClaim.Device,
161
+ ObservationClaim.Encounter,
162
+ ObservationClaim.EffectiveDateTime,
163
+ ObservationClaim.Focus,
164
+ ObservationClaim.HasMember,
165
+ ObservationClaim.ComponentTags,
166
+ ObservationClaim.ComponentCodeValues,
167
+ ObservationClaim.ComponentNames,
168
+ ObservationClaim.Identifier,
169
+ ObservationClaim.Language,
170
+ ObservationClaim.Method,
171
+ ObservationClaim.Note,
172
+ ObservationClaim.Patient,
173
+ ObservationClaim.Performer,
174
+ ObservationClaim.Specimen,
175
+ ObservationClaim.Status,
176
+ ObservationClaim.Subject,
177
+ ObservationClaim.ValueConceptSystem,
178
+ ObservationClaim.ValueConceptValue,
179
+ ObservationClaim.ValueConceptText,
180
+ ObservationClaim.ValueConceptDisplay,
181
+ ObservationClaim.ValueConcept,
182
+ ObservationClaim.ValueDate,
183
+ ObservationClaim.ValueQuantityComparator,
184
+ ObservationClaim.ValueQuantityNumber,
185
+ ObservationClaim.ValueQuantityUnit,
186
+ ObservationClaim.ScoreTotalNumber,
187
+ ObservationClaim.BloodPressureSystolicNumber,
188
+ ObservationClaim.BloodPressureDiastolicNumber,
189
+ ObservationClaim.ValueString,
190
+ ];
191
+ /**
192
+ * Full persisted claim surface for visible/searchable Vital Signs rows.
193
+ *
194
+ * This keeps the claims-first authoring fields but still avoids introducing
195
+ * fields that only belong to broader Observation families.
196
+ */
197
+ export const ObservationVitalSignsClaimsList = [
198
+ ObservationClaim.Category,
199
+ ObservationClaim.CodeSystem,
200
+ ObservationClaim.CodeValue,
201
+ ObservationClaim.CodeText,
202
+ ObservationClaim.CodeDisplay,
203
+ ObservationClaim.Code,
204
+ ObservationClaim.Date,
205
+ ObservationClaim.EffectiveDateTime,
206
+ ObservationClaim.HasMember,
207
+ ObservationClaim.ComponentTags,
208
+ ObservationClaim.ComponentCodeValues,
209
+ ObservationClaim.ComponentNames,
210
+ ObservationClaim.Identifier,
211
+ ObservationClaim.Language,
212
+ ObservationClaim.Method,
213
+ ObservationClaim.Note,
214
+ ObservationClaim.Patient,
215
+ ObservationClaim.Status,
216
+ ObservationClaim.Subject,
217
+ ObservationClaim.ValueConceptSystem,
218
+ ObservationClaim.ValueConceptValue,
219
+ ObservationClaim.ValueConceptText,
220
+ ObservationClaim.ValueConceptDisplay,
221
+ ObservationClaim.ValueConcept,
222
+ ObservationClaim.ValueDate,
223
+ ObservationClaim.ValueQuantityComparator,
224
+ ObservationClaim.ValueQuantityNumber,
225
+ ObservationClaim.ValueQuantityUnit,
226
+ ObservationClaim.ScoreTotalNumber,
227
+ ObservationClaim.BloodPressureSystolicNumber,
228
+ ObservationClaim.BloodPressureDiastolicNumber,
229
+ ObservationClaim.ValueString,
230
+ ];
26
231
  export const ObservationClaimSpecs = [
27
232
  { key: ObservationClaim.BasedOn, meaning: 'Order or request that originated the observation.', example: 'ServiceRequest/sr-1' },
28
233
  { key: ObservationClaim.Category, meaning: 'Observation category token.', example: 'http://terminology.hl7.org/CodeSystem/observation-category|vital-signs' },
234
+ { key: ObservationClaim.CodeSystem, meaning: 'Observation code system URL for UI/storage normalization.', example: 'http://loinc.org' },
235
+ { key: ObservationClaim.CodeValue, meaning: 'Observation code value used for UI editing and search.', example: '8867-4' },
236
+ { key: ObservationClaim.CodeText, meaning: 'Local-language label shown to the user.', example: 'Heart rate' },
237
+ { key: ObservationClaim.CodeDisplay, meaning: 'Canonical English/international code display.', example: 'Heart rate' },
29
238
  { key: ObservationClaim.Code, meaning: 'Observation code token.', example: 'http://loinc.org|8480-6' },
30
239
  { key: ObservationClaim.Date, meaning: 'Observation effective or issued date/time.', example: '2026-06-01T10:00:00Z' },
31
240
  { key: ObservationClaim.Device, meaning: 'Device reference.', example: 'Device/dev-1' },
32
241
  { key: ObservationClaim.Encounter, meaning: 'Encounter reference.', example: 'Encounter/enc-1' },
33
242
  { key: ObservationClaim.Focus, meaning: 'Focus reference.', example: 'Condition/cond-1' },
34
243
  { key: ObservationClaim.HasMember, meaning: 'Member observation references (CSV).', example: 'Observation/obs-2,Observation/obs-3' },
244
+ { key: ObservationClaim.ComponentTags, meaning: 'Synthetic component tags summarized on the parent observation.', example: 'bp-systolic,bp-diastolic' },
245
+ { key: ObservationClaim.ComponentCodeValues, meaning: 'Component code values summarized on the parent observation.', example: '8480-6,8462-4' },
246
+ { key: ObservationClaim.ComponentNames, meaning: 'Human-readable component names summarized on the parent observation.', example: 'Systolic blood pressure,Diastolic blood pressure' },
35
247
  { key: ObservationClaim.Identifier, meaning: 'Business identifier.', example: 'obs-001' },
248
+ { key: ObservationClaim.Language, meaning: 'BCP-47 language of the observation content.', example: 'en' },
36
249
  { key: ObservationClaim.Method, meaning: 'Observation method token.', example: 'http://snomed.info/sct|252465000' },
37
250
  { key: ObservationClaim.Patient, meaning: 'Patient reference.', example: 'did:web:patient.example.org' },
38
251
  { key: ObservationClaim.Performer, meaning: 'Performer references (CSV).', example: 'Practitioner/prac-1' },
39
252
  { key: ObservationClaim.Specimen, meaning: 'Specimen reference.', example: 'Specimen/spec-1' },
40
253
  { key: ObservationClaim.Status, meaning: 'Observation status.', example: 'final' },
41
254
  { key: ObservationClaim.Subject, meaning: 'Canonical subject reference.', example: 'did:web:patient.example.org' },
42
- { key: ObservationClaim.ValueConcept, meaning: 'Value concept token.', example: 'http://snomed.info/sct|373066001' },
255
+ { key: ObservationClaim.ValueConceptSystem, meaning: 'Value concept system URL for UI/storage normalization.', example: 'http://snomed.info/sct' },
256
+ { key: ObservationClaim.ValueConceptValue, meaning: 'Value concept code value used for UI editing and filters.', example: '373066001' },
257
+ { key: ObservationClaim.ValueConceptText, meaning: 'Local-language label for the coded value.', example: 'Never smoker' },
258
+ { key: ObservationClaim.ValueConceptDisplay, meaning: 'Canonical English/international display for the coded value.', example: 'Never smoker' },
259
+ { key: ObservationClaim.ValueConcept, meaning: 'Value concept token.', example: 'http://snomed.info/sct|266919005' },
43
260
  { key: ObservationClaim.ValueDate, meaning: 'Value date.', example: '2026-06-01' },
261
+ { key: ObservationClaim.ValueQuantityComparator, meaning: 'Optional FHIR Quantity comparator.', example: '>=' },
262
+ { key: ObservationClaim.ValueQuantityNumber, meaning: 'Observation value quantity numeric scalar.', example: '72' },
263
+ { key: ObservationClaim.ValueQuantityUnit, meaning: 'Observation value quantity unit token or display.', example: 'http://unitsofmeasure.org|/min' },
264
+ { key: ObservationClaim.ScoreTotalNumber, meaning: 'Aggregated assessment score total for the parent observation when present.', example: '8' },
265
+ { key: ObservationClaim.BloodPressureSystolicNumber, meaning: 'Parent blood pressure panel copy of the systolic numeric value.', example: '120' },
266
+ { key: ObservationClaim.BloodPressureDiastolicNumber, meaning: 'Parent blood pressure panel copy of the diastolic numeric value.', example: '78' },
44
267
  { key: ObservationClaim.ValueString, meaning: 'Value string.', example: 'Former smoker' },
45
- { key: ObservationClaim.ComponentCode, meaning: 'Component code token.', example: 'http://loinc.org|8462-4' },
46
268
  { key: ObservationClaim.Note, meaning: 'Clinical note text.', example: 'Patient seated for 5 minutes before measurement.' },
47
269
  { key: ObservationClaim.EffectiveDateTime, meaning: 'FHIR-compatible effectiveDateTime fallback.', example: '2026-06-01T10:00:00Z' },
48
270
  ];
271
+ /**
272
+ * Returns `true` when the flat claims represent one visible/searchable vital
273
+ * sign Observation row.
274
+ *
275
+ * Current rule:
276
+ * - must be categorized as `vital-signs`
277
+ * - must carry `Observation.status`
278
+ *
279
+ * Reduced indexed component rows derived from FHIR `component` intentionally do
280
+ * not carry `Observation.status`, so they are excluded from normal UI list and
281
+ * search results even though they remain persisted for reconstruction/export.
282
+ */
283
+ export function isDisplayableVitalSignObservationClaims(claims) {
284
+ if (!claims || typeof claims !== 'object') {
285
+ return false;
286
+ }
287
+ const status = String(claims[ObservationClaim.Status] || '').trim();
288
+ const category = String(claims[ObservationClaim.Category] || '').trim();
289
+ return Boolean(status) && category
290
+ .split(',')
291
+ .map((item) => item.trim())
292
+ .filter(Boolean)
293
+ .includes(ObservationCategoryCodes.VitalSigns.claim);
294
+ }
@@ -2,4 +2,4 @@
2
2
  * Canonical interoperable-claims keys used by claims-first payloads.
3
3
  * Keep this separated from strict FHIR resource typings.
4
4
  */
5
- export * from './interoperable-claims';
5
+ export * from './interoperable-claims/index';
@@ -4,4 +4,4 @@
4
4
  * Canonical interoperable-claims keys used by claims-first payloads.
5
5
  * Keep this separated from strict FHIR resource typings.
6
6
  */
7
- export * from './interoperable-claims.js';
7
+ export * from './interoperable-claims/index.js';
@@ -29,6 +29,7 @@ export declare enum Format {
29
29
  export declare enum Resource {
30
30
  Person = "Person",
31
31
  RelatedPerson = "RelatedPerson",
32
+ License = "License",
32
33
  Employee = "Emloyee",
33
34
  EmployeeRole = "EmloyeeRole",
34
35
  Practitioner = "Practitioner",
@@ -40,7 +41,8 @@ export declare enum Resource {
40
41
  export declare enum JobAction {
41
42
  "_batch" = "_batch",
42
43
  "_create" = "_create",
43
- "_discovery" = "_discovery"
44
+ "_discovery" = "_discovery",
45
+ "_search" = "_search"
44
46
  }
45
47
  export declare enum knownDomainsReversedEnum {
46
48
  'org.schema' = "org.schema",
@@ -36,6 +36,7 @@ export var Resource;
36
36
  (function (Resource) {
37
37
  Resource["Person"] = "Person";
38
38
  Resource["RelatedPerson"] = "RelatedPerson";
39
+ Resource["License"] = "License";
39
40
  Resource["Employee"] = "Emloyee";
40
41
  Resource["EmployeeRole"] = "EmloyeeRole";
41
42
  Resource["Practitioner"] = "Practitioner";
@@ -49,6 +50,7 @@ export var JobAction;
49
50
  JobAction["_batch"] = "_batch";
50
51
  JobAction["_create"] = "_create";
51
52
  JobAction["_discovery"] = "_discovery";
53
+ JobAction["_search"] = "_search";
52
54
  })(JobAction || (JobAction = {}));
53
55
  export var knownDomainsReversedEnum;
54
56
  (function (knownDomainsReversedEnum) {