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,567 @@
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Notifications } from '@mantine/notifications';
4
+ import type { Communication } from '@medplum/fhirtypes';
5
+ import { HomerSimpson, MockClient } from '@medplum/mock';
6
+ import { MedplumProvider } from '@medplum/react';
7
+ import { act, render, screen, waitFor, userEvent } from '../../test-utils/render';
8
+ import { MemoryRouter } from 'react-router';
9
+ import { describe, expect, test, vi, beforeEach } from 'vitest';
10
+ import { ThreadInbox } from './ThreadInbox';
11
+ import * as reactHooks from '@medplum/react-hooks';
12
+
13
+ vi.mock('@medplum/react-hooks', async () => {
14
+ const actual = await vi.importActual('@medplum/react-hooks');
15
+ return {
16
+ ...actual,
17
+ useSubscription: vi.fn(),
18
+ };
19
+ });
20
+
21
+ const mockCommunication: Communication | undefined = {
22
+ resourceType: 'Communication',
23
+ id: 'comm-123',
24
+ status: 'in-progress',
25
+ topic: { text: 'Test Topic' },
26
+ subject: { reference: `Patient/${HomerSimpson.id}` },
27
+ };
28
+
29
+ const mockOnNew = vi.fn();
30
+ const mockGetThreadUri = vi.fn((topic: Communication) => `/Message/${topic.id}`);
31
+ const mockOnChange = vi.fn();
32
+
33
+ describe('ThreadInbox', () => {
34
+ let medplum: MockClient;
35
+
36
+ beforeEach(async () => {
37
+ medplum = new MockClient();
38
+ vi.clearAllMocks();
39
+ vi.mocked(reactHooks.useSubscription).mockClear();
40
+
41
+ // Mock search and graphql to return empty results by default
42
+ medplum.search = vi.fn().mockResolvedValue({
43
+ resourceType: 'Bundle',
44
+ type: 'searchset',
45
+ total: 0,
46
+ entry: [],
47
+ });
48
+ medplum.graphql = vi.fn().mockResolvedValue({
49
+ data: { CommunicationList: [] },
50
+ });
51
+ });
52
+
53
+ const setup = (props?: {
54
+ threadId?: string;
55
+ showPatientSummary?: boolean;
56
+ subject?: typeof HomerSimpson;
57
+ }): Promise<void> => {
58
+ return act(async () => {
59
+ render(
60
+ <MemoryRouter>
61
+ <MedplumProvider medplum={medplum}>
62
+ <Notifications />
63
+ <ThreadInbox
64
+ query="_sort=-_lastUpdated"
65
+ threadId={props?.threadId}
66
+ showPatientSummary={props?.showPatientSummary ?? false}
67
+ subject={props?.subject}
68
+ onNew={mockOnNew}
69
+ getThreadUri={mockGetThreadUri}
70
+ onChange={mockOnChange}
71
+ inProgressUri="/Communication?status=in-progress"
72
+ completedUri="/Communication?status=completed"
73
+ />
74
+ </MedplumProvider>
75
+ </MemoryRouter>
76
+ );
77
+ });
78
+ };
79
+
80
+ test('renders filter buttons and new message button', async () => {
81
+ await setup();
82
+ // Status filter buttons
83
+ expect(screen.getByText('In progress')).toBeInTheDocument();
84
+ expect(screen.getByText('Completed')).toBeInTheDocument();
85
+ // Participant filter and new message buttons
86
+ const iconButtons = screen.getAllByRole('button', { name: '' });
87
+ expect(iconButtons.length).toBeGreaterThanOrEqual(2);
88
+ });
89
+
90
+ test('renders status filter buttons', async () => {
91
+ await setup();
92
+ expect(screen.getByText('In progress')).toBeInTheDocument();
93
+ expect(screen.getByText('Completed')).toBeInTheDocument();
94
+ });
95
+
96
+ test('shows loading skeletons when loading', async () => {
97
+ medplum.search = vi.fn().mockImplementation(() => new Promise(() => {}));
98
+ await setup();
99
+
100
+ await waitFor(() => {
101
+ const skeletons = document.querySelectorAll('.mantine-Skeleton-root');
102
+ expect(skeletons.length).toBeGreaterThan(0);
103
+ });
104
+ });
105
+
106
+ test('shows chat list with multiple communications and displays their topics', async () => {
107
+ const communications: Communication[] = [
108
+ {
109
+ resourceType: 'Communication',
110
+ id: 'comm-1',
111
+ status: 'in-progress',
112
+ topic: { text: 'Topic Alpha' },
113
+ subject: { reference: `Patient/${HomerSimpson.id}` },
114
+ meta: {
115
+ lastUpdated: '2024-01-01T10:00:00Z',
116
+ },
117
+ },
118
+ {
119
+ resourceType: 'Communication',
120
+ id: 'comm-2',
121
+ status: 'in-progress',
122
+ topic: { text: 'Topic Beta' },
123
+ subject: { reference: `Patient/${HomerSimpson.id}` },
124
+ meta: {
125
+ lastUpdated: '2024-01-01T11:00:00Z',
126
+ },
127
+ },
128
+ {
129
+ resourceType: 'Communication',
130
+ id: 'comm-3',
131
+ status: 'completed',
132
+ topic: { text: 'Topic Gamma' },
133
+ subject: { reference: `Patient/${HomerSimpson.id}` },
134
+ meta: {
135
+ lastUpdated: '2024-01-01T12:00:00Z',
136
+ },
137
+ },
138
+ ];
139
+
140
+ for (const comm of communications) {
141
+ await medplum.createResource(comm);
142
+ }
143
+
144
+ const lastMessages: Communication[] = communications.map((comm, index) => ({
145
+ resourceType: 'Communication',
146
+ id: `last-${comm.id}`,
147
+ status: 'in-progress',
148
+ partOf: [{ reference: `Communication/${comm.id}` }],
149
+ sent: `2024-01-01T${12 + index}:00:00Z`, // Different sent times for sorting
150
+ payload: [{ contentString: `Last message for ${comm.topic?.text}` }],
151
+ meta: {
152
+ lastUpdated: `2024-01-01T${12 + index}:00:00Z`,
153
+ },
154
+ sender: {
155
+ display: 'Test Sender',
156
+ reference: 'Practitioner/test',
157
+ },
158
+ }));
159
+
160
+ for (const msg of lastMessages) {
161
+ await medplum.createResource(msg);
162
+ }
163
+
164
+ vi.spyOn(medplum, 'search').mockResolvedValue({
165
+ resourceType: 'Bundle',
166
+ type: 'searchset',
167
+ total: 2,
168
+ entry: [
169
+ { resource: communications[0] },
170
+ { resource: communications[1] },
171
+ // comm-3 excluded because it has status 'completed'
172
+ ],
173
+ } as any);
174
+
175
+ vi.spyOn(medplum, 'graphql').mockImplementation((_query: string) => {
176
+ // Return data matching the alias format
177
+ return Promise.resolve({
178
+ data: {
179
+ thread_comm1: [lastMessages[0]],
180
+ thread_comm2: [lastMessages[1]],
181
+ // thread_comm3 not included because comm-3 has status 'completed' and will be filtered out by the status=in-progress query
182
+ },
183
+ });
184
+ });
185
+
186
+ await setup();
187
+
188
+ await waitFor(
189
+ () => {
190
+ expect(screen.getByText('Topic Alpha')).toBeInTheDocument();
191
+ expect(screen.getByText('Topic Beta')).toBeInTheDocument();
192
+ // Topic Gamma won't appear because comm-3 has status 'completed'
193
+ },
194
+ { timeout: 3000 }
195
+ );
196
+ });
197
+
198
+ test('shows no messages state when no thread is selected', async () => {
199
+ await setup();
200
+ await waitFor(() => {
201
+ expect(screen.getByText('Select a message from the list to view details')).toBeInTheDocument();
202
+ });
203
+ });
204
+
205
+ test('shows empty messages state when no messages are found', async () => {
206
+ await setup();
207
+
208
+ await waitFor(
209
+ () => {
210
+ expect(screen.getByText('No messages found')).toBeInTheDocument();
211
+ },
212
+ { timeout: 3000 }
213
+ );
214
+ });
215
+
216
+ test('shows thread chat when thread is selected', async () => {
217
+ await medplum.createResource(mockCommunication);
218
+
219
+ medplum.search = vi.fn().mockResolvedValue({
220
+ resourceType: 'Bundle',
221
+ type: 'searchset',
222
+ entry: [{ resource: mockCommunication }],
223
+ });
224
+ medplum.graphql = vi.fn().mockResolvedValue({
225
+ data: { CommunicationList: [] },
226
+ });
227
+
228
+ await setup({ threadId: 'comm-123' });
229
+
230
+ await waitFor(
231
+ () => {
232
+ const topicTexts = screen.getAllByText('Test Topic');
233
+ expect(topicTexts.length).toBeGreaterThan(0);
234
+ },
235
+ { timeout: 3000 }
236
+ );
237
+
238
+ // Verify useSubscription was called (ThreadChat uses BaseChat which uses useSubscription)
239
+ expect(vi.mocked(reactHooks.useSubscription)).toHaveBeenCalled();
240
+ });
241
+
242
+ test('shows patient summary when showPatientSummary is true and thread is selected', async () => {
243
+ const medplumReact = await import('@medplum/react');
244
+ const patientSummarySpy = vi.spyOn(medplumReact, 'PatientSummary');
245
+
246
+ await medplum.createResource(mockCommunication);
247
+
248
+ medplum.search = vi.fn().mockResolvedValue({
249
+ resourceType: 'Bundle',
250
+ type: 'searchset',
251
+ entry: [{ resource: mockCommunication }],
252
+ });
253
+ medplum.graphql = vi.fn().mockResolvedValue({
254
+ data: { CommunicationList: [] },
255
+ });
256
+
257
+ await setup({ showPatientSummary: true, threadId: 'comm-123' });
258
+
259
+ await waitFor(
260
+ () => {
261
+ expect(patientSummarySpy).toHaveBeenCalled();
262
+ },
263
+ { timeout: 3000 }
264
+ );
265
+ });
266
+
267
+ test('does not show patient summary when showPatientSummary is false', async () => {
268
+ const medplumReact = await import('@medplum/react');
269
+ const patientSummarySpy = vi.spyOn(medplumReact, 'PatientSummary');
270
+ await medplum.createResource(mockCommunication);
271
+
272
+ medplum.search = vi.fn().mockResolvedValue({
273
+ resourceType: 'Bundle',
274
+ type: 'searchset',
275
+ entry: [{ resource: mockCommunication }],
276
+ });
277
+ medplum.graphql = vi.fn().mockResolvedValue({
278
+ data: { CommunicationList: [] },
279
+ });
280
+
281
+ await setup({ showPatientSummary: false, threadId: 'comm-123' });
282
+
283
+ await waitFor(
284
+ () => {
285
+ expect(patientSummarySpy).not.toHaveBeenCalled();
286
+ },
287
+ { timeout: 3000 }
288
+ );
289
+ });
290
+
291
+ test('opens new topic dialog when plus button is clicked', async () => {
292
+ const user = userEvent.setup();
293
+ await setup();
294
+
295
+ // Get all icon buttons and select the plus button (second one, after participant filter)
296
+ const iconButtons = screen.getAllByRole('button', { name: '' });
297
+ const plusButton = iconButtons[iconButtons.length - 1]; // Plus button is last
298
+ await user.click(plusButton);
299
+
300
+ await waitFor(() => {
301
+ expect(screen.getByText('New Message')).toBeInTheDocument();
302
+ });
303
+ });
304
+
305
+ test('closes new topic dialog when close is clicked', async () => {
306
+ const user = userEvent.setup();
307
+ await setup();
308
+
309
+ // Open dialog first - get all icon buttons and select the plus button (last one)
310
+ const iconButtons = screen.getAllByRole('button', { name: '' });
311
+ const plusButton = iconButtons[iconButtons.length - 1];
312
+ await user.click(plusButton);
313
+
314
+ await waitFor(() => {
315
+ expect(screen.getByText('New Message')).toBeInTheDocument();
316
+ });
317
+
318
+ // Close dialog
319
+ const closeButton = document.querySelector('.mantine-Modal-close');
320
+ if (closeButton) {
321
+ await user.click(closeButton);
322
+ }
323
+
324
+ await waitFor(() => {
325
+ expect(screen.queryByText('New Message')).not.toBeInTheDocument();
326
+ });
327
+ });
328
+
329
+ test('displays "Messages" in header when thread has no topic', async () => {
330
+ const commWithoutTopic: Communication = {
331
+ ...mockCommunication,
332
+ topic: undefined,
333
+ };
334
+ await medplum.createResource(commWithoutTopic);
335
+
336
+ medplum.search = vi.fn().mockResolvedValue({
337
+ resourceType: 'Bundle',
338
+ type: 'searchset',
339
+ entry: [{ resource: commWithoutTopic }],
340
+ });
341
+ medplum.graphql = vi.fn().mockResolvedValue({
342
+ data: { CommunicationList: [] },
343
+ });
344
+
345
+ await setup({ threadId: 'comm-123' });
346
+
347
+ await waitFor(
348
+ () => {
349
+ const messagesTexts = screen.getAllByText('Messages');
350
+ expect(messagesTexts.length).toBeGreaterThan(0);
351
+ },
352
+ { timeout: 3000 }
353
+ );
354
+ });
355
+
356
+ test('changes status filter to completed when Completed button is clicked', async () => {
357
+ const user = userEvent.setup();
358
+ await setup();
359
+
360
+ const completedButton = screen.getByText('Completed');
361
+ await user.click(completedButton);
362
+
363
+ await waitFor(() => {
364
+ // The search should be called again with completed status
365
+ expect(medplum.search).toHaveBeenCalled();
366
+ });
367
+ });
368
+
369
+ test('shows status dropdown for in-progress thread', async () => {
370
+ const user = userEvent.setup();
371
+ await medplum.createResource(mockCommunication);
372
+
373
+ medplum.search = vi.fn().mockResolvedValue({
374
+ resourceType: 'Bundle',
375
+ type: 'searchset',
376
+ entry: [{ resource: mockCommunication }],
377
+ });
378
+ medplum.graphql = vi.fn().mockResolvedValue({
379
+ data: { CommunicationList: [] },
380
+ });
381
+
382
+ await setup({ threadId: 'comm-123' });
383
+
384
+ await waitFor(
385
+ () => {
386
+ expect(screen.getByText('In Progress')).toBeInTheDocument();
387
+ },
388
+ { timeout: 3000 }
389
+ );
390
+
391
+ // Click the status button to open dropdown
392
+ const statusButton = screen.getByText('In Progress');
393
+ await user.click(statusButton);
394
+
395
+ await waitFor(() => {
396
+ expect(screen.getByRole('menu')).toBeInTheDocument();
397
+ });
398
+ });
399
+
400
+ test('changes thread status to completed through dropdown', async () => {
401
+ const user = userEvent.setup();
402
+ await medplum.createResource(mockCommunication);
403
+
404
+ medplum.search = vi.fn().mockResolvedValue({
405
+ resourceType: 'Bundle',
406
+ type: 'searchset',
407
+ entry: [{ resource: mockCommunication }],
408
+ });
409
+ medplum.graphql = vi.fn().mockResolvedValue({
410
+ data: { CommunicationList: [] },
411
+ });
412
+
413
+ const updateResourceSpy = vi.spyOn(medplum, 'updateResource');
414
+
415
+ await setup({ threadId: 'comm-123' });
416
+
417
+ await waitFor(
418
+ () => {
419
+ expect(screen.getByText('In Progress')).toBeInTheDocument();
420
+ },
421
+ { timeout: 3000 }
422
+ );
423
+
424
+ // Click the status button to open dropdown
425
+ const statusButton = screen.getByText('In Progress');
426
+ await user.click(statusButton);
427
+
428
+ await waitFor(() => {
429
+ expect(screen.getByRole('menu')).toBeInTheDocument();
430
+ });
431
+
432
+ // Click Completed in the dropdown - look for menu item by text
433
+ const completedMenuItem = screen.queryByText('Completed', { selector: '[role="menuitem"]' });
434
+ if (completedMenuItem) {
435
+ await user.click(completedMenuItem);
436
+ await waitFor(() => {
437
+ expect(updateResourceSpy).toHaveBeenCalled();
438
+ });
439
+ }
440
+ });
441
+
442
+ test('shows green status badge for completed thread', async () => {
443
+ const completedCommunication: Communication = {
444
+ ...mockCommunication,
445
+ status: 'completed',
446
+ };
447
+ await medplum.createResource(completedCommunication);
448
+
449
+ medplum.search = vi.fn().mockResolvedValue({
450
+ resourceType: 'Bundle',
451
+ type: 'searchset',
452
+ entry: [{ resource: completedCommunication }],
453
+ });
454
+ medplum.graphql = vi.fn().mockResolvedValue({
455
+ data: { CommunicationList: [] },
456
+ });
457
+
458
+ await setup({ threadId: 'comm-123' });
459
+
460
+ await waitFor(
461
+ () => {
462
+ // The status is shown on the thread header button
463
+ const buttons = screen.getAllByRole('button');
464
+ const completedButton = buttons.find((btn) => btn.textContent?.includes('Completed'));
465
+ expect(completedButton).toBeInTheDocument();
466
+ },
467
+ { timeout: 3000 }
468
+ );
469
+ });
470
+
471
+ test('shows red status badge for stopped thread', async () => {
472
+ const stoppedCommunication: Communication = {
473
+ ...mockCommunication,
474
+ status: 'stopped',
475
+ };
476
+ await medplum.createResource(stoppedCommunication);
477
+
478
+ medplum.search = vi.fn().mockResolvedValue({
479
+ resourceType: 'Bundle',
480
+ type: 'searchset',
481
+ entry: [{ resource: stoppedCommunication }],
482
+ });
483
+ medplum.graphql = vi.fn().mockResolvedValue({
484
+ data: { CommunicationList: [] },
485
+ });
486
+
487
+ await setup({ threadId: 'comm-123' });
488
+
489
+ await waitFor(
490
+ () => {
491
+ // The status is shown on the thread header button
492
+ const buttons = screen.getAllByRole('button');
493
+ const stoppedButton = buttons.find((btn) => btn.textContent?.includes('Stopped'));
494
+ expect(stoppedButton).toBeInTheDocument();
495
+ },
496
+ { timeout: 3000 }
497
+ );
498
+ });
499
+
500
+ test('shows error notification when status change fails', async () => {
501
+ const user = userEvent.setup();
502
+ await medplum.createResource(mockCommunication);
503
+
504
+ medplum.search = vi.fn().mockResolvedValue({
505
+ resourceType: 'Bundle',
506
+ type: 'searchset',
507
+ entry: [{ resource: mockCommunication }],
508
+ });
509
+ medplum.graphql = vi.fn().mockResolvedValue({
510
+ data: { CommunicationList: [] },
511
+ });
512
+
513
+ // Make updateResource fail
514
+ medplum.updateResource = vi.fn().mockRejectedValue(new Error('Status update failed'));
515
+
516
+ await setup({ threadId: 'comm-123' });
517
+
518
+ await waitFor(
519
+ () => {
520
+ expect(screen.getByText('In Progress')).toBeInTheDocument();
521
+ },
522
+ { timeout: 3000 }
523
+ );
524
+
525
+ // Click the status button to open dropdown
526
+ const statusButton = screen.getByText('In Progress');
527
+ await user.click(statusButton);
528
+
529
+ await waitFor(() => {
530
+ expect(screen.getByRole('menu')).toBeInTheDocument();
531
+ });
532
+
533
+ // Click Completed in the dropdown - look for menu item by text
534
+ const completedMenuItem = screen.queryByText('Completed', { selector: '[role="menuitem"]' });
535
+ if (completedMenuItem) {
536
+ await user.click(completedMenuItem);
537
+ await waitFor(() => {
538
+ expect(screen.getByText(/Status update failed/i)).toBeInTheDocument();
539
+ });
540
+ }
541
+ });
542
+
543
+ test('shows pagination when total exceeds items per page', async () => {
544
+ await medplum.createResource(mockCommunication);
545
+
546
+ medplum.search = vi.fn().mockResolvedValue({
547
+ resourceType: 'Bundle',
548
+ type: 'searchset',
549
+ total: 50, // More than 20 items per page
550
+ entry: [{ resource: mockCommunication }],
551
+ });
552
+ medplum.graphql = vi.fn().mockResolvedValue({
553
+ data: { CommunicationList: [] },
554
+ });
555
+
556
+ await setup();
557
+
558
+ await waitFor(
559
+ () => {
560
+ // Pagination should be visible
561
+ const pagination = document.querySelector('.mantine-Pagination-root');
562
+ expect(pagination).toBeInTheDocument();
563
+ },
564
+ { timeout: 3000 }
565
+ );
566
+ });
567
+ });