@medplum/react 2.0.0 → 2.0.2

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 (229) hide show
  1. package/dist/cjs/DiagnosticReportDisplay/DiagnosticReportDisplay.d.ts +2 -0
  2. package/dist/cjs/DiagnosticReportDisplay/DiagnosticReportDisplay.stories.d.ts +1 -0
  3. package/dist/cjs/MedplumProvider/MedplumProvider.d.ts +8 -0
  4. package/dist/cjs/NoteDisplay/NoteDisplay.d.ts +6 -0
  5. package/dist/cjs/{ResourceDiffTable/ResourceDiffTable.stories.d.ts → NoteDisplay/NoteDisplay.stories.d.ts} +3 -1
  6. package/dist/cjs/QuantityInput/QuantityInput.d.ts +1 -0
  7. package/dist/cjs/QuantityInput/QuantityInput.stories.d.ts +7 -0
  8. package/dist/cjs/ReferenceRangeEditor/ReferenceRangeEditor.d.ts +1 -2
  9. package/dist/cjs/ResourceTimeline/ResourceTimeline.d.ts +2 -2
  10. package/dist/cjs/index.cjs +1206 -1204
  11. package/dist/cjs/index.cjs.map +1 -1
  12. package/dist/cjs/index.min.cjs +1 -1
  13. package/dist/esm/AddressDisplay/AddressDisplay.mjs +2 -2
  14. package/dist/esm/AddressDisplay/AddressDisplay.mjs.map +1 -1
  15. package/dist/esm/AddressInput/AddressInput.mjs +9 -9
  16. package/dist/esm/AddressInput/AddressInput.mjs.map +1 -1
  17. package/dist/esm/AnnotationInput/AnnotationInput.mjs +2 -2
  18. package/dist/esm/AnnotationInput/AnnotationInput.mjs.map +1 -1
  19. package/dist/esm/AsyncAutocomplete/AsyncAutocomplete.mjs +2 -2
  20. package/dist/esm/AsyncAutocomplete/AsyncAutocomplete.mjs.map +1 -1
  21. package/dist/esm/AttachmentArrayDisplay/AttachmentArrayDisplay.mjs +4 -4
  22. package/dist/esm/AttachmentArrayDisplay/AttachmentArrayDisplay.mjs.map +1 -1
  23. package/dist/esm/AttachmentArrayInput/AttachmentArrayInput.mjs +19 -19
  24. package/dist/esm/AttachmentArrayInput/AttachmentArrayInput.mjs.map +1 -1
  25. package/dist/esm/AttachmentButton/AttachmentButton.mjs +3 -3
  26. package/dist/esm/AttachmentButton/AttachmentButton.mjs.map +1 -1
  27. package/dist/esm/AttachmentDisplay/AttachmentDisplay.mjs +9 -9
  28. package/dist/esm/AttachmentDisplay/AttachmentDisplay.mjs.map +1 -1
  29. package/dist/esm/AttachmentInput/AttachmentInput.mjs +5 -5
  30. package/dist/esm/AttachmentInput/AttachmentInput.mjs.map +1 -1
  31. package/dist/esm/BackboneElementDisplay/BackboneElementDisplay.mjs +6 -6
  32. package/dist/esm/BackboneElementDisplay/BackboneElementDisplay.mjs.map +1 -1
  33. package/dist/esm/BackboneElementInput/BackboneElementInput.mjs +7 -7
  34. package/dist/esm/BackboneElementInput/BackboneElementInput.mjs.map +1 -1
  35. package/dist/esm/CalendarInput/CalendarInput.mjs +18 -18
  36. package/dist/esm/CalendarInput/CalendarInput.mjs.map +1 -1
  37. package/dist/esm/CheckboxFormSection/CheckboxFormSection.mjs +5 -5
  38. package/dist/esm/CheckboxFormSection/CheckboxFormSection.mjs.map +1 -1
  39. package/dist/esm/CodeInput/CodeInput.mjs +2 -2
  40. package/dist/esm/CodeInput/CodeInput.mjs.map +1 -1
  41. package/dist/esm/CodeableConceptDisplay/CodeableConceptDisplay.mjs +2 -2
  42. package/dist/esm/CodeableConceptDisplay/CodeableConceptDisplay.mjs.map +1 -1
  43. package/dist/esm/CodeableConceptInput/CodeableConceptInput.mjs +2 -2
  44. package/dist/esm/CodeableConceptInput/CodeableConceptInput.mjs.map +1 -1
  45. package/dist/esm/CodingDisplay/CodingDisplay.mjs +2 -2
  46. package/dist/esm/CodingDisplay/CodingDisplay.mjs.map +1 -1
  47. package/dist/esm/CodingInput/CodingInput.mjs +2 -2
  48. package/dist/esm/CodingInput/CodingInput.mjs.map +1 -1
  49. package/dist/esm/ContactDetailDisplay/ContactDetailDisplay.mjs +3 -3
  50. package/dist/esm/ContactDetailDisplay/ContactDetailDisplay.mjs.map +1 -1
  51. package/dist/esm/ContactDetailInput/ContactDetailInput.mjs +4 -4
  52. package/dist/esm/ContactDetailInput/ContactDetailInput.mjs.map +1 -1
  53. package/dist/esm/ContactPointDisplay/ContactPointDisplay.mjs +2 -2
  54. package/dist/esm/ContactPointDisplay/ContactPointDisplay.mjs.map +1 -1
  55. package/dist/esm/ContactPointInput/ContactPointInput.mjs +5 -5
  56. package/dist/esm/ContactPointInput/ContactPointInput.mjs.map +1 -1
  57. package/dist/esm/Container/Container.mjs +2 -2
  58. package/dist/esm/Container/Container.mjs.map +1 -1
  59. package/dist/esm/DateTimeInput/DateTimeInput.mjs +2 -2
  60. package/dist/esm/DateTimeInput/DateTimeInput.mjs.map +1 -1
  61. package/dist/esm/DefaultResourceTimeline/DefaultResourceTimeline.mjs +7 -19
  62. package/dist/esm/DefaultResourceTimeline/DefaultResourceTimeline.mjs.map +1 -1
  63. package/dist/esm/DescriptionList/DescriptionList.mjs +5 -5
  64. package/dist/esm/DescriptionList/DescriptionList.mjs.map +1 -1
  65. package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.d.ts +2 -0
  66. package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.mjs +56 -52
  67. package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.mjs.map +1 -1
  68. package/dist/esm/DiagnosticReportDisplay/DiagnosticReportDisplay.stories.d.ts +1 -0
  69. package/dist/esm/Document/Document.mjs +3 -3
  70. package/dist/esm/Document/Document.mjs.map +1 -1
  71. package/dist/esm/EncounterTimeline/EncounterTimeline.mjs +8 -25
  72. package/dist/esm/EncounterTimeline/EncounterTimeline.mjs.map +1 -1
  73. package/dist/esm/ErrorBoundary/ErrorBoundary.mjs +4 -4
  74. package/dist/esm/ErrorBoundary/ErrorBoundary.mjs.map +1 -1
  75. package/dist/esm/ExtensionInput/ExtensionInput.mjs +2 -2
  76. package/dist/esm/ExtensionInput/ExtensionInput.mjs.map +1 -1
  77. package/dist/esm/FhirPathDisplay/FhirPathDisplay.mjs +2 -2
  78. package/dist/esm/FhirPathDisplay/FhirPathDisplay.mjs.map +1 -1
  79. package/dist/esm/FhirPathTable/FhirPathTable.mjs +19 -19
  80. package/dist/esm/FhirPathTable/FhirPathTable.mjs.map +1 -1
  81. package/dist/esm/Form/Form.mjs +2 -2
  82. package/dist/esm/Form/Form.mjs.map +1 -1
  83. package/dist/esm/FormSection/FormSection.mjs +2 -2
  84. package/dist/esm/FormSection/FormSection.mjs.map +1 -1
  85. package/dist/esm/GoogleButton/GoogleButton.mjs +8 -6
  86. package/dist/esm/GoogleButton/GoogleButton.mjs.map +1 -1
  87. package/dist/esm/HumanNameDisplay/HumanNameDisplay.mjs +2 -2
  88. package/dist/esm/HumanNameDisplay/HumanNameDisplay.mjs.map +1 -1
  89. package/dist/esm/HumanNameInput/HumanNameInput.mjs +7 -7
  90. package/dist/esm/HumanNameInput/HumanNameInput.mjs.map +1 -1
  91. package/dist/esm/IdentifierDisplay/IdentifierDisplay.mjs +2 -2
  92. package/dist/esm/IdentifierDisplay/IdentifierDisplay.mjs.map +1 -1
  93. package/dist/esm/IdentifierInput/IdentifierInput.mjs +4 -4
  94. package/dist/esm/IdentifierInput/IdentifierInput.mjs.map +1 -1
  95. package/dist/esm/Logo/Logo.mjs +8 -8
  96. package/dist/esm/Logo/Logo.mjs.map +1 -1
  97. package/dist/esm/MedplumLink/MedplumLink.mjs +4 -4
  98. package/dist/esm/MedplumLink/MedplumLink.mjs.map +1 -1
  99. package/dist/esm/MedplumProvider/MedplumProvider.d.ts +8 -0
  100. package/dist/esm/MedplumProvider/MedplumProvider.mjs +19 -3
  101. package/dist/esm/MedplumProvider/MedplumProvider.mjs.map +1 -1
  102. package/dist/esm/MoneyDisplay/MoneyDisplay.mjs +2 -2
  103. package/dist/esm/MoneyDisplay/MoneyDisplay.mjs.map +1 -1
  104. package/dist/esm/MoneyInput/MoneyInput.mjs +4 -4
  105. package/dist/esm/MoneyInput/MoneyInput.mjs.map +1 -1
  106. package/dist/esm/NoteDisplay/NoteDisplay.d.ts +6 -0
  107. package/dist/esm/NoteDisplay/NoteDisplay.mjs +18 -0
  108. package/dist/esm/NoteDisplay/NoteDisplay.mjs.map +1 -0
  109. package/dist/esm/{ResourceDiffTable/ResourceDiffTable.stories.d.ts → NoteDisplay/NoteDisplay.stories.d.ts} +3 -1
  110. package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.mjs +3 -3
  111. package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.mjs.map +1 -1
  112. package/dist/esm/Panel/Panel.mjs +2 -2
  113. package/dist/esm/Panel/Panel.mjs.map +1 -1
  114. package/dist/esm/PatientTimeline/PatientTimeline.mjs +13 -20
  115. package/dist/esm/PatientTimeline/PatientTimeline.mjs.map +1 -1
  116. package/dist/esm/PeriodInput/PeriodInput.mjs +4 -4
  117. package/dist/esm/PeriodInput/PeriodInput.mjs.map +1 -1
  118. package/dist/esm/PlanDefinitionBuilder/PlanDefinitionBuilder.mjs +34 -34
  119. package/dist/esm/PlanDefinitionBuilder/PlanDefinitionBuilder.mjs.map +1 -1
  120. package/dist/esm/QuantityDisplay/QuantityDisplay.mjs +2 -2
  121. package/dist/esm/QuantityDisplay/QuantityDisplay.mjs.map +1 -1
  122. package/dist/esm/QuantityInput/QuantityInput.d.ts +1 -0
  123. package/dist/esm/QuantityInput/QuantityInput.mjs +14 -8
  124. package/dist/esm/QuantityInput/QuantityInput.mjs.map +1 -1
  125. package/dist/esm/QuantityInput/QuantityInput.stories.d.ts +7 -0
  126. package/dist/esm/QuestionnaireBuilder/QuestionnaireBuilder.mjs +31 -31
  127. package/dist/esm/QuestionnaireBuilder/QuestionnaireBuilder.mjs.map +1 -1
  128. package/dist/esm/QuestionnaireForm/QuestionnaireForm.mjs +33 -33
  129. package/dist/esm/QuestionnaireForm/QuestionnaireForm.mjs.map +1 -1
  130. package/dist/esm/RangeDisplay/RangeDisplay.mjs +2 -2
  131. package/dist/esm/RangeDisplay/RangeDisplay.mjs.map +1 -1
  132. package/dist/esm/RangeInput/RangeInput.mjs +4 -4
  133. package/dist/esm/RangeInput/RangeInput.mjs.map +1 -1
  134. package/dist/esm/RatioDisplay/RatioDisplay.mjs +4 -4
  135. package/dist/esm/RatioDisplay/RatioDisplay.mjs.map +1 -1
  136. package/dist/esm/RatioInput/RatioInput.mjs +4 -4
  137. package/dist/esm/RatioInput/RatioInput.mjs.map +1 -1
  138. package/dist/esm/ReferenceDisplay/ReferenceDisplay.mjs +3 -3
  139. package/dist/esm/ReferenceDisplay/ReferenceDisplay.mjs.map +1 -1
  140. package/dist/esm/ReferenceInput/ReferenceInput.mjs +4 -4
  141. package/dist/esm/ReferenceInput/ReferenceInput.mjs.map +1 -1
  142. package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.d.ts +1 -2
  143. package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.mjs +31 -31
  144. package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.mjs.map +1 -1
  145. package/dist/esm/RequestGroupDisplay/RequestGroupDisplay.mjs +15 -15
  146. package/dist/esm/RequestGroupDisplay/RequestGroupDisplay.mjs.map +1 -1
  147. package/dist/esm/ResourceArrayDisplay/ResourceArrayDisplay.mjs +3 -3
  148. package/dist/esm/ResourceArrayDisplay/ResourceArrayDisplay.mjs.map +1 -1
  149. package/dist/esm/ResourceArrayInput/ResourceArrayInput.mjs +18 -18
  150. package/dist/esm/ResourceArrayInput/ResourceArrayInput.mjs.map +1 -1
  151. package/dist/esm/ResourceAvatar/ResourceAvatar.mjs +4 -4
  152. package/dist/esm/ResourceAvatar/ResourceAvatar.mjs.map +1 -1
  153. package/dist/esm/ResourceBadge/ResourceBadge.mjs +4 -4
  154. package/dist/esm/ResourceBadge/ResourceBadge.mjs.map +1 -1
  155. package/dist/esm/ResourceBlame/ResourceBlame.mjs +13 -13
  156. package/dist/esm/ResourceBlame/ResourceBlame.mjs.map +1 -1
  157. package/dist/esm/ResourceDiff/ResourceDiff.mjs +7 -7
  158. package/dist/esm/ResourceDiff/ResourceDiff.mjs.map +1 -1
  159. package/dist/esm/ResourceDiffTable/ResourceDiffTable.mjs +18 -18
  160. package/dist/esm/ResourceDiffTable/ResourceDiffTable.mjs.map +1 -1
  161. package/dist/esm/ResourceForm/ResourceForm.mjs +12 -12
  162. package/dist/esm/ResourceForm/ResourceForm.mjs.map +1 -1
  163. package/dist/esm/ResourceHistoryTable/ResourceHistoryTable.mjs +17 -17
  164. package/dist/esm/ResourceHistoryTable/ResourceHistoryTable.mjs.map +1 -1
  165. package/dist/esm/ResourceInput/ResourceInput.mjs +8 -8
  166. package/dist/esm/ResourceInput/ResourceInput.mjs.map +1 -1
  167. package/dist/esm/ResourceName/ResourceName.mjs +2 -2
  168. package/dist/esm/ResourceName/ResourceName.mjs.map +1 -1
  169. package/dist/esm/ResourcePropertyDisplay/ResourcePropertyDisplay.mjs +27 -27
  170. package/dist/esm/ResourcePropertyDisplay/ResourcePropertyDisplay.mjs.map +1 -1
  171. package/dist/esm/ResourcePropertyInput/ResourcePropertyInput.mjs +35 -35
  172. package/dist/esm/ResourcePropertyInput/ResourcePropertyInput.mjs.map +1 -1
  173. package/dist/esm/ResourceTable/ResourceTable.mjs +2 -2
  174. package/dist/esm/ResourceTable/ResourceTable.mjs.map +1 -1
  175. package/dist/esm/ResourceTimeline/ResourceTimeline.d.ts +2 -2
  176. package/dist/esm/ResourceTimeline/ResourceTimeline.mjs +67 -73
  177. package/dist/esm/ResourceTimeline/ResourceTimeline.mjs.map +1 -1
  178. package/dist/esm/Scheduler/Scheduler.mjs +22 -22
  179. package/dist/esm/Scheduler/Scheduler.mjs.map +1 -1
  180. package/dist/esm/SearchControl/SearchControl.mjs +49 -49
  181. package/dist/esm/SearchControl/SearchControl.mjs.map +1 -1
  182. package/dist/esm/SearchControl/SearchUtils.mjs +4 -4
  183. package/dist/esm/SearchControl/SearchUtils.mjs.map +1 -1
  184. package/dist/esm/SearchFieldEditor/SearchFieldEditor.mjs +25 -25
  185. package/dist/esm/SearchFieldEditor/SearchFieldEditor.mjs.map +1 -1
  186. package/dist/esm/SearchFilterEditor/SearchFilterEditor.mjs +37 -37
  187. package/dist/esm/SearchFilterEditor/SearchFilterEditor.mjs.map +1 -1
  188. package/dist/esm/SearchFilterValueDialog/SearchFilterValueDialog.mjs +6 -6
  189. package/dist/esm/SearchFilterValueDialog/SearchFilterValueDialog.mjs.map +1 -1
  190. package/dist/esm/SearchFilterValueDisplay/SearchFilterValueDisplay.mjs +4 -4
  191. package/dist/esm/SearchFilterValueDisplay/SearchFilterValueDisplay.mjs.map +1 -1
  192. package/dist/esm/SearchFilterValueInput/SearchFilterValueInput.mjs +8 -8
  193. package/dist/esm/SearchFilterValueInput/SearchFilterValueInput.mjs.map +1 -1
  194. package/dist/esm/SearchPopupMenu/SearchPopupMenu.mjs +62 -62
  195. package/dist/esm/SearchPopupMenu/SearchPopupMenu.mjs.map +1 -1
  196. package/dist/esm/ServiceRequestTimeline/ServiceRequestTimeline.mjs +9 -31
  197. package/dist/esm/ServiceRequestTimeline/ServiceRequestTimeline.mjs.map +1 -1
  198. package/dist/esm/StatusBadge/StatusBadge.mjs +2 -2
  199. package/dist/esm/StatusBadge/StatusBadge.mjs.map +1 -1
  200. package/dist/esm/Timeline/Timeline.mjs +20 -20
  201. package/dist/esm/Timeline/Timeline.mjs.map +1 -1
  202. package/dist/esm/TimingInput/TimingInput.mjs +19 -19
  203. package/dist/esm/TimingInput/TimingInput.mjs.map +1 -1
  204. package/dist/esm/ValueSetAutocomplete/ValueSetAutocomplete.mjs +2 -2
  205. package/dist/esm/ValueSetAutocomplete/ValueSetAutocomplete.mjs.map +1 -1
  206. package/dist/esm/auth/AuthenticationForm.mjs +22 -22
  207. package/dist/esm/auth/AuthenticationForm.mjs.map +1 -1
  208. package/dist/esm/auth/ChooseProfileForm.mjs +11 -11
  209. package/dist/esm/auth/ChooseProfileForm.mjs.map +1 -1
  210. package/dist/esm/auth/ChooseScopeForm.mjs +9 -9
  211. package/dist/esm/auth/ChooseScopeForm.mjs.map +1 -1
  212. package/dist/esm/auth/MfaForm.mjs +12 -12
  213. package/dist/esm/auth/MfaForm.mjs.map +1 -1
  214. package/dist/esm/auth/NewProjectForm.mjs +12 -12
  215. package/dist/esm/auth/NewProjectForm.mjs.map +1 -1
  216. package/dist/esm/auth/NewUserForm.mjs +22 -22
  217. package/dist/esm/auth/NewUserForm.mjs.map +1 -1
  218. package/dist/esm/auth/RegisterForm.mjs +5 -5
  219. package/dist/esm/auth/RegisterForm.mjs.map +1 -1
  220. package/dist/esm/auth/SignInForm.mjs +8 -8
  221. package/dist/esm/auth/SignInForm.mjs.map +1 -1
  222. package/dist/esm/index.min.mjs +1 -1
  223. package/dist/esm/index.mjs +1 -1
  224. package/dist/esm/node_modules/@tabler/icons/icons-react/dist/index.esm.mjs +6 -0
  225. package/dist/esm/node_modules/@tabler/icons/icons-react/dist/index.esm.mjs.map +1 -0
  226. package/dist/esm/useResource/useResource.mjs +3 -0
  227. package/dist/esm/useResource/useResource.mjs.map +1 -1
  228. package/package.json +20 -25
  229. package/rollup.config.mjs +0 -110
@@ -1,14 +1,13 @@
1
1
  import { createStyles, Center, Loader, Group, TextInput, ActionIcon, ScrollArea, Menu } from '@mantine/core';
2
2
  import { updateNotification, showNotification } from '@mantine/notifications';
3
3
  import { normalizeErrorString, getReferenceString } from '@medplum/core';
4
- import { IconMessage, IconCloudUpload, IconCheck, IconFileAlert, IconPin, IconPinnedOff, IconListDetails, IconEdit, IconTrash } from '@tabler/icons';
5
- import React, { useRef, useState, useCallback, useEffect } from 'react';
6
- import { useNavigate } from 'react-router-dom';
4
+ import { IconMessage as Lde, IconCloudUpload as XA, IconCheck as DW, IconFileAlert as B$, IconPin as Ege, IconPinnedOff as xge, IconListDetails as qae, IconEdit as CY, IconTrash as zKe } from '../node_modules/@tabler/icons/icons-react/dist/index.esm.mjs';
5
+ import e__default, { useRef, useState, useCallback, useEffect } from 'react';
7
6
  import { AttachmentButton } from '../AttachmentButton/AttachmentButton.mjs';
8
7
  import { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay.mjs';
9
8
  import { DiagnosticReportDisplay } from '../DiagnosticReportDisplay/DiagnosticReportDisplay.mjs';
10
9
  import { Form } from '../Form/Form.mjs';
11
- import { useMedplum } from '../MedplumProvider/MedplumProvider.mjs';
10
+ import { useMedplum, useMedplumNavigate } from '../MedplumProvider/MedplumProvider.mjs';
12
11
  import { Panel } from '../Panel/Panel.mjs';
13
12
  import { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar.mjs';
14
13
  import { ResourceDiffTable } from '../ResourceDiffTable/ResourceDiffTable.mjs';
@@ -23,14 +22,14 @@ const useStyles = createStyles((theme) => ({
23
22
  },
24
23
  }));
25
24
  function ResourceTimeline(props) {
26
- const navigate = useNavigate();
27
25
  const medplum = useMedplum();
26
+ const navigate = useMedplumNavigate();
28
27
  const sender = medplum.getProfile();
29
28
  const inputRef = useRef(null);
30
29
  const resource = useResource(props.value);
31
30
  const [history, setHistory] = useState();
32
31
  const [items, setItems] = useState([]);
33
- const buildSearchRequests = props.buildSearchRequests;
32
+ const loadTimelineResources = props.loadTimelineResources;
34
33
  const itemsRef = useRef(items);
35
34
  itemsRef.current = items;
36
35
  const loadTimeline = useCallback(() => {
@@ -39,8 +38,8 @@ function ResourceTimeline(props) {
39
38
  setHistory({});
40
39
  return;
41
40
  }
42
- medplum.executeBatch(buildSearchRequests(resource)).then(handleBatchResponse).catch(console.log);
43
- }, [medplum, resource, buildSearchRequests]);
41
+ loadTimelineResources(medplum, resource).then(handleBatchResponse).catch(console.log);
42
+ }, [medplum, resource, loadTimelineResources]);
44
43
  useEffect(() => {
45
44
  loadTimeline();
46
45
  }, [loadTimeline]);
@@ -48,29 +47,24 @@ function ResourceTimeline(props) {
48
47
  * Handles a batch request response.
49
48
  * @param batchResponse The batch response.
50
49
  */
51
- function handleBatchResponse(batchResponse) {
50
+ function handleBatchResponse(bundles) {
52
51
  const newItems = [];
53
- if (batchResponse.entry) {
54
- for (const batchEntry of batchResponse.entry) {
55
- const bundle = batchEntry.resource;
56
- if (!bundle) {
57
- // User may not have access to all resource types
58
- continue;
59
- }
60
- if (bundle.type === 'history') {
61
- setHistory(bundle);
62
- }
63
- if (bundle.entry) {
64
- for (const entry of bundle.entry) {
65
- if (entry.resource) {
66
- newItems.push(entry.resource);
67
- }
68
- }
52
+ for (const bundle of bundles) {
53
+ if (!bundle) {
54
+ // User may not have access to all resource types
55
+ continue;
56
+ }
57
+ if (bundle.type === 'history') {
58
+ setHistory(bundle);
59
+ }
60
+ if (bundle.entry) {
61
+ for (const entry of bundle.entry) {
62
+ newItems.push(entry.resource);
69
63
  }
70
64
  }
71
- sortByDateAndPriority(newItems);
72
- newItems.reverse();
73
65
  }
66
+ sortByDateAndPriority(newItems);
67
+ newItems.reverse();
74
68
  setItems(newItems);
75
69
  }
76
70
  /**
@@ -116,7 +110,7 @@ function ResourceTimeline(props) {
116
110
  color: 'teal',
117
111
  title: 'Upload complete',
118
112
  message: '',
119
- icon: React.createElement(IconCheck, { size: 16 }),
113
+ icon: e__default.createElement(DW, { size: 16 }),
120
114
  autoClose: 2000,
121
115
  }))
122
116
  .catch((reason) => updateNotification({
@@ -124,7 +118,7 @@ function ResourceTimeline(props) {
124
118
  color: 'red',
125
119
  title: 'Upload error',
126
120
  message: normalizeErrorString(reason),
127
- icon: React.createElement(IconFileAlert, { size: 16 }),
121
+ icon: e__default.createElement(B$, { size: 16 }),
128
122
  autoClose: 2000,
129
123
  }));
130
124
  }
@@ -170,12 +164,12 @@ function ResourceTimeline(props) {
170
164
  });
171
165
  }
172
166
  if (!resource) {
173
- return (React.createElement(Center, { style: { width: '100%', height: '100%' } },
174
- React.createElement(Loader, null)));
167
+ return (e__default.createElement(Center, { style: { width: '100%', height: '100%' } },
168
+ e__default.createElement(Loader, null)));
175
169
  }
176
- return (React.createElement(Timeline, null,
177
- props.createCommunication && (React.createElement(Panel, null,
178
- React.createElement(Form, { testid: "timeline-form", onSubmit: (formData) => {
170
+ return (e__default.createElement(Timeline, null,
171
+ props.createCommunication && (e__default.createElement(Panel, null,
172
+ e__default.createElement(Form, { testid: "timeline-form", onSubmit: (formData) => {
179
173
  createComment(formData.text);
180
174
  const input = inputRef.current;
181
175
  if (input) {
@@ -183,55 +177,55 @@ function ResourceTimeline(props) {
183
177
  input.focus();
184
178
  }
185
179
  } },
186
- React.createElement(Group, { spacing: "xs", noWrap: true, style: { width: '100%' } },
187
- React.createElement(ResourceAvatar, { value: sender }),
188
- React.createElement(TextInput, { name: "text", ref: inputRef, placeholder: "Add comment", style: { width: '100%', maxWidth: 300 } }),
189
- React.createElement(ActionIcon, { type: "submit", radius: "xl", color: "blue", variant: "filled" },
190
- React.createElement(IconMessage, { size: 16 })),
191
- React.createElement(AttachmentButton, { onUpload: createMedia, onUploadStart: onUploadStart, onUploadProgress: onUploadProgress }, (props) => (React.createElement(ActionIcon, { ...props, radius: "xl", color: "blue", variant: "filled" },
192
- React.createElement(IconCloudUpload, { size: 16 })))))))),
180
+ e__default.createElement(Group, { spacing: "xs", noWrap: true, style: { width: '100%' } },
181
+ e__default.createElement(ResourceAvatar, { value: sender }),
182
+ e__default.createElement(TextInput, { name: "text", ref: inputRef, placeholder: "Add comment", style: { width: '100%', maxWidth: 300 } }),
183
+ e__default.createElement(ActionIcon, { type: "submit", radius: "xl", color: "blue", variant: "filled" },
184
+ e__default.createElement(Lde, { size: 16 })),
185
+ e__default.createElement(AttachmentButton, { onUpload: createMedia, onUploadStart: onUploadStart, onUploadProgress: onUploadProgress }, (props) => (e__default.createElement(ActionIcon, { ...props, radius: "xl", color: "blue", variant: "filled" },
186
+ e__default.createElement(XA, { size: 16 })))))))),
193
187
  items.map((item) => {
188
+ const key = `${item.resourceType}/${item.id}/${item.meta?.versionId}`;
194
189
  if (item.resourceType === resource.resourceType && item.id === resource.id) {
195
- return (React.createElement(HistoryTimelineItem, { key: item.meta?.versionId, history: history, resource: item, onDetails: onVersionDetails }));
190
+ return (e__default.createElement(HistoryTimelineItem, { key: key, history: history, resource: item, onDetails: onVersionDetails }));
196
191
  }
197
- const key = `${item.resourceType}/${item.id}`;
198
192
  switch (item.resourceType) {
199
193
  case 'AuditEvent':
200
- return React.createElement(AuditEventTimelineItem, { key: key, resource: item, onDetails: onDetails });
194
+ return e__default.createElement(AuditEventTimelineItem, { key: key, resource: item, onDetails: onDetails });
201
195
  case 'Communication':
202
- return (React.createElement(CommunicationTimelineItem, { key: key, resource: item, onPin: item.priority !== 'stat' ? onPin : undefined, onUnpin: item.priority === 'stat' ? onUnpin : undefined, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
196
+ return (e__default.createElement(CommunicationTimelineItem, { key: key, resource: item, onPin: item.priority !== 'stat' ? onPin : undefined, onUnpin: item.priority === 'stat' ? onUnpin : undefined, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
203
197
  case 'DiagnosticReport':
204
- return (React.createElement(DiagnosticReportTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
198
+ return (e__default.createElement(DiagnosticReportTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
205
199
  case 'Media':
206
- return (React.createElement(MediaTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
200
+ return (e__default.createElement(MediaTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
207
201
  default:
208
- return (React.createElement(TimelineItem, { key: key, resource: item, padding: true },
209
- React.createElement(ResourceTable, { value: item, ignoreMissingValues: true })));
202
+ return (e__default.createElement(TimelineItem, { key: key, resource: item, padding: true },
203
+ e__default.createElement(ResourceTable, { value: item, ignoreMissingValues: true })));
210
204
  }
211
205
  })));
212
206
  }
213
207
  function TimelineItemPopupMenu(props) {
214
- return (React.createElement(Menu.Dropdown, null,
215
- React.createElement(Menu.Label, null, "Resource"),
216
- props.onPin && (React.createElement(Menu.Item, { icon: React.createElement(IconPin, { size: 14 }), onClick: () => props.onPin(props.resource), "aria-label": `Pin ${getReferenceString(props.resource)}` }, "Pin")),
217
- props.onUnpin && (React.createElement(Menu.Item, { icon: React.createElement(IconPinnedOff, { size: 14 }), onClick: () => props.onUnpin(props.resource), "aria-label": `Unpin ${getReferenceString(props.resource)}` }, "Unpin")),
218
- props.onDetails && (React.createElement(Menu.Item, { icon: React.createElement(IconListDetails, { size: 14 }), onClick: () => props.onDetails(props.resource), "aria-label": `Details ${getReferenceString(props.resource)}` }, "Details")),
219
- props.onEdit && (React.createElement(Menu.Item, { icon: React.createElement(IconEdit, { size: 14 }), onClick: () => props.onEdit(props.resource), "aria-label": `Edit ${getReferenceString(props.resource)}` }, "Edit")),
220
- props.onDelete && (React.createElement(React.Fragment, null,
221
- React.createElement(Menu.Divider, null),
222
- React.createElement(Menu.Label, null, "Danger zone"),
223
- React.createElement(Menu.Item, { color: "red", icon: React.createElement(IconTrash, { size: 14 }), onClick: () => props.onDelete(props.resource), "aria-label": `Delete ${getReferenceString(props.resource)}` }, "Delete")))));
208
+ return (e__default.createElement(Menu.Dropdown, null,
209
+ e__default.createElement(Menu.Label, null, "Resource"),
210
+ props.onPin && (e__default.createElement(Menu.Item, { icon: e__default.createElement(Ege, { size: 14 }), onClick: () => props.onPin(props.resource), "aria-label": `Pin ${getReferenceString(props.resource)}` }, "Pin")),
211
+ props.onUnpin && (e__default.createElement(Menu.Item, { icon: e__default.createElement(xge, { size: 14 }), onClick: () => props.onUnpin(props.resource), "aria-label": `Unpin ${getReferenceString(props.resource)}` }, "Unpin")),
212
+ props.onDetails && (e__default.createElement(Menu.Item, { icon: e__default.createElement(qae, { size: 14 }), onClick: () => props.onDetails(props.resource), "aria-label": `Details ${getReferenceString(props.resource)}` }, "Details")),
213
+ props.onEdit && (e__default.createElement(Menu.Item, { icon: e__default.createElement(CY, { size: 14 }), onClick: () => props.onEdit(props.resource), "aria-label": `Edit ${getReferenceString(props.resource)}` }, "Edit")),
214
+ props.onDelete && (e__default.createElement(e__default.Fragment, null,
215
+ e__default.createElement(Menu.Divider, null),
216
+ e__default.createElement(Menu.Label, null, "Danger zone"),
217
+ e__default.createElement(Menu.Item, { color: "red", icon: e__default.createElement(zKe, { size: 14 }), onClick: () => props.onDelete(props.resource), "aria-label": `Delete ${getReferenceString(props.resource)}` }, "Delete")))));
224
218
  }
225
219
  function HistoryTimelineItem(props) {
226
220
  const previous = getPrevious(props.history, props.resource);
227
221
  if (previous) {
228
- return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
229
- React.createElement(ResourceDiffTable, { original: previous, revised: props.resource })));
222
+ return (e__default.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: e__default.createElement(TimelineItemPopupMenu, { ...props }) },
223
+ e__default.createElement(ResourceDiffTable, { original: previous, revised: props.resource })));
230
224
  }
231
225
  else {
232
- return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
233
- React.createElement("h3", null, "Created"),
234
- React.createElement(ResourceTable, { value: props.resource, ignoreMissingValues: true })));
226
+ return (e__default.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: e__default.createElement(TimelineItemPopupMenu, { ...props }) },
227
+ e__default.createElement("h3", null, "Created"),
228
+ e__default.createElement(ResourceTable, { value: props.resource, ignoreMissingValues: true })));
235
229
  }
236
230
  }
237
231
  function getPrevious(history, version) {
@@ -246,8 +240,8 @@ function CommunicationTimelineItem(props) {
246
240
  const { classes } = useStyles();
247
241
  const routine = !props.resource.priority || props.resource.priority === 'routine';
248
242
  const className = routine ? undefined : classes.pinnedComment;
249
- return (React.createElement(TimelineItem, { resource: props.resource, profile: props.resource.sender, padding: true, className: className, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
250
- React.createElement("p", null, props.resource.payload?.[0]?.contentString)));
243
+ return (e__default.createElement(TimelineItem, { resource: props.resource, profile: props.resource.sender, padding: true, className: className, popupMenuItems: e__default.createElement(TimelineItemPopupMenu, { ...props }) },
244
+ e__default.createElement("p", null, props.resource.payload?.[0]?.contentString)));
251
245
  }
252
246
  function MediaTimelineItem(props) {
253
247
  const contentType = props.resource.content?.contentType;
@@ -255,17 +249,17 @@ function MediaTimelineItem(props) {
255
249
  !contentType.startsWith('image/') &&
256
250
  !contentType.startsWith('video/') &&
257
251
  contentType !== 'application/pdf';
258
- return (React.createElement(TimelineItem, { resource: props.resource, padding: !!padding, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
259
- React.createElement(AttachmentDisplay, { value: props.resource.content })));
252
+ return (e__default.createElement(TimelineItem, { resource: props.resource, padding: !!padding, popupMenuItems: e__default.createElement(TimelineItemPopupMenu, { ...props }) },
253
+ e__default.createElement(AttachmentDisplay, { value: props.resource.content })));
260
254
  }
261
255
  function AuditEventTimelineItem(props) {
262
- return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
263
- React.createElement(ScrollArea, null,
264
- React.createElement("pre", null, props.resource.outcomeDesc))));
256
+ return (e__default.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: e__default.createElement(TimelineItemPopupMenu, { ...props }) },
257
+ e__default.createElement(ScrollArea, null,
258
+ e__default.createElement("pre", null, props.resource.outcomeDesc))));
265
259
  }
266
260
  function DiagnosticReportTimelineItem(props) {
267
- return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, { ...props }) },
268
- React.createElement(DiagnosticReportDisplay, { value: props.resource })));
261
+ return (e__default.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: e__default.createElement(TimelineItemPopupMenu, { ...props }) },
262
+ e__default.createElement(DiagnosticReportDisplay, { value: props.resource })));
269
263
  }
270
264
  function getProgressMessage(e) {
271
265
  if (e.lengthComputable) {
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceTimeline.mjs","sources":["../../../src/ResourceTimeline/ResourceTimeline.tsx"],"sourcesContent":["import { ActionIcon, Center, createStyles, Group, Loader, Menu, ScrollArea, TextInput } from '@mantine/core';\nimport { showNotification, updateNotification } from '@mantine/notifications';\nimport { getReferenceString, normalizeErrorString, ProfileResource } from '@medplum/core';\nimport {\n Attachment,\n AuditEvent,\n Bundle,\n BundleEntry,\n Communication,\n DiagnosticReport,\n Media,\n Reference,\n Resource,\n} from '@medplum/fhirtypes';\nimport {\n IconCheck,\n IconCloudUpload,\n IconEdit,\n IconFileAlert,\n IconListDetails,\n IconMessage,\n IconPin,\n IconPinnedOff,\n IconTrash,\n} from '@tabler/icons';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { AttachmentButton } from '../AttachmentButton/AttachmentButton';\nimport { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay';\nimport { DiagnosticReportDisplay } from '../DiagnosticReportDisplay/DiagnosticReportDisplay';\nimport { Form } from '../Form/Form';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { Panel } from '../Panel/Panel';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceDiffTable } from '../ResourceDiffTable/ResourceDiffTable';\nimport { ResourceTable } from '../ResourceTable/ResourceTable';\nimport { Timeline, TimelineItem } from '../Timeline/Timeline';\nimport { useResource } from '../useResource/useResource';\nimport { sortByDateAndPriority } from '../utils/date';\n\nconst useStyles = createStyles((theme) => ({\n pinnedComment: {\n backgroundColor: theme.colors.blue[0],\n },\n}));\n\nexport interface ResourceTimelineProps<T extends Resource> {\n value: T | Reference<T>;\n buildSearchRequests: (resource: T) => Bundle;\n createCommunication?: (resource: T, sender: ProfileResource, text: string) => Communication;\n createMedia?: (resource: T, operator: ProfileResource, attachment: Attachment) => Media;\n}\n\nexport function ResourceTimeline<T extends Resource>(props: ResourceTimelineProps<T>): JSX.Element {\n const navigate = useNavigate();\n const medplum = useMedplum();\n const sender = medplum.getProfile() as ProfileResource;\n const inputRef = useRef<HTMLInputElement>(null);\n const resource = useResource(props.value);\n const [history, setHistory] = useState<Bundle>();\n const [items, setItems] = useState<Resource[]>([]);\n const buildSearchRequests = props.buildSearchRequests;\n\n const itemsRef = useRef<Resource[]>(items);\n itemsRef.current = items;\n\n const loadTimeline = useCallback(() => {\n if (!resource) {\n setItems([]);\n setHistory({} as Bundle);\n return;\n }\n medplum.executeBatch(buildSearchRequests(resource)).then(handleBatchResponse).catch(console.log);\n }, [medplum, resource, buildSearchRequests]);\n\n useEffect(() => {\n loadTimeline();\n }, [loadTimeline]);\n\n /**\n * Handles a batch request response.\n * @param batchResponse The batch response.\n */\n function handleBatchResponse(batchResponse: Bundle): void {\n const newItems = [];\n\n if (batchResponse.entry) {\n for (const batchEntry of batchResponse.entry) {\n const bundle = batchEntry.resource as Bundle;\n if (!bundle) {\n // User may not have access to all resource types\n continue;\n }\n\n if (bundle.type === 'history') {\n setHistory(bundle);\n }\n\n if (bundle.entry) {\n for (const entry of bundle.entry) {\n if (entry.resource) {\n newItems.push(entry.resource);\n }\n }\n }\n }\n\n sortByDateAndPriority(newItems);\n newItems.reverse();\n }\n\n setItems(newItems);\n }\n\n /**\n * Adds an array of resources to the timeline.\n * @param resources Array of resources.\n */\n function addResources(resources: Resource[]): void {\n const newItems = [...itemsRef.current, ...resources];\n sortByDateAndPriority(newItems);\n newItems.reverse();\n setItems(newItems);\n }\n\n /**\n * Adds a Communication resource to the timeline.\n * @param contentString The comment content.\n */\n function createComment(contentString: string): void {\n if (!resource || !props.createCommunication) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createCommunication(resource, sender, contentString))\n .then((result) => {\n addResources([result]);\n })\n .catch(console.log);\n }\n\n /**\n * Adds a Media resource to the timeline.\n * @param attachment The media attachment.\n */\n function createMedia(attachment: Attachment): void {\n if (!resource || !props.createMedia) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createMedia(resource, sender, attachment))\n .then((result) => addResources([result]))\n .then(() =>\n updateNotification({\n id: 'upload-notification',\n color: 'teal',\n title: 'Upload complete',\n message: '',\n icon: <IconCheck size={16} />,\n autoClose: 2000,\n })\n )\n .catch((reason) =>\n updateNotification({\n id: 'upload-notification',\n color: 'red',\n title: 'Upload error',\n message: normalizeErrorString(reason),\n icon: <IconFileAlert size={16} />,\n autoClose: 2000,\n })\n );\n }\n\n function setPriority(\n communication: Communication,\n priority: 'routine' | 'urgent' | 'asap' | 'stat'\n ): Promise<Communication> {\n return medplum.updateResource({ ...communication, priority });\n }\n\n function onPin(communication: Communication): void {\n setPriority(communication, 'stat').then(loadTimeline).catch(console.log);\n }\n\n function onUnpin(communication: Communication): void {\n setPriority(communication, 'routine').then(loadTimeline).catch(console.log);\n }\n\n function onDetails(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}`);\n }\n\n function onEdit(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/edit`);\n }\n\n function onDelete(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/delete`);\n }\n\n function onVersionDetails(version: Resource): void {\n navigate(`/${version.resourceType}/${version.id}/_history/${version.meta?.versionId}`);\n }\n\n function onUploadStart(): void {\n showNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Initializing upload...',\n message: 'Please wait...',\n autoClose: false,\n disallowClose: true,\n });\n }\n\n function onUploadProgress(e: ProgressEvent): void {\n updateNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Uploading...',\n message: getProgressMessage(e),\n autoClose: false,\n disallowClose: true,\n });\n }\n\n if (!resource) {\n return (\n <Center style={{ width: '100%', height: '100%' }}>\n <Loader />\n </Center>\n );\n }\n\n return (\n <Timeline>\n {props.createCommunication && (\n <Panel>\n <Form\n testid=\"timeline-form\"\n onSubmit={(formData: Record<string, string>) => {\n createComment(formData.text);\n\n const input = inputRef.current;\n if (input) {\n input.value = '';\n input.focus();\n }\n }}\n >\n <Group spacing=\"xs\" noWrap style={{ width: '100%' }}>\n <ResourceAvatar value={sender} />\n <TextInput\n name=\"text\"\n ref={inputRef}\n placeholder=\"Add comment\"\n style={{ width: '100%', maxWidth: 300 }}\n />\n <ActionIcon type=\"submit\" radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconMessage size={16} />\n </ActionIcon>\n <AttachmentButton\n onUpload={createMedia}\n onUploadStart={onUploadStart}\n onUploadProgress={onUploadProgress}\n >\n {(props) => (\n <ActionIcon {...props} radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconCloudUpload size={16} />\n </ActionIcon>\n )}\n </AttachmentButton>\n </Group>\n </Form>\n </Panel>\n )}\n {items.map((item) => {\n if (item.resourceType === resource.resourceType && item.id === resource.id) {\n return (\n <HistoryTimelineItem\n key={item.meta?.versionId}\n history={history as Bundle<Resource>}\n resource={item}\n onDetails={onVersionDetails}\n />\n );\n }\n const key = `${item.resourceType}/${item.id}`;\n switch (item.resourceType) {\n case 'AuditEvent':\n return <AuditEventTimelineItem key={key} resource={item} onDetails={onDetails} />;\n case 'Communication':\n return (\n <CommunicationTimelineItem\n key={key}\n resource={item}\n onPin={item.priority !== 'stat' ? onPin : undefined}\n onUnpin={item.priority === 'stat' ? onUnpin : undefined}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'DiagnosticReport':\n return (\n <DiagnosticReportTimelineItem\n key={key}\n resource={item}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'Media':\n return (\n <MediaTimelineItem key={key} resource={item} onDetails={onDetails} onEdit={onEdit} onDelete={onDelete} />\n );\n default:\n return (\n <TimelineItem key={key} resource={item} padding={true}>\n <ResourceTable value={item} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n })}\n </Timeline>\n );\n}\n\ninterface BaseTimelineItemProps<T extends Resource> {\n resource: T;\n onPin?: (resource: T) => void;\n onUnpin?: (resource: T) => void;\n onDetails?: (resource: T) => void;\n onEdit?: (resource: T) => void;\n onDelete?: (resource: T) => void;\n}\n\nfunction TimelineItemPopupMenu<T extends Resource>(props: BaseTimelineItemProps<T>): JSX.Element {\n return (\n <Menu.Dropdown>\n <Menu.Label>Resource</Menu.Label>\n {props.onPin && (\n <Menu.Item\n icon={<IconPin size={14} />}\n onClick={() => (props.onPin as (resource: T) => void)(props.resource)}\n aria-label={`Pin ${getReferenceString(props.resource)}`}\n >\n Pin\n </Menu.Item>\n )}\n {props.onUnpin && (\n <Menu.Item\n icon={<IconPinnedOff size={14} />}\n onClick={() => (props.onUnpin as (resource: T) => void)(props.resource)}\n aria-label={`Unpin ${getReferenceString(props.resource)}`}\n >\n Unpin\n </Menu.Item>\n )}\n {props.onDetails && (\n <Menu.Item\n icon={<IconListDetails size={14} />}\n onClick={() => (props.onDetails as (resource: T) => void)(props.resource)}\n aria-label={`Details ${getReferenceString(props.resource)}`}\n >\n Details\n </Menu.Item>\n )}\n {props.onEdit && (\n <Menu.Item\n icon={<IconEdit size={14} />}\n onClick={() => (props.onEdit as (resource: T) => void)(props.resource)}\n aria-label={`Edit ${getReferenceString(props.resource)}`}\n >\n Edit\n </Menu.Item>\n )}\n {props.onDelete && (\n <>\n <Menu.Divider />\n <Menu.Label>Danger zone</Menu.Label>\n <Menu.Item\n color=\"red\"\n icon={<IconTrash size={14} />}\n onClick={() => (props.onDelete as (resource: T) => void)(props.resource)}\n aria-label={`Delete ${getReferenceString(props.resource)}`}\n >\n Delete\n </Menu.Item>\n </>\n )}\n </Menu.Dropdown>\n );\n}\n\ninterface HistoryTimelineItemProps extends BaseTimelineItemProps<Resource> {\n history: Bundle;\n}\n\nfunction HistoryTimelineItem(props: HistoryTimelineItemProps): JSX.Element {\n const previous = getPrevious(props.history, props.resource);\n if (previous) {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ResourceDiffTable original={previous} revised={props.resource} />\n </TimelineItem>\n );\n } else {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <h3>Created</h3>\n <ResourceTable value={props.resource} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n}\n\nfunction getPrevious(history: Bundle, version: Resource): Resource | undefined {\n const entries = history.entry as BundleEntry[];\n const index = entries.findIndex((entry) => entry.resource?.meta?.versionId === version.meta?.versionId);\n if (index >= entries.length - 1) {\n return undefined;\n }\n return entries[index + 1].resource;\n}\n\nfunction CommunicationTimelineItem(props: BaseTimelineItemProps<Communication>): JSX.Element {\n const { classes } = useStyles();\n const routine = !props.resource.priority || props.resource.priority === 'routine';\n const className = routine ? undefined : classes.pinnedComment;\n return (\n <TimelineItem\n resource={props.resource}\n profile={props.resource.sender}\n padding={true}\n className={className}\n popupMenuItems={<TimelineItemPopupMenu {...props} />}\n >\n <p>{props.resource.payload?.[0]?.contentString}</p>\n </TimelineItem>\n );\n}\n\nfunction MediaTimelineItem(props: BaseTimelineItemProps<Media>): JSX.Element {\n const contentType = props.resource.content?.contentType;\n const padding =\n contentType &&\n !contentType.startsWith('image/') &&\n !contentType.startsWith('video/') &&\n contentType !== 'application/pdf';\n return (\n <TimelineItem resource={props.resource} padding={!!padding} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <AttachmentDisplay value={props.resource.content} />\n </TimelineItem>\n );\n}\n\nfunction AuditEventTimelineItem(props: BaseTimelineItemProps<AuditEvent>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ScrollArea>\n <pre>{props.resource.outcomeDesc}</pre>\n </ScrollArea>\n </TimelineItem>\n );\n}\n\nfunction DiagnosticReportTimelineItem(props: BaseTimelineItemProps<DiagnosticReport>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <DiagnosticReportDisplay value={props.resource} />\n </TimelineItem>\n );\n}\n\nfunction getProgressMessage(e: ProgressEvent): string {\n if (e.lengthComputable) {\n const percent = (100 * e.loaded) / e.total;\n return `Uploaded: ${formatFileSize(e.loaded)} / ${formatFileSize(e.total)} ${percent.toFixed(2)}%`;\n }\n return `Uploaded: ${formatFileSize(e.loaded)}`;\n}\n\nfunction formatFileSize(bytes: number): string {\n if (bytes == 0) {\n return '0.00 B';\n }\n const e = Math.floor(Math.log(bytes) / Math.log(1024));\n return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,aAAa,EAAE;QACb,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,KAAA;AACF,CAAA,CAAC,CAAC,CAAC;AASE,SAAU,gBAAgB,CAAqB,KAA+B,EAAA;AAClF,IAAA,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;AAC/B,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAqB,CAAC;AACvD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAU,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;AACnD,IAAA,MAAM,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC;AAEtD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAa,KAAK,CAAC,CAAC;AAC3C,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;AAEzB,IAAA,MAAM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OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,oBAAC,qBAAqB,EAAA,EAAA,GAAK,KAAK,EAAI,CAAA,EAAA;QACzG,KAAC,CAAA,aAAA,CAAA,uBAAuB,EAAC,EAAA,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAI,CACrC,EACf;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAgB,EAAA;IAC1C,IAAI,CAAC,CAAC,gBAAgB,EAAE;AACtB,QAAA,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC;QAC3C,OAAO,CAAA,UAAA,EAAa,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAM,GAAA,EAAA,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAA,CAAG,CAAC;AACpG,KAAA;IACD,OAAO,CAAA,UAAA,EAAa,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAA;IACnC,IAAI,KAAK,IAAI,CAAC,EAAE;AACd,QAAA,OAAO,QAAQ,CAAC;AACjB,KAAA;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,IAAA,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AACjF;;;;"}
1
+ {"version":3,"file":"ResourceTimeline.mjs","sources":["../../../src/ResourceTimeline/ResourceTimeline.tsx"],"sourcesContent":["import { ActionIcon, Center, createStyles, Group, Loader, Menu, ScrollArea, TextInput } from '@mantine/core';\nimport { showNotification, updateNotification } from '@mantine/notifications';\nimport { getReferenceString, MedplumClient, normalizeErrorString, ProfileResource } from '@medplum/core';\nimport {\n Attachment,\n AuditEvent,\n Bundle,\n BundleEntry,\n Communication,\n DiagnosticReport,\n Media,\n Reference,\n Resource,\n} from '@medplum/fhirtypes';\nimport {\n IconCheck,\n IconCloudUpload,\n IconEdit,\n IconFileAlert,\n IconListDetails,\n IconMessage,\n IconPin,\n IconPinnedOff,\n IconTrash,\n} from '@tabler/icons';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { AttachmentButton } from '../AttachmentButton/AttachmentButton';\nimport { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay';\nimport { DiagnosticReportDisplay } from '../DiagnosticReportDisplay/DiagnosticReportDisplay';\nimport { Form } from '../Form/Form';\nimport { useMedplum, useMedplumNavigate } from '../MedplumProvider/MedplumProvider';\nimport { Panel } from '../Panel/Panel';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceDiffTable } from '../ResourceDiffTable/ResourceDiffTable';\nimport { ResourceTable } from '../ResourceTable/ResourceTable';\nimport { Timeline, TimelineItem } from '../Timeline/Timeline';\nimport { useResource } from '../useResource/useResource';\nimport { sortByDateAndPriority } from '../utils/date';\n\nconst useStyles = createStyles((theme) => ({\n pinnedComment: {\n backgroundColor: theme.colors.blue[0],\n },\n}));\n\nexport interface ResourceTimelineProps<T extends Resource> {\n value: T | Reference<T>;\n loadTimelineResources: (medplum: MedplumClient, resource: T) => Promise<Bundle[]>;\n createCommunication?: (resource: T, sender: ProfileResource, text: string) => Communication;\n createMedia?: (resource: T, operator: ProfileResource, attachment: Attachment) => Media;\n}\n\nexport function ResourceTimeline<T extends Resource>(props: ResourceTimelineProps<T>): JSX.Element {\n const medplum = useMedplum();\n const navigate = useMedplumNavigate();\n const sender = medplum.getProfile() as ProfileResource;\n const inputRef = useRef<HTMLInputElement>(null);\n const resource = useResource(props.value);\n const [history, setHistory] = useState<Bundle>();\n const [items, setItems] = useState<Resource[]>([]);\n const loadTimelineResources = props.loadTimelineResources;\n\n const itemsRef = useRef<Resource[]>(items);\n itemsRef.current = items;\n\n const loadTimeline = useCallback(() => {\n if (!resource) {\n setItems([]);\n setHistory({} as Bundle);\n return;\n }\n loadTimelineResources(medplum, resource).then(handleBatchResponse).catch(console.log);\n }, [medplum, resource, loadTimelineResources]);\n\n useEffect(() => {\n loadTimeline();\n }, [loadTimeline]);\n\n /**\n * Handles a batch request response.\n * @param batchResponse The batch response.\n */\n function handleBatchResponse(bundles: Bundle[]): void {\n const newItems = [];\n\n for (const bundle of bundles) {\n if (!bundle) {\n // User may not have access to all resource types\n continue;\n }\n\n if (bundle.type === 'history') {\n setHistory(bundle);\n }\n\n if (bundle.entry) {\n for (const entry of bundle.entry) {\n newItems.push(entry.resource as Resource);\n }\n }\n }\n\n sortByDateAndPriority(newItems);\n newItems.reverse();\n setItems(newItems);\n }\n\n /**\n * Adds an array of resources to the timeline.\n * @param resources Array of resources.\n */\n function addResources(resources: Resource[]): void {\n const newItems = [...itemsRef.current, ...resources];\n sortByDateAndPriority(newItems);\n newItems.reverse();\n setItems(newItems);\n }\n\n /**\n * Adds a Communication resource to the timeline.\n * @param contentString The comment content.\n */\n function createComment(contentString: string): void {\n if (!resource || !props.createCommunication) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createCommunication(resource, sender, contentString))\n .then((result) => {\n addResources([result]);\n })\n .catch(console.log);\n }\n\n /**\n * Adds a Media resource to the timeline.\n * @param attachment The media attachment.\n */\n function createMedia(attachment: Attachment): void {\n if (!resource || !props.createMedia) {\n // Encounter not loaded yet\n return;\n }\n medplum\n .createResource(props.createMedia(resource, sender, attachment))\n .then((result) => addResources([result]))\n .then(() =>\n updateNotification({\n id: 'upload-notification',\n color: 'teal',\n title: 'Upload complete',\n message: '',\n icon: <IconCheck size={16} />,\n autoClose: 2000,\n })\n )\n .catch((reason) =>\n updateNotification({\n id: 'upload-notification',\n color: 'red',\n title: 'Upload error',\n message: normalizeErrorString(reason),\n icon: <IconFileAlert size={16} />,\n autoClose: 2000,\n })\n );\n }\n\n function setPriority(\n communication: Communication,\n priority: 'routine' | 'urgent' | 'asap' | 'stat'\n ): Promise<Communication> {\n return medplum.updateResource({ ...communication, priority });\n }\n\n function onPin(communication: Communication): void {\n setPriority(communication, 'stat').then(loadTimeline).catch(console.log);\n }\n\n function onUnpin(communication: Communication): void {\n setPriority(communication, 'routine').then(loadTimeline).catch(console.log);\n }\n\n function onDetails(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}`);\n }\n\n function onEdit(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/edit`);\n }\n\n function onDelete(timelineItem: Resource): void {\n navigate(`/${timelineItem.resourceType}/${timelineItem.id}/delete`);\n }\n\n function onVersionDetails(version: Resource): void {\n navigate(`/${version.resourceType}/${version.id}/_history/${version.meta?.versionId}`);\n }\n\n function onUploadStart(): void {\n showNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Initializing upload...',\n message: 'Please wait...',\n autoClose: false,\n disallowClose: true,\n });\n }\n\n function onUploadProgress(e: ProgressEvent): void {\n updateNotification({\n id: 'upload-notification',\n loading: true,\n title: 'Uploading...',\n message: getProgressMessage(e),\n autoClose: false,\n disallowClose: true,\n });\n }\n\n if (!resource) {\n return (\n <Center style={{ width: '100%', height: '100%' }}>\n <Loader />\n </Center>\n );\n }\n\n return (\n <Timeline>\n {props.createCommunication && (\n <Panel>\n <Form\n testid=\"timeline-form\"\n onSubmit={(formData: Record<string, string>) => {\n createComment(formData.text);\n\n const input = inputRef.current;\n if (input) {\n input.value = '';\n input.focus();\n }\n }}\n >\n <Group spacing=\"xs\" noWrap style={{ width: '100%' }}>\n <ResourceAvatar value={sender} />\n <TextInput\n name=\"text\"\n ref={inputRef}\n placeholder=\"Add comment\"\n style={{ width: '100%', maxWidth: 300 }}\n />\n <ActionIcon type=\"submit\" radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconMessage size={16} />\n </ActionIcon>\n <AttachmentButton\n onUpload={createMedia}\n onUploadStart={onUploadStart}\n onUploadProgress={onUploadProgress}\n >\n {(props) => (\n <ActionIcon {...props} radius=\"xl\" color=\"blue\" variant=\"filled\">\n <IconCloudUpload size={16} />\n </ActionIcon>\n )}\n </AttachmentButton>\n </Group>\n </Form>\n </Panel>\n )}\n {items.map((item) => {\n const key = `${item.resourceType}/${item.id}/${item.meta?.versionId}`;\n if (item.resourceType === resource.resourceType && item.id === resource.id) {\n return (\n <HistoryTimelineItem\n key={key}\n history={history as Bundle<Resource>}\n resource={item}\n onDetails={onVersionDetails}\n />\n );\n }\n switch (item.resourceType) {\n case 'AuditEvent':\n return <AuditEventTimelineItem key={key} resource={item} onDetails={onDetails} />;\n case 'Communication':\n return (\n <CommunicationTimelineItem\n key={key}\n resource={item}\n onPin={item.priority !== 'stat' ? onPin : undefined}\n onUnpin={item.priority === 'stat' ? onUnpin : undefined}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'DiagnosticReport':\n return (\n <DiagnosticReportTimelineItem\n key={key}\n resource={item}\n onDetails={onDetails}\n onEdit={onEdit}\n onDelete={onDelete}\n />\n );\n case 'Media':\n return (\n <MediaTimelineItem key={key} resource={item} onDetails={onDetails} onEdit={onEdit} onDelete={onDelete} />\n );\n default:\n return (\n <TimelineItem key={key} resource={item} padding={true}>\n <ResourceTable value={item} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n })}\n </Timeline>\n );\n}\n\ninterface BaseTimelineItemProps<T extends Resource> {\n resource: T;\n onPin?: (resource: T) => void;\n onUnpin?: (resource: T) => void;\n onDetails?: (resource: T) => void;\n onEdit?: (resource: T) => void;\n onDelete?: (resource: T) => void;\n}\n\nfunction TimelineItemPopupMenu<T extends Resource>(props: BaseTimelineItemProps<T>): JSX.Element {\n return (\n <Menu.Dropdown>\n <Menu.Label>Resource</Menu.Label>\n {props.onPin && (\n <Menu.Item\n icon={<IconPin size={14} />}\n onClick={() => (props.onPin as (resource: T) => void)(props.resource)}\n aria-label={`Pin ${getReferenceString(props.resource)}`}\n >\n Pin\n </Menu.Item>\n )}\n {props.onUnpin && (\n <Menu.Item\n icon={<IconPinnedOff size={14} />}\n onClick={() => (props.onUnpin as (resource: T) => void)(props.resource)}\n aria-label={`Unpin ${getReferenceString(props.resource)}`}\n >\n Unpin\n </Menu.Item>\n )}\n {props.onDetails && (\n <Menu.Item\n icon={<IconListDetails size={14} />}\n onClick={() => (props.onDetails as (resource: T) => void)(props.resource)}\n aria-label={`Details ${getReferenceString(props.resource)}`}\n >\n Details\n </Menu.Item>\n )}\n {props.onEdit && (\n <Menu.Item\n icon={<IconEdit size={14} />}\n onClick={() => (props.onEdit as (resource: T) => void)(props.resource)}\n aria-label={`Edit ${getReferenceString(props.resource)}`}\n >\n Edit\n </Menu.Item>\n )}\n {props.onDelete && (\n <>\n <Menu.Divider />\n <Menu.Label>Danger zone</Menu.Label>\n <Menu.Item\n color=\"red\"\n icon={<IconTrash size={14} />}\n onClick={() => (props.onDelete as (resource: T) => void)(props.resource)}\n aria-label={`Delete ${getReferenceString(props.resource)}`}\n >\n Delete\n </Menu.Item>\n </>\n )}\n </Menu.Dropdown>\n );\n}\n\ninterface HistoryTimelineItemProps extends BaseTimelineItemProps<Resource> {\n history: Bundle;\n}\n\nfunction HistoryTimelineItem(props: HistoryTimelineItemProps): JSX.Element {\n const previous = getPrevious(props.history, props.resource);\n if (previous) {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ResourceDiffTable original={previous} revised={props.resource} />\n </TimelineItem>\n );\n } else {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <h3>Created</h3>\n <ResourceTable value={props.resource} ignoreMissingValues={true} />\n </TimelineItem>\n );\n }\n}\n\nfunction getPrevious(history: Bundle, version: Resource): Resource | undefined {\n const entries = history.entry as BundleEntry[];\n const index = entries.findIndex((entry) => entry.resource?.meta?.versionId === version.meta?.versionId);\n if (index >= entries.length - 1) {\n return undefined;\n }\n return entries[index + 1].resource;\n}\n\nfunction CommunicationTimelineItem(props: BaseTimelineItemProps<Communication>): JSX.Element {\n const { classes } = useStyles();\n const routine = !props.resource.priority || props.resource.priority === 'routine';\n const className = routine ? undefined : classes.pinnedComment;\n return (\n <TimelineItem\n resource={props.resource}\n profile={props.resource.sender}\n padding={true}\n className={className}\n popupMenuItems={<TimelineItemPopupMenu {...props} />}\n >\n <p>{props.resource.payload?.[0]?.contentString}</p>\n </TimelineItem>\n );\n}\n\nfunction MediaTimelineItem(props: BaseTimelineItemProps<Media>): JSX.Element {\n const contentType = props.resource.content?.contentType;\n const padding =\n contentType &&\n !contentType.startsWith('image/') &&\n !contentType.startsWith('video/') &&\n contentType !== 'application/pdf';\n return (\n <TimelineItem resource={props.resource} padding={!!padding} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <AttachmentDisplay value={props.resource.content} />\n </TimelineItem>\n );\n}\n\nfunction AuditEventTimelineItem(props: BaseTimelineItemProps<AuditEvent>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <ScrollArea>\n <pre>{props.resource.outcomeDesc}</pre>\n </ScrollArea>\n </TimelineItem>\n );\n}\n\nfunction DiagnosticReportTimelineItem(props: BaseTimelineItemProps<DiagnosticReport>): JSX.Element {\n return (\n <TimelineItem resource={props.resource} padding={true} popupMenuItems={<TimelineItemPopupMenu {...props} />}>\n <DiagnosticReportDisplay value={props.resource} />\n </TimelineItem>\n );\n}\n\nfunction getProgressMessage(e: ProgressEvent): string {\n if (e.lengthComputable) {\n const percent = (100 * e.loaded) / e.total;\n return `Uploaded: ${formatFileSize(e.loaded)} / ${formatFileSize(e.total)} ${percent.toFixed(2)}%`;\n }\n return `Uploaded: ${formatFileSize(e.loaded)}`;\n}\n\nfunction formatFileSize(bytes: number): string {\n if (bytes == 0) {\n return '0.00 B';\n }\n const e = Math.floor(Math.log(bytes) / Math.log(1024));\n return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';\n}\n"],"names":["React","IconCheck","IconFileAlert","IconMessage","IconCloudUpload","IconPin","IconPinnedOff","IconListDetails","IconEdit","IconTrash"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,aAAa,EAAE;QACb,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,KAAA;AACF,CAAA,CAAC,CAAC,CAAC;AASE,SAAU,gBAAgB,CAAqB,KAA+B,EAAA;AAClF,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAC;AACtC,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAqB,CAAC;AACvD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAU,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;AACnD,IAAA,MAAM,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAC;AAE1D,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAa,KAAK,CAAC,CAAC;AAC3C,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;AAEzB,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;QACpC,IAAI,CAAC,QAAQ,EAAE;YACb,QAAQ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;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAgB,EAAA;IAC1C,IAAI,CAAC,CAAC,gBAAgB,EAAE;AACtB,QAAA,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC;QAC3C,OAAO,CAAA,UAAA,EAAa,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAM,GAAA,EAAA,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAA,CAAG,CAAC;AACpG,KAAA;IACD,OAAO,CAAA,UAAA,EAAa,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAA;IACnC,IAAI,KAAK,IAAI,CAAC,EAAE;AACd,QAAA,OAAO,QAAQ,CAAC;AACjB,KAAA;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,IAAA,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AACjF;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { createStyles, Text, Stack, Button } from '@mantine/core';
2
2
  import { getReferenceString } from '@medplum/core';
3
- import React, { useState, useRef, useEffect } from 'react';
3
+ import e__default, { useState, useRef, useEffect } from 'react';
4
4
  import { getStartMonth, CalendarInput } from '../CalendarInput/CalendarInput.mjs';
5
5
  import { useMedplum } from '../MedplumProvider/MedplumProvider.mjs';
6
6
  import { QuestionnaireForm } from '../QuestionnaireForm/QuestionnaireForm.mjs';
@@ -56,30 +56,30 @@ function Scheduler(props) {
56
56
  return null;
57
57
  }
58
58
  const actor = schedule.actor?.[0];
59
- return (React.createElement("div", { className: classes.container, "data-testid": "scheduler" },
60
- React.createElement("div", { className: classes.info },
61
- actor && React.createElement(ResourceAvatar, { value: actor, size: "xl" }),
62
- actor && (React.createElement(Text, { size: "xl", weight: 500 },
63
- React.createElement(ResourceName, { value: actor }))),
64
- React.createElement("p", null, "1 hour"),
65
- date && React.createElement("p", null, date.toLocaleDateString()),
66
- slot && React.createElement("p", null, formatTime(new Date(slot.start)))),
67
- React.createElement("div", { className: classes.selection },
68
- !date && (React.createElement("div", null,
69
- React.createElement("h3", null, "Select date"),
70
- React.createElement(CalendarInput, { slots: slots, onChangeMonth: setMonth, onClick: setDate }))),
71
- date && !slot && (React.createElement("div", null,
72
- React.createElement("h3", null, "Select time"),
73
- React.createElement(Stack, null, slots.map((s) => {
59
+ return (e__default.createElement("div", { className: classes.container, "data-testid": "scheduler" },
60
+ e__default.createElement("div", { className: classes.info },
61
+ actor && e__default.createElement(ResourceAvatar, { value: actor, size: "xl" }),
62
+ actor && (e__default.createElement(Text, { size: "xl", weight: 500 },
63
+ e__default.createElement(ResourceName, { value: actor }))),
64
+ e__default.createElement("p", null, "1 hour"),
65
+ date && e__default.createElement("p", null, date.toLocaleDateString()),
66
+ slot && e__default.createElement("p", null, formatTime(new Date(slot.start)))),
67
+ e__default.createElement("div", { className: classes.selection },
68
+ !date && (e__default.createElement("div", null,
69
+ e__default.createElement("h3", null, "Select date"),
70
+ e__default.createElement(CalendarInput, { slots: slots, onChangeMonth: setMonth, onClick: setDate }))),
71
+ date && !slot && (e__default.createElement("div", null,
72
+ e__default.createElement("h3", null, "Select time"),
73
+ e__default.createElement(Stack, null, slots.map((s) => {
74
74
  const slotStart = new Date(s.start);
75
75
  return (slotStart.getTime() > date.getTime() &&
76
- slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (React.createElement("div", { key: s.id },
77
- React.createElement(Button, { variant: "outline", style: { width: 150 }, onClick: () => setSlot(s) }, formatTime(slotStart)))));
76
+ slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (e__default.createElement("div", { key: s.id },
77
+ e__default.createElement(Button, { variant: "outline", style: { width: 150 }, onClick: () => setSlot(s) }, formatTime(slotStart)))));
78
78
  })))),
79
- date && slot && !response && (React.createElement(QuestionnaireForm, { questionnaire: questionnaire, submitButtonText: 'Next', onSubmit: setResponse })),
80
- date && slot && response && (React.createElement("div", null,
81
- React.createElement("h3", null, "You're all set!"),
82
- React.createElement("p", null, "Check your email for a calendar invite."))))));
79
+ date && slot && !response && (e__default.createElement(QuestionnaireForm, { questionnaire: questionnaire, submitButtonText: 'Next', onSubmit: setResponse })),
80
+ date && slot && response && (e__default.createElement("div", null,
81
+ e__default.createElement("h3", null, "You're all set!"),
82
+ e__default.createElement("p", null, "Check your email for a calendar invite."))))));
83
83
  }
84
84
  function getStart(month) {
85
85
  return formatSlotInstant(month.getTime());
@@ -1 +1 @@
1
- {"version":3,"file":"Scheduler.mjs","sources":["../../../src/Scheduler/Scheduler.tsx"],"sourcesContent":["import { Button, createStyles, Stack, Text } from '@mantine/core';\nimport { getReferenceString } from '@medplum/core';\nimport { Questionnaire, QuestionnaireResponse, Reference, Schedule, Slot } from '@medplum/fhirtypes';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CalendarInput, getStartMonth } from '../CalendarInput/CalendarInput';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { QuestionnaireForm } from '../QuestionnaireForm/QuestionnaireForm';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceName } from '../ResourceName/ResourceName';\nimport { useResource } from '../useResource/useResource';\n\nconst useStyles = createStyles((theme) => ({\n container: {\n display: 'flex',\n minHeight: 400,\n },\n\n info: {\n minWidth: 300,\n padding: 20,\n borderRight: `1px solid ${theme.colors.gray[3]}`,\n },\n\n selection: {\n minWidth: 300,\n padding: 20,\n },\n}));\n\nexport interface SchedulerProps {\n schedule: Schedule | Reference<Schedule>;\n questionnaire: Questionnaire | Reference<Questionnaire>;\n}\n\nexport function Scheduler(props: SchedulerProps): JSX.Element | null {\n const { classes } = useStyles();\n const medplum = useMedplum();\n const schedule = useResource(props.schedule);\n const questionnaire = useResource(props.questionnaire);\n\n const [slots, setSlots] = useState<Slot[]>();\n const slotsRef = useRef<Slot[]>();\n slotsRef.current = slots;\n\n const [month, setMonth] = useState<Date>(getStartMonth());\n const [date, setDate] = useState<Date>();\n const [slot, setSlot] = useState<Slot>();\n const [response, setResponse] = useState<QuestionnaireResponse>();\n\n useEffect(() => {\n if (schedule) {\n setSlots([]);\n medplum\n .searchResources(\n 'Slot',\n new URLSearchParams([\n ['_count', (30 * 24).toString()],\n ['schedule', getReferenceString(schedule)],\n ['start', 'gt' + getStart(month)],\n ['start', 'lt' + getEnd(month)],\n ])\n )\n .then(setSlots)\n .catch(console.log);\n } else {\n setSlots(undefined);\n }\n }, [medplum, schedule, month]);\n\n if (!schedule || !slots || !questionnaire) {\n return null;\n }\n\n const actor = schedule.actor?.[0];\n\n return (\n <div className={classes.container} data-testid=\"scheduler\">\n <div className={classes.info}>\n {actor && <ResourceAvatar value={actor} size=\"xl\" />}\n {actor && (\n <Text size=\"xl\" weight={500}>\n <ResourceName value={actor} />\n </Text>\n )}\n <p>1 hour</p>\n {date && <p>{date.toLocaleDateString()}</p>}\n {slot && <p>{formatTime(new Date(slot.start as string))}</p>}\n </div>\n <div className={classes.selection}>\n {!date && (\n <div>\n <h3>Select date</h3>\n <CalendarInput slots={slots} onChangeMonth={setMonth} onClick={setDate} />\n </div>\n )}\n {date && !slot && (\n <div>\n <h3>Select time</h3>\n <Stack>\n {slots.map((s) => {\n const slotStart = new Date(s.start as string);\n return (\n slotStart.getTime() > date.getTime() &&\n slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (\n <div key={s.id}>\n <Button variant=\"outline\" style={{ width: 150 }} onClick={() => setSlot(s)}>\n {formatTime(slotStart)}\n </Button>\n </div>\n )\n );\n })}\n </Stack>\n </div>\n )}\n {date && slot && !response && (\n <QuestionnaireForm questionnaire={questionnaire} submitButtonText={'Next'} onSubmit={setResponse} />\n )}\n {date && slot && response && (\n <div>\n <h3>You're all set!</h3>\n <p>Check your email for a calendar invite.</p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction getStart(month: Date): string {\n return formatSlotInstant(month.getTime());\n}\n\nfunction getEnd(month: Date): string {\n return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);\n}\n\nfunction formatSlotInstant(time: number): string {\n return new Date(Math.max(Date.now(), time)).toISOString();\n}\n\nfunction formatTime(date: Date): string {\n return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAWA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,SAAS,EAAE;AACT,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,SAAS,EAAE,GAAG;AACf,KAAA;AAED,IAAA,IAAI,EAAE;AACJ,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAa,UAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAA;AACjD,KAAA;AAED,IAAA,SAAS,EAAE;AACT,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,OAAO,EAAE,EAAE;AACZ,KAAA;AACF,CAAA,CAAC,CAAC,CAAC;AAOE,SAAU,SAAS,CAAC,KAAqB,EAAA;AAC7C,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAChC,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,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F,EACN;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAW,EAAA;AAC3B,IAAA,OAAO,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,KAAW,EAAA;AACzB,IAAA,OAAO,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAA;AACrC,IAAA,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,UAAU,CAAC,IAAU,EAAA;AAC5B,IAAA,OAAO,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAC7E;;;;"}
1
+ {"version":3,"file":"Scheduler.mjs","sources":["../../../src/Scheduler/Scheduler.tsx"],"sourcesContent":["import { Button, createStyles, Stack, Text } from '@mantine/core';\nimport { getReferenceString } from '@medplum/core';\nimport { Questionnaire, QuestionnaireResponse, Reference, Schedule, Slot } from '@medplum/fhirtypes';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CalendarInput, getStartMonth } from '../CalendarInput/CalendarInput';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { QuestionnaireForm } from '../QuestionnaireForm/QuestionnaireForm';\nimport { ResourceAvatar } from '../ResourceAvatar/ResourceAvatar';\nimport { ResourceName } from '../ResourceName/ResourceName';\nimport { useResource } from '../useResource/useResource';\n\nconst useStyles = createStyles((theme) => ({\n container: {\n display: 'flex',\n minHeight: 400,\n },\n\n info: {\n minWidth: 300,\n padding: 20,\n borderRight: `1px solid ${theme.colors.gray[3]}`,\n },\n\n selection: {\n minWidth: 300,\n padding: 20,\n },\n}));\n\nexport interface SchedulerProps {\n schedule: Schedule | Reference<Schedule>;\n questionnaire: Questionnaire | Reference<Questionnaire>;\n}\n\nexport function Scheduler(props: SchedulerProps): JSX.Element | null {\n const { classes } = useStyles();\n const medplum = useMedplum();\n const schedule = useResource(props.schedule);\n const questionnaire = useResource(props.questionnaire);\n\n const [slots, setSlots] = useState<Slot[]>();\n const slotsRef = useRef<Slot[]>();\n slotsRef.current = slots;\n\n const [month, setMonth] = useState<Date>(getStartMonth());\n const [date, setDate] = useState<Date>();\n const [slot, setSlot] = useState<Slot>();\n const [response, setResponse] = useState<QuestionnaireResponse>();\n\n useEffect(() => {\n if (schedule) {\n setSlots([]);\n medplum\n .searchResources(\n 'Slot',\n new URLSearchParams([\n ['_count', (30 * 24).toString()],\n ['schedule', getReferenceString(schedule)],\n ['start', 'gt' + getStart(month)],\n ['start', 'lt' + getEnd(month)],\n ])\n )\n .then(setSlots)\n .catch(console.log);\n } else {\n setSlots(undefined);\n }\n }, [medplum, schedule, month]);\n\n if (!schedule || !slots || !questionnaire) {\n return null;\n }\n\n const actor = schedule.actor?.[0];\n\n return (\n <div className={classes.container} data-testid=\"scheduler\">\n <div className={classes.info}>\n {actor && <ResourceAvatar value={actor} size=\"xl\" />}\n {actor && (\n <Text size=\"xl\" weight={500}>\n <ResourceName value={actor} />\n </Text>\n )}\n <p>1 hour</p>\n {date && <p>{date.toLocaleDateString()}</p>}\n {slot && <p>{formatTime(new Date(slot.start as string))}</p>}\n </div>\n <div className={classes.selection}>\n {!date && (\n <div>\n <h3>Select date</h3>\n <CalendarInput slots={slots} onChangeMonth={setMonth} onClick={setDate} />\n </div>\n )}\n {date && !slot && (\n <div>\n <h3>Select time</h3>\n <Stack>\n {slots.map((s) => {\n const slotStart = new Date(s.start as string);\n return (\n slotStart.getTime() > date.getTime() &&\n slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (\n <div key={s.id}>\n <Button variant=\"outline\" style={{ width: 150 }} onClick={() => setSlot(s)}>\n {formatTime(slotStart)}\n </Button>\n </div>\n )\n );\n })}\n </Stack>\n </div>\n )}\n {date && slot && !response && (\n <QuestionnaireForm questionnaire={questionnaire} submitButtonText={'Next'} onSubmit={setResponse} />\n )}\n {date && slot && response && (\n <div>\n <h3>You're all set!</h3>\n <p>Check your email for a calendar invite.</p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction getStart(month: Date): string {\n return formatSlotInstant(month.getTime());\n}\n\nfunction getEnd(month: Date): string {\n return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);\n}\n\nfunction formatSlotInstant(time: number): string {\n return new Date(Math.max(Date.now(), time)).toISOString();\n}\n\nfunction formatTime(date: Date): string {\n return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n}\n"],"names":["React"],"mappings":";;;;;;;;;;AAWA,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM;AACzC,IAAA,SAAS,EAAE;AACT,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,SAAS,EAAE,GAAG;AACf,KAAA;AAED,IAAA,IAAI,EAAE;AACJ,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAa,UAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAA;AACjD,KAAA;AAED,IAAA,SAAS,EAAE;AACT,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,OAAO,EAAE,EAAE;AACZ,KAAA;AACF,CAAA,CAAC,CAAC,CAAC;AAOE,SAAU,SAAS,CAAC,KAAqB,EAAA;AAC7C,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAChC,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C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