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,286 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Stack, Text, Box, ScrollArea, Group, ActionIcon, CloseButton, Avatar, ThemeIcon } from '@mantine/core';
|
|
4
|
+
import type { JSX } from 'react';
|
|
5
|
+
import { useState, useRef, useEffect } from 'react';
|
|
6
|
+
import { useMedplum, useResource } from '@medplum/react';
|
|
7
|
+
import { IconRobot, IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand, IconPlus } from '@tabler/icons-react';
|
|
8
|
+
import { showErrorNotification } from '../../utils/notifications';
|
|
9
|
+
import { ResourceBox } from './ResourceBox';
|
|
10
|
+
import { ResourcePanel } from './ResourcePanel';
|
|
11
|
+
import type { Message } from '../../types/spaces';
|
|
12
|
+
import { loadConversationMessages } from '../../utils/spacePersistence';
|
|
13
|
+
import { processMessage } from '../../utils/spaceMessaging';
|
|
14
|
+
import { HistoryList } from './HistoryList';
|
|
15
|
+
import { ChatInput } from '../../pages/spaces/ChatInput';
|
|
16
|
+
import type { Communication, Reference } from '@medplum/fhirtypes';
|
|
17
|
+
import classes from './SpacesInbox.module.css';
|
|
18
|
+
import cx from 'clsx';
|
|
19
|
+
|
|
20
|
+
interface SpaceInboxProps {
|
|
21
|
+
topic: Communication | Reference<Communication> | undefined;
|
|
22
|
+
onNewTopic: (topic: Communication) => void;
|
|
23
|
+
onSelectedItem: (topic: Communication) => string;
|
|
24
|
+
onAdd?: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function SpacesInbox(props: SpaceInboxProps): JSX.Element {
|
|
28
|
+
const { topic: topicRef, onNewTopic, onSelectedItem, onAdd } = props;
|
|
29
|
+
const medplum = useMedplum();
|
|
30
|
+
const topic = useResource(topicRef);
|
|
31
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
32
|
+
const [input, setInput] = useState('');
|
|
33
|
+
const [loading, setLoading] = useState(false);
|
|
34
|
+
const [selectedModel, setSelectedModel] = useState('gpt-5');
|
|
35
|
+
const [hasStarted, setHasStarted] = useState(false);
|
|
36
|
+
const [currentFhirRequest, setCurrentFhirRequest] = useState<string | undefined>();
|
|
37
|
+
const [currentTopicId, setCurrentTopicId] = useState<string | undefined>(topic?.id);
|
|
38
|
+
const [sidebarOpen, setSidebarOpen] = useState(false);
|
|
39
|
+
const [refreshKey, setRefreshKey] = useState(0);
|
|
40
|
+
const [selectedResource, setSelectedResource] = useState<string | undefined>();
|
|
41
|
+
const scrollViewportRef = useRef<HTMLDivElement>(null);
|
|
42
|
+
const isSendingRef = useRef(false);
|
|
43
|
+
|
|
44
|
+
// Load conversation when topic changes
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const topicId = topic?.id;
|
|
47
|
+
if (topicId) {
|
|
48
|
+
if (isSendingRef.current) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const loadTopic = async (): Promise<void> => {
|
|
52
|
+
try {
|
|
53
|
+
setLoading(true);
|
|
54
|
+
const loadedMessages = await loadConversationMessages(medplum, topicId);
|
|
55
|
+
setMessages([...loadedMessages]);
|
|
56
|
+
setCurrentTopicId(topicId);
|
|
57
|
+
setHasStarted(true);
|
|
58
|
+
setSelectedResource(undefined);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
showErrorNotification(error);
|
|
61
|
+
} finally {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
loadTopic().catch(showErrorNotification);
|
|
66
|
+
} else {
|
|
67
|
+
setMessages([]);
|
|
68
|
+
setHasStarted(false);
|
|
69
|
+
setCurrentTopicId(undefined);
|
|
70
|
+
setSelectedResource(undefined);
|
|
71
|
+
}
|
|
72
|
+
}, [topic, medplum]);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const viewport = scrollViewportRef.current;
|
|
76
|
+
if (viewport && hasStarted) {
|
|
77
|
+
viewport.scrollTo({
|
|
78
|
+
top: viewport.scrollHeight,
|
|
79
|
+
behavior: 'smooth',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, [messages, hasStarted]);
|
|
83
|
+
|
|
84
|
+
const handleSelectTopic = async (selectedTopicId: string): Promise<void> => {
|
|
85
|
+
try {
|
|
86
|
+
setLoading(true);
|
|
87
|
+
const loadedMessages = await loadConversationMessages(medplum, selectedTopicId);
|
|
88
|
+
setMessages([...loadedMessages]);
|
|
89
|
+
setCurrentTopicId(selectedTopicId);
|
|
90
|
+
setHasStarted(true);
|
|
91
|
+
setSelectedResource(undefined);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
showErrorNotification(error);
|
|
94
|
+
} finally {
|
|
95
|
+
setLoading(false);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleSend = async (): Promise<void> => {
|
|
100
|
+
if (!input.trim()) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const isFirstMessage = !hasStarted;
|
|
105
|
+
if (isFirstMessage) {
|
|
106
|
+
setHasStarted(true);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const userMessage: Message = { role: 'user', content: input };
|
|
110
|
+
const currentMessages = [...messages, userMessage];
|
|
111
|
+
setMessages(currentMessages);
|
|
112
|
+
setInput('');
|
|
113
|
+
setCurrentFhirRequest(undefined);
|
|
114
|
+
setLoading(true);
|
|
115
|
+
isSendingRef.current = true;
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
const result = await processMessage({
|
|
119
|
+
medplum,
|
|
120
|
+
input,
|
|
121
|
+
userMessage,
|
|
122
|
+
currentMessages,
|
|
123
|
+
currentTopicId,
|
|
124
|
+
selectedModel,
|
|
125
|
+
isFirstMessage,
|
|
126
|
+
setCurrentTopicId,
|
|
127
|
+
setRefreshKey,
|
|
128
|
+
setCurrentFhirRequest,
|
|
129
|
+
onNewTopic,
|
|
130
|
+
});
|
|
131
|
+
setMessages(result.updatedMessages);
|
|
132
|
+
} catch (error: unknown) {
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
134
|
+
setMessages([...currentMessages, { role: 'assistant', content: `Error: ${errorMessage}` }]);
|
|
135
|
+
} finally {
|
|
136
|
+
isSendingRef.current = false;
|
|
137
|
+
setLoading(false);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const handleKeyDown = (e: React.KeyboardEvent): void => {
|
|
142
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
handleSend().catch((error) => showErrorNotification(error));
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const visibleMessages = messages.filter(
|
|
149
|
+
(m) => m.role !== 'system' && m.role !== 'tool' && !(m.role === 'assistant' && m.tool_calls)
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<>
|
|
154
|
+
{/* Sidebar */}
|
|
155
|
+
<Box className={classes.sidebar} style={{ width: sidebarOpen ? 280 : 0, opacity: sidebarOpen ? 1 : 0 }}>
|
|
156
|
+
<div className={classes.sidebarHeader}>
|
|
157
|
+
<Text className={classes.sidebarTitle}>Conversations</Text>
|
|
158
|
+
<ActionIcon variant="subtle" color="gray" onClick={() => setSidebarOpen(false)}>
|
|
159
|
+
<IconLayoutSidebarLeftCollapse size={18} />
|
|
160
|
+
</ActionIcon>
|
|
161
|
+
</div>
|
|
162
|
+
<div className={classes.sidebarContent}>
|
|
163
|
+
<HistoryList
|
|
164
|
+
key={refreshKey}
|
|
165
|
+
currentTopicId={currentTopicId}
|
|
166
|
+
onSelectTopic={handleSelectTopic}
|
|
167
|
+
onSelectedItem={onSelectedItem}
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
</Box>
|
|
171
|
+
|
|
172
|
+
{/* Main Chat Area */}
|
|
173
|
+
<div className={classes.chatContainer}>
|
|
174
|
+
<div className={classes.chatHeader}>
|
|
175
|
+
<div>
|
|
176
|
+
{!sidebarOpen && (
|
|
177
|
+
<ActionIcon variant="subtle" color="gray" onClick={() => setSidebarOpen(true)} mr="md">
|
|
178
|
+
<IconLayoutSidebarLeftExpand size={16} />
|
|
179
|
+
</ActionIcon>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
{onAdd && (
|
|
183
|
+
<ActionIcon variant="subtle" color="gray" size="sm" onClick={onAdd} aria-label="New conversation">
|
|
184
|
+
<IconPlus size={16} />
|
|
185
|
+
</ActionIcon>
|
|
186
|
+
)}
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div className={classes.messagesArea}>
|
|
190
|
+
{!hasStarted ? (
|
|
191
|
+
<div className={classes.emptyState}>
|
|
192
|
+
<ThemeIcon size={64} radius="xl" variant="light" color="gray" className={classes.emptyStateIcon}>
|
|
193
|
+
<IconRobot size={32} />
|
|
194
|
+
</ThemeIcon>
|
|
195
|
+
<Text size="xl" fw={500} mb="sm">
|
|
196
|
+
How can I help you today?
|
|
197
|
+
</Text>
|
|
198
|
+
<Text c="dimmed" size="sm" maw={400}>
|
|
199
|
+
I can help you search for patients, create resources, or answer clinical questions.
|
|
200
|
+
</Text>
|
|
201
|
+
</div>
|
|
202
|
+
) : (
|
|
203
|
+
<ScrollArea style={{ flex: 1 }} offsetScrollbars viewportRef={scrollViewportRef}>
|
|
204
|
+
<Stack gap="xl" p="xs">
|
|
205
|
+
{visibleMessages.map((message, index) => (
|
|
206
|
+
<div
|
|
207
|
+
key={index}
|
|
208
|
+
className={cx(
|
|
209
|
+
classes.messageWrapper,
|
|
210
|
+
message.role === 'user' ? classes.userMessage : classes.assistantMessage
|
|
211
|
+
)}
|
|
212
|
+
>
|
|
213
|
+
<Group align="flex-start" gap="sm" mb={4}>
|
|
214
|
+
{message.role === 'assistant' && (
|
|
215
|
+
<Avatar radius="xl" size="sm" color="blue">
|
|
216
|
+
<IconRobot size={14} />
|
|
217
|
+
</Avatar>
|
|
218
|
+
)}
|
|
219
|
+
<Text fw={600} size="sm" c="dimmed">
|
|
220
|
+
{message.role === 'user' ? 'You' : 'AI Assistant'}
|
|
221
|
+
</Text>
|
|
222
|
+
</Group>
|
|
223
|
+
<div className={classes.messageContent}>
|
|
224
|
+
<Text style={{ whiteSpace: 'pre-wrap' }}>{message.content}</Text>
|
|
225
|
+
</div>
|
|
226
|
+
{message.resources && message.resources.length > 0 && (
|
|
227
|
+
<Stack gap="xs" mt="sm" w={300} ml={message.role === 'assistant' ? 0 : 'auto'}>
|
|
228
|
+
{message.resources.map((resourceRef, idx) => (
|
|
229
|
+
<ResourceBox key={idx} resourceReference={resourceRef} onClick={setSelectedResource} />
|
|
230
|
+
))}
|
|
231
|
+
</Stack>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
))}
|
|
235
|
+
{loading && (
|
|
236
|
+
<div className={cx(classes.messageWrapper, classes.assistantMessage)}>
|
|
237
|
+
<Group align="center" gap="sm" wrap="nowrap">
|
|
238
|
+
<Avatar radius="xl" size="sm" color="blue">
|
|
239
|
+
<IconRobot size={14} />
|
|
240
|
+
</Avatar>
|
|
241
|
+
<Box style={{ flex: 1, minWidth: 0 }}>
|
|
242
|
+
<Text size="sm" c="dimmed" fs="italic" truncate>
|
|
243
|
+
{currentFhirRequest ? `Executing ${currentFhirRequest}...` : 'Thinking...'}
|
|
244
|
+
</Text>
|
|
245
|
+
</Box>
|
|
246
|
+
</Group>
|
|
247
|
+
</div>
|
|
248
|
+
)}
|
|
249
|
+
</Stack>
|
|
250
|
+
</ScrollArea>
|
|
251
|
+
)}
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div className={classes.inputArea}>
|
|
255
|
+
<div className={classes.inputWrapper}>
|
|
256
|
+
<ChatInput
|
|
257
|
+
input={input}
|
|
258
|
+
onInputChange={setInput}
|
|
259
|
+
onKeyDown={handleKeyDown}
|
|
260
|
+
onSend={handleSend}
|
|
261
|
+
loading={loading}
|
|
262
|
+
selectedModel={selectedModel}
|
|
263
|
+
onModelChange={setSelectedModel}
|
|
264
|
+
backgroundColor="transparent"
|
|
265
|
+
/>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
{/* Resource Panel */}
|
|
271
|
+
{selectedResource && (
|
|
272
|
+
<div className={classes.resourcePanel}>
|
|
273
|
+
<div className={classes.resourceHeader}>
|
|
274
|
+
<Text fw={600} size="sm">
|
|
275
|
+
Resource Details
|
|
276
|
+
</Text>
|
|
277
|
+
<CloseButton onClick={() => setSelectedResource(undefined)} />
|
|
278
|
+
</div>
|
|
279
|
+
<ScrollArea style={{ flex: 1 }} p="md">
|
|
280
|
+
<ResourcePanel key={selectedResource} resource={{ reference: selectedResource }} />
|
|
281
|
+
</ScrollArea>
|
|
282
|
+
</div>
|
|
283
|
+
)}
|
|
284
|
+
</>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Box, Button, Divider, Grid, Modal, Stack, Text, TextInput, Textarea } from '@mantine/core';
|
|
4
|
+
import { notifications } from '@mantine/notifications';
|
|
5
|
+
import { createReference, normalizeErrorString } from '@medplum/core';
|
|
6
|
+
import type { CodeableConcept, Media, Patient, Practitioner, Reference, Task } from '@medplum/fhirtypes';
|
|
7
|
+
import {
|
|
8
|
+
CodeableConceptInput,
|
|
9
|
+
CodeInput,
|
|
10
|
+
DateTimeInput,
|
|
11
|
+
ReferenceInput,
|
|
12
|
+
ResourceInput,
|
|
13
|
+
useMedplum,
|
|
14
|
+
useMedplumProfile,
|
|
15
|
+
} from '@medplum/react';
|
|
16
|
+
import { IconCircleCheck, IconCircleOff } from '@tabler/icons-react';
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
import type { JSX } from 'react';
|
|
19
|
+
import { TaskFileUpload } from './TaskFileUpload';
|
|
20
|
+
import { TaskAttachmentList } from './TaskAttachmentList';
|
|
21
|
+
import { TASK_ATTACHMENT_INPUT_TYPE } from '../../../lib/constants';
|
|
22
|
+
|
|
23
|
+
export interface NewTaskModalProps {
|
|
24
|
+
opened: boolean;
|
|
25
|
+
onClose: () => void;
|
|
26
|
+
onTaskCreated?: (task: Task) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function NewTaskModal(props: NewTaskModalProps): JSX.Element {
|
|
30
|
+
const { opened, onClose, onTaskCreated } = props;
|
|
31
|
+
const medplum = useMedplum();
|
|
32
|
+
const profile = useMedplumProfile();
|
|
33
|
+
|
|
34
|
+
const [title, setTitle] = useState<string>('');
|
|
35
|
+
const [description, setDescription] = useState<string>('');
|
|
36
|
+
const [intent, setIntent] = useState<string>('order');
|
|
37
|
+
|
|
38
|
+
const [status, setStatus] = useState<Task['status']>('draft');
|
|
39
|
+
const [priority, setPriority] = useState<string>('routine');
|
|
40
|
+
const [assignee, setAssignee] = useState<Reference<Practitioner> | undefined>();
|
|
41
|
+
const [dueDate, setDueDate] = useState<string | undefined>();
|
|
42
|
+
const [taskPatient, setTaskPatient] = useState<Reference<Patient> | undefined>();
|
|
43
|
+
|
|
44
|
+
const [taskCode, setTaskCode] = useState<CodeableConcept | undefined>();
|
|
45
|
+
const [performerType, setPerformerType] = useState<CodeableConcept | undefined>();
|
|
46
|
+
|
|
47
|
+
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
|
48
|
+
const [attachments, setAttachments] = useState<Media[]>([]);
|
|
49
|
+
|
|
50
|
+
const handleSubmit = async (): Promise<void> => {
|
|
51
|
+
if (!title.trim()) {
|
|
52
|
+
notifications.show({
|
|
53
|
+
color: 'red',
|
|
54
|
+
icon: <IconCircleOff />,
|
|
55
|
+
title: 'Validation Error',
|
|
56
|
+
message: 'Task title is required',
|
|
57
|
+
});
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setIsSubmitting(true);
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const newTask: Task = {
|
|
65
|
+
resourceType: 'Task',
|
|
66
|
+
status: status,
|
|
67
|
+
intent: intent as Task['intent'],
|
|
68
|
+
priority: priority as Task['priority'],
|
|
69
|
+
code: taskCode || {
|
|
70
|
+
text: title,
|
|
71
|
+
},
|
|
72
|
+
description: description.trim() || undefined,
|
|
73
|
+
for: taskPatient,
|
|
74
|
+
authoredOn: new Date().toISOString(),
|
|
75
|
+
requester: profile ? createReference(profile) : undefined,
|
|
76
|
+
owner: assignee,
|
|
77
|
+
performerType: performerType ? [performerType] : undefined,
|
|
78
|
+
restriction: dueDate
|
|
79
|
+
? {
|
|
80
|
+
period: {
|
|
81
|
+
end: dueDate,
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
: undefined,
|
|
85
|
+
// Add attachments to task.input
|
|
86
|
+
input: attachments.map((media) => ({
|
|
87
|
+
type: {
|
|
88
|
+
coding: [TASK_ATTACHMENT_INPUT_TYPE],
|
|
89
|
+
text: 'File Attachment',
|
|
90
|
+
},
|
|
91
|
+
valueReference: createReference(media),
|
|
92
|
+
})),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const createdTask = await medplum.createResource(newTask);
|
|
96
|
+
|
|
97
|
+
notifications.show({
|
|
98
|
+
icon: <IconCircleCheck />,
|
|
99
|
+
title: 'Success',
|
|
100
|
+
message: 'Task created successfully',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
onTaskCreated?.(createdTask);
|
|
104
|
+
handleClose();
|
|
105
|
+
} catch (error) {
|
|
106
|
+
notifications.show({
|
|
107
|
+
color: 'red',
|
|
108
|
+
icon: <IconCircleOff />,
|
|
109
|
+
title: 'Error',
|
|
110
|
+
message: normalizeErrorString(error),
|
|
111
|
+
});
|
|
112
|
+
} finally {
|
|
113
|
+
setIsSubmitting(false);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleClose = (): void => {
|
|
118
|
+
setTitle('');
|
|
119
|
+
setDescription('');
|
|
120
|
+
setIntent('order');
|
|
121
|
+
setStatus('draft');
|
|
122
|
+
setPriority('routine');
|
|
123
|
+
setAssignee(undefined);
|
|
124
|
+
setDueDate(undefined);
|
|
125
|
+
setTaskCode(undefined);
|
|
126
|
+
setPerformerType(undefined);
|
|
127
|
+
setTaskPatient(undefined);
|
|
128
|
+
setAttachments([]);
|
|
129
|
+
setIsSubmitting(false);
|
|
130
|
+
onClose();
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const handleFileUploaded = (media: Media): void => {
|
|
134
|
+
setAttachments((prev) => [...prev, media]);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const handleRemoveAttachment = (mediaId: string): void => {
|
|
138
|
+
setAttachments((prev) => prev.filter((m) => m.id !== mediaId));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Modal
|
|
143
|
+
opened={opened}
|
|
144
|
+
onClose={handleClose}
|
|
145
|
+
size="xl"
|
|
146
|
+
title="Create New Task"
|
|
147
|
+
styles={{
|
|
148
|
+
body: {
|
|
149
|
+
padding: 0,
|
|
150
|
+
height: '70vh',
|
|
151
|
+
},
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<Stack h="100%" justify="space-between" gap={0}>
|
|
155
|
+
<Box flex={1} miw={0}>
|
|
156
|
+
<Grid p="md" h="100%">
|
|
157
|
+
<Grid.Col span={6} pr="lg">
|
|
158
|
+
<Stack gap="md" h="100%">
|
|
159
|
+
<Box>
|
|
160
|
+
<Stack gap="sm">
|
|
161
|
+
<TextInput
|
|
162
|
+
label="Title"
|
|
163
|
+
placeholder="Enter task title"
|
|
164
|
+
value={title}
|
|
165
|
+
onChange={(event) => setTitle(event.currentTarget.value)}
|
|
166
|
+
required
|
|
167
|
+
size="md"
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
<Textarea
|
|
171
|
+
label="Description"
|
|
172
|
+
placeholder="Enter task description (optional)"
|
|
173
|
+
value={description}
|
|
174
|
+
onChange={(event) => setDescription(event.currentTarget.value)}
|
|
175
|
+
minRows={4}
|
|
176
|
+
autosize
|
|
177
|
+
maxRows={8}
|
|
178
|
+
/>
|
|
179
|
+
|
|
180
|
+
<Box>
|
|
181
|
+
<Text size="sm" fw={500} mb="xs">
|
|
182
|
+
Attachments
|
|
183
|
+
</Text>
|
|
184
|
+
<Stack gap="sm">
|
|
185
|
+
<TaskFileUpload onFileUploaded={handleFileUploaded} disabled={isSubmitting} />
|
|
186
|
+
{attachments.length > 0 && (
|
|
187
|
+
<TaskAttachmentList attachments={attachments} onRemove={handleRemoveAttachment} />
|
|
188
|
+
)}
|
|
189
|
+
</Stack>
|
|
190
|
+
</Box>
|
|
191
|
+
</Stack>
|
|
192
|
+
</Box>
|
|
193
|
+
</Stack>
|
|
194
|
+
</Grid.Col>
|
|
195
|
+
|
|
196
|
+
<Grid.Col span={6} pl="lg">
|
|
197
|
+
<Stack gap="md" h="100%">
|
|
198
|
+
<Box>
|
|
199
|
+
<Stack gap="sm">
|
|
200
|
+
<CodeInput
|
|
201
|
+
name="status"
|
|
202
|
+
label="Status"
|
|
203
|
+
binding="http://hl7.org/fhir/ValueSet/task-status"
|
|
204
|
+
maxValues={1}
|
|
205
|
+
defaultValue={status}
|
|
206
|
+
onChange={(value) => setStatus((value as Task['status']) || 'draft')}
|
|
207
|
+
required
|
|
208
|
+
/>
|
|
209
|
+
|
|
210
|
+
<DateTimeInput
|
|
211
|
+
name="dueDate"
|
|
212
|
+
label="Due Date"
|
|
213
|
+
placeholder="Select due date (optional)"
|
|
214
|
+
defaultValue={dueDate}
|
|
215
|
+
onChange={setDueDate}
|
|
216
|
+
/>
|
|
217
|
+
|
|
218
|
+
<CodeInput
|
|
219
|
+
name="priority"
|
|
220
|
+
label="Priority"
|
|
221
|
+
binding="http://hl7.org/fhir/ValueSet/request-priority"
|
|
222
|
+
maxValues={1}
|
|
223
|
+
defaultValue={priority}
|
|
224
|
+
onChange={(value) => setPriority(value || 'routine')}
|
|
225
|
+
/>
|
|
226
|
+
|
|
227
|
+
<ResourceInput<Patient>
|
|
228
|
+
resourceType="Patient"
|
|
229
|
+
name="patient"
|
|
230
|
+
label="Patient"
|
|
231
|
+
placeholder="Select patient"
|
|
232
|
+
defaultValue={taskPatient}
|
|
233
|
+
onChange={(value: Patient | undefined) =>
|
|
234
|
+
setTaskPatient(value ? createReference(value) : undefined)
|
|
235
|
+
}
|
|
236
|
+
/>
|
|
237
|
+
|
|
238
|
+
<Box>
|
|
239
|
+
<Text size="sm" fw={500} mb="xs">
|
|
240
|
+
Assignee
|
|
241
|
+
</Text>
|
|
242
|
+
<ReferenceInput
|
|
243
|
+
name="assignee"
|
|
244
|
+
targetTypes={['Practitioner', 'Organization']}
|
|
245
|
+
placeholder="Select assignee (optional)"
|
|
246
|
+
onChange={(value) => setAssignee(value as Reference<Practitioner>)}
|
|
247
|
+
/>
|
|
248
|
+
</Box>
|
|
249
|
+
|
|
250
|
+
<CodeableConceptInput
|
|
251
|
+
name="performerType"
|
|
252
|
+
label="Performer Type"
|
|
253
|
+
placeholder="Select performer type (optional)"
|
|
254
|
+
binding="http://hl7.org/fhir/ValueSet/performer-role"
|
|
255
|
+
maxValues={1}
|
|
256
|
+
onChange={(value) => setPerformerType(value as CodeableConcept)}
|
|
257
|
+
path={'Task.performerType'}
|
|
258
|
+
/>
|
|
259
|
+
</Stack>
|
|
260
|
+
</Box>
|
|
261
|
+
</Stack>
|
|
262
|
+
</Grid.Col>
|
|
263
|
+
</Grid>
|
|
264
|
+
</Box>
|
|
265
|
+
|
|
266
|
+
<Stack p="md">
|
|
267
|
+
<Divider />
|
|
268
|
+
<Button variant="filled" w="100%" onClick={handleSubmit} loading={isSubmitting}>
|
|
269
|
+
Create Task
|
|
270
|
+
</Button>
|
|
271
|
+
</Stack>
|
|
272
|
+
</Stack>
|
|
273
|
+
</Modal>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useMedplum } from '@medplum/react';
|
|
2
|
+
import type { Media } from '@medplum/fhirtypes';
|
|
3
|
+
import { Badge, Group, ActionIcon, Text, Stack, Paper, Tooltip } from '@mantine/core';
|
|
4
|
+
import { IconDownload, IconX, IconFile, IconFileText, IconPhoto } from '@tabler/icons-react';
|
|
5
|
+
import type { JSX } from 'react';
|
|
6
|
+
|
|
7
|
+
export interface TaskAttachmentListProps {
|
|
8
|
+
attachments: Media[];
|
|
9
|
+
onRemove?: (mediaId: string) => void;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Displays a list of file attachments for a task.
|
|
15
|
+
* Allows downloading and optionally removing attachments.
|
|
16
|
+
*/
|
|
17
|
+
export function TaskAttachmentList({ attachments, onRemove, readOnly = false }: TaskAttachmentListProps): JSX.Element {
|
|
18
|
+
const medplum = useMedplum();
|
|
19
|
+
|
|
20
|
+
if (attachments.length === 0) {
|
|
21
|
+
return (
|
|
22
|
+
<Text size="sm" color="dimmed">
|
|
23
|
+
No attachments
|
|
24
|
+
</Text>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const getFileIcon = (contentType?: string): JSX.Element => {
|
|
29
|
+
if (!contentType) {
|
|
30
|
+
return <IconFile size={20} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (contentType.startsWith('image/')) {
|
|
34
|
+
return <IconPhoto size={20} />;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (contentType.includes('pdf') || contentType.includes('document') || contentType.includes('text')) {
|
|
38
|
+
return <IconFileText size={20} />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return <IconFile size={20} />;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const formatFileSize = (url?: string): string => {
|
|
45
|
+
// In a real implementation, you might fetch the binary to get the actual size
|
|
46
|
+
// For now, we'll just return a placeholder
|
|
47
|
+
return 'Unknown size';
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleDownload = async (media: Media): Promise<void> => {
|
|
51
|
+
if (!media.content?.url) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Extract Binary ID from the URL (format: "Binary/{id}")
|
|
57
|
+
const binaryId = media.content.url.split('/')[1];
|
|
58
|
+
const binary = await medplum.readResource('Binary', binaryId);
|
|
59
|
+
|
|
60
|
+
// Create a download link using Binary resource URL
|
|
61
|
+
const url = `${medplum.getBaseUrl()}fhir/R4/Binary/${binaryId}`;
|
|
62
|
+
const link = document.createElement('a');
|
|
63
|
+
link.href = url;
|
|
64
|
+
link.download = media.content.title || 'download';
|
|
65
|
+
link.target = '_blank';
|
|
66
|
+
document.body.appendChild(link);
|
|
67
|
+
link.click();
|
|
68
|
+
document.body.removeChild(link);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Failed to download file:', error);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleRemove = (mediaId: string): void => {
|
|
75
|
+
if (onRemove) {
|
|
76
|
+
onRemove(mediaId);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Stack gap="xs">
|
|
82
|
+
{attachments.map((media) => (
|
|
83
|
+
<Paper key={media.id} p="sm" withBorder>
|
|
84
|
+
<Group justify="space-between">
|
|
85
|
+
<Group gap="sm" style={{ flex: 1, minWidth: 0 }}>
|
|
86
|
+
{getFileIcon(media.content?.contentType)}
|
|
87
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
88
|
+
<Text size="sm" fw={500} truncate="end" title={media.content?.title || 'Untitled'}>
|
|
89
|
+
{media.content?.title || 'Untitled'}
|
|
90
|
+
</Text>
|
|
91
|
+
<Group gap="xs">
|
|
92
|
+
<Badge size="xs" variant="outline">
|
|
93
|
+
{media.content?.contentType || 'Unknown type'}
|
|
94
|
+
</Badge>
|
|
95
|
+
<Text size="xs" color="dimmed">
|
|
96
|
+
{formatFileSize(media.content?.url)}
|
|
97
|
+
</Text>
|
|
98
|
+
</Group>
|
|
99
|
+
</div>
|
|
100
|
+
</Group>
|
|
101
|
+
|
|
102
|
+
<Group gap="xs" style={{ flexShrink: 0 }}>
|
|
103
|
+
<Tooltip label="Download file">
|
|
104
|
+
<ActionIcon
|
|
105
|
+
variant="subtle"
|
|
106
|
+
color="blue"
|
|
107
|
+
onClick={() => handleDownload(media)}
|
|
108
|
+
aria-label="Download file"
|
|
109
|
+
>
|
|
110
|
+
<IconDownload size={18} />
|
|
111
|
+
</ActionIcon>
|
|
112
|
+
</Tooltip>
|
|
113
|
+
|
|
114
|
+
{!readOnly && onRemove && (
|
|
115
|
+
<Tooltip label="Remove attachment">
|
|
116
|
+
<ActionIcon
|
|
117
|
+
variant="subtle"
|
|
118
|
+
color="red"
|
|
119
|
+
onClick={() => handleRemove(media.id as string)}
|
|
120
|
+
aria-label="Remove attachment"
|
|
121
|
+
>
|
|
122
|
+
<IconX size={18} />
|
|
123
|
+
</ActionIcon>
|
|
124
|
+
</Tooltip>
|
|
125
|
+
)}
|
|
126
|
+
</Group>
|
|
127
|
+
</Group>
|
|
128
|
+
</Paper>
|
|
129
|
+
))}
|
|
130
|
+
</Stack>
|
|
131
|
+
);
|
|
132
|
+
}
|