@ovok/core 0.4.37 → 0.4.38

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 (99) hide show
  1. package/dist/client/auth/account-storage.d.ts +1 -0
  2. package/dist/client/auth/account-storage.js +2 -1
  3. package/dist/{utils → client}/auth/exchange-code.d.ts +1 -1
  4. package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.js +5 -17
  5. package/dist/{utils → client}/auth/handle-tenant-code.d.ts +1 -1
  6. package/dist/{utils → client}/auth/handle-tenant-code.js +1 -1
  7. package/dist/client/auth/methods/appleLogin.js +2 -6
  8. package/dist/client/auth/methods/changePassword.js +2 -1
  9. package/dist/client/auth/methods/getSessions.js +2 -1
  10. package/dist/client/auth/methods/googleLogin.js +2 -6
  11. package/dist/client/auth/methods/login.js +26 -44
  12. package/dist/client/auth/methods/logout.js +2 -1
  13. package/dist/client/auth/methods/requestDeleteUser.js +5 -4
  14. package/dist/client/auth/methods/revokeSessions.js +2 -1
  15. package/dist/client/auth/methods/socialLogin.d.ts +7 -0
  16. package/dist/client/auth/methods/socialLogin.js +11 -0
  17. package/dist/client/auth/session-fetch.js +5 -6
  18. package/dist/client/auth/session-http.js +8 -19
  19. package/dist/client/auth/sha256.d.ts +2 -0
  20. package/dist/client/auth/sha256.js +65 -0
  21. package/dist/{utils → client}/auth/start-login.d.ts +2 -2
  22. package/dist/client/change-history/methods.js +2 -1
  23. package/dist/client/cms/methods.js +16 -28
  24. package/dist/client/consent/methods.js +3 -2
  25. package/dist/client/email/methods.js +2 -1
  26. package/dist/client/errors/ovok-error-utils.d.ts +6 -0
  27. package/dist/client/errors/ovok-error-utils.js +10 -1
  28. package/dist/client/errors/ovok-error.js +6 -13
  29. package/dist/client/errors/rate-limit-error.js +2 -6
  30. package/dist/client/experience/methods.js +13 -12
  31. package/dist/client/invites/methods.js +8 -12
  32. package/dist/client/notifications/methods.js +4 -3
  33. package/dist/client/observation/fhir-systems.d.ts +4 -0
  34. package/dist/client/observation/fhir-systems.js +7 -0
  35. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +23 -29
  36. package/dist/client/observation/methods/getLatestObservationsByCodes.js +6 -9
  37. package/dist/client/observation/methods/observationsToMeasurements.js +44 -91
  38. package/dist/client/observation/services/base-observation-service.js +4 -3
  39. package/dist/client/observation/services/blood-pressure.js +1 -4
  40. package/dist/client/observation/services/{baby-sleep.d.ts → component-observation-services.d.ts} +18 -13
  41. package/dist/client/observation/services/component-observation-services.js +69 -0
  42. package/dist/client/observation/services/creator.d.ts +1 -2
  43. package/dist/client/observation/services/creator.js +14 -18
  44. package/dist/client/observation/services/ecg-observation-fragments.js +5 -6
  45. package/dist/client/observation/services/ecg.js +3 -2
  46. package/dist/client/observation/services/lipid-panel.js +8 -12
  47. package/dist/client/observation/services/measurement-time.d.ts +4 -0
  48. package/dist/client/observation/services/measurement-time.js +6 -0
  49. package/dist/client/observation/services/single-value-services.d.ts +5 -0
  50. package/dist/client/observation/services/single-value-services.js +6 -1
  51. package/dist/client/observation/services/uric-acid-service.js +6 -7
  52. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +2 -458
  53. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +0 -6
  54. package/dist/client/offline/offline-measurement-queue.js +31 -28
  55. package/dist/client/ovok-client.d.ts +5 -2
  56. package/dist/client/ovok-client.js +46 -42
  57. package/dist/client/patient/methods.js +25 -25
  58. package/dist/client/patient-sharing/methods.js +4 -3
  59. package/dist/client/platform/methods.js +17 -16
  60. package/dist/client/platform/types.d.ts +3 -6
  61. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -1
  62. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +2 -1
  63. package/dist/client/request-options.d.ts +2 -0
  64. package/dist/client/request-options.js +6 -0
  65. package/dist/client/signals/errors.js +2 -6
  66. package/dist/client/signals/methods.js +14 -13
  67. package/dist/client/slim/live-read.d.ts +4 -0
  68. package/dist/client/slim/live-read.js +87 -0
  69. package/dist/client/slim/methods.d.ts +3 -0
  70. package/dist/client/slim/methods.js +63 -146
  71. package/dist/client/storage.js +3 -2
  72. package/dist/conformance/capability-requirements.js +1 -1
  73. package/dist/conformance/capability.js +8 -7
  74. package/dist/hooks/account-hooks.js +1 -1
  75. package/dist/hooks/api-hooks.d.ts +5 -6
  76. package/dist/hooks/api-hooks.js +10 -24
  77. package/dist/hooks/cms-hooks.js +8 -13
  78. package/dist/hooks/experience-hooks.js +1 -1
  79. package/dist/hooks/index.d.ts +2 -2
  80. package/dist/hooks/index.js +4 -4
  81. package/dist/hooks/invites-hooks.js +0 -1
  82. package/dist/hooks/notification-hooks.d.ts +4 -1
  83. package/dist/hooks/notification-hooks.js +28 -35
  84. package/dist/hooks/notification-invalidation.d.ts +1 -1
  85. package/dist/hooks/notification-note-hooks.js +13 -28
  86. package/dist/hooks/observation-hooks.js +2 -4
  87. package/dist/hooks/patient-hooks.js +1 -1
  88. package/dist/hooks/patient-sharing-hooks.js +1 -2
  89. package/dist/hooks/poll-hooks.js +10 -8
  90. package/dist/hooks/signals-alert-hooks.js +4 -6
  91. package/package.json +1 -1
  92. package/dist/client/observation/services/baby-sleep.js +0 -69
  93. package/dist/client/observation/services/respiratory-therapy.d.ts +0 -28
  94. package/dist/client/observation/services/respiratory-therapy.js +0 -69
  95. package/dist/utils/auth/sha256.d.ts +0 -8
  96. package/dist/utils/auth/sha256.js +0 -300
  97. /package/dist/{utils → client}/auth/exchange-code.js +0 -0
  98. /package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.d.ts +0 -0
  99. /package/dist/{utils → client}/auth/start-login.js +0 -0
@@ -38,26 +38,23 @@ exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = expor
38
38
  const React = __importStar(require("react"));
39
39
  const cms_1 = require("../client/cms");
40
40
  const api_hooks_1 = require("./api-hooks");
41
- const index_1 = require("./index");
41
+ /** `locale` as a CMS locale, else the runtime's language; recomputed only when `locale` changes. */
42
+ const useCmsLocale = (locale) => React.useMemo(() => (0, cms_1.toCmsLocale)(locale || (0, cms_1.defaultCmsLocale)()), [locale]);
42
43
  /**
43
44
  * A published CMS document by slug, in `options.locale` or else the runtime's
44
45
  * language. Waits while `slug` is empty; a new CMS locale reads it again.
45
46
  */
46
47
  const useCmsDocument = (collection, slug, options = {}) => {
47
- const client = (0, index_1.useClient)();
48
48
  const { tenantCode, environment, allowSignedOut } = options;
49
- const locale = React.useMemo(() => (0, cms_1.toCmsLocale)(options.locale || (0, cms_1.defaultCmsLocale)()), [options.locale]);
50
- const load = React.useCallback((signal) => client.getCmsDocument(collection, slug, { locale, tenantCode, environment, allowSignedOut }, { signal }), [client, collection, slug, locale, tenantCode, environment, allowSignedOut]);
51
- return (0, api_hooks_1.useOvokRequest)(load, Boolean(slug));
49
+ const locale = useCmsLocale(options.locale);
50
+ return (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getCmsDocument(collection, slug, { locale, tenantCode, environment, allowSignedOut }, { signal }), [collection, slug, locale, tenantCode, environment, allowSignedOut], Boolean(slug));
52
51
  };
53
52
  exports.useCmsDocument = useCmsDocument;
54
53
  /** A page of a CMS collection, in `options.locale` or else the runtime's language. */
55
54
  const useCmsDocuments = (collection, options = {}) => {
56
- const client = (0, index_1.useClient)();
57
55
  const { tenantCode, environment, allowSignedOut, page, limit, sort } = options;
58
- const locale = React.useMemo(() => (0, cms_1.toCmsLocale)(options.locale || (0, cms_1.defaultCmsLocale)()), [options.locale]);
59
- const load = React.useCallback((signal) => client.listCmsDocuments(collection, { locale, tenantCode, environment, allowSignedOut, page, limit, sort }, { signal }), [client, collection, locale, tenantCode, environment, allowSignedOut, page, limit, sort]);
60
- return (0, api_hooks_1.useOvokRequest)(load);
56
+ const locale = useCmsLocale(options.locale);
57
+ return (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listCmsDocuments(collection, { locale, tenantCode, environment, allowSignedOut, page, limit, sort }, { signal }), [collection, locale, tenantCode, environment, allowSignedOut, page, limit, sort]);
61
58
  };
62
59
  exports.useCmsDocuments = useCmsDocuments;
63
60
  /** A legal page by slug; with `tenantCode`, readable before sign-in. */
@@ -71,10 +68,8 @@ exports.useReleaseNotes = useReleaseNotes;
71
68
  * runtime's language; with `tenantCode`, readable before sign-in.
72
69
  */
73
70
  const useTranslations = (options = {}) => {
74
- const client = (0, index_1.useClient)();
75
71
  const { tenantCode, environment, allowSignedOut } = options;
76
- const locale = React.useMemo(() => (0, cms_1.toCmsLocale)(options.locale || (0, cms_1.defaultCmsLocale)()), [options.locale]);
77
- const load = React.useCallback((signal) => client.getTranslations({ locale, tenantCode, environment, allowSignedOut }, { signal }), [client, locale, tenantCode, environment, allowSignedOut]);
78
- return (0, api_hooks_1.useOvokRequest)(load);
72
+ const locale = useCmsLocale(options.locale);
73
+ return (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getTranslations({ locale, tenantCode, environment, allowSignedOut }, { signal }), [locale, tenantCode, environment, allowSignedOut]);
79
74
  };
80
75
  exports.useTranslations = useTranslations;
@@ -11,7 +11,7 @@ const useContent = (type, language, params = {}) => (0, api_hooks_1.useOvokClien
11
11
  exports.useContent = useContent;
12
12
  const useVideoCallAppointments = (params = {}) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listVideoCallAppointments(params, { signal }), params);
13
13
  exports.useVideoCallAppointments = useVideoCallAppointments;
14
- const useVideoCallAccess = (appointmentId) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => appointmentId ? client.getVideoCallAccessPermission(appointmentId, { signal }) : Promise.reject(new Error("appointmentId is required")), appointmentId, appointmentId !== undefined);
14
+ const useVideoCallAccess = (appointmentId) => (0, api_hooks_1.useOvokClientRequestFor)("appointmentId", appointmentId, (client, id, signal) => client.getVideoCallAccessPermission(id, { signal }));
15
15
  exports.useVideoCallAccess = useVideoCallAccess;
16
16
  const useCreateVideoCallAppointment = () => (0, api_hooks_1.useOvokMutation)((client, params) => client.createVideoCallAppointment(params));
17
17
  exports.useCreateVideoCallAppointment = useCreateVideoCallAppointment;
@@ -6,7 +6,7 @@ export declare const OvokProvider: (props: React.PropsWithChildren<{
6
6
  client: OvokClient;
7
7
  }>) => React.JSX.Element;
8
8
  export { observationsToMeasurements, useEcgRecording, useObservations, useSaveMeasurement, useUrineTests, } from "./observation-hooks";
9
- export { useAdministeredProjects, useSlimDeviceTelemetry, useSlimDevices, useSlimNotifications, useSlimPatients, useCapabilityStatement, useOvokMutation, useOvokRequest, useProjectFeatures, useProjectSettings, usePublicApiEndpoints, useRecentSlimNotifications, } from "./api-hooks";
9
+ export { useAdministeredProjects, useSlimDeviceTelemetry, useSlimDevices, useSlimPatients, useCapabilityStatement, useOvokMutation, useOvokRequest, useProjectFeatures, useProjectSettings, usePublicApiEndpoints, } from "./api-hooks";
10
10
  export type { OvokMutationState, OvokRequestState } from "./api-hooks";
11
11
  export { useOvokPoll } from "./poll-hooks";
12
12
  export type { OvokPollOptions, OvokPollState } from "./poll-hooks";
@@ -14,7 +14,7 @@ export { useConsentSignature, useContent, useCreateVideoCallAppointment, useCrea
14
14
  export { useI18nextDocument, useLocales, useLocalizations, useUpdateI18nextDocument, useUpdateLocalization, useUpdateProjectTextSetting, } from "./platform-hooks";
15
15
  export { useEmailTemplates } from "./email-hooks";
16
16
  export { useChangeHistory, useLegalConsent, useMedicalConsent, useRepushUnconfirmedLimits, useSetLegalConsent, useSetMedicalConsent, useSlimPatientThresholdV2, useSlimThresholdV2, useUnconfirmedLimits, useUpdateSlimPatientThresholdV2, useUpdateSlimThresholdV2, } from "./account-hooks";
17
- export { useRecentAlarms, useRecentOutOfBed, useSlimAlarms, useSlimMedicalNotifications, useSlimOutOfBedNotifications, } from "./notification-hooks";
17
+ export { useRecentAlarms, useRecentOutOfBed, useRecentSlimNotifications, useSlimAlarms, useSlimMedicalNotifications, useSlimNotifications, useSlimOutOfBedNotifications, } from "./notification-hooks";
18
18
  export { useCreateNotificationNote, useCreateSignalsAlertNote, useCreateSignalsRawAlertNote, useDeleteNotificationNote, useDeleteSignalsNote, useNotificationNotes, useSignalsAlertNotes, useSignalsRawAlertNotes, useUpdateNotificationNote, useUpdateSignalsNote, } from "./notification-note-hooks";
19
19
  export { useAcknowledgeSlimAlarm, useAcknowledgeSlimMedicalNotification, } from "./notification-ack-hooks";
20
20
  export { useCmsDocument, useCmsDocuments, useLegalPage, useReleaseNotes, useTranslations, } from "./cms-hooks";
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.useSetLegalConsent = exports.useRepushUnconfirmedLimits = exports.useMedicalConsent = exports.useLegalConsent = exports.useChangeHistory = exports.useEmailTemplates = exports.useUpdateProjectTextSetting = exports.useUpdateLocalization = exports.useUpdateI18nextDocument = exports.useLocalizations = exports.useLocales = exports.useI18nextDocument = exports.useVideoCallAppointments = exports.useVideoCallAccess = exports.useDocuments = exports.useCreateVideoCallUserAccess = exports.useCreateVideoCallAppointment = exports.useContent = exports.useConsentSignature = exports.useOvokPoll = exports.useRecentSlimNotifications = exports.usePublicApiEndpoints = exports.useProjectSettings = exports.useProjectFeatures = exports.useOvokRequest = exports.useOvokMutation = exports.useCapabilityStatement = exports.useSlimPatients = exports.useSlimNotifications = exports.useSlimDevices = exports.useSlimDeviceTelemetry = exports.useAdministeredProjects = exports.useUrineTests = exports.useSaveMeasurement = exports.useObservations = exports.useEcgRecording = exports.observationsToMeasurements = exports.OvokProvider = exports.useClient = exports.useCachedBinaryUrl = exports.reactContext = exports.useSubscription = exports.useSearchResources = exports.useSearchOne = exports.useSearch = exports.useResource = exports.usePrevious = exports.useMedplumProfile = exports.useMedplumNavigate = exports.useMedplumContext = void 0;
38
- exports.usePatientSharingSettings = exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = exports.usePopulateQuestionnaire = exports.usePatientSlots = exports.usePatientSchedules = exports.usePatientQuestionnaires = exports.usePatientQuestionnaireResponses = exports.usePatientNotifications = exports.usePatientLatestObservations = exports.usePatientDashboard = exports.usePatientMeasurementHistory = exports.usePatientMeasurement = exports.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = exports.useInvitePatient = exports.useAcceptInvite = exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = exports.useAcknowledgeSlimMedicalNotification = exports.useAcknowledgeSlimAlarm = exports.useUpdateSignalsNote = exports.useUpdateNotificationNote = exports.useSignalsRawAlertNotes = exports.useSignalsAlertNotes = exports.useNotificationNotes = exports.useDeleteSignalsNote = exports.useDeleteNotificationNote = exports.useCreateSignalsRawAlertNote = exports.useCreateSignalsAlertNote = exports.useCreateNotificationNote = exports.useSlimOutOfBedNotifications = exports.useSlimMedicalNotifications = exports.useSlimAlarms = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useUpdateSlimThresholdV2 = exports.useUpdateSlimPatientThresholdV2 = exports.useUnconfirmedLimits = exports.useSlimThresholdV2 = exports.useSlimPatientThresholdV2 = exports.useSetMedicalConsent = void 0;
37
+ exports.useSlimPatientThresholdV2 = exports.useSetMedicalConsent = exports.useSetLegalConsent = exports.useRepushUnconfirmedLimits = exports.useMedicalConsent = exports.useLegalConsent = exports.useChangeHistory = exports.useEmailTemplates = exports.useUpdateProjectTextSetting = exports.useUpdateLocalization = exports.useUpdateI18nextDocument = exports.useLocalizations = exports.useLocales = exports.useI18nextDocument = exports.useVideoCallAppointments = exports.useVideoCallAccess = exports.useDocuments = exports.useCreateVideoCallUserAccess = exports.useCreateVideoCallAppointment = exports.useContent = exports.useConsentSignature = exports.useOvokPoll = exports.usePublicApiEndpoints = exports.useProjectSettings = exports.useProjectFeatures = exports.useOvokRequest = exports.useOvokMutation = exports.useCapabilityStatement = exports.useSlimPatients = exports.useSlimDevices = exports.useSlimDeviceTelemetry = exports.useAdministeredProjects = exports.useUrineTests = exports.useSaveMeasurement = exports.useObservations = exports.useEcgRecording = exports.observationsToMeasurements = exports.OvokProvider = exports.useClient = exports.useCachedBinaryUrl = exports.reactContext = exports.useSubscription = exports.useSearchResources = exports.useSearchOne = exports.useSearch = exports.useResource = exports.usePrevious = exports.useMedplumProfile = exports.useMedplumNavigate = exports.useMedplumContext = void 0;
38
+ exports.usePatientSharingSettings = exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = exports.usePopulateQuestionnaire = exports.usePatientSlots = exports.usePatientSchedules = exports.usePatientQuestionnaires = exports.usePatientQuestionnaireResponses = exports.usePatientNotifications = exports.usePatientLatestObservations = exports.usePatientDashboard = exports.usePatientMeasurementHistory = exports.usePatientMeasurement = exports.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = exports.useInvitePatient = exports.useAcceptInvite = exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = exports.useAcknowledgeSlimMedicalNotification = exports.useAcknowledgeSlimAlarm = exports.useUpdateSignalsNote = exports.useUpdateNotificationNote = exports.useSignalsRawAlertNotes = exports.useSignalsAlertNotes = exports.useNotificationNotes = exports.useDeleteSignalsNote = exports.useDeleteNotificationNote = exports.useCreateSignalsRawAlertNote = exports.useCreateSignalsAlertNote = exports.useCreateNotificationNote = exports.useSlimOutOfBedNotifications = exports.useSlimNotifications = exports.useSlimMedicalNotifications = exports.useSlimAlarms = exports.useRecentSlimNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useUpdateSlimThresholdV2 = exports.useUpdateSlimPatientThresholdV2 = exports.useUnconfirmedLimits = exports.useSlimThresholdV2 = void 0;
39
39
  exports.useUpdateSignalsSettings = exports.useSignalsThresholds = exports.useSignalsSettings = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useSetSignalsThreshold = exports.useRemoveSignalsThreshold = exports.useEnableSignalsForPatient = exports.useAcknowledgeSignalsAlert = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = exports.useRedeemPatientSharingInvite = void 0;
40
40
  /*
41
41
  * The only React-dependent module in the package.
@@ -82,7 +82,6 @@ var api_hooks_1 = require("./api-hooks");
82
82
  Object.defineProperty(exports, "useAdministeredProjects", { enumerable: true, get: function () { return api_hooks_1.useAdministeredProjects; } });
83
83
  Object.defineProperty(exports, "useSlimDeviceTelemetry", { enumerable: true, get: function () { return api_hooks_1.useSlimDeviceTelemetry; } });
84
84
  Object.defineProperty(exports, "useSlimDevices", { enumerable: true, get: function () { return api_hooks_1.useSlimDevices; } });
85
- Object.defineProperty(exports, "useSlimNotifications", { enumerable: true, get: function () { return api_hooks_1.useSlimNotifications; } });
86
85
  Object.defineProperty(exports, "useSlimPatients", { enumerable: true, get: function () { return api_hooks_1.useSlimPatients; } });
87
86
  Object.defineProperty(exports, "useCapabilityStatement", { enumerable: true, get: function () { return api_hooks_1.useCapabilityStatement; } });
88
87
  Object.defineProperty(exports, "useOvokMutation", { enumerable: true, get: function () { return api_hooks_1.useOvokMutation; } });
@@ -90,7 +89,6 @@ Object.defineProperty(exports, "useOvokRequest", { enumerable: true, get: functi
90
89
  Object.defineProperty(exports, "useProjectFeatures", { enumerable: true, get: function () { return api_hooks_1.useProjectFeatures; } });
91
90
  Object.defineProperty(exports, "useProjectSettings", { enumerable: true, get: function () { return api_hooks_1.useProjectSettings; } });
92
91
  Object.defineProperty(exports, "usePublicApiEndpoints", { enumerable: true, get: function () { return api_hooks_1.usePublicApiEndpoints; } });
93
- Object.defineProperty(exports, "useRecentSlimNotifications", { enumerable: true, get: function () { return api_hooks_1.useRecentSlimNotifications; } });
94
92
  var poll_hooks_1 = require("./poll-hooks");
95
93
  Object.defineProperty(exports, "useOvokPoll", { enumerable: true, get: function () { return poll_hooks_1.useOvokPoll; } });
96
94
  var experience_hooks_1 = require("./experience-hooks");
@@ -125,8 +123,10 @@ Object.defineProperty(exports, "useUpdateSlimThresholdV2", { enumerable: true, g
125
123
  var notification_hooks_1 = require("./notification-hooks");
126
124
  Object.defineProperty(exports, "useRecentAlarms", { enumerable: true, get: function () { return notification_hooks_1.useRecentAlarms; } });
127
125
  Object.defineProperty(exports, "useRecentOutOfBed", { enumerable: true, get: function () { return notification_hooks_1.useRecentOutOfBed; } });
126
+ Object.defineProperty(exports, "useRecentSlimNotifications", { enumerable: true, get: function () { return notification_hooks_1.useRecentSlimNotifications; } });
128
127
  Object.defineProperty(exports, "useSlimAlarms", { enumerable: true, get: function () { return notification_hooks_1.useSlimAlarms; } });
129
128
  Object.defineProperty(exports, "useSlimMedicalNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimMedicalNotifications; } });
129
+ Object.defineProperty(exports, "useSlimNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimNotifications; } });
130
130
  Object.defineProperty(exports, "useSlimOutOfBedNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimOutOfBedNotifications; } });
131
131
  var notification_note_hooks_1 = require("./notification-note-hooks");
132
132
  Object.defineProperty(exports, "useCreateNotificationNote", { enumerable: true, get: function () { return notification_note_hooks_1.useCreateNotificationNote; } });
@@ -10,7 +10,6 @@ const useInvitePatient = () => (0, api_hooks_1.useOvokMutation)((client, body) =
10
10
  exports.useInvitePatient = useInvitePatient;
11
11
  const useAcceptInvite = () => (0, api_hooks_1.useOvokMutation)(async (client, body) => {
12
12
  const result = await client.acceptInvite(body);
13
- client.invalidateUrl("/v1/patient-sharing/shares");
14
13
  (0, notification_invalidation_1.notifyNotificationChanges)(client, { type: "patient-sharing" });
15
14
  return result;
16
15
  });
@@ -1,6 +1,9 @@
1
1
  import { SlimAlarmQuery, SlimAlarmsPage, SlimMedicalNotificationsQuery, SlimMedicalNotificationsCollection, SlimRecentAlarms, SlimRecentOutOfBed } from "../client/notifications";
2
- import { SlimNotificationsQuery, SlimNotificationsResponse } from "../client/slim/types";
2
+ import { SlimNotificationsQuery, SlimNotificationsResponse, SlimRecentNotificationsResponse } from "../client/slim/types";
3
3
  import { OvokRequestState } from "./api-hooks";
4
+ /** @deprecated Use useSlimOutOfBedNotifications, useSlimAlarms, or useSlimMedicalNotifications. */
5
+ export declare const useSlimNotifications: (params?: SlimNotificationsQuery) => OvokRequestState<SlimNotificationsResponse>;
6
+ export declare const useRecentSlimNotifications: (count?: number) => OvokRequestState<SlimRecentNotificationsResponse>;
4
7
  export declare const useSlimAlarms: (params?: SlimAlarmQuery) => OvokRequestState<SlimAlarmsPage>;
5
8
  export declare const useRecentAlarms: (count?: number) => OvokRequestState<SlimRecentAlarms>;
6
9
  export declare const useRecentOutOfBed: (count?: number) => OvokRequestState<SlimRecentOutOfBed>;
@@ -34,12 +34,30 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.useSlimMedicalNotifications = exports.useSlimOutOfBedNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useSlimAlarms = void 0;
37
+ exports.useSlimMedicalNotifications = exports.useSlimOutOfBedNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useSlimAlarms = exports.useRecentSlimNotifications = exports.useSlimNotifications = void 0;
38
38
  const React = __importStar(require("react"));
39
39
  const paging_1 = require("../client/slim/paging");
40
40
  const api_hooks_1 = require("./api-hooks");
41
41
  const notification_invalidation_1 = require("./notification-invalidation");
42
42
  const index_1 = require("./index");
43
+ /**
44
+ * A Slim notification list kept current by notification changes. `inputs` holds every value
45
+ * the request depends on and is compared by value, as in `useOvokClientRequest`.
46
+ */
47
+ function useSlimNotificationFeed(request, inputs, field) {
48
+ const client = (0, index_1.useClient)();
49
+ const key = JSON.stringify(inputs);
50
+ // `inputs` is compared by value through `key`, so the request closure isn't a dependency.
51
+ const load = React.useCallback((signal) => request(client, signal), [client, key]);
52
+ const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
53
+ (0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, field);
54
+ return state;
55
+ }
56
+ /** @deprecated Use useSlimOutOfBedNotifications, useSlimAlarms, or useSlimMedicalNotifications. */
57
+ const useSlimNotifications = (params = {}) => useSlimNotificationFeed((client, signal) => client.listSlimNotifications(params, { signal }), params, "resources");
58
+ exports.useSlimNotifications = useSlimNotifications;
59
+ const useRecentSlimNotifications = (count) => useSlimNotificationFeed((client, signal) => client.getRecentSlimNotifications(count, { signal }), count, "recent");
60
+ exports.useRecentSlimNotifications = useRecentSlimNotifications;
43
61
  const useSlimAlarms = (params = {}) => {
44
62
  const client = (0, index_1.useClient)();
45
63
  const serialized = JSON.stringify(params);
@@ -47,44 +65,19 @@ const useSlimAlarms = (params = {}) => {
47
65
  const load = React.useCallback((signal) => client.listSlimAlarms(params, { signal }), [client, serialized, revision]);
48
66
  const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
49
67
  (0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, "resources");
50
- return { ...state, reload: () => setRevision((value) => value + 1) };
68
+ const reload = React.useCallback(() => setRevision((value) => value + 1), []);
69
+ return { ...state, reload };
51
70
  };
52
71
  exports.useSlimAlarms = useSlimAlarms;
53
- const useRecentAlarms = (count) => {
54
- const client = (0, index_1.useClient)();
55
- const load = React.useCallback((signal) => client.getRecentAlarms(count, { signal }), [client, count]);
56
- const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
57
- (0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, "recent");
58
- return state;
59
- };
72
+ const useRecentAlarms = (count) => useSlimNotificationFeed((client, signal) => client.getRecentAlarms(count, { signal }), count, "recent");
60
73
  exports.useRecentAlarms = useRecentAlarms;
61
- const useRecentOutOfBed = (count) => {
62
- const client = (0, index_1.useClient)();
63
- const load = React.useCallback((signal) => client.getRecentOutOfBed(count, { signal }), [client, count]);
64
- const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
65
- (0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, "recent");
66
- return state;
67
- };
74
+ const useRecentOutOfBed = (count) => useSlimNotificationFeed((client, signal) => client.getRecentOutOfBed(count, { signal }), count, "recent");
68
75
  exports.useRecentOutOfBed = useRecentOutOfBed;
69
- const useSlimOutOfBedNotifications = (params = {}) => {
70
- const client = (0, index_1.useClient)();
71
- const serialized = JSON.stringify(params);
72
- const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(React.useCallback((signal) => client.listSlimOutOfBedNotifications(params, { signal }), [client, serialized]));
73
- (0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, "resources");
74
- return state;
75
- };
76
+ const useSlimOutOfBedNotifications = (params = {}) => useSlimNotificationFeed((client, signal) => client.listSlimOutOfBedNotifications(params, { signal }), params, "resources");
76
77
  exports.useSlimOutOfBedNotifications = useSlimOutOfBedNotifications;
77
78
  /** Fetches every cursor page; a short page is not treated as the end of the feed. */
78
- const useSlimMedicalNotifications = (params = {}, options = {}) => {
79
- const client = (0, index_1.useClient)();
80
- const serialized = JSON.stringify(params);
81
- const serializedOptions = JSON.stringify(options);
82
- const load = React.useCallback(async (signal) => {
83
- const result = await (0, paging_1.iterateCursor)((cursor) => client.listSlimMedicalNotifications({ ...params, cursor }, { signal }), options);
84
- return { items: result.rows, nextCursor: null, total: result.total, truncated: result.truncated };
85
- }, [client, serialized, serializedOptions]);
86
- const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
87
- (0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, "items");
88
- return state;
89
- };
79
+ const useSlimMedicalNotifications = (params = {}, options = {}) => useSlimNotificationFeed(async (client, signal) => {
80
+ const result = await (0, paging_1.iterateCursor)((cursor) => client.listSlimMedicalNotifications({ ...params, cursor }, { signal }), options);
81
+ return { items: result.rows, nextCursor: null, total: result.total, truncated: result.truncated };
82
+ }, [params, options], "items");
90
83
  exports.useSlimMedicalNotifications = useSlimMedicalNotifications;
@@ -18,7 +18,7 @@ type NotificationChangeListener = (change?: NotificationChange) => void;
18
18
  export declare function subscribeToNotificationChanges(client: OvokClient, listener: NotificationChangeListener): () => void;
19
19
  export declare function notifyNotificationChanges(client: OvokClient, change?: NotificationChange): void;
20
20
  export declare function mergeSlimNotification<T extends object>(item: T, notification: SlimNotification | SlimMedicalNotificationRow): T;
21
- type SlimListField = "resources" | "recent" | "items";
21
+ export type SlimListField = "resources" | "recent" | "items";
22
22
  /**
23
23
  * Keeps a mounted Slim notification list current: a full invalidation reloads it, a single
24
24
  * Slim change is merged into the matching rows of `field`.
@@ -39,18 +39,23 @@ const React = __importStar(require("react"));
39
39
  const api_hooks_1 = require("./api-hooks");
40
40
  const notification_invalidation_1 = require("./notification-invalidation");
41
41
  const index_1 = require("./index");
42
- const useNotificationNotes = (kind, id) => {
42
+ /**
43
+ * A note list that reloads on a full notification invalidation. The revision is part of the
44
+ * loader on purpose: a new loader clears the mounted notes before the reload.
45
+ */
46
+ function useNoteList(id, idName, request, scope) {
43
47
  const client = (0, index_1.useClient)();
44
48
  const [revision, setRevision] = React.useState(0);
45
- const load = React.useCallback((signal) => (id ? client.listNotificationNotes(kind, id, { signal }) : Promise.reject(new Error("id is required"))), [client, kind, id, revision]);
46
- const state = (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
49
+ // `request` is rebuilt every render; `scope` and `id` are everything it depends on.
50
+ const load = React.useCallback((signal) => (id ? request(client, id, signal) : Promise.reject(new Error(`${idName} is required`))), [client, scope, id, revision]);
47
51
  React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
48
52
  if (!change) {
49
53
  setRevision((value) => value + 1);
50
54
  }
51
- }), [client, kind, id]);
52
- return state;
53
- };
55
+ }), [client, scope, id]);
56
+ return (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
57
+ }
58
+ const useNotificationNotes = (kind, id) => useNoteList(id, "id", (client, noteId, signal) => client.listNotificationNotes(kind, noteId, { signal }), kind);
54
59
  exports.useNotificationNotes = useNotificationNotes;
55
60
  function useNoteMutation(request) {
56
61
  return (0, api_hooks_1.useOvokMutation)(async (client, params) => {
@@ -65,29 +70,9 @@ const useUpdateNotificationNote = () => useNoteMutation((client, params) => clie
65
70
  exports.useUpdateNotificationNote = useUpdateNotificationNote;
66
71
  const useDeleteNotificationNote = () => useNoteMutation((client, noteId) => client.deleteNotificationNote(noteId));
67
72
  exports.useDeleteNotificationNote = useDeleteNotificationNote;
68
- const useSignalsAlertNotes = (episodeId) => {
69
- const client = (0, index_1.useClient)();
70
- const [revision, setRevision] = React.useState(0);
71
- const load = React.useCallback((signal) => (episodeId ? client.listSignalsAlertNotes(episodeId, { signal }) : Promise.reject(new Error("episodeId is required"))), [client, episodeId, revision]);
72
- React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
73
- if (!change) {
74
- setRevision((value) => value + 1);
75
- }
76
- }), [client, episodeId]);
77
- return (0, api_hooks_1.useOvokRequest)(load, episodeId !== undefined);
78
- };
73
+ const useSignalsAlertNotes = (episodeId) => useNoteList(episodeId, "episodeId", (client, id, signal) => client.listSignalsAlertNotes(id, { signal }));
79
74
  exports.useSignalsAlertNotes = useSignalsAlertNotes;
80
- const useSignalsRawAlertNotes = (alertId) => {
81
- const client = (0, index_1.useClient)();
82
- const [revision, setRevision] = React.useState(0);
83
- const load = React.useCallback((signal) => (alertId ? client.listSignalsRawAlertNotes(alertId, { signal }) : Promise.reject(new Error("alertId is required"))), [client, alertId, revision]);
84
- React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
85
- if (!change) {
86
- setRevision((value) => value + 1);
87
- }
88
- }), [client, alertId]);
89
- return (0, api_hooks_1.useOvokRequest)(load, alertId !== undefined);
90
- };
75
+ const useSignalsRawAlertNotes = (alertId) => useNoteList(alertId, "alertId", (client, id, signal) => client.listSignalsRawAlertNotes(id, { signal }));
91
76
  exports.useSignalsRawAlertNotes = useSignalsRawAlertNotes;
92
77
  const useCreateSignalsAlertNote = () => useNoteMutation((client, params) => client.createSignalsAlertNote(params.episodeId, { text: params.text }));
93
78
  exports.useCreateSignalsAlertNote = useCreateSignalsAlertNote;
@@ -76,8 +76,7 @@ const useSaveMeasurement = () => {
76
76
  };
77
77
  exports.useSaveMeasurement = useSaveMeasurement;
78
78
  const useEcgRecording = (id) => {
79
- const client = (0, index_1.useClient)();
80
- const load = React.useCallback(async (signal) => {
79
+ const { data: observations = [], ...state } = (0, api_hooks_1.useOvokClientRequest)(async (client, signal) => {
81
80
  const query = {
82
81
  code: (0, observationsToMeasurements_1.observationCodesForTypes)([types_1.MeasurementTypeKey.ecg]),
83
82
  _elements: "id,effectivePeriod,code,device,component,interpretation,valueSampledData,hasMember",
@@ -90,8 +89,7 @@ const useEcgRecording = (id) => {
90
89
  client.searchResources("Observation", { ...query, "has-member": `Observation/${id}` }, { signal }),
91
90
  ]);
92
91
  return [...root, ...members];
93
- }, [client, id]);
94
- const { data: observations = [], ...state } = (0, api_hooks_1.useOvokRequest)(load);
92
+ }, id);
95
93
  const recording = (0, observationsToMeasurements_1.observationsToMeasurements)(observations, [types_1.MeasurementTypeKey.ecg])[0];
96
94
  return { ...state, recording, measurements: observations };
97
95
  };
@@ -17,7 +17,7 @@ const usePatientSlots = (params = {}) => (0, api_hooks_1.useOvokClientRequest)((
17
17
  exports.usePatientSlots = usePatientSlots;
18
18
  const usePatientMeasurementHistory = (params = {}) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listPatientMeasurementHistory(params, { signal }), params);
19
19
  exports.usePatientMeasurementHistory = usePatientMeasurementHistory;
20
- const usePatientMeasurement = (measurementId) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => measurementId ? client.getPatientMeasurement(measurementId, { signal }) : Promise.reject(new Error("measurementId is required")), measurementId, measurementId !== undefined);
20
+ const usePatientMeasurement = (measurementId) => (0, api_hooks_1.useOvokClientRequestFor)("measurementId", measurementId, (client, id, signal) => client.getPatientMeasurement(id, { signal }));
21
21
  exports.usePatientMeasurement = usePatientMeasurement;
22
22
  const usePatientCarePlans = (params = {}) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listPatientCarePlans(params, { signal }), params);
23
23
  exports.usePatientCarePlans = usePatientCarePlans;
@@ -41,8 +41,7 @@ const notification_invalidation_1 = require("./notification-invalidation");
41
41
  const index_1 = require("./index");
42
42
  const usePatientSharing = () => {
43
43
  const client = (0, index_1.useClient)();
44
- const load = React.useCallback((signal) => client.listPatientSharing({ signal }), [client]);
45
- const state = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
44
+ const state = (0, api_hooks_1.useOvokClientRequest)((current, signal) => current.listPatientSharing({ signal }));
46
45
  React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
47
46
  if ((change === null || change === void 0 ? void 0 : change.type) === "patient-sharing") {
48
47
  state.reload();
@@ -37,6 +37,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.useOvokPoll = useOvokPoll;
38
38
  const React = __importStar(require("react"));
39
39
  const ovok_error_1 = require("../client/errors/ovok-error");
40
+ const ovok_error_utils_1 = require("../client/errors/ovok-error-utils");
41
+ /** Failed polls wait at most 2^4 = 16 intervals. */
42
+ const MAX_BACKOFF_EXPONENT = 4;
43
+ /** The wait after a failed poll: doubled per failure when backing off, and never shorter than Retry-After. */
44
+ const nextDelayMs = (intervalMs, failureCount, backoff, retryAfterMs) => {
45
+ const delay = backoff ? intervalMs * 2 ** Math.min(failureCount, MAX_BACKOFF_EXPONENT) : intervalMs;
46
+ return retryAfterMs === undefined ? delay : Math.max(delay, retryAfterMs);
47
+ };
40
48
  /** Polls after each completed request, pausing hidden tabs and aborting replaced work. */
41
49
  function useOvokPoll(load, options) {
42
50
  const { intervalMs, whenHidden = true, backoff = true, honorRetryAfter = true } = options;
@@ -81,14 +89,8 @@ function useOvokPoll(load, options) {
81
89
  .catch((reason) => {
82
90
  if (!stopped && !controller.signal.aborted) {
83
91
  failureCount += 1;
84
- setError(reason instanceof Error ? reason : new Error(String(reason)));
85
- const retryAfter = honorRetryAfter ? (0, ovok_error_1.readOvokError)(reason).retryAfterMs : undefined;
86
- nextDelay = backoff
87
- ? Math.min(intervalMs * (2 ** Math.min(failureCount, 4)), intervalMs * 16)
88
- : intervalMs;
89
- if (retryAfter !== undefined) {
90
- nextDelay = Math.max(nextDelay, retryAfter);
91
- }
92
+ setError((0, ovok_error_utils_1.toError)(reason));
93
+ nextDelay = nextDelayMs(intervalMs, failureCount, backoff, honorRetryAfter ? (0, ovok_error_1.readOvokError)(reason).retryAfterMs : undefined);
92
94
  }
93
95
  })
94
96
  .finally(() => {
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.useSignalsAlert = exports.useAcknowledgeSignalsAlert = void 0;
38
38
  exports.useSignalsAlerts = useSignalsAlerts;
39
39
  const React = __importStar(require("react"));
40
+ const ovok_error_utils_1 = require("../client/errors/ovok-error-utils");
40
41
  const notification_invalidation_1 = require("./notification-invalidation");
41
42
  const index_1 = require("./index");
42
43
  var signals_alert_item_hooks_1 = require("./signals-alert-item-hooks");
@@ -69,10 +70,7 @@ function useSignalsAlerts(query = {}) {
69
70
  if (!change) {
70
71
  setRevision((value) => value + 1);
71
72
  }
72
- else if (querySnapshot.episodes === false && change.type === "signals-raw-alert") {
73
- setItems((current) => current.map((item) => item.id === change.alert.id ? { ...item, ...change.alert } : item));
74
- }
75
- else if (querySnapshot.episodes !== false && change.type === "signals-alert") {
73
+ else if (change.type === (querySnapshot.episodes === false ? "signals-raw-alert" : "signals-alert")) {
76
74
  setItems((current) => current.map((item) => item.id === change.alert.id ? { ...item, ...change.alert } : item));
77
75
  }
78
76
  }), [client, querySnapshot.episodes]);
@@ -100,7 +98,7 @@ function useSignalsAlerts(query = {}) {
100
98
  })
101
99
  .catch((reason) => {
102
100
  if (generation.current === requestGeneration) {
103
- setError(reason instanceof Error ? reason : new Error(String(reason)));
101
+ setError((0, ovok_error_utils_1.toError)(reason));
104
102
  }
105
103
  })
106
104
  .finally(() => {
@@ -138,7 +136,7 @@ function useSignalsAlerts(query = {}) {
138
136
  }
139
137
  catch (reason) {
140
138
  if (generation.current === requestGeneration) {
141
- setError(reason instanceof Error ? reason : new Error(String(reason)));
139
+ setError((0, ovok_error_utils_1.toError)(reason));
142
140
  }
143
141
  }
144
142
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.37",
3
+ "version": "0.4.38",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BabySleepService = void 0;
4
- const types_1 = require("../../../types");
5
- const base_observation_service_1 = require("./base-observation-service");
6
- const BABY_SLEEP_SYSTEM = "https://sdk.ovok.com/fhir/CodeSystem/measurement-type";
7
- const recordedAt = (measurement) => measurement.recordedAt instanceof Date &&
8
- !Number.isNaN(measurement.recordedAt.getTime())
9
- ? measurement.recordedAt.toISOString()
10
- : new Date().toISOString();
11
- class BabySleepService extends base_observation_service_1.BaseObservationService {
12
- constructor() {
13
- super(...arguments);
14
- this.measurementTypeKey = types_1.MeasurementTypeKey.babySleep;
15
- this.measurementTypeName = "baby sleep";
16
- this.observationMetadata = [];
17
- }
18
- generateObservationFragments(measurement) {
19
- const babySleep = this.getCastedMeasurement(measurement);
20
- if (babySleep.components.length === 0) {
21
- return [];
22
- }
23
- return [{
24
- code: {
25
- coding: [{
26
- code: types_1.ObservationCode.BABY_SLEEP,
27
- display: "Baby sleep observation",
28
- system: BABY_SLEEP_SYSTEM,
29
- }],
30
- },
31
- additionalProperties: {
32
- effectiveDateTime: recordedAt(babySleep),
33
- component: babySleep.components,
34
- },
35
- }];
36
- }
37
- getObservationCodes() {
38
- return [{
39
- coding: [{
40
- code: types_1.ObservationCode.BABY_SLEEP,
41
- display: "Baby sleep observation",
42
- system: BABY_SLEEP_SYSTEM,
43
- }],
44
- }];
45
- }
46
- getAdditionalProperties(measurement) {
47
- return [{ effectiveDateTime: recordedAt(this.getCastedMeasurement(measurement)) }];
48
- }
49
- generateValues(_measurement) {
50
- return [];
51
- }
52
- getUnits() {
53
- return [];
54
- }
55
- getMeasurementDisplay(measurement) {
56
- return `${this.getCastedMeasurement(measurement).components.length} baby sleep metrics`;
57
- }
58
- getObservationDisplay(observations) {
59
- const count = observations.reduce((total, observation) => { var _a, _b; return total + ((_b = (_a = observation.component) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); }, 0);
60
- return count ? `${count} baby sleep metrics` : undefined;
61
- }
62
- convertSamplesToMeasurement(_samples) {
63
- throw new Error("Baby sleep samples are not supported.");
64
- }
65
- convertRecordToMeasurement(_record) {
66
- throw new Error("Baby sleep Health Connect records are not supported.");
67
- }
68
- }
69
- exports.BabySleepService = BabySleepService;
@@ -1,28 +0,0 @@
1
- import { Observation } from "@medplum/fhirtypes";
2
- import { Measurement, MeasurementTypeKey, ObservationCode, RespiratoryTherapyMeasurement } from "../../../types";
3
- import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
4
- import { Sample } from "../types/generate-measurement/Sample";
5
- import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
6
- import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
7
- import { ObservationMetadata } from "../types/service/ObservationMetadata";
8
- import { BaseObservationService } from "./base-observation-service";
9
- export declare class RespiratoryTherapyService extends BaseObservationService<RespiratoryTherapyMeasurement> {
10
- protected measurementTypeKey: MeasurementTypeKey;
11
- protected measurementTypeName: string;
12
- protected observationMetadata: ObservationMetadata<RespiratoryTherapyMeasurement>[];
13
- generateObservationFragments(measurement: Measurement): ObservationFragment[];
14
- getObservationCodes(): {
15
- coding: {
16
- code: ObservationCode;
17
- display: string;
18
- system: string;
19
- }[];
20
- }[];
21
- getAdditionalProperties(measurement: Measurement): Partial<Observation>[];
22
- generateValues(_measurement: Measurement): ObservationValue[];
23
- getUnits(): string[];
24
- getMeasurementDisplay(measurement: Measurement): string;
25
- getObservationDisplay(observations: Observation[]): string | undefined;
26
- convertSamplesToMeasurement(_samples: Sample[]): RespiratoryTherapyMeasurement;
27
- convertRecordToMeasurement(_record: RecordResult<RecordType>): RespiratoryTherapyMeasurement;
28
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RespiratoryTherapyService = void 0;
4
- const types_1 = require("../../../types");
5
- const base_observation_service_1 = require("./base-observation-service");
6
- const RESPIRATORY_THERAPY_SYSTEM = "https://sdk.ovok.com/fhir/CodeSystem/measurement-type";
7
- const recordedAt = (measurement) => measurement.recordedAt instanceof Date &&
8
- !Number.isNaN(measurement.recordedAt.getTime())
9
- ? measurement.recordedAt.toISOString()
10
- : new Date().toISOString();
11
- class RespiratoryTherapyService extends base_observation_service_1.BaseObservationService {
12
- constructor() {
13
- super(...arguments);
14
- this.measurementTypeKey = types_1.MeasurementTypeKey.respiratoryTherapy;
15
- this.measurementTypeName = "respiratory therapy";
16
- this.observationMetadata = [];
17
- }
18
- generateObservationFragments(measurement) {
19
- const respiratoryTherapy = this.getCastedMeasurement(measurement);
20
- if (respiratoryTherapy.components.length === 0) {
21
- return [];
22
- }
23
- return [{
24
- code: {
25
- coding: [{
26
- code: types_1.ObservationCode.RESPIRATORY_THERAPY,
27
- display: "Respiratory therapy observation",
28
- system: RESPIRATORY_THERAPY_SYSTEM,
29
- }],
30
- },
31
- additionalProperties: {
32
- effectiveDateTime: recordedAt(respiratoryTherapy),
33
- component: respiratoryTherapy.components,
34
- },
35
- }];
36
- }
37
- getObservationCodes() {
38
- return [{
39
- coding: [{
40
- code: types_1.ObservationCode.RESPIRATORY_THERAPY,
41
- display: "Respiratory therapy observation",
42
- system: RESPIRATORY_THERAPY_SYSTEM,
43
- }],
44
- }];
45
- }
46
- getAdditionalProperties(measurement) {
47
- return [{ effectiveDateTime: recordedAt(this.getCastedMeasurement(measurement)) }];
48
- }
49
- generateValues(_measurement) {
50
- return [];
51
- }
52
- getUnits() {
53
- return [];
54
- }
55
- getMeasurementDisplay(measurement) {
56
- return `${this.getCastedMeasurement(measurement).components.length} respiratory therapy metrics`;
57
- }
58
- getObservationDisplay(observations) {
59
- const count = observations.reduce((total, observation) => { var _a, _b; return total + ((_b = (_a = observation.component) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); }, 0);
60
- return count ? `${count} respiratory therapy metrics` : undefined;
61
- }
62
- convertSamplesToMeasurement(_samples) {
63
- throw new Error("Respiratory therapy samples are not supported.");
64
- }
65
- convertRecordToMeasurement(_record) {
66
- throw new Error("Respiratory therapy Health Connect records are not supported.");
67
- }
68
- }
69
- exports.RespiratoryTherapyService = RespiratoryTherapyService;
@@ -1,8 +0,0 @@
1
- export declare const sha256: {
2
- hex: (s: string) => string;
3
- b64: (k: string, d: string) => string;
4
- any: (k: string, d: string, e: string) => string;
5
- hex_hmac: (k: string, d: string) => string;
6
- b64_hmac: (k: string, d: string) => string;
7
- any_hmac: (k: string, d: string, e: string) => string;
8
- };