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.
Files changed (284) hide show
  1. package/README.md +5 -0
  2. package/dist/examples/vintasend-medplum-example/.env.example +11 -0
  3. package/dist/examples/vintasend-medplum-example/IMPLEMENTATION_PLAN_FILE_ATTACHMENTS.md +597 -0
  4. package/dist/examples/vintasend-medplum-example/README.md +190 -0
  5. package/dist/examples/vintasend-medplum-example/TUTORIAL_EMAIL_NOTIFICATIONS.md +2596 -0
  6. package/dist/examples/vintasend-medplum-example/bots/handlers/send-pending-notifications-bot.ts +39 -0
  7. package/dist/examples/vintasend-medplum-example/bots/handlers/send-task-assignment-email.ts +41 -0
  8. package/dist/examples/vintasend-medplum-example/bots/handlers/task-due-soon-notification-bot.ts +86 -0
  9. package/dist/examples/vintasend-medplum-example/bots/index.ts +53 -0
  10. package/dist/examples/vintasend-medplum-example/bots/services/emails/schedule-task-due-soon-email.ts +84 -0
  11. package/dist/examples/vintasend-medplum-example/bots/services/emails/send-task-assignment-email.test.ts +388 -0
  12. package/dist/examples/vintasend-medplum-example/bots/services/emails/send-task-assignment-email.ts +113 -0
  13. package/dist/examples/vintasend-medplum-example/bots/shared/task-due-soon-helpers.ts +115 -0
  14. package/dist/examples/vintasend-medplum-example/bots/task-assignment-bot.ts +41 -0
  15. package/dist/examples/vintasend-medplum-example/compiled-notification-templates.json +6 -0
  16. package/dist/examples/vintasend-medplum-example/esbuild-script.mjs +71 -0
  17. package/dist/examples/vintasend-medplum-example/index.html +14 -0
  18. package/dist/examples/vintasend-medplum-example/lib/constants.ts +32 -0
  19. package/dist/examples/vintasend-medplum-example/lib/extensions.ts +1 -0
  20. package/dist/examples/vintasend-medplum-example/lib/file-upload.test.ts +389 -0
  21. package/dist/examples/vintasend-medplum-example/lib/file-upload.ts +222 -0
  22. package/dist/examples/vintasend-medplum-example/lib/medplum-singleton.ts +18 -0
  23. package/dist/examples/vintasend-medplum-example/lib/notification-service.test.ts +293 -0
  24. package/dist/examples/vintasend-medplum-example/lib/notification-service.ts +284 -0
  25. package/dist/examples/vintasend-medplum-example/lib/patients.ts +20 -0
  26. package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-assignment/body.html.pug +37 -0
  27. package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-assignment/subject.txt.pug +4 -0
  28. package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-due-soon/body.html.pug +34 -0
  29. package/dist/examples/vintasend-medplum-example/notification-templates/emails/task-due-soon/subject.txt.pug +4 -0
  30. package/dist/examples/vintasend-medplum-example/package.json +75 -0
  31. package/dist/examples/vintasend-medplum-example/plugins/gql-plugin.mjs +31 -0
  32. package/dist/examples/vintasend-medplum-example/postcss.config.mjs +21 -0
  33. package/dist/examples/vintasend-medplum-example/public/favicon.ico +0 -0
  34. package/dist/examples/vintasend-medplum-example/public/img/integrations/acuity.png +0 -0
  35. package/dist/examples/vintasend-medplum-example/public/img/integrations/auth0.png +0 -0
  36. package/dist/examples/vintasend-medplum-example/public/img/integrations/azure.png +0 -0
  37. package/dist/examples/vintasend-medplum-example/public/img/integrations/calcom.png +0 -0
  38. package/dist/examples/vintasend-medplum-example/public/img/integrations/candid.png +0 -0
  39. package/dist/examples/vintasend-medplum-example/public/img/integrations/claude.png +0 -0
  40. package/dist/examples/vintasend-medplum-example/public/img/integrations/datadog.png +0 -0
  41. package/dist/examples/vintasend-medplum-example/public/img/integrations/deepseek.png +0 -0
  42. package/dist/examples/vintasend-medplum-example/public/img/integrations/entra.png +0 -0
  43. package/dist/examples/vintasend-medplum-example/public/img/integrations/epic.png +0 -0
  44. package/dist/examples/vintasend-medplum-example/public/img/integrations/google.png +0 -0
  45. package/dist/examples/vintasend-medplum-example/public/img/integrations/healthgorilla.png +0 -0
  46. package/dist/examples/vintasend-medplum-example/public/img/integrations/healthie.png +0 -0
  47. package/dist/examples/vintasend-medplum-example/public/img/integrations/labcorp.png +0 -0
  48. package/dist/examples/vintasend-medplum-example/public/img/integrations/okta.png +0 -0
  49. package/dist/examples/vintasend-medplum-example/public/img/integrations/openai.png +0 -0
  50. package/dist/examples/vintasend-medplum-example/public/img/integrations/particle.png +0 -0
  51. package/dist/examples/vintasend-medplum-example/public/img/integrations/quest.png +0 -0
  52. package/dist/examples/vintasend-medplum-example/public/img/integrations/recaptcha.png +0 -0
  53. package/dist/examples/vintasend-medplum-example/public/img/integrations/snowflake.png +0 -0
  54. package/dist/examples/vintasend-medplum-example/public/img/integrations/stedi.png +0 -0
  55. package/dist/examples/vintasend-medplum-example/public/img/integrations/stripe.png +0 -0
  56. package/dist/examples/vintasend-medplum-example/public/img/integrations/sumo.png +0 -0
  57. package/dist/examples/vintasend-medplum-example/scripts/README.md +162 -0
  58. package/dist/examples/vintasend-medplum-example/scripts/client.ts +18 -0
  59. package/dist/examples/vintasend-medplum-example/scripts/deploy-bots.ts +171 -0
  60. package/dist/examples/vintasend-medplum-example/src/App.tsx +185 -0
  61. package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemList.test.tsx +350 -0
  62. package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemList.tsx +241 -0
  63. package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemPanel.test.tsx +616 -0
  64. package/dist/examples/vintasend-medplum-example/src/components/ChargeItem/ChargeItemPanel.tsx +138 -0
  65. package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionItem.test.tsx +92 -0
  66. package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionItem.tsx +47 -0
  67. package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionList.test.tsx +464 -0
  68. package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionList.tsx +186 -0
  69. package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionModal.test.tsx +80 -0
  70. package/dist/examples/vintasend-medplum-example/src/components/Conditions/ConditionModal.tsx +82 -0
  71. package/dist/examples/vintasend-medplum-example/src/components/DoseSpotIcon.test.tsx +100 -0
  72. package/dist/examples/vintasend-medplum-example/src/components/DoseSpotIcon.tsx +20 -0
  73. package/dist/examples/vintasend-medplum-example/src/components/IntegrationCard.module.css +3 -0
  74. package/dist/examples/vintasend-medplum-example/src/components/IntegrationCard.tsx +62 -0
  75. package/dist/examples/vintasend-medplum-example/src/components/MessageWithLinks.tsx +47 -0
  76. package/dist/examples/vintasend-medplum-example/src/components/PerformingLabInput.test.tsx +299 -0
  77. package/dist/examples/vintasend-medplum-example/src/components/PerformingLabInput.tsx +52 -0
  78. package/dist/examples/vintasend-medplum-example/src/components/ResourceFormWithRequiredProfile.tsx +82 -0
  79. package/dist/examples/vintasend-medplum-example/src/components/encounter/BillingTab.test.tsx +1016 -0
  80. package/dist/examples/vintasend-medplum-example/src/components/encounter/BillingTab.tsx +298 -0
  81. package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterChart.test.tsx +732 -0
  82. package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterChart.tsx +282 -0
  83. package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterHeader.test.tsx +268 -0
  84. package/dist/examples/vintasend-medplum-example/src/components/encounter/EncounterHeader.tsx +224 -0
  85. package/dist/examples/vintasend-medplum-example/src/components/encounter/SignAddendum.test.tsx +255 -0
  86. package/dist/examples/vintasend-medplum-example/src/components/encounter/SignAddendum.tsx +212 -0
  87. package/dist/examples/vintasend-medplum-example/src/components/encounter/SignLockDialog.test.tsx +120 -0
  88. package/dist/examples/vintasend-medplum-example/src/components/encounter/SignLockDialog.tsx +57 -0
  89. package/dist/examples/vintasend-medplum-example/src/components/encounter/VisitDetailsPanel.test.tsx +224 -0
  90. package/dist/examples/vintasend-medplum-example/src/components/encounter/VisitDetailsPanel.tsx +100 -0
  91. package/dist/examples/vintasend-medplum-example/src/components/labs/CoverageInput.test.tsx +431 -0
  92. package/dist/examples/vintasend-medplum-example/src/components/labs/CoverageInput.tsx +130 -0
  93. package/dist/examples/vintasend-medplum-example/src/components/labs/LabListItem.module.css +31 -0
  94. package/dist/examples/vintasend-medplum-example/src/components/labs/LabListItem.test.tsx +234 -0
  95. package/dist/examples/vintasend-medplum-example/src/components/labs/LabListItem.tsx +143 -0
  96. package/dist/examples/vintasend-medplum-example/src/components/labs/LabOrderDetails.module.css +11 -0
  97. package/dist/examples/vintasend-medplum-example/src/components/labs/LabOrderDetails.test.tsx +875 -0
  98. package/dist/examples/vintasend-medplum-example/src/components/labs/LabOrderDetails.tsx +943 -0
  99. package/dist/examples/vintasend-medplum-example/src/components/labs/LabResultDetails.test.tsx +413 -0
  100. package/dist/examples/vintasend-medplum-example/src/components/labs/LabResultDetails.tsx +203 -0
  101. package/dist/examples/vintasend-medplum-example/src/components/labs/LabSelectEmpty.tsx +22 -0
  102. package/dist/examples/vintasend-medplum-example/src/components/labs/README.md +104 -0
  103. package/dist/examples/vintasend-medplum-example/src/components/labs/TestMetadataCardInput.test.tsx +318 -0
  104. package/dist/examples/vintasend-medplum-example/src/components/labs/TestMetadataCardInput.tsx +87 -0
  105. package/dist/examples/vintasend-medplum-example/src/components/messages/ChatList.test.tsx +126 -0
  106. package/dist/examples/vintasend-medplum-example/src/components/messages/ChatList.tsx +38 -0
  107. package/dist/examples/vintasend-medplum-example/src/components/messages/ChatListItem.module.css +23 -0
  108. package/dist/examples/vintasend-medplum-example/src/components/messages/ChatListItem.test.tsx +167 -0
  109. package/dist/examples/vintasend-medplum-example/src/components/messages/ChatListItem.tsx +53 -0
  110. package/dist/examples/vintasend-medplum-example/src/components/messages/NewTopicDialog.test.tsx +94 -0
  111. package/dist/examples/vintasend-medplum-example/src/components/messages/NewTopicDialog.tsx +165 -0
  112. package/dist/examples/vintasend-medplum-example/src/components/messages/ParticipantFilter.module.css +8 -0
  113. package/dist/examples/vintasend-medplum-example/src/components/messages/ParticipantFilter.test.tsx +523 -0
  114. package/dist/examples/vintasend-medplum-example/src/components/messages/ParticipantFilter.tsx +230 -0
  115. package/dist/examples/vintasend-medplum-example/src/components/messages/ThreadInbox.module.css +23 -0
  116. package/dist/examples/vintasend-medplum-example/src/components/messages/ThreadInbox.test.tsx +567 -0
  117. package/dist/examples/vintasend-medplum-example/src/components/messages/ThreadInbox.tsx +358 -0
  118. package/dist/examples/vintasend-medplum-example/src/components/plandefinition/AddPlanDefinition.module.css +40 -0
  119. package/dist/examples/vintasend-medplum-example/src/components/plandefinition/AddPlanDefinition.tsx +257 -0
  120. package/dist/examples/vintasend-medplum-example/src/components/schedule/CreateVisit.module.css +7 -0
  121. package/dist/examples/vintasend-medplum-example/src/components/schedule/CreateVisit.test.tsx +279 -0
  122. package/dist/examples/vintasend-medplum-example/src/components/schedule/CreateVisit.tsx +156 -0
  123. package/dist/examples/vintasend-medplum-example/src/components/spaces/HistoryList.module.css +45 -0
  124. package/dist/examples/vintasend-medplum-example/src/components/spaces/HistoryList.test.tsx +90 -0
  125. package/dist/examples/vintasend-medplum-example/src/components/spaces/HistoryList.tsx +84 -0
  126. package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourceBox.module.css +26 -0
  127. package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourceBox.tsx +90 -0
  128. package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourcePanel.test.tsx +305 -0
  129. package/dist/examples/vintasend-medplum-example/src/components/spaces/ResourcePanel.tsx +46 -0
  130. package/dist/examples/vintasend-medplum-example/src/components/spaces/SpacesInbox.module.css +262 -0
  131. package/dist/examples/vintasend-medplum-example/src/components/spaces/SpacesInbox.test.tsx +622 -0
  132. package/dist/examples/vintasend-medplum-example/src/components/spaces/SpacesInbox.tsx +286 -0
  133. package/dist/examples/vintasend-medplum-example/src/components/tasks/NewTaskModal.tsx +275 -0
  134. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskAttachmentList.tsx +132 -0
  135. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskBoard.module.css +45 -0
  136. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskBoard.test.tsx +749 -0
  137. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskBoard.tsx +416 -0
  138. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailPanel.test.tsx +278 -0
  139. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailPanel.tsx +133 -0
  140. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailsModal.module.css +16 -0
  141. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailsModal.test.tsx +255 -0
  142. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskDetailsModal.tsx +203 -0
  143. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFileUpload.tsx +129 -0
  144. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFilterMenu.test.tsx +156 -0
  145. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFilterMenu.tsx +142 -0
  146. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskFilterMenu.utils.ts +28 -0
  147. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskInputNote.test.tsx +134 -0
  148. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskInputNote.tsx +250 -0
  149. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskListItem.module.css +23 -0
  150. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskListItem.test.tsx +149 -0
  151. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskListItem.tsx +53 -0
  152. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskNoteItem.test.tsx +68 -0
  153. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskNoteItem.tsx +46 -0
  154. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskProperties.test.tsx +555 -0
  155. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskProperties.tsx +170 -0
  156. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskSelectEmpty.test.tsx +32 -0
  157. package/dist/examples/vintasend-medplum-example/src/components/tasks/TaskSelectEmpty.tsx +34 -0
  158. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/SimpleTask.test.tsx +47 -0
  159. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/SimpleTask.tsx +29 -0
  160. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskPanel.test.tsx +285 -0
  161. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskPanel.tsx +129 -0
  162. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskQuestionnaireForm.test.tsx +455 -0
  163. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskQuestionnaireForm.tsx +167 -0
  164. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskServiceRequest.test.tsx +435 -0
  165. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskServiceRequest.tsx +116 -0
  166. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskStatusPanel.module.css +38 -0
  167. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskStatusPanel.test.tsx +200 -0
  168. package/dist/examples/vintasend-medplum-example/src/components/tasks/encounter/TaskStatusPanel.tsx +84 -0
  169. package/dist/examples/vintasend-medplum-example/src/components/utils.test.ts +176 -0
  170. package/dist/examples/vintasend-medplum-example/src/components/utils.ts +17 -0
  171. package/dist/examples/vintasend-medplum-example/src/config/constants.ts +3 -0
  172. package/dist/examples/vintasend-medplum-example/src/hooks/useDebouncedUpdateResource.test.tsx +166 -0
  173. package/dist/examples/vintasend-medplum-example/src/hooks/useDebouncedUpdateResource.ts +28 -0
  174. package/dist/examples/vintasend-medplum-example/src/hooks/useEncounter.test.tsx +94 -0
  175. package/dist/examples/vintasend-medplum-example/src/hooks/useEncounter.ts +11 -0
  176. package/dist/examples/vintasend-medplum-example/src/hooks/useEncounterChart.test.tsx +477 -0
  177. package/dist/examples/vintasend-medplum-example/src/hooks/useEncounterChart.ts +191 -0
  178. package/dist/examples/vintasend-medplum-example/src/hooks/usePatient.test.tsx +100 -0
  179. package/dist/examples/vintasend-medplum-example/src/hooks/usePatient.ts +18 -0
  180. package/dist/examples/vintasend-medplum-example/src/hooks/useThreadInbox.test.tsx +379 -0
  181. package/dist/examples/vintasend-medplum-example/src/hooks/useThreadInbox.ts +194 -0
  182. package/dist/examples/vintasend-medplum-example/src/index.css +8 -0
  183. package/dist/examples/vintasend-medplum-example/src/main.tsx +57 -0
  184. package/dist/examples/vintasend-medplum-example/src/pages/SearchPage.module.css +6 -0
  185. package/dist/examples/vintasend-medplum-example/src/pages/SearchPage.test.tsx +295 -0
  186. package/dist/examples/vintasend-medplum-example/src/pages/SearchPage.tsx +124 -0
  187. package/dist/examples/vintasend-medplum-example/src/pages/SignInPage.test.tsx +77 -0
  188. package/dist/examples/vintasend-medplum-example/src/pages/SignInPage.tsx +22 -0
  189. package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterChartPage.test.tsx +87 -0
  190. package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterChartPage.tsx +27 -0
  191. package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterModal.module.css +16 -0
  192. package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterModal.test.tsx +287 -0
  193. package/dist/examples/vintasend-medplum-example/src/pages/encounter/EncounterModal.tsx +151 -0
  194. package/dist/examples/vintasend-medplum-example/src/pages/integrations/DoseSpotFavoritesPage.test.tsx +519 -0
  195. package/dist/examples/vintasend-medplum-example/src/pages/integrations/DoseSpotFavoritesPage.tsx +179 -0
  196. package/dist/examples/vintasend-medplum-example/src/pages/integrations/FavoriteMedicationsTable.tsx +76 -0
  197. package/dist/examples/vintasend-medplum-example/src/pages/integrations/IntegrationsPage.test.tsx +234 -0
  198. package/dist/examples/vintasend-medplum-example/src/pages/integrations/IntegrationsPage.tsx +222 -0
  199. package/dist/examples/vintasend-medplum-example/src/pages/labs/OrderLabsPage.test.tsx +356 -0
  200. package/dist/examples/vintasend-medplum-example/src/pages/labs/OrderLabsPage.tsx +275 -0
  201. package/dist/examples/vintasend-medplum-example/src/pages/messages/MessagesPage.module.css +8 -0
  202. package/dist/examples/vintasend-medplum-example/src/pages/messages/MessagesPage.test.tsx +103 -0
  203. package/dist/examples/vintasend-medplum-example/src/pages/messages/MessagesPage.tsx +78 -0
  204. package/dist/examples/vintasend-medplum-example/src/pages/patient/CommunicationTab.test.tsx +84 -0
  205. package/dist/examples/vintasend-medplum-example/src/pages/patient/CommunicationTab.tsx +82 -0
  206. package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotAdvancedOptions.test.tsx +364 -0
  207. package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotAdvancedOptions.tsx +149 -0
  208. package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotTab.test.tsx +159 -0
  209. package/dist/examples/vintasend-medplum-example/src/pages/patient/DoseSpotTab.tsx +37 -0
  210. package/dist/examples/vintasend-medplum-example/src/pages/patient/EditTab.test.tsx +140 -0
  211. package/dist/examples/vintasend-medplum-example/src/pages/patient/EditTab.tsx +72 -0
  212. package/dist/examples/vintasend-medplum-example/src/pages/patient/ExportTab.test.tsx +57 -0
  213. package/dist/examples/vintasend-medplum-example/src/pages/patient/ExportTab.tsx +14 -0
  214. package/dist/examples/vintasend-medplum-example/src/pages/patient/IntakeFormPage.test.tsx +241 -0
  215. package/dist/examples/vintasend-medplum-example/src/pages/patient/IntakeFormPage.tsx +710 -0
  216. package/dist/examples/vintasend-medplum-example/src/pages/patient/LabsPage.module.css +37 -0
  217. package/dist/examples/vintasend-medplum-example/src/pages/patient/LabsPage.test.tsx +428 -0
  218. package/dist/examples/vintasend-medplum-example/src/pages/patient/LabsPage.tsx +334 -0
  219. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.module.css +24 -0
  220. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.test.tsx +154 -0
  221. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.tsx +115 -0
  222. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.utils.test.ts +223 -0
  223. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientPage.utils.ts +89 -0
  224. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientSearchPage.test.tsx +147 -0
  225. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientSearchPage.tsx +79 -0
  226. package/dist/examples/vintasend-medplum-example/src/pages/patient/PatientTabsNavigation.tsx +35 -0
  227. package/dist/examples/vintasend-medplum-example/src/pages/patient/TasksTab.test.tsx +185 -0
  228. package/dist/examples/vintasend-medplum-example/src/pages/patient/TasksTab.tsx +115 -0
  229. package/dist/examples/vintasend-medplum-example/src/pages/patient/TimelineTab.tsx +14 -0
  230. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceCreatePage.test.tsx +170 -0
  231. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceCreatePage.tsx +117 -0
  232. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceDetailPage.tsx +28 -0
  233. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceEditPage.test.tsx +131 -0
  234. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceEditPage.tsx +65 -0
  235. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceHistoryPage.test.tsx +108 -0
  236. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourceHistoryPage.tsx +16 -0
  237. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourcePage.module.css +7 -0
  238. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourcePage.test.tsx +37 -0
  239. package/dist/examples/vintasend-medplum-example/src/pages/resource/ResourcePage.tsx +44 -0
  240. package/dist/examples/vintasend-medplum-example/src/pages/resource/useResourceType.ts +44 -0
  241. package/dist/examples/vintasend-medplum-example/src/pages/resource/utils.ts +9 -0
  242. package/dist/examples/vintasend-medplum-example/src/pages/schedule/SchedulePage.test.tsx +302 -0
  243. package/dist/examples/vintasend-medplum-example/src/pages/schedule/SchedulePage.tsx +416 -0
  244. package/dist/examples/vintasend-medplum-example/src/pages/spaces/ChatInput.tsx +91 -0
  245. package/dist/examples/vintasend-medplum-example/src/pages/spaces/SpacesPage.module.css +6 -0
  246. package/dist/examples/vintasend-medplum-example/src/pages/spaces/SpacesPage.test.tsx +102 -0
  247. package/dist/examples/vintasend-medplum-example/src/pages/spaces/SpacesPage.tsx +44 -0
  248. package/dist/examples/vintasend-medplum-example/src/pages/tasks/TasksPage.module.css +7 -0
  249. package/dist/examples/vintasend-medplum-example/src/pages/tasks/TasksPage.test.tsx +133 -0
  250. package/dist/examples/vintasend-medplum-example/src/pages/tasks/TasksPage.tsx +91 -0
  251. package/dist/examples/vintasend-medplum-example/src/test-utils/render.tsx +20 -0
  252. package/dist/examples/vintasend-medplum-example/src/test.setup.ts +49 -0
  253. package/dist/examples/vintasend-medplum-example/src/types/encounter.ts +8 -0
  254. package/dist/examples/vintasend-medplum-example/src/types/spaces.ts +10 -0
  255. package/dist/examples/vintasend-medplum-example/src/utils/chargeitems.test.ts +141 -0
  256. package/dist/examples/vintasend-medplum-example/src/utils/chargeitems.ts +59 -0
  257. package/dist/examples/vintasend-medplum-example/src/utils/claims.test.ts +153 -0
  258. package/dist/examples/vintasend-medplum-example/src/utils/claims.ts +65 -0
  259. package/dist/examples/vintasend-medplum-example/src/utils/communication-search.ts +47 -0
  260. package/dist/examples/vintasend-medplum-example/src/utils/coverage.test.ts +48 -0
  261. package/dist/examples/vintasend-medplum-example/src/utils/coverage.ts +33 -0
  262. package/dist/examples/vintasend-medplum-example/src/utils/documentReference.test.ts +102 -0
  263. package/dist/examples/vintasend-medplum-example/src/utils/documentReference.ts +55 -0
  264. package/dist/examples/vintasend-medplum-example/src/utils/encounter.test.ts +169 -0
  265. package/dist/examples/vintasend-medplum-example/src/utils/encounter.ts +261 -0
  266. package/dist/examples/vintasend-medplum-example/src/utils/intake-form.test.ts +154 -0
  267. package/dist/examples/vintasend-medplum-example/src/utils/intake-form.ts +272 -0
  268. package/dist/examples/vintasend-medplum-example/src/utils/intake-utils.test.ts +1137 -0
  269. package/dist/examples/vintasend-medplum-example/src/utils/intake-utils.ts +827 -0
  270. package/dist/examples/vintasend-medplum-example/src/utils/notifications.test.ts +27 -0
  271. package/dist/examples/vintasend-medplum-example/src/utils/notifications.ts +15 -0
  272. package/dist/examples/vintasend-medplum-example/src/utils/spaceMessaging.ts +249 -0
  273. package/dist/examples/vintasend-medplum-example/src/utils/spacePersistence.test.ts +450 -0
  274. package/dist/examples/vintasend-medplum-example/src/utils/spacePersistence.ts +147 -0
  275. package/dist/examples/vintasend-medplum-example/src/utils/task-search.ts +63 -0
  276. package/dist/examples/vintasend-medplum-example/src/vite-env.d.ts +3 -0
  277. package/dist/examples/vintasend-medplum-example/tsconfig.bots.json +4 -0
  278. package/dist/examples/vintasend-medplum-example/tsconfig.json +19 -0
  279. package/dist/examples/vintasend-medplum-example/vercel.json +3 -0
  280. package/dist/examples/vintasend-medplum-example/vite.config.ts +44 -0
  281. package/dist/services/notification-backends/base-notification-backend.d.ts +5 -0
  282. package/dist/services/notification-service.js +11 -1
  283. package/dist/services/notification-template-renderers/base-email-template-renderer.d.ts +5 -0
  284. package/package.json +1 -1
@@ -0,0 +1,223 @@
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import type { Patient } from '@medplum/fhirtypes';
4
+ import { describe, expect, test } from 'vitest';
5
+ import {
6
+ formatPatientPageTabUrl,
7
+ getPatientPageTabOrThrow,
8
+ patientPathPrefix,
9
+ PatientPageTabs,
10
+ prependPatientPath,
11
+ } from './PatientPage.utils';
12
+
13
+ describe('PatientPage.utils', () => {
14
+ describe('patientPathPrefix', () => {
15
+ test('returns correct path prefix for patient ID', () => {
16
+ expect(patientPathPrefix('123')).toBe('/Patient/123');
17
+ expect(patientPathPrefix('patient-456')).toBe('/Patient/patient-456');
18
+ expect(patientPathPrefix('abc-def-ghi')).toBe('/Patient/abc-def-ghi');
19
+ });
20
+
21
+ test('handles empty string patient ID', () => {
22
+ expect(patientPathPrefix('')).toBe('/Patient/');
23
+ });
24
+ });
25
+
26
+ describe('prependPatientPath', () => {
27
+ const mockPatient: Patient = {
28
+ resourceType: 'Patient',
29
+ id: 'patient-123',
30
+ };
31
+
32
+ test('prepends patient path when patient has ID', () => {
33
+ expect(prependPatientPath(mockPatient, 'edit')).toBe('/Patient/patient-123/edit');
34
+ expect(prependPatientPath(mockPatient, '/edit')).toBe('/Patient/patient-123/edit');
35
+ expect(prependPatientPath(mockPatient, 'Encounter')).toBe('/Patient/patient-123/Encounter');
36
+ });
37
+
38
+ test('handles path without leading slash', () => {
39
+ expect(prependPatientPath(mockPatient, 'edit')).toBe('/Patient/patient-123/edit');
40
+ expect(prependPatientPath(mockPatient, 'Task')).toBe('/Patient/patient-123/Task');
41
+ });
42
+
43
+ test('handles path with leading slash', () => {
44
+ expect(prependPatientPath(mockPatient, '/edit')).toBe('/Patient/patient-123/edit');
45
+ expect(prependPatientPath(mockPatient, '/Encounter')).toBe('/Patient/patient-123/Encounter');
46
+ });
47
+
48
+ test('returns original path when patient is undefined', () => {
49
+ expect(prependPatientPath(undefined, 'edit')).toBe('edit');
50
+ expect(prependPatientPath(undefined, '/edit')).toBe('/edit');
51
+ expect(prependPatientPath(undefined, 'Encounter')).toBe('Encounter');
52
+ });
53
+
54
+ test('returns original path when patient has no ID', () => {
55
+ const patientWithoutId: Patient = {
56
+ resourceType: 'Patient',
57
+ };
58
+ expect(prependPatientPath(patientWithoutId, 'edit')).toBe('edit');
59
+ expect(prependPatientPath(patientWithoutId, '/edit')).toBe('/edit');
60
+ });
61
+
62
+ test('handles empty path string', () => {
63
+ expect(prependPatientPath(mockPatient, '')).toBe('/Patient/patient-123/');
64
+ expect(prependPatientPath(undefined, '')).toBe('');
65
+ });
66
+ });
67
+
68
+ describe('formatPatientPageTabUrl', () => {
69
+ test('formats URL with patient ID replacement', () => {
70
+ const tab = {
71
+ id: 'encounter',
72
+ url: 'Encounter?patient=%patient.id',
73
+ label: 'Visits',
74
+ };
75
+ expect(formatPatientPageTabUrl('patient-123', tab)).toBe('/Patient/patient-123/Encounter?patient=patient-123');
76
+ });
77
+
78
+ test('handles tab with empty URL', () => {
79
+ const tab = {
80
+ id: 'timeline',
81
+ url: '',
82
+ label: 'Timeline',
83
+ };
84
+ expect(formatPatientPageTabUrl('patient-456', tab)).toBe('/Patient/patient-456/');
85
+ });
86
+
87
+ test('handles tab URL without patient.id placeholder', () => {
88
+ const tab = {
89
+ id: 'labs',
90
+ url: 'labs',
91
+ label: 'Labs',
92
+ };
93
+ expect(formatPatientPageTabUrl('patient-789', tab)).toBe('/Patient/patient-789/labs');
94
+ });
95
+
96
+ test('handles multiple patient.id placeholders (replaces only first)', () => {
97
+ const tab = {
98
+ id: 'test',
99
+ url: 'Resource?patient=%patient.id&other=%patient.id',
100
+ label: 'Test',
101
+ };
102
+ // replace() only replaces the first occurrence
103
+ expect(formatPatientPageTabUrl('patient-123', tab)).toBe(
104
+ '/Patient/patient-123/Resource?patient=patient-123&other=%patient.id'
105
+ );
106
+ });
107
+
108
+ test('handles complex query string with patient.id placeholder', () => {
109
+ const tab = PatientPageTabs.find((t) => t.id === 'encounter');
110
+ if (tab) {
111
+ const result = formatPatientPageTabUrl('patient-123', tab);
112
+ expect(result).toContain('/Patient/patient-123/Encounter');
113
+ expect(result).toContain('patient=patient-123');
114
+ expect(result).not.toContain('%patient.id');
115
+ }
116
+ });
117
+ });
118
+
119
+ describe('getPatientPageTabOrThrow', () => {
120
+ test('returns tab when found', () => {
121
+ const timelineTab = getPatientPageTabOrThrow('timeline');
122
+ expect(timelineTab.id).toBe('timeline');
123
+ expect(timelineTab.url).toBe('');
124
+ expect(timelineTab.label).toBe('Timeline');
125
+
126
+ const editTab = getPatientPageTabOrThrow('edit');
127
+ expect(editTab.id).toBe('edit');
128
+ expect(editTab.url).toBe('edit');
129
+ expect(editTab.label).toBe('Edit');
130
+
131
+ const medsTab = getPatientPageTabOrThrow('meds');
132
+ expect(medsTab.id).toBe('meds');
133
+ expect(medsTab.label).toBe('Meds');
134
+ });
135
+
136
+ test('throws error when tab not found', () => {
137
+ expect(() => getPatientPageTabOrThrow('nonexistent')).toThrow(
138
+ 'Could not find patient page tab with id nonexistent'
139
+ );
140
+ expect(() => getPatientPageTabOrThrow('invalid-tab')).toThrow(
141
+ 'Could not find patient page tab with id invalid-tab'
142
+ );
143
+ });
144
+
145
+ test('finds all defined tabs', () => {
146
+ const tabIds = [
147
+ 'timeline',
148
+ 'edit',
149
+ 'encounter',
150
+ 'tasks',
151
+ 'meds',
152
+ 'labs',
153
+ 'devices',
154
+ 'documentreference',
155
+ 'careplan',
156
+ 'message',
157
+ 'dosespot',
158
+ 'export',
159
+ ];
160
+ for (const tabId of tabIds) {
161
+ const tab = getPatientPageTabOrThrow(tabId);
162
+ expect(tab).toBeDefined();
163
+ expect(tab.id).toBe(tabId);
164
+ expect(tab.url).toBeDefined();
165
+ expect(tab.label).toBeDefined();
166
+ }
167
+ });
168
+ });
169
+
170
+ describe('PatientPageTabs', () => {
171
+ test('is an array', () => {
172
+ expect(Array.isArray(PatientPageTabs)).toBe(true);
173
+ });
174
+
175
+ test('contains expected tabs', () => {
176
+ const tabIds = PatientPageTabs.map((tab) => tab.id);
177
+ expect(tabIds).toContain('timeline');
178
+ expect(tabIds).toContain('edit');
179
+ expect(tabIds).toContain('encounter');
180
+ expect(tabIds).toContain('tasks');
181
+ expect(tabIds).toContain('meds');
182
+ expect(tabIds).toContain('labs');
183
+ expect(tabIds).toContain('devices');
184
+ expect(tabIds).toContain('documentreference');
185
+ expect(tabIds).toContain('careplan');
186
+ expect(tabIds).toContain('message');
187
+ expect(tabIds).toContain('dosespot');
188
+ expect(tabIds).toContain('export');
189
+ });
190
+
191
+ test('all tabs have required properties', () => {
192
+ for (const tab of PatientPageTabs) {
193
+ expect(tab).toHaveProperty('id');
194
+ expect(tab).toHaveProperty('url');
195
+ expect(tab).toHaveProperty('label');
196
+ expect(typeof tab.id).toBe('string');
197
+ expect(typeof tab.url).toBe('string');
198
+ expect(typeof tab.label).toBe('string');
199
+ }
200
+ });
201
+
202
+ test('timeline tab has empty URL', () => {
203
+ const timelineTab = PatientPageTabs.find((tab) => tab.id === 'timeline');
204
+ expect(timelineTab).toBeDefined();
205
+ expect(timelineTab?.url).toBe('');
206
+ });
207
+
208
+ test('tabs with patient.id placeholder contain the placeholder', () => {
209
+ const tabsWithPlaceholder = PatientPageTabs.filter((tab) => tab.url.includes('%patient.id'));
210
+ expect(tabsWithPlaceholder.length).toBeGreaterThan(0);
211
+ for (const tab of tabsWithPlaceholder) {
212
+ expect(tab.url).toContain('%patient.id');
213
+ }
214
+ });
215
+
216
+ test('tasks tab has correct URL', () => {
217
+ const tasksTab = PatientPageTabs.find((tab) => tab.id === 'tasks');
218
+ expect(tasksTab).toBeDefined();
219
+ expect(tasksTab?.url).toBe('Task');
220
+ expect(tasksTab?.label).toBe('Tasks');
221
+ });
222
+ });
223
+ });
@@ -0,0 +1,89 @@
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import type { Patient, ProjectMembership } from '@medplum/fhirtypes';
4
+ import { hasDoseSpotIdentifier } from '../../components/utils';
5
+
6
+ export function patientPathPrefix(patientId: string): string {
7
+ return `/Patient/${patientId}`;
8
+ }
9
+
10
+ export function prependPatientPath(patient: Patient | undefined, path: string): string {
11
+ if (patient?.id) {
12
+ return `${patientPathPrefix(patient.id)}${!path.startsWith('/') ? '/' : ''}${path}`;
13
+ }
14
+
15
+ return path;
16
+ }
17
+
18
+ export function formatPatientPageTabUrl(patientId: string, tab: PatientPageTabInfo): string {
19
+ return `${patientPathPrefix(patientId)}/${tab.url.replace('%patient.id', patientId)}`;
20
+ }
21
+
22
+ export type PatientPageTabInfo = {
23
+ id: string;
24
+ url: string;
25
+ label: string;
26
+ };
27
+
28
+ export function getPatientPageTabOrThrow(tabId: string): PatientPageTabInfo {
29
+ const result = PatientPageTabs.find((tab) => tab.id === tabId);
30
+
31
+ if (!result) {
32
+ throw new Error(`Could not find patient page tab with id ${tabId}`);
33
+ }
34
+ return result;
35
+ }
36
+
37
+ /**
38
+ * Returns the patient page tabs filtered based on user permissions.
39
+ * Currently filters out the DoseSpot tab if the user doesn't have DoseSpot access.
40
+ * @param membership - The current user's project membership.
41
+ * @returns Filtered array of patient page tabs.
42
+ */
43
+ export function getPatientPageTabs(membership: ProjectMembership | undefined): PatientPageTabInfo[] {
44
+ const hasDoseSpot = hasDoseSpotIdentifier(membership);
45
+ return PatientPageTabs.filter((tab) => tab.id !== 'dosespot' || hasDoseSpot);
46
+ }
47
+
48
+ export const PatientPageTabs: PatientPageTabInfo[] = [
49
+ { id: 'timeline', url: '', label: 'Timeline' },
50
+ { id: 'edit', url: 'edit', label: 'Edit' },
51
+ {
52
+ id: 'encounter',
53
+ url: 'Encounter?_count=20&_fields=_lastUpdated,period,status,serviceType&_sort=-_lastUpdated&patient=%patient.id',
54
+ label: 'Visits',
55
+ },
56
+ {
57
+ id: 'tasks',
58
+ url: 'Task',
59
+ label: 'Tasks',
60
+ },
61
+ {
62
+ id: 'meds',
63
+ url: 'MedicationRequest?_fields=medication[x],intent,status&_offset=0&_sort=-_lastUpdated&patient=%patient.id',
64
+ label: 'Meds',
65
+ },
66
+ {
67
+ id: 'labs',
68
+ url: 'ServiceRequest',
69
+ label: 'Labs',
70
+ },
71
+ {
72
+ id: 'devices',
73
+ url: 'Device?_fields=manufacturer,deviceName,status,distinctIdentifier,serialNumber&_offset=0&_sort=-_lastUpdated&patient=%patient.id',
74
+ label: 'Devices',
75
+ },
76
+ {
77
+ id: 'documentreference',
78
+ url: 'DocumentReference?_fields=_lastUpdated,category,type,status,author&_offset=0&_sort=-_lastUpdated&patient=%patient.id',
79
+ label: 'Documents',
80
+ },
81
+ {
82
+ id: 'careplan',
83
+ url: 'CarePlan?_fields=_lastUpdated,status,intent,category,period&_sort=-_lastUpdated&patient=%patient.id',
84
+ label: 'Care Plans',
85
+ },
86
+ { id: 'message', url: 'Communication', label: 'Messages' },
87
+ { id: 'dosespot', url: 'dosespot', label: 'DoseSpot' },
88
+ { id: 'export', url: 'export', label: 'Export' },
89
+ ];
@@ -0,0 +1,147 @@
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { MantineProvider } from '@mantine/core';
4
+ import { Notifications } from '@mantine/notifications';
5
+ import { HomerSimpson, MockClient } from '@medplum/mock';
6
+ import { MedplumProvider } from '@medplum/react';
7
+ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
8
+ import { MemoryRouter, Routes, Route } from 'react-router';
9
+ import { describe, expect, test, vi, beforeEach } from 'vitest';
10
+ import { PatientSearchPage } from './PatientSearchPage';
11
+
12
+ async function setup(url: string, medplum = new MockClient()): Promise<void> {
13
+ await act(async () => {
14
+ render(
15
+ <MedplumProvider medplum={medplum}>
16
+ <MemoryRouter initialEntries={[url]} initialIndex={0}>
17
+ <MantineProvider>
18
+ <Notifications />
19
+ <Routes>
20
+ <Route path="/Patient/:patientId/:resourceType" element={<PatientSearchPage />} />
21
+ <Route path="/Patient/:patientId/:resourceType/:resourceId" element={<div>Resource Detail</div>} />
22
+ <Route path="/Patient/:patientId/:resourceType/new" element={<div>New Resource</div>} />
23
+ </Routes>
24
+ </MantineProvider>
25
+ </MemoryRouter>
26
+ </MedplumProvider>
27
+ );
28
+ });
29
+ }
30
+
31
+ describe('PatientSearchPage', () => {
32
+ beforeEach(async () => {
33
+ vi.clearAllMocks();
34
+ });
35
+
36
+ test('Renders default page with Patient resource type', async () => {
37
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
38
+ expect(await screen.findByTestId('search-control')).toBeInTheDocument();
39
+ });
40
+
41
+ test('Renders with Encounter resource type', async () => {
42
+ await setup(`/Patient/${HomerSimpson.id}/Encounter`);
43
+ expect(await screen.findByTestId('search-control')).toBeInTheDocument();
44
+ });
45
+
46
+ test('Renders with Task resource type', async () => {
47
+ await setup(`/Patient/${HomerSimpson.id}/Task`);
48
+ expect(await screen.findByTestId('search-control')).toBeInTheDocument();
49
+ });
50
+
51
+ test('Renders with resourceType and fields query params', async () => {
52
+ await setup(`/Patient/${HomerSimpson.id}/Patient?_fields=id,_lastUpdated,name,birthDate,gender`);
53
+ expect(await screen.findByTestId('search-control')).toBeInTheDocument();
54
+ });
55
+
56
+ test('Shows loading state when patient is not available', async () => {
57
+ await setup('/Patient/non-existent-patient/Patient');
58
+ // Loading component doesn't have a test ID, check for loading indicator by class
59
+ await waitFor(() => {
60
+ const loader = document.querySelector('.mantine-Loader-root');
61
+ expect(loader).toBeInTheDocument();
62
+ });
63
+ });
64
+
65
+ test('Navigates to correct URL when resourceType changes', async () => {
66
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
67
+
68
+ await waitFor(() => {
69
+ expect(screen.getByTestId('search-control')).toBeInTheDocument();
70
+ });
71
+
72
+ // The component should navigate to the correct URL format
73
+ // This is tested implicitly by the component's useEffect logic
74
+ });
75
+
76
+ test('Next page button', async () => {
77
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
78
+ expect(await screen.findByLabelText('Next page')).toBeInTheDocument();
79
+
80
+ await act(async () => {
81
+ fireEvent.click(screen.getByLabelText('Next page'));
82
+ });
83
+ });
84
+
85
+ test('Prev page button', async () => {
86
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
87
+ expect(await screen.findByLabelText('Previous page')).toBeInTheDocument();
88
+
89
+ await act(async () => {
90
+ fireEvent.click(screen.getByLabelText('Previous page'));
91
+ });
92
+ });
93
+
94
+ test('New button navigates to new resource page', async () => {
95
+ await setup(`/Patient/${HomerSimpson.id}/Task`);
96
+ expect(await screen.findByText('New...')).toBeInTheDocument();
97
+
98
+ await act(async () => {
99
+ fireEvent.click(screen.getByText('New...'));
100
+ });
101
+
102
+ await waitFor(() => {
103
+ expect(screen.getByText('New Resource')).toBeInTheDocument();
104
+ });
105
+ });
106
+
107
+ test('SearchControl renders and is clickable', async () => {
108
+ window.open = vi.fn();
109
+
110
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
111
+ await waitFor(() => {
112
+ expect(screen.getByTestId('search-control')).toBeInTheDocument();
113
+ });
114
+
115
+ // Verify SearchControl is rendered and functional
116
+ const searchControl = screen.getByTestId('search-control');
117
+ expect(searchControl).toBeInTheDocument();
118
+ });
119
+
120
+ test('SearchControl renders with toolbar buttons', async () => {
121
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
122
+ await waitFor(() => {
123
+ expect(screen.getByTestId('search-control')).toBeInTheDocument();
124
+ });
125
+
126
+ // Verify SearchControl is rendered (toolbar buttons may or may not be visible)
127
+ const searchControl = screen.getByTestId('search-control');
128
+ expect(searchControl).toBeInTheDocument();
129
+ });
130
+
131
+ test('Search control has checkboxes enabled', async () => {
132
+ await setup(`/Patient/${HomerSimpson.id}/Patient`);
133
+ const searchControl = await screen.findByTestId('search-control');
134
+ expect(searchControl).toBeInTheDocument();
135
+ // Checkboxes should be enabled (tested implicitly through SearchControl rendering)
136
+ });
137
+
138
+ test('Handles search with offset and count', async () => {
139
+ await setup(`/Patient/${HomerSimpson.id}/Patient?_offset=10&_count=20`);
140
+ expect(await screen.findByTestId('search-control')).toBeInTheDocument();
141
+ });
142
+
143
+ test('Handles search with filters', async () => {
144
+ await setup(`/Patient/${HomerSimpson.id}/Patient?name=Homer`);
145
+ expect(await screen.findByTestId('search-control')).toBeInTheDocument();
146
+ });
147
+ });
@@ -0,0 +1,79 @@
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Paper } from '@mantine/core';
4
+ import { DEFAULT_SEARCH_COUNT, formatSearchQuery, parseSearchRequest } from '@medplum/core';
5
+ import type { SearchRequest } from '@medplum/core';
6
+ import { Loading, SearchControl, useMedplum } from '@medplum/react';
7
+ import { useEffect, useState } from 'react';
8
+ import type { JSX } from 'react';
9
+ import { useLocation, useNavigate } from 'react-router';
10
+ import { usePatient } from '../../hooks/usePatient';
11
+ import { useResourceType } from '../resource/useResourceType';
12
+ import { prependPatientPath } from './PatientPage.utils';
13
+
14
+ export function PatientSearchPage(): JSX.Element {
15
+ const medplum = useMedplum();
16
+ const patient = usePatient();
17
+ const navigate = useNavigate();
18
+ const location = useLocation();
19
+ const [search, setSearch] = useState<SearchRequest>();
20
+
21
+ useResourceType(search?.resourceType, { onInvalidResourceType: () => navigate('..')?.catch(console.error) });
22
+
23
+ useEffect(() => {
24
+ if (!patient) {
25
+ return;
26
+ }
27
+
28
+ const parsedSearch = parseSearchRequest(location.pathname + location.search);
29
+ const populatedSearch = addDefaultSearchValues(parsedSearch);
30
+
31
+ if (
32
+ location.pathname === `/Patient/${patient.id}/${populatedSearch.resourceType}` &&
33
+ location.search === formatSearchQuery(populatedSearch)
34
+ ) {
35
+ setSearch(populatedSearch);
36
+ } else {
37
+ navigate(`/Patient/${patient.id}/${populatedSearch.resourceType}${formatSearchQuery(populatedSearch)}`)?.catch(
38
+ console.error
39
+ );
40
+ }
41
+ }, [medplum, patient, navigate, location]);
42
+
43
+ if (!patient || !search?.resourceType || !search.fields || search.fields.length === 0) {
44
+ return <Loading />;
45
+ }
46
+
47
+ return (
48
+ <Paper shadow="xs" m="md" p="xs">
49
+ <SearchControl
50
+ checkboxesEnabled={true}
51
+ search={search}
52
+ onClick={(e) =>
53
+ navigate(`/Patient/${patient.id}/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error)
54
+ }
55
+ onAuxClick={(e) => window.open(`/Patient/${patient.id}/${e.resource.resourceType}/${e.resource.id}`, '_blank')}
56
+ onNew={() => {
57
+ navigate(prependPatientPath(patient, `/${search.resourceType}/new`))?.catch(console.error);
58
+ }}
59
+ onChange={(e) => {
60
+ navigate(`/Patient/${patient.id}/${search.resourceType}${formatSearchQuery(e.definition)}`)?.catch(
61
+ console.error
62
+ );
63
+ }}
64
+ />
65
+ </Paper>
66
+ );
67
+ }
68
+
69
+ function addDefaultSearchValues(search: SearchRequest): SearchRequest {
70
+ const fields = search.fields ?? ['_id', '_lastUpdated'];
71
+ const offset = search.offset ?? 0;
72
+ const count = search.count ?? DEFAULT_SEARCH_COUNT;
73
+ return {
74
+ ...search,
75
+ fields,
76
+ offset,
77
+ count,
78
+ };
79
+ }
@@ -0,0 +1,35 @@
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Paper, Tabs } from '@mantine/core';
4
+ import type { JSX } from 'react';
5
+ import type { PatientPageTabInfo } from './PatientPage.utils';
6
+
7
+ interface PatientTabsNavigationProps {
8
+ tabs: PatientPageTabInfo[];
9
+ currentTab: string;
10
+ onTabChange: (value: string | null) => void;
11
+ }
12
+
13
+ export function PatientTabsNavigation({ tabs, currentTab, onTabChange }: PatientTabsNavigationProps): JSX.Element {
14
+ return (
15
+ <Paper w="100%">
16
+ <Tabs value={currentTab.toLowerCase()} onChange={onTabChange}>
17
+ <Tabs.List
18
+ style={{
19
+ display: 'flex',
20
+ width: '100%',
21
+ overflowX: 'auto',
22
+ overflowY: 'hidden',
23
+ flexWrap: 'nowrap',
24
+ }}
25
+ >
26
+ {tabs.map((t) => (
27
+ <Tabs.Tab key={t.id} value={t.id}>
28
+ {t.label}
29
+ </Tabs.Tab>
30
+ ))}
31
+ </Tabs.List>
32
+ </Tabs>
33
+ </Paper>
34
+ );
35
+ }