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,185 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MantineProvider } from '@mantine/core';
|
|
4
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
|
+
import { MedplumProvider } from '@medplum/react';
|
|
6
|
+
import { MockClient } from '@medplum/mock';
|
|
7
|
+
import { MemoryRouter, Routes, Route } from 'react-router';
|
|
8
|
+
import { describe, expect, test, beforeEach, vi } from 'vitest';
|
|
9
|
+
import { TasksTab } from './TasksTab';
|
|
10
|
+
import type { Task } from '@medplum/fhirtypes';
|
|
11
|
+
|
|
12
|
+
describe('TasksTab', () => {
|
|
13
|
+
let medplum: MockClient;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
medplum = new MockClient();
|
|
17
|
+
vi.clearAllMocks();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const setup = (initialPath = '/Patient/patient-123/Task'): ReturnType<typeof render> => {
|
|
21
|
+
return render(
|
|
22
|
+
<MemoryRouter initialEntries={[initialPath]}>
|
|
23
|
+
<MedplumProvider medplum={medplum}>
|
|
24
|
+
<MantineProvider>
|
|
25
|
+
<Routes>
|
|
26
|
+
<Route path="/Patient/:patientId/Task" element={<TasksTab />} />
|
|
27
|
+
<Route path="/Patient/:patientId/Task/:taskId" element={<TasksTab />} />
|
|
28
|
+
</Routes>
|
|
29
|
+
</MantineProvider>
|
|
30
|
+
</MedplumProvider>
|
|
31
|
+
</MemoryRouter>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const mockTask: Task = {
|
|
36
|
+
resourceType: 'Task',
|
|
37
|
+
id: 'task-123',
|
|
38
|
+
status: 'in-progress',
|
|
39
|
+
intent: 'order',
|
|
40
|
+
code: { text: 'Test Task' },
|
|
41
|
+
authoredOn: '2023-01-01T12:00:00Z',
|
|
42
|
+
for: { reference: 'Patient/patient-123' },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
test('renders TaskBoard component', async () => {
|
|
46
|
+
setup();
|
|
47
|
+
|
|
48
|
+
await waitFor(() => {
|
|
49
|
+
expect(screen.getByText('My Tasks')).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('filters tasks by patient ID', async () => {
|
|
54
|
+
await medplum.createResource(mockTask);
|
|
55
|
+
const searchSpy = vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
56
|
+
resourceType: 'Bundle',
|
|
57
|
+
type: 'searchset',
|
|
58
|
+
total: 1,
|
|
59
|
+
entry: [{ resource: mockTask }],
|
|
60
|
+
} as any);
|
|
61
|
+
|
|
62
|
+
setup();
|
|
63
|
+
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(searchSpy).toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const callArgs = searchSpy.mock.calls[0];
|
|
69
|
+
expect(callArgs[0]).toBe('Task');
|
|
70
|
+
expect(callArgs[1]).toContain('patient=Patient%2Fpatient-123');
|
|
71
|
+
expect(callArgs[1]).toContain('_sort=-_lastUpdated');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('displays tasks for the patient', async () => {
|
|
75
|
+
await medplum.createResource(mockTask);
|
|
76
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
77
|
+
resourceType: 'Bundle',
|
|
78
|
+
type: 'searchset',
|
|
79
|
+
total: 1,
|
|
80
|
+
entry: [{ resource: mockTask }],
|
|
81
|
+
} as any);
|
|
82
|
+
|
|
83
|
+
setup();
|
|
84
|
+
|
|
85
|
+
await waitFor(
|
|
86
|
+
() => {
|
|
87
|
+
expect(screen.getByText('Test Task')).toBeInTheDocument();
|
|
88
|
+
},
|
|
89
|
+
{ timeout: 3000 }
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('uses patient-specific URL for task navigation', async () => {
|
|
94
|
+
await medplum.createResource(mockTask);
|
|
95
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
96
|
+
resourceType: 'Bundle',
|
|
97
|
+
type: 'searchset',
|
|
98
|
+
total: 1,
|
|
99
|
+
entry: [{ resource: mockTask }],
|
|
100
|
+
} as any);
|
|
101
|
+
|
|
102
|
+
setup();
|
|
103
|
+
|
|
104
|
+
await waitFor(() => {
|
|
105
|
+
expect(screen.getByText('Test Task')).toBeInTheDocument();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const links = screen.getAllByRole('link');
|
|
109
|
+
const taskLink = links.find((link) => link.getAttribute('href')?.includes('/Patient/patient-123/Task/task-123'));
|
|
110
|
+
expect(taskLink).toBeDefined();
|
|
111
|
+
// getTaskUri includes the query string, so check that href starts with the expected path
|
|
112
|
+
expect(taskLink?.getAttribute('href')).toMatch(/^\/Patient\/patient-123\/Task\/task-123/);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('handles selected task from URL parameter', async () => {
|
|
116
|
+
await medplum.createResource(mockTask);
|
|
117
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
118
|
+
resourceType: 'Bundle',
|
|
119
|
+
type: 'searchset',
|
|
120
|
+
total: 1,
|
|
121
|
+
entry: [{ resource: mockTask }],
|
|
122
|
+
} as any);
|
|
123
|
+
vi.spyOn(medplum, 'readResource').mockResolvedValue(mockTask as any);
|
|
124
|
+
|
|
125
|
+
setup(
|
|
126
|
+
'/Patient/patient-123/Task/task-123?_sort=-_lastUpdated&_count=20&_total=accurate&patient=Patient%2Fpatient-123'
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
await waitFor(
|
|
130
|
+
() => {
|
|
131
|
+
expect(medplum.readResource).toHaveBeenCalledWith('Task', 'task-123');
|
|
132
|
+
},
|
|
133
|
+
{ timeout: 3000 }
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
await waitFor(
|
|
137
|
+
() => {
|
|
138
|
+
expect(screen.getByText('Properties')).toBeInTheDocument();
|
|
139
|
+
},
|
|
140
|
+
{ timeout: 3000 }
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('handles different patient IDs', async () => {
|
|
145
|
+
const taskForDifferentPatient: Task = {
|
|
146
|
+
...mockTask,
|
|
147
|
+
id: 'task-456',
|
|
148
|
+
for: { reference: 'Patient/patient-456' },
|
|
149
|
+
};
|
|
150
|
+
await medplum.createResource(taskForDifferentPatient);
|
|
151
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
152
|
+
resourceType: 'Bundle',
|
|
153
|
+
type: 'searchset',
|
|
154
|
+
total: 1,
|
|
155
|
+
entry: [{ resource: taskForDifferentPatient }],
|
|
156
|
+
} as any);
|
|
157
|
+
|
|
158
|
+
setup('/Patient/patient-456/Task?_sort=-_lastUpdated&_count=20&_total=accurate&patient=Patient%2Fpatient-456');
|
|
159
|
+
|
|
160
|
+
await waitFor(() => {
|
|
161
|
+
expect(screen.getByText('Test Task')).toBeInTheDocument();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const links = screen.getAllByRole('link');
|
|
165
|
+
const taskLink = links.find((link) => link.getAttribute('href')?.includes('/Patient/patient-456/Task/task-456'));
|
|
166
|
+
expect(taskLink).toBeDefined();
|
|
167
|
+
// getTaskUri includes the query string, so check that href starts with the expected path
|
|
168
|
+
expect(taskLink?.getAttribute('href')).toMatch(/^\/Patient\/patient-456\/Task\/task-456/);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('shows empty state when no tasks found', async () => {
|
|
172
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
173
|
+
resourceType: 'Bundle',
|
|
174
|
+
type: 'searchset',
|
|
175
|
+
total: 0,
|
|
176
|
+
entry: [],
|
|
177
|
+
} as any);
|
|
178
|
+
|
|
179
|
+
setup();
|
|
180
|
+
|
|
181
|
+
await waitFor(() => {
|
|
182
|
+
expect(screen.getByText('No tasks available.')).toBeInTheDocument();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import type { Task } from '@medplum/fhirtypes';
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import type { JSX } from 'react';
|
|
6
|
+
import { useLocation, useNavigate, useParams } from 'react-router';
|
|
7
|
+
import classes from '../tasks/TasksPage.module.css';
|
|
8
|
+
import { TaskBoard } from '../../components/tasks/TaskBoard';
|
|
9
|
+
import { formatSearchQuery, getReferenceString, Operator } from '@medplum/core';
|
|
10
|
+
import type { SearchRequest } from '@medplum/core';
|
|
11
|
+
import { Loading, useMedplumProfile } from '@medplum/react';
|
|
12
|
+
import { normalizeTaskSearch } from '../../utils/task-search';
|
|
13
|
+
|
|
14
|
+
export function TasksTab(): JSX.Element {
|
|
15
|
+
const { patientId, taskId } = useParams();
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
const location = useLocation();
|
|
18
|
+
const profile = useMedplumProfile();
|
|
19
|
+
const [parsedSearch, setParsedSearch] = useState<SearchRequest>();
|
|
20
|
+
const patientRef = `Patient/${patientId}`;
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const { normalizedSearch, needsNavigation } = normalizeTaskSearch(location.pathname, location.search, {
|
|
24
|
+
additionalFilters: [
|
|
25
|
+
{
|
|
26
|
+
code: 'patient',
|
|
27
|
+
operator: Operator.EQUALS,
|
|
28
|
+
value: patientRef,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (needsNavigation) {
|
|
34
|
+
navigate(`/Patient/${patientId}/Task${formatSearchQuery(normalizedSearch)}`)?.catch(console.error);
|
|
35
|
+
} else {
|
|
36
|
+
setParsedSearch(normalizedSearch);
|
|
37
|
+
}
|
|
38
|
+
}, [location, navigate, patientId, patientRef]);
|
|
39
|
+
|
|
40
|
+
if (!parsedSearch) {
|
|
41
|
+
return <Loading />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const onNew = (task: Task): void => {
|
|
45
|
+
navigate(getTaskUri(task))?.catch(console.error);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getTaskUri = (task: Task): string => {
|
|
49
|
+
return `/Patient/${patientId}/Task/${task.id}${formatSearchQuery(parsedSearch)}`;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const onDelete = (_: Task): void => {
|
|
53
|
+
navigate(`/Patient/${patientId}/Task${formatSearchQuery(parsedSearch)}`)?.catch(console.error);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const onChange = (search: SearchRequest): void => {
|
|
57
|
+
navigate(`/Patient/${patientId}/Task${formatSearchQuery(search)}`)?.catch(console.error);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const myTasksFilters = parsedSearch.filters?.filter((f) => f.code !== 'owner' && f.code !== 'patient') || [];
|
|
61
|
+
myTasksFilters.push({
|
|
62
|
+
code: 'patient',
|
|
63
|
+
operator: Operator.EQUALS,
|
|
64
|
+
value: patientRef,
|
|
65
|
+
});
|
|
66
|
+
if (profile) {
|
|
67
|
+
const profileRef = getReferenceString(profile);
|
|
68
|
+
if (profileRef) {
|
|
69
|
+
myTasksFilters.push({
|
|
70
|
+
code: 'owner',
|
|
71
|
+
operator: Operator.EQUALS,
|
|
72
|
+
value: profileRef,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const myTasksSearch: SearchRequest = {
|
|
77
|
+
...parsedSearch,
|
|
78
|
+
filters: myTasksFilters,
|
|
79
|
+
offset: 0,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const allTasksFilters = parsedSearch.filters?.filter((f) => f.code !== 'owner' && f.code !== 'patient') || [];
|
|
83
|
+
allTasksFilters.push({
|
|
84
|
+
code: 'patient',
|
|
85
|
+
operator: Operator.EQUALS,
|
|
86
|
+
value: patientRef,
|
|
87
|
+
});
|
|
88
|
+
const allTasksSearch: SearchRequest = {
|
|
89
|
+
...parsedSearch,
|
|
90
|
+
filters: allTasksFilters,
|
|
91
|
+
offset: 0,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const myTasksQuery = formatSearchQuery(myTasksSearch);
|
|
95
|
+
const allTasksQuery = formatSearchQuery(allTasksSearch);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div className={classes.container}>
|
|
99
|
+
<TaskBoard
|
|
100
|
+
query={formatSearchQuery(parsedSearch).substring(1)}
|
|
101
|
+
selectedTaskId={taskId}
|
|
102
|
+
onDelete={onDelete}
|
|
103
|
+
onNew={onNew}
|
|
104
|
+
onChange={onChange}
|
|
105
|
+
getTaskUri={getTaskUri}
|
|
106
|
+
myTasksUri={
|
|
107
|
+
myTasksQuery ? `/Patient/${patientId}/Task?${myTasksQuery.substring(1)}` : `/Patient/${patientId}/Task`
|
|
108
|
+
}
|
|
109
|
+
allTasksUri={
|
|
110
|
+
allTasksQuery ? `/Patient/${patientId}/Task?${allTasksQuery.substring(1)}` : `/Patient/${patientId}/Task`
|
|
111
|
+
}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Loader } from '@mantine/core';
|
|
4
|
+
import { PatientTimeline } from '@medplum/react';
|
|
5
|
+
import type { JSX } from 'react';
|
|
6
|
+
import { usePatient } from '../../hooks/usePatient';
|
|
7
|
+
|
|
8
|
+
export function TimelineTab(): JSX.Element {
|
|
9
|
+
const patient = usePatient();
|
|
10
|
+
if (!patient) {
|
|
11
|
+
return <Loader />;
|
|
12
|
+
}
|
|
13
|
+
return <PatientTimeline patient={patient} />;
|
|
14
|
+
}
|
package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceCreatePage.test.tsx
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
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 { act, render, screen, waitFor } from '@testing-library/react';
|
|
8
|
+
import userEvent from '@testing-library/user-event';
|
|
9
|
+
import { MemoryRouter, Routes, Route } from 'react-router';
|
|
10
|
+
import * as reactRouter from 'react-router';
|
|
11
|
+
import { describe, expect, test, vi, beforeEach } from 'vitest';
|
|
12
|
+
import { ResourceCreatePage } from './ResourceCreatePage';
|
|
13
|
+
|
|
14
|
+
describe('ResourceCreatePage', () => {
|
|
15
|
+
let medplum: MockClient;
|
|
16
|
+
let navigateSpy: ReturnType<typeof vi.fn>;
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
medplum = new MockClient();
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
navigateSpy = vi.fn();
|
|
22
|
+
vi.spyOn(reactRouter, 'useNavigate').mockReturnValue(navigateSpy as any);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const setup = async (url: string): Promise<void> => {
|
|
26
|
+
await act(async () => {
|
|
27
|
+
render(
|
|
28
|
+
<MemoryRouter initialEntries={[url]}>
|
|
29
|
+
<MedplumProvider medplum={medplum}>
|
|
30
|
+
<MantineProvider>
|
|
31
|
+
<Notifications />
|
|
32
|
+
<Routes>
|
|
33
|
+
<Route path="/:resourceType/new" element={<ResourceCreatePage />} />
|
|
34
|
+
<Route path="/Patient/:patientId/:resourceType/new" element={<ResourceCreatePage />} />
|
|
35
|
+
</Routes>
|
|
36
|
+
</MantineProvider>
|
|
37
|
+
</MedplumProvider>
|
|
38
|
+
</MemoryRouter>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
test('Renders new Practitioner form page', async () => {
|
|
44
|
+
await setup('/Practitioner/new');
|
|
45
|
+
|
|
46
|
+
await waitFor(() => {
|
|
47
|
+
expect(screen.getByText('New Practitioner')).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('Renders new Task form page', async () => {
|
|
52
|
+
await setup('/Task/new');
|
|
53
|
+
|
|
54
|
+
await waitFor(() => {
|
|
55
|
+
expect(screen.getByText('New Task')).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Form submit creates new Practitioner', async () => {
|
|
60
|
+
const user = userEvent.setup();
|
|
61
|
+
await setup('/Practitioner/new');
|
|
62
|
+
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
expect(screen.getByText('New Practitioner')).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Find the submit button (ResourceForm typically has a "Create" or "OK" button)
|
|
68
|
+
const submitButton = await screen.findByRole('button', { name: /create|ok|submit/i });
|
|
69
|
+
expect(submitButton).toBeInTheDocument();
|
|
70
|
+
|
|
71
|
+
// Mock createResource to return a result
|
|
72
|
+
const createdPractitioner = {
|
|
73
|
+
resourceType: 'Practitioner',
|
|
74
|
+
id: 'practitioner-123',
|
|
75
|
+
};
|
|
76
|
+
vi.spyOn(medplum, 'createResource').mockResolvedValue(createdPractitioner as any);
|
|
77
|
+
|
|
78
|
+
await user.click(submitButton);
|
|
79
|
+
|
|
80
|
+
await waitFor(() => {
|
|
81
|
+
expect(medplum.createResource).toHaveBeenCalled();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('Form submit creates new Task and navigates', async () => {
|
|
86
|
+
const user = userEvent.setup();
|
|
87
|
+
await setup('/Task/new');
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(screen.getByText('New Task')).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const submitButton = await screen.findByRole('button', { name: /create|ok|submit/i });
|
|
94
|
+
expect(submitButton).toBeInTheDocument();
|
|
95
|
+
|
|
96
|
+
const createdTask = {
|
|
97
|
+
resourceType: 'Task',
|
|
98
|
+
id: 'task-123',
|
|
99
|
+
};
|
|
100
|
+
vi.spyOn(medplum, 'createResource').mockResolvedValue(createdTask as any);
|
|
101
|
+
|
|
102
|
+
await user.click(submitButton);
|
|
103
|
+
|
|
104
|
+
await waitFor(
|
|
105
|
+
() => {
|
|
106
|
+
expect(medplum.createResource).toHaveBeenCalled();
|
|
107
|
+
expect(navigateSpy).toHaveBeenCalledWith('/Task/task-123');
|
|
108
|
+
},
|
|
109
|
+
{ timeout: 3000 }
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('Form submit creates new Task with patient context and navigates', async () => {
|
|
114
|
+
const user = userEvent.setup();
|
|
115
|
+
await setup(`/Patient/${HomerSimpson.id}/Task/new`);
|
|
116
|
+
|
|
117
|
+
await waitFor(() => {
|
|
118
|
+
expect(screen.getByText('New Task')).toBeInTheDocument();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const submitButton = await screen.findByRole('button', { name: /create|ok|submit/i });
|
|
122
|
+
expect(submitButton).toBeInTheDocument();
|
|
123
|
+
|
|
124
|
+
const createdTask = {
|
|
125
|
+
resourceType: 'Task',
|
|
126
|
+
id: 'task-123',
|
|
127
|
+
};
|
|
128
|
+
vi.spyOn(medplum, 'createResource').mockResolvedValue(createdTask as any);
|
|
129
|
+
|
|
130
|
+
await user.click(submitButton);
|
|
131
|
+
|
|
132
|
+
await waitFor(
|
|
133
|
+
() => {
|
|
134
|
+
expect(medplum.createResource).toHaveBeenCalled();
|
|
135
|
+
// Should navigate with patient path prepended - check that navigate was called
|
|
136
|
+
expect(navigateSpy).toHaveBeenCalled();
|
|
137
|
+
// The path should include the patient ID
|
|
138
|
+
const navigateCalls = navigateSpy.mock.calls;
|
|
139
|
+
expect(navigateCalls.length).toBeGreaterThan(0);
|
|
140
|
+
const lastCall = navigateCalls[navigateCalls.length - 1][0];
|
|
141
|
+
expect(String(lastCall)).toContain(`Patient/${HomerSimpson.id}`);
|
|
142
|
+
expect(String(lastCall)).toContain('Task/task-123');
|
|
143
|
+
},
|
|
144
|
+
{ timeout: 3000 }
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('Handles form submission error', async () => {
|
|
149
|
+
const user = userEvent.setup();
|
|
150
|
+
await setup('/Practitioner/new');
|
|
151
|
+
|
|
152
|
+
await waitFor(() => {
|
|
153
|
+
expect(screen.getByText('New Practitioner')).toBeInTheDocument();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const submitButton = await screen.findByRole('button', { name: /create|ok|submit/i });
|
|
157
|
+
expect(submitButton).toBeInTheDocument();
|
|
158
|
+
|
|
159
|
+
const error = new Error('Failed to create resource');
|
|
160
|
+
vi.spyOn(medplum, 'createResource').mockRejectedValue(error);
|
|
161
|
+
|
|
162
|
+
await user.click(submitButton);
|
|
163
|
+
|
|
164
|
+
await waitFor(() => {
|
|
165
|
+
expect(medplum.createResource).toHaveBeenCalled();
|
|
166
|
+
// Should show error notification
|
|
167
|
+
expect(screen.getByText(/failed to create resource/i)).toBeInTheDocument();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Stack, Text } from '@mantine/core';
|
|
4
|
+
import { showNotification } from '@mantine/notifications';
|
|
5
|
+
import { createReference, normalizeErrorString, normalizeOperationOutcome } from '@medplum/core';
|
|
6
|
+
import type { OperationOutcome, Patient, Resource, ResourceType } from '@medplum/fhirtypes';
|
|
7
|
+
import { Document, Loading, useMedplum } from '@medplum/react';
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
9
|
+
import type { JSX } from 'react';
|
|
10
|
+
import { useNavigate, useParams } from 'react-router';
|
|
11
|
+
import { ResourceFormWithRequiredProfile } from '../../components/ResourceFormWithRequiredProfile';
|
|
12
|
+
import { usePatient } from '../../hooks/usePatient';
|
|
13
|
+
import { prependPatientPath } from '../patient/PatientPage.utils';
|
|
14
|
+
import { RESOURCE_PROFILE_URLS } from './utils';
|
|
15
|
+
|
|
16
|
+
const PatientReferencesElements: Partial<Record<ResourceType, string[]>> = {
|
|
17
|
+
Task: ['for'],
|
|
18
|
+
MedicationRequest: ['subject'],
|
|
19
|
+
ServiceRequest: ['subject'],
|
|
20
|
+
Device: ['patient'],
|
|
21
|
+
DiagnosticReport: ['subject'],
|
|
22
|
+
DocumentReference: ['subject'],
|
|
23
|
+
Appointment: ['participant.actor'],
|
|
24
|
+
CarePlan: ['subject'],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function getDefaultValue(resourceType: ResourceType, patient: Patient | undefined): Partial<Resource> {
|
|
28
|
+
const dv = { resourceType } as Partial<Resource>;
|
|
29
|
+
const refKeys = PatientReferencesElements[resourceType];
|
|
30
|
+
if (patient && refKeys) {
|
|
31
|
+
for (const key of refKeys) {
|
|
32
|
+
const keyParts = key.split('.');
|
|
33
|
+
if (keyParts.length === 1) {
|
|
34
|
+
(dv as any)[key] = createReference(patient);
|
|
35
|
+
} else if (keyParts.length === 2) {
|
|
36
|
+
const [first, second] = keyParts;
|
|
37
|
+
(dv as any)[first] = [{ [second]: createReference(patient) }];
|
|
38
|
+
} else {
|
|
39
|
+
throw new Error('Can only process keys with one or two parts');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return dv;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getResourceTypeFromPath(pathname: string): ResourceType | undefined {
|
|
48
|
+
const pathParts = pathname.split('/');
|
|
49
|
+
if (pathParts.length >= 3 && pathParts[2] === 'new') {
|
|
50
|
+
return pathParts[1] as ResourceType;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function ResourceCreatePage(): JSX.Element {
|
|
57
|
+
const medplum = useMedplum();
|
|
58
|
+
const [outcome, setOutcome] = useState<OperationOutcome | undefined>();
|
|
59
|
+
const patient = usePatient({ ignoreMissingPatientId: true, setOutcome });
|
|
60
|
+
const navigate = useNavigate();
|
|
61
|
+
const params = useParams() as { patientId?: string; resourceType?: ResourceType };
|
|
62
|
+
const resourceType = params.resourceType || getResourceTypeFromPath(location.pathname);
|
|
63
|
+
const patientId = params.patientId;
|
|
64
|
+
const [loadingPatient, setLoadingPatient] = useState(Boolean(patientId));
|
|
65
|
+
const [defaultValue, setDefaultValue] = useState<Partial<Resource>>(() => {
|
|
66
|
+
if (!resourceType) {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
return getDefaultValue(resourceType, patient);
|
|
70
|
+
});
|
|
71
|
+
const profileUrl = resourceType && RESOURCE_PROFILE_URLS[resourceType];
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (patient && resourceType) {
|
|
75
|
+
setDefaultValue(getDefaultValue(resourceType, patient));
|
|
76
|
+
}
|
|
77
|
+
setLoadingPatient(false);
|
|
78
|
+
}, [patient, resourceType]);
|
|
79
|
+
|
|
80
|
+
const handleSubmit = (newResource: Resource): void => {
|
|
81
|
+
if (outcome) {
|
|
82
|
+
setOutcome(undefined);
|
|
83
|
+
}
|
|
84
|
+
medplum
|
|
85
|
+
.createResource(newResource)
|
|
86
|
+
.then((result) => navigate(prependPatientPath(patient, '/' + result.resourceType + '/' + result.id)))
|
|
87
|
+
.catch((err) => {
|
|
88
|
+
if (setOutcome) {
|
|
89
|
+
setOutcome(normalizeOperationOutcome(err));
|
|
90
|
+
}
|
|
91
|
+
showNotification({
|
|
92
|
+
color: 'red',
|
|
93
|
+
message: normalizeErrorString(err),
|
|
94
|
+
autoClose: false,
|
|
95
|
+
styles: { description: { whiteSpace: 'pre-line' } },
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (loadingPatient) {
|
|
101
|
+
return <Loading />;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Document shadow="xs">
|
|
106
|
+
<Stack>
|
|
107
|
+
<Text fw={500}>New {resourceType}</Text>
|
|
108
|
+
<ResourceFormWithRequiredProfile
|
|
109
|
+
defaultValue={defaultValue}
|
|
110
|
+
onSubmit={handleSubmit}
|
|
111
|
+
outcome={outcome}
|
|
112
|
+
profileUrl={profileUrl}
|
|
113
|
+
/>
|
|
114
|
+
</Stack>
|
|
115
|
+
</Document>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Stack, Title } from '@mantine/core';
|
|
4
|
+
import { getDisplayString } from '@medplum/core';
|
|
5
|
+
import { ResourceTable, useResource } from '@medplum/react';
|
|
6
|
+
import type { JSX } from 'react';
|
|
7
|
+
import { useParams } from 'react-router';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This is an example of a generic "Resource Display" page.
|
|
11
|
+
* It uses the Medplum `<ResourceTable>` component to display a resource.
|
|
12
|
+
* @returns A React component that displays a resource.
|
|
13
|
+
*/
|
|
14
|
+
export function ResourceDetailPage(): JSX.Element | null {
|
|
15
|
+
const { resourceType, id } = useParams();
|
|
16
|
+
const resource = useResource({ reference: resourceType + '/' + id });
|
|
17
|
+
|
|
18
|
+
if (!resource) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Stack>
|
|
24
|
+
<Title>{getDisplayString(resource)}</Title>
|
|
25
|
+
<ResourceTable key={`${resourceType}/${id}`} value={resource} />
|
|
26
|
+
</Stack>
|
|
27
|
+
);
|
|
28
|
+
}
|