@ovok/core 0.4.49-rc.1 → 0.4.49-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +27 -79
  2. package/dist/client/observation/measurement-fields.d.ts +1 -1
  3. package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
  4. package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
  5. package/dist/client/observation/services/base-observation-service.d.ts +1 -1
  6. package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
  7. package/dist/client/observation/services/blood-oxygen.js +7 -7
  8. package/dist/client/observation/services/blood-pressure.d.ts +1 -1
  9. package/dist/client/observation/services/blood-pressure.js +16 -16
  10. package/dist/client/observation/services/component-observation-services.d.ts +1 -1
  11. package/dist/client/observation/services/component-observation-services.js +3 -3
  12. package/dist/client/observation/services/creator.d.ts +1 -1
  13. package/dist/client/observation/services/creator.js +10 -10
  14. package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
  15. package/dist/client/observation/services/ecg.d.ts +1 -1
  16. package/dist/client/observation/services/ecg.js +10 -10
  17. package/dist/client/observation/services/lipid-panel.d.ts +1 -1
  18. package/dist/client/observation/services/lipid-panel.js +13 -13
  19. package/dist/client/observation/services/single-value-services.d.ts +1 -1
  20. package/dist/client/observation/services/single-value-services.js +19 -19
  21. package/dist/client/observation/services/step-count.d.ts +1 -1
  22. package/dist/client/observation/services/step-count.js +5 -5
  23. package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
  24. package/dist/client/observation/services/uric-acid-service.js +7 -7
  25. package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
  26. package/dist/client/signals/methods.d.ts +2 -23
  27. package/dist/client/signals/methods.js +10 -93
  28. package/dist/client/signals/types.d.ts +6 -132
  29. package/dist/client/wearables/types.d.ts +5 -0
  30. package/dist/conformance/api-requirements.js +2 -9
  31. package/dist/conformance/capability-requirements.js +1 -1
  32. package/dist/hooks/index.d.ts +1 -1
  33. package/dist/hooks/index.js +1 -9
  34. package/dist/hooks/notification-invalidation.d.ts +0 -7
  35. package/dist/hooks/signals-hooks.d.ts +2 -23
  36. package/dist/hooks/signals-hooks.js +1 -15
  37. package/dist/next/auth/access-token.d.ts +9 -0
  38. package/dist/next/auth/access-token.js +18 -0
  39. package/dist/next/auth/client-credentials.d.ts +16 -0
  40. package/dist/next/auth/client-credentials.js +40 -0
  41. package/dist/next/auth/credentials.d.ts +5 -0
  42. package/dist/next/auth/credentials.js +7 -0
  43. package/dist/next/auth/saved-accounts-store.d.ts +26 -0
  44. package/dist/next/auth/saved-accounts-store.js +93 -0
  45. package/dist/next/auth/session-store.d.ts +12 -0
  46. package/dist/next/auth/session-store.js +33 -0
  47. package/dist/next/auth/session.d.ts +28 -0
  48. package/dist/next/auth/session.js +27 -0
  49. package/dist/next/auth/token-endpoint.d.ts +12 -0
  50. package/dist/next/auth/token-endpoint.js +28 -0
  51. package/dist/next/auth/user-session.d.ts +39 -0
  52. package/dist/next/auth/user-session.js +183 -0
  53. package/dist/next/config/ovok-config.d.ts +42 -0
  54. package/dist/next/config/ovok-config.js +2 -0
  55. package/dist/next/config/settings.d.ts +6 -0
  56. package/dist/next/config/settings.js +74 -0
  57. package/dist/next/errors/error-from-response.d.ts +2 -0
  58. package/dist/next/errors/error-from-response.js +35 -0
  59. package/dist/next/errors/ovok-account-error.d.ts +5 -0
  60. package/dist/next/errors/ovok-account-error.js +13 -0
  61. package/dist/next/errors/ovok-errors.d.ts +42 -0
  62. package/dist/next/errors/ovok-errors.js +74 -0
  63. package/dist/next/http/http-client.d.ts +36 -0
  64. package/dist/next/http/http-client.js +116 -0
  65. package/dist/next/http/retry-after.d.ts +1 -0
  66. package/dist/next/http/retry-after.js +16 -0
  67. package/dist/next/http/retry-policy.d.ts +13 -0
  68. package/dist/next/http/retry-policy.js +27 -0
  69. package/dist/next/http/transmit.d.ts +14 -0
  70. package/dist/next/http/transmit.js +57 -0
  71. package/dist/next/http/url.d.ts +6 -0
  72. package/dist/next/http/url.js +22 -0
  73. package/dist/next/index.d.ts +77 -0
  74. package/dist/next/index.js +35 -0
  75. package/dist/next/ovok.d.ts +56 -0
  76. package/dist/next/ovok.js +86 -0
  77. package/dist/next/paging/bundle-page.d.ts +4 -0
  78. package/dist/next/paging/bundle-page.js +25 -0
  79. package/dist/next/paging/cursor-pages.d.ts +7 -0
  80. package/dist/next/paging/cursor-pages.js +14 -0
  81. package/dist/next/paging/numbered-pages.d.ts +15 -0
  82. package/dist/next/paging/numbered-pages.js +20 -0
  83. package/dist/next/paging/page.d.ts +12 -0
  84. package/dist/next/paging/page.js +17 -0
  85. package/dist/next/react/context.d.ts +4 -0
  86. package/dist/{hooks/signals-alert-item-hooks.js → next/react/context.js} +10 -26
  87. package/dist/next/react/index.d.ts +14 -0
  88. package/dist/next/react/index.js +68 -0
  89. package/dist/next/react/query-hooks.d.ts +31 -0
  90. package/dist/next/react/query-hooks.js +160 -0
  91. package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
  92. package/dist/next/resources/accounts/accounts-resource.js +13 -0
  93. package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
  94. package/dist/next/resources/ai/ai-chat-resource.js +12 -0
  95. package/dist/next/resources/ai/ai-resource.d.ts +16 -0
  96. package/dist/next/resources/ai/ai-resource.js +19 -0
  97. package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
  98. package/dist/next/resources/ai/chat-messages-resource.js +18 -0
  99. package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
  100. package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
  101. package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
  102. package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
  103. package/dist/next/resources/auth/registration.d.ts +35 -0
  104. package/dist/next/resources/auth/registration.js +24 -0
  105. package/dist/next/resources/auth/social-login.d.ts +8 -0
  106. package/dist/next/resources/auth/social-login.js +7 -0
  107. package/dist/next/resources/auth-resource.d.ts +63 -0
  108. package/dist/next/resources/auth-resource.js +119 -0
  109. package/dist/next/resources/bots/bots-resource.d.ts +10 -0
  110. package/dist/next/resources/bots/bots-resource.js +15 -0
  111. package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
  112. package/dist/next/resources/cms/cms-delivery.js +36 -0
  113. package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
  114. package/dist/next/resources/cms/cms-documents-resource.js +17 -0
  115. package/dist/next/resources/cms/cms-resource.d.ts +17 -0
  116. package/dist/next/resources/cms/cms-resource.js +38 -0
  117. package/dist/next/resources/cms/payload-pages.d.ts +6 -0
  118. package/dist/next/resources/cms/payload-pages.js +15 -0
  119. package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
  120. package/dist/next/resources/cms/release-notes-resource.js +15 -0
  121. package/dist/next/resources/cms/translation-tree.d.ts +3 -0
  122. package/dist/next/resources/cms/translation-tree.js +45 -0
  123. package/dist/next/resources/consent/consent-resource.d.ts +23 -0
  124. package/dist/next/resources/consent/consent-resource.js +43 -0
  125. package/dist/next/resources/content/content-resource.d.ts +19 -0
  126. package/dist/next/resources/content/content-resource.js +41 -0
  127. package/dist/next/resources/documents/documents-resource.d.ts +26 -0
  128. package/dist/next/resources/documents/documents-resource.js +41 -0
  129. package/dist/next/resources/email/email-resource.d.ts +6 -0
  130. package/dist/next/resources/email/email-resource.js +10 -0
  131. package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
  132. package/dist/next/resources/email/email-templates-resource.js +13 -0
  133. package/dist/next/resources/fhir-resource.d.ts +28 -0
  134. package/dist/next/resources/fhir-resource.js +64 -0
  135. package/dist/next/resources/health-resource.d.ts +17 -0
  136. package/dist/next/resources/health-resource.js +14 -0
  137. package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
  138. package/dist/next/resources/invites/invite-flow-resource.js +19 -0
  139. package/dist/next/resources/invites/invites-resource.d.ts +22 -0
  140. package/dist/next/resources/invites/invites-resource.js +29 -0
  141. package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
  142. package/dist/next/resources/localization/i18next-resource.js +18 -0
  143. package/dist/next/resources/localization/locales-resource.d.ts +9 -0
  144. package/dist/next/resources/localization/locales-resource.js +16 -0
  145. package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
  146. package/dist/next/resources/localization/localizations-resource.js +27 -0
  147. package/dist/next/resources/measurements/measurements-resource.d.ts +58 -0
  148. package/dist/next/resources/measurements/measurements-resource.js +98 -0
  149. package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
  150. package/dist/next/resources/measurements/observation-builder.js +57 -0
  151. package/dist/next/resources/measurements/offline-measurement-queue-types.d.ts +22 -0
  152. package/dist/next/resources/measurements/offline-measurement-queue-types.js +2 -0
  153. package/dist/next/resources/measurements/offline-measurement-queue.d.ts +25 -0
  154. package/dist/next/resources/measurements/offline-measurement-queue.js +154 -0
  155. package/dist/next/resources/measurements/save-error.d.ts +5 -0
  156. package/dist/next/resources/measurements/save-error.js +18 -0
  157. package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
  158. package/dist/next/resources/measurements/signed-in-account.js +26 -0
  159. package/dist/next/resources/patient/fhir-records.d.ts +19 -0
  160. package/dist/next/resources/patient/fhir-records.js +33 -0
  161. package/dist/next/resources/patient/patient-resource.d.ts +21 -0
  162. package/dist/next/resources/patient/patient-resource.js +38 -0
  163. package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
  164. package/dist/next/resources/projects/project-features-resource.js +17 -0
  165. package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
  166. package/dist/next/resources/projects/project-members-resource.js +25 -0
  167. package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
  168. package/dist/next/resources/projects/project-settings-resource.js +21 -0
  169. package/dist/next/resources/projects/projects-resource.d.ts +20 -0
  170. package/dist/next/resources/projects/projects-resource.js +21 -0
  171. package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
  172. package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
  173. package/dist/next/resources/realtime/realtime-binding.d.ts +7 -0
  174. package/dist/next/resources/realtime/realtime-binding.js +44 -0
  175. package/dist/next/resources/realtime/realtime-connection.d.ts +38 -0
  176. package/dist/next/resources/realtime/realtime-connection.js +167 -0
  177. package/dist/next/resources/realtime/realtime-resource.d.ts +13 -0
  178. package/dist/next/resources/realtime/realtime-resource.js +39 -0
  179. package/dist/next/resources/realtime/realtime-socket.d.ts +23 -0
  180. package/dist/next/resources/realtime/realtime-socket.js +152 -0
  181. package/dist/next/resources/realtime/realtime-types.d.ts +6 -0
  182. package/dist/next/resources/realtime/realtime-types.js +2 -0
  183. package/dist/next/resources/session/saved-accounts-resource.d.ts +13 -0
  184. package/dist/next/resources/session/saved-accounts-resource.js +44 -0
  185. package/dist/next/resources/session/session-resource.d.ts +12 -0
  186. package/dist/next/resources/session/session-resource.js +19 -0
  187. package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
  188. package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
  189. package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
  190. package/dist/next/resources/sharing/sharing-resource.js +14 -0
  191. package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
  192. package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
  193. package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
  194. package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
  195. package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
  196. package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
  197. package/dist/next/resources/signals/signals-resource.d.ts +13 -0
  198. package/dist/next/resources/signals/signals-resource.js +19 -0
  199. package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
  200. package/dist/next/resources/signals/undeliverable-resource.js +18 -0
  201. package/dist/next/resources/slim/live-reads.d.ts +13 -0
  202. package/dist/next/resources/slim/live-reads.js +87 -0
  203. package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
  204. package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
  205. package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
  206. package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
  207. package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
  208. package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
  209. package/dist/next/resources/slim/slim-devices-resource.d.ts +29 -0
  210. package/dist/next/resources/slim/slim-devices-resource.js +81 -0
  211. package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
  212. package/dist/next/resources/slim/slim-exports-resource.js +14 -0
  213. package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
  214. package/dist/next/resources/slim/slim-locations-resource.js +30 -0
  215. package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
  216. package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
  217. package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
  218. package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
  219. package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
  220. package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
  221. package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
  222. package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
  223. package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
  224. package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
  225. package/dist/next/resources/slim/slim-paths.d.ts +6 -0
  226. package/dist/next/resources/slim/slim-paths.js +9 -0
  227. package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
  228. package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
  229. package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
  230. package/dist/next/resources/slim/slim-patients-resource.js +39 -0
  231. package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
  232. package/dist/next/resources/slim/slim-policies-resource.js +29 -0
  233. package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
  234. package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
  235. package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
  236. package/dist/next/resources/slim/slim-projects-resource.js +35 -0
  237. package/dist/next/resources/slim/slim-queries.d.ts +34 -0
  238. package/dist/next/resources/slim/slim-queries.js +2 -0
  239. package/dist/next/resources/slim/slim-resource.d.ts +39 -0
  240. package/dist/next/resources/slim/slim-resource.js +44 -0
  241. package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
  242. package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
  243. package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
  244. package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
  245. package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
  246. package/dist/next/resources/slim/slim-trends-resource.js +19 -0
  247. package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
  248. package/dist/next/resources/slim/slim-users-resource.js +15 -0
  249. package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
  250. package/dist/next/resources/slim/slim-zones-resource.js +24 -0
  251. package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
  252. package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
  253. package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
  254. package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
  255. package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
  256. package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
  257. package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
  258. package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
  259. package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
  260. package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
  261. package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
  262. package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
  263. package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
  264. package/dist/next/resources/wearables/wearables-resource.js +14 -0
  265. package/dist/next/storage/ovok-storage.d.ts +11 -0
  266. package/dist/next/storage/ovok-storage.js +19 -0
  267. package/dist/types/MeasurementTypes.d.ts +5 -0
  268. package/dist/types/MeasurementTypes.js +21 -0
  269. package/dist/types/index.d.ts +1 -5
  270. package/dist/types/index.js +1 -5
  271. package/next/index.d.ts +1 -0
  272. package/next/index.js +3 -0
  273. package/next/react/index.d.ts +1 -0
  274. package/next/react/index.js +1 -0
  275. package/package.json +14 -2
  276. package/dist/hooks/signals-alert-hooks.d.ts +0 -22
  277. package/dist/hooks/signals-alert-hooks.js +0 -166
  278. package/dist/hooks/signals-alert-item-hooks.d.ts +0 -19
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentsResource = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const url_1 = require("../../http/url");
6
+ const DOCUMENT_PATH = "document";
7
+ const PUBLIC_DOCUMENT_PATH = "document/public";
8
+ const documentPath = (documentId) => `${DOCUMENT_PATH}/${(0, url_1.pathSegment)(documentId)}`;
9
+ class DocumentsResource {
10
+ constructor(http, baseUrl) {
11
+ this.http = http;
12
+ this.baseUrl = baseUrl;
13
+ }
14
+ list(params = {}, options) {
15
+ return this.http.get(`${DOCUMENT_PATH}${(0, query_string_1.toQueryString)(params)}`, options);
16
+ }
17
+ createUpload(body, options) {
18
+ return this.http.post(DOCUMENT_PATH, body, options);
19
+ }
20
+ replaceUpload(documentId, body, options) {
21
+ return this.http.post(documentPath(documentId), body, options);
22
+ }
23
+ updateMetadata(documentId, body, options) {
24
+ return this.http.patch(documentPath(documentId), body, options);
25
+ }
26
+ delete(documentId, options) {
27
+ return this.http.delete(documentPath(documentId), options);
28
+ }
29
+ /** The signed-in route: fetched with the bearer, it redirects to a signed download URL. */
30
+ downloadUrl(documentId, params = {}) {
31
+ return this.urlFor(documentPath(documentId), params);
32
+ }
33
+ /** Needs no bearer, so it fits an image, download or media element. */
34
+ publicDownloadUrl(publicToken, params = {}) {
35
+ return this.urlFor(`${PUBLIC_DOCUMENT_PATH}/${(0, url_1.pathSegment)(publicToken)}`, params);
36
+ }
37
+ urlFor(path, params) {
38
+ return `${(0, url_1.joinPath)(this.baseUrl, path)}${(0, query_string_1.toQueryString)(params)}`;
39
+ }
40
+ }
41
+ exports.DocumentsResource = DocumentsResource;
@@ -0,0 +1,6 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ import { EmailTemplatesResource } from "./email-templates-resource";
3
+ export declare class EmailResource {
4
+ readonly templates: EmailTemplatesResource;
5
+ constructor(http: HttpClient);
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailResource = void 0;
4
+ const email_templates_resource_1 = require("./email-templates-resource");
5
+ class EmailResource {
6
+ constructor(http) {
7
+ this.templates = new email_templates_resource_1.EmailTemplatesResource(http);
8
+ }
9
+ }
10
+ exports.EmailResource = EmailResource;
@@ -0,0 +1,8 @@
1
+ import type { OvokEmailTemplates } from "../../../client/email/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class EmailTemplatesResource {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ list(options?: RequestOptions): Promise<OvokEmailTemplates>;
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailTemplatesResource = void 0;
4
+ const EMAIL_TEMPLATES_PATH = "v1/email/templates";
5
+ class EmailTemplatesResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ list(options) {
10
+ return this.http.get(EMAIL_TEMPLATES_PATH, options);
11
+ }
12
+ }
13
+ exports.EmailTemplatesResource = EmailTemplatesResource;
@@ -0,0 +1,28 @@
1
+ import type { Bundle, ExtractResource, Resource, ResourceType } from "@medplum/fhirtypes";
2
+ import { HttpClient } from "../http/http-client";
3
+ import { RequestOptions } from "../http/transmit";
4
+ import { QueryParams } from "../http/url";
5
+ import { PagePromise } from "../paging/page";
6
+ export type PatchOperation = {
7
+ op: "add" | "remove" | "replace" | "copy" | "move" | "test";
8
+ path: string;
9
+ value?: unknown;
10
+ from?: string;
11
+ };
12
+ export type CreateOptions = RequestOptions & {
13
+ ifNoneExist?: string;
14
+ };
15
+ export declare class FhirResource {
16
+ private readonly http;
17
+ constructor(http: HttpClient);
18
+ read<K extends ResourceType>(type: K, id: string, options?: RequestOptions): Promise<ExtractResource<K>>;
19
+ search<K extends ResourceType>(type: K, params?: QueryParams, options?: RequestOptions): PagePromise<ExtractResource<K>>;
20
+ searchOne<K extends ResourceType>(type: K, params?: QueryParams, options?: RequestOptions): Promise<ExtractResource<K> | null>;
21
+ /** With `ifNoneExist`, a retry cannot create a duplicate, so the request is safe to repeat. */
22
+ create<T extends Resource>(resource: T, options?: CreateOptions): Promise<T>;
23
+ update<T extends Resource>(resource: T, options?: RequestOptions): Promise<T>;
24
+ patch<K extends ResourceType>(type: K, id: string, operations: PatchOperation[], options?: RequestOptions): Promise<ExtractResource<K>>;
25
+ delete(type: ResourceType, id: string, options?: RequestOptions): Promise<void>;
26
+ batch(bundle: Bundle, options?: RequestOptions): Promise<Bundle>;
27
+ private searchPage;
28
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FhirResource = void 0;
4
+ const ovok_errors_1 = require("../errors/ovok-errors");
5
+ const url_1 = require("../http/url");
6
+ const bundle_page_1 = require("../paging/bundle-page");
7
+ const page_1 = require("../paging/page");
8
+ const FHIR_JSON = "application/fhir+json";
9
+ const READ_HEADERS = { Accept: FHIR_JSON };
10
+ const WRITE_HEADERS = { Accept: FHIR_JSON, "Content-Type": FHIR_JSON };
11
+ const PATCH_HEADERS = { Accept: FHIR_JSON, "Content-Type": "application/json-patch+json" };
12
+ class FhirResource {
13
+ constructor(http) {
14
+ this.http = http;
15
+ }
16
+ read(type, id, options) {
17
+ return this.http.send({ method: "GET", path: resourcePath(type, id), headers: READ_HEADERS }, options);
18
+ }
19
+ search(type, params = {}, options) {
20
+ return (0, page_1.pagePromise)(() => this.searchPage(type, (0, url_1.toSearchQuery)(params), options));
21
+ }
22
+ async searchOne(type, params = {}, options) {
23
+ var _a;
24
+ const page = await this.search(type, { ...params, _count: 1 }, options);
25
+ return (_a = page.data[0]) !== null && _a !== void 0 ? _a : null;
26
+ }
27
+ /** With `ifNoneExist`, a retry cannot create a duplicate, so the request is safe to repeat. */
28
+ create(resource, options = {}) {
29
+ const { ifNoneExist, ...requestOptions } = options;
30
+ const condition = ifNoneExist === undefined ? {} : { "If-None-Exist": ifNoneExist };
31
+ return this.http.send({
32
+ method: "POST",
33
+ path: resource.resourceType,
34
+ body: resource,
35
+ headers: { ...WRITE_HEADERS, ...condition },
36
+ idempotent: ifNoneExist !== undefined,
37
+ }, requestOptions);
38
+ }
39
+ update(resource, options) {
40
+ const path = resourcePath(resource.resourceType, requireId(resource));
41
+ return this.http.send({ method: "PUT", path, body: resource, headers: WRITE_HEADERS }, options);
42
+ }
43
+ patch(type, id, operations, options) {
44
+ return this.http.send({ method: "PATCH", path: resourcePath(type, id), body: operations, headers: PATCH_HEADERS }, options);
45
+ }
46
+ delete(type, id, options) {
47
+ return this.http.send({ method: "DELETE", path: resourcePath(type, id), headers: READ_HEADERS }, options);
48
+ }
49
+ batch(bundle, options) {
50
+ return this.http.send({ method: "POST", path: "", body: bundle, headers: WRITE_HEADERS }, options);
51
+ }
52
+ async searchPage(type, query, options) {
53
+ const bundle = await this.http.send({ method: "GET", path: `${type}${query}`, headers: READ_HEADERS }, options);
54
+ return (0, bundle_page_1.bundlePage)(bundle, (nextQuery) => this.searchPage(type, nextQuery, options));
55
+ }
56
+ }
57
+ exports.FhirResource = FhirResource;
58
+ const resourcePath = (type, id) => `${type}/${(0, url_1.pathSegment)(id)}`;
59
+ const requireId = (resource) => {
60
+ if (resource.id === undefined) {
61
+ throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)(`update needs ${resource.resourceType}.id.`));
62
+ }
63
+ return resource.id;
64
+ };
@@ -0,0 +1,17 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import { RequestOptions } from "../http/transmit";
3
+ export type HealthCheck = {
4
+ ok: boolean;
5
+ dependencies: Record<string, {
6
+ ok: boolean;
7
+ }>;
8
+ version?: string | null;
9
+ buildEnv?: string | null;
10
+ commitHash?: string | null;
11
+ };
12
+ export declare class HealthResource {
13
+ private readonly http;
14
+ constructor(http: HttpClient);
15
+ /** Always answers 200: read `ok`, not the status. */
16
+ check(options?: RequestOptions): Promise<HealthCheck>;
17
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HealthResource = void 0;
4
+ const HEALTHCHECK_PATH = "healthcheck";
5
+ class HealthResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ /** Always answers 200: read `ok`, not the status. */
10
+ check(options) {
11
+ return this.http.get(HEALTHCHECK_PATH, options);
12
+ }
13
+ }
14
+ exports.HealthResource = HealthResource;
@@ -0,0 +1,12 @@
1
+ import type { InviteSent } from "../../../client/invites/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ /** One invite kind: `create` sends it to `path`, `accept` redeems it at `path/accept`. */
5
+ export declare class InviteFlowResource<Invite, Acceptance, Accepted> {
6
+ private readonly http;
7
+ private readonly path;
8
+ private readonly acceptPath;
9
+ constructor(http: HttpClient, path: string);
10
+ create(body: Invite, options?: RequestOptions): Promise<InviteSent>;
11
+ accept(body: Acceptance, options?: RequestOptions): Promise<Accepted>;
12
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InviteFlowResource = void 0;
4
+ const ACCEPT_SEGMENT = "accept";
5
+ /** One invite kind: `create` sends it to `path`, `accept` redeems it at `path/accept`. */
6
+ class InviteFlowResource {
7
+ constructor(http, path) {
8
+ this.http = http;
9
+ this.path = path;
10
+ this.acceptPath = `${path}/${ACCEPT_SEGMENT}`;
11
+ }
12
+ create(body, options) {
13
+ return this.http.post(this.path, body, options);
14
+ }
15
+ accept(body, options) {
16
+ return this.http.post(this.acceptPath, body, options);
17
+ }
18
+ }
19
+ exports.InviteFlowResource = InviteFlowResource;
@@ -0,0 +1,22 @@
1
+ import type { AcceptInviteBody, AcceptRecordShareBody, InviteBody, RecordShareAccepted, RecordShareBody } from "../../../client/invites/types";
2
+ import type { PatientSharingPractitionerShare } from "../../../client/patient-sharing/types";
3
+ import type { UserSession } from "../../auth/user-session";
4
+ import { HttpClient } from "../../http/http-client";
5
+ import { RequestOptions } from "../../http/transmit";
6
+ import { InviteFlowResource } from "./invite-flow-resource";
7
+ export type RecordShareFlow = InviteFlowResource<RecordShareBody, AcceptRecordShareBody, RecordShareAccepted>;
8
+ export type PersonInviteFlow = InviteFlowResource<InviteBody, AcceptInviteBody, PatientSharingPractitionerShare>;
9
+ export declare class InvitesResource {
10
+ private readonly session;
11
+ /** A patient shares their record with a practitioner, or some codes with a carer. */
12
+ readonly recordShares: RecordShareFlow;
13
+ /** A practitioner invites a patient into their care. */
14
+ readonly care: PersonInviteFlow;
15
+ /** @deprecated Use `recordShares` with `recipient: "practitioner"`; the route sunsets on 2026-12-01. */
16
+ readonly practitioners: PersonInviteFlow;
17
+ /** @deprecated Use `care`; the route sunsets on 2026-12-01. */
18
+ readonly patients: PersonInviteFlow;
19
+ constructor(http: HttpClient, session?: UserSession | null);
20
+ /** Accepts a record share as a practitioner or a care invite as a patient. */
21
+ accept(body: AcceptInviteBody, options?: RequestOptions): Promise<PatientSharingPractitionerShare>;
22
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvitesResource = void 0;
4
+ const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ const invite_flow_resource_1 = require("./invite-flow-resource");
6
+ const INVITES_PATH = "v1/invites";
7
+ class InvitesResource {
8
+ constructor(http, session = null) {
9
+ this.session = session;
10
+ this.recordShares = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/record-share`);
11
+ this.care = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/care`);
12
+ this.practitioners = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/practitioner`);
13
+ this.patients = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/patient`);
14
+ }
15
+ /** Accepts a record share as a practitioner or a care invite as a patient. */
16
+ async accept(body, options) {
17
+ var _a, _b;
18
+ const profileReference = (_b = (await ((_a = this.session) === null || _a === void 0 ? void 0 : _a.current()))) === null || _b === void 0 ? void 0 : _b.profile.reference;
19
+ const profileType = profileReference === null || profileReference === void 0 ? void 0 : profileReference.split("/", 1)[0];
20
+ if (profileType === "Practitioner") {
21
+ return this.recordShares.accept(body, options);
22
+ }
23
+ if (profileType === "Patient") {
24
+ return this.care.accept(body, options);
25
+ }
26
+ throw new ovok_errors_1.OvokConfigError((0, ovok_errors_1.detailsFor)("Accepting an invite requires a signed-in Patient or Practitioner profile."));
27
+ }
28
+ }
29
+ exports.InvitesResource = InvitesResource;
@@ -0,0 +1,10 @@
1
+ import type { OvokI18nDocument, OvokI18nValue } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class I18nextResource {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ retrieve(language: string, options?: RequestOptions): Promise<OvokI18nDocument>;
8
+ /** The server queues the write (202), so a read right after may not show it yet. */
9
+ update(language: string, document: Record<string, OvokI18nValue>, options?: RequestOptions): Promise<void>;
10
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I18nextResource = void 0;
4
+ const url_1 = require("../../http/url");
5
+ const i18nextPath = (language) => `localization/i18next/${(0, url_1.pathSegment)(language)}`;
6
+ class I18nextResource {
7
+ constructor(http) {
8
+ this.http = http;
9
+ }
10
+ retrieve(language, options) {
11
+ return this.http.get(i18nextPath(language), options);
12
+ }
13
+ /** The server queues the write (202), so a read right after may not show it yet. */
14
+ update(language, document, options) {
15
+ return this.http.patch(i18nextPath(language), document, options);
16
+ }
17
+ }
18
+ exports.I18nextResource = I18nextResource;
@@ -0,0 +1,9 @@
1
+ import type { OvokLocales } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class LocalesResource {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ retrieve(options?: RequestOptions): Promise<OvokLocales>;
8
+ update(locales: OvokLocales, options?: RequestOptions): Promise<OvokLocales>;
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalesResource = void 0;
4
+ const LOCALES_PATH = "locales";
5
+ class LocalesResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ retrieve(options) {
10
+ return this.http.get(LOCALES_PATH, options);
11
+ }
12
+ update(locales, options) {
13
+ return this.http.patch(LOCALES_PATH, locales, options);
14
+ }
15
+ }
16
+ exports.LocalesResource = LocalesResource;
@@ -0,0 +1,17 @@
1
+ import type { OvokLocalization, OvokLocalizationQuery, OvokLocalizationUpdate } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ import { I18nextResource } from "./i18next-resource";
5
+ export type LocalizationList = {
6
+ total: number;
7
+ resources: OvokLocalization[];
8
+ };
9
+ export declare class LocalizationsResource {
10
+ private readonly http;
11
+ readonly i18next: I18nextResource;
12
+ constructor(http: HttpClient);
13
+ list(language: string, query?: OvokLocalizationQuery, options?: RequestOptions): Promise<LocalizationList>;
14
+ retrieve(language: string, key: string, options?: RequestOptions): Promise<OvokLocalization>;
15
+ update(language: string, key: string, body: OvokLocalizationUpdate, options?: RequestOptions): Promise<OvokLocalization>;
16
+ delete(language: string, key: string, options?: RequestOptions): Promise<void>;
17
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalizationsResource = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const url_1 = require("../../http/url");
6
+ const i18next_resource_1 = require("./i18next-resource");
7
+ const languagePath = (language) => `localization/${(0, url_1.pathSegment)(language)}`;
8
+ const entryPath = (language, key) => `${languagePath(language)}/${(0, url_1.pathSegment)(key)}`;
9
+ class LocalizationsResource {
10
+ constructor(http) {
11
+ this.http = http;
12
+ this.i18next = new i18next_resource_1.I18nextResource(http);
13
+ }
14
+ list(language, query = {}, options) {
15
+ return this.http.get(`${languagePath(language)}${(0, query_string_1.toQueryString)(query)}`, options);
16
+ }
17
+ retrieve(language, key, options) {
18
+ return this.http.get(entryPath(language, key), options);
19
+ }
20
+ update(language, key, body, options) {
21
+ return this.http.put(entryPath(language, key), body, options);
22
+ }
23
+ delete(language, key, options) {
24
+ return this.http.delete(entryPath(language, key), options);
25
+ }
26
+ }
27
+ exports.LocalizationsResource = LocalizationsResource;
@@ -0,0 +1,58 @@
1
+ import type { OfflineMeasurementQueueApi } from "./offline-measurement-queue";
2
+ import type { GetLatestObservationsByCodeParams } from "../../../client/observation/types/GetLatestObservationsByCodeParams";
3
+ import type { OvokStorage } from "../../storage/ovok-storage";
4
+ import type { Bundle, Observation } from "@medplum/fhirtypes";
5
+ import { observationCodesForTypes } from "../../../client/observation/methods/observationsToMeasurements";
6
+ import { HttpClient } from "../../http/http-client";
7
+ import { RequestOptions } from "../../http/transmit";
8
+ import { FhirResource } from "../fhir-resource";
9
+ import { BuildObservationsParams } from "./observation-builder";
10
+ import { SessionSource } from "./signed-in-account";
11
+ export type SaveObservationsOptions = RequestOptions & {
12
+ /** Identifier systems that name a reading for good; the SDK's device-reading id always counts. */
13
+ identifierSystems?: readonly string[];
14
+ /** Write over the observation saved under the same reading identifiers, for a value that changes. */
15
+ replace?: boolean;
16
+ };
17
+ export type SaveObservationsResult = {
18
+ status: "saved";
19
+ response: Bundle;
20
+ } | {
21
+ status: "queued";
22
+ queueId: string;
23
+ };
24
+ type MeasurementStorage = {
25
+ storage: OvokStorage;
26
+ queueKey: string;
27
+ machineClientId: string | null;
28
+ };
29
+ export type LatestObservationsParams = GetLatestObservationsByCodeParams;
30
+ export type LastObservationsQuery = {
31
+ code: string;
32
+ max?: number;
33
+ };
34
+ export type MeasurementCodeTypes = Parameters<typeof observationCodesForTypes>[0];
35
+ export declare class MeasurementsResource {
36
+ private readonly http;
37
+ private readonly fhir;
38
+ private readonly account;
39
+ private readonly offlineMeasurementQueue;
40
+ private readonly machineClientId;
41
+ private readonly session;
42
+ readonly offlineQueue: OfflineMeasurementQueueApi;
43
+ constructor(http: HttpClient, fhir: FhirResource, session: SessionSource | null, storageOptions: MeasurementStorage);
44
+ save(params: BuildObservationsParams, options?: SaveObservationsOptions): Promise<SaveObservationsResult>;
45
+ /** One reading, main observation first, created conditionally so a retry cannot duplicate it. */
46
+ saveObservations(observations: Observation[], options?: SaveObservationsOptions): Promise<SaveObservationsResult>;
47
+ build(params: BuildObservationsParams): Promise<Observation[]>;
48
+ latest(params: LatestObservationsParams, options?: RequestOptions): Promise<Bundle<Observation>>;
49
+ lastForPatient(patientId: string, query: LastObservationsQuery, options?: RequestOptions): Promise<Bundle<Observation>>;
50
+ /** The comma-joined codes the types are saved under, as `latest` and FHIR `code` searches take them. */
51
+ codesFor(types: MeasurementCodeTypes): string;
52
+ private latestPatientId;
53
+ /** A reading split over several requests stops once another account signs in, so none of it lands elsewhere. */
54
+ private send;
55
+ private currentOwnerKey;
56
+ private requireOwner;
57
+ }
58
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MeasurementsResource = void 0;
4
+ const observationsToMeasurements_1 = require("../../../client/observation/methods/observationsToMeasurements");
5
+ const observation_bundle_utils_1 = require("../../../client/observation/observation-bundle-utils");
6
+ const offline_measurement_queue_1 = require("../../../client/offline/offline-measurement-queue");
7
+ const query_string_1 = require("../../../client/query-string");
8
+ const ovok_errors_1 = require("../../errors/ovok-errors");
9
+ const url_1 = require("../../http/url");
10
+ const observation_builder_1 = require("./observation-builder");
11
+ const offline_measurement_queue_2 = require("./offline-measurement-queue");
12
+ const save_error_1 = require("./save-error");
13
+ const signed_in_account_1 = require("./signed-in-account");
14
+ const LATEST_OBSERVATIONS_PATH = "fhir/Observation/$lastn";
15
+ const LATEST_PER_CODE = 1;
16
+ class MeasurementsResource {
17
+ constructor(http, fhir, session, storageOptions) {
18
+ this.http = http;
19
+ this.fhir = fhir;
20
+ this.session = session;
21
+ this.machineClientId = storageOptions.machineClientId;
22
+ this.account = new signed_in_account_1.SignedInAccount(session);
23
+ this.offlineMeasurementQueue = new offline_measurement_queue_2.OfflineMeasurementQueue(storageOptions.storage, storageOptions.queueKey, () => this.currentOwnerKey(), (bundle, ownerKey, requestOptions) => this.send(bundle, requestOptions, ownerKey));
24
+ this.offlineQueue = {
25
+ flush: (options, requestOptions) => this.offlineMeasurementQueue.flush(options, requestOptions),
26
+ };
27
+ }
28
+ async save(params, options) {
29
+ return this.saveObservations(await this.build(params), options);
30
+ }
31
+ /** One reading, main observation first, created conditionally so a retry cannot duplicate it. */
32
+ async saveObservations(observations, options = {}) {
33
+ const { identifierSystems, replace, ...requestOptions } = options;
34
+ const entry = (0, observation_bundle_utils_1.linkObservationMembers)(observations).map((observation) => (0, offline_measurement_queue_1.entryForObservation)(observation, { identifierSystems, replace }));
35
+ const ownerKey = await this.currentOwnerKey();
36
+ if (entry.length === 0 || ownerKey === null) {
37
+ const response = await this.send({ resourceType: "Bundle", type: "transaction", entry }, requestOptions, ownerKey);
38
+ return { status: "saved", response };
39
+ }
40
+ const queued = await this.offlineMeasurementQueue.enqueueAndFlush(entry, ownerKey, requestOptions);
41
+ const response = queued.flush.responses[queued.id];
42
+ return response
43
+ ? { status: "saved", response }
44
+ : { status: "queued", queueId: queued.id };
45
+ }
46
+ async build(params) {
47
+ const subject = params.patientId ? `Patient/${params.patientId}` : await this.account.profileReference();
48
+ return (0, observation_builder_1.buildObservations)(params, subject);
49
+ }
50
+ async latest(params, options) {
51
+ const query = (0, query_string_1.toQueryString)({
52
+ max: LATEST_PER_CODE,
53
+ code: params.codes,
54
+ patient: `Patient/${await this.latestPatientId(params)}`,
55
+ date: params.date ? `ge${params.date}` : undefined,
56
+ });
57
+ return this.http.get(`${LATEST_OBSERVATIONS_PATH}${query}`, options);
58
+ }
59
+ lastForPatient(patientId, query, options) {
60
+ return this.http.get(`patient/${(0, url_1.pathSegment)(patientId)}/observation${(0, query_string_1.toQueryString)(query)}`, options);
61
+ }
62
+ /** The comma-joined codes the types are saved under, as `latest` and FHIR `code` searches take them. */
63
+ codesFor(types) {
64
+ return (0, observationsToMeasurements_1.observationCodesForTypes)(types);
65
+ }
66
+ async latestPatientId(params) {
67
+ if (params.me) {
68
+ return idOf(await this.account.profileReference());
69
+ }
70
+ return params.patientId;
71
+ }
72
+ /** A reading split over several requests stops once another account signs in, so none of it lands elsewhere. */
73
+ async send(bundle, options, owner) {
74
+ try {
75
+ return await (0, observation_bundle_utils_1.executeObservationBundle)(bundle, async (request) => {
76
+ await this.requireOwner(owner);
77
+ return this.fhir.batch(request, options);
78
+ });
79
+ }
80
+ catch (error) {
81
+ throw (0, save_error_1.isBundle)(error) ? (0, save_error_1.saveErrorFrom)(error) : error;
82
+ }
83
+ }
84
+ async currentOwnerKey() {
85
+ const accountKey = await this.account.key();
86
+ if (accountKey) {
87
+ return `user:${accountKey}`;
88
+ }
89
+ return this.session === null && this.machineClientId ? `machine:${this.machineClientId}` : null;
90
+ }
91
+ async requireOwner(owner) {
92
+ if (owner !== (await this.currentOwnerKey())) {
93
+ throw new ovok_errors_1.OvokConflictError((0, ovok_errors_1.detailsFor)("The signed-in account changed during the save; the rest was not sent."));
94
+ }
95
+ }
96
+ }
97
+ exports.MeasurementsResource = MeasurementsResource;
98
+ const idOf = (reference) => reference.slice(reference.indexOf("/") + 1);
@@ -0,0 +1,5 @@
1
+ import type { GenerateObservationBodyParams } from "../../../client/observation/types/generate-observation-body/GenerateObservationBodyParams";
2
+ import type { Observation } from "@medplum/fhirtypes";
3
+ export type BuildObservationsParams = GenerateObservationBodyParams;
4
+ /** One measurement's Observations about `subject`, a reference such as `Patient/1`. */
5
+ export declare function buildObservations(params: BuildObservationsParams, subject: string): Observation[];
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildObservations = buildObservations;
4
+ const fhir_systems_1 = require("../../../client/observation/fhir-systems");
5
+ const creator_1 = require("../../../client/observation/services/creator");
6
+ const getDeviceObject_1 = require("../../../client/observation/utils/getDeviceObject");
7
+ /** One measurement's Observations about `subject`, a reference such as `Patient/1`. */
8
+ function buildObservations(params, subject) {
9
+ const service = creator_1.ObservationServiceCreator.getInstance().getService(params.measurement.measurementTypeKey);
10
+ const device = (0, getDeviceObject_1.getDeviceObject)(params.device);
11
+ const observations = fragmentsOf(service, params.measurement)
12
+ .map((fragment) => observationOf(fragment, subject, device))
13
+ .filter(hasValue)
14
+ .map((observation) => datedAt(observation, params.effectiveDateTime));
15
+ return params.sourceId ? namedAfterSource(observations, subject, params.sourceId) : observations;
16
+ }
17
+ /** Services without fragments describe their observations as parallel code, value and property lists. */
18
+ const fragmentsOf = (service, measurement) => { var _a, _b; return (_b = (_a = service.generateObservationFragments) === null || _a === void 0 ? void 0 : _a.call(service, measurement)) !== null && _b !== void 0 ? _b : codeValueFragments(service, measurement); };
19
+ const codeValueFragments = (service, measurement) => {
20
+ const values = service.generateValues(measurement);
21
+ const additionalProperties = service.getAdditionalProperties(measurement);
22
+ return service.getObservationCodes().map((code, index) => ({
23
+ code,
24
+ value: values[index],
25
+ additionalProperties: additionalProperties[index],
26
+ }));
27
+ };
28
+ const observationOf = (fragment, subject, device) => ({
29
+ resourceType: "Observation",
30
+ status: "registered",
31
+ subject: { reference: subject },
32
+ device,
33
+ ...fragment.value,
34
+ code: fragment.code,
35
+ ...fragment.additionalProperties,
36
+ });
37
+ const hasValue = (observation) => {
38
+ var _a, _b, _c, _d, _e, _f;
39
+ return ((_a = observation.valueQuantity) === null || _a === void 0 ? void 0 : _a.value) !== undefined ||
40
+ Boolean((_b = observation.valueSampledData) === null || _b === void 0 ? void 0 : _b.data) ||
41
+ Boolean((_e = (_d = (_c = observation.valueCodeableConcept) === null || _c === void 0 ? void 0 : _c.coding) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.code) ||
42
+ Boolean((_f = observation.component) === null || _f === void 0 ? void 0 : _f.length);
43
+ };
44
+ /** A period the service set wins over the measurement's time. */
45
+ const datedAt = (observation, effectiveDateTime) => effectiveDateTime && !observation.effectivePeriod
46
+ ? { ...observation, effectiveDateTime: effectiveDateTime.toISOString() }
47
+ : observation;
48
+ const namedAfterSource = (observations, subject, sourceId) => observations.map((observation, index) => {
49
+ var _a;
50
+ return ({
51
+ ...observation,
52
+ identifier: [
53
+ ...((_a = observation.identifier) !== null && _a !== void 0 ? _a : []),
54
+ { system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM, value: `${subject}/${sourceId}/${index}` },
55
+ ],
56
+ });
57
+ });