vintasend 0.4.0 → 0.4.7
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.
- package/README.md +5 -0
- package/dist/examples/vintasend-medplum-example/.env.example +11 -0
- package/dist/examples/vintasend-medplum-example/IMPLEMENTATION_PLAN_FILE_ATTACHMENTS.md +597 -0
- package/dist/examples/vintasend-medplum-example/README.md +190 -0
- package/dist/examples/vintasend-medplum-example/TUTORIAL_EMAIL_NOTIFICATIONS.md +2596 -0
- package/dist/examples/vintasend-medplum-example/bots/handlers/send-pending-notifications-bot.ts +39 -0
- package/dist/examples/vintasend-medplum-example/bots/handlers/send-task-assignment-email.ts +41 -0
- package/dist/examples/vintasend-medplum-example/bots/handlers/task-due-soon-notification-bot.ts +86 -0
- package/dist/examples/vintasend-medplum-example/bots/index.ts +53 -0
- package/dist/examples/vintasend-medplum-example/bots/services/emails/schedule-task-due-soon-email.ts +84 -0
- package/dist/examples/vintasend-medplum-example/bots/services/emails/send-task-assignment-email.test.ts +388 -0
- package/dist/examples/vintasend-medplum-example/bots/services/emails/send-task-assignment-email.ts +113 -0
- package/dist/examples/vintasend-medplum-example/bots/shared/task-due-soon-helpers.ts +115 -0
- package/dist/examples/vintasend-medplum-example/bots/task-assignment-bot.ts +41 -0
- package/dist/examples/vintasend-medplum-example/compiled-notification-templates.json +6 -0
- package/dist/examples/vintasend-medplum-example/esbuild-script.mjs +71 -0
- package/dist/examples/vintasend-medplum-example/index.html +14 -0
- package/dist/examples/vintasend-medplum-example/lib/constants.ts +32 -0
- package/dist/examples/vintasend-medplum-example/lib/extensions.ts +1 -0
- package/dist/examples/vintasend-medplum-example/lib/file-upload.test.ts +389 -0
- package/dist/examples/vintasend-medplum-example/lib/file-upload.ts +222 -0
- package/dist/examples/vintasend-medplum-example/lib/medplum-singleton.ts +18 -0
- package/dist/examples/vintasend-medplum-example/lib/notification-service.test.ts +293 -0
- package/dist/examples/vintasend-medplum-example/lib/notification-service.ts +284 -0
- package/dist/examples/vintasend-medplum-example/lib/patients.ts +20 -0
- package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-assignment/body.html.pug +37 -0
- package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-assignment/subject.txt.pug +4 -0
- package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-due-soon/body.html.pug +34 -0
- package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-due-soon/subject.txt.pug +4 -0
- package/dist/examples/vintasend-medplum-example/package.json +75 -0
- package/dist/examples/vintasend-medplum-example/plugins/gql-plugin.mjs +31 -0
- package/dist/examples/vintasend-medplum-example/postcss.config.mjs +21 -0
- package/dist/examples/vintasend-medplum-example/public/favicon.ico +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/acuity.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/auth0.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/azure.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/calcom.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/candid.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/claude.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/datadog.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/deepseek.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/entra.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/epic.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/google.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/healthgorilla.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/healthie.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/labcorp.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/okta.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/openai.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/particle.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/quest.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/recaptcha.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/snowflake.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/stedi.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/stripe.png +0 -0
- package/dist/examples/vintasend-medplum-example/public/img/integrations/sumo.png +0 -0
- package/dist/examples/vintasend-medplum-example/scripts/README.md +162 -0
- package/dist/examples/vintasend-medplum-example/scripts/client.ts +18 -0
- package/dist/examples/vintasend-medplum-example/scripts/deploy-bots.ts +171 -0
- package/dist/examples/vintasend-medplum-example/src/App.tsx +185 -0
- package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemList.test.tsx +350 -0
- package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemList.tsx +241 -0
- package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemPanel.test.tsx +616 -0
- package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemPanel.tsx +138 -0
- package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionItem.test.tsx +92 -0
- package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionItem.tsx +47 -0
- package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionList.test.tsx +464 -0
- package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionList.tsx +186 -0
- package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionModal.test.tsx +80 -0
- package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionModal.tsx +82 -0
- package/dist/examples/vintasend-medplum-example/src/components/DoseSpotIcon.test.tsx +100 -0
- package/dist/examples/vintasend-medplum-example/src/components/DoseSpotIcon.tsx +20 -0
- package/dist/examples/vintasend-medplum-example/src/components/IntegrationCard.module.css +3 -0
- package/dist/examples/vintasend-medplum-example/src/components/IntegrationCard.tsx +62 -0
- package/dist/examples/vintasend-medplum-example/src/components/MessageWithLinks.tsx +47 -0
- package/dist/examples/vintasend-medplum-example/src/components/PerformingLabInput.test.tsx +299 -0
- package/dist/examples/vintasend-medplum-example/src/components/PerformingLabInput.tsx +52 -0
- package/dist/examples/vintasend-medplum-example/src/components/ResourceFormWithRequiredProfile.tsx +82 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/BillingTab.test.tsx +1016 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/BillingTab.tsx +298 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterChart.test.tsx +732 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterChart.tsx +282 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterHeader.test.tsx +268 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterHeader.tsx +224 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/SignAddendum.test.tsx +255 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/SignAddendum.tsx +212 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/SignLockDialog.test.tsx +120 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/SignLockDialog.tsx +57 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/VisitDetailsPanel.test.tsx +224 -0
- package/dist/examples/vintasend-medplum-example/src/components/encounter/VisitDetailsPanel.tsx +100 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/CoverageInput.test.tsx +431 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/CoverageInput.tsx +130 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabListItem.module.css +31 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabListItem.test.tsx +234 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabListItem.tsx +143 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabOrderDetails.module.css +11 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabOrderDetails.test.tsx +875 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabOrderDetails.tsx +943 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabResultDetails.test.tsx +413 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabResultDetails.tsx +203 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/LabSelectEmpty.tsx +22 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/README.md +104 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/TestMetadataCardInput.test.tsx +318 -0
- package/dist/examples/vintasend-medplum-example/src/components/labs/TestMetadataCardInput.tsx +87 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ChatList.test.tsx +126 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ChatList.tsx +38 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ChatListItem.module.css +23 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ChatListItem.test.tsx +167 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ChatListItem.tsx +53 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/NewTopicDialog.test.tsx +94 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/NewTopicDialog.tsx +165 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ParticipantFilter.module.css +8 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ParticipantFilter.test.tsx +523 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ParticipantFilter.tsx +230 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ThreadInbox.module.css +23 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ThreadInbox.test.tsx +567 -0
- package/dist/examples/vintasend-medplum-example/src/components/messages/ThreadInbox.tsx +358 -0
- package/dist/examples/vintasend-medplum-example/src/components/plandefinition/AddPlanDefinition.module.css +40 -0
- package/dist/examples/vintasend-medplum-example/src/components/plandefinition/AddPlanDefinition.tsx +257 -0
- package/dist/examples/vintasend-medplum-example/src/components/schedule/CreateVisit.module.css +7 -0
- package/dist/examples/vintasend-medplum-example/src/components/schedule/CreateVisit.test.tsx +279 -0
- package/dist/examples/vintasend-medplum-example/src/components/schedule/CreateVisit.tsx +156 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/HistoryList.module.css +45 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/HistoryList.test.tsx +90 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/HistoryList.tsx +84 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourceBox.module.css +26 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourceBox.tsx +90 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourcePanel.test.tsx +305 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourcePanel.tsx +46 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/SpacesInbox.module.css +262 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/SpacesInbox.test.tsx +622 -0
- package/dist/examples/vintasend-medplum-example/src/components/spaces/SpacesInbox.tsx +286 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/NewTaskModal.tsx +275 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskAttachmentList.tsx +132 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskBoard.module.css +45 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskBoard.test.tsx +749 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskBoard.tsx +416 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailPanel.test.tsx +278 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailPanel.tsx +133 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailsModal.module.css +16 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailsModal.test.tsx +255 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailsModal.tsx +203 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFileUpload.tsx +129 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFilterMenu.test.tsx +156 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFilterMenu.tsx +142 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFilterMenu.utils.ts +28 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskInputNote.test.tsx +134 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskInputNote.tsx +250 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskListItem.module.css +23 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskListItem.test.tsx +149 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskListItem.tsx +53 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskNoteItem.test.tsx +68 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskNoteItem.tsx +46 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskProperties.test.tsx +555 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskProperties.tsx +170 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskSelectEmpty.test.tsx +32 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskSelectEmpty.tsx +34 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/SimpleTask.test.tsx +47 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/SimpleTask.tsx +29 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskPanel.test.tsx +285 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskPanel.tsx +129 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskQuestionnaireForm.test.tsx +455 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskQuestionnaireForm.tsx +167 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskServiceRequest.test.tsx +435 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskServiceRequest.tsx +116 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskStatusPanel.module.css +38 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskStatusPanel.test.tsx +200 -0
- package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskStatusPanel.tsx +84 -0
- package/dist/examples/vintasend-medplum-example/src/components/utils.test.ts +176 -0
- package/dist/examples/vintasend-medplum-example/src/components/utils.ts +17 -0
- package/dist/examples/vintasend-medplum-example/src/config/constants.ts +3 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useDebouncedUpdateResource.test.tsx +166 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useDebouncedUpdateResource.ts +28 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useEncounter.test.tsx +94 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useEncounter.ts +11 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useEncounterChart.test.tsx +477 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useEncounterChart.ts +191 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/usePatient.test.tsx +100 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/usePatient.ts +18 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useThreadInbox.test.tsx +379 -0
- package/dist/examples/vintasend-medplum-example/src/hooks/useThreadInbox.ts +194 -0
- package/dist/examples/vintasend-medplum-example/src/index.css +8 -0
- package/dist/examples/vintasend-medplum-example/src/main.tsx +57 -0
- package/dist/examples/vintasend-medplum-example/src/pages/SearchPage.module.css +6 -0
- package/dist/examples/vintasend-medplum-example/src/pages/SearchPage.test.tsx +295 -0
- package/dist/examples/vintasend-medplum-example/src/pages/SearchPage.tsx +124 -0
- package/dist/examples/vintasend-medplum-example/src/pages/SignInPage.test.tsx +77 -0
- package/dist/examples/vintasend-medplum-example/src/pages/SignInPage.tsx +22 -0
- package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterChartPage.test.tsx +87 -0
- package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterChartPage.tsx +27 -0
- package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterModal.module.css +16 -0
- package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterModal.test.tsx +287 -0
- package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterModal.tsx +151 -0
- package/dist/examples/vintasend-medplum-example/src/pages/integrations/DoseSpotFavoritesPage.test.tsx +519 -0
- package/dist/examples/vintasend-medplum-example/src/pages/integrations/DoseSpotFavoritesPage.tsx +179 -0
- package/dist/examples/vintasend-medplum-example/src/pages/integrations/FavoriteMedicationsTable.tsx +76 -0
- package/dist/examples/vintasend-medplum-example/src/pages/integrations/IntegrationsPage.test.tsx +234 -0
- package/dist/examples/vintasend-medplum-example/src/pages/integrations/IntegrationsPage.tsx +222 -0
- package/dist/examples/vintasend-medplum-example/src/pages/labs/OrderLabsPage.test.tsx +356 -0
- package/dist/examples/vintasend-medplum-example/src/pages/labs/OrderLabsPage.tsx +275 -0
- package/dist/examples/vintasend-medplum-example/src/pages/messages/MessagesPage.module.css +8 -0
- package/dist/examples/vintasend-medplum-example/src/pages/messages/MessagesPage.test.tsx +103 -0
- package/dist/examples/vintasend-medplum-example/src/pages/messages/MessagesPage.tsx +78 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/CommunicationTab.test.tsx +84 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/CommunicationTab.tsx +82 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotAdvancedOptions.test.tsx +364 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotAdvancedOptions.tsx +149 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotTab.test.tsx +159 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotTab.tsx +37 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/EditTab.test.tsx +140 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/EditTab.tsx +72 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/ExportTab.test.tsx +57 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/ExportTab.tsx +14 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/IntakeFormPage.test.tsx +241 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/IntakeFormPage.tsx +710 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/LabsPage.module.css +37 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/LabsPage.test.tsx +428 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/LabsPage.tsx +334 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.module.css +24 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.test.tsx +154 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.tsx +115 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.utils.test.ts +223 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.utils.ts +89 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientSearchPage.test.tsx +147 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientSearchPage.tsx +79 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientTabsNavigation.tsx +35 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/TasksTab.test.tsx +185 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/TasksTab.tsx +115 -0
- package/dist/examples/vintasend-medplum-example/src/pages/patient/TimelineTab.tsx +14 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceCreatePage.test.tsx +170 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceCreatePage.tsx +117 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceDetailPage.tsx +28 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceEditPage.test.tsx +131 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceEditPage.tsx +65 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceHistoryPage.test.tsx +108 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceHistoryPage.tsx +16 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourcePage.module.css +7 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourcePage.test.tsx +37 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourcePage.tsx +44 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/useResourceType.ts +44 -0
- package/dist/examples/vintasend-medplum-example/src/pages/resource/utils.ts +9 -0
- package/dist/examples/vintasend-medplum-example/src/pages/schedule/SchedulePage.test.tsx +302 -0
- package/dist/examples/vintasend-medplum-example/src/pages/schedule/SchedulePage.tsx +416 -0
- package/dist/examples/vintasend-medplum-example/src/pages/spaces/ChatInput.tsx +91 -0
- package/dist/examples/vintasend-medplum-example/src/pages/spaces/SpacesPage.module.css +6 -0
- package/dist/examples/vintasend-medplum-example/src/pages/spaces/SpacesPage.test.tsx +102 -0
- package/dist/examples/vintasend-medplum-example/src/pages/spaces/SpacesPage.tsx +44 -0
- package/dist/examples/vintasend-medplum-example/src/pages/tasks/TasksPage.module.css +7 -0
- package/dist/examples/vintasend-medplum-example/src/pages/tasks/TasksPage.test.tsx +133 -0
- package/dist/examples/vintasend-medplum-example/src/pages/tasks/TasksPage.tsx +91 -0
- package/dist/examples/vintasend-medplum-example/src/test-utils/render.tsx +20 -0
- package/dist/examples/vintasend-medplum-example/src/test.setup.ts +49 -0
- package/dist/examples/vintasend-medplum-example/src/types/encounter.ts +8 -0
- package/dist/examples/vintasend-medplum-example/src/types/spaces.ts +10 -0
- package/dist/examples/vintasend-medplum-example/src/utils/chargeitems.test.ts +141 -0
- package/dist/examples/vintasend-medplum-example/src/utils/chargeitems.ts +59 -0
- package/dist/examples/vintasend-medplum-example/src/utils/claims.test.ts +153 -0
- package/dist/examples/vintasend-medplum-example/src/utils/claims.ts +65 -0
- package/dist/examples/vintasend-medplum-example/src/utils/communication-search.ts +47 -0
- package/dist/examples/vintasend-medplum-example/src/utils/coverage.test.ts +48 -0
- package/dist/examples/vintasend-medplum-example/src/utils/coverage.ts +33 -0
- package/dist/examples/vintasend-medplum-example/src/utils/documentReference.test.ts +102 -0
- package/dist/examples/vintasend-medplum-example/src/utils/documentReference.ts +55 -0
- package/dist/examples/vintasend-medplum-example/src/utils/encounter.test.ts +169 -0
- package/dist/examples/vintasend-medplum-example/src/utils/encounter.ts +261 -0
- package/dist/examples/vintasend-medplum-example/src/utils/intake-form.test.ts +154 -0
- package/dist/examples/vintasend-medplum-example/src/utils/intake-form.ts +272 -0
- package/dist/examples/vintasend-medplum-example/src/utils/intake-utils.test.ts +1137 -0
- package/dist/examples/vintasend-medplum-example/src/utils/intake-utils.ts +827 -0
- package/dist/examples/vintasend-medplum-example/src/utils/notifications.test.ts +27 -0
- package/dist/examples/vintasend-medplum-example/src/utils/notifications.ts +15 -0
- package/dist/examples/vintasend-medplum-example/src/utils/spaceMessaging.ts +249 -0
- package/dist/examples/vintasend-medplum-example/src/utils/spacePersistence.test.ts +450 -0
- package/dist/examples/vintasend-medplum-example/src/utils/spacePersistence.ts +147 -0
- package/dist/examples/vintasend-medplum-example/src/utils/task-search.ts +63 -0
- package/dist/examples/vintasend-medplum-example/src/vite-env.d.ts +3 -0
- package/dist/examples/vintasend-medplum-example/tsconfig.bots.json +4 -0
- package/dist/examples/vintasend-medplum-example/tsconfig.json +19 -0
- package/dist/examples/vintasend-medplum-example/vercel.json +3 -0
- package/dist/examples/vintasend-medplum-example/vite.config.ts +44 -0
- package/dist/services/notification-backends/base-notification-backend.d.ts +5 -0
- package/dist/services/notification-service.js +11 -1
- package/dist/services/notification-template-renderers/base-email-template-renderer.d.ts +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import {
|
|
4
|
+
Flex,
|
|
5
|
+
Paper,
|
|
6
|
+
Group,
|
|
7
|
+
Button,
|
|
8
|
+
Divider,
|
|
9
|
+
ActionIcon,
|
|
10
|
+
ScrollArea,
|
|
11
|
+
Stack,
|
|
12
|
+
Skeleton,
|
|
13
|
+
Text,
|
|
14
|
+
Box,
|
|
15
|
+
Modal,
|
|
16
|
+
} from '@mantine/core';
|
|
17
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
18
|
+
import type { JSX } from 'react';
|
|
19
|
+
import type { ServiceRequest } from '@medplum/fhirtypes';
|
|
20
|
+
import { getReferenceString } from '@medplum/core';
|
|
21
|
+
import { useNavigate, useParams } from 'react-router';
|
|
22
|
+
import { useMedplum } from '@medplum/react';
|
|
23
|
+
import { showErrorNotification } from '../../utils/notifications';
|
|
24
|
+
import { IconPlus } from '@tabler/icons-react';
|
|
25
|
+
import { LabListItem } from '../../components/labs/LabListItem';
|
|
26
|
+
import { LabSelectEmpty } from '../../components/labs/LabSelectEmpty';
|
|
27
|
+
import { LabOrderDetails } from '../../components/labs/LabOrderDetails';
|
|
28
|
+
import { OrderLabsPage } from '../labs/OrderLabsPage';
|
|
29
|
+
import { usePatient } from '../../hooks/usePatient';
|
|
30
|
+
import cx from 'clsx';
|
|
31
|
+
import classes from './LabsPage.module.css';
|
|
32
|
+
|
|
33
|
+
type LabTab = 'open' | 'completed';
|
|
34
|
+
|
|
35
|
+
export function LabsPage(): JSX.Element {
|
|
36
|
+
const { patientId, serviceRequestId } = useParams();
|
|
37
|
+
const navigate = useNavigate();
|
|
38
|
+
const medplum = useMedplum();
|
|
39
|
+
|
|
40
|
+
const [activeTab, setActiveTab] = useState<LabTab>('completed');
|
|
41
|
+
const [openOrders, setOpenOrders] = useState<ServiceRequest[]>([]);
|
|
42
|
+
const [completedOrders, setCompletedOrders] = useState<ServiceRequest[]>([]);
|
|
43
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
44
|
+
const [newOrderModalOpened, setNewOrderModalOpened] = useState<boolean>(false);
|
|
45
|
+
|
|
46
|
+
const patient = usePatient();
|
|
47
|
+
const patientReference = useMemo(() => (patient ? getReferenceString(patient) : undefined), [patient]);
|
|
48
|
+
const [currentOrder, setCurrentOrder] = useState<ServiceRequest>();
|
|
49
|
+
|
|
50
|
+
const fetchOrders = useCallback(async (): Promise<void> => {
|
|
51
|
+
if (!patientReference) {
|
|
52
|
+
showErrorNotification('Patient not found');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const searchParams = new URLSearchParams({
|
|
57
|
+
subject: patientReference,
|
|
58
|
+
_count: '100',
|
|
59
|
+
_sort: '-_lastUpdated',
|
|
60
|
+
_fields:
|
|
61
|
+
'_lastUpdated,code,status,orderDetail,category,subject,requester,performer,requisition,identifier,authoredOn,priority,reasonCode,note,supportingInfo,basedOn',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const results: ServiceRequest[] = await medplum.searchResources('ServiceRequest', searchParams, {
|
|
65
|
+
cache: 'no-cache',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
setOpenOrders(filterOpenOrders(results));
|
|
69
|
+
setCompletedOrders(filterCompletedOrders(results));
|
|
70
|
+
} catch (error) {
|
|
71
|
+
showErrorNotification(error);
|
|
72
|
+
}
|
|
73
|
+
}, [medplum, patientReference]);
|
|
74
|
+
|
|
75
|
+
const fetchData = useCallback(async (): Promise<void> => {
|
|
76
|
+
setLoading(true);
|
|
77
|
+
try {
|
|
78
|
+
await fetchOrders();
|
|
79
|
+
} finally {
|
|
80
|
+
setLoading(false);
|
|
81
|
+
}
|
|
82
|
+
}, [fetchOrders]);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (patientId) {
|
|
86
|
+
fetchData().catch(showErrorNotification);
|
|
87
|
+
}
|
|
88
|
+
}, [patientId, fetchData]);
|
|
89
|
+
|
|
90
|
+
const handleOrderSelect = useCallback(
|
|
91
|
+
(order: ServiceRequest): string => {
|
|
92
|
+
return `/Patient/${patientId}/ServiceRequest/${order.id}`;
|
|
93
|
+
},
|
|
94
|
+
[patientId]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
const fetchOrder = async (): Promise<void> => {
|
|
99
|
+
if (serviceRequestId) {
|
|
100
|
+
const currentItems = activeTab === 'open' ? openOrders : completedOrders;
|
|
101
|
+
const order = currentItems.find((order: ServiceRequest) => order.id === serviceRequestId);
|
|
102
|
+
if (order) {
|
|
103
|
+
setCurrentOrder(order);
|
|
104
|
+
} else {
|
|
105
|
+
const order = await medplum.readResource('ServiceRequest', serviceRequestId);
|
|
106
|
+
if (order) {
|
|
107
|
+
setCurrentOrder(order);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
setCurrentOrder(undefined);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
fetchOrder().catch(showErrorNotification);
|
|
115
|
+
}, [activeTab, openOrders, completedOrders, serviceRequestId, medplum]);
|
|
116
|
+
|
|
117
|
+
const handleTabChange = (value: string): void => {
|
|
118
|
+
const newTab = value as LabTab;
|
|
119
|
+
setActiveTab(newTab);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const handleNewOrderCreated = (): void => {
|
|
123
|
+
setNewOrderModalOpened(false);
|
|
124
|
+
|
|
125
|
+
fetchData()
|
|
126
|
+
.then(() => {
|
|
127
|
+
setActiveTab('open');
|
|
128
|
+
navigate(`/Patient/${patientId}/ServiceRequest`)?.catch(console.error);
|
|
129
|
+
})
|
|
130
|
+
.catch(showErrorNotification);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const currentItems = activeTab === 'completed' ? completedOrders : openOrders;
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Box w="100%" h="100%">
|
|
137
|
+
<Flex h="100%">
|
|
138
|
+
<Box w={350} h="100%">
|
|
139
|
+
<Flex direction="column" h="100%" className={classes.borderRight}>
|
|
140
|
+
<Paper>
|
|
141
|
+
<Flex h={64} align="center" justify="space-between" p="md">
|
|
142
|
+
<Group gap="xs">
|
|
143
|
+
<Button
|
|
144
|
+
className={cx(classes.button, { [classes.selected]: activeTab === 'completed' })}
|
|
145
|
+
h={32}
|
|
146
|
+
radius="xl"
|
|
147
|
+
onClick={() => handleTabChange('completed')}
|
|
148
|
+
>
|
|
149
|
+
Completed
|
|
150
|
+
</Button>
|
|
151
|
+
|
|
152
|
+
<Button
|
|
153
|
+
className={cx(classes.button, { [classes.selected]: activeTab === 'open' })}
|
|
154
|
+
h={32}
|
|
155
|
+
radius="xl"
|
|
156
|
+
onClick={() => handleTabChange('open')}
|
|
157
|
+
>
|
|
158
|
+
Open
|
|
159
|
+
</Button>
|
|
160
|
+
</Group>
|
|
161
|
+
|
|
162
|
+
<ActionIcon radius="50%" variant="filled" color="blue" onClick={() => setNewOrderModalOpened(true)}>
|
|
163
|
+
<IconPlus size={16} />
|
|
164
|
+
</ActionIcon>
|
|
165
|
+
</Flex>
|
|
166
|
+
</Paper>
|
|
167
|
+
|
|
168
|
+
<Divider />
|
|
169
|
+
<Paper style={{ flex: 1, overflow: 'hidden' }}>
|
|
170
|
+
<ScrollArea h="100%" id="lab-list-scrollarea" p="0.5rem">
|
|
171
|
+
{loading && <LabListSkeleton />}
|
|
172
|
+
{!loading && currentItems.length === 0 && <EmptyLabsState activeTab={activeTab} />}
|
|
173
|
+
{!loading &&
|
|
174
|
+
currentItems.length > 0 &&
|
|
175
|
+
currentItems.map((item, index) => {
|
|
176
|
+
return (
|
|
177
|
+
<React.Fragment key={item.id}>
|
|
178
|
+
<LabListItem
|
|
179
|
+
item={item}
|
|
180
|
+
selectedItem={currentOrder}
|
|
181
|
+
activeTab={activeTab}
|
|
182
|
+
onItemSelect={handleOrderSelect}
|
|
183
|
+
/>
|
|
184
|
+
{index < currentItems.length - 1 && (
|
|
185
|
+
<Box px="0.5rem">
|
|
186
|
+
<Divider />
|
|
187
|
+
</Box>
|
|
188
|
+
)}
|
|
189
|
+
</React.Fragment>
|
|
190
|
+
);
|
|
191
|
+
})}
|
|
192
|
+
</ScrollArea>
|
|
193
|
+
</Paper>
|
|
194
|
+
</Flex>
|
|
195
|
+
</Box>
|
|
196
|
+
|
|
197
|
+
{currentItems.length > 0 ? (
|
|
198
|
+
<>
|
|
199
|
+
<Box
|
|
200
|
+
h="100%"
|
|
201
|
+
style={{
|
|
202
|
+
flex: 1,
|
|
203
|
+
}}
|
|
204
|
+
className={classes.borderRight}
|
|
205
|
+
>
|
|
206
|
+
{currentOrder ? (
|
|
207
|
+
<LabOrderDetails key={currentOrder.id} order={currentOrder} />
|
|
208
|
+
) : (
|
|
209
|
+
<LabSelectEmpty activeTab={'open'} />
|
|
210
|
+
)}
|
|
211
|
+
</Box>
|
|
212
|
+
</>
|
|
213
|
+
) : (
|
|
214
|
+
<Flex direction="column" h="100%" style={{ flex: 1 }}>
|
|
215
|
+
<LabSelectEmpty activeTab={activeTab} />
|
|
216
|
+
</Flex>
|
|
217
|
+
)}
|
|
218
|
+
</Flex>
|
|
219
|
+
|
|
220
|
+
{/* New Order Modal */}
|
|
221
|
+
<Modal
|
|
222
|
+
opened={newOrderModalOpened}
|
|
223
|
+
onClose={() => setNewOrderModalOpened(false)}
|
|
224
|
+
size="xl"
|
|
225
|
+
centered
|
|
226
|
+
title="Order Labs"
|
|
227
|
+
>
|
|
228
|
+
<OrderLabsPage onSubmitLabOrder={handleNewOrderCreated} />
|
|
229
|
+
</Modal>
|
|
230
|
+
</Box>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function filterOpenOrders(orders: ServiceRequest[]): ServiceRequest[] {
|
|
235
|
+
const filteredOutStatuses = ['completed', 'draft', 'entered-in-error'];
|
|
236
|
+
const completedServiceRequestIds = new Set<string>();
|
|
237
|
+
orders.forEach((order) => {
|
|
238
|
+
if (order.status === 'completed' && order.id) {
|
|
239
|
+
completedServiceRequestIds.add(order.id);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const completedRequisitionNumbers = new Set<string>();
|
|
244
|
+
const filtered = orders.filter((order) => {
|
|
245
|
+
if (filteredOutStatuses.includes(order.status || '')) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (order.basedOn) {
|
|
250
|
+
const basedOnCompleted = order.basedOn.find((basedOn) => {
|
|
251
|
+
if (basedOn.reference?.startsWith('ServiceRequest/')) {
|
|
252
|
+
const [, id] = basedOn.reference.split('/');
|
|
253
|
+
return completedServiceRequestIds.has(id);
|
|
254
|
+
}
|
|
255
|
+
return false;
|
|
256
|
+
});
|
|
257
|
+
if (basedOnCompleted) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const requisitionNumber = order.requisition?.value;
|
|
263
|
+
if (requisitionNumber && completedRequisitionNumbers.has(requisitionNumber)) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (requisitionNumber) {
|
|
268
|
+
completedRequisitionNumbers.add(requisitionNumber);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return true;
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return filtered.sort((a, b) => {
|
|
275
|
+
const aDate = a.meta?.lastUpdated || a.authoredOn;
|
|
276
|
+
const bDate = b.meta?.lastUpdated || b.authoredOn;
|
|
277
|
+
return new Date(bDate || 0).getTime() - new Date(aDate || 0).getTime();
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function filterCompletedOrders(orders: ServiceRequest[]): ServiceRequest[] {
|
|
282
|
+
const completedRequisitionNumbers = new Set<string>();
|
|
283
|
+
const filtered = orders.filter((order) => {
|
|
284
|
+
if (order.status !== 'completed') {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const requisitionNumber = order.requisition?.value;
|
|
289
|
+
if (requisitionNumber && completedRequisitionNumbers.has(requisitionNumber)) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (requisitionNumber) {
|
|
294
|
+
completedRequisitionNumbers.add(requisitionNumber);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return true;
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
return filtered.sort((a, b) => {
|
|
301
|
+
const aDate = a.meta?.lastUpdated || a.authoredOn;
|
|
302
|
+
const bDate = b.meta?.lastUpdated || b.authoredOn;
|
|
303
|
+
return new Date(bDate || 0).getTime() - new Date(aDate || 0).getTime();
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function EmptyLabsState({ activeTab }: { activeTab: LabTab }): JSX.Element {
|
|
308
|
+
return (
|
|
309
|
+
<Flex direction="column" h="100%" justify="center" align="center">
|
|
310
|
+
<Stack align="center" gap="md" pt="xl">
|
|
311
|
+
<Text size="md" c="dimmed" fw={400}>
|
|
312
|
+
No {activeTab} labs to display.
|
|
313
|
+
</Text>
|
|
314
|
+
</Stack>
|
|
315
|
+
</Flex>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function LabListSkeleton(): JSX.Element {
|
|
320
|
+
return (
|
|
321
|
+
<Stack gap="md" p="md">
|
|
322
|
+
{Array.from({ length: 6 }).map((_, index) => (
|
|
323
|
+
<Stack key={index}>
|
|
324
|
+
<Flex direction="column" gap="xs" align="flex-start">
|
|
325
|
+
<Skeleton height={16} width={`${Math.random() * 40 + 60}%`} />
|
|
326
|
+
<Skeleton height={14} width={`${Math.random() * 50 + 40}%`} />
|
|
327
|
+
<Skeleton height={14} width={`${Math.random() * 50 + 40}%`} />
|
|
328
|
+
</Flex>
|
|
329
|
+
<Divider />
|
|
330
|
+
</Stack>
|
|
331
|
+
))}
|
|
332
|
+
</Stack>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
align-items: stretch;
|
|
5
|
+
height: calc(100vh - var(--app-shell-header-height, 0));
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sidebar {
|
|
10
|
+
flex: 1;
|
|
11
|
+
width: 350px;
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.scrollArea {
|
|
16
|
+
height: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.content {
|
|
20
|
+
width: calc(100% - 350px);
|
|
21
|
+
height: 100%;
|
|
22
|
+
overflow: auto;
|
|
23
|
+
border-inline-start: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
|
24
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MantineProvider } from '@mantine/core';
|
|
4
|
+
import { Notifications } from '@mantine/notifications';
|
|
5
|
+
import { HomerSimpson, MockClient } from '@medplum/mock';
|
|
6
|
+
import { MedplumProvider } from '@medplum/react';
|
|
7
|
+
import * as medplumReact from '@medplum/react';
|
|
8
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
9
|
+
import userEvent from '@testing-library/user-event';
|
|
10
|
+
import { MemoryRouter, Routes, Route } from 'react-router';
|
|
11
|
+
import { describe, expect, test, vi, beforeEach } from 'vitest';
|
|
12
|
+
import { PatientPage } from './PatientPage';
|
|
13
|
+
import { TimelineTab } from './TimelineTab';
|
|
14
|
+
import { EditTab } from './EditTab';
|
|
15
|
+
|
|
16
|
+
describe('PatientPage', () => {
|
|
17
|
+
let medplum: MockClient;
|
|
18
|
+
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
medplum = new MockClient();
|
|
21
|
+
vi.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const setup = (initialPath = '/Patient/patient-123'): ReturnType<typeof render> => {
|
|
25
|
+
return render(
|
|
26
|
+
<MemoryRouter initialEntries={[initialPath]}>
|
|
27
|
+
<MedplumProvider medplum={medplum}>
|
|
28
|
+
<MantineProvider>
|
|
29
|
+
<Notifications />
|
|
30
|
+
<Routes>
|
|
31
|
+
<Route path="/Patient/:patientId/*" element={<PatientPage />}>
|
|
32
|
+
<Route path="edit" element={<EditTab />} />
|
|
33
|
+
<Route path="" element={<TimelineTab />} />
|
|
34
|
+
<Route path="*" element={<TimelineTab />} />
|
|
35
|
+
</Route>
|
|
36
|
+
</Routes>
|
|
37
|
+
</MantineProvider>
|
|
38
|
+
</MedplumProvider>
|
|
39
|
+
</MemoryRouter>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
test('shows loader when patient is loading', async () => {
|
|
44
|
+
// Use a non-existent patient ID to simulate loading
|
|
45
|
+
setup('/Patient/non-existent-patient');
|
|
46
|
+
|
|
47
|
+
await waitFor(() => {
|
|
48
|
+
const loader = document.querySelector('.mantine-Loader-root');
|
|
49
|
+
expect(loader).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('renders patient page when patient is loaded', async () => {
|
|
54
|
+
setup(`/Patient/${HomerSimpson.id}`);
|
|
55
|
+
|
|
56
|
+
await waitFor(() => {
|
|
57
|
+
expect(screen.getByText('Timeline')).toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('renders all tabs in navigation', async () => {
|
|
62
|
+
setup(`/Patient/${HomerSimpson.id}`);
|
|
63
|
+
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(screen.getByText('Timeline')).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Check for some key tabs
|
|
69
|
+
expect(screen.getByText('Edit')).toBeInTheDocument();
|
|
70
|
+
expect(screen.getByText('Visits')).toBeInTheDocument();
|
|
71
|
+
expect(screen.getByText('Tasks')).toBeInTheDocument();
|
|
72
|
+
expect(screen.getByText('Meds')).toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('sets initial tab from URL path', async () => {
|
|
76
|
+
setup(`/Patient/${HomerSimpson.id}/edit`);
|
|
77
|
+
|
|
78
|
+
await waitFor(() => {
|
|
79
|
+
const editTab = screen.getByText('Edit');
|
|
80
|
+
expect(editTab).toBeInTheDocument();
|
|
81
|
+
expect(editTab.closest('[role="tab"]')).toHaveAttribute('aria-selected', 'true');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('handles tab change when clicking on tab', async () => {
|
|
86
|
+
const user = userEvent.setup();
|
|
87
|
+
setup(`/Patient/${HomerSimpson.id}`);
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(screen.getByText('Timeline')).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const editTab = screen.getByText('Edit');
|
|
94
|
+
await user.click(editTab);
|
|
95
|
+
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
const editTab = screen.getByText('Edit');
|
|
98
|
+
expect(editTab).toBeInTheDocument();
|
|
99
|
+
expect(editTab.closest('[role="tab"]')).toHaveAttribute('aria-selected', 'true');
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('does not show tabs when patient is loading', async () => {
|
|
104
|
+
setup('/Patient/non-existent-patient');
|
|
105
|
+
|
|
106
|
+
await waitFor(() => {
|
|
107
|
+
const loader = document.querySelector('.mantine-Loader-root');
|
|
108
|
+
expect(loader).toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(screen.queryByText('Timeline')).not.toBeInTheDocument();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('defaults to timeline tab when URL does not match any tab', async () => {
|
|
115
|
+
setup(`/Patient/${HomerSimpson.id}/unknown-path`);
|
|
116
|
+
|
|
117
|
+
await waitFor(() => {
|
|
118
|
+
const timelineTab = screen.getByText('Timeline');
|
|
119
|
+
expect(timelineTab).toBeInTheDocument();
|
|
120
|
+
expect(timelineTab.closest('[role="tab"]')).toHaveAttribute('aria-selected', 'true');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('renders homer summary information in sidebar', async () => {
|
|
125
|
+
const patientSummarySpy = vi.spyOn(medplumReact, 'PatientSummary');
|
|
126
|
+
setup(`/Patient/${HomerSimpson.id}`);
|
|
127
|
+
|
|
128
|
+
await waitFor(() => {
|
|
129
|
+
expect(patientSummarySpy).toHaveBeenCalled();
|
|
130
|
+
expect(screen.getByText('Male')).toBeInTheDocument();
|
|
131
|
+
expect(screen.getByText('1956-05-12 (069Y)')).toBeInTheDocument();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('handles empty pathname correctly', async () => {
|
|
136
|
+
setup(`/Patient/${HomerSimpson.id}/`);
|
|
137
|
+
|
|
138
|
+
await waitFor(() => {
|
|
139
|
+
const timelineTab = screen.getByText('Timeline');
|
|
140
|
+
expect(timelineTab).toBeInTheDocument();
|
|
141
|
+
expect(timelineTab.closest('[role="tab"]')).toHaveAttribute('aria-selected', 'true');
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('highlights the Edit tab in a case-insensitive way even when /EDIT is used', async () => {
|
|
146
|
+
setup(`/Patient/${HomerSimpson.id}/EDIT`);
|
|
147
|
+
|
|
148
|
+
await waitFor(() => {
|
|
149
|
+
const editTab = screen.getByText('Edit');
|
|
150
|
+
expect(editTab).toBeInTheDocument();
|
|
151
|
+
expect(editTab.closest('[role="tab"]')).toHaveAttribute('aria-selected', 'true');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Loader, Modal, ScrollArea } from '@mantine/core';
|
|
4
|
+
import { getReferenceString, isOk } from '@medplum/core';
|
|
5
|
+
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
6
|
+
import { Document, OperationOutcomeAlert, PatientSummary, useMedplum } from '@medplum/react';
|
|
7
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
8
|
+
import type { JSX } from 'react';
|
|
9
|
+
import { Outlet, useLocation, useNavigate } from 'react-router';
|
|
10
|
+
import type { Location } from 'react-router';
|
|
11
|
+
import { usePatient } from '../../hooks/usePatient';
|
|
12
|
+
import classes from './PatientPage.module.css';
|
|
13
|
+
import { formatPatientPageTabUrl, getPatientPageTabs } from './PatientPage.utils';
|
|
14
|
+
import type { PatientPageTabInfo } from './PatientPage.utils';
|
|
15
|
+
import { PatientTabsNavigation } from './PatientTabsNavigation';
|
|
16
|
+
import { OrderLabsPage } from '../labs/OrderLabsPage';
|
|
17
|
+
|
|
18
|
+
function getTabFromLocation(location: Location, tabs: PatientPageTabInfo[]): PatientPageTabInfo | undefined {
|
|
19
|
+
const tabId = location.pathname.split('/')[3] ?? '';
|
|
20
|
+
const tab = tabId
|
|
21
|
+
? tabs.find((t) => t.id === tabId || t.url.toLowerCase().startsWith(tabId.toLowerCase()))
|
|
22
|
+
: undefined;
|
|
23
|
+
return tab;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function PatientPage(): JSX.Element {
|
|
27
|
+
const navigate = useNavigate();
|
|
28
|
+
const location = useLocation();
|
|
29
|
+
const medplum = useMedplum();
|
|
30
|
+
const membership = medplum.getProjectMembership();
|
|
31
|
+
const [outcome, setOutcome] = useState<OperationOutcome>();
|
|
32
|
+
const patient = usePatient({ setOutcome });
|
|
33
|
+
const [isLabsModalOpen, setIsLabsModalOpen] = useState(false);
|
|
34
|
+
const tabs = getPatientPageTabs(membership);
|
|
35
|
+
const [currentTab, setCurrentTab] = useState<string>(() => {
|
|
36
|
+
return (getTabFromLocation(location, tabs) ?? tabs[0]).id;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Handles a tab change event.
|
|
41
|
+
* @param newTabName - The new tab name.
|
|
42
|
+
*/
|
|
43
|
+
const onTabChange = useCallback(
|
|
44
|
+
(newTabName: string | null): void => {
|
|
45
|
+
if (!patient?.id) {
|
|
46
|
+
console.error('Not within a patient context');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const tab = newTabName ? tabs.find((t) => t.id === newTabName) : tabs[0];
|
|
50
|
+
if (tab) {
|
|
51
|
+
setCurrentTab(tab.id);
|
|
52
|
+
navigate(formatPatientPageTabUrl(patient.id, tab))?.catch(console.error);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
[navigate, patient?.id, tabs]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// Rectify the active tab UI with the current URL. This is necessary because the active tab can be changed
|
|
59
|
+
// in ways other than clicking on a tab in the navigation bar.
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const newTab = getTabFromLocation(location, tabs);
|
|
62
|
+
if (newTab && newTab.id !== currentTab) {
|
|
63
|
+
setCurrentTab(newTab.id);
|
|
64
|
+
}
|
|
65
|
+
}, [currentTab, location, tabs]);
|
|
66
|
+
|
|
67
|
+
const handleCloseLabsModal = useCallback(() => {
|
|
68
|
+
setIsLabsModalOpen(false);
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
if (outcome && !isOk(outcome)) {
|
|
72
|
+
return (
|
|
73
|
+
<Document>
|
|
74
|
+
<OperationOutcomeAlert outcome={outcome} />
|
|
75
|
+
</Document>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const patientId = patient?.id;
|
|
80
|
+
if (!patientId) {
|
|
81
|
+
return (
|
|
82
|
+
<Document>
|
|
83
|
+
<Loader />
|
|
84
|
+
</Document>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<>
|
|
90
|
+
<div key={getReferenceString(patient)} className={classes.container}>
|
|
91
|
+
<div className={classes.sidebar}>
|
|
92
|
+
<ScrollArea className={classes.scrollArea}>
|
|
93
|
+
<PatientSummary
|
|
94
|
+
patient={patient}
|
|
95
|
+
onClickResource={(resource) =>
|
|
96
|
+
navigate(`/Patient/${patientId}/${resource.resourceType}/${resource.id}`)?.catch(console.error)
|
|
97
|
+
}
|
|
98
|
+
onRequestLabs={() => {
|
|
99
|
+
setIsLabsModalOpen(true);
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
</ScrollArea>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div className={classes.content}>
|
|
106
|
+
<PatientTabsNavigation tabs={tabs} currentTab={currentTab} onTabChange={onTabChange} />
|
|
107
|
+
<Outlet />
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
<Modal opened={isLabsModalOpen} onClose={handleCloseLabsModal} size="xl" centered title="Order Labs">
|
|
111
|
+
<OrderLabsPage onSubmitLabOrder={handleCloseLabsModal} />
|
|
112
|
+
</Modal>
|
|
113
|
+
</>
|
|
114
|
+
);
|
|
115
|
+
}
|