fhir-data-utils-ts 0.2.4 → 0.3.1

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 (285) hide show
  1. package/.codex/skills/govern-fhir-data-utilities/SKILL.md +58 -0
  2. package/.codex/skills/govern-fhir-data-utilities/agents/openai.yaml +4 -0
  3. package/.codex/skills/govern-fhir-observation-components/SKILL.md +18 -0
  4. package/CHANGELOG.md +30 -0
  5. package/README.md +39 -0
  6. package/dist/builders/immunization-graph.d.ts +36 -0
  7. package/dist/builders/immunization-graph.js +115 -0
  8. package/dist/builders/immunization-reminders.d.ts +35 -0
  9. package/dist/builders/immunization-reminders.js +104 -0
  10. package/dist/builders/index.d.ts +2 -0
  11. package/dist/builders/index.js +2 -0
  12. package/dist/claim-helpers/claim-list-helpers.d.ts +21 -0
  13. package/dist/claim-helpers/claim-list-helpers.js +54 -0
  14. package/dist/claim-helpers/claims-helpers-allergy-intolerance.d.ts +18 -0
  15. package/dist/claim-helpers/claims-helpers-allergy-intolerance.js +65 -0
  16. package/dist/claim-helpers/claims-helpers-appointment-response.d.ts +8 -0
  17. package/dist/claim-helpers/claims-helpers-appointment-response.js +20 -0
  18. package/dist/claim-helpers/claims-helpers-appointment.d.ts +10 -0
  19. package/dist/claim-helpers/claims-helpers-appointment.js +26 -0
  20. package/dist/claim-helpers/claims-helpers-care-plan.d.ts +8 -0
  21. package/dist/claim-helpers/claims-helpers-care-plan.js +20 -0
  22. package/dist/claim-helpers/claims-helpers-clinical-impression.d.ts +10 -0
  23. package/dist/claim-helpers/claims-helpers-clinical-impression.js +26 -0
  24. package/dist/claim-helpers/claims-helpers-communication.d.ts +19 -0
  25. package/dist/claim-helpers/claims-helpers-communication.js +63 -0
  26. package/dist/claim-helpers/claims-helpers-composition.d.ts +12 -0
  27. package/dist/claim-helpers/claims-helpers-composition.js +32 -0
  28. package/dist/claim-helpers/claims-helpers-condition.d.ts +18 -0
  29. package/dist/claim-helpers/claims-helpers-condition.js +65 -0
  30. package/dist/claim-helpers/claims-helpers-coverage.d.ts +10 -0
  31. package/dist/claim-helpers/claims-helpers-coverage.js +26 -0
  32. package/dist/claim-helpers/claims-helpers-device-use-statement.d.ts +8 -0
  33. package/dist/claim-helpers/claims-helpers-device-use-statement.js +20 -0
  34. package/dist/claim-helpers/claims-helpers-device.d.ts +8 -0
  35. package/dist/claim-helpers/claims-helpers-device.js +20 -0
  36. package/dist/claim-helpers/claims-helpers-diagnostic-report.d.ts +16 -0
  37. package/dist/claim-helpers/claims-helpers-diagnostic-report.js +47 -0
  38. package/dist/claim-helpers/claims-helpers-document-reference.d.ts +8 -0
  39. package/dist/claim-helpers/claims-helpers-document-reference.js +20 -0
  40. package/dist/claim-helpers/claims-helpers-encounter.d.ts +10 -0
  41. package/dist/claim-helpers/claims-helpers-encounter.js +26 -0
  42. package/dist/claim-helpers/claims-helpers-flag.d.ts +8 -0
  43. package/dist/claim-helpers/claims-helpers-flag.js +20 -0
  44. package/dist/claim-helpers/claims-helpers-immunization.d.ts +8 -0
  45. package/dist/claim-helpers/claims-helpers-immunization.js +20 -0
  46. package/dist/claim-helpers/claims-helpers-location.d.ts +10 -0
  47. package/dist/claim-helpers/claims-helpers-location.js +26 -0
  48. package/dist/claim-helpers/claims-helpers-medication-statement.d.ts +96 -0
  49. package/dist/claim-helpers/claims-helpers-medication-statement.js +278 -0
  50. package/dist/claim-helpers/claims-helpers-observation.d.ts +8 -0
  51. package/dist/claim-helpers/claims-helpers-observation.js +20 -0
  52. package/dist/claim-helpers/claims-helpers-organization.d.ts +12 -0
  53. package/dist/claim-helpers/claims-helpers-organization.js +32 -0
  54. package/dist/claim-helpers/claims-helpers-procedure.d.ts +8 -0
  55. package/dist/claim-helpers/claims-helpers-procedure.js +20 -0
  56. package/dist/claim-helpers/claims-helpers-related-person.d.ts +22 -0
  57. package/dist/claim-helpers/claims-helpers-related-person.js +53 -0
  58. package/dist/claim-helpers/index.d.ts +23 -0
  59. package/dist/claim-helpers/index.js +23 -0
  60. package/dist/claims/allergy-intolerance-claims.d.ts +153 -0
  61. package/dist/claims/allergy-intolerance-claims.js +194 -0
  62. package/dist/claims/appointment-claims.d.ts +226 -0
  63. package/dist/claims/appointment-claims.js +218 -0
  64. package/dist/claims/appointment-response-claims.d.ts +63 -0
  65. package/dist/claims/appointment-response-claims.js +58 -0
  66. package/dist/claims/care-plan-claims.d.ts +37 -0
  67. package/dist/claims/care-plan-claims.js +59 -0
  68. package/dist/claims/claim-types.d.ts +9 -0
  69. package/dist/claims/claim-types.js +3 -0
  70. package/dist/claims/clinical-impression-claims.d.ts +17 -0
  71. package/dist/claims/clinical-impression-claims.js +30 -0
  72. package/dist/claims/communication-claims.d.ts +55 -0
  73. package/dist/claims/communication-claims.js +57 -0
  74. package/dist/claims/composition-claims.d.ts +27 -0
  75. package/dist/claims/composition-claims.js +27 -0
  76. package/dist/claims/condition-claims.d.ts +79 -0
  77. package/dist/claims/condition-claims.js +104 -0
  78. package/dist/claims/consent-claims.d.ts +195 -0
  79. package/dist/claims/consent-claims.js +74 -0
  80. package/dist/claims/coverage-claims.d.ts +16 -0
  81. package/dist/claims/coverage-claims.js +28 -0
  82. package/dist/claims/device-claims.d.ts +20 -0
  83. package/dist/claims/device-claims.js +36 -0
  84. package/dist/claims/device-use-statement-claims.d.ts +17 -0
  85. package/dist/claims/device-use-statement-claims.js +28 -0
  86. package/dist/claims/diagnostic-report-claims.d.ts +109 -0
  87. package/dist/claims/diagnostic-report-claims.js +120 -0
  88. package/dist/claims/document-reference-claims.d.ts +39 -0
  89. package/dist/claims/document-reference-claims.js +96 -0
  90. package/dist/claims/encounter-claims.d.ts +18 -0
  91. package/dist/claims/encounter-claims.js +32 -0
  92. package/dist/claims/flag-claims.d.ts +19 -0
  93. package/dist/claims/flag-claims.js +33 -0
  94. package/dist/claims/immunization-claims.d.ts +31 -0
  95. package/dist/claims/immunization-claims.js +54 -0
  96. package/dist/claims/immunization-recommendation-claims.d.ts +19 -0
  97. package/dist/claims/immunization-recommendation-claims.js +26 -0
  98. package/dist/claims/index.d.ts +29 -0
  99. package/dist/claims/index.js +29 -0
  100. package/dist/claims/invoice-claims.d.ts +277 -0
  101. package/dist/claims/invoice-claims.js +357 -0
  102. package/dist/claims/location-claims.d.ts +22 -0
  103. package/dist/claims/location-claims.js +34 -0
  104. package/dist/claims/medication-claims.d.ts +15 -0
  105. package/dist/claims/medication-claims.js +23 -0
  106. package/dist/claims/medication-statement-claims.d.ts +539 -0
  107. package/dist/claims/medication-statement-claims.js +469 -0
  108. package/dist/claims/organization-claims.d.ts +18 -0
  109. package/dist/claims/organization-claims.js +27 -0
  110. package/dist/claims/practitioner-role-claims.d.ts +18 -0
  111. package/dist/claims/practitioner-role-claims.js +33 -0
  112. package/dist/claims/procedure-claims.d.ts +24 -0
  113. package/dist/claims/procedure-claims.js +44 -0
  114. package/dist/claims/related-person-claims.d.ts +30 -0
  115. package/dist/claims/related-person-claims.js +44 -0
  116. package/dist/claims/research-subject-claims.d.ts +4 -0
  117. package/dist/claims/research-subject-claims.js +4 -0
  118. package/dist/claims/task-claims.d.ts +61 -0
  119. package/dist/claims/task-claims.js +64 -0
  120. package/dist/clinical-terminology.d.ts +73 -0
  121. package/dist/clinical-terminology.js +77 -0
  122. package/dist/constants/clinical-statuses.d.ts +102 -0
  123. package/dist/constants/clinical-statuses.js +93 -0
  124. package/dist/constants/fhir-code-systems.d.ts +15 -0
  125. package/dist/constants/fhir-code-systems.js +15 -0
  126. package/dist/constants/fhir-resource-types.d.ts +162 -0
  127. package/dist/constants/fhir-resource-types.js +70 -0
  128. package/dist/constants/fhir-versions.d.ts +10 -0
  129. package/dist/constants/fhir-versions.js +10 -0
  130. package/dist/constants/index.d.ts +4 -0
  131. package/dist/constants/index.js +4 -0
  132. package/dist/converters/convert-allergy-intolerance.d.ts +3 -0
  133. package/dist/converters/convert-allergy-intolerance.js +85 -0
  134. package/dist/converters/convert-appointment-response.d.ts +3 -0
  135. package/dist/converters/convert-appointment-response.js +32 -0
  136. package/dist/converters/convert-appointment.d.ts +3 -0
  137. package/dist/converters/convert-appointment.js +61 -0
  138. package/dist/converters/convert-care-plan.d.ts +3 -0
  139. package/dist/converters/convert-care-plan.js +93 -0
  140. package/dist/converters/convert-clinical-impression.d.ts +3 -0
  141. package/dist/converters/convert-clinical-impression.js +42 -0
  142. package/dist/converters/convert-composition.d.ts +3 -0
  143. package/dist/converters/convert-composition.js +70 -0
  144. package/dist/converters/convert-condition.d.ts +3 -0
  145. package/dist/converters/convert-condition.js +51 -0
  146. package/dist/converters/convert-consent.d.ts +9 -0
  147. package/dist/converters/convert-consent.js +174 -0
  148. package/dist/converters/convert-coverage.d.ts +3 -0
  149. package/dist/converters/convert-coverage.js +51 -0
  150. package/dist/converters/convert-device-use-statement.d.ts +3 -0
  151. package/dist/converters/convert-device-use-statement.js +36 -0
  152. package/dist/converters/convert-device.d.ts +3 -0
  153. package/dist/converters/convert-device.js +48 -0
  154. package/dist/converters/convert-diagnostic-report.d.ts +3 -0
  155. package/dist/converters/convert-diagnostic-report.js +63 -0
  156. package/dist/converters/convert-document-reference.d.ts +3 -0
  157. package/dist/converters/convert-document-reference.js +54 -0
  158. package/dist/converters/convert-encounter.d.ts +3 -0
  159. package/dist/converters/convert-encounter.js +68 -0
  160. package/dist/converters/convert-flag.d.ts +3 -0
  161. package/dist/converters/convert-flag.js +42 -0
  162. package/dist/converters/convert-immunization.d.ts +3 -0
  163. package/dist/converters/convert-immunization.js +80 -0
  164. package/dist/converters/convert-location.d.ts +3 -0
  165. package/dist/converters/convert-location.js +44 -0
  166. package/dist/converters/convert-medication-statement.d.ts +3 -0
  167. package/dist/converters/convert-medication-statement.js +130 -0
  168. package/dist/converters/convert-observation.d.ts +33 -0
  169. package/dist/converters/convert-observation.js +246 -0
  170. package/dist/converters/convert-organization.d.ts +3 -0
  171. package/dist/converters/convert-organization.js +39 -0
  172. package/dist/converters/convert-practitioner-role.d.ts +3 -0
  173. package/dist/converters/convert-practitioner-role.js +62 -0
  174. package/dist/converters/convert-procedure.d.ts +3 -0
  175. package/dist/converters/convert-procedure.js +64 -0
  176. package/dist/converters/convert-related-person.d.ts +3 -0
  177. package/dist/converters/convert-related-person.js +31 -0
  178. package/dist/converters/convert-shared.d.ts +33 -0
  179. package/dist/converters/convert-shared.js +181 -0
  180. package/dist/converters/index.d.ts +24 -0
  181. package/dist/converters/index.js +24 -0
  182. package/dist/fhir-bundle.d.ts +9 -0
  183. package/dist/fhir-bundle.js +43 -0
  184. package/dist/fhir-search-parameters.d.ts +18 -0
  185. package/dist/fhir-search-parameters.js +52 -0
  186. package/dist/fhir-tokens.d.ts +11 -0
  187. package/dist/fhir-tokens.js +26 -0
  188. package/dist/fhir-types.d.ts +77 -0
  189. package/dist/fhir-types.js +1 -0
  190. package/dist/fhir-values.d.ts +13 -0
  191. package/dist/fhir-values.js +53 -0
  192. package/dist/group-r5.d.ts +121 -0
  193. package/dist/group-r5.js +301 -0
  194. package/dist/imaging-types.d.ts +30 -0
  195. package/dist/imaging-types.js +1 -0
  196. package/dist/immunization-flat-claims.d.ts +2 -0
  197. package/dist/immunization-flat-claims.js +2 -0
  198. package/dist/immunization-reminder-plan.d.ts +2 -0
  199. package/dist/immunization-reminder-plan.js +2 -0
  200. package/dist/index.d.ts +19 -0
  201. package/dist/index.js +19 -0
  202. package/dist/observation-claims.d.ts +170 -0
  203. package/dist/observation-claims.js +184 -0
  204. package/dist/related-person.d.ts +16 -0
  205. package/dist/related-person.js +14 -0
  206. package/dist/research-study-r5.d.ts +163 -0
  207. package/dist/research-study-r5.js +490 -0
  208. package/dist/search-models/index.d.ts +7 -0
  209. package/dist/search-models/index.js +7 -0
  210. package/dist/search-models/params/AdverseEvent.params.model.d.ts +14 -0
  211. package/dist/search-models/params/AdverseEvent.params.model.js +16 -0
  212. package/dist/search-models/params/AllergyIntolerance.params.model.d.ts +24 -0
  213. package/dist/search-models/params/AllergyIntolerance.params.model.js +27 -0
  214. package/dist/search-models/params/Appointment.params.model.d.ts +12 -0
  215. package/dist/search-models/params/Appointment.params.model.js +14 -0
  216. package/dist/search-models/params/ClinicalImpression.params.model.d.ts +14 -0
  217. package/dist/search-models/params/ClinicalImpression.params.model.js +15 -0
  218. package/dist/search-models/params/Condition.params.model.d.ts +16 -0
  219. package/dist/search-models/params/Condition.params.model.js +17 -0
  220. package/dist/search-models/params/DetectedIssue.params.model.d.ts +9 -0
  221. package/dist/search-models/params/DetectedIssue.params.model.js +11 -0
  222. package/dist/search-models/params/DiagnosticReport.params.model.d.ts +13 -0
  223. package/dist/search-models/params/DiagnosticReport.params.model.js +14 -0
  224. package/dist/search-models/params/Encounter.params.model.d.ts +15 -0
  225. package/dist/search-models/params/Encounter.params.model.js +17 -0
  226. package/dist/search-models/params/Immunization.params.model.d.ts +14 -0
  227. package/dist/search-models/params/Immunization.params.model.js +16 -0
  228. package/dist/search-models/params/Medication.params.model.d.ts +35 -0
  229. package/dist/search-models/params/Medication.params.model.js +45 -0
  230. package/dist/search-models/params/Observation.params.model.d.ts +326 -0
  231. package/dist/search-models/params/Observation.params.model.js +244 -0
  232. package/dist/search-models/params/Procedure.params.model.d.ts +15 -0
  233. package/dist/search-models/params/Procedure.params.model.js +17 -0
  234. package/dist/search-models/params/Search.params.model.d.ts +75 -0
  235. package/dist/search-models/params/Search.params.model.js +69 -0
  236. package/dist/search-models/params/ServiceRequest.params.model.d.ts +14 -0
  237. package/dist/search-models/params/ServiceRequest.params.model.js +16 -0
  238. package/dist/search-models/params/Specimen.params.model.d.ts +10 -0
  239. package/dist/search-models/params/Specimen.params.model.js +12 -0
  240. package/dist/search-models/params/index.d.ts +15 -0
  241. package/dist/search-models/params/index.js +15 -0
  242. package/dist/search-models/templates/AdverseEvent.template.model.d.ts +16 -0
  243. package/dist/search-models/templates/AdverseEvent.template.model.js +2 -0
  244. package/dist/search-models/templates/AllergyIntolerance.template.model.d.ts +24 -0
  245. package/dist/search-models/templates/AllergyIntolerance.template.model.js +1 -0
  246. package/dist/search-models/templates/Appointment.template.model.d.ts +13 -0
  247. package/dist/search-models/templates/Appointment.template.model.js +1 -0
  248. package/dist/search-models/templates/ClinicalImpression.template.model.d.ts +16 -0
  249. package/dist/search-models/templates/ClinicalImpression.template.model.js +1 -0
  250. package/dist/search-models/templates/Condition.template.model.d.ts +18 -0
  251. package/dist/search-models/templates/Condition.template.model.js +1 -0
  252. package/dist/search-models/templates/DetectedIssue.template.model.d.ts +11 -0
  253. package/dist/search-models/templates/DetectedIssue.template.model.js +1 -0
  254. package/dist/search-models/templates/DiagnosticReport.template.model.d.ts +15 -0
  255. package/dist/search-models/templates/DiagnosticReport.template.model.js +1 -0
  256. package/dist/search-models/templates/Encounter.template.model.d.ts +17 -0
  257. package/dist/search-models/templates/Encounter.template.model.js +1 -0
  258. package/dist/search-models/templates/Immunization.template.model.d.ts +18 -0
  259. package/dist/search-models/templates/Immunization.template.model.js +2 -0
  260. package/dist/search-models/templates/Medication.template.model.d.ts +37 -0
  261. package/dist/search-models/templates/Medication.template.model.js +1 -0
  262. package/dist/search-models/templates/Observation.template.model.d.ts +18 -0
  263. package/dist/search-models/templates/Observation.template.model.js +1 -0
  264. package/dist/search-models/templates/Procedure.template.model.d.ts +17 -0
  265. package/dist/search-models/templates/Procedure.template.model.js +1 -0
  266. package/dist/search-models/templates/ServiceRequest.template.model.d.ts +16 -0
  267. package/dist/search-models/templates/ServiceRequest.template.model.js +1 -0
  268. package/dist/search-models/templates/Specimen.template.model.d.ts +12 -0
  269. package/dist/search-models/templates/Specimen.template.model.js +1 -0
  270. package/dist/search-models/templates/index.d.ts +14 -0
  271. package/dist/search-models/templates/index.js +14 -0
  272. package/dist/terminology-models/AtcModel.d.ts +15 -0
  273. package/dist/terminology-models/AtcModel.js +2 -0
  274. package/dist/terminology-models/CommonModels.d.ts +70 -0
  275. package/dist/terminology-models/CommonModels.js +55 -0
  276. package/dist/terminology-models/FhirModels.d.ts +60 -0
  277. package/dist/terminology-models/FhirModels.js +34 -0
  278. package/dist/terminology-models/LoincModels.d.ts +24 -0
  279. package/dist/terminology-models/LoincModels.js +2 -0
  280. package/dist/terminology-models/SnomedModels.d.ts +13 -0
  281. package/dist/terminology-models/SnomedModels.js +2 -0
  282. package/dist/terminology-models/index.d.ts +6 -0
  283. package/dist/terminology-models/index.js +6 -0
  284. package/docs/UHC_FHIR_UTILS_MIGRATION.md +51 -8
  285. package/package.json +83 -2
@@ -73,6 +73,8 @@ export const ObservationClaim = Object.freeze({
73
73
  ValueString: 'Observation.value-string',
74
74
  Note: 'Observation.note',
75
75
  EffectiveDateTime: 'Observation.effective-datetime',
76
+ /** @deprecated Read-only camelCase key from historical persisted rows. */
77
+ EffectiveDateTimeLegacy: 'Observation.effectiveDateTime',
76
78
  /** Custom provenance flag for an explicitly entered or selected result. */
77
79
  UserSelected: 'Observation.user-selected',
78
80
  });
@@ -94,3 +96,185 @@ export function decodeObservationClaimList(value) {
94
96
  }
95
97
  return Object.freeze(normalized.split(',').map(item => item.trim()));
96
98
  }
99
+ /**
100
+ * Builds the legacy compact `system|code` token from split claims.
101
+ *
102
+ * Use this only for compatibility/export. Frontend authoring should prefer the
103
+ * split fields such as `code-value`, `code-text`, and `value-concept-value`.
104
+ */
105
+ export function buildObservationCodingClaim(input) {
106
+ const value = String(input.value || '').trim();
107
+ const system = String(input.system || '').trim();
108
+ if (!value)
109
+ return undefined;
110
+ return system ? `${system}|${value}` : value;
111
+ }
112
+ /**
113
+ * Splits a compact token such as `http://loinc.org|8867-4` into separate
114
+ * claims that are easier for forms, local storage, and numeric/text filters.
115
+ */
116
+ export function splitObservationCodingClaim(value) {
117
+ const token = String(value || '').trim();
118
+ if (!token) {
119
+ return {};
120
+ }
121
+ const separatorIndex = token.indexOf('|');
122
+ if (separatorIndex < 0) {
123
+ return { value: token };
124
+ }
125
+ return {
126
+ system: token.slice(0, separatorIndex) || undefined,
127
+ value: token.slice(separatorIndex + 1) || undefined,
128
+ };
129
+ }
130
+ /**
131
+ * Full persisted claim surface for a general Observation row in local storage.
132
+ *
133
+ * This list is intentionally broader than the searchable/indexable subset.
134
+ * Free-text or UI-only fields may exist here even when they must stay out of
135
+ * blind-query/search indexes.
136
+ */
137
+ export const ObservationGeneralClaimsList = [
138
+ ObservationClaim.BasedOn,
139
+ ObservationClaim.Category,
140
+ ObservationClaim.CodeSystem,
141
+ ObservationClaim.CodeValue,
142
+ ObservationClaim.CodeText,
143
+ ObservationClaim.CodeDisplay,
144
+ ObservationClaim.Code,
145
+ ObservationClaim.Date,
146
+ ObservationClaim.Device,
147
+ ObservationClaim.Encounter,
148
+ ObservationClaim.EffectiveDateTime,
149
+ ObservationClaim.Focus,
150
+ ObservationClaim.HasMember,
151
+ ObservationClaim.ComponentTags,
152
+ ObservationClaim.ComponentCodeValues,
153
+ ObservationClaim.ComponentNames,
154
+ ObservationClaim.Identifier,
155
+ ObservationClaim.Language,
156
+ ObservationClaim.Method,
157
+ ObservationClaim.Note,
158
+ ObservationClaim.Patient,
159
+ ObservationClaim.Performer,
160
+ ObservationClaim.Specimen,
161
+ ObservationClaim.Status,
162
+ ObservationClaim.Subject,
163
+ ObservationClaim.ValueConceptSystem,
164
+ ObservationClaim.ValueConceptValue,
165
+ ObservationClaim.ValueConceptText,
166
+ ObservationClaim.ValueConceptDisplay,
167
+ ObservationClaim.ValueConcept,
168
+ ObservationClaim.ValueDate,
169
+ ObservationClaim.ValueQuantityComparator,
170
+ ObservationClaim.ValueQuantityNumber,
171
+ ObservationClaim.ValueQuantityUnit,
172
+ ObservationClaim.ScoreTotalNumber,
173
+ ObservationClaim.BloodPressureSystolicNumber,
174
+ ObservationClaim.BloodPressureDiastolicNumber,
175
+ ObservationClaim.ValueString,
176
+ ];
177
+ /**
178
+ * Full persisted claim surface for visible/searchable Vital Signs rows.
179
+ *
180
+ * This keeps the claims-first authoring fields but still avoids introducing
181
+ * fields that only belong to broader Observation families.
182
+ */
183
+ export const ObservationVitalSignsClaimsList = [
184
+ ObservationClaim.Category,
185
+ ObservationClaim.CodeSystem,
186
+ ObservationClaim.CodeValue,
187
+ ObservationClaim.CodeText,
188
+ ObservationClaim.CodeDisplay,
189
+ ObservationClaim.Code,
190
+ ObservationClaim.Date,
191
+ ObservationClaim.EffectiveDateTime,
192
+ ObservationClaim.HasMember,
193
+ ObservationClaim.ComponentTags,
194
+ ObservationClaim.ComponentCodeValues,
195
+ ObservationClaim.ComponentNames,
196
+ ObservationClaim.Identifier,
197
+ ObservationClaim.Language,
198
+ ObservationClaim.Method,
199
+ ObservationClaim.Note,
200
+ ObservationClaim.Patient,
201
+ ObservationClaim.Status,
202
+ ObservationClaim.Subject,
203
+ ObservationClaim.ValueConceptSystem,
204
+ ObservationClaim.ValueConceptValue,
205
+ ObservationClaim.ValueConceptText,
206
+ ObservationClaim.ValueConceptDisplay,
207
+ ObservationClaim.ValueConcept,
208
+ ObservationClaim.ValueDate,
209
+ ObservationClaim.ValueQuantityComparator,
210
+ ObservationClaim.ValueQuantityNumber,
211
+ ObservationClaim.ValueQuantityUnit,
212
+ ObservationClaim.ScoreTotalNumber,
213
+ ObservationClaim.BloodPressureSystolicNumber,
214
+ ObservationClaim.BloodPressureDiastolicNumber,
215
+ ObservationClaim.ValueString,
216
+ ];
217
+ export const ObservationClaimSpecs = [
218
+ { key: ObservationClaim.BasedOn, meaning: 'Order or request that originated the observation.', example: 'ServiceRequest/sr-1' },
219
+ { key: ObservationClaim.Category, meaning: 'Observation category token.', example: 'http://terminology.hl7.org/CodeSystem/observation-category|vital-signs' },
220
+ { key: ObservationClaim.CodeSystem, meaning: 'Observation code system URL for UI/storage normalization.', example: 'http://loinc.org' },
221
+ { key: ObservationClaim.CodeValue, meaning: 'Observation code value used for UI editing and search.', example: '8867-4' },
222
+ { key: ObservationClaim.CodeText, meaning: 'Local-language label shown to the user.', example: 'Heart rate' },
223
+ { key: ObservationClaim.CodeDisplay, meaning: 'Canonical English/international code display.', example: 'Heart rate' },
224
+ { key: ObservationClaim.Code, meaning: 'Observation code token.', example: 'http://loinc.org|8480-6' },
225
+ { key: ObservationClaim.Date, meaning: 'Observation effective or issued date/time.', example: '2026-06-01T10:00:00Z' },
226
+ { key: ObservationClaim.Device, meaning: 'Device reference.', example: 'Device/dev-1' },
227
+ { key: ObservationClaim.Encounter, meaning: 'Encounter reference.', example: 'Encounter/enc-1' },
228
+ { key: ObservationClaim.Focus, meaning: 'Focus reference.', example: 'Condition/cond-1' },
229
+ { key: ObservationClaim.HasMember, meaning: 'Member observation references (CSV).', example: 'Observation/obs-2,Observation/obs-3' },
230
+ { key: ObservationClaim.ComponentTags, meaning: 'Synthetic component tags summarized on the parent observation.', example: 'bp-systolic,bp-diastolic' },
231
+ { key: ObservationClaim.ComponentCodeValues, meaning: 'Component code values summarized on the parent observation.', example: '8480-6,8462-4' },
232
+ { key: ObservationClaim.ComponentNames, meaning: 'Human-readable component names summarized on the parent observation.', example: 'Systolic blood pressure,Diastolic blood pressure' },
233
+ { key: ObservationClaim.Identifier, meaning: 'Business identifier.', example: 'obs-001' },
234
+ { key: ObservationClaim.Language, meaning: 'BCP-47 language of the observation content.', example: 'en' },
235
+ { key: ObservationClaim.Method, meaning: 'Observation method token.', example: 'http://snomed.info/sct|252465000' },
236
+ { key: ObservationClaim.Patient, meaning: 'Patient reference.', example: 'did:web:patient.example.org' },
237
+ { key: ObservationClaim.Performer, meaning: 'Performer references (CSV).', example: 'Practitioner/prac-1' },
238
+ { key: ObservationClaim.Specimen, meaning: 'Specimen reference.', example: 'Specimen/spec-1' },
239
+ { key: ObservationClaim.Status, meaning: 'Observation status.', example: 'final' },
240
+ { key: ObservationClaim.Subject, meaning: 'Canonical subject reference.', example: 'did:web:patient.example.org' },
241
+ { key: ObservationClaim.ValueConceptSystem, meaning: 'Value concept system URL for UI/storage normalization.', example: 'http://snomed.info/sct' },
242
+ { key: ObservationClaim.ValueConceptValue, meaning: 'Value concept code value used for UI editing and filters.', example: '373066001' },
243
+ { key: ObservationClaim.ValueConceptText, meaning: 'Local-language label for the coded value.', example: 'Never smoker' },
244
+ { key: ObservationClaim.ValueConceptDisplay, meaning: 'Canonical English/international display for the coded value.', example: 'Never smoker' },
245
+ { key: ObservationClaim.ValueConcept, meaning: 'Value concept token.', example: 'http://snomed.info/sct|266919005' },
246
+ { key: ObservationClaim.ValueDate, meaning: 'Value date.', example: '2026-06-01' },
247
+ { key: ObservationClaim.ValueQuantityComparator, meaning: 'Optional FHIR Quantity comparator.', example: '>=' },
248
+ { key: ObservationClaim.ValueQuantityNumber, meaning: 'Observation value quantity numeric scalar.', example: '72' },
249
+ { key: ObservationClaim.ValueQuantityUnit, meaning: 'Observation value quantity unit token or display.', example: 'http://unitsofmeasure.org|/min' },
250
+ { key: ObservationClaim.ScoreTotalNumber, meaning: 'Aggregated assessment score total for the parent observation when present.', example: '8' },
251
+ { key: ObservationClaim.BloodPressureSystolicNumber, meaning: 'Parent blood pressure panel copy of the systolic numeric value.', example: '120' },
252
+ { key: ObservationClaim.BloodPressureDiastolicNumber, meaning: 'Parent blood pressure panel copy of the diastolic numeric value.', example: '78' },
253
+ { key: ObservationClaim.ValueString, meaning: 'Value string.', example: 'Former smoker' },
254
+ { key: ObservationClaim.Note, meaning: 'Clinical note text.', example: 'Patient seated for 5 minutes before measurement.' },
255
+ { key: ObservationClaim.EffectiveDateTime, meaning: 'FHIR-compatible effectiveDateTime fallback.', example: '2026-06-01T10:00:00Z' },
256
+ ];
257
+ /**
258
+ * Returns `true` when the flat claims represent one visible/searchable vital
259
+ * sign Observation row.
260
+ *
261
+ * Current rule:
262
+ * - must be categorized as `vital-signs`
263
+ * - must carry `Observation.status`
264
+ *
265
+ * Reduced indexed component rows derived from FHIR `component` intentionally do
266
+ * not carry `Observation.status`, so they are excluded from normal UI list and
267
+ * search results even though they remain persisted for reconstruction/export.
268
+ */
269
+ export function isDisplayableVitalSignObservationClaims(claims) {
270
+ if (!claims || typeof claims !== 'object') {
271
+ return false;
272
+ }
273
+ const status = String(claims[ObservationClaim.Status] || '').trim();
274
+ const category = String(claims[ObservationClaim.Category] || '').trim();
275
+ return Boolean(status) && category
276
+ .split(',')
277
+ .map((item) => item.trim())
278
+ .filter(Boolean)
279
+ .includes(ObservationCategoryCodes.VitalSigns.claim);
280
+ }
@@ -0,0 +1,16 @@
1
+ import type { FhirCodeableConcept, FhirContactPoint, FhirReference } from './fhir-types.js';
2
+ export type FhirHumanName = Readonly<{
3
+ use?: string;
4
+ text?: string;
5
+ family?: string;
6
+ given?: readonly string[];
7
+ }>;
8
+ export type FhirRelatedPerson = Readonly<{
9
+ resourceType: 'RelatedPerson';
10
+ patient?: FhirReference;
11
+ name?: readonly FhirHumanName[];
12
+ relationship?: readonly FhirCodeableConcept[];
13
+ telecom?: readonly FhirContactPoint[];
14
+ }>;
15
+ /** Projects a RelatedPerson to standard search values without reading server-private metadata. */
16
+ export declare function relatedPersonToSearchValues(resource: FhirRelatedPerson): Readonly<Record<string, string | undefined>>;
@@ -0,0 +1,14 @@
1
+ import { joinFhirOrList, makeFhirToken, telecomToTokens } from './fhir-tokens.js';
2
+ /** Projects a RelatedPerson to standard search values without reading server-private metadata. */
3
+ export function relatedPersonToSearchValues(resource) {
4
+ const name = resource.name?.find(value => value.use === 'nickname') ?? resource.name?.[0];
5
+ const displayName = name?.text?.trim() || [...(name?.given ?? []), name?.family].filter(Boolean).join(' ') || undefined;
6
+ const relationships = resource.relationship?.flatMap(concept => concept.coding ?? []).flatMap(coding => coding.system && coding.code ? [makeFhirToken(coding.system, coding.code)] : []) ?? [];
7
+ return Object.freeze({
8
+ subject: resource.patient?.reference,
9
+ name: displayName,
10
+ 'name-use': name?.use ? makeFhirToken('http://hl7.org/fhir/name-use', name.use) : undefined,
11
+ relationship: joinFhirOrList(relationships),
12
+ telecom: joinFhirOrList(telecomToTokens(resource)),
13
+ });
14
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Browser-safe FHIR R5 ResearchStudy flat-claim contract.
3
+ *
4
+ * The standard catalogue is copied from the R5 SearchParameter definitions,
5
+ * not inferred from similarly named resource elements. In particular, the
6
+ * `date` SearchParameter targets `ResearchStudy.period`, not the publication
7
+ * date element. Associated-party projections are indexed separately because
8
+ * base R5 defines no ResearchStudy party SearchParameter.
9
+ *
10
+ * @see https://hl7.org/fhir/R5/researchstudy.html
11
+ * @see https://hl7.org/fhir/R5/researchstudy-search.html
12
+ */
13
+ export declare const ResearchStudyR5Version: "5.0.0";
14
+ /**
15
+ * Immutable codes defined by the FHIR R5 5.0.0 ResearchStudy party-role code
16
+ * system. The element binding remains extensible; this catalogue is the closed
17
+ * set a portal may offer by default, not a validator for every conformant
18
+ * external Coding.
19
+ *
20
+ * @see https://hl7.org/fhir/R5/codesystem-research-study-party-role.html
21
+ */
22
+ export declare const ResearchStudyR5PartyRoleSystem: "http://hl7.org/fhir/research-study-party-role";
23
+ export declare const ResearchStudyR5PartyRoleCodes: readonly ["sponsor", "lead-sponsor", "sponsor-investigator", "primary-investigator", "collaborator", "funding-source", "general-contact", "recruitment-contact", "sub-investigator", "study-director", "study-chair", "irb"];
24
+ export type ResearchStudyR5PartyRoleCode = (typeof ResearchStudyR5PartyRoleCodes)[number];
25
+ export declare const ResearchStudyAssociatedPartyBindings: Readonly<{
26
+ readonly role: Readonly<{
27
+ valueSet: "http://hl7.org/fhir/ValueSet/research-study-party-role";
28
+ strength: "extensible";
29
+ }>;
30
+ readonly classifier: Readonly<{
31
+ valueSet: "http://hl7.org/fhir/ValueSet/research-study-party-organization-type";
32
+ strength: "example";
33
+ }>;
34
+ }>;
35
+ export type ResearchStudySearchParameterType = 'composite' | 'date' | 'number' | 'reference' | 'string' | 'token';
36
+ export type ResearchStudyR5SearchParameter = Readonly<{
37
+ code: string;
38
+ type: ResearchStudySearchParameterType;
39
+ expression: string;
40
+ components: readonly string[];
41
+ }>;
42
+ /** Exact resource-specific SearchParameters published by FHIR R5 5.0.0. */
43
+ export declare const ResearchStudyR5SearchParameterCatalog: readonly ResearchStudyR5SearchParameter[];
44
+ /** Canonical ResearchStudy flat-claim names. Never repeat these storage keys as literals. */
45
+ export declare const ResearchStudyClaim: Readonly<{
46
+ readonly Classifier: "ResearchStudy.classifier";
47
+ readonly Condition: "ResearchStudy.condition";
48
+ readonly Date: "ResearchStudy.date";
49
+ readonly Description: "ResearchStudy.description";
50
+ readonly Eligibility: "ResearchStudy.eligibility";
51
+ readonly FocusCode: "ResearchStudy.focus-code";
52
+ readonly FocusReference: "ResearchStudy.focus-reference";
53
+ readonly Identifier: "ResearchStudy.identifier";
54
+ readonly Keyword: "ResearchStudy.keyword";
55
+ readonly Name: "ResearchStudy.name";
56
+ readonly ObjectiveDescription: "ResearchStudy.objective-description";
57
+ readonly ObjectiveType: "ResearchStudy.objective-type";
58
+ readonly PartOf: "ResearchStudy.part-of";
59
+ readonly Phase: "ResearchStudy.phase";
60
+ readonly ProgressStatusStateActual: "ResearchStudy.progress-status-state-actual";
61
+ readonly ProgressStatusStatePeriod: "ResearchStudy.progress-status-state-period";
62
+ readonly ProgressStatusStatePeriodActual: "ResearchStudy.progress-status-state-period-actual";
63
+ readonly Protocol: "ResearchStudy.protocol";
64
+ readonly RecruitmentActual: "ResearchStudy.recruitment-actual";
65
+ readonly RecruitmentTarget: "ResearchStudy.recruitment-target";
66
+ readonly Region: "ResearchStudy.region";
67
+ readonly Site: "ResearchStudy.site";
68
+ readonly Status: "ResearchStudy.status";
69
+ readonly StudyDesign: "ResearchStudy.study-design";
70
+ readonly Title: "ResearchStudy.title";
71
+ readonly PartyName: "ResearchStudy.party-name";
72
+ readonly PartyRole: "ResearchStudy.party-role";
73
+ readonly PartyPeriodStart: "ResearchStudy.party-period-start";
74
+ readonly PartyPeriodEnd: "ResearchStudy.party-period-end";
75
+ readonly PartyClassifier: "ResearchStudy.party-classifier";
76
+ readonly Party: "ResearchStudy.party";
77
+ }>;
78
+ declare const standardSearchClaims: readonly ["ResearchStudy.classifier", "ResearchStudy.condition", "ResearchStudy.date", "ResearchStudy.description", "ResearchStudy.eligibility", "ResearchStudy.focus-code", "ResearchStudy.focus-reference", "ResearchStudy.identifier", "ResearchStudy.keyword", "ResearchStudy.name", "ResearchStudy.objective-description", "ResearchStudy.objective-type", "ResearchStudy.part-of", "ResearchStudy.phase", "ResearchStudy.progress-status-state-actual", "ResearchStudy.progress-status-state-period", "ResearchStudy.progress-status-state-period-actual", "ResearchStudy.protocol", "ResearchStudy.recruitment-actual", "ResearchStudy.recruitment-target", "ResearchStudy.region", "ResearchStudy.site", "ResearchStudy.status", "ResearchStudy.study-design", "ResearchStudy.title"];
79
+ declare const associatedPartyClaims: readonly ["ResearchStudy.party-name", "ResearchStudy.party-role", "ResearchStudy.party-period-start", "ResearchStudy.party-period-end", "ResearchStudy.party-classifier", "ResearchStudy.party"];
80
+ /**
81
+ * Governed flat claims for ResearchStudy.
82
+ *
83
+ * `standardSearch` contains only official R5 SearchParameters. The
84
+ * `associatedParty` list is an explicit operational projection of the R5
85
+ * backbone element; none of those names is advertised as a standard search
86
+ * parameter and `classifier` never carries CRUD or authorization policy.
87
+ */
88
+ export declare const ResearchStudyFlatClaimCatalog: Readonly<{
89
+ standardSearch: readonly ["ResearchStudy.classifier", "ResearchStudy.condition", "ResearchStudy.date", "ResearchStudy.description", "ResearchStudy.eligibility", "ResearchStudy.focus-code", "ResearchStudy.focus-reference", "ResearchStudy.identifier", "ResearchStudy.keyword", "ResearchStudy.name", "ResearchStudy.objective-description", "ResearchStudy.objective-type", "ResearchStudy.part-of", "ResearchStudy.phase", "ResearchStudy.progress-status-state-actual", "ResearchStudy.progress-status-state-period", "ResearchStudy.progress-status-state-period-actual", "ResearchStudy.protocol", "ResearchStudy.recruitment-actual", "ResearchStudy.recruitment-target", "ResearchStudy.region", "ResearchStudy.site", "ResearchStudy.status", "ResearchStudy.study-design", "ResearchStudy.title"];
90
+ associatedParty: readonly ["ResearchStudy.party-name", "ResearchStudy.party-role", "ResearchStudy.party-period-start", "ResearchStudy.party-period-end", "ResearchStudy.party-classifier", "ResearchStudy.party"];
91
+ all: readonly ("ResearchStudy.classifier" | "ResearchStudy.condition" | "ResearchStudy.description" | "ResearchStudy.identifier" | "ResearchStudy.keyword" | "ResearchStudy.name" | "ResearchStudy.phase" | "ResearchStudy.protocol" | "ResearchStudy.region" | "ResearchStudy.site" | "ResearchStudy.status" | "ResearchStudy.title" | "ResearchStudy.date" | "ResearchStudy.eligibility" | "ResearchStudy.focus-code" | "ResearchStudy.focus-reference" | "ResearchStudy.objective-description" | "ResearchStudy.objective-type" | "ResearchStudy.part-of" | "ResearchStudy.progress-status-state-actual" | "ResearchStudy.progress-status-state-period" | "ResearchStudy.progress-status-state-period-actual" | "ResearchStudy.recruitment-actual" | "ResearchStudy.recruitment-target" | "ResearchStudy.study-design" | "ResearchStudy.party-name" | "ResearchStudy.party-role" | "ResearchStudy.party-period-start" | "ResearchStudy.party-period-end" | "ResearchStudy.party-classifier" | "ResearchStudy.party")[];
92
+ }>;
93
+ export type ResearchStudyCoding = Readonly<{
94
+ system?: string;
95
+ code?: string;
96
+ display?: string;
97
+ }>;
98
+ export type ResearchStudyCodeableConcept = Readonly<{
99
+ coding?: readonly ResearchStudyCoding[];
100
+ text?: string;
101
+ }>;
102
+ export type ResearchStudyPeriod = Readonly<{
103
+ start?: string;
104
+ end?: string;
105
+ }>;
106
+ export type ResearchStudyAssociatedPartyReferenceType = 'Organization' | 'Practitioner' | 'PractitionerRole';
107
+ export type ResearchStudyAssociatedPartyReference = Readonly<{
108
+ reference: string;
109
+ type?: ResearchStudyAssociatedPartyReferenceType;
110
+ display?: string;
111
+ }>;
112
+ export type ResearchStudyAssociatedParty = Readonly<{
113
+ name?: string;
114
+ role: ResearchStudyCodeableConcept;
115
+ period?: readonly ResearchStudyPeriod[];
116
+ classifier?: readonly ResearchStudyCodeableConcept[];
117
+ party?: ResearchStudyAssociatedPartyReference;
118
+ }>;
119
+ export type ResearchStudyAssociatedPartyClaimProjection = Readonly<{
120
+ /** The complete party is retained beside its derived claims to preserve correlation. */
121
+ associatedParty: ResearchStudyAssociatedParty;
122
+ claims: Readonly<Record<(typeof associatedPartyClaims)[number], readonly string[]>>;
123
+ }>;
124
+ export type ResearchStudyR5SearchClaim = (typeof standardSearchClaims)[number];
125
+ export type ResearchStudyR5SearchClaims = Readonly<Partial<Record<ResearchStudyR5SearchClaim, readonly string[]>>>;
126
+ export type ResearchStudyR5FlatClaimsResource = Readonly<{
127
+ resourceType: 'ResearchStudy';
128
+ id: string;
129
+ meta: Readonly<{
130
+ claims: Readonly<Record<string, readonly string[]>>;
131
+ }>;
132
+ }>;
133
+ /**
134
+ * Projects the official resource-specific R5 SearchParameters from one native
135
+ * ResearchStudy into flat `resource.meta.claims`. Composite values use FHIR's
136
+ * `$` component separator; associatedParty remains a separate projection and
137
+ * never becomes authorization data.
138
+ *
139
+ * @see https://hl7.org/fhir/R5/researchstudy-search.html
140
+ */
141
+ export declare function projectResearchStudyR5SearchClaims(input: unknown): ResearchStudyR5SearchClaims;
142
+ /**
143
+ * Normalizes the R5 `associatedParty[]` backbone without flattening parties
144
+ * into unrelated parallel arrays. This function validates data shape only; it
145
+ * does not grant study access or interpret classifier values as permissions.
146
+ */
147
+ export declare function normalizeResearchStudyAssociatedParties(input: unknown): readonly ResearchStudyAssociatedParty[];
148
+ /**
149
+ * Produces one flat-claim map per associated party. Keeping the normalized
150
+ * party beside each map preserves the party/role/period/classifier boundary
151
+ * required when a later Bundle PATCH changes one party.
152
+ */
153
+ export declare function projectResearchStudyAssociatedPartyClaims(input: unknown): readonly ResearchStudyAssociatedPartyClaimProjection[];
154
+ /** Projects native-shaped study input to the claims-only GW persistence shape. */
155
+ export declare function projectResearchStudyR5FlatClaimsResource(input: unknown): ResearchStudyR5FlatClaimsResource;
156
+ /** Projects one correlated claims-only GW resource per associated party. */
157
+ export declare function projectResearchStudyAssociatedPartyFlatClaimResources(input: Readonly<{
158
+ researchStudyId: string;
159
+ associatedParties: unknown;
160
+ }>): readonly ResearchStudyR5FlatClaimsResource[];
161
+ /** Validates and freezes a claims-only ResearchStudy GW resource. */
162
+ export declare function normalizeResearchStudyR5FlatClaimsResource(input: unknown): ResearchStudyR5FlatClaimsResource;
163
+ export {};