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,224 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { ActionIcon, Box, Button, Flex, Group, Menu, Modal, Paper, SegmentedControl, Stack, Text } from '@mantine/core';
|
|
4
|
+
import { useDisclosure } from '@mantine/hooks';
|
|
5
|
+
import { formatDate, formatHumanName } from '@medplum/core';
|
|
6
|
+
import type { Encounter, Practitioner, Reference } from '@medplum/fhirtypes';
|
|
7
|
+
import { IconChevronDown, IconLock, IconLockOpen } from '@tabler/icons-react';
|
|
8
|
+
import type { JSX } from 'react';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
import { ChartNoteStatus } from '../../types/encounter';
|
|
11
|
+
import { SignLockDialog } from './SignLockDialog';
|
|
12
|
+
|
|
13
|
+
interface EncounterHeaderProps {
|
|
14
|
+
encounter: Encounter;
|
|
15
|
+
practitioner?: Practitioner | undefined;
|
|
16
|
+
chartNoteStatus?: ChartNoteStatus;
|
|
17
|
+
onStatusChange?: (status: Encounter['status']) => void;
|
|
18
|
+
onTabChange?: (tab: string) => void;
|
|
19
|
+
onSign?: (practitioner: Reference<Practitioner>, lock: boolean) => void;
|
|
20
|
+
onSignLock?: (practitioner: Reference<Practitioner>) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const EncounterHeader = (props: EncounterHeaderProps): JSX.Element => {
|
|
24
|
+
const {
|
|
25
|
+
encounter,
|
|
26
|
+
practitioner,
|
|
27
|
+
chartNoteStatus = ChartNoteStatus.Unsigned,
|
|
28
|
+
onStatusChange,
|
|
29
|
+
onTabChange,
|
|
30
|
+
onSign,
|
|
31
|
+
} = props;
|
|
32
|
+
const [status, setStatus] = useState<Encounter['status']>(encounter.status);
|
|
33
|
+
const [activeTab, setActiveTab] = useState<string>('notes');
|
|
34
|
+
const [confirmOpened, { open: openConfirm, close: closeConfirm }] = useDisclosure(false);
|
|
35
|
+
const [signOpened, { open: openSign, close: closeSign }] = useDisclosure(false);
|
|
36
|
+
|
|
37
|
+
const handleStatusChange = (newStatus: Encounter['status']): void => {
|
|
38
|
+
if (newStatus === 'cancelled') {
|
|
39
|
+
openConfirm();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setStatus(newStatus);
|
|
44
|
+
onStatusChange?.(newStatus);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const confirmStatusChange = (): void => {
|
|
48
|
+
setStatus('cancelled');
|
|
49
|
+
onStatusChange?.('cancelled');
|
|
50
|
+
closeConfirm();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onConfirmSign = (practitioner: Reference<Practitioner>, lock: boolean): void => {
|
|
54
|
+
onSign?.(practitioner, lock);
|
|
55
|
+
closeSign();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const handleTabChange = (tab: string): void => {
|
|
59
|
+
setActiveTab(tab);
|
|
60
|
+
onTabChange?.(tab);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleSign = (): void => {
|
|
64
|
+
if (chartNoteStatus === ChartNoteStatus.SignedAndLocked) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
openSign();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const practitionerName = practitioner?.name?.[0] ? formatHumanName(practitioner.name[0]) : 'Unknown Provider';
|
|
71
|
+
const formattedDate = formatDate(encounter.period?.start);
|
|
72
|
+
const encounterDetail = formattedDate ? `${formattedDate} · ${practitionerName}` : practitionerName;
|
|
73
|
+
|
|
74
|
+
const renderMenuItems = (): JSX.Element | null => {
|
|
75
|
+
if (status === 'planned') {
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<Menu.Item onClick={() => handleStatusChange('arrived')}>Arrived</Menu.Item>
|
|
79
|
+
<Menu.Item onClick={() => handleStatusChange('in-progress')}>In Progress</Menu.Item>
|
|
80
|
+
<Menu.Item onClick={() => handleStatusChange('finished')}>Finished</Menu.Item>
|
|
81
|
+
<Menu.Item onClick={() => handleStatusChange('cancelled')}>Cancelled</Menu.Item>
|
|
82
|
+
<Menu.Divider />
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (status === 'arrived') {
|
|
88
|
+
return (
|
|
89
|
+
<>
|
|
90
|
+
<Menu.Item onClick={() => handleStatusChange('in-progress')}>In Progress</Menu.Item>
|
|
91
|
+
<Menu.Item onClick={() => handleStatusChange('finished')}>Finished</Menu.Item>
|
|
92
|
+
<Menu.Item onClick={() => handleStatusChange('cancelled')}>Cancelled</Menu.Item>
|
|
93
|
+
<Menu.Divider />
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (status === 'in-progress') {
|
|
99
|
+
return (
|
|
100
|
+
<>
|
|
101
|
+
<Menu.Item onClick={() => handleStatusChange('finished')}>Finished</Menu.Item>
|
|
102
|
+
<Menu.Item onClick={() => handleStatusChange('cancelled')}>Cancelled</Menu.Item>
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<Paper shadow="sm" p={0}>
|
|
113
|
+
<Flex justify="space-between" align="center" p="lg">
|
|
114
|
+
<Stack gap={0}>
|
|
115
|
+
<Text fw={800} size="lg">
|
|
116
|
+
{encounter.basedOn?.[0]?.display || 'Visit'}
|
|
117
|
+
</Text>
|
|
118
|
+
<Text fw={500} size="xs" c="dimmed">
|
|
119
|
+
{encounterDetail}
|
|
120
|
+
</Text>
|
|
121
|
+
</Stack>
|
|
122
|
+
<Group>
|
|
123
|
+
{status === 'cancelled' || status === 'finished' ? (
|
|
124
|
+
<>
|
|
125
|
+
{status === 'finished' && chartNoteStatus === ChartNoteStatus.Unsigned && (
|
|
126
|
+
<ActionIcon radius="50%" variant={'outline'} color={'gray'} onClick={handleSign}>
|
|
127
|
+
<IconLock size={16} />
|
|
128
|
+
</ActionIcon>
|
|
129
|
+
)}
|
|
130
|
+
|
|
131
|
+
{status === 'finished' && chartNoteStatus === ChartNoteStatus.Signed && (
|
|
132
|
+
<ActionIcon radius="50%" variant={'outline'} color={'gray'} onClick={handleSign}>
|
|
133
|
+
<IconLockOpen size={16} />
|
|
134
|
+
</ActionIcon>
|
|
135
|
+
)}
|
|
136
|
+
|
|
137
|
+
{status === 'finished' && chartNoteStatus === ChartNoteStatus.SignedAndLocked && (
|
|
138
|
+
<ActionIcon radius="50%" variant={'filled'} color={'blue'} onClick={handleSign}>
|
|
139
|
+
<IconLock size={16} />
|
|
140
|
+
</ActionIcon>
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
<Button variant="light" color={getStatusColor(status)} radius="xl" size="sm">
|
|
144
|
+
{getStatusDisplay(status)}
|
|
145
|
+
</Button>
|
|
146
|
+
</>
|
|
147
|
+
) : (
|
|
148
|
+
<Menu position="bottom-end" shadow="md">
|
|
149
|
+
<Menu.Target>
|
|
150
|
+
<Button
|
|
151
|
+
variant="light"
|
|
152
|
+
color={getStatusColor(status)}
|
|
153
|
+
rightSection={<IconChevronDown size={16} />}
|
|
154
|
+
radius="xl"
|
|
155
|
+
size="sm"
|
|
156
|
+
>
|
|
157
|
+
{getStatusDisplay(status)}
|
|
158
|
+
</Button>
|
|
159
|
+
</Menu.Target>
|
|
160
|
+
|
|
161
|
+
<Menu.Dropdown>{renderMenuItems()}</Menu.Dropdown>
|
|
162
|
+
</Menu>
|
|
163
|
+
)}
|
|
164
|
+
</Group>
|
|
165
|
+
</Flex>
|
|
166
|
+
|
|
167
|
+
<Box px="md" pb="md">
|
|
168
|
+
<SegmentedControl
|
|
169
|
+
value={activeTab}
|
|
170
|
+
onChange={(value: string) => handleTabChange(value)}
|
|
171
|
+
data={[
|
|
172
|
+
{ label: 'Note & Tasks', value: 'notes' },
|
|
173
|
+
{ label: 'Details & Billing', value: 'details' },
|
|
174
|
+
]}
|
|
175
|
+
fullWidth
|
|
176
|
+
radius="md"
|
|
177
|
+
size="md"
|
|
178
|
+
/>
|
|
179
|
+
</Box>
|
|
180
|
+
</Paper>
|
|
181
|
+
|
|
182
|
+
<Modal opened={confirmOpened} onClose={closeConfirm}>
|
|
183
|
+
<Text size="lg" fw={500}>
|
|
184
|
+
Are you sure you want to cancel this encounter?
|
|
185
|
+
</Text>
|
|
186
|
+
<Text size="sm" c="dimmed" mt="xs">
|
|
187
|
+
This action cannot be undone.
|
|
188
|
+
</Text>
|
|
189
|
+
<Group justify="flex-end" mt="xl" gap="xs">
|
|
190
|
+
<Button onClick={closeConfirm} color="red" variant="outline">
|
|
191
|
+
No, keep it
|
|
192
|
+
</Button>
|
|
193
|
+
<Button onClick={confirmStatusChange} color="red">
|
|
194
|
+
Yes, cancel it
|
|
195
|
+
</Button>
|
|
196
|
+
</Group>
|
|
197
|
+
</Modal>
|
|
198
|
+
|
|
199
|
+
<Modal opened={signOpened} onClose={closeSign} title="Signing As">
|
|
200
|
+
<SignLockDialog onSign={onConfirmSign} />
|
|
201
|
+
</Modal>
|
|
202
|
+
</>
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const getStatusColor = (status: Encounter['status']): string => {
|
|
207
|
+
if (status === 'finished') {
|
|
208
|
+
return 'green';
|
|
209
|
+
}
|
|
210
|
+
if (status === 'cancelled') {
|
|
211
|
+
return 'red';
|
|
212
|
+
}
|
|
213
|
+
if (status === 'arrived' || status === 'in-progress' || status === 'planned') {
|
|
214
|
+
return 'blue';
|
|
215
|
+
}
|
|
216
|
+
return 'gray';
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const getStatusDisplay = (status: Encounter['status']): string => {
|
|
220
|
+
return status
|
|
221
|
+
.split('-')
|
|
222
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
223
|
+
.join(' ');
|
|
224
|
+
};
|
package/dist/examples/vintasend-medplum-example/src/components/encounter/SignAddendum.test.tsx
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MantineProvider } from '@mantine/core';
|
|
4
|
+
import { act, render, screen, waitFor } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
import { MedplumProvider } from '@medplum/react';
|
|
7
|
+
import type { Encounter, Provenance } from '@medplum/fhirtypes';
|
|
8
|
+
import { MockClient } from '@medplum/mock';
|
|
9
|
+
import { MemoryRouter } from 'react-router';
|
|
10
|
+
import { describe, expect, test, beforeEach, vi } from 'vitest';
|
|
11
|
+
import { SignAddendum } from './SignAddendum';
|
|
12
|
+
import { ChartNoteStatus } from '../../types/encounter';
|
|
13
|
+
import * as notifications from '../../utils/notifications';
|
|
14
|
+
|
|
15
|
+
const mockEncounter: Encounter = {
|
|
16
|
+
resourceType: 'Encounter',
|
|
17
|
+
id: 'encounter-123',
|
|
18
|
+
status: 'finished',
|
|
19
|
+
class: { code: 'AMB', system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode' },
|
|
20
|
+
subject: { reference: 'Patient/patient-123' },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const mockProvenance: Provenance = {
|
|
24
|
+
resourceType: 'Provenance',
|
|
25
|
+
id: 'provenance-123',
|
|
26
|
+
target: [{ reference: 'Encounter/encounter-123' }],
|
|
27
|
+
recorded: '2024-01-01T10:00:00Z',
|
|
28
|
+
agent: [
|
|
29
|
+
{
|
|
30
|
+
who: { reference: 'Practitioner/practitioner-123', display: 'Dr. Test' },
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe('SignAddendumCard', () => {
|
|
36
|
+
let medplum: MockClient;
|
|
37
|
+
|
|
38
|
+
beforeEach(async () => {
|
|
39
|
+
medplum = new MockClient();
|
|
40
|
+
vi.clearAllMocks();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const setup = (props: Partial<Parameters<typeof SignAddendum>[0]> = {}): ReturnType<typeof render> => {
|
|
44
|
+
return render(
|
|
45
|
+
<MemoryRouter>
|
|
46
|
+
<MedplumProvider medplum={medplum}>
|
|
47
|
+
<MantineProvider>
|
|
48
|
+
<SignAddendum
|
|
49
|
+
encounter={mockEncounter}
|
|
50
|
+
provenances={[]}
|
|
51
|
+
chartNoteStatus={ChartNoteStatus.Unsigned}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
</MantineProvider>
|
|
55
|
+
</MedplumProvider>
|
|
56
|
+
</MemoryRouter>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
test('returns null when no provenances', async () => {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
const { container } = setup({ provenances: [] });
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
expect(container.firstChild).toBeNull();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('renders provenance information', async () => {
|
|
70
|
+
await act(async () => {
|
|
71
|
+
setup({ provenances: [mockProvenance] });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
await waitFor(() => {
|
|
75
|
+
expect(screen.getByText(/Signed by/i)).toBeInTheDocument();
|
|
76
|
+
expect(screen.getByText(/Dr\. Test/i)).toBeInTheDocument();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('displays signed and locked status for last provenance', async () => {
|
|
81
|
+
await act(async () => {
|
|
82
|
+
setup({
|
|
83
|
+
provenances: [mockProvenance],
|
|
84
|
+
chartNoteStatus: ChartNoteStatus.SignedAndLocked,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await waitFor(() => {
|
|
89
|
+
expect(screen.getByText(/Signed and Locked by/i)).toBeInTheDocument();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('displays addendum form', async () => {
|
|
94
|
+
await act(async () => {
|
|
95
|
+
setup({ provenances: [mockProvenance] });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await waitFor(() => {
|
|
99
|
+
expect(screen.getByPlaceholderText('Add an addendum to this Visit...')).toBeInTheDocument();
|
|
100
|
+
expect(screen.getByRole('button', { name: 'Add Addendum' })).toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('creates addendum when form is submitted', async () => {
|
|
105
|
+
const user = userEvent.setup();
|
|
106
|
+
const createResourceSpy = vi.spyOn(medplum, 'createResource').mockResolvedValue({
|
|
107
|
+
resourceType: 'DocumentReference',
|
|
108
|
+
id: 'doc-new',
|
|
109
|
+
status: 'current',
|
|
110
|
+
date: new Date().toISOString(),
|
|
111
|
+
author: [{ display: 'Dr. Alice Smith' }],
|
|
112
|
+
} as any);
|
|
113
|
+
|
|
114
|
+
await act(async () => {
|
|
115
|
+
setup({ provenances: [mockProvenance] });
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(screen.getByPlaceholderText('Add an addendum to this Visit...')).toBeInTheDocument();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const textarea = screen.getByPlaceholderText('Add an addendum to this Visit...');
|
|
123
|
+
await user.type(textarea, 'Test addendum text');
|
|
124
|
+
|
|
125
|
+
const submitButton = screen.getByRole('button', { name: 'Add Addendum' });
|
|
126
|
+
await user.click(submitButton);
|
|
127
|
+
|
|
128
|
+
await waitFor(() => {
|
|
129
|
+
expect(createResourceSpy).toHaveBeenCalled();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('disables submit button when textarea is empty', async () => {
|
|
134
|
+
await act(async () => {
|
|
135
|
+
setup({ provenances: [mockProvenance] });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
await waitFor(() => {
|
|
139
|
+
const submitButton = screen.getByRole('button', { name: 'Add Addendum' });
|
|
140
|
+
expect(submitButton).toBeInTheDocument();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const submitButton = screen.getByRole('button', { name: 'Add Addendum' });
|
|
144
|
+
expect(submitButton).toBeDisabled();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('disables submit button when only whitespace', async () => {
|
|
148
|
+
const user = userEvent.setup();
|
|
149
|
+
await act(async () => {
|
|
150
|
+
setup({ provenances: [mockProvenance] });
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
await waitFor(() => {
|
|
154
|
+
expect(screen.getByPlaceholderText('Add an addendum to this Visit...')).toBeInTheDocument();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const textarea = screen.getByPlaceholderText('Add an addendum to this Visit...');
|
|
158
|
+
await user.type(textarea, ' ');
|
|
159
|
+
|
|
160
|
+
await waitFor(() => {
|
|
161
|
+
const submitButton = screen.getByRole('button', { name: 'Add Addendum' });
|
|
162
|
+
expect(submitButton).toBeDisabled();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('loads and displays addendums from DocumentReference', async () => {
|
|
167
|
+
const mockDocumentReference = {
|
|
168
|
+
resourceType: 'DocumentReference' as const,
|
|
169
|
+
id: 'doc-123',
|
|
170
|
+
status: 'current' as const,
|
|
171
|
+
date: '2024-01-02T10:00:00Z',
|
|
172
|
+
author: [{ display: 'Dr. Author' }],
|
|
173
|
+
content: [
|
|
174
|
+
{
|
|
175
|
+
attachment: {
|
|
176
|
+
contentType: 'text/plain',
|
|
177
|
+
data: btoa('Test addendum content'),
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
vi.spyOn(medplum, 'searchResources').mockResolvedValue([mockDocumentReference] as any);
|
|
184
|
+
|
|
185
|
+
await act(async () => {
|
|
186
|
+
setup({ provenances: [mockProvenance] });
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await waitFor(() => {
|
|
190
|
+
expect(screen.getByText(/Addendum by/i)).toBeInTheDocument();
|
|
191
|
+
expect(screen.getByText('Test addendum content')).toBeInTheDocument();
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('handles errors when loading addendums', async () => {
|
|
196
|
+
const error = new Error('Failed to load addendums');
|
|
197
|
+
vi.spyOn(medplum, 'searchResources').mockRejectedValue(error);
|
|
198
|
+
const errorNotificationSpy = vi.spyOn(notifications, 'showErrorNotification');
|
|
199
|
+
|
|
200
|
+
await act(async () => {
|
|
201
|
+
setup({ provenances: [mockProvenance] });
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
await waitFor(() => {
|
|
205
|
+
expect(errorNotificationSpy).toHaveBeenCalledWith(error);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('handles errors when creating addendum', async () => {
|
|
210
|
+
const user = userEvent.setup();
|
|
211
|
+
const error = new Error('Failed to create addendum');
|
|
212
|
+
vi.spyOn(medplum, 'createResource').mockRejectedValue(error);
|
|
213
|
+
const errorNotificationSpy = vi.spyOn(notifications, 'showErrorNotification');
|
|
214
|
+
|
|
215
|
+
await act(async () => {
|
|
216
|
+
setup({ provenances: [mockProvenance] });
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
await waitFor(() => {
|
|
220
|
+
expect(screen.getByPlaceholderText('Add an addendum to this Visit...')).toBeInTheDocument();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const textarea = screen.getByPlaceholderText('Add an addendum to this Visit...');
|
|
224
|
+
await user.type(textarea, 'Test addendum');
|
|
225
|
+
|
|
226
|
+
const submitButton = screen.getByRole('button', { name: 'Add Addendum' });
|
|
227
|
+
await user.click(submitButton);
|
|
228
|
+
|
|
229
|
+
await waitFor(() => {
|
|
230
|
+
expect(errorNotificationSpy).toHaveBeenCalledWith(error);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test('displays multiple provenances', async () => {
|
|
235
|
+
const provenance2: Provenance = {
|
|
236
|
+
...mockProvenance,
|
|
237
|
+
id: 'provenance-456',
|
|
238
|
+
recorded: '2024-01-02T10:00:00Z',
|
|
239
|
+
agent: [
|
|
240
|
+
{
|
|
241
|
+
who: { reference: 'Practitioner/practitioner-456', display: 'Dr. Another' },
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
await act(async () => {
|
|
247
|
+
setup({ provenances: [mockProvenance, provenance2] });
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
await waitFor(() => {
|
|
251
|
+
expect(screen.getByText(/Dr\. Test/i)).toBeInTheDocument();
|
|
252
|
+
expect(screen.getByText(/Dr\. Another/i)).toBeInTheDocument();
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
});
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Card, Stack, Text, Group, Textarea, Button, Divider } from '@mantine/core';
|
|
4
|
+
import { IconLock, IconPencil, IconSignature } from '@tabler/icons-react';
|
|
5
|
+
import type { Provenance, Encounter } from '@medplum/fhirtypes';
|
|
6
|
+
import { useMedplum, useMedplumProfile } from '@medplum/react';
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
import type { JSX } from 'react';
|
|
9
|
+
import { ChartNoteStatus } from '../../types/encounter';
|
|
10
|
+
import { createReference, formatDate } from '@medplum/core';
|
|
11
|
+
import { showErrorNotification } from '../../utils/notifications';
|
|
12
|
+
|
|
13
|
+
interface SignAddendumProps {
|
|
14
|
+
provenances: Provenance[];
|
|
15
|
+
chartNoteStatus: ChartNoteStatus;
|
|
16
|
+
encounter: Encounter;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ProvenanceDisplay {
|
|
20
|
+
practitionerName: string;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface AddendumDisplay {
|
|
25
|
+
authorName: string;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const SignAddendum = ({ provenances, chartNoteStatus, encounter }: SignAddendumProps): JSX.Element | null => {
|
|
31
|
+
const medplum = useMedplum();
|
|
32
|
+
const author = useMedplumProfile();
|
|
33
|
+
const authorReference = author ? createReference(author) : undefined;
|
|
34
|
+
const [provenanceDisplays, setProvenanceDisplays] = useState<ProvenanceDisplay[]>([]);
|
|
35
|
+
const [addendumDisplays, setAddendumDisplays] = useState<AddendumDisplay[]>([]);
|
|
36
|
+
const [addendumText, setAddendumText] = useState('');
|
|
37
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const loadProvenanceData = async (): Promise<void> => {
|
|
41
|
+
const displays: ProvenanceDisplay[] = provenances.map((prov) => ({
|
|
42
|
+
practitionerName: prov.agent?.[0]?.who?.display || 'Unknown Practitioner',
|
|
43
|
+
timestamp: formatDate(prov.recorded),
|
|
44
|
+
}));
|
|
45
|
+
setProvenanceDisplays(displays);
|
|
46
|
+
};
|
|
47
|
+
loadProvenanceData().catch(showErrorNotification);
|
|
48
|
+
}, [provenances, medplum]);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const loadAddendums = async (): Promise<void> => {
|
|
52
|
+
try {
|
|
53
|
+
const bundle = await medplum.searchResources('DocumentReference', {
|
|
54
|
+
encounter: `Encounter/${encounter.id}`,
|
|
55
|
+
type: '55107-7', // LOINC code for Addendum Document
|
|
56
|
+
_sort: '-date',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const displays: AddendumDisplay[] = bundle.map((doc) => {
|
|
60
|
+
const authorName = doc.author?.[0]?.display || 'Unknown Author';
|
|
61
|
+
const timestamp = doc.date ? formatDate(doc.date) : 'Unknown Date';
|
|
62
|
+
const encodedText = doc.content?.[0]?.attachment?.data;
|
|
63
|
+
const text = encodedText ? atob(encodedText) : '';
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
authorName,
|
|
67
|
+
timestamp,
|
|
68
|
+
text,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
setAddendumDisplays(displays);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
showErrorNotification(error);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (encounter.id) {
|
|
78
|
+
loadAddendums().catch(console.error);
|
|
79
|
+
}
|
|
80
|
+
}, [encounter.id, medplum]);
|
|
81
|
+
|
|
82
|
+
const handleAddAddendum = async (): Promise<void> => {
|
|
83
|
+
setIsSubmitting(true);
|
|
84
|
+
try {
|
|
85
|
+
const documentReference = await medplum.createResource({
|
|
86
|
+
resourceType: 'DocumentReference',
|
|
87
|
+
status: 'current',
|
|
88
|
+
type: {
|
|
89
|
+
coding: [
|
|
90
|
+
{
|
|
91
|
+
system: 'http://loinc.org',
|
|
92
|
+
code: '55107-7',
|
|
93
|
+
display: 'Addendum Document',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
subject: encounter.subject,
|
|
98
|
+
author: [
|
|
99
|
+
{
|
|
100
|
+
reference: authorReference?.reference,
|
|
101
|
+
display: authorReference?.display,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
context: {
|
|
105
|
+
encounter: [
|
|
106
|
+
{
|
|
107
|
+
reference: `Encounter/${encounter.id}`,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
date: new Date().toISOString(),
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
attachment: {
|
|
115
|
+
contentType: 'text/plain',
|
|
116
|
+
data: btoa(addendumText),
|
|
117
|
+
title: 'Addendum',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
setAddendumDisplays([
|
|
124
|
+
...addendumDisplays,
|
|
125
|
+
{
|
|
126
|
+
authorName: authorReference?.display || 'Unknown Author',
|
|
127
|
+
timestamp: formatDate(documentReference.date),
|
|
128
|
+
text: addendumText,
|
|
129
|
+
},
|
|
130
|
+
]);
|
|
131
|
+
setAddendumText('');
|
|
132
|
+
} catch (error) {
|
|
133
|
+
showErrorNotification(error);
|
|
134
|
+
} finally {
|
|
135
|
+
setIsSubmitting(false);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
if (provenanceDisplays.length === 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<Card withBorder shadow="sm">
|
|
145
|
+
<Stack gap="md">
|
|
146
|
+
{provenanceDisplays.map((display, index) => (
|
|
147
|
+
<Stack key={`prov-${index}`}>
|
|
148
|
+
<Group gap="sm">
|
|
149
|
+
{provenanceDisplays.length - 1 === index && chartNoteStatus === ChartNoteStatus.SignedAndLocked ? (
|
|
150
|
+
<IconLock size={20} />
|
|
151
|
+
) : (
|
|
152
|
+
<IconSignature size={20} />
|
|
153
|
+
)}
|
|
154
|
+
<Text fw={500}>
|
|
155
|
+
{provenanceDisplays.length - 1 === index && chartNoteStatus === ChartNoteStatus.SignedAndLocked
|
|
156
|
+
? 'Signed and Locked by '
|
|
157
|
+
: 'Signed by '}
|
|
158
|
+
{display.practitionerName}
|
|
159
|
+
</Text>
|
|
160
|
+
<Text c="dimmed" size="sm">
|
|
161
|
+
{display.timestamp}
|
|
162
|
+
</Text>
|
|
163
|
+
</Group>
|
|
164
|
+
<Divider />
|
|
165
|
+
</Stack>
|
|
166
|
+
))}
|
|
167
|
+
|
|
168
|
+
{addendumDisplays.map((addendum, index) => (
|
|
169
|
+
<Stack key={`addendum-${index}`}>
|
|
170
|
+
<Group gap="sm" align="flex-start">
|
|
171
|
+
<IconPencil size={20} />
|
|
172
|
+
<Stack gap="xs" style={{ flex: 1 }}>
|
|
173
|
+
<Group gap="sm">
|
|
174
|
+
<Text fw={500}>Addendum by {addendum.authorName}</Text>
|
|
175
|
+
<Text c="dimmed" size="sm">
|
|
176
|
+
{addendum.timestamp}
|
|
177
|
+
</Text>
|
|
178
|
+
</Group>
|
|
179
|
+
<Text size="sm" style={{ whiteSpace: 'pre-wrap' }}>
|
|
180
|
+
{addendum.text}
|
|
181
|
+
</Text>
|
|
182
|
+
</Stack>
|
|
183
|
+
</Group>
|
|
184
|
+
<Divider />
|
|
185
|
+
</Stack>
|
|
186
|
+
))}
|
|
187
|
+
|
|
188
|
+
<Text fw={600} mt="sm">
|
|
189
|
+
Add Addendum
|
|
190
|
+
</Text>
|
|
191
|
+
<Textarea
|
|
192
|
+
placeholder="Add an addendum to this Visit..."
|
|
193
|
+
value={addendumText}
|
|
194
|
+
onChange={(e) => setAddendumText(e.target.value)}
|
|
195
|
+
autosize
|
|
196
|
+
minRows={3}
|
|
197
|
+
maxRows={6}
|
|
198
|
+
/>
|
|
199
|
+
<Group justify="flex-end">
|
|
200
|
+
<Button
|
|
201
|
+
leftSection={<IconPencil size={16} />}
|
|
202
|
+
onClick={handleAddAddendum}
|
|
203
|
+
disabled={!addendumText.trim() || isSubmitting}
|
|
204
|
+
loading={isSubmitting}
|
|
205
|
+
>
|
|
206
|
+
Add Addendum
|
|
207
|
+
</Button>
|
|
208
|
+
</Group>
|
|
209
|
+
</Stack>
|
|
210
|
+
</Card>
|
|
211
|
+
);
|
|
212
|
+
};
|