@medplum/react 0.9.25 → 0.9.26

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 (407) hide show
  1. package/dist/cjs/index.js.map +1 -1
  2. package/dist/cjs/index.min.js.map +1 -1
  3. package/dist/{types → esm}/AddressDisplay.d.ts +0 -0
  4. package/dist/esm/AddressDisplay.js +13 -0
  5. package/dist/esm/AddressDisplay.js.map +1 -0
  6. package/dist/{types → esm}/AddressInput.d.ts +0 -0
  7. package/dist/esm/AddressInput.js +69 -0
  8. package/dist/esm/AddressInput.js.map +1 -0
  9. package/dist/{types → esm}/AnnotationInput.d.ts +0 -0
  10. package/dist/esm/AnnotationInput.js +28 -0
  11. package/dist/esm/AnnotationInput.js.map +1 -0
  12. package/dist/{types → esm}/AttachmentArrayDisplay.d.ts +0 -0
  13. package/dist/esm/AttachmentArrayDisplay.js +11 -0
  14. package/dist/esm/AttachmentArrayDisplay.js.map +1 -0
  15. package/dist/{types → esm}/AttachmentArrayInput.d.ts +0 -0
  16. package/dist/esm/AttachmentArrayInput.js +42 -0
  17. package/dist/esm/AttachmentArrayInput.js.map +1 -0
  18. package/dist/{types → esm}/AttachmentDisplay.d.ts +0 -0
  19. package/dist/esm/AttachmentDisplay.js +20 -0
  20. package/dist/esm/AttachmentDisplay.js.map +1 -0
  21. package/dist/{types → esm}/AttachmentInput.d.ts +0 -0
  22. package/dist/esm/AttachmentInput.js +27 -0
  23. package/dist/esm/AttachmentInput.js.map +1 -0
  24. package/dist/{types → esm}/Autocomplete.d.ts +0 -0
  25. package/dist/esm/Autocomplete.js +284 -0
  26. package/dist/esm/Autocomplete.js.map +1 -0
  27. package/dist/{types → esm}/Avatar.d.ts +0 -0
  28. package/dist/esm/Avatar.js +24 -0
  29. package/dist/esm/Avatar.js.map +1 -0
  30. package/dist/{types → esm}/BackboneElementDisplay.d.ts +0 -0
  31. package/dist/esm/BackboneElementDisplay.js +43 -0
  32. package/dist/esm/BackboneElementDisplay.js.map +1 -0
  33. package/dist/{types → esm}/BackboneElementInput.d.ts +0 -0
  34. package/dist/esm/BackboneElementInput.js +51 -0
  35. package/dist/esm/BackboneElementInput.js.map +1 -0
  36. package/dist/{types → esm}/Button.d.ts +0 -0
  37. package/dist/esm/Button.js +13 -0
  38. package/dist/esm/Button.js.map +1 -0
  39. package/dist/{types → esm}/CalendarInput.d.ts +0 -0
  40. package/dist/esm/CalendarInput.js +96 -0
  41. package/dist/esm/CalendarInput.js.map +1 -0
  42. package/dist/{types → esm}/Checkbox.d.ts +0 -0
  43. package/dist/esm/Checkbox.js +13 -0
  44. package/dist/esm/Checkbox.js.map +1 -0
  45. package/dist/{types → esm}/CheckboxFormSection.d.ts +0 -0
  46. package/dist/esm/CheckboxFormSection.js +12 -0
  47. package/dist/esm/CheckboxFormSection.js.map +1 -0
  48. package/dist/{types → esm}/CodeInput.d.ts +0 -0
  49. package/dist/esm/CodeInput.js +28 -0
  50. package/dist/esm/CodeInput.js.map +1 -0
  51. package/dist/{types → esm}/CodeableConceptDisplay.d.ts +0 -0
  52. package/dist/esm/CodeableConceptDisplay.js +19 -0
  53. package/dist/esm/CodeableConceptDisplay.js.map +1 -0
  54. package/dist/{types → esm}/CodeableConceptInput.d.ts +0 -0
  55. package/dist/esm/CodeableConceptInput.js +52 -0
  56. package/dist/esm/CodeableConceptInput.js.map +1 -0
  57. package/dist/{types → esm}/CodingDisplay.d.ts +0 -0
  58. package/dist/esm/CodingDisplay.js +9 -0
  59. package/dist/esm/CodingDisplay.js.map +1 -0
  60. package/dist/{types → esm}/CodingInput.d.ts +0 -0
  61. package/dist/esm/CodingInput.js +30 -0
  62. package/dist/esm/CodingInput.js.map +1 -0
  63. package/dist/{types → esm}/ContactDetailDisplay.d.ts +0 -0
  64. package/dist/esm/ContactDetailDisplay.js +17 -0
  65. package/dist/esm/ContactDetailDisplay.js.map +1 -0
  66. package/dist/{types → esm}/ContactDetailInput.d.ts +0 -0
  67. package/dist/esm/ContactDetailInput.js +37 -0
  68. package/dist/esm/ContactDetailInput.js.map +1 -0
  69. package/dist/{types → esm}/ContactPointDisplay.d.ts +0 -0
  70. package/dist/esm/ContactPointDisplay.js +29 -0
  71. package/dist/esm/ContactPointDisplay.js.map +1 -0
  72. package/dist/{types → esm}/ContactPointInput.d.ts +0 -0
  73. package/dist/esm/ContactPointInput.js +60 -0
  74. package/dist/esm/ContactPointInput.js.map +1 -0
  75. package/dist/{types → esm}/DateTimeDisplay.d.ts +0 -0
  76. package/dist/esm/DateTimeDisplay.js +11 -0
  77. package/dist/esm/DateTimeDisplay.js.map +1 -0
  78. package/dist/{types → esm}/DateTimeInput.d.ts +0 -0
  79. package/dist/esm/DateTimeInput.js +62 -0
  80. package/dist/esm/DateTimeInput.js.map +1 -0
  81. package/dist/{types → esm}/DefaultResourceTimeline.d.ts +0 -0
  82. package/dist/esm/DefaultResourceTimeline.js +27 -0
  83. package/dist/esm/DefaultResourceTimeline.js.map +1 -0
  84. package/dist/{types → esm}/DescriptionList.d.ts +0 -0
  85. package/dist/esm/DescriptionList.js +13 -0
  86. package/dist/esm/DescriptionList.js.map +1 -0
  87. package/dist/{types → esm}/DiagnosticReportDisplay.d.ts +0 -0
  88. package/dist/esm/DiagnosticReportDisplay.js +103 -0
  89. package/dist/esm/DiagnosticReportDisplay.js.map +1 -0
  90. package/dist/{types → esm}/Dialog.d.ts +0 -0
  91. package/dist/esm/Dialog.js +43 -0
  92. package/dist/esm/Dialog.js.map +1 -0
  93. package/dist/{types → esm}/Document.d.ts +0 -0
  94. package/dist/esm/Document.js +9 -0
  95. package/dist/esm/Document.js.map +1 -0
  96. package/dist/{types → esm}/EncounterTimeline.d.ts +0 -0
  97. package/dist/esm/EncounterTimeline.js +47 -0
  98. package/dist/esm/EncounterTimeline.js.map +1 -0
  99. package/dist/{types → esm}/ErrorBoundary.d.ts +0 -0
  100. package/dist/esm/ErrorBoundary.js +27 -0
  101. package/dist/esm/ErrorBoundary.js.map +1 -0
  102. package/dist/{types → esm}/ExtensionInput.d.ts +0 -0
  103. package/dist/esm/ExtensionInput.js +14 -0
  104. package/dist/esm/ExtensionInput.js.map +1 -0
  105. package/dist/{types → esm}/FhirPathDisplay.d.ts +0 -0
  106. package/dist/esm/FhirPathDisplay.js +23 -0
  107. package/dist/esm/FhirPathDisplay.js.map +1 -0
  108. package/dist/{types → esm}/FhirPathTable.d.ts +0 -0
  109. package/dist/esm/FhirPathTable.js +117 -0
  110. package/dist/esm/FhirPathTable.js.map +1 -0
  111. package/dist/{types → esm}/FooterLinks.d.ts +0 -0
  112. package/dist/esm/FooterLinks.js +8 -0
  113. package/dist/esm/FooterLinks.js.map +1 -0
  114. package/dist/{types → esm}/Form.d.ts +0 -0
  115. package/dist/esm/Form.js +15 -0
  116. package/dist/esm/Form.js.map +1 -0
  117. package/dist/{types → esm}/FormSection.d.ts +0 -0
  118. package/dist/esm/FormSection.js +18 -0
  119. package/dist/esm/FormSection.js.map +1 -0
  120. package/dist/{types → esm}/FormUtils.d.ts +0 -0
  121. package/dist/esm/FormUtils.js +49 -0
  122. package/dist/esm/FormUtils.js.map +1 -0
  123. package/dist/{types → esm}/GoogleButton.d.ts +0 -0
  124. package/dist/esm/GoogleButton.js +48 -0
  125. package/dist/esm/GoogleButton.js.map +1 -0
  126. package/dist/{types → esm}/Header.d.ts +0 -0
  127. package/dist/esm/Header.js +95 -0
  128. package/dist/esm/Header.js.map +1 -0
  129. package/dist/{types → esm}/HeaderSearchInput.d.ts +0 -0
  130. package/dist/esm/HeaderSearchInput.js +181 -0
  131. package/dist/esm/HeaderSearchInput.js.map +1 -0
  132. package/dist/{types → esm}/HumanNameDisplay.d.ts +0 -0
  133. package/dist/esm/HumanNameDisplay.js +13 -0
  134. package/dist/esm/HumanNameDisplay.js.map +1 -0
  135. package/dist/{types → esm}/HumanNameInput.d.ts +0 -0
  136. package/dist/esm/HumanNameInput.js +49 -0
  137. package/dist/esm/HumanNameInput.js.map +1 -0
  138. package/dist/{types → esm}/IdentifierDisplay.d.ts +0 -0
  139. package/dist/esm/IdentifierDisplay.js +12 -0
  140. package/dist/esm/IdentifierDisplay.js.map +1 -0
  141. package/dist/{types → esm}/IdentifierInput.d.ts +0 -0
  142. package/dist/esm/IdentifierInput.js +19 -0
  143. package/dist/esm/IdentifierInput.js.map +1 -0
  144. package/dist/{types → esm}/Input.d.ts +0 -0
  145. package/dist/esm/Input.js +26 -0
  146. package/dist/esm/Input.js.map +1 -0
  147. package/dist/{types → esm}/InputRow.d.ts +0 -0
  148. package/dist/esm/InputRow.js +8 -0
  149. package/dist/esm/InputRow.js.map +1 -0
  150. package/dist/{types → esm}/Loading.d.ts +0 -0
  151. package/dist/esm/Loading.js +11 -0
  152. package/dist/esm/Loading.js.map +1 -0
  153. package/dist/{types → esm}/Logo.d.ts +0 -0
  154. package/dist/esm/Logo.js +14 -0
  155. package/dist/esm/Logo.js.map +1 -0
  156. package/dist/{types → esm}/MedplumLink.d.ts +0 -0
  157. package/dist/esm/MedplumLink.js +34 -0
  158. package/dist/esm/MedplumLink.js.map +1 -0
  159. package/dist/{types → esm}/MedplumProvider.d.ts +0 -0
  160. package/dist/esm/MedplumProvider.js +50 -0
  161. package/dist/esm/MedplumProvider.js.map +1 -0
  162. package/dist/{types → esm}/MenuItem.d.ts +0 -0
  163. package/dist/esm/MenuItem.js +8 -0
  164. package/dist/esm/MenuItem.js.map +1 -0
  165. package/dist/{types → esm}/MenuSeparator.d.ts +0 -0
  166. package/dist/esm/MenuSeparator.js +8 -0
  167. package/dist/esm/MenuSeparator.js.map +1 -0
  168. package/dist/{types → esm}/PatientTimeline.d.ts +0 -0
  169. package/dist/esm/PatientTimeline.js +40 -0
  170. package/dist/esm/PatientTimeline.js.map +1 -0
  171. package/dist/{types → esm}/PeriodDisplay.d.ts +0 -0
  172. package/dist/esm/PeriodDisplay.js +16 -0
  173. package/dist/esm/PeriodDisplay.js.map +1 -0
  174. package/dist/{types → esm}/PeriodInput.d.ts +0 -0
  175. package/dist/esm/PeriodInput.js +19 -0
  176. package/dist/esm/PeriodInput.js.map +1 -0
  177. package/dist/{types → esm}/PlanDefinitionBuilder.d.ts +0 -0
  178. package/dist/esm/PlanDefinitionBuilder.js +155 -0
  179. package/dist/esm/PlanDefinitionBuilder.js.map +1 -0
  180. package/dist/{types → esm}/Popup.d.ts +0 -0
  181. package/dist/esm/Popup.js +64 -0
  182. package/dist/esm/Popup.js.map +1 -0
  183. package/dist/{types → esm}/QuantityDisplay.d.ts +0 -0
  184. package/dist/esm/QuantityDisplay.js +28 -0
  185. package/dist/esm/QuantityDisplay.js.map +1 -0
  186. package/dist/{types → esm}/QuantityInput.d.ts +0 -0
  187. package/dist/esm/QuantityInput.js +33 -0
  188. package/dist/esm/QuantityInput.js.map +1 -0
  189. package/dist/{types → esm}/QuestionnaireBuilder.d.ts +0 -0
  190. package/dist/esm/QuestionnaireBuilder.js +217 -0
  191. package/dist/esm/QuestionnaireBuilder.js.map +1 -0
  192. package/dist/{types → esm}/QuestionnaireForm.d.ts +0 -0
  193. package/dist/esm/QuestionnaireForm.js +215 -0
  194. package/dist/esm/QuestionnaireForm.js.map +1 -0
  195. package/dist/{types → esm}/QuestionnaireUtils.d.ts +0 -0
  196. package/dist/esm/QuestionnaireUtils.js +103 -0
  197. package/dist/esm/QuestionnaireUtils.js.map +1 -0
  198. package/dist/{types → esm}/RangeDisplay.d.ts +0 -0
  199. package/dist/esm/RangeDisplay.js +21 -0
  200. package/dist/esm/RangeDisplay.js.map +1 -0
  201. package/dist/{types → esm}/RangeInput.d.ts +0 -0
  202. package/dist/esm/RangeInput.js +25 -0
  203. package/dist/esm/RangeInput.js.map +1 -0
  204. package/dist/{types → esm}/RatioDisplay.d.ts +0 -0
  205. package/dist/esm/RatioDisplay.js +16 -0
  206. package/dist/esm/RatioDisplay.js.map +1 -0
  207. package/dist/{types → esm}/RatioInput.d.ts +0 -0
  208. package/dist/esm/RatioInput.js +25 -0
  209. package/dist/esm/RatioInput.js.map +1 -0
  210. package/dist/{types → esm}/ReferenceDisplay.d.ts +0 -0
  211. package/dist/esm/ReferenceDisplay.js +21 -0
  212. package/dist/esm/ReferenceDisplay.js.map +1 -0
  213. package/dist/{types → esm}/ReferenceInput.d.ts +0 -0
  214. package/dist/esm/ReferenceInput.js +42 -0
  215. package/dist/esm/ReferenceInput.js.map +1 -0
  216. package/dist/{types → esm}/RegisterForm.d.ts +0 -0
  217. package/dist/esm/RegisterForm.js +110 -0
  218. package/dist/esm/RegisterForm.js.map +1 -0
  219. package/dist/{types → esm}/RequestGroupDisplay.d.ts +0 -0
  220. package/dist/esm/RequestGroupDisplay.js +73 -0
  221. package/dist/esm/RequestGroupDisplay.js.map +1 -0
  222. package/dist/{types → esm}/ResourceArrayDisplay.d.ts +0 -0
  223. package/dist/esm/ResourceArrayDisplay.js +14 -0
  224. package/dist/esm/ResourceArrayDisplay.js.map +1 -0
  225. package/dist/{types → esm}/ResourceArrayInput.d.ts +0 -0
  226. package/dist/esm/ResourceArrayInput.js +48 -0
  227. package/dist/esm/ResourceArrayInput.js.map +1 -0
  228. package/dist/{types → esm}/ResourceBadge.d.ts +0 -0
  229. package/dist/esm/ResourceBadge.js +13 -0
  230. package/dist/esm/ResourceBadge.js.map +1 -0
  231. package/dist/{types → esm}/ResourceBlame.d.ts +0 -0
  232. package/dist/esm/ResourceBlame.js +65 -0
  233. package/dist/esm/ResourceBlame.js.map +1 -0
  234. package/dist/{types → esm}/ResourceDiff.d.ts +0 -0
  235. package/dist/esm/ResourceDiff.js +28 -0
  236. package/dist/esm/ResourceDiff.js.map +1 -0
  237. package/dist/{types → esm}/ResourceDiffTable.d.ts +0 -0
  238. package/dist/esm/ResourceDiffTable.js +58 -0
  239. package/dist/esm/ResourceDiffTable.js.map +1 -0
  240. package/dist/{types → esm}/ResourceForm.d.ts +0 -0
  241. package/dist/esm/ResourceForm.js +55 -0
  242. package/dist/esm/ResourceForm.js.map +1 -0
  243. package/dist/{types → esm}/ResourceHistoryTable.d.ts +0 -0
  244. package/dist/esm/ResourceHistoryTable.js +46 -0
  245. package/dist/esm/ResourceHistoryTable.js.map +1 -0
  246. package/dist/{types → esm}/ResourceInput.d.ts +0 -0
  247. package/dist/esm/ResourceInput.js +40 -0
  248. package/dist/esm/ResourceInput.js.map +1 -0
  249. package/dist/{types → esm}/ResourceName.d.ts +0 -0
  250. package/dist/esm/ResourceName.js +16 -0
  251. package/dist/esm/ResourceName.js.map +1 -0
  252. package/dist/{types → esm}/ResourcePropertyDisplay.d.ts +0 -0
  253. package/dist/esm/ResourcePropertyDisplay.js +107 -0
  254. package/dist/esm/ResourcePropertyDisplay.js.map +1 -0
  255. package/dist/{types → esm}/ResourcePropertyInput.d.ts +0 -0
  256. package/dist/esm/ResourcePropertyInput.js +151 -0
  257. package/dist/esm/ResourcePropertyInput.js.map +1 -0
  258. package/dist/{types → esm}/ResourceTable.d.ts +0 -0
  259. package/dist/esm/ResourceTable.js +22 -0
  260. package/dist/esm/ResourceTable.js.map +1 -0
  261. package/dist/{types → esm}/ResourceTimeline.d.ts +0 -0
  262. package/dist/esm/ResourceTimeline.js +221 -0
  263. package/dist/esm/ResourceTimeline.js.map +1 -0
  264. package/dist/{types → esm}/Scheduler.d.ts +0 -0
  265. package/dist/esm/Scheduler.js +82 -0
  266. package/dist/esm/Scheduler.js.map +1 -0
  267. package/dist/{types → esm}/Scrollable.d.ts +0 -0
  268. package/dist/esm/Scrollable.js +12 -0
  269. package/dist/esm/Scrollable.js.map +1 -0
  270. package/dist/{types → esm}/SearchControl.d.ts +0 -0
  271. package/dist/esm/SearchControl.js +268 -0
  272. package/dist/esm/SearchControl.js.map +1 -0
  273. package/dist/{types → esm}/SearchControlField.d.ts +0 -0
  274. package/dist/esm/SearchControlField.js +98 -0
  275. package/dist/esm/SearchControlField.js.map +1 -0
  276. package/dist/{types → esm}/SearchFieldEditor.d.ts +0 -0
  277. package/dist/esm/SearchFieldEditor.js +192 -0
  278. package/dist/esm/SearchFieldEditor.js.map +1 -0
  279. package/dist/{types → esm}/SearchFilterEditor.d.ts +0 -0
  280. package/dist/esm/SearchFilterEditor.js +103 -0
  281. package/dist/esm/SearchFilterEditor.js.map +1 -0
  282. package/dist/{types → esm}/SearchFilterValueDialog.d.ts +0 -0
  283. package/dist/esm/SearchFilterValueDialog.js +22 -0
  284. package/dist/esm/SearchFilterValueDialog.js.map +1 -0
  285. package/dist/{types → esm}/SearchFilterValueDisplay.d.ts +0 -0
  286. package/dist/esm/SearchFilterValueDisplay.js +22 -0
  287. package/dist/esm/SearchFilterValueDisplay.js.map +1 -0
  288. package/dist/{types → esm}/SearchFilterValueInput.d.ts +0 -0
  289. package/dist/esm/SearchFilterValueInput.js +59 -0
  290. package/dist/esm/SearchFilterValueInput.js.map +1 -0
  291. package/dist/{types → esm}/SearchPopupMenu.d.ts +0 -0
  292. package/dist/esm/SearchPopupMenu.js +135 -0
  293. package/dist/esm/SearchPopupMenu.js.map +1 -0
  294. package/dist/{types → esm}/SearchUtils.d.ts +0 -0
  295. package/dist/esm/SearchUtils.js +488 -0
  296. package/dist/esm/SearchUtils.js.map +1 -0
  297. package/dist/{types → esm}/Select.d.ts +0 -0
  298. package/dist/esm/Select.js +16 -0
  299. package/dist/esm/Select.js.map +1 -0
  300. package/dist/{types → esm}/ServiceRequestTimeline.d.ts +0 -0
  301. package/dist/esm/ServiceRequestTimeline.js +53 -0
  302. package/dist/esm/ServiceRequestTimeline.js.map +1 -0
  303. package/dist/{types → esm}/SignInForm.d.ts +0 -0
  304. package/dist/esm/SignInForm.js +130 -0
  305. package/dist/esm/SignInForm.js.map +1 -0
  306. package/dist/{types → esm}/StatusBadge.d.ts +0 -0
  307. package/dist/esm/StatusBadge.js +8 -0
  308. package/dist/esm/StatusBadge.js.map +1 -0
  309. package/dist/{types → esm}/SubMenu.d.ts +0 -0
  310. package/dist/esm/SubMenu.js +38 -0
  311. package/dist/esm/SubMenu.js.map +1 -0
  312. package/dist/{types → esm}/Tab.d.ts +0 -0
  313. package/dist/esm/Tab.js +19 -0
  314. package/dist/esm/Tab.js.map +1 -0
  315. package/dist/{types → esm}/TabList.d.ts +0 -0
  316. package/dist/esm/TabList.js +23 -0
  317. package/dist/esm/TabList.js.map +1 -0
  318. package/dist/{types → esm}/TabPanel.d.ts +0 -0
  319. package/dist/esm/TabPanel.js +8 -0
  320. package/dist/esm/TabPanel.js.map +1 -0
  321. package/dist/{types → esm}/TabSwitch.d.ts +0 -0
  322. package/dist/esm/TabSwitch.js +16 -0
  323. package/dist/esm/TabSwitch.js.map +1 -0
  324. package/dist/{types → esm}/TextArea.d.ts +0 -0
  325. package/dist/esm/TextArea.js +16 -0
  326. package/dist/esm/TextArea.js.map +1 -0
  327. package/dist/{types → esm}/Timeline.d.ts +0 -0
  328. package/dist/esm/Timeline.js +50 -0
  329. package/dist/esm/Timeline.js.map +1 -0
  330. package/dist/{types → esm}/TitleBar.d.ts +0 -0
  331. package/dist/esm/TitleBar.js +8 -0
  332. package/dist/esm/TitleBar.js.map +1 -0
  333. package/dist/{types → esm}/UploadButton.d.ts +0 -0
  334. package/dist/esm/UploadButton.js +55 -0
  335. package/dist/esm/UploadButton.js.map +1 -0
  336. package/dist/{types → esm}/constants.d.ts +0 -0
  337. package/dist/esm/constants.js +12 -0
  338. package/dist/esm/constants.js.map +1 -0
  339. package/dist/{types → esm}/index.d.ts +0 -0
  340. package/dist/esm/index.js +87 -5814
  341. package/dist/esm/index.js.map +1 -1
  342. package/dist/esm/index.min.js.map +1 -1
  343. package/dist/esm/node_modules/tslib/tslib.es6.js +27 -0
  344. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
  345. package/dist/{types → esm}/stories/AddressInput.stories.d.ts +0 -0
  346. package/dist/{types → esm}/stories/AttachmentArrayInput.stories.d.ts +0 -0
  347. package/dist/{types → esm}/stories/AttachmentInput.stories.d.ts +0 -0
  348. package/dist/{types → esm}/stories/Autocomplete.stories.d.ts +0 -0
  349. package/dist/{types → esm}/stories/Avatar.stories.d.ts +0 -0
  350. package/dist/{types → esm}/stories/Button.stories.d.ts +0 -0
  351. package/dist/{types → esm}/stories/DiagnosticReportDisplay.stories.d.ts +0 -0
  352. package/dist/{types → esm}/stories/Dialog.stories.d.ts +0 -0
  353. package/dist/{types → esm}/stories/EncounterTimeline.stories.d.ts +0 -0
  354. package/dist/{types → esm}/stories/FhirPathDisplay.stories.d.ts +0 -0
  355. package/dist/{types → esm}/stories/FormSection.stories.d.ts +0 -0
  356. package/dist/{types → esm}/stories/Header.stories.d.ts +0 -0
  357. package/dist/{types → esm}/stories/Input.stories.d.ts +0 -0
  358. package/dist/{types → esm}/stories/Loading.stories.d.ts +0 -0
  359. package/dist/{types → esm}/stories/Logo.stories.d.ts +0 -0
  360. package/dist/{types → esm}/stories/PatientTimeline.stories.d.ts +0 -0
  361. package/dist/{types → esm}/stories/PlanDefinitionBuilder.stories.d.ts +0 -0
  362. package/dist/{types → esm}/stories/QuestionnaireBuilder.stories.d.ts +0 -0
  363. package/dist/{types → esm}/stories/QuestionnaireForm.stories.d.ts +0 -0
  364. package/dist/{types → esm}/stories/ReferenceInput.stories.d.ts +0 -0
  365. package/dist/{types → esm}/stories/RegisterForm.stories.d.ts +0 -0
  366. package/dist/{types → esm}/stories/RequestGroupDisplay.stories.d.ts +0 -0
  367. package/dist/{types → esm}/stories/ResourceBlame.stories.d.ts +0 -0
  368. package/dist/{types → esm}/stories/ResourceForm.stories.d.ts +0 -0
  369. package/dist/{types → esm}/stories/ResourceHistoryTable.stories.d.ts +0 -0
  370. package/dist/{types → esm}/stories/ResourceTable.stories.d.ts +0 -0
  371. package/dist/{types → esm}/stories/Scheduler.stories.d.ts +0 -0
  372. package/dist/{types → esm}/stories/SearchControl.stories.d.ts +0 -0
  373. package/dist/{types → esm}/stories/Select.stories.d.ts +0 -0
  374. package/dist/{types → esm}/stories/SignInForm.stories.d.ts +0 -0
  375. package/dist/{types → esm}/stories/StatusBadge.stories.d.ts +0 -0
  376. package/dist/{types → esm}/stories/Tabs.stories.d.ts +0 -0
  377. package/dist/{types → esm}/stories/Timeline.stories.d.ts +0 -0
  378. package/dist/{types → esm}/stories/UploadButton.stories.d.ts +0 -0
  379. package/dist/{types → esm}/test.setup.d.ts +0 -0
  380. package/dist/{types → esm}/useResource.d.ts +0 -0
  381. package/dist/esm/useResource.js +65 -0
  382. package/dist/esm/useResource.js.map +1 -0
  383. package/dist/{types → esm}/utils/blame.d.ts +0 -0
  384. package/dist/esm/utils/blame.js +74 -0
  385. package/dist/esm/utils/blame.js.map +1 -0
  386. package/dist/{types → esm}/utils/date.d.ts +0 -0
  387. package/dist/esm/utils/date.js +48 -0
  388. package/dist/esm/utils/date.js.map +1 -0
  389. package/dist/{types → esm}/utils/diff.d.ts +0 -0
  390. package/dist/esm/utils/diff.js +118 -0
  391. package/dist/esm/utils/diff.js.map +1 -0
  392. package/dist/{types → esm}/utils/dom.d.ts +0 -0
  393. package/dist/esm/utils/dom.js +34 -0
  394. package/dist/esm/utils/dom.js.map +1 -0
  395. package/dist/{types → esm}/utils/outcomes.d.ts +0 -0
  396. package/dist/esm/utils/outcomes.js +7 -0
  397. package/dist/esm/utils/outcomes.js.map +1 -0
  398. package/dist/{types → esm}/utils/recaptcha.d.ts +0 -0
  399. package/dist/esm/utils/recaptcha.js +27 -0
  400. package/dist/esm/utils/recaptcha.js.map +1 -0
  401. package/dist/{types → esm}/utils.d.ts +0 -0
  402. package/dist/esm/utils.js +15 -0
  403. package/dist/esm/utils.js.map +1 -0
  404. package/package.json +7 -7
  405. package/stats.html +4034 -0
  406. package/tsconfig.cjs.json +7 -0
  407. package/tsconfig.esm.json +7 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourcePropertyDisplay.js","sources":["../../src/ResourcePropertyDisplay.tsx"],"sourcesContent":["import { buildTypeName, getTypedPropertyValue, PropertyType, TypedValue } from '@medplum/core';\nimport { ElementDefinition } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { AddressDisplay } from './AddressDisplay';\nimport { AttachmentArrayDisplay } from './AttachmentArrayDisplay';\nimport { AttachmentDisplay } from './AttachmentDisplay';\nimport { BackboneElementDisplay } from './BackboneElementDisplay';\nimport { CodeableConceptDisplay } from './CodeableConceptDisplay';\nimport { CodingDisplay } from './CodingDisplay';\nimport { ContactDetailDisplay } from './ContactDetailDisplay';\nimport { ContactPointDisplay } from './ContactPointDisplay';\nimport { DateTimeDisplay } from './DateTimeDisplay';\nimport { HumanNameDisplay } from './HumanNameDisplay';\nimport { IdentifierDisplay } from './IdentifierDisplay';\nimport { PeriodDisplay } from './PeriodDisplay';\nimport { QuantityDisplay } from './QuantityDisplay';\nimport { RangeDisplay } from './RangeDisplay';\nimport { RatioDisplay } from './RatioDisplay';\nimport { ReferenceDisplay } from './ReferenceDisplay';\nimport { ResourceArrayDisplay } from './ResourceArrayDisplay';\n\nexport interface ResourcePropertyDisplayProps {\n property?: ElementDefinition;\n propertyType: PropertyType;\n value: any;\n arrayElement?: boolean;\n maxWidth?: number;\n ignoreMissingValues?: boolean;\n link?: boolean;\n}\n\nexport function ResourcePropertyDisplay(props: ResourcePropertyDisplayProps): JSX.Element {\n const { property, propertyType, value } = props;\n\n if (property?.max === '*' && !props.arrayElement) {\n if (propertyType === 'Attachment') {\n return <AttachmentArrayDisplay values={value} maxWidth={props.maxWidth} />;\n }\n return (\n <ResourceArrayDisplay\n property={property}\n values={value}\n ignoreMissingValues={props.ignoreMissingValues}\n link={props.link}\n />\n );\n }\n\n switch (propertyType) {\n case PropertyType.boolean:\n return <div>{value === undefined ? '' : Boolean(value).toString()}</div>;\n case PropertyType.SystemString:\n case PropertyType.code:\n case PropertyType.date:\n case PropertyType.integer:\n case PropertyType.positiveInt:\n case PropertyType.string:\n case PropertyType.unsignedInt:\n case PropertyType.uri:\n case PropertyType.url:\n return <div>{value}</div>;\n case PropertyType.canonical:\n return <ReferenceDisplay value={{ reference: value }} link={props.link} />;\n case PropertyType.dateTime:\n case PropertyType.instant:\n return <DateTimeDisplay value={value} />;\n case PropertyType.markdown:\n return <pre>{value}</pre>;\n case PropertyType.Address:\n return <AddressDisplay value={value} />;\n case PropertyType.Annotation:\n return <div>{value?.text}</div>;\n case PropertyType.Attachment:\n return <AttachmentDisplay value={value} maxWidth={props.maxWidth} />;\n case PropertyType.CodeableConcept:\n return <CodeableConceptDisplay value={value} />;\n case PropertyType.Coding:\n return <CodingDisplay value={value} />;\n case PropertyType.ContactDetail:\n return <ContactDetailDisplay value={value} />;\n case PropertyType.ContactPoint:\n return <ContactPointDisplay value={value} />;\n case PropertyType.HumanName:\n return <HumanNameDisplay value={value} />;\n case PropertyType.Identifier:\n return <IdentifierDisplay value={value} />;\n case PropertyType.Period:\n return <PeriodDisplay value={value} />;\n case PropertyType.Quantity:\n return <QuantityDisplay value={value} />;\n case PropertyType.Range:\n return <RangeDisplay value={value} />;\n case PropertyType.Ratio:\n return <RatioDisplay value={value} />;\n case PropertyType.Reference:\n return <ReferenceDisplay value={value} link={props.link} />;\n default:\n if (!property?.path) {\n throw Error(`Displaying property of type ${props.propertyType} requires element definition path`);\n }\n return (\n <BackboneElementDisplay\n value={{ type: buildTypeName(property?.path?.split('.') as string[]), value }}\n compact={true}\n ignoreMissingValues={props.ignoreMissingValues}\n />\n );\n }\n}\n\n/**\n * Returns the value of the property and the property type.\n * Some property definitions support multiple types.\n * For example, \"Observation.value[x]\" can be \"valueString\", \"valueInteger\", \"valueQuantity\", etc.\n * According to the spec, there can only be one property for a given element definition.\n * This function returns the value and the type.\n * @param context The base context (usually a FHIR resource).\n * @param property The property definition.\n * @returns The value of the property and the property type.\n */\nexport function getValueAndType(context: TypedValue, path: string): [any, PropertyType] {\n const typedResult = getTypedPropertyValue(context, path);\n if (!typedResult) {\n return [undefined, 'undefined' as PropertyType];\n }\n\n if (Array.isArray(typedResult)) {\n return [typedResult.map((e) => e.value), typedResult[0].type as PropertyType];\n }\n\n return [typedResult.value, typedResult.type as PropertyType];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BM,SAAU,uBAAuB,CAAC,KAAmC,EAAA;;IACz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EAAA,CAAE,KAAK,CAAC,GAAG,CAAa,CAAC,EAAE,KAAK,EAAE,EAC7E,OAAO,EAAE,IAAI,EACb,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAAA,CAC9C,EACF;AACL,KAAA;AACH,CAAC;AAED;;;;;;;;;AASG;AACa,SAAA,eAAe,CAAC,OAAmB,EAAE,IAAY,EAAA;IAC/D,MAAM,WAAW,GAAG,qBAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,WAAW,EAAE;AAChB,QAAA,OAAO,CAAC,SAAS,EAAE,WAA2B,CAAC,CAAC;AACjD,KAAA;AAED,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QAC9B,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAoB,CAAC,CAAC;AAC/E,KAAA;IAED,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,IAAoB,CAAC,CAAC;AAC/D;;;;"}
File without changes
@@ -0,0 +1,151 @@
1
+ import { capitalize, buildTypeName, PropertyType } from '@medplum/core';
2
+ import React, { useState } from 'react';
3
+ import { AddressInput } from './AddressInput.js';
4
+ import { AnnotationInput } from './AnnotationInput.js';
5
+ import { AttachmentArrayInput } from './AttachmentArrayInput.js';
6
+ import { AttachmentInput } from './AttachmentInput.js';
7
+ import { BackboneElementInput } from './BackboneElementInput.js';
8
+ import { Checkbox } from './Checkbox.js';
9
+ import { CodeableConceptInput } from './CodeableConceptInput.js';
10
+ import { CodeInput } from './CodeInput.js';
11
+ import { CodingInput } from './CodingInput.js';
12
+ import { ContactDetailInput } from './ContactDetailInput.js';
13
+ import { ContactPointInput } from './ContactPointInput.js';
14
+ import { DateTimeInput } from './DateTimeInput.js';
15
+ import { ExtensionInput } from './ExtensionInput.js';
16
+ import { HumanNameInput } from './HumanNameInput.js';
17
+ import { IdentifierInput } from './IdentifierInput.js';
18
+ import { Input } from './Input.js';
19
+ import { InputRow } from './InputRow.js';
20
+ import { PeriodInput } from './PeriodInput.js';
21
+ import { QuantityInput } from './QuantityInput.js';
22
+ import { RangeInput } from './RangeInput.js';
23
+ import { RatioInput } from './RatioInput.js';
24
+ import { ReferenceInput } from './ReferenceInput.js';
25
+ import { ResourceArrayInput } from './ResourceArrayInput.js';
26
+ import { Select } from './Select.js';
27
+ import { TextArea } from './TextArea.js';
28
+
29
+ function ResourcePropertyInput(props) {
30
+ var _a, _b, _c;
31
+ const property = props.property;
32
+ const propertyType = (_a = props.defaultPropertyType) !== null && _a !== void 0 ? _a : (_c = (_b = property.type) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code;
33
+ const name = props.name;
34
+ const value = props.defaultValue;
35
+ if (property.max === '*' && !props.arrayElement) {
36
+ if (propertyType === 'Attachment') {
37
+ return React.createElement(AttachmentArrayInput, { name: name, defaultValue: value, onChange: props.onChange });
38
+ }
39
+ return React.createElement(ResourceArrayInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
40
+ }
41
+ const propertyTypes = property.type;
42
+ if (propertyTypes.length > 1) {
43
+ return React.createElement(ElementDefinitionInputSelector, Object.assign({ elementDefinitionTypes: propertyTypes }, props));
44
+ }
45
+ else {
46
+ return React.createElement(ElementDefinitionTypeInput, Object.assign({ elementDefinitionType: propertyTypes[0] }, props));
47
+ }
48
+ }
49
+ function ElementDefinitionInputSelector(props) {
50
+ const propertyTypes = props.elementDefinitionTypes;
51
+ let initialPropertyType = undefined;
52
+ if (props.defaultPropertyType) {
53
+ initialPropertyType = propertyTypes.find((t) => t.code === props.defaultPropertyType);
54
+ }
55
+ if (!initialPropertyType) {
56
+ initialPropertyType = propertyTypes[0];
57
+ }
58
+ const [selectedType, setSelectedType] = useState(initialPropertyType);
59
+ return (React.createElement(InputRow, null,
60
+ React.createElement(Select, { style: { width: '200px' }, defaultValue: selectedType === null || selectedType === void 0 ? void 0 : selectedType.code, onChange: (newValue) => {
61
+ setSelectedType(propertyTypes.find((type) => type.code === newValue));
62
+ } }, propertyTypes.map((type) => (React.createElement("option", { key: type.code, value: type.code }, type.code)))),
63
+ React.createElement(ElementDefinitionTypeInput, Object.assign({}, props, { elementDefinitionType: selectedType, onChange: (newValue) => {
64
+ if (props.onChange) {
65
+ props.onChange(newValue, props.name.replace('[x]', capitalize(selectedType.code)));
66
+ }
67
+ } }))));
68
+ }
69
+ function ElementDefinitionTypeInput(props) {
70
+ var _a;
71
+ const property = props.property;
72
+ const propertyType = props.elementDefinitionType.code;
73
+ const name = props.name;
74
+ const value = props.defaultValue;
75
+ switch (propertyType) {
76
+ // 2.24.0.1 Primitive Types
77
+ // https://www.hl7.org/fhir/datatypes.html#primitive
78
+ case PropertyType.SystemString:
79
+ case PropertyType.canonical:
80
+ case PropertyType.string:
81
+ case PropertyType.time:
82
+ case PropertyType.uri:
83
+ case PropertyType.url:
84
+ return (React.createElement(Input, { type: "text", name: name, testid: name, defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
85
+ case PropertyType.date:
86
+ return (React.createElement(Input, { type: "date", name: name, testid: name, defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
87
+ case PropertyType.dateTime:
88
+ case PropertyType.instant:
89
+ return (React.createElement(DateTimeInput, { type: "datetime-local", name: name, testid: name, defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
90
+ case PropertyType.decimal:
91
+ case PropertyType.integer:
92
+ case PropertyType.positiveInt:
93
+ case PropertyType.unsignedInt:
94
+ return (React.createElement(Input, { type: "number", step: propertyType === PropertyType.decimal ? 'any' : 1, name: name, testid: name, defaultValue: value, onChange: (newValue) => {
95
+ if (props.onChange) {
96
+ props.onChange(parseFloat(newValue));
97
+ }
98
+ }, outcome: props.outcome }));
99
+ case PropertyType.code:
100
+ return React.createElement(CodeInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
101
+ case PropertyType.boolean:
102
+ return (React.createElement(Checkbox, { name: name, testid: name, defaultValue: !!value, onChange: (newValue) => {
103
+ if (props.onChange) {
104
+ props.onChange(newValue);
105
+ }
106
+ } }));
107
+ case PropertyType.markdown:
108
+ return React.createElement(TextArea, { name: name, testid: name, defaultValue: value, onChange: props.onChange });
109
+ // 2.24.0.2 Complex Types
110
+ // https://www.hl7.org/fhir/datatypes.html#complex
111
+ case PropertyType.Address:
112
+ return React.createElement(AddressInput, { name: name, defaultValue: value, onChange: props.onChange });
113
+ case PropertyType.Annotation:
114
+ return React.createElement(AnnotationInput, { name: name, defaultValue: value, onChange: props.onChange });
115
+ case PropertyType.Attachment:
116
+ return React.createElement(AttachmentInput, { name: name, defaultValue: value, onChange: props.onChange });
117
+ case PropertyType.CodeableConcept:
118
+ return React.createElement(CodeableConceptInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
119
+ case PropertyType.Coding:
120
+ return React.createElement(CodingInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
121
+ case PropertyType.ContactDetail:
122
+ return React.createElement(ContactDetailInput, { name: name, defaultValue: value, onChange: props.onChange });
123
+ case PropertyType.ContactPoint:
124
+ return React.createElement(ContactPointInput, { name: name, defaultValue: value, onChange: props.onChange });
125
+ case PropertyType.Extension:
126
+ return React.createElement(ExtensionInput, { name: name, defaultValue: value, onChange: props.onChange });
127
+ case PropertyType.HumanName:
128
+ return React.createElement(HumanNameInput, { name: name, defaultValue: value, onChange: props.onChange });
129
+ case PropertyType.Identifier:
130
+ return React.createElement(IdentifierInput, { name: name, defaultValue: value, onChange: props.onChange });
131
+ case PropertyType.Period:
132
+ return React.createElement(PeriodInput, { name: name, defaultValue: value, onChange: props.onChange });
133
+ case PropertyType.Quantity:
134
+ return React.createElement(QuantityInput, { name: name, defaultValue: value, onChange: props.onChange });
135
+ case PropertyType.Range:
136
+ return React.createElement(RangeInput, { name: name, defaultValue: value, onChange: props.onChange });
137
+ case PropertyType.Ratio:
138
+ return React.createElement(RatioInput, { name: name, defaultValue: value, onChange: props.onChange });
139
+ case PropertyType.Reference:
140
+ return (React.createElement(ReferenceInput, { name: name, defaultValue: value, targetTypes: getTargetTypes(property), onChange: props.onChange }));
141
+ default:
142
+ return (React.createElement(BackboneElementInput, { typeName: buildTypeName((_a = property.path) === null || _a === void 0 ? void 0 : _a.split('.')), defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
143
+ }
144
+ }
145
+ function getTargetTypes(property) {
146
+ var _a, _b, _c;
147
+ return (_c = (_b = (_a = property === null || property === void 0 ? void 0 : property.type) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.targetProfile) === null || _c === void 0 ? void 0 : _c.map((p) => p.split('/').pop());
148
+ }
149
+
150
+ export { ElementDefinitionInputSelector, ElementDefinitionTypeInput, ResourcePropertyInput };
151
+ //# sourceMappingURL=ResourcePropertyInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourcePropertyInput.js","sources":["../../src/ResourcePropertyInput.tsx"],"sourcesContent":["import { buildTypeName, capitalize, PropertyType } from '@medplum/core';\nimport { ElementDefinition, ElementDefinitionType, OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { AddressInput } from './AddressInput';\nimport { AnnotationInput } from './AnnotationInput';\nimport { AttachmentArrayInput } from './AttachmentArrayInput';\nimport { AttachmentInput } from './AttachmentInput';\nimport { BackboneElementInput } from './BackboneElementInput';\nimport { Checkbox } from './Checkbox';\nimport { CodeableConceptInput } from './CodeableConceptInput';\nimport { CodeInput } from './CodeInput';\nimport { CodingInput } from './CodingInput';\nimport { ContactDetailInput } from './ContactDetailInput';\nimport { ContactPointInput } from './ContactPointInput';\nimport { DateTimeInput } from './DateTimeInput';\nimport { ExtensionInput } from './ExtensionInput';\nimport { HumanNameInput } from './HumanNameInput';\nimport { IdentifierInput } from './IdentifierInput';\nimport { Input } from './Input';\nimport { InputRow } from './InputRow';\nimport { PeriodInput } from './PeriodInput';\nimport { QuantityInput } from './QuantityInput';\nimport { RangeInput } from './RangeInput';\nimport { RatioInput } from './RatioInput';\nimport { ReferenceInput } from './ReferenceInput';\nimport { ResourceArrayInput } from './ResourceArrayInput';\nimport { Select } from './Select';\nimport { TextArea } from './TextArea';\n\nexport interface ResourcePropertyInputProps {\n property: ElementDefinition;\n name: string;\n defaultPropertyType?: PropertyType;\n defaultValue?: any;\n arrayElement?: boolean;\n onChange?: (value: any, propName?: string) => void;\n outcome?: OperationOutcome;\n}\n\nexport function ResourcePropertyInput(props: ResourcePropertyInputProps): JSX.Element {\n const property = props.property;\n const propertyType = props.defaultPropertyType ?? (property.type?.[0]?.code as PropertyType);\n const name = props.name;\n const value = props.defaultValue;\n\n if (property.max === '*' && !props.arrayElement) {\n if (propertyType === 'Attachment') {\n return <AttachmentArrayInput name={name} defaultValue={value} onChange={props.onChange} />;\n }\n return <ResourceArrayInput property={property} name={name} defaultValue={value} onChange={props.onChange} />;\n }\n\n const propertyTypes = property.type as ElementDefinitionType[];\n if (propertyTypes.length > 1) {\n return <ElementDefinitionInputSelector elementDefinitionTypes={propertyTypes} {...props} />;\n } else {\n return <ElementDefinitionTypeInput elementDefinitionType={propertyTypes[0]} {...props} />;\n }\n}\n\nexport interface ElementDefinitionSelectorProps extends ResourcePropertyInputProps {\n elementDefinitionTypes: ElementDefinitionType[];\n}\n\nexport function ElementDefinitionInputSelector(props: ElementDefinitionSelectorProps): JSX.Element {\n const propertyTypes = props.elementDefinitionTypes;\n let initialPropertyType: ElementDefinitionType | undefined = undefined;\n if (props.defaultPropertyType) {\n initialPropertyType = propertyTypes.find((t) => t.code === props.defaultPropertyType) as ElementDefinitionType;\n }\n if (!initialPropertyType) {\n initialPropertyType = propertyTypes[0];\n }\n const [selectedType, setSelectedType] = useState(initialPropertyType);\n return (\n <InputRow>\n <Select\n style={{ width: '200px' }}\n defaultValue={selectedType?.code}\n onChange={(newValue) => {\n setSelectedType(\n propertyTypes.find((type: ElementDefinitionType) => type.code === newValue) as ElementDefinitionType\n );\n }}\n >\n {propertyTypes.map((type: ElementDefinitionType) => (\n <option key={type.code} value={type.code}>\n {type.code}\n </option>\n ))}\n </Select>\n <ElementDefinitionTypeInput\n {...props}\n elementDefinitionType={selectedType}\n onChange={(newValue: any) => {\n if (props.onChange) {\n props.onChange(newValue, props.name.replace('[x]', capitalize(selectedType.code as string)));\n }\n }}\n />\n </InputRow>\n );\n}\n\nexport interface ElementDefinitionTypeInputProps extends ResourcePropertyInputProps {\n elementDefinitionType: ElementDefinitionType;\n}\n\nexport function ElementDefinitionTypeInput(props: ElementDefinitionTypeInputProps): JSX.Element {\n const property = props.property;\n const propertyType = props.elementDefinitionType.code as PropertyType;\n const name = props.name;\n const value = props.defaultValue;\n\n switch (propertyType) {\n // 2.24.0.1 Primitive Types\n // https://www.hl7.org/fhir/datatypes.html#primitive\n\n case PropertyType.SystemString:\n case PropertyType.canonical:\n case PropertyType.string:\n case PropertyType.time:\n case PropertyType.uri:\n case PropertyType.url:\n return (\n <Input\n type=\"text\"\n name={name}\n testid={name}\n defaultValue={value}\n onChange={props.onChange}\n outcome={props.outcome}\n />\n );\n case PropertyType.date:\n return (\n <Input\n type=\"date\"\n name={name}\n testid={name}\n defaultValue={value}\n onChange={props.onChange}\n outcome={props.outcome}\n />\n );\n case PropertyType.dateTime:\n case PropertyType.instant:\n return (\n <DateTimeInput\n type=\"datetime-local\"\n name={name}\n testid={name}\n defaultValue={value}\n onChange={props.onChange}\n outcome={props.outcome}\n />\n );\n case PropertyType.decimal:\n case PropertyType.integer:\n case PropertyType.positiveInt:\n case PropertyType.unsignedInt:\n return (\n <Input\n type=\"number\"\n step={propertyType === PropertyType.decimal ? 'any' : 1}\n name={name}\n testid={name}\n defaultValue={value}\n onChange={(newValue) => {\n if (props.onChange) {\n props.onChange(parseFloat(newValue));\n }\n }}\n outcome={props.outcome}\n />\n );\n case PropertyType.code:\n return <CodeInput property={property} name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.boolean:\n return (\n <Checkbox\n name={name}\n testid={name}\n defaultValue={!!value}\n onChange={(newValue) => {\n if (props.onChange) {\n props.onChange(newValue);\n }\n }}\n />\n );\n case PropertyType.markdown:\n return <TextArea name={name} testid={name} defaultValue={value} onChange={props.onChange} />;\n\n // 2.24.0.2 Complex Types\n // https://www.hl7.org/fhir/datatypes.html#complex\n\n case PropertyType.Address:\n return <AddressInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Annotation:\n return <AnnotationInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Attachment:\n return <AttachmentInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.CodeableConcept:\n return <CodeableConceptInput property={property} name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Coding:\n return <CodingInput property={property} name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.ContactDetail:\n return <ContactDetailInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.ContactPoint:\n return <ContactPointInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Extension:\n return <ExtensionInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.HumanName:\n return <HumanNameInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Identifier:\n return <IdentifierInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Period:\n return <PeriodInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Quantity:\n return <QuantityInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Range:\n return <RangeInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Ratio:\n return <RatioInput name={name} defaultValue={value} onChange={props.onChange} />;\n case PropertyType.Reference:\n return (\n <ReferenceInput\n name={name}\n defaultValue={value}\n targetTypes={getTargetTypes(property)}\n onChange={props.onChange}\n />\n );\n default:\n return (\n <BackboneElementInput\n typeName={buildTypeName(property.path?.split('.') as string[])}\n defaultValue={value}\n onChange={props.onChange}\n outcome={props.outcome}\n />\n );\n }\n}\n\nfunction getTargetTypes(property?: ElementDefinition): string[] | undefined {\n return property?.type?.[0]?.targetProfile?.map((p) => p.split('/').pop() as string);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCM,SAAU,qBAAqB,CAAC,KAAiC,EAAA;;AACrE,IAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AAChC,IAAA,MAAM,YAAY,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,mBAAmB,MAAK,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,IAAI,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,IAAqB,CAAC;AAC7F,IAAA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;AACxB,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC;IAEjC,IAAI,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QAC/C,IAAI,YAAY,KAAK,YAAY,EAAE;AACjC,YAAA,OAAO,oBAAC,oBAAoB,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAI,CAAC;AAC5F,SAAA;QACD,OAAO,KAAA,CAAA,aAAA,CAAC,kBAAkB,EAAC,EAAA,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAI,CAAC;AAC9G,KAAA;AAED,IAAA,MAAM,aAAa,GAAG,QAAQ,CAAC,IAA+B,CAAC;A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CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,KAAK,CAAC,GAAG,CAAa,CAAC,EAC9D,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAA,CACtB,EACF;AACL,KAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,QAA4B,EAAA;;AAClD,IAAA,OAAO,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,QAAQ,aAAR,QAAQ,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAR,QAAQ,CAAE,IAAI,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,0CAAE,aAAa,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAY,CAAC,CAAC;AACtF;;;;"}
File without changes
@@ -0,0 +1,22 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { BackboneElementDisplay } from './BackboneElementDisplay.js';
3
+ import { useMedplum } from './MedplumProvider.js';
4
+ import { useResource } from './useResource.js';
5
+
6
+ function ResourceTable(props) {
7
+ const medplum = useMedplum();
8
+ const value = useResource(props.value);
9
+ const [schema, setSchema] = useState();
10
+ useEffect(() => {
11
+ if (value) {
12
+ medplum.requestSchema(value.resourceType).then(setSchema);
13
+ }
14
+ }, [medplum, value]);
15
+ if (!schema || !value) {
16
+ return null;
17
+ }
18
+ return (React.createElement(BackboneElementDisplay, { value: { type: value.resourceType, value }, ignoreMissingValues: props.ignoreMissingValues }));
19
+ }
20
+
21
+ export { ResourceTable };
22
+ //# sourceMappingURL=ResourceTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourceTable.js","sources":["../../src/ResourceTable.tsx"],"sourcesContent":["import { IndexedStructureDefinition } from '@medplum/core';\nimport { Reference, Resource } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { BackboneElementDisplay } from './BackboneElementDisplay';\nimport { useMedplum } from './MedplumProvider';\nimport { useResource } from './useResource';\n\nexport interface ResourceTableProps {\n value: Resource | Reference;\n ignoreMissingValues?: boolean;\n}\n\nexport function ResourceTable(props: ResourceTableProps): JSX.Element | null {\n const medplum = useMedplum();\n const value = useResource(props.value);\n const [schema, setSchema] = useState<IndexedStructureDefinition | undefined>();\n\n useEffect(() => {\n if (value) {\n medplum.requestSchema(value.resourceType).then(setSchema);\n }\n }, [medplum, value]);\n\n if (!schema || !value) {\n return null;\n }\n\n return (\n <BackboneElementDisplay\n value={{ type: value.resourceType, value }}\n ignoreMissingValues={props.ignoreMissingValues}\n />\n );\n}\n"],"names":[],"mappings":";;;;;AAYM,SAAU,aAAa,CAAC,KAAyB,EAAA;AACrD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAA0C,CAAC;IAE/E,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,KAAK,EAAE;AACT,YAAA,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC3D,SAAA;AACH,KAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAErB,IAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;AACrB,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;IAED,QACE,oBAAC,sBAAsB,EAAA,EACrB,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,EAC1C,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,CAAA,EACF;AACJ;;;;"}
File without changes
@@ -0,0 +1,221 @@
1
+ import { getReferenceString } from '@medplum/core';
2
+ import React, { useRef, useState, useCallback, useEffect } from 'react';
3
+ import { useNavigate } from 'react-router-dom';
4
+ import { AttachmentDisplay } from './AttachmentDisplay.js';
5
+ import { Button } from './Button.js';
6
+ import { DiagnosticReportDisplay } from './DiagnosticReportDisplay.js';
7
+ import { Form } from './Form.js';
8
+ import { Input } from './Input.js';
9
+ import { Loading } from './Loading.js';
10
+ import { useMedplum } from './MedplumProvider.js';
11
+ import { MenuItem } from './MenuItem.js';
12
+ import { ResourceDiffTable } from './ResourceDiffTable.js';
13
+ import { ResourceTable } from './ResourceTable.js';
14
+ import { Scrollable } from './Scrollable.js';
15
+ import { Timeline, TimelineItem } from './Timeline.js';
16
+ import { UploadButton } from './UploadButton.js';
17
+ import { useResource } from './useResource.js';
18
+ import { sortByDateAndPriority } from './utils/date.js';
19
+
20
+ function ResourceTimeline(props) {
21
+ const navigate = useNavigate();
22
+ const medplum = useMedplum();
23
+ const sender = medplum.getProfile();
24
+ const inputRef = useRef(null);
25
+ const resource = useResource(props.value);
26
+ const [history, setHistory] = useState();
27
+ const [items, setItems] = useState([]);
28
+ const buildSearchRequests = props.buildSearchRequests;
29
+ const itemsRef = useRef(items);
30
+ itemsRef.current = items;
31
+ const loadTimeline = useCallback(() => {
32
+ if (!resource) {
33
+ setItems([]);
34
+ setHistory({});
35
+ return;
36
+ }
37
+ medplum.executeBatch(buildSearchRequests(resource)).then(handleBatchResponse);
38
+ }, [medplum, resource, buildSearchRequests]);
39
+ useEffect(() => {
40
+ loadTimeline();
41
+ }, [loadTimeline]);
42
+ /**
43
+ * Handles a batch request response.
44
+ * @param batchResponse The batch response.
45
+ */
46
+ function handleBatchResponse(batchResponse) {
47
+ const newItems = [];
48
+ if (batchResponse.entry) {
49
+ for (const batchEntry of batchResponse.entry) {
50
+ const bundle = batchEntry.resource;
51
+ if (!bundle) {
52
+ // User may not have access to all resource types
53
+ continue;
54
+ }
55
+ if (bundle.type === 'history') {
56
+ setHistory(bundle);
57
+ }
58
+ if (bundle.entry) {
59
+ for (const entry of bundle.entry) {
60
+ newItems.push(entry.resource);
61
+ }
62
+ }
63
+ }
64
+ sortByDateAndPriority(newItems);
65
+ newItems.reverse();
66
+ }
67
+ setItems(newItems);
68
+ }
69
+ /**
70
+ * Adds an array of resources to the timeline.
71
+ * @param resources Array of resources.
72
+ */
73
+ function addResources(resources) {
74
+ const newItems = [...itemsRef.current, ...resources];
75
+ sortByDateAndPriority(newItems);
76
+ newItems.reverse();
77
+ setItems(newItems);
78
+ }
79
+ /**
80
+ * Adds a Communication resource to the timeline.
81
+ * @param contentString The comment content.
82
+ */
83
+ function createComment(contentString) {
84
+ if (!resource || !props.createCommunication) {
85
+ // Encounter not loaded yet
86
+ return;
87
+ }
88
+ medplum.createResource(props.createCommunication(resource, sender, contentString)).then((result) => {
89
+ addResources([result]);
90
+ });
91
+ }
92
+ /**
93
+ * Adds a Media resource to the timeline.
94
+ * @param attachment The media attachment.
95
+ */
96
+ function createMedia(attachment) {
97
+ if (!resource || !props.createMedia) {
98
+ // Encounter not loaded yet
99
+ return;
100
+ }
101
+ medplum.createResource(props.createMedia(resource, sender, attachment)).then((result) => {
102
+ addResources([result]);
103
+ });
104
+ }
105
+ function setPriority(communication, priority) {
106
+ return medplum.updateResource(Object.assign(Object.assign({}, communication), { priority }));
107
+ }
108
+ function onPin(communication) {
109
+ setPriority(communication, 'stat').then(loadTimeline);
110
+ }
111
+ function onUnpin(communication) {
112
+ setPriority(communication, 'routine').then(loadTimeline);
113
+ }
114
+ function onDetails(timelineItem) {
115
+ navigate(`/${timelineItem.resourceType}/${timelineItem.id}`);
116
+ }
117
+ function onEdit(timelineItem) {
118
+ navigate(`/${timelineItem.resourceType}/${timelineItem.id}/edit`);
119
+ }
120
+ function onDelete(timelineItem) {
121
+ navigate(`/${timelineItem.resourceType}/${timelineItem.id}/delete`);
122
+ }
123
+ function onVersionDetails(version) {
124
+ var _a;
125
+ navigate(`/${version.resourceType}/${version.id}/_history/${(_a = version.meta) === null || _a === void 0 ? void 0 : _a.versionId}`);
126
+ }
127
+ if (!resource || !history) {
128
+ return React.createElement(Loading, null);
129
+ }
130
+ return (React.createElement(Timeline, null,
131
+ props.createCommunication && (React.createElement("article", { className: "medplum-timeline-item" },
132
+ React.createElement("div", { className: "medplum-timeline-item-header" },
133
+ React.createElement(Form, { testid: "timeline-form", onSubmit: (formData) => {
134
+ createComment(formData.text);
135
+ const input = inputRef.current;
136
+ if (input) {
137
+ input.value = '';
138
+ input.focus();
139
+ }
140
+ } },
141
+ React.createElement(Input, { name: "text", testid: "timeline-input", inputRef: inputRef }),
142
+ React.createElement(Button, { type: "submit" }, "Comment"),
143
+ React.createElement(UploadButton, { onUpload: createMedia }))))),
144
+ items.map((item) => {
145
+ var _a;
146
+ if (item.resourceType === resource.resourceType && item.id === resource.id) {
147
+ return (React.createElement(HistoryTimelineItem, { key: (_a = item.meta) === null || _a === void 0 ? void 0 : _a.versionId, history: history, resource: item, onDetails: onVersionDetails }));
148
+ }
149
+ const key = `${item.resourceType}/${item.id}`;
150
+ switch (item.resourceType) {
151
+ case 'AuditEvent':
152
+ return React.createElement(AuditEventTimelineItem, { key: key, resource: item, onDetails: onDetails });
153
+ case 'Communication':
154
+ 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 }));
155
+ case 'DiagnosticReport':
156
+ return (React.createElement(DiagnosticReportTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
157
+ case 'Media':
158
+ return (React.createElement(MediaTimelineItem, { key: key, resource: item, onDetails: onDetails, onEdit: onEdit, onDelete: onDelete }));
159
+ default:
160
+ return (React.createElement(TimelineItem, { key: key, resource: item, padding: true },
161
+ React.createElement(ResourceTable, { value: item, ignoreMissingValues: true })));
162
+ }
163
+ })));
164
+ }
165
+ function TimelineItemPopupMenu(props) {
166
+ return (React.createElement(React.Fragment, null,
167
+ props.onPin && (React.createElement(MenuItem, { onClick: () => props.onPin(props.resource), label: `Pin ${getReferenceString(props.resource)}` }, "Pin")),
168
+ props.onUnpin && (React.createElement(MenuItem, { onClick: () => props.onUnpin(props.resource), label: `Unpin ${getReferenceString(props.resource)}` }, "Unpin")),
169
+ props.onDetails && (React.createElement(MenuItem, { onClick: () => props.onDetails(props.resource), label: `Details ${getReferenceString(props.resource)}` }, "Details")),
170
+ props.onEdit && (React.createElement(MenuItem, { onClick: () => props.onEdit(props.resource), label: `Edit ${getReferenceString(props.resource)}` }, "Edit")),
171
+ props.onDelete && (React.createElement(MenuItem, { onClick: () => props.onDelete(props.resource), label: `Delete ${getReferenceString(props.resource)}` }, "Delete"))));
172
+ }
173
+ function HistoryTimelineItem(props) {
174
+ const previous = getPrevious(props.history, props.resource);
175
+ if (previous) {
176
+ return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
177
+ React.createElement(ResourceDiffTable, { original: previous, revised: props.resource })));
178
+ }
179
+ else {
180
+ return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
181
+ React.createElement("h3", null, "Created"),
182
+ React.createElement(ResourceTable, { value: props.resource, ignoreMissingValues: true })));
183
+ }
184
+ }
185
+ function getPrevious(history, version) {
186
+ const entries = history.entry;
187
+ const index = entries.findIndex((entry) => { var _a, _b, _c; return ((_b = (_a = entry.resource) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.versionId) === ((_c = version.meta) === null || _c === void 0 ? void 0 : _c.versionId); });
188
+ if (index >= entries.length - 1) {
189
+ return undefined;
190
+ }
191
+ return entries[index + 1].resource;
192
+ }
193
+ function CommunicationTimelineItem(props) {
194
+ var _a, _b;
195
+ const routine = !props.resource.priority || props.resource.priority === 'routine';
196
+ const className = routine ? 'medplum-timeline-item' : 'medplum-timeline-item medplum-timeline-item-pinned';
197
+ return (React.createElement(TimelineItem, { resource: props.resource, profile: props.resource.sender, padding: true, className: className, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
198
+ React.createElement("p", null, (_b = (_a = props.resource.payload) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.contentString)));
199
+ }
200
+ function MediaTimelineItem(props) {
201
+ var _a;
202
+ const contentType = (_a = props.resource.content) === null || _a === void 0 ? void 0 : _a.contentType;
203
+ const padding = contentType &&
204
+ !contentType.startsWith('image/') &&
205
+ !contentType.startsWith('video/') &&
206
+ contentType !== 'application/pdf';
207
+ return (React.createElement(TimelineItem, { resource: props.resource, padding: !!padding, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
208
+ React.createElement(AttachmentDisplay, { value: props.resource.content })));
209
+ }
210
+ function AuditEventTimelineItem(props) {
211
+ return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
212
+ React.createElement(Scrollable, null,
213
+ React.createElement("pre", null, props.resource.outcomeDesc))));
214
+ }
215
+ function DiagnosticReportTimelineItem(props) {
216
+ return (React.createElement(TimelineItem, { resource: props.resource, padding: true, popupMenuItems: React.createElement(TimelineItemPopupMenu, Object.assign({}, props)) },
217
+ React.createElement(DiagnosticReportDisplay, { value: props.resource })));
218
+ }
219
+
220
+ export { ResourceTimeline };
221
+ //# sourceMappingURL=ResourceTimeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourceTimeline.js","sources":["../../src/ResourceTimeline.tsx"],"sourcesContent":["import { getReferenceString, 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 React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { AttachmentDisplay } from './AttachmentDisplay';\nimport { Button } from './Button';\nimport { DiagnosticReportDisplay } from './DiagnosticReportDisplay';\nimport { Form } from './Form';\nimport { Input } from './Input';\nimport { Loading } from './Loading';\nimport { useMedplum } from './MedplumProvider';\nimport { MenuItem } from './MenuItem';\nimport { ResourceDiffTable } from './ResourceDiffTable';\nimport { ResourceTable } from './ResourceTable';\nimport { Scrollable } from './Scrollable';\nimport { Timeline, TimelineItem } from './Timeline';\nimport { UploadButton } from './UploadButton';\nimport { useResource } from './useResource';\nimport { sortByDateAndPriority } from './utils/date';\nimport './ResourceTimeline.css';\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);\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 newItems.push(entry.resource as Resource);\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.createResource(props.createCommunication(resource, sender, contentString)).then((result) => {\n addResources([result]);\n });\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.createResource(props.createMedia(resource, sender, attachment)).then((result) => {\n addResources([result]);\n });\n }\n\n function setPriority(communication: Communication, priority: string): Promise<Communication> {\n return medplum.updateResource({ ...communication, priority });\n }\n\n function onPin(communication: Communication): void {\n setPriority(communication, 'stat').then(loadTimeline);\n }\n\n function onUnpin(communication: Communication): void {\n setPriority(communication, 'routine').then(loadTimeline);\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 if (!resource || !history) {\n return <Loading />;\n }\n\n return (\n <Timeline>\n {props.createCommunication && (\n <article className=\"medplum-timeline-item\">\n <div className=\"medplum-timeline-item-header\">\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 <Input name=\"text\" testid=\"timeline-input\" inputRef={inputRef} />\n <Button type=\"submit\">Comment</Button>\n <UploadButton onUpload={createMedia} />\n </Form>\n </div>\n </article>\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}\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 <>\n {props.onPin && (\n <MenuItem\n onClick={() => (props.onPin as (resource: T) => void)(props.resource)}\n label={`Pin ${getReferenceString(props.resource)}`}\n >\n Pin\n </MenuItem>\n )}\n {props.onUnpin && (\n <MenuItem\n onClick={() => (props.onUnpin as (resource: T) => void)(props.resource)}\n label={`Unpin ${getReferenceString(props.resource)}`}\n >\n Unpin\n </MenuItem>\n )}\n {props.onDetails && (\n <MenuItem\n onClick={() => (props.onDetails as (resource: T) => void)(props.resource)}\n label={`Details ${getReferenceString(props.resource)}`}\n >\n Details\n </MenuItem>\n )}\n {props.onEdit && (\n <MenuItem\n onClick={() => (props.onEdit as (resource: T) => void)(props.resource)}\n label={`Edit ${getReferenceString(props.resource)}`}\n >\n Edit\n </MenuItem>\n )}\n {props.onDelete && (\n <MenuItem\n onClick={() => (props.onDelete as (resource: T) => void)(props.resource)}\n label={`Delete ${getReferenceString(props.resource)}`}\n >\n Delete\n </MenuItem>\n )}\n </>\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 routine = !props.resource.priority || props.resource.priority === 'routine';\n const className = routine ? 'medplum-timeline-item' : 'medplum-timeline-item medplum-timeline-item-pinned';\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 <Scrollable>\n <pre>{props.resource.outcomeDesc}</pre>\n </Scrollable>\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"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAsCM,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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OAAO,EAAA,CAAI,CACvC,EACf;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAwC,EAAA;IACtE,QACE,oBAAC,YAAY,EAAA,EAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,oBAAC,qBAAqB,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,CAAI,CAAA,EAAA;AACzG,QAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,IAAA;YACT,KAAM,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EAAA,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAO,CAC5B,CACA,EACf;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,KAA8C,EAAA;IAClF,QACE,oBAAC,YAAY,EAAA,EAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,oBAAC,qBAAqB,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,CAAI,CAAA,EAAA;QACzG,KAAC,CAAA,aAAA,CAAA,uBAAuB,EAAC,EAAA,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAA,CAAI,CACrC,EACf;AACJ;;;;"}
File without changes
@@ -0,0 +1,82 @@
1
+ import { getReferenceString } from '@medplum/core';
2
+ import React, { useState, useRef, useEffect } from 'react';
3
+ import { Avatar } from './Avatar.js';
4
+ import { Button } from './Button.js';
5
+ import { CalendarInput } from './CalendarInput.js';
6
+ import { FormSection } from './FormSection.js';
7
+ import { Input } from './Input.js';
8
+ import { useMedplum } from './MedplumProvider.js';
9
+ import { ResourceName } from './ResourceName.js';
10
+ import { useResource } from './useResource.js';
11
+
12
+ function Scheduler(props) {
13
+ var _a;
14
+ const medplum = useMedplum();
15
+ const schedule = useResource(props.schedule);
16
+ const [slots, setSlots] = useState();
17
+ const slotsRef = useRef();
18
+ slotsRef.current = slots;
19
+ const [date, setDate] = useState();
20
+ const [slot, setSlot] = useState();
21
+ const [info, setInfo] = useState();
22
+ const [form, setForm] = useState();
23
+ useEffect(() => {
24
+ if (schedule) {
25
+ medplum.search('Slot', 'schedule=' + getReferenceString(schedule)).then((bundle) => {
26
+ setSlots(bundle.entry.map((entry) => entry.resource));
27
+ });
28
+ }
29
+ else {
30
+ setSlots(undefined);
31
+ }
32
+ }, [medplum, schedule]);
33
+ if (!schedule || !slots) {
34
+ return null;
35
+ }
36
+ const actor = (_a = schedule.actor) === null || _a === void 0 ? void 0 : _a[0];
37
+ return (React.createElement("div", { className: "medplum-calendar-container", "data-testid": "scheduler" },
38
+ React.createElement("div", { className: "medplum-calendar-info-pane" },
39
+ actor && React.createElement(Avatar, { value: actor, size: "large" }),
40
+ actor && (React.createElement("h1", null,
41
+ React.createElement(ResourceName, { value: actor }))),
42
+ React.createElement("p", null, "1 hour"),
43
+ date && React.createElement("p", null, date.toLocaleDateString()),
44
+ slot && React.createElement("p", null, formatTime(new Date(slot.start)))),
45
+ React.createElement("div", { className: "medplum-calendar-selection-pane" },
46
+ !date && (React.createElement("div", null,
47
+ React.createElement("h3", null, "Select date"),
48
+ React.createElement(CalendarInput, { slots: slots, onClick: setDate }))),
49
+ date && !slot && (React.createElement("div", null,
50
+ React.createElement("h3", null, "Select time"),
51
+ slots.map((s) => {
52
+ const slotStart = new Date(s.start);
53
+ return (slotStart.getTime() > date.getTime() &&
54
+ slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (React.createElement("div", { key: s.id },
55
+ React.createElement(Button, { style: { width: 150 }, onClick: () => setSlot(s) }, formatTime(slotStart)))));
56
+ }))),
57
+ date && slot && !info && (React.createElement("div", null,
58
+ React.createElement("h3", null, "Enter your info"),
59
+ React.createElement(FormSection, { title: "Name", htmlFor: "name" },
60
+ React.createElement(Input, { name: "name" })),
61
+ React.createElement(FormSection, { title: "Email", htmlFor: "email" },
62
+ React.createElement(Input, { name: "email" })),
63
+ React.createElement(Button, { primary: true, onClick: () => setInfo('info') }, "Next"))),
64
+ date && slot && info && !form && (React.createElement("div", null,
65
+ React.createElement("h3", null, "Custom questions"),
66
+ React.createElement(FormSection, { title: "Question 1", htmlFor: "q1" },
67
+ React.createElement(Input, { name: "q1" })),
68
+ React.createElement(FormSection, { title: "Question 2", htmlFor: "q2" },
69
+ React.createElement(Input, { name: "email" })),
70
+ React.createElement(FormSection, { title: "Question 3", htmlFor: "q3" },
71
+ React.createElement(Input, { name: "email" })),
72
+ React.createElement(Button, { primary: true, onClick: () => setForm('form') }, "Next"))),
73
+ date && slot && info && form && (React.createElement("div", null,
74
+ React.createElement("h3", null, "You're all set!"),
75
+ React.createElement("p", null, "Check your email for a calendar invite."))))));
76
+ }
77
+ function formatTime(date) {
78
+ return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
79
+ }
80
+
81
+ export { Scheduler };
82
+ //# sourceMappingURL=Scheduler.js.map