@ovok/core 0.4.49-rc.3 → 0.4.49-rc.5

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 (421) hide show
  1. package/README.md +23 -666
  2. package/dist/client/ai-fhir/methods/AIFhirResources.d.ts +3 -1
  3. package/dist/client/ai-fhir/methods/AIFhirResources.js +3 -1
  4. package/dist/client/ai-fhir/types/AIFhirPlan.d.ts +8 -0
  5. package/dist/client/ai-fhir/types/AIFhirPlanRequest.d.ts +8 -0
  6. package/dist/client/ai-fhir/types/AIFhirRequest.d.ts +5 -0
  7. package/dist/client/ai-fhir/types/AIFhirResponse.d.ts +6 -0
  8. package/dist/client/auth/errors.d.ts +15 -2
  9. package/dist/client/auth/errors.js +12 -2
  10. package/dist/client/auth/methods/appleLogin.d.ts +1 -0
  11. package/dist/client/auth/methods/appleLogin.js +1 -0
  12. package/dist/client/auth/methods/changePassword.d.ts +1 -0
  13. package/dist/client/auth/methods/changePassword.js +1 -0
  14. package/dist/client/auth/methods/googleLogin.d.ts +1 -0
  15. package/dist/client/auth/methods/googleLogin.js +1 -0
  16. package/dist/client/auth/methods/login.d.ts +6 -0
  17. package/dist/client/auth/methods/login.js +6 -0
  18. package/dist/client/auth/methods/register.d.ts +5 -0
  19. package/dist/client/auth/methods/register.js +5 -0
  20. package/dist/client/auth/methods/registerPractitioner.d.ts +5 -0
  21. package/dist/client/auth/methods/registerPractitioner.js +5 -0
  22. package/dist/client/auth/methods/reloadSession.d.ts +3 -0
  23. package/dist/client/auth/methods/requestDeleteUser.d.ts +4 -5
  24. package/dist/client/auth/methods/requestDeleteUser.js +4 -5
  25. package/dist/client/auth/methods/setPasswordFromReset.d.ts +1 -0
  26. package/dist/client/auth/methods/setPasswordFromReset.js +1 -0
  27. package/dist/client/auth/session-fetch.d.ts +11 -0
  28. package/dist/client/auth/types/Account.d.ts +8 -1
  29. package/dist/client/auth/types/AppleLoginBody.d.ts +16 -0
  30. package/dist/client/auth/types/AppleLoginBody.js +5 -0
  31. package/dist/client/auth/types/AuthResponse.d.ts +12 -0
  32. package/dist/client/auth/types/ChangePasswordBody.d.ts +7 -0
  33. package/dist/client/auth/types/ChangePasswordResponse.d.ts +5 -0
  34. package/dist/client/auth/types/CompletePasswordResetBody.d.ts +8 -0
  35. package/dist/client/auth/types/GoogleLoginBody.d.ts +5 -0
  36. package/dist/client/auth/types/LoginBody.d.ts +15 -1
  37. package/dist/client/auth/types/LoginError.d.ts +21 -2
  38. package/dist/client/auth/types/LoginError.js +8 -2
  39. package/dist/client/auth/types/LoginResponse.d.ts +8 -1
  40. package/dist/client/auth/types/RegisterBody.d.ts +12 -0
  41. package/dist/client/auth/types/RegisterPractitionerBody.d.ts +5 -0
  42. package/dist/client/auth/types/RegisterResponse.d.ts +7 -0
  43. package/dist/client/auth/types/RequestDeleteUserBody.d.ts +7 -7
  44. package/dist/client/auth/types/RequestDeleteUserResponse.d.ts +14 -0
  45. package/dist/client/auth/types/ResetPasswordBody.d.ts +5 -0
  46. package/dist/client/auth/types/Session.d.ts +14 -2
  47. package/dist/client/change-history/methods.d.ts +6 -0
  48. package/dist/client/change-history/methods.js +6 -0
  49. package/dist/client/change-history/types.d.ts +82 -0
  50. package/dist/client/chat/ai/methods/createAiSession.d.ts +6 -0
  51. package/dist/client/chat/ai/methods/createAiSession.js +6 -0
  52. package/dist/client/chat/ai/types/CreateAiSessionResponse.d.ts +17 -0
  53. package/dist/client/chat/ai/types/SessionMessagesResponse.d.ts +9 -0
  54. package/dist/client/cms/locale.d.ts +12 -2
  55. package/dist/client/cms/locale.js +9 -2
  56. package/dist/client/cms/methods.d.ts +6 -2
  57. package/dist/client/cms/methods.js +7 -3
  58. package/dist/client/cms/types.d.ts +44 -4
  59. package/dist/client/consent/methods.d.ts +16 -0
  60. package/dist/client/consent/methods.js +16 -0
  61. package/dist/client/consent/types.d.ts +53 -1
  62. package/dist/client/consent/types.js +10 -1
  63. package/dist/client/email/methods.d.ts +3 -0
  64. package/dist/client/email/methods.js +3 -0
  65. package/dist/client/email/types.d.ts +33 -0
  66. package/dist/client/errors/field-errors.d.ts +3 -0
  67. package/dist/client/errors/field-errors.js +3 -0
  68. package/dist/client/errors/ovok-error-utils.d.ts +6 -0
  69. package/dist/client/errors/ovok-error-utils.js +6 -0
  70. package/dist/client/errors/ovok-error.d.ts +36 -4
  71. package/dist/client/errors/ovok-error.js +15 -4
  72. package/dist/client/errors/rate-limit-error.d.ts +11 -2
  73. package/dist/client/errors/rate-limit-error.js +10 -2
  74. package/dist/client/errors/sign-in-required-error.d.ts +5 -2
  75. package/dist/client/errors/sign-in-required-error.js +5 -2
  76. package/dist/client/experience/methods.d.ts +38 -0
  77. package/dist/client/experience/methods.js +35 -0
  78. package/dist/client/experience/types.d.ts +316 -0
  79. package/dist/client/experience/types.js +1 -0
  80. package/dist/client/invites/methods.d.ts +27 -9
  81. package/dist/client/invites/methods.js +27 -9
  82. package/dist/client/invites/parse-accept-invite-link.d.ts +3 -1
  83. package/dist/client/invites/parse-accept-invite-link.js +3 -1
  84. package/dist/client/invites/types.d.ts +55 -0
  85. package/dist/client/invites/types.js +12 -0
  86. package/dist/client/notifications/methods.d.ts +15 -0
  87. package/dist/client/notifications/methods.js +15 -0
  88. package/dist/client/notifications/types.d.ts +249 -2
  89. package/dist/client/observation/bundle-entry-status.d.ts +3 -0
  90. package/dist/client/observation/bundle-entry-status.js +13 -0
  91. package/dist/client/observation/fhir-systems.d.ts +7 -0
  92. package/dist/client/observation/fhir-systems.js +8 -1
  93. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.d.ts +3 -0
  94. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +10 -65
  95. package/dist/client/observation/methods/getLatestObservationsByCodes.d.ts +3 -0
  96. package/dist/client/observation/methods/getLatestObservationsByCodes.js +3 -0
  97. package/dist/client/observation/methods/observationsToMeasurements.d.ts +23 -1
  98. package/dist/client/observation/methods/observationsToMeasurements.js +72 -12
  99. package/dist/client/observation/methods/saveMeasurement.d.ts +3 -1
  100. package/dist/client/observation/methods/saveMeasurement.js +3 -1
  101. package/dist/client/observation/observation-bundle-utils.d.ts +11 -7
  102. package/dist/client/observation/observation-bundle-utils.js +61 -71
  103. package/dist/client/observation/observation-coding.d.ts +12 -0
  104. package/dist/client/observation/observation-coding.js +69 -0
  105. package/dist/client/observation/observation-groups.d.ts +12 -0
  106. package/dist/client/observation/observation-groups.js +51 -0
  107. package/dist/client/observation/reading-group-backfill.d.ts +13 -0
  108. package/dist/client/observation/reading-group-backfill.js +79 -0
  109. package/dist/client/observation/reading-group.d.ts +14 -0
  110. package/dist/client/observation/reading-group.js +85 -0
  111. package/dist/client/observation/series.d.ts +28 -5
  112. package/dist/client/observation/series.js +16 -6
  113. package/dist/client/observation/services/base-observation-service.d.ts +1 -1
  114. package/dist/client/observation/services/base-observation-service.js +6 -12
  115. package/dist/client/observation/services/blood-pressure.d.ts +2 -0
  116. package/dist/client/observation/services/blood-pressure.js +9 -5
  117. package/dist/client/observation/services/component-observation-services.js +2 -2
  118. package/dist/client/observation/services/creator.d.ts +5 -0
  119. package/dist/client/observation/services/creator.js +5 -0
  120. package/dist/client/observation/services/ecg-observation-fragments.d.ts +4 -0
  121. package/dist/client/observation/services/ecg-observation-fragments.js +30 -37
  122. package/dist/client/observation/services/ecg.d.ts +3 -1
  123. package/dist/client/observation/services/ecg.js +19 -19
  124. package/dist/client/observation/services/uric-acid-service.js +2 -13
  125. package/dist/client/observation/services/urine-analyte-values.d.ts +4 -0
  126. package/dist/client/observation/services/urine-analyte-values.js +27 -0
  127. package/dist/client/observation/types/GetLatestObservationsByCodeParams.d.ts +10 -0
  128. package/dist/client/observation/types/MeasurementTypeKey.d.ts +26 -0
  129. package/dist/client/observation/types/MeasurementTypeKey.js +26 -0
  130. package/dist/client/observation/types/ObservationCode.d.ts +64 -1
  131. package/dist/client/observation/types/ObservationCode.js +64 -1
  132. package/dist/client/observation/types/UrineAnalytes.d.ts +29 -0
  133. package/dist/client/observation/types/UrineAnalytes.js +18 -9
  134. package/dist/client/observation/types/generate-measurement/Sample.d.ts +33 -0
  135. package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +9 -0
  136. package/dist/client/observation/types/measurement/BabySleepMeasurement.d.ts +3 -0
  137. package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.d.ts +7 -0
  138. package/dist/client/observation/types/measurement/BloodPressureMeasurement.d.ts +10 -0
  139. package/dist/client/observation/types/measurement/BloodPressureStates.d.ts +10 -0
  140. package/dist/client/observation/types/measurement/BloodPressureStates.js +10 -0
  141. package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.d.ts +7 -0
  142. package/dist/client/observation/types/measurement/BodyWeightMeasurmement.d.ts +8 -0
  143. package/dist/client/observation/types/measurement/EcgDiagnosticFlag.d.ts +18 -0
  144. package/dist/client/observation/types/measurement/EcgDiagnosticFlag.js +18 -0
  145. package/dist/client/observation/types/measurement/EcgMeasurement.d.ts +9 -0
  146. package/dist/client/observation/types/measurement/HeartRateMeasurement.d.ts +7 -0
  147. package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.d.ts +7 -0
  148. package/dist/client/observation/types/measurement/LipidPanelMeasurement.d.ts +12 -0
  149. package/dist/client/observation/types/measurement/Measurement.d.ts +9 -0
  150. package/dist/client/observation/types/measurement/MeasurementDevice.d.ts +10 -0
  151. package/dist/client/observation/types/measurement/MeasurementSeries.d.ts +2 -0
  152. package/dist/client/observation/types/measurement/PulseOximeterMeasurement.d.ts +10 -0
  153. package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.d.ts +7 -0
  154. package/dist/client/observation/types/measurement/RespiratoryTherapyMeasurement.d.ts +3 -0
  155. package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.d.ts +7 -0
  156. package/dist/client/observation/types/measurement/SpirometryMeasurement.d.ts +23 -0
  157. package/dist/client/observation/types/measurement/StepCountMeasurement.d.ts +9 -0
  158. package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.d.ts +29 -0
  159. package/dist/client/observation/types/measurement/Vo2MaxMeasurement.d.ts +7 -0
  160. package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.d.ts +7 -0
  161. package/dist/client/observation/types/service/MeasurementField.d.ts +5 -1
  162. package/dist/client/observation/utils/getDeviceObject.js +15 -32
  163. package/dist/client/observation/utils/getObservationValueDisplay.d.ts +2 -0
  164. package/dist/client/offline/offline-measurement-queue.d.ts +56 -1
  165. package/dist/client/offline/offline-measurement-queue.js +23 -8
  166. package/dist/client/offline/shared-measurement-queue.d.ts +16 -1
  167. package/dist/client/offline/shared-measurement-queue.js +3 -1
  168. package/dist/client/ovok-client.d.ts +28 -6
  169. package/dist/client/ovok-client.js +19 -11
  170. package/dist/client/patient/methods.d.ts +21 -0
  171. package/dist/client/patient/methods.js +21 -0
  172. package/dist/client/patient/types.d.ts +131 -0
  173. package/dist/client/patient-sharing/methods.d.ts +18 -0
  174. package/dist/client/patient-sharing/methods.js +18 -0
  175. package/dist/client/patient-sharing/types.d.ts +89 -1
  176. package/dist/client/platform/methods.d.ts +22 -0
  177. package/dist/client/platform/methods.js +20 -0
  178. package/dist/client/platform/types.d.ts +194 -1
  179. package/dist/client/platform/types.js +24 -0
  180. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.d.ts +3 -0
  181. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +3 -0
  182. package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.d.ts +3 -0
  183. package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.js +3 -0
  184. package/dist/client/questionnaire-response/methods/populateQuestionnaire.d.ts +3 -0
  185. package/dist/client/questionnaire-response/methods/populateQuestionnaire.js +3 -0
  186. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.d.ts +3 -0
  187. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +3 -0
  188. package/dist/client/questionnaire-response/types.d.ts +6 -0
  189. package/dist/client/signals/errors.d.ts +13 -2
  190. package/dist/client/signals/errors.js +9 -2
  191. package/dist/client/signals/methods.d.ts +9 -0
  192. package/dist/client/signals/methods.js +9 -0
  193. package/dist/client/signals/types.d.ts +31 -0
  194. package/dist/client/slim/methods.d.ts +268 -21
  195. package/dist/client/slim/methods.js +264 -21
  196. package/dist/client/slim/paging.d.ts +22 -2
  197. package/dist/client/slim/paging.js +6 -2
  198. package/dist/client/slim/types.d.ts +920 -1
  199. package/dist/client/storage.d.ts +15 -1
  200. package/dist/client/storage.js +7 -1
  201. package/dist/client/wearables/methods.d.ts +24 -0
  202. package/dist/client/wearables/methods.js +24 -0
  203. package/dist/client/wearables/types.d.ts +74 -0
  204. package/dist/conformance/api-requirements.d.ts +31 -5
  205. package/dist/conformance/api-requirements.js +47 -10
  206. package/dist/conformance/capability-requirements.d.ts +4 -26
  207. package/dist/conformance/capability-requirements.js +5 -27
  208. package/dist/conformance/capability.d.ts +9 -1
  209. package/dist/conformance/capability.js +3 -1
  210. package/dist/hooks/account-hooks.d.ts +35 -0
  211. package/dist/hooks/account-hooks.js +33 -0
  212. package/dist/hooks/api-hooks.d.ts +74 -4
  213. package/dist/hooks/api-hooks.js +56 -4
  214. package/dist/hooks/cms-hooks.d.ts +9 -3
  215. package/dist/hooks/cms-hooks.js +9 -3
  216. package/dist/hooks/email-hooks.d.ts +3 -0
  217. package/dist/hooks/email-hooks.js +3 -0
  218. package/dist/hooks/experience-hooks.d.ts +26 -0
  219. package/dist/hooks/experience-hooks.js +24 -0
  220. package/dist/hooks/index.d.ts +18 -0
  221. package/dist/hooks/index.js +18 -0
  222. package/dist/hooks/invites-hooks.d.ts +21 -2
  223. package/dist/hooks/invites-hooks.js +21 -2
  224. package/dist/hooks/notification-ack-hooks.d.ts +6 -2
  225. package/dist/hooks/notification-ack-hooks.js +6 -2
  226. package/dist/hooks/notification-hooks.d.ts +27 -3
  227. package/dist/hooks/notification-hooks.js +27 -3
  228. package/dist/hooks/notification-note-hooks.d.ts +41 -0
  229. package/dist/hooks/notification-note-hooks.js +33 -0
  230. package/dist/hooks/observation-hooks.d.ts +30 -0
  231. package/dist/hooks/observation-hooks.js +26 -3
  232. package/dist/hooks/patient-hooks.d.ts +53 -0
  233. package/dist/hooks/patient-hooks.js +48 -0
  234. package/dist/hooks/patient-sharing-hooks.d.ts +18 -0
  235. package/dist/hooks/patient-sharing-hooks.js +18 -0
  236. package/dist/hooks/platform-hooks.d.ts +32 -0
  237. package/dist/hooks/platform-hooks.js +23 -0
  238. package/dist/hooks/poll-hooks.d.ts +17 -1
  239. package/dist/hooks/poll-hooks.js +3 -1
  240. package/dist/hooks/signals-hooks.d.ts +3 -0
  241. package/dist/hooks/signals-hooks.js +3 -0
  242. package/dist/hooks/wearables-hooks.d.ts +23 -0
  243. package/dist/hooks/wearables-hooks.js +21 -0
  244. package/dist/index.d.ts +1 -965
  245. package/dist/index.js +1 -71
  246. package/dist/next/auth/saved-accounts-store.d.ts +10 -0
  247. package/dist/next/auth/session.d.ts +17 -0
  248. package/dist/next/auth/user-session.d.ts +5 -0
  249. package/dist/next/config/ovok-config.d.ts +45 -0
  250. package/dist/next/errors/ovok-account-error.d.ts +14 -1
  251. package/dist/next/errors/ovok-account-error.js +8 -1
  252. package/dist/next/errors/ovok-errors.d.ts +88 -0
  253. package/dist/next/errors/ovok-errors.js +67 -0
  254. package/dist/next/http/http-client.d.ts +5 -0
  255. package/dist/next/http/transmit.d.ts +7 -0
  256. package/dist/next/http/url.d.ts +10 -0
  257. package/dist/next/ovok.d.ts +31 -1
  258. package/dist/next/ovok.js +5 -1
  259. package/dist/next/paging/page.d.ts +13 -1
  260. package/dist/next/react/context.d.ts +7 -0
  261. package/dist/next/react/context.js +7 -0
  262. package/dist/next/react/index.d.ts +24 -0
  263. package/dist/next/react/index.js +18 -0
  264. package/dist/next/react/query-hooks.d.ts +69 -0
  265. package/dist/next/react/query-hooks.js +31 -0
  266. package/dist/next/resources/accounts/accounts-resource.d.ts +6 -0
  267. package/dist/next/resources/accounts/accounts-resource.js +6 -0
  268. package/dist/next/resources/ai/ai-chat-resource.d.ts +7 -0
  269. package/dist/next/resources/ai/ai-chat-resource.js +5 -0
  270. package/dist/next/resources/ai/ai-resource.d.ts +13 -0
  271. package/dist/next/resources/ai/ai-resource.js +6 -0
  272. package/dist/next/resources/ai/chat-messages-resource.d.ts +7 -0
  273. package/dist/next/resources/ai/chat-messages-resource.js +7 -0
  274. package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
  275. package/dist/next/resources/ai/chat-sessions-resource.js +8 -0
  276. package/dist/next/resources/auth/auth-sessions-resource.d.ts +6 -1
  277. package/dist/next/resources/auth/auth-sessions-resource.js +6 -1
  278. package/dist/next/resources/auth/registration.d.ts +18 -1
  279. package/dist/next/resources/auth/social-login.d.ts +12 -0
  280. package/dist/next/resources/auth-resource.d.ts +54 -1
  281. package/dist/next/resources/auth-resource.js +23 -0
  282. package/dist/next/resources/bots/bots-resource.d.ts +15 -0
  283. package/dist/next/resources/bots/bots-resource.js +5 -0
  284. package/dist/next/resources/cms/cms-delivery.d.ts +14 -2
  285. package/dist/next/resources/cms/cms-documents-resource.d.ts +7 -1
  286. package/dist/next/resources/cms/cms-documents-resource.js +7 -1
  287. package/dist/next/resources/cms/cms-resource.d.ts +7 -0
  288. package/dist/next/resources/cms/cms-resource.js +5 -0
  289. package/dist/next/resources/cms/release-notes-resource.d.ts +6 -0
  290. package/dist/next/resources/cms/release-notes-resource.js +6 -0
  291. package/dist/next/resources/consent/consent-resource.d.ts +22 -0
  292. package/dist/next/resources/consent/consent-resource.js +20 -0
  293. package/dist/next/resources/content/content-resource.d.ts +18 -0
  294. package/dist/next/resources/content/content-resource.js +12 -0
  295. package/dist/next/resources/documents/documents-resource.d.ts +24 -0
  296. package/dist/next/resources/documents/documents-resource.js +10 -0
  297. package/dist/next/resources/email/email-resource.d.ts +6 -0
  298. package/dist/next/resources/email/email-resource.js +5 -0
  299. package/dist/next/resources/email/email-templates-resource.d.ts +6 -0
  300. package/dist/next/resources/email/email-templates-resource.js +6 -0
  301. package/dist/next/resources/fhir-resource.d.ts +36 -0
  302. package/dist/next/resources/fhir-resource.js +21 -0
  303. package/dist/next/resources/health-resource.d.ts +16 -0
  304. package/dist/next/resources/health-resource.js +5 -0
  305. package/dist/next/resources/invites/invite-flow-resource.d.ts +7 -1
  306. package/dist/next/resources/invites/invite-flow-resource.js +7 -1
  307. package/dist/next/resources/invites/invites-resource.d.ts +15 -0
  308. package/dist/next/resources/invites/invites-resource.js +5 -0
  309. package/dist/next/resources/localization/i18next-resource.d.ts +6 -0
  310. package/dist/next/resources/localization/i18next-resource.js +6 -0
  311. package/dist/next/resources/localization/locales-resource.d.ts +7 -0
  312. package/dist/next/resources/localization/locales-resource.js +7 -0
  313. package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
  314. package/dist/next/resources/localization/localizations-resource.js +9 -0
  315. package/dist/next/resources/measurements/measurements-resource.d.ts +64 -3
  316. package/dist/next/resources/measurements/measurements-resource.js +45 -6
  317. package/dist/next/resources/measurements/observation-builder.d.ts +6 -1
  318. package/dist/next/resources/measurements/observation-builder.js +16 -7
  319. package/dist/next/resources/measurements/offline-measurement-queue-types.d.ts +32 -0
  320. package/dist/next/resources/measurements/save-error.js +3 -4
  321. package/dist/next/resources/patient/fhir-records.d.ts +19 -1
  322. package/dist/next/resources/patient/fhir-records.js +19 -1
  323. package/dist/next/resources/patient/patient-resource.d.ts +15 -0
  324. package/dist/next/resources/patient/patient-resource.js +6 -0
  325. package/dist/next/resources/projects/project-features-resource.d.ts +7 -0
  326. package/dist/next/resources/projects/project-features-resource.js +7 -0
  327. package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
  328. package/dist/next/resources/projects/project-members-resource.js +9 -0
  329. package/dist/next/resources/projects/project-settings-resource.d.ts +8 -0
  330. package/dist/next/resources/projects/project-settings-resource.js +8 -0
  331. package/dist/next/resources/projects/projects-resource.d.ts +15 -0
  332. package/dist/next/resources/projects/projects-resource.js +5 -0
  333. package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +13 -0
  334. package/dist/next/resources/questionnaires/questionnaires-resource.js +13 -0
  335. package/dist/next/resources/realtime/realtime-resource.d.ts +11 -0
  336. package/dist/next/resources/realtime/realtime-resource.js +11 -0
  337. package/dist/next/resources/realtime/realtime-socket.js +12 -5
  338. package/dist/next/resources/realtime/realtime-types.d.ts +19 -1
  339. package/dist/next/resources/session/saved-accounts-resource.d.ts +16 -0
  340. package/dist/next/resources/session/saved-accounts-resource.js +16 -0
  341. package/dist/next/resources/session/session-resource.d.ts +8 -0
  342. package/dist/next/resources/session/session-resource.js +7 -0
  343. package/dist/next/resources/sharing/sharing-invites-resource.d.ts +7 -0
  344. package/dist/next/resources/sharing/sharing-invites-resource.js +7 -0
  345. package/dist/next/resources/sharing/sharing-resource.d.ts +8 -0
  346. package/dist/next/resources/sharing/sharing-resource.js +5 -0
  347. package/dist/next/resources/sharing/sharing-settings-resource.d.ts +7 -0
  348. package/dist/next/resources/sharing/sharing-settings-resource.js +7 -0
  349. package/dist/next/resources/sharing/sharing-shares-resource.d.ts +7 -0
  350. package/dist/next/resources/sharing/sharing-shares-resource.js +7 -0
  351. package/dist/next/resources/signals/signals-gateway-resource.d.ts +15 -0
  352. package/dist/next/resources/signals/signals-gateway-resource.js +6 -0
  353. package/dist/next/resources/signals/signals-resource.d.ts +7 -0
  354. package/dist/next/resources/signals/signals-resource.js +5 -0
  355. package/dist/next/resources/signals/undeliverable-resource.d.ts +35 -0
  356. package/dist/next/resources/signals/undeliverable-resource.js +6 -0
  357. package/dist/next/resources/slim/slim-alarms-resource.d.ts +7 -0
  358. package/dist/next/resources/slim/slim-alarms-resource.js +7 -0
  359. package/dist/next/resources/slim/slim-change-history-resource.d.ts +6 -0
  360. package/dist/next/resources/slim/slim-change-history-resource.js +6 -0
  361. package/dist/next/resources/slim/slim-child-projects-resource.d.ts +21 -0
  362. package/dist/next/resources/slim/slim-child-projects-resource.js +8 -0
  363. package/dist/next/resources/slim/slim-devices-resource.d.ts +31 -0
  364. package/dist/next/resources/slim/slim-devices-resource.js +16 -0
  365. package/dist/next/resources/slim/slim-exports-resource.d.ts +6 -0
  366. package/dist/next/resources/slim/slim-exports-resource.js +6 -0
  367. package/dist/next/resources/slim/slim-locations-resource.d.ts +9 -0
  368. package/dist/next/resources/slim/slim-locations-resource.js +9 -0
  369. package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +6 -0
  370. package/dist/next/resources/slim/slim-medical-notifications-resource.js +6 -0
  371. package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +10 -0
  372. package/dist/next/resources/slim/slim-notification-notes-resource.js +10 -0
  373. package/dist/next/resources/slim/slim-notifications-resource.d.ts +10 -0
  374. package/dist/next/resources/slim/slim-notifications-resource.js +6 -0
  375. package/dist/next/resources/slim/slim-organizations-resource.d.ts +9 -0
  376. package/dist/next/resources/slim/slim-organizations-resource.js +9 -0
  377. package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +12 -0
  378. package/dist/next/resources/slim/slim-out-of-bed-resource.js +7 -0
  379. package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +6 -0
  380. package/dist/next/resources/slim/slim-patient-thresholds-resource.js +6 -0
  381. package/dist/next/resources/slim/slim-patients-resource.d.ts +11 -0
  382. package/dist/next/resources/slim/slim-patients-resource.js +10 -0
  383. package/dist/next/resources/slim/slim-policies-resource.d.ts +10 -0
  384. package/dist/next/resources/slim/slim-policies-resource.js +10 -0
  385. package/dist/next/resources/slim/slim-practitioners-resource.d.ts +6 -0
  386. package/dist/next/resources/slim/slim-practitioners-resource.js +6 -0
  387. package/dist/next/resources/slim/slim-projects-resource.d.ts +12 -0
  388. package/dist/next/resources/slim/slim-projects-resource.js +11 -0
  389. package/dist/next/resources/slim/slim-queries.d.ts +51 -0
  390. package/dist/next/resources/slim/slim-resource.d.ts +21 -0
  391. package/dist/next/resources/slim/slim-resource.js +6 -0
  392. package/dist/next/resources/slim/slim-sleep-resource.d.ts +6 -0
  393. package/dist/next/resources/slim/slim-sleep-resource.js +6 -0
  394. package/dist/next/resources/slim/slim-thresholds-resource.d.ts +5 -0
  395. package/dist/next/resources/slim/slim-thresholds-resource.js +5 -0
  396. package/dist/next/resources/slim/slim-trends-resource.d.ts +6 -0
  397. package/dist/next/resources/slim/slim-trends-resource.js +6 -0
  398. package/dist/next/resources/slim/slim-users-resource.d.ts +12 -0
  399. package/dist/next/resources/slim/slim-users-resource.js +6 -0
  400. package/dist/next/resources/slim/slim-zones-resource.d.ts +8 -0
  401. package/dist/next/resources/slim/slim-zones-resource.js +8 -0
  402. package/dist/next/resources/video-calls/video-call-access-resource.d.ts +13 -0
  403. package/dist/next/resources/video-calls/video-call-access-resource.js +8 -0
  404. package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +8 -0
  405. package/dist/next/resources/video-calls/video-call-appointments-resource.js +8 -0
  406. package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +8 -0
  407. package/dist/next/resources/video-calls/video-call-emails-resource.js +8 -0
  408. package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
  409. package/dist/next/resources/video-calls/video-calls-resource.js +6 -0
  410. package/dist/next/resources/wearables/wearable-connections-resource.d.ts +8 -0
  411. package/dist/next/resources/wearables/wearable-connections-resource.js +8 -0
  412. package/dist/next/resources/wearables/wearable-providers-resource.d.ts +10 -0
  413. package/dist/next/resources/wearables/wearable-providers-resource.js +10 -0
  414. package/dist/next/resources/wearables/wearables-resource.d.ts +7 -0
  415. package/dist/next/resources/wearables/wearables-resource.js +5 -0
  416. package/dist/next/storage/ovok-storage.d.ts +16 -0
  417. package/dist/next/storage/ovok-storage.js +8 -0
  418. package/dist/types/ValidationError.d.ts +9 -0
  419. package/dist/utils/patch/getPatchOperationType.d.ts +3 -0
  420. package/dist/utils/patch/getPatchOperationType.js +3 -0
  421. package/package.json +52 -13
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readingGroupEntries = exports.missingReadingGroups = exports.GROUPED_MEASUREMENT_TYPES = exports.READING_GROUP_OF_SYSTEM = void 0;
4
+ const observation_coding_1 = require("./observation-coding");
5
+ const reading_group_1 = require("./reading-group");
6
+ const MeasurementTypeKey_1 = require("./types/MeasurementTypeKey");
7
+ const ObservationCode_1 = require("./types/ObservationCode");
8
+ const UrineAnalytes_1 = require("./types/UrineAnalytes");
9
+ /** Identifies a group created for a reading saved before groups existed, by its first observation's id. */
10
+ exports.READING_GROUP_OF_SYSTEM = "https://sdk.ovok.com/fhir/reading-group-of";
11
+ const TYPE_BY_FIRST_CODE = new Map([
12
+ [ObservationCode_1.ObservationCode.SYSTOLIC_BLOOD_PRESSURE, MeasurementTypeKey_1.MeasurementTypeKey.bloodPressure],
13
+ [ObservationCode_1.ObservationCode.OXYGEN_SATURATION, MeasurementTypeKey_1.MeasurementTypeKey.bloodOxygenPulseRate],
14
+ [ObservationCode_1.ObservationCode.ECG, MeasurementTypeKey_1.MeasurementTypeKey.ecg],
15
+ ...UrineAnalytes_1.URINE_ANALYTE_DEFINITIONS.map(({ code }) => [code, MeasurementTypeKey_1.MeasurementTypeKey.urineAnalysis]),
16
+ ]);
17
+ /** The measurement types whose readings get a group, for the code search that loads them. */
18
+ exports.GROUPED_MEASUREMENT_TYPES = [...new Set(TYPE_BY_FIRST_CODE.values())];
19
+ const referencedId = (reference) => { var _a; return (_a = reference === null || reference === void 0 ? void 0 : reference.match(/^Observation\/(.+)$/)) === null || _a === void 0 ? void 0 : _a[1]; };
20
+ const firstIdOf = (observation) => { var _a, _b; return referencedId((_b = (_a = observation.hasMember) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.reference); };
21
+ const codeOf = (observation) => { var _a, _b, _c; return (_c = (_b = (_a = observation.code) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code; };
22
+ /** The ids of first observations a group already points at. */
23
+ const groupedFirstIds = (observations) => new Set(observations
24
+ .filter(reading_group_1.isReadingGroup)
25
+ .flatMap((group) => { var _a; return (_a = group.hasMember) !== null && _a !== void 0 ? _a : []; })
26
+ .flatMap(({ reference }) => { var _a; return (_a = referencedId(reference)) !== null && _a !== void 0 ? _a : []; }));
27
+ /** Each first observation that later parts point at, with those parts, in saved order. */
28
+ const readingsByFirst = (observations) => {
29
+ var _a, _b;
30
+ const byId = new Map(observations.flatMap((observation) => (observation.id ? [[observation.id, observation]] : [])));
31
+ const readings = new Map();
32
+ for (const observation of observations) {
33
+ const first = byId.get((_a = firstIdOf(observation)) !== null && _a !== void 0 ? _a : "");
34
+ if (first && !(0, reading_group_1.isReadingGroup)(observation)) {
35
+ readings.set(first, [...((_b = readings.get(first)) !== null && _b !== void 0 ? _b : [first]), observation]);
36
+ }
37
+ }
38
+ return readings;
39
+ };
40
+ const groupFor = (type, parts) => {
41
+ var _a;
42
+ const group = (0, reading_group_1.readingGroupOf)(type, parts);
43
+ const firstId = (_a = parts[0]) === null || _a === void 0 ? void 0 : _a.id;
44
+ return group && firstId
45
+ ? {
46
+ ...group,
47
+ ...(0, observation_coding_1.readingStatusAndCategory)(type),
48
+ identifier: [{ system: exports.READING_GROUP_OF_SYSTEM, value: firstId }],
49
+ hasMember: parts.map(({ id }) => ({ reference: `Observation/${id}` })),
50
+ }
51
+ : undefined;
52
+ };
53
+ /**
54
+ * The groups that readings saved before groups existed are missing: one for each first observation that later parts
55
+ * point at, that no group covers yet, and whose type has a group. Pass every observation of one patient's readings.
56
+ */
57
+ const missingReadingGroups = (observations) => {
58
+ const grouped = groupedFirstIds(observations);
59
+ return [...readingsByFirst(observations)].flatMap(([first, parts]) => {
60
+ var _a;
61
+ const type = TYPE_BY_FIRST_CODE.get((_a = codeOf(first)) !== null && _a !== void 0 ? _a : "");
62
+ const group = type && first.id && !grouped.has(first.id) ? groupFor(type, parts) : undefined;
63
+ return group ? [group] : [];
64
+ });
65
+ };
66
+ exports.missingReadingGroups = missingReadingGroups;
67
+ /** Bundle entries that create each group only if none was created for its reading before. */
68
+ const readingGroupEntries = (groups) => groups.map((group) => {
69
+ var _a, _b, _c;
70
+ return ({
71
+ request: {
72
+ method: "POST",
73
+ url: "Observation",
74
+ ifNoneExist: `identifier=${encodeURIComponent(`${exports.READING_GROUP_OF_SYSTEM}|${(_c = (_b = (_a = group.identifier) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : ""}`)}`,
75
+ },
76
+ resource: group,
77
+ });
78
+ });
79
+ exports.readingGroupEntries = readingGroupEntries;
@@ -0,0 +1,14 @@
1
+ import { Coding, Observation } from "@medplum/fhirtypes";
2
+ import { MeasurementTypeKey } from "./types/MeasurementTypeKey";
3
+ /** The code of a reading's group: its LOINC panel where one exists, else Ovok's measurement-type code. */
4
+ export declare const readingGroupCoding: (type: MeasurementTypeKey) => Coding;
5
+ /** The code a reading of `type` is grouped under, as a code search takes it. */
6
+ export declare const readingGroupCode: (type: MeasurementTypeKey) => string;
7
+ /** The observation that groups a multi-value reading: a group code and no value of its own. */
8
+ export declare const isReadingGroup: (observation: Observation) => boolean;
9
+ /**
10
+ * The group observation of a reading made of several observations: it carries the reading's code, time and device,
11
+ * and its `hasMember` is filled with the parts when they are saved. A blood pressure's also holds the pressures as
12
+ * components, as the FHIR vital-signs blood-pressure profile expects. A reading of one observation has none.
13
+ */
14
+ export declare const readingGroupOf: (type: MeasurementTypeKey, parts: readonly Observation[]) => Observation | undefined;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readingGroupOf = exports.isReadingGroup = exports.readingGroupCode = exports.readingGroupCoding = void 0;
4
+ const fhir_systems_1 = require("./fhir-systems");
5
+ const MeasurementTypeKey_1 = require("./types/MeasurementTypeKey");
6
+ const ObservationCode_1 = require("./types/ObservationCode");
7
+ const BLOOD_PRESSURE_PANEL = {
8
+ system: fhir_systems_1.LOINC_SYSTEM,
9
+ code: "85354-9",
10
+ display: "Blood pressure panel with all children optional",
11
+ };
12
+ const URINE_DIPSTICK_PANEL = {
13
+ system: fhir_systems_1.LOINC_SYSTEM,
14
+ code: "24357-6",
15
+ display: "Urinalysis macro (dipstick) panel - Urine",
16
+ };
17
+ const PANEL_BY_TYPE = {
18
+ [MeasurementTypeKey_1.MeasurementTypeKey.bloodPressure]: BLOOD_PRESSURE_PANEL,
19
+ [MeasurementTypeKey_1.MeasurementTypeKey.urineAnalysis]: URINE_DIPSTICK_PANEL,
20
+ [MeasurementTypeKey_1.MeasurementTypeKey.uricAcid]: URINE_DIPSTICK_PANEL,
21
+ };
22
+ const PANEL_CODES = new Set([BLOOD_PRESSURE_PANEL.code, URINE_DIPSTICK_PANEL.code]);
23
+ /** The pressures a panel repeats as components, as the vital-signs profile requires; a share must cover both. */
24
+ const BLOOD_PRESSURE_COMPONENT_CODES = [
25
+ ObservationCode_1.ObservationCode.SYSTOLIC_BLOOD_PRESSURE,
26
+ ObservationCode_1.ObservationCode.DIASTOLIC_BLOOD_PRESSURE,
27
+ ];
28
+ /** The code of a reading's group: its LOINC panel where one exists, else Ovok's measurement-type code. */
29
+ const readingGroupCoding = (type) => { var _a; return (_a = PANEL_BY_TYPE[type]) !== null && _a !== void 0 ? _a : { system: fhir_systems_1.MEASUREMENT_TYPE_SYSTEM, code: type }; };
30
+ exports.readingGroupCoding = readingGroupCoding;
31
+ /** The code a reading of `type` is grouped under, as a code search takes it. */
32
+ const readingGroupCode = (type) => { var _a; return (_a = (0, exports.readingGroupCoding)(type).code) !== null && _a !== void 0 ? _a : type; };
33
+ exports.readingGroupCode = readingGroupCode;
34
+ const hasValue = (observation) => Object.keys(observation).some((key) => key.startsWith("value"));
35
+ const hasPanelCode = (observation) => { var _a, _b, _c; return (_c = (_b = (_a = observation.code) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b.some(({ system, code }) => system === fhir_systems_1.LOINC_SYSTEM && PANEL_CODES.has(code !== null && code !== void 0 ? code : ""))) !== null && _c !== void 0 ? _c : false; };
36
+ /** A measurement-type code without components; component readings such as baby sleep share the system. */
37
+ const hasTypeGroupCode = (observation) => {
38
+ var _a, _b, _c, _d;
39
+ return !((_a = observation.component) === null || _a === void 0 ? void 0 : _a.length) &&
40
+ ((_d = (_c = (_b = observation.code) === null || _b === void 0 ? void 0 : _b.coding) === null || _c === void 0 ? void 0 : _c.some(({ system }) => system === fhir_systems_1.MEASUREMENT_TYPE_SYSTEM)) !== null && _d !== void 0 ? _d : false);
41
+ };
42
+ /** The observation that groups a multi-value reading: a group code and no value of its own. */
43
+ const isReadingGroup = (observation) => !hasValue(observation) && (hasPanelCode(observation) || hasTypeGroupCode(observation));
44
+ exports.isReadingGroup = isReadingGroup;
45
+ const codeOf = (observation) => { var _a, _b, _c; return (_c = (_b = (_a = observation.code) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code; };
46
+ const bloodPressureComponents = (parts) => BLOOD_PRESSURE_COMPONENT_CODES.flatMap((code) => {
47
+ const part = parts.find((observation) => codeOf(observation) === code);
48
+ return (part === null || part === void 0 ? void 0 : part.valueQuantity) ? [{ code: part.code, valueQuantity: part.valueQuantity }] : [];
49
+ });
50
+ const spanOf = (parts) => {
51
+ const periods = parts.flatMap((part) => (part.effectivePeriod ? [part.effectivePeriod] : []));
52
+ if (periods.length === 0) {
53
+ return undefined;
54
+ }
55
+ const starts = periods.flatMap(({ start }) => (start ? [start] : [])).sort();
56
+ const ends = periods.flatMap(({ end }) => (end ? [end] : [])).sort();
57
+ return { start: starts[0], end: ends[ends.length - 1] };
58
+ };
59
+ /**
60
+ * The group observation of a reading made of several observations: it carries the reading's code, time and device,
61
+ * and its `hasMember` is filled with the parts when they are saved. A blood pressure's also holds the pressures as
62
+ * components, as the FHIR vital-signs blood-pressure profile expects. A reading of one observation has none.
63
+ */
64
+ const readingGroupOf = (type, parts) => {
65
+ var _a;
66
+ const [first] = parts;
67
+ if (!first || parts.length < 2) {
68
+ return undefined;
69
+ }
70
+ const period = spanOf(parts);
71
+ const components = type === MeasurementTypeKey_1.MeasurementTypeKey.bloodPressure ? bloodPressureComponents(parts) : [];
72
+ const interpretation = (_a = parts.find((part) => { var _a; return (_a = part.interpretation) === null || _a === void 0 ? void 0 : _a.length; })) === null || _a === void 0 ? void 0 : _a.interpretation;
73
+ return {
74
+ resourceType: "Observation",
75
+ status: first.status,
76
+ ...(first.category ? { category: first.category } : {}),
77
+ code: { coding: [(0, exports.readingGroupCoding)(type)] },
78
+ subject: first.subject,
79
+ ...(first.device ? { device: first.device } : {}),
80
+ ...(period ? { effectivePeriod: period } : first.effectiveDateTime ? { effectiveDateTime: first.effectiveDateTime } : {}),
81
+ ...(components.length > 0 ? { component: components } : {}),
82
+ ...(interpretation ? { interpretation } : {}),
83
+ };
84
+ };
85
+ exports.readingGroupOf = readingGroupOf;
@@ -1,33 +1,56 @@
1
1
  import { Observation } from "@medplum/fhirtypes";
2
2
  import { MeasurementDevice } from "./types/measurement/MeasurementDevice";
3
3
  import { MeasurementSeries } from "./types/measurement/MeasurementSeries";
4
+ /**
5
+ * Parameters of `seriesObservations`.
6
+ */
4
7
  export type SeriesObservationParams = {
8
+ /** The series to convert. */
5
9
  series: MeasurementSeries;
10
+ /** ID of the patient the observations belong to. */
6
11
  patientId: string;
12
+ /** Device that recorded the series. */
7
13
  device?: MeasurementDevice;
8
- /** `preliminary` for values a device's own recording may still replace. */
14
+ /** Defaults to `final`; `preliminary` for values a device's own recording may still replace. */
9
15
  status?: Observation["status"];
10
16
  };
11
- /** The values of a series observation, one per slot from `start`. */
17
+ /**
18
+ * The values of a series observation, one per slot from `start`.
19
+ */
12
20
  export type ReadSeries = {
21
+ /** When the first slot starts. */
13
22
  start: Date;
23
+ /** Milliseconds from one slot to the next. */
14
24
  periodMs: number;
25
+ /** Value per slot, `null` for a slot with no value. */
15
26
  values: Array<number | null>;
16
27
  };
28
+ /**
29
+ * Lowest, highest and mean of a series' values.
30
+ */
17
31
  export type SeriesSummary = {
32
+ /** Lowest value. */
18
33
  min: number;
34
+ /** Highest value. */
19
35
  max: number;
36
+ /** Mean of the values. */
20
37
  mean: number;
38
+ /** Number of values that were not null. */
21
39
  count: number;
22
40
  };
23
41
  /**
24
42
  * A series as observations: one per measured property, in `MEASUREMENT_FIELDS` order with the main one first, each
25
43
  * holding its values as `valueSampledData` across the series' `effectivePeriod`. They carry the same codes as a
26
- * single reading of that kind. Save them with `saveObservations`, which links the rest to the first. ECG recordings
44
+ * single reading of that kind, and a series of several properties ends with their group. Save them with
45
+ * `saveObservations`, which links the rest to the first. ECG recordings
27
46
  * keep their own path, `generateObservationBodiesByMeasurement`.
28
47
  */
29
48
  export declare const seriesObservations: ({ series, patientId, device, status, }: SeriesObservationParams) => Observation[];
30
- /** The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other. */
49
+ /**
50
+ * The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other.
51
+ */
31
52
  export declare const readSeries: (observation: Observation) => ReadSeries | undefined;
32
- /** The lowest, highest and mean of a series' values, or `undefined` when it holds none. */
53
+ /**
54
+ * The lowest, highest and mean of a series' values, or `undefined` when it holds none.
55
+ */
33
56
  export declare const summarizeSeries: (values: ReadonlyArray<number | null>) => SeriesSummary | undefined;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.summarizeSeries = exports.readSeries = exports.seriesObservations = void 0;
4
+ const observation_coding_1 = require("./observation-coding");
5
+ const reading_group_1 = require("./reading-group");
4
6
  const creator_1 = require("./services/creator");
5
7
  const getDeviceObject_1 = require("./utils/getDeviceObject");
6
8
  /** FHIR's mark for a slot with no value. */
@@ -11,10 +13,11 @@ const sampledData = (values, decimals) => values
11
13
  /**
12
14
  * A series as observations: one per measured property, in `MEASUREMENT_FIELDS` order with the main one first, each
13
15
  * holding its values as `valueSampledData` across the series' `effectivePeriod`. They carry the same codes as a
14
- * single reading of that kind. Save them with `saveObservations`, which links the rest to the first. ECG recordings
16
+ * single reading of that kind, and a series of several properties ends with their group. Save them with
17
+ * `saveObservations`, which links the rest to the first. ECG recordings
15
18
  * keep their own path, `generateObservationBodiesByMeasurement`.
16
19
  */
17
- const seriesObservations = ({ series, patientId, device, status = "registered", }) => {
20
+ const seriesObservations = ({ series, patientId, device, status = "final", }) => {
18
21
  const service = creator_1.ObservationServiceCreator.getInstance().getService(series.measurementTypeKey);
19
22
  const codes = service.getObservationCodes();
20
23
  const slots = Math.max(0, ...Object.values(series.values).map((values) => { var _a; return (_a = values === null || values === void 0 ? void 0 : values.length) !== null && _a !== void 0 ? _a : 0; }));
@@ -22,7 +25,7 @@ const seriesObservations = ({ series, patientId, device, status = "registered",
22
25
  start: series.start.toISOString(),
23
26
  end: new Date(series.start.getTime() + slots * series.periodMs).toISOString(),
24
27
  };
25
- return service.getFields().flatMap((field, index) => {
28
+ const parts = service.getFields().flatMap((field, index) => {
26
29
  const values = series.values[field.key];
27
30
  const code = codes[index];
28
31
  if (!code || !(values === null || values === void 0 ? void 0 : values.some((value) => value !== null))) {
@@ -30,22 +33,27 @@ const seriesObservations = ({ series, patientId, device, status = "registered",
30
33
  }
31
34
  return [{
32
35
  resourceType: "Observation",
36
+ ...(0, observation_coding_1.readingStatusAndCategory)(series.measurementTypeKey),
33
37
  status,
34
38
  subject: { reference: `Patient/${patientId}` },
35
39
  device: (0, getDeviceObject_1.getDeviceObject)(device),
36
40
  code,
37
41
  effectivePeriod,
38
42
  valueSampledData: {
39
- origin: { value: 0, unit: field.unit },
43
+ origin: (0, observation_coding_1.ucumQuantity)(0, field.unit),
40
44
  period: series.periodMs,
41
45
  dimensions: 1,
42
46
  data: sampledData(values, field.decimals),
43
47
  },
44
48
  }];
45
49
  });
50
+ const group = (0, reading_group_1.readingGroupOf)(series.measurementTypeKey, parts);
51
+ return group ? [...parts, group] : parts;
46
52
  };
47
53
  exports.seriesObservations = seriesObservations;
48
- /** The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other. */
54
+ /**
55
+ * The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other.
56
+ */
49
57
  const readSeries = (observation) => {
50
58
  var _a, _b, _c, _d, _e, _f;
51
59
  const sampled = observation.valueSampledData;
@@ -66,7 +74,9 @@ const readSeries = (observation) => {
66
74
  };
67
75
  };
68
76
  exports.readSeries = readSeries;
69
- /** The lowest, highest and mean of a series' values, or `undefined` when it holds none. */
77
+ /**
78
+ * The lowest, highest and mean of a series' values, or `undefined` when it holds none.
79
+ */
70
80
  const summarizeSeries = (values) => {
71
81
  let min = Infinity, max = -Infinity, total = 0, count = 0;
72
82
  // A loop, not Math.min(...values): an ECG holds more values than a call takes arguments.
@@ -17,7 +17,7 @@ export declare abstract class BaseObservationService<T extends Measurement> impl
17
17
  protected getCastedMeasurement(measurement: Measurement): T;
18
18
  generateValues(measurement: Measurement): ObservationValue[];
19
19
  getObservationCodes(): CodeableConcept[];
20
- getAdditionalProperties(_measurement: Measurement): Partial<Observation>[];
20
+ getAdditionalProperties(measurement: Measurement): Partial<Observation>[];
21
21
  getUnits(): string[];
22
22
  getMeasurementDisplay(measurement: Measurement): string;
23
23
  getObservationDisplay(observations: Observation[]): string | undefined;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseObservationService = void 0;
4
4
  const fhir_systems_1 = require("../fhir-systems");
5
+ const observation_coding_1 = require("../observation-coding");
6
+ const measurement_time_1 = require("./measurement-time");
5
7
  class BaseObservationService {
6
8
  getFields() {
7
9
  return this.observationMetadata.map(({ valueKey, primaryCode, unit, toFixed, display }) => ({
@@ -30,14 +32,7 @@ class BaseObservationService {
30
32
  throw new Error(`${metadata.valueKey} must be a number but got ${value}`);
31
33
  }
32
34
  const fixedValue = numberValue.toFixed(metadata.toFixed);
33
- return {
34
- valueQuantity: {
35
- value: Number(fixedValue),
36
- unit: metadata.unit,
37
- code: metadata.primaryCode,
38
- system: fhir_systems_1.LOINC_SYSTEM,
39
- },
40
- };
35
+ return { valueQuantity: (0, observation_coding_1.ucumQuantity)(Number(fixedValue), metadata.unit) };
41
36
  });
42
37
  }
43
38
  getObservationCodes() {
@@ -57,10 +52,9 @@ class BaseObservationService {
57
52
  text: metadata.display,
58
53
  }));
59
54
  }
60
- getAdditionalProperties(_measurement) {
61
- return Object.values(this.observationMetadata).map(() => ({
62
- effectiveDateTime: new Date().toISOString(),
63
- }));
55
+ getAdditionalProperties(measurement) {
56
+ const effectiveDateTime = (0, measurement_time_1.recordedAtOrNow)(measurement).toISOString();
57
+ return this.observationMetadata.map(() => ({ effectiveDateTime }));
64
58
  }
65
59
  getUnits() {
66
60
  return this.observationMetadata.map((metadata) => metadata.unit);
@@ -5,6 +5,8 @@ import { Sample } from "../types/generate-measurement/Sample";
5
5
  import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
6
6
  import { ObservationMetadata } from "../types/service/ObservationMetadata";
7
7
  import { BaseObservationService } from "./base-observation-service";
8
+ /** The monitor's measurement status (movement, loose cuff), kept on the systolic observation. */
9
+ export declare const BLOOD_PRESSURE_STATUS_URL = "http://ovok.com/fhir/StructureDefinition/blood-pressure-measurement-status";
8
10
  export declare class BloodPressureService extends BaseObservationService<BloodPressureMeasurement> {
9
11
  protected measurementTypeKey: MeasurementTypeKey;
10
12
  protected measurementTypeName: string;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BloodPressureService = void 0;
3
+ exports.BloodPressureService = exports.BLOOD_PRESSURE_STATUS_URL = void 0;
4
4
  const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
5
+ const fhir_systems_1 = require("../fhir-systems");
5
6
  const base_observation_service_1 = require("./base-observation-service");
7
+ /** The monitor's measurement status (movement, loose cuff), kept on the systolic observation. */
8
+ exports.BLOOD_PRESSURE_STATUS_URL = `${fhir_systems_1.OVOK_EXTENSION_BASE_URL}/blood-pressure-measurement-status`;
6
9
  class BloodPressureService extends base_observation_service_1.BaseObservationService {
7
10
  constructor() {
8
11
  super(...arguments);
@@ -78,11 +81,12 @@ class BloodPressureService extends base_observation_service_1.BaseObservationSer
78
81
  ];
79
82
  }
80
83
  getAdditionalProperties(measurement) {
81
- var _a;
82
- const properties = super.getAdditionalProperties(measurement);
84
+ const [systolic, ...rest] = super.getAdditionalProperties(measurement);
85
+ const { status } = this.getCastedMeasurement(measurement);
83
86
  return [
84
- ...properties,
85
- { effectiveDateTime: (_a = properties[0]) === null || _a === void 0 ? void 0 : _a.effectiveDateTime },
87
+ status ? { ...systolic, extension: [{ url: exports.BLOOD_PRESSURE_STATUS_URL, valueString: status }] } : systolic,
88
+ ...rest,
89
+ { effectiveDateTime: systolic === null || systolic === void 0 ? void 0 : systolic.effectiveDateTime },
86
90
  ];
87
91
  }
88
92
  getMeasurementDisplay(measurement) {
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.respiratoryTherapyService = exports.babySleepService = void 0;
4
4
  const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
5
+ const fhir_systems_1 = require("../fhir-systems");
5
6
  const base_observation_service_1 = require("./base-observation-service");
6
7
  const measurement_time_1 = require("./measurement-time");
7
- const MEASUREMENT_TYPE_SYSTEM = "https://sdk.ovok.com/fhir/CodeSystem/measurement-type";
8
8
  /** One observation that carries the device adapter's coded components as they are. */
9
9
  class ComponentObservationService extends base_observation_service_1.BaseObservationService {
10
10
  constructor(measurementTypeKey, measurementTypeName, code) {
@@ -58,7 +58,7 @@ class ComponentObservationService extends base_observation_service_1.BaseObserva
58
58
  coding: [{
59
59
  code: this.code,
60
60
  display: `${this.title} observation`,
61
- system: MEASUREMENT_TYPE_SYSTEM,
61
+ system: fhir_systems_1.MEASUREMENT_TYPE_SYSTEM,
62
62
  }],
63
63
  };
64
64
  }
@@ -1,11 +1,16 @@
1
1
  import { MeasurementTypeKey } from "../../../types/MeasurementTypes";
2
2
  import { IObservationService } from "../types/IObservationService";
3
+ /**
4
+ * Registry of the observation services that turn measurements into Observations.
5
+ */
3
6
  export declare class ObservationServiceCreator {
4
7
  private static instance;
5
8
  private readonly services;
6
9
  private constructor();
10
+ /** Returns the shared registry. */
7
11
  static getInstance(): ObservationServiceCreator;
8
12
  /** The measurement types the SDK turns into Observations. */
9
13
  getTypes(): MeasurementTypeKey[];
14
+ /** Returns the service for a measurement type; throws when the type is unsupported. */
10
15
  getService(type: MeasurementTypeKey): IObservationService;
11
16
  }
@@ -10,6 +10,9 @@ const lipid_panel_1 = require("./lipid-panel");
10
10
  const single_value_services_1 = require("./single-value-services");
11
11
  const step_count_1 = require("./step-count");
12
12
  const uric_acid_service_1 = require("./uric-acid-service");
13
+ /**
14
+ * Registry of the observation services that turn measurements into Observations.
15
+ */
13
16
  class ObservationServiceCreator {
14
17
  constructor() {
15
18
  const uricAcid = new uric_acid_service_1.UricAcidService();
@@ -26,6 +29,7 @@ class ObservationServiceCreator {
26
29
  [MeasurementTypes_1.MeasurementTypeKey.babySleep, (0, component_observation_services_1.babySleepService)()],
27
30
  ]);
28
31
  }
32
+ /** Returns the shared registry. */
29
33
  static getInstance() {
30
34
  if (!ObservationServiceCreator.instance) {
31
35
  ObservationServiceCreator.instance = new ObservationServiceCreator();
@@ -36,6 +40,7 @@ class ObservationServiceCreator {
36
40
  getTypes() {
37
41
  return [...this.services.keys()];
38
42
  }
43
+ /** Returns the service for a measurement type; throws when the type is unsupported. */
39
44
  getService(type) {
40
45
  const service = this.services.get(type);
41
46
  if (!service) {
@@ -1,4 +1,8 @@
1
1
  import { CodeableConcept } from "@medplum/fhirtypes";
2
2
  import { EcgMeasurement } from "../../../types/MeasurementTypes";
3
3
  import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
4
+ /** Milliseconds between samples; without a recording duration the time base is unknown, so the ECG can't be saved. */
5
+ export declare const ecgSamplePeriodMs: ({ duration, diagramPoints }: EcgMeasurement) => number;
6
+ /** SampledData's space-separated values; a sample the device could not measure is "E". */
7
+ export declare const sampledDataOf: (samples: readonly number[]) => string;
4
8
  export declare const generateEcgObservationFragments: (measurement: EcgMeasurement, observationCodes: CodeableConcept[]) => ObservationFragment[];
@@ -1,47 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateEcgObservationFragments = void 0;
3
+ exports.generateEcgObservationFragments = exports.sampledDataOf = exports.ecgSamplePeriodMs = void 0;
4
4
  const fhir_systems_1 = require("../fhir-systems");
5
+ const observation_coding_1 = require("../observation-coding");
5
6
  const measurement_time_1 = require("./measurement-time");
6
7
  const MAX_SEGMENT_DURATION_SECONDS = 5 * 60;
7
8
  const MAX_SAMPLED_DATA_CHARACTERS = 750000;
9
+ const MILLISECONDS_PER_SECOND = 1000;
10
+ const SAMPLE_DECIMALS = 3;
11
+ const ERROR_SAMPLE = "E";
12
+ const MILLIVOLT_ORIGIN = { value: 0, unit: "mV", system: fhir_systems_1.UCUM_SYSTEM, code: "mV" };
13
+ const DURATION_COMPONENT_SYSTEM = `${fhir_systems_1.OVOK_EXTENSION_BASE_URL}/observation-component`;
14
+ /** Milliseconds between samples; without a recording duration the time base is unknown, so the ECG can't be saved. */
15
+ const ecgSamplePeriodMs = ({ duration, diagramPoints }) => {
16
+ if (typeof duration !== "number" || !Number.isFinite(duration) || duration <= 0 || !(diagramPoints === null || diagramPoints === void 0 ? void 0 : diagramPoints.length)) {
17
+ throw new Error("An ECG needs its recording duration to be saved.");
18
+ }
19
+ return (duration * MILLISECONDS_PER_SECOND) / diagramPoints.length;
20
+ };
21
+ exports.ecgSamplePeriodMs = ecgSamplePeriodMs;
22
+ /** SampledData's space-separated values; a sample the device could not measure is "E". */
23
+ const sampledDataOf = (samples) => samples.map((sample) => (Number.isFinite(sample) ? String(Number(sample.toFixed(SAMPLE_DECIMALS))) : ERROR_SAMPLE)).join(" ");
24
+ exports.sampledDataOf = sampledDataOf;
8
25
  const generateEcgObservationFragments = (measurement, observationCodes) => {
9
26
  const fragments = [];
10
27
  const diagramPoints = measurement.diagramPoints;
11
28
  const recordedAt = (0, measurement_time_1.recordedAtOrNow)(measurement);
12
- const duration = typeof measurement.duration === "number" &&
13
- Number.isFinite(measurement.duration) &&
14
- measurement.duration > 0
15
- ? measurement.duration
16
- : undefined;
17
29
  if (diagramPoints === null || diagramPoints === void 0 ? void 0 : diagramPoints.length) {
18
- const maxSamplesForDuration = duration
19
- ? Math.max(1, Math.floor((MAX_SEGMENT_DURATION_SECONDS * diagramPoints.length) / duration))
20
- : diagramPoints.length;
30
+ const period = (0, exports.ecgSamplePeriodMs)(measurement);
31
+ const duration = measurement.duration;
32
+ const maxSamplesForDuration = Math.max(1, Math.floor((MAX_SEGMENT_DURATION_SECONDS * diagramPoints.length) / duration));
21
33
  const maxSamples = Math.min(maxSamplesForDuration, Math.max(1, Math.floor(MAX_SAMPLED_DATA_CHARACTERS / 7)));
22
34
  const recordingId = `ecg-${recordedAt.getTime()}-${diagramPoints.length}`;
23
35
  const ecgCode = observationCodes[0];
24
36
  for (let startIndex = 0, segmentIndex = 0; startIndex < diagramPoints.length; startIndex += maxSamples, segmentIndex++) {
25
37
  const segment = diagramPoints.slice(startIndex, startIndex + maxSamples);
26
- const segmentDuration = duration
27
- ? (duration * segment.length) / diagramPoints.length
28
- : segment.length / 1000;
29
- const segmentStart = new Date(recordedAt.getTime() +
30
- (duration
31
- ? (duration * startIndex * 1000) / diagramPoints.length
32
- : startIndex));
33
- const segmentEnd = new Date(segmentStart.getTime() + segmentDuration * 1000);
38
+ const segmentStart = new Date(recordedAt.getTime() + startIndex * period);
39
+ const segmentEnd = new Date(segmentStart.getTime() + segment.length * period);
34
40
  const firstId = recordingId;
35
41
  fragments.push({
36
42
  code: ecgCode,
37
43
  value: {
38
44
  valueSampledData: {
39
- origin: { value: 0, unit: "mV" },
40
- period: duration
41
- ? (duration * 1000) / diagramPoints.length
42
- : 1,
45
+ origin: MILLIVOLT_ORIGIN,
46
+ period,
43
47
  dimensions: 1,
44
- data: segment.map((sample) => Number(sample.toFixed(3))).join(" "),
48
+ data: (0, exports.sampledDataOf)(segment),
45
49
  },
46
50
  },
47
51
  additionalProperties: {
@@ -50,15 +54,11 @@ const generateEcgObservationFragments = (measurement, observationCodes) => {
50
54
  start: segmentStart.toISOString(),
51
55
  end: segmentEnd.toISOString(),
52
56
  },
53
- hasMember: segmentIndex === 0
54
- ? []
55
- : [{ reference: `Observation/${firstId}` }],
57
+ ...(segmentIndex === 0 ? {} : { hasMember: [{ reference: `Observation/${firstId}` }] }),
56
58
  ...(segmentIndex === 0 && measurement.diagnosticResult
57
59
  ? { interpretation: [{ text: measurement.diagnosticResult }] }
58
60
  : {}),
59
- ...(segmentIndex === 0 && duration !== undefined
60
- ? { component: [durationComponent(duration)] }
61
- : {}),
61
+ ...(segmentIndex === 0 ? { component: [durationComponent(duration)] } : {}),
62
62
  },
63
63
  });
64
64
  }
@@ -66,14 +66,7 @@ const generateEcgObservationFragments = (measurement, observationCodes) => {
66
66
  if (typeof measurement.heartRate === "number") {
67
67
  fragments.push({
68
68
  code: observationCodes[1],
69
- value: {
70
- valueQuantity: {
71
- value: Number(measurement.heartRate.toFixed(0)),
72
- unit: "bpm",
73
- code: "8867-4",
74
- system: fhir_systems_1.LOINC_SYSTEM,
75
- },
76
- },
69
+ value: { valueQuantity: (0, observation_coding_1.ucumQuantity)(Number(measurement.heartRate.toFixed(0)), "bpm") },
77
70
  additionalProperties: {
78
71
  effectiveDateTime: recordedAt.toISOString(),
79
72
  },
@@ -85,7 +78,7 @@ exports.generateEcgObservationFragments = generateEcgObservationFragments;
85
78
  const durationComponent = (duration) => ({
86
79
  code: {
87
80
  text: "measurement-duration",
88
- coding: [{ code: "measurement-duration" }],
81
+ coding: [{ system: DURATION_COMPONENT_SYSTEM, code: "measurement-duration" }],
89
82
  },
90
83
  id: "measurement-duration",
91
84
  valueQuantity: {
@@ -1,4 +1,4 @@
1
- import { Observation } from "@medplum/fhirtypes";
1
+ import { CodeableConcept, Observation } from "@medplum/fhirtypes";
2
2
  import { EcgMeasurement, Measurement, MeasurementTypeKey } from "../../../types/MeasurementTypes";
3
3
  import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
4
4
  import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
@@ -12,6 +12,8 @@ export declare class EcgService extends BaseObservationService<EcgMeasurement> {
12
12
  /** Expand long recordings into bounded, timestamped observations. */
13
13
  generateObservationFragments(measurement: Measurement): ObservationFragment[];
14
14
  getAdditionalProperties(measurement: Measurement): Partial<Observation>[];
15
+ /** The waveform is coded in the ISO/IEEE 11073 nomenclature, not LOINC. */
16
+ getObservationCodes(): CodeableConcept[];
15
17
  getMeasurementDisplay(measurement: Measurement): string;
16
18
  getObservationDisplay(observations: Observation[]): string | undefined;
17
19
  convertSamplesToMeasurement(): EcgMeasurement;