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,133 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MantineProvider } from '@mantine/core';
|
|
4
|
+
import { MockClient } from '@medplum/mock';
|
|
5
|
+
import { MedplumProvider } from '@medplum/react';
|
|
6
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
7
|
+
import type { Task } from '@medplum/fhirtypes';
|
|
8
|
+
import { MemoryRouter, Routes, Route } from 'react-router';
|
|
9
|
+
import type { NavigateFunction } from 'react-router';
|
|
10
|
+
import * as reactRouter from 'react-router';
|
|
11
|
+
import { describe, expect, test, vi, beforeEach } from 'vitest';
|
|
12
|
+
import { TasksPage } from './TasksPage';
|
|
13
|
+
|
|
14
|
+
describe('TasksPage', () => {
|
|
15
|
+
let medplum: MockClient;
|
|
16
|
+
let navigateSpy: NavigateFunction;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
medplum = new MockClient();
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
navigateSpy = vi.fn() as NavigateFunction;
|
|
22
|
+
vi.spyOn(reactRouter, 'useNavigate').mockReturnValue(navigateSpy);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const setup = (initialPath = '/Task'): ReturnType<typeof render> => {
|
|
26
|
+
return render(
|
|
27
|
+
<MemoryRouter initialEntries={[initialPath]}>
|
|
28
|
+
<MedplumProvider medplum={medplum}>
|
|
29
|
+
<MantineProvider>
|
|
30
|
+
<Routes>
|
|
31
|
+
<Route path="/Task/:taskId?" element={<TasksPage />} />
|
|
32
|
+
</Routes>
|
|
33
|
+
</MantineProvider>
|
|
34
|
+
</MedplumProvider>
|
|
35
|
+
</MemoryRouter>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const mockTask: Task & { id: string } = {
|
|
40
|
+
resourceType: 'Task',
|
|
41
|
+
id: 'task-123',
|
|
42
|
+
status: 'in-progress',
|
|
43
|
+
intent: 'order',
|
|
44
|
+
code: { text: 'Test Task' },
|
|
45
|
+
authoredOn: '2023-01-01T12:00:00Z',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
test('renders TaskBoard component', async () => {
|
|
49
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
50
|
+
resourceType: 'Bundle',
|
|
51
|
+
type: 'searchset',
|
|
52
|
+
total: 0,
|
|
53
|
+
entry: [],
|
|
54
|
+
} as any);
|
|
55
|
+
|
|
56
|
+
setup('/Task?_sort=-_lastUpdated&_count=20&_total=accurate');
|
|
57
|
+
|
|
58
|
+
await waitFor(() => {
|
|
59
|
+
expect(screen.getByText('My Tasks')).toBeInTheDocument();
|
|
60
|
+
expect(screen.getByText('All Tasks')).toBeInTheDocument();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('passes taskId from URL params to TaskBoard', async () => {
|
|
65
|
+
await medplum.createResource(mockTask);
|
|
66
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
67
|
+
resourceType: 'Bundle',
|
|
68
|
+
type: 'searchset',
|
|
69
|
+
total: 1,
|
|
70
|
+
entry: [{ resource: mockTask }],
|
|
71
|
+
} as any);
|
|
72
|
+
vi.spyOn(medplum, 'readResource').mockResolvedValue(mockTask);
|
|
73
|
+
|
|
74
|
+
setup('/Task/task-123?_sort=-_lastUpdated&_count=20&_total=accurate');
|
|
75
|
+
|
|
76
|
+
await waitFor(() => {
|
|
77
|
+
expect(screen.getByText('My Tasks')).toBeInTheDocument();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Verify that TaskBoard receives the taskId by checking if readResource is called
|
|
81
|
+
await waitFor(
|
|
82
|
+
() => {
|
|
83
|
+
expect(medplum.readResource).toHaveBeenCalledWith('Task', 'task-123');
|
|
84
|
+
},
|
|
85
|
+
{ timeout: 3000 }
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('passes correct query prop to TaskBoard', async () => {
|
|
90
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
91
|
+
resourceType: 'Bundle',
|
|
92
|
+
type: 'searchset',
|
|
93
|
+
total: 0,
|
|
94
|
+
entry: [],
|
|
95
|
+
} as any);
|
|
96
|
+
|
|
97
|
+
setup('/Task?_sort=-_lastUpdated&_count=20&_total=accurate');
|
|
98
|
+
|
|
99
|
+
await waitFor(() => {
|
|
100
|
+
expect(screen.getByText('My Tasks')).toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Verify that search was called with the correct query parameter
|
|
104
|
+
await waitFor(() => {
|
|
105
|
+
expect(medplum.search).toHaveBeenCalled();
|
|
106
|
+
const searchCalls = vi.mocked(medplum.search).mock.calls;
|
|
107
|
+
expect(searchCalls.length).toBeGreaterThan(0);
|
|
108
|
+
// Check that the query includes the sort parameter
|
|
109
|
+
const queryString = searchCalls[0][1] as string;
|
|
110
|
+
expect(queryString).toContain('_sort=-_lastUpdated');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('passes undefined selectedTaskId when no taskId in URL', async () => {
|
|
115
|
+
vi.spyOn(medplum, 'search').mockResolvedValue({
|
|
116
|
+
resourceType: 'Bundle',
|
|
117
|
+
type: 'searchset',
|
|
118
|
+
total: 0,
|
|
119
|
+
entry: [],
|
|
120
|
+
} as any);
|
|
121
|
+
const readResourceSpy = vi.spyOn(medplum, 'readResource');
|
|
122
|
+
|
|
123
|
+
setup('/Task?_sort=-_lastUpdated&_count=20&_total=accurate');
|
|
124
|
+
|
|
125
|
+
await waitFor(() => {
|
|
126
|
+
expect(screen.getByText('My Tasks')).toBeInTheDocument();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
await waitFor(() => {
|
|
130
|
+
expect(readResourceSpy).not.toHaveBeenCalled();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
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 './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 TasksPage(): JSX.Element {
|
|
15
|
+
const { taskId } = useParams();
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
const location = useLocation();
|
|
18
|
+
const profile = useMedplumProfile();
|
|
19
|
+
const [parsedSearch, setParsedSearch] = useState<SearchRequest>();
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const { normalizedSearch, needsNavigation } = normalizeTaskSearch(location.pathname, location.search);
|
|
23
|
+
if (needsNavigation) {
|
|
24
|
+
navigate(`/Task${formatSearchQuery(normalizedSearch)}`)?.catch(console.error);
|
|
25
|
+
} else {
|
|
26
|
+
setParsedSearch(normalizedSearch);
|
|
27
|
+
}
|
|
28
|
+
}, [location, navigate]);
|
|
29
|
+
|
|
30
|
+
if (!parsedSearch) {
|
|
31
|
+
return <Loading />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const onNew = (task: Task): void => {
|
|
35
|
+
navigate(getTaskUri(task))?.catch(console.error);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getTaskUri = (task: Task): string => {
|
|
39
|
+
return `/Task/${task.id}${formatSearchQuery(parsedSearch)}`;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const onDelete = (_: Task): void => {
|
|
43
|
+
navigate(`/Task${formatSearchQuery(parsedSearch)}`)?.catch(console.error);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onChange = (search: SearchRequest): void => {
|
|
47
|
+
navigate(`/Task${formatSearchQuery(search)}`)?.catch(console.error);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const myTasksFilters = parsedSearch.filters?.filter((f) => f.code !== 'owner') || [];
|
|
51
|
+
if (profile) {
|
|
52
|
+
const profileRef = getReferenceString(profile);
|
|
53
|
+
if (profileRef) {
|
|
54
|
+
myTasksFilters.push({
|
|
55
|
+
code: 'owner',
|
|
56
|
+
operator: Operator.EQUALS,
|
|
57
|
+
value: profileRef,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const myTasksSearch: SearchRequest = {
|
|
62
|
+
...parsedSearch,
|
|
63
|
+
filters: myTasksFilters,
|
|
64
|
+
offset: 0,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const allTasksFilters = parsedSearch.filters?.filter((f) => f.code !== 'owner') || [];
|
|
68
|
+
const allTasksSearch: SearchRequest = {
|
|
69
|
+
...parsedSearch,
|
|
70
|
+
filters: allTasksFilters,
|
|
71
|
+
offset: 0,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const myTasksQuery = formatSearchQuery(myTasksSearch);
|
|
75
|
+
const allTasksQuery = formatSearchQuery(allTasksSearch);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className={classes.container}>
|
|
79
|
+
<TaskBoard
|
|
80
|
+
query={formatSearchQuery(parsedSearch).substring(1)}
|
|
81
|
+
selectedTaskId={taskId}
|
|
82
|
+
onDelete={onDelete}
|
|
83
|
+
onNew={onNew}
|
|
84
|
+
onChange={onChange}
|
|
85
|
+
getTaskUri={getTaskUri}
|
|
86
|
+
myTasksUri={myTasksQuery ? `/Task?${myTasksQuery.substring(1)}` : '/Task'}
|
|
87
|
+
allTasksUri={allTasksQuery ? `/Task?${allTasksQuery.substring(1)}` : '/Task'}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Sets up MantineProvider for all tests
|
|
5
|
+
// See: https://mantine.dev/guides/vitest/
|
|
6
|
+
|
|
7
|
+
import { MantineProvider } from '@mantine/core';
|
|
8
|
+
import { act, fireEvent, screen, render as testingLibraryRender, waitFor } from '@testing-library/react';
|
|
9
|
+
import type { RenderResult } from '@testing-library/react';
|
|
10
|
+
import userEvent from '@testing-library/user-event';
|
|
11
|
+
import type { UserEvent } from '@testing-library/user-event';
|
|
12
|
+
|
|
13
|
+
export type { RenderResult, UserEvent };
|
|
14
|
+
export { act, fireEvent, screen, userEvent, waitFor };
|
|
15
|
+
|
|
16
|
+
export function render(ui: React.ReactNode): RenderResult {
|
|
17
|
+
return testingLibraryRender(<>{ui}</>, {
|
|
18
|
+
wrapper: ({ children }: { children: React.ReactNode }) => <MantineProvider>{children}</MantineProvider>,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// See: https://mantine.dev/guides/vitest/
|
|
4
|
+
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
7
|
+
import { MemoryStorage, indexSearchParameterBundle, indexStructureDefinitionBundle } from '@medplum/core';
|
|
8
|
+
import { SEARCH_PARAMETER_BUNDLE_FILES, readJson } from '@medplum/definitions';
|
|
9
|
+
import type { Bundle, SearchParameter } from '@medplum/fhirtypes';
|
|
10
|
+
import { vi } from 'vitest';
|
|
11
|
+
|
|
12
|
+
const { getComputedStyle } = window;
|
|
13
|
+
window.getComputedStyle = (elt) => getComputedStyle(elt);
|
|
14
|
+
window.HTMLElement.prototype.scrollIntoView = () => {};
|
|
15
|
+
|
|
16
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
17
|
+
writable: true,
|
|
18
|
+
value: vi.fn().mockImplementation((query) => ({
|
|
19
|
+
matches: false,
|
|
20
|
+
media: query,
|
|
21
|
+
onchange: null,
|
|
22
|
+
addListener: vi.fn(),
|
|
23
|
+
removeListener: vi.fn(),
|
|
24
|
+
addEventListener: vi.fn(),
|
|
25
|
+
removeEventListener: vi.fn(),
|
|
26
|
+
dispatchEvent: vi.fn(),
|
|
27
|
+
})),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
class ResizeObserver {
|
|
31
|
+
observe(): void {}
|
|
32
|
+
unobserve(): void {}
|
|
33
|
+
disconnect(): void {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
window.ResizeObserver = ResizeObserver;
|
|
37
|
+
|
|
38
|
+
// jsdom does not implement scrollIntoView
|
|
39
|
+
// See: https://github.com/jsdom/jsdom/issues/1695#issuecomment-449931788
|
|
40
|
+
Element.prototype.scrollIntoView = vi.fn();
|
|
41
|
+
|
|
42
|
+
indexStructureDefinitionBundle(readJson('fhir/r4/profiles-types.json') as Bundle);
|
|
43
|
+
indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
|
|
44
|
+
indexStructureDefinitionBundle(readJson('fhir/r4/profiles-medplum.json') as Bundle);
|
|
45
|
+
for (const filename of SEARCH_PARAMETER_BUNDLE_FILES) {
|
|
46
|
+
indexSearchParameterBundle(readJson(filename) as Bundle<SearchParameter>);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Object.defineProperty(globalThis.window, 'sessionStorage', { value: new MemoryStorage() });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export interface Message {
|
|
5
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
6
|
+
content: string | null;
|
|
7
|
+
tool_calls?: any[];
|
|
8
|
+
tool_call_id?: string;
|
|
9
|
+
resources?: string[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import type { ChargeItem, ChargeItemDefinition, Encounter } from '@medplum/fhirtypes';
|
|
4
|
+
import { MockClient } from '@medplum/mock';
|
|
5
|
+
import { describe, expect, test, beforeEach, vi, afterEach } from 'vitest';
|
|
6
|
+
import * as chargeitemsModule from './chargeitems';
|
|
7
|
+
|
|
8
|
+
const { applyChargeItemDefinition, getChargeItemsForEncounter, calculateTotalPrice } = chargeitemsModule;
|
|
9
|
+
|
|
10
|
+
describe('chargeitems utils', () => {
|
|
11
|
+
let medplum: MockClient;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
medplum = new MockClient();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.restoreAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('applyChargeItemDefinition', () => {
|
|
22
|
+
const chargeItem: ChargeItem = {
|
|
23
|
+
resourceType: 'ChargeItem',
|
|
24
|
+
id: 'charge-1',
|
|
25
|
+
status: 'planned',
|
|
26
|
+
code: {
|
|
27
|
+
text: 'Test Charge Item',
|
|
28
|
+
coding: [{ system: 'http://example.com', code: '1234' }],
|
|
29
|
+
},
|
|
30
|
+
subject: { reference: 'Patient/patient-1' },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
test('returns original charge item when no definition canonical', async () => {
|
|
34
|
+
const result = await applyChargeItemDefinition(medplum as any, chargeItem);
|
|
35
|
+
expect(result).toBe(chargeItem);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('returns original charge item when definition not found', async () => {
|
|
39
|
+
const canonicalItem: ChargeItem = {
|
|
40
|
+
...chargeItem,
|
|
41
|
+
definitionCanonical: ['ChargeItemDefinition/123'],
|
|
42
|
+
};
|
|
43
|
+
const searchSpy = vi.spyOn(medplum, 'searchResources').mockResolvedValue([] as any);
|
|
44
|
+
|
|
45
|
+
const result = await applyChargeItemDefinition(medplum as any, canonicalItem);
|
|
46
|
+
|
|
47
|
+
expect(searchSpy).toHaveBeenCalledWith('ChargeItemDefinition', 'url=ChargeItemDefinition/123');
|
|
48
|
+
expect(result).toBe(canonicalItem);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('applies definition and returns updated charge item', async () => {
|
|
52
|
+
const canonicalItem: ChargeItem = {
|
|
53
|
+
...chargeItem,
|
|
54
|
+
definitionCanonical: ['ChargeItemDefinition/123'],
|
|
55
|
+
};
|
|
56
|
+
const definition: ChargeItemDefinition = {
|
|
57
|
+
resourceType: 'ChargeItemDefinition',
|
|
58
|
+
id: 'cid-1',
|
|
59
|
+
url: 'http://example.com/chargeitemdefinition/123',
|
|
60
|
+
status: 'active',
|
|
61
|
+
};
|
|
62
|
+
vi.spyOn(medplum, 'searchResources').mockResolvedValue([definition] as any);
|
|
63
|
+
const updatedChargeItem: ChargeItem = { ...canonicalItem, status: 'billable' };
|
|
64
|
+
const postSpy = vi.spyOn(medplum, 'post').mockResolvedValue(updatedChargeItem);
|
|
65
|
+
|
|
66
|
+
const result = await applyChargeItemDefinition(medplum as any, canonicalItem);
|
|
67
|
+
|
|
68
|
+
expect(postSpy).toHaveBeenCalledWith(
|
|
69
|
+
medplum.fhirUrl('ChargeItemDefinition', 'cid-1', '$apply'),
|
|
70
|
+
expect.objectContaining({
|
|
71
|
+
resourceType: 'Parameters',
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
expect(result).toEqual(updatedChargeItem);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('getChargeItemsForEncounter', () => {
|
|
79
|
+
test('returns empty array when encounter missing', async () => {
|
|
80
|
+
const result = await getChargeItemsForEncounter(medplum as any, undefined as unknown as Encounter);
|
|
81
|
+
expect(result).toEqual([]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('fetches charge items for encounter', async () => {
|
|
85
|
+
const encounter: Encounter = {
|
|
86
|
+
resourceType: 'Encounter',
|
|
87
|
+
id: 'enc-1',
|
|
88
|
+
status: 'finished',
|
|
89
|
+
class: { code: 'AMB', system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode' },
|
|
90
|
+
};
|
|
91
|
+
const chargeItem: ChargeItem = {
|
|
92
|
+
resourceType: 'ChargeItem',
|
|
93
|
+
id: 'charge-1',
|
|
94
|
+
status: 'billable',
|
|
95
|
+
code: {
|
|
96
|
+
text: 'Test Charge Item',
|
|
97
|
+
coding: [{ system: 'http://example.com', code: '1234' }],
|
|
98
|
+
},
|
|
99
|
+
subject: { reference: 'Patient/patient-1' },
|
|
100
|
+
};
|
|
101
|
+
vi.spyOn(medplum, 'searchResources').mockResolvedValue([chargeItem] as any);
|
|
102
|
+
|
|
103
|
+
const result = await getChargeItemsForEncounter(medplum as any, encounter);
|
|
104
|
+
|
|
105
|
+
expect(result).toEqual([chargeItem]);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('calculateTotalPrice', () => {
|
|
110
|
+
test('sums up price overrides', () => {
|
|
111
|
+
const items: ChargeItem[] = [
|
|
112
|
+
{
|
|
113
|
+
resourceType: 'ChargeItem',
|
|
114
|
+
id: '1',
|
|
115
|
+
status: 'billable',
|
|
116
|
+
priceOverride: { value: 10 },
|
|
117
|
+
code: { text: 'Test Charge Item', coding: [{ system: 'http://example.com', code: '1234' }] },
|
|
118
|
+
subject: { reference: 'Patient/patient-1' },
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
resourceType: 'ChargeItem',
|
|
122
|
+
id: '2',
|
|
123
|
+
status: 'billable',
|
|
124
|
+
priceOverride: { value: 15.5 },
|
|
125
|
+
code: { text: 'Test Charge Item', coding: [{ system: 'http://example.com', code: '1234' }] },
|
|
126
|
+
subject: { reference: 'Patient/patient-1' },
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
resourceType: 'ChargeItem',
|
|
130
|
+
id: '3',
|
|
131
|
+
status: 'billable',
|
|
132
|
+
priceOverride: { value: 20 },
|
|
133
|
+
code: { text: 'Test Charge Item', coding: [{ system: 'http://example.com', code: '1234' }] },
|
|
134
|
+
subject: { reference: 'Patient/patient-1' },
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
expect(calculateTotalPrice(items)).toBe(45.5);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { getReferenceString } from '@medplum/core';
|
|
4
|
+
import type { MedplumClient } from '@medplum/core';
|
|
5
|
+
import type { ChargeItem, Encounter } from '@medplum/fhirtypes';
|
|
6
|
+
|
|
7
|
+
export const CPT = 'http://www.ama-assn.org/go/cpt';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Standalone function to fetch and apply ChargeItemDefinition to charge item
|
|
11
|
+
* @param medplum - Medplum client instance
|
|
12
|
+
* @param chargeItem - Current charge item
|
|
13
|
+
* @returns Promise with updated charge items
|
|
14
|
+
*/
|
|
15
|
+
export async function applyChargeItemDefinition(medplum: MedplumClient, chargeItem: ChargeItem): Promise<ChargeItem> {
|
|
16
|
+
if (!chargeItem.definitionCanonical || chargeItem.definitionCanonical.length === 0) {
|
|
17
|
+
return chargeItem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const searchResult = await medplum.searchResources(
|
|
21
|
+
'ChargeItemDefinition',
|
|
22
|
+
`url=${chargeItem.definitionCanonical[0]}`
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (searchResult.length === 0) {
|
|
26
|
+
return chargeItem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const chargeItemDefinition = searchResult[0];
|
|
30
|
+
const applyResult = await medplum.post(medplum.fhirUrl('ChargeItemDefinition', chargeItemDefinition.id, '$apply'), {
|
|
31
|
+
resourceType: 'Parameters',
|
|
32
|
+
parameter: [
|
|
33
|
+
{
|
|
34
|
+
name: 'chargeItem',
|
|
35
|
+
valueReference: {
|
|
36
|
+
reference: getReferenceString(chargeItem),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return applyResult as ChargeItem;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function getChargeItemsForEncounter(medplum: MedplumClient, encounter: Encounter): Promise<ChargeItem[]> {
|
|
46
|
+
if (!encounter) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const chargeItems = await medplum.searchResources('ChargeItem', `context=${getReferenceString(encounter)}`);
|
|
51
|
+
const updatedChargeItems = await Promise.all(
|
|
52
|
+
chargeItems.map((chargeItem) => applyChargeItemDefinition(medplum, chargeItem))
|
|
53
|
+
);
|
|
54
|
+
return updatedChargeItems;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function calculateTotalPrice(items: ChargeItem[]): number {
|
|
58
|
+
return items.reduce((sum, item) => sum + (item.priceOverride?.value || 0), 0);
|
|
59
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { CPT } from '@medplum/core';
|
|
4
|
+
import type { ChargeItem, Claim, Coverage } from '@medplum/fhirtypes';
|
|
5
|
+
import { MockClient } from '@medplum/mock';
|
|
6
|
+
import { describe, expect, test, beforeEach, vi, afterEach } from 'vitest';
|
|
7
|
+
import * as coverageModule from './coverage';
|
|
8
|
+
import { createClaimFromEncounter, getCptChargeItems } from './claims';
|
|
9
|
+
|
|
10
|
+
describe('claims utils', () => {
|
|
11
|
+
let medplum: MockClient;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
medplum = new MockClient();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.restoreAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('getCptChargeItems', () => {
|
|
22
|
+
test('filters charge items to CPT codings and preserves modifiers', () => {
|
|
23
|
+
const cptItem: ChargeItem = {
|
|
24
|
+
resourceType: 'ChargeItem',
|
|
25
|
+
id: 'charge-1',
|
|
26
|
+
code: {
|
|
27
|
+
text: 'Test CPT',
|
|
28
|
+
coding: [
|
|
29
|
+
{ system: CPT, code: '1234' },
|
|
30
|
+
{ system: 'http://example.com', code: 'other' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
priceOverride: { value: 42 },
|
|
34
|
+
extension: [
|
|
35
|
+
{
|
|
36
|
+
url: 'http://hl7.org/fhir/StructureDefinition/chargeitem-modifier',
|
|
37
|
+
valueCodeableConcept: { coding: [{ code: '59' }] },
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
status: 'billable',
|
|
41
|
+
subject: { reference: 'Patient/patient-1' },
|
|
42
|
+
};
|
|
43
|
+
const nonCptItem: ChargeItem = {
|
|
44
|
+
resourceType: 'ChargeItem',
|
|
45
|
+
id: 'charge-2',
|
|
46
|
+
code: { coding: [{ system: 'http://example.com', code: 'not-cpt' }] },
|
|
47
|
+
status: 'billable',
|
|
48
|
+
subject: { reference: 'Patient/patient-1' },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const items = getCptChargeItems([cptItem, nonCptItem], { reference: 'Encounter/enc-1' });
|
|
52
|
+
|
|
53
|
+
expect(items).toHaveLength(1);
|
|
54
|
+
expect(items[0]).toEqual(
|
|
55
|
+
expect.objectContaining({
|
|
56
|
+
sequence: 1,
|
|
57
|
+
encounter: [{ reference: 'Encounter/enc-1' }],
|
|
58
|
+
productOrService: expect.objectContaining({
|
|
59
|
+
coding: [{ system: CPT, code: '1234' }],
|
|
60
|
+
text: 'Test CPT',
|
|
61
|
+
}),
|
|
62
|
+
modifier: [{ coding: [{ code: '59' }] }],
|
|
63
|
+
net: { value: 42 },
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('createClaimFromEncounter', () => {
|
|
70
|
+
const chargeItems: ChargeItem[] = [
|
|
71
|
+
{
|
|
72
|
+
resourceType: 'ChargeItem',
|
|
73
|
+
id: 'charge-1',
|
|
74
|
+
code: { coding: [{ system: CPT, code: '1111' }], text: 'Visit' },
|
|
75
|
+
priceOverride: { value: 25 },
|
|
76
|
+
status: 'billable',
|
|
77
|
+
subject: { reference: 'Patient/patient-1' },
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
test('creates claim using existing coverage', async () => {
|
|
82
|
+
const coverage: Coverage = {
|
|
83
|
+
resourceType: 'Coverage',
|
|
84
|
+
id: 'coverage-1',
|
|
85
|
+
status: 'active',
|
|
86
|
+
beneficiary: { reference: 'Patient/patient-1' },
|
|
87
|
+
payor: [{ reference: 'Organization/organization-1' }],
|
|
88
|
+
};
|
|
89
|
+
const claim: Claim = {
|
|
90
|
+
resourceType: 'Claim',
|
|
91
|
+
id: 'claim-1',
|
|
92
|
+
status: 'draft',
|
|
93
|
+
type: { coding: [{ code: 'professional' }] },
|
|
94
|
+
use: 'claim',
|
|
95
|
+
created: new Date().toISOString(),
|
|
96
|
+
patient: { reference: 'Patient/patient-1' },
|
|
97
|
+
provider: { reference: 'Practitioner/practitioner-1' },
|
|
98
|
+
priority: { coding: [{ code: 'normal' }] },
|
|
99
|
+
insurance: [{ sequence: 1, focal: true, coverage: { reference: 'Coverage/coverage-1' } }],
|
|
100
|
+
item: [
|
|
101
|
+
{
|
|
102
|
+
sequence: 1,
|
|
103
|
+
encounter: [{ reference: 'Encounter/encounter-1' }],
|
|
104
|
+
productOrService: { coding: [{ system: CPT, code: '1111' }], text: 'Visit' },
|
|
105
|
+
net: { value: 25 },
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
total: { value: 25 },
|
|
109
|
+
};
|
|
110
|
+
vi.spyOn(medplum, 'searchResources').mockResolvedValue([coverage] as any);
|
|
111
|
+
const createSpy = vi.spyOn(medplum, 'createResource').mockResolvedValue(claim as any);
|
|
112
|
+
|
|
113
|
+
const result = await createClaimFromEncounter(
|
|
114
|
+
medplum as any,
|
|
115
|
+
'patient-1',
|
|
116
|
+
'encounter-1',
|
|
117
|
+
'practitioner-1',
|
|
118
|
+
chargeItems
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(createSpy).toHaveBeenCalledWith(
|
|
122
|
+
expect.objectContaining({
|
|
123
|
+
insurance: [
|
|
124
|
+
expect.objectContaining({
|
|
125
|
+
coverage: { reference: 'Coverage/coverage-1' },
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
patient: { reference: 'Patient/patient-1' },
|
|
129
|
+
provider: expect.objectContaining({ reference: 'Practitioner/practitioner-1' }),
|
|
130
|
+
total: { value: 25 },
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
expect(result).toBe(claim);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('creates self-pay coverage when no coverage exists', async () => {
|
|
137
|
+
vi.spyOn(medplum, 'searchResources').mockResolvedValue([] as any);
|
|
138
|
+
const createdCoverage: Coverage = {
|
|
139
|
+
resourceType: 'Coverage',
|
|
140
|
+
id: 'coverage-self',
|
|
141
|
+
status: 'active',
|
|
142
|
+
beneficiary: { reference: 'Patient/patient-1' },
|
|
143
|
+
payor: [{ reference: 'Organization/organization-1' }],
|
|
144
|
+
};
|
|
145
|
+
const coverageSpy = vi.spyOn(coverageModule, 'createSelfPayCoverage').mockResolvedValue(createdCoverage);
|
|
146
|
+
vi.spyOn(medplum, 'createResource').mockResolvedValue({ resourceType: 'Claim' } as any);
|
|
147
|
+
|
|
148
|
+
await createClaimFromEncounter(medplum as any, 'patient-1', 'enc-1', 'prac-1', chargeItems);
|
|
149
|
+
|
|
150
|
+
expect(coverageSpy).toHaveBeenCalledWith(medplum, 'patient-1');
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|