@photonhealth/react 0.0.0-stage → 2.0.0-rc.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 (277) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +111 -2
  3. package/dist/adapters/index.d.ts +2 -0
  4. package/dist/adapters/index.d.ts.map +1 -0
  5. package/dist/adapters/index.js +2 -0
  6. package/dist/adapters/index.js.map +1 -0
  7. package/dist/adapters/tailwind.d.ts +3 -0
  8. package/dist/adapters/tailwind.d.ts.map +1 -0
  9. package/dist/adapters/tailwind.js +126 -0
  10. package/dist/adapters/tailwind.js.map +1 -0
  11. package/dist/analytics/PhotonAnalyticsProvider.d.ts +16 -0
  12. package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -0
  13. package/dist/analytics/PhotonAnalyticsProvider.js +57 -0
  14. package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -0
  15. package/dist/analytics/fieldInteraction.d.ts +18 -0
  16. package/dist/analytics/fieldInteraction.d.ts.map +1 -0
  17. package/dist/analytics/fieldInteraction.js +102 -0
  18. package/dist/analytics/fieldInteraction.js.map +1 -0
  19. package/dist/analytics/tracker.d.ts +17 -0
  20. package/dist/analytics/tracker.d.ts.map +1 -0
  21. package/dist/analytics/tracker.js +36 -0
  22. package/dist/analytics/tracker.js.map +1 -0
  23. package/dist/analytics/viewed.d.ts +11 -0
  24. package/dist/analytics/viewed.d.ts.map +1 -0
  25. package/dist/analytics/viewed.js +16 -0
  26. package/dist/analytics/viewed.js.map +1 -0
  27. package/dist/components/ChangeList.d.ts +21 -0
  28. package/dist/components/ChangeList.d.ts.map +1 -0
  29. package/dist/components/ChangeList.js +40 -0
  30. package/dist/components/ChangeList.js.map +1 -0
  31. package/dist/components/PhotonOrder.d.ts +46 -0
  32. package/dist/components/PhotonOrder.d.ts.map +1 -0
  33. package/dist/components/PhotonOrder.js +274 -0
  34. package/dist/components/PhotonOrder.js.map +1 -0
  35. package/dist/components/PhotonPatient.d.ts +48 -0
  36. package/dist/components/PhotonPatient.d.ts.map +1 -0
  37. package/dist/components/PhotonPatient.js +85 -0
  38. package/dist/components/PhotonPatient.js.map +1 -0
  39. package/dist/components/PhotonPrescription.d.ts +32 -0
  40. package/dist/components/PhotonPrescription.d.ts.map +1 -0
  41. package/dist/components/PhotonPrescription.js +11 -0
  42. package/dist/components/PhotonPrescription.js.map +1 -0
  43. package/dist/components/ScreeningAlerts.d.ts +6 -0
  44. package/dist/components/ScreeningAlerts.d.ts.map +1 -0
  45. package/dist/components/ScreeningAlerts.js +11 -0
  46. package/dist/components/ScreeningAlerts.js.map +1 -0
  47. package/dist/components/SignedIn.d.ts +12 -0
  48. package/dist/components/SignedIn.d.ts.map +1 -0
  49. package/dist/components/SignedIn.js +84 -0
  50. package/dist/components/SignedIn.js.map +1 -0
  51. package/dist/components/activity.d.ts +7 -0
  52. package/dist/components/activity.d.ts.map +1 -0
  53. package/dist/components/activity.js +24 -0
  54. package/dist/components/activity.js.map +1 -0
  55. package/dist/components/display.d.ts +90 -0
  56. package/dist/components/display.d.ts.map +1 -0
  57. package/dist/components/display.js +223 -0
  58. package/dist/components/display.js.map +1 -0
  59. package/dist/components/flow.d.ts +35 -0
  60. package/dist/components/flow.d.ts.map +1 -0
  61. package/dist/components/flow.js +53 -0
  62. package/dist/components/flow.js.map +1 -0
  63. package/dist/components/format.d.ts +26 -0
  64. package/dist/components/format.d.ts.map +1 -0
  65. package/dist/components/format.js +61 -0
  66. package/dist/components/format.js.map +1 -0
  67. package/dist/components/index.d.ts +6 -0
  68. package/dist/components/index.d.ts.map +1 -0
  69. package/dist/components/index.js +6 -0
  70. package/dist/components/index.js.map +1 -0
  71. package/dist/components/open.d.ts +47 -0
  72. package/dist/components/open.d.ts.map +1 -0
  73. package/dist/components/open.js +73 -0
  74. package/dist/components/open.js.map +1 -0
  75. package/dist/components/order/DraftOrderPrompt.d.ts +18 -0
  76. package/dist/components/order/DraftOrderPrompt.d.ts.map +1 -0
  77. package/dist/components/order/DraftOrderPrompt.js +26 -0
  78. package/dist/components/order/DraftOrderPrompt.js.map +1 -0
  79. package/dist/components/patient/Benefits.d.ts +25 -0
  80. package/dist/components/patient/Benefits.d.ts.map +1 -0
  81. package/dist/components/patient/Benefits.js +48 -0
  82. package/dist/components/patient/Benefits.js.map +1 -0
  83. package/dist/components/patient/Clinical.d.ts +56 -0
  84. package/dist/components/patient/Clinical.d.ts.map +1 -0
  85. package/dist/components/patient/Clinical.js +118 -0
  86. package/dist/components/patient/Clinical.js.map +1 -0
  87. package/dist/components/patient/IntakeForm.d.ts +10 -0
  88. package/dist/components/patient/IntakeForm.d.ts.map +1 -0
  89. package/dist/components/patient/IntakeForm.js +333 -0
  90. package/dist/components/patient/IntakeForm.js.map +1 -0
  91. package/dist/components/patient/Summary.d.ts +48 -0
  92. package/dist/components/patient/Summary.d.ts.map +1 -0
  93. package/dist/components/patient/Summary.js +90 -0
  94. package/dist/components/patient/Summary.js.map +1 -0
  95. package/dist/components/patient/fields.d.ts +42 -0
  96. package/dist/components/patient/fields.d.ts.map +1 -0
  97. package/dist/components/patient/fields.js +72 -0
  98. package/dist/components/patient/fields.js.map +1 -0
  99. package/dist/components/patient/query.d.ts +37 -0
  100. package/dist/components/patient/query.d.ts.map +1 -0
  101. package/dist/components/patient/query.js +70 -0
  102. package/dist/components/patient/query.js.map +1 -0
  103. package/dist/components/prescription/PrescriptionCard.d.ts +45 -0
  104. package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -0
  105. package/dist/components/prescription/PrescriptionCard.js +179 -0
  106. package/dist/components/prescription/PrescriptionCard.js.map +1 -0
  107. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.d.ts +15 -0
  108. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.d.ts.map +1 -0
  109. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.js +18 -0
  110. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.js.map +1 -0
  111. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.d.ts +23 -0
  112. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.d.ts.map +1 -0
  113. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.js +42 -0
  114. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.js.map +1 -0
  115. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +27 -0
  116. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -0
  117. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +169 -0
  118. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -0
  119. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts +8 -0
  120. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts.map +1 -0
  121. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js +12 -0
  122. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js.map +1 -0
  123. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.d.ts +11 -0
  124. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.d.ts.map +1 -0
  125. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.js +25 -0
  126. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.js.map +1 -0
  127. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.d.ts +50 -0
  128. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.d.ts.map +1 -0
  129. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.js +287 -0
  130. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.js.map +1 -0
  131. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.d.ts +28 -0
  132. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.d.ts.map +1 -0
  133. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.js +146 -0
  134. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.js.map +1 -0
  135. package/dist/components/schemaErrors.d.ts +12 -0
  136. package/dist/components/schemaErrors.d.ts.map +1 -0
  137. package/dist/components/schemaErrors.js +24 -0
  138. package/dist/components/schemaErrors.js.map +1 -0
  139. package/dist/components/search.d.ts +154 -0
  140. package/dist/components/search.d.ts.map +1 -0
  141. package/dist/components/search.js +295 -0
  142. package/dist/components/search.js.map +1 -0
  143. package/dist/hooks/index.d.ts +5 -0
  144. package/dist/hooks/index.d.ts.map +1 -0
  145. package/dist/hooks/index.js +5 -0
  146. package/dist/hooks/index.js.map +1 -0
  147. package/dist/hooks/useLatestCallback.d.ts +7 -0
  148. package/dist/hooks/useLatestCallback.d.ts.map +1 -0
  149. package/dist/hooks/useLatestCallback.js +14 -0
  150. package/dist/hooks/useLatestCallback.js.map +1 -0
  151. package/dist/hooks/useLive.d.ts +15 -0
  152. package/dist/hooks/useLive.d.ts.map +1 -0
  153. package/dist/hooks/useLive.js +6 -0
  154. package/dist/hooks/useLive.js.map +1 -0
  155. package/dist/hooks/useOnChange.d.ts +11 -0
  156. package/dist/hooks/useOnChange.d.ts.map +1 -0
  157. package/dist/hooks/useOnChange.js +28 -0
  158. package/dist/hooks/useOnChange.js.map +1 -0
  159. package/dist/hooks/useSession.d.ts +7 -0
  160. package/dist/hooks/useSession.d.ts.map +1 -0
  161. package/dist/hooks/useSession.js +10 -0
  162. package/dist/hooks/useSession.js.map +1 -0
  163. package/dist/index.d.ts +22 -0
  164. package/dist/index.d.ts.map +1 -0
  165. package/dist/index.js +20 -0
  166. package/dist/index.js.map +1 -0
  167. package/dist/meta/version.d.ts +5 -0
  168. package/dist/meta/version.d.ts.map +1 -0
  169. package/dist/meta/version.js +5 -0
  170. package/dist/meta/version.js.map +1 -0
  171. package/dist/primitives/PhotonProvider.d.ts +60 -0
  172. package/dist/primitives/PhotonProvider.d.ts.map +1 -0
  173. package/dist/primitives/PhotonProvider.js +103 -0
  174. package/dist/primitives/PhotonProvider.js.map +1 -0
  175. package/dist/primitives/defaults.d.ts +3 -0
  176. package/dist/primitives/defaults.d.ts.map +1 -0
  177. package/dist/primitives/defaults.js +70 -0
  178. package/dist/primitives/defaults.js.map +1 -0
  179. package/dist/primitives/icons.d.ts +6 -0
  180. package/dist/primitives/icons.d.ts.map +1 -0
  181. package/dist/primitives/icons.js +6 -0
  182. package/dist/primitives/icons.js.map +1 -0
  183. package/dist/primitives/index.d.ts +5 -0
  184. package/dist/primitives/index.d.ts.map +1 -0
  185. package/dist/primitives/index.js +5 -0
  186. package/dist/primitives/index.js.map +1 -0
  187. package/dist/primitives/photonContext.d.ts +3 -0
  188. package/dist/primitives/photonContext.d.ts.map +1 -0
  189. package/dist/primitives/photonContext.js +3 -0
  190. package/dist/primitives/photonContext.js.map +1 -0
  191. package/dist/primitives/select.d.ts +7 -0
  192. package/dist/primitives/select.d.ts.map +1 -0
  193. package/dist/primitives/select.js +16 -0
  194. package/dist/primitives/select.js.map +1 -0
  195. package/dist/primitives/types.d.ts +288 -0
  196. package/dist/primitives/types.d.ts.map +1 -0
  197. package/dist/primitives/types.js +3 -0
  198. package/dist/primitives/types.js.map +1 -0
  199. package/dist/primitives/useProvidedPhoton.d.ts +8 -0
  200. package/dist/primitives/useProvidedPhoton.d.ts.map +1 -0
  201. package/dist/primitives/useProvidedPhoton.js +8 -0
  202. package/dist/primitives/useProvidedPhoton.js.map +1 -0
  203. package/dist/styles.css +653 -0
  204. package/dist/test-utils/contract.d.ts +17 -0
  205. package/dist/test-utils/contract.d.ts.map +1 -0
  206. package/dist/test-utils/contract.js +282 -0
  207. package/dist/test-utils/contract.js.map +1 -0
  208. package/package.json +76 -4
  209. package/src/adapters/index.ts +1 -0
  210. package/src/adapters/tailwind.tsx +572 -0
  211. package/src/analytics/PhotonAnalyticsProvider.test.tsx +191 -0
  212. package/src/analytics/PhotonAnalyticsProvider.tsx +96 -0
  213. package/src/analytics/fieldInteraction.test.tsx +184 -0
  214. package/src/analytics/fieldInteraction.tsx +148 -0
  215. package/src/analytics/tracker.test.ts +52 -0
  216. package/src/analytics/tracker.ts +42 -0
  217. package/src/analytics/viewed.ts +27 -0
  218. package/src/components/ChangeList.tsx +85 -0
  219. package/src/components/PhotonOrder.test.tsx +256 -0
  220. package/src/components/PhotonOrder.tsx +508 -0
  221. package/src/components/PhotonPatient.tsx +188 -0
  222. package/src/components/PhotonPrescription.test.tsx +116 -0
  223. package/src/components/PhotonPrescription.tsx +45 -0
  224. package/src/components/ScreeningAlerts.tsx +28 -0
  225. package/src/components/SignedIn.tsx +144 -0
  226. package/src/components/activity.ts +23 -0
  227. package/src/components/display.ts +278 -0
  228. package/src/components/flow.ts +67 -0
  229. package/src/components/format.ts +73 -0
  230. package/src/components/index.ts +5 -0
  231. package/src/components/open.ts +100 -0
  232. package/src/components/order/DraftOrderPrompt.test.tsx +80 -0
  233. package/src/components/order/DraftOrderPrompt.tsx +81 -0
  234. package/src/components/patient/Benefits.tsx +133 -0
  235. package/src/components/patient/Clinical.tsx +215 -0
  236. package/src/components/patient/IntakeForm.test.tsx +89 -0
  237. package/src/components/patient/IntakeForm.tsx +564 -0
  238. package/src/components/patient/Summary.test.tsx +106 -0
  239. package/src/components/patient/Summary.tsx +330 -0
  240. package/src/components/patient/fields.tsx +158 -0
  241. package/src/components/patient/query.ts +83 -0
  242. package/src/components/prescription/PrescriptionCard.test.tsx +85 -0
  243. package/src/components/prescription/PrescriptionCard.tsx +347 -0
  244. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +85 -0
  245. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.tsx +41 -0
  246. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +209 -0
  247. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.tsx +99 -0
  248. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +456 -0
  249. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +238 -0
  250. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.test.ts +63 -0
  251. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.ts +15 -0
  252. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +75 -0
  253. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.tsx +41 -0
  254. package/src/components/prescription/TreatmentSearch/TreatmentPicker.tsx +375 -0
  255. package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +699 -0
  256. package/src/components/prescription/TreatmentSearch/TreatmentSearch.tsx +220 -0
  257. package/src/components/schemaErrors.test.ts +49 -0
  258. package/src/components/schemaErrors.ts +33 -0
  259. package/src/components/search.tsx +377 -0
  260. package/src/hooks/index.ts +4 -0
  261. package/src/hooks/useLatestCallback.ts +16 -0
  262. package/src/hooks/useLive.ts +21 -0
  263. package/src/hooks/useOnChange.ts +34 -0
  264. package/src/hooks/useSession.ts +11 -0
  265. package/src/index.ts +21 -0
  266. package/src/meta/version.test.ts +10 -0
  267. package/src/meta/version.ts +4 -0
  268. package/src/primitives/PhotonProvider.tsx +168 -0
  269. package/src/primitives/defaults.tsx +432 -0
  270. package/src/primitives/icons.tsx +37 -0
  271. package/src/primitives/index.ts +4 -0
  272. package/src/primitives/photonContext.ts +4 -0
  273. package/src/primitives/select.ts +15 -0
  274. package/src/primitives/types.ts +288 -0
  275. package/src/primitives/useProvidedPhoton.ts +21 -0
  276. package/src/styles.css +653 -0
  277. package/src/test-utils/contract.tsx +453 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../src/analytics/tracker.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,qHAAqH;AACrH,MAAM,OAAO,OAAO;IAIW;IAH7B,MAAM,GAAG,KAAK,CAAC;IACf,MAAM,GAAkB,EAAE,CAAC;IAE3B,YAA6B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE3C,QAAQ,CAAC,KAAc;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,KAAK;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,MAAmB;QACvB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS;YAAE,OAAO;QAC/B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,iBAAiB;YAAE,OAAO;QACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,KAAK,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,KAAK,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC9G,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAmB,CAAC;AAExD,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,IAAI,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvC,IAAI,CAAC,OAAO;QAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { AnalyticsProperties } from "./tracker.ts";
2
+ interface CardProps {
3
+ order?: unknown;
4
+ patient?: unknown;
5
+ prescription?: unknown;
6
+ locked?: boolean;
7
+ fixed?: boolean;
8
+ }
9
+ export declare function viewedPropertiesFromCardProps(props: CardProps): AnalyticsProperties;
10
+ export {};
11
+ //# sourceMappingURL=viewed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewed.d.ts","sourceRoot":"","sources":["../../src/analytics/viewed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,SAAS,GAAG,mBAAmB,CAanF"}
@@ -0,0 +1,16 @@
1
+ export function viewedPropertiesFromCardProps(props) {
2
+ const order = asObject(props.order);
3
+ const linesToAdd = asObject(order?.prescriptions)?.add;
4
+ const lines = Array.isArray(linesToAdd) ? linesToAdd.map(asObject) : [];
5
+ return {
6
+ hasOrderPrefill: props.order != null,
7
+ hasPatientPrefill: props.patient != null || order?.patient != null,
8
+ hasPrescriptionPrefill: props.prescription != null,
9
+ numTemplateIds: lines.filter((line) => typeof line?.templateId === "string").length,
10
+ numPrescriptionIds: lines.filter((line) => typeof line?.id === "string").length,
11
+ locked: Boolean(props.locked),
12
+ fixed: Boolean(props.fixed),
13
+ };
14
+ }
15
+ const asObject = (value) => value && typeof value === "object" ? value : null;
16
+ //# sourceMappingURL=viewed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewed.js","sourceRoot":"","sources":["../../src/analytics/viewed.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,6BAA6B,CAAC,KAAgB;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC;IACvD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,OAAO;QACL,eAAe,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;QACpC,iBAAiB,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,OAAO,IAAI,IAAI;QAClE,sBAAsB,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;QAClD,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC,MAAM;QACnF,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE,EAAE,KAAK,QAAQ,CAAC,CAAC,MAAM;QAC/E,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;QAC7B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;KAC5B,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAkC,EAAE,CAClE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,IAAI,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ChangeOption, ClassifiedChanges } from "@photonhealth/client";
2
+ import { type SearchHandle } from "./search.tsx";
3
+ /**
4
+ * Renders any ChangeSet the same way in every component:
5
+ * needsChoice → the server's options as search results (closest first; onChoose re-sends)
6
+ * blocking → critical, with the server's reason
7
+ * advisories → dismissible info (COST_SAVINGS, PRODUCT_PREFERENCE, …)
8
+ * Applied INFO changes are not shown — they already took effect. `handleRef` reaches the first choice's
9
+ * results — from the field that asked (e.g. Add allergy), so its keys work on them.
10
+ */
11
+ export declare function ChangeList({ changes, onChoose, busy, handleRef, onBack, }: {
12
+ changes: ClassifiedChanges;
13
+ onChoose?: (option: ChangeOption) => void;
14
+ busy?: boolean;
15
+ handleRef?: {
16
+ current: SearchHandle | null;
17
+ };
18
+ /** Esc in the first choice's results: back to the field that asked. */
19
+ onBack?: () => void;
20
+ }): import("react").JSX.Element | null;
21
+ //# sourceMappingURL=ChangeList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeList.d.ts","sourceRoot":"","sources":["../../src/components/ChangeList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAGhE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,MAAM,GACP,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7C,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,sCAyDA"}
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useComponents } from "../primitives/index.js";
3
+ import { orderedOptions } from "./display.js";
4
+ import { SearchResults } from "./search.js";
5
+ import { useState } from "react";
6
+ /**
7
+ * Renders any ChangeSet the same way in every component:
8
+ * needsChoice → the server's options as search results (closest first; onChoose re-sends)
9
+ * blocking → critical, with the server's reason
10
+ * advisories → dismissible info (COST_SAVINGS, PRODUCT_PREFERENCE, …)
11
+ * Applied INFO changes are not shown — they already took effect. `handleRef` reaches the first choice's
12
+ * results — from the field that asked (e.g. Add allergy), so its keys work on them.
13
+ */
14
+ export function ChangeList({ changes, onChoose, busy, handleRef, onBack, }) {
15
+ const { Alert, Stack } = useComponents();
16
+ const [dismissed, setDismissed] = useState(new Set());
17
+ // The server can report the same problem once per affected field; show it once.
18
+ const unique = (list) => {
19
+ const seen = new Set();
20
+ return list.filter((c) => {
21
+ const id = `${c.label}|${c.reason ?? ""}`;
22
+ return seen.has(id) ? false : (seen.add(id), true);
23
+ });
24
+ };
25
+ const needsChoice = unique(changes.needsChoice);
26
+ const blocking = unique(changes.blocking);
27
+ const advisories = unique(changes.advisories).filter((c) => !dismissed.has(c.key));
28
+ if (!needsChoice.length && !blocking.length && !advisories.length)
29
+ return null;
30
+ return (_jsxs(Stack, { gap: "2", children: [needsChoice.map((change, i) => {
31
+ // Only options that say where their pick goes can be sent back.
32
+ const options = orderedOptions({ options: change.options.filter((o) => o.path) }, change.inputText);
33
+ return (_jsx(SearchResults, { label: change.label, busy: busy, disabled: !onChoose, results: options.map((o, j) => ({
34
+ key: String(j),
35
+ label: o.displayName,
36
+ description: o.reason ?? undefined,
37
+ })), onPick: (key) => onChoose?.(options[Number(key)]), handleRef: i === 0 ? handleRef : undefined, onBack: i === 0 ? onBack : undefined }, `${change.key}-${i}`));
38
+ }), blocking.map((change, i) => (_jsx(Alert, { tone: "critical", title: change.label, description: change.reason ?? undefined }, `${change.key}-${i}`))), advisories.map((change) => (_jsx(Alert, { tone: "info", title: change.label, description: change.reason ?? undefined, onDismiss: () => setDismissed((d) => new Set(d).add(change.key)) }, change.key)))] }));
39
+ }
40
+ //# sourceMappingURL=ChangeList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeList.js","sourceRoot":"","sources":["../../src/components/ChangeList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAqB,MAAM,aAAc,C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M,IAAI,SAAS,IAHlC,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAIzB,CACH,CAAC,EACD,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC1B,KAAC,KAAK,IAEJ,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,WAAW,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS,EACvC,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAJ3D,MAAM,CAAC,GAAG,CAKf,CACH,CAAC,IACI,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Order, Patient, type OrderInput, type PatientInput } from "@photonhealth/client";
2
+ import { type Given } from "./open.ts";
3
+ /**
4
+ * The order is the treatment: who it's for, their prescriptions, and sending them — on one card, bound to a
5
+ * live Order from @photonhealth/client: the one given (live, used as given; or opened from what's given, see `Given`),
6
+ * else a new order for the patient given, or for someone to find or add. The rules are the objects'; this renders
7
+ * them, plus what's only about the screen: which line is focused, and the Sent summary. Send shows once the order
8
+ * is ready and everything is saved.
9
+ *
10
+ * It renders only cards: no page, landmark or app chrome, so it sits in a page, a dialog or a side panel.
11
+ */
12
+ export interface PhotonOrderProps {
13
+ /**
14
+ * The order: a live Order (used as given), its id (`"ord_…"` or `{ id }`: read), its id with fields (that order
15
+ * updated — e.g. prescriptions added), or what's known of one (synced): `{ patient: { id }, prescriptions: {
16
+ * add: [{ templateId: "tmp_…" }, { id: "rx_…" }] } }` — new lines from a template, existing prescriptions (the
17
+ * order takes their patient). Without prescriptions, it starts with one empty line.
18
+ */
19
+ order?: Order | Given<OrderInput> | null;
20
+ /**
21
+ * Who a new order is for, when `order` doesn't say — given as a patient card's `patient` is. Without one,
22
+ * someone to find or add.
23
+ */
24
+ patient?: Patient | Given<PatientInput> | null;
25
+ /**
26
+ * The order's patient, once it has a record and each time that record changes from the backend; `null` on
27
+ * "Change patient".
28
+ */
29
+ onPatient?: (patient: Patient | null) => void;
30
+ /** The order was sent from this card — once per order; e.g. to close the dialog it's in. */
31
+ onSent?: (order: Order) => void;
32
+ /**
33
+ * The order this card shows — given, opened, or the next one (after "Change patient" on a saved draft) — once
34
+ * it, its patient or a prescription has a record, and each time one of those records changes from the
35
+ * backend (a line created or signed, the draft saved, sent). Its ids are what a URL keeps.
36
+ */
37
+ onOrder?: (order: Order) => void;
38
+ /**
39
+ * The order's patient is fixed: "Change patient" is hidden — e.g. embedded beside the host's own view of that
40
+ * patient. The patient and the prescriptions stay editable. (An order handed in, or with existing
41
+ * prescriptions, is fixed anyway.)
42
+ */
43
+ fixed?: boolean;
44
+ }
45
+ export declare function PhotonOrder(props: PhotonOrderProps): import("react").JSX.Element;
46
+ //# sourceMappingURL=PhotonOrder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhotonOrder.d.ts","sourceRoot":"","sources":["../../src/components/PhotonOrder.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,EACL,OAAO,EAGP,KAAK,UAAU,EAEf,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAA4D,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAQjG;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,4FAA4F;IAC5F,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAQlD"}
@@ -0,0 +1,274 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useComponents, usePhoton } from "../primitives/index.js";
3
+ import { AnalyticsWorkflow } from "../analytics/PhotonAnalyticsProvider.js";
4
+ import { viewedPropertiesFromCardProps } from "../analytics/viewed.js";
5
+ import { SignedIn } from "./SignedIn.js";
6
+ import { asksForAddress, Order, Patient, Prescription, } from "@photonhealth/client";
7
+ import { useLive, useOnChange } from "../hooks/index.js";
8
+ import { useEffect, useRef, useState } from "react";
9
+ import { displayName } from "./format.js";
10
+ import { callFor, NotFound, openFailed, openGiven, shared, toOpen } from "./open.js";
11
+ import { PatientCard } from "./PhotonPatient.js";
12
+ import { PrescriptionCard } from "./prescription/PrescriptionCard.js";
13
+ import { DraftOrderPrompt } from "./order/DraftOrderPrompt.js";
14
+ import { ScreeningAlerts } from "./ScreeningAlerts.js";
15
+ import { SearchResults } from "./search.js";
16
+ import { cardFlowKeys, cardProps, focusProps } from "./flow.js";
17
+ /** Its id known: update that order; before, sync what's known. A failure lands on the object (snapshot.error). */
18
+ const change = (order, input) => (order.id ? order.update(input) : order.sync(input)).catch(() => { });
19
+ /** What makes an order's onOrder fire: its record, its patient's and its prescriptions'. */
20
+ const orderRecords = (order) => {
21
+ const lines = order.prescriptions.flatMap((rx) => (rx.state ? [rx.state] : []));
22
+ const patient = order.patient?.state ?? null;
23
+ return order.state || patient || lines.length ? [order.state, patient, lines] : null;
24
+ };
25
+ export function PhotonOrder(props) {
26
+ return (_jsx(AnalyticsWorkflow, { card: "PhotonOrder", viewedProperties: viewedPropertiesFromCardProps(props), children: _jsx(SignedIn, { children: _jsx(OrderCard, { ...props }) }) }));
27
+ }
28
+ /** PhotonOrder, once signed in. */
29
+ function OrderCard(props) {
30
+ const { Alert, Text } = useComponents();
31
+ const ph = usePhoton();
32
+ // The order opened from what's given, and the next one (another patient) — a host's order is used as given.
33
+ const [opened, setOpened] = useState(null);
34
+ // A patient given by id that the server doesn't have: said above someone to find or add.
35
+ const [missingPatient, setMissingPatient] = useState(null);
36
+ const [next, setNext] = useState(null);
37
+ const sharedOrder = props.order instanceof Order ? props.order : null;
38
+ const order = next ?? sharedOrder ?? opened;
39
+ // Orders started on this card (not handed to it): their patient can change — a saved draft by starting over.
40
+ const [ours] = useState(() => new WeakSet()); // added to alongside the state that shows the order
41
+ useOnChange(order, orderRecords, props.onOrder);
42
+ // Why it couldn't be opened, for what it was given: given something else (or a live order), that's gone.
43
+ const [failed, setFailed] = useState(null);
44
+ const sharedPatient = props.patient instanceof Patient ? props.patient : null;
45
+ const orderGiven = toOpen(props.order, Boolean(sharedOrder));
46
+ const patientGiven = toOpen(props.patient, Boolean(sharedPatient));
47
+ // What it's given, by value: a host re-rendering with the same values doesn't open it again.
48
+ const key = JSON.stringify([orderGiven, patientGiven]);
49
+ const how = orderGiven ? callFor(orderGiven) : null;
50
+ // Handed off — an existing order, or existing prescriptions (not template lines) — it keeps its patient.
51
+ const handedOff = Boolean(sharedOrder ||
52
+ (how && how.call !== "sync") ||
53
+ (how?.call === "sync" &&
54
+ how.input.prescriptions?.add?.some((p) => ("id" in p && p.id) || ("externalId" in p && p.externalId))));
55
+ useEffect(() => {
56
+ if (sharedOrder)
57
+ return;
58
+ let live = true;
59
+ const [wanted, forPatient] = JSON.parse(key);
60
+ // Shared while it's in flight: StrictMode runs this twice, and a new order's draft is saved as it opens.
61
+ shared(sharedPatient ?? ph, key, async () => {
62
+ const opening = wanted ? callFor(wanted) : null;
63
+ if (opening && opening.call !== "sync") {
64
+ const existing = await openGiven(ph.order, wanted, (r) => r.order);
65
+ if (!existing)
66
+ throw new NotFound("order", opening.id);
67
+ return { order: existing, missing: null };
68
+ }
69
+ // Synced: what's known of it — its patient (or the one given; or someone to find or add) and prescriptions
70
+ // (or one empty line). The order's own rules decide the rest. A patient given by id that isn't there is said,
71
+ // and the order goes on with someone to find or add — its lines still open.
72
+ const input = opening?.input ?? {};
73
+ const givenPatient = input.patient ?? forPatient;
74
+ let patient = sharedPatient ?? undefined;
75
+ let missing = null;
76
+ if (!patient && givenPatient) {
77
+ patient = (await openGiven(ph.patient, givenPatient, (r) => r.patient)) ?? undefined;
78
+ const id = typeof givenPatient === "string" ? givenPatient : givenPatient.id;
79
+ if (!patient && id)
80
+ missing = new NotFound("patient", id);
81
+ }
82
+ const add = input.prescriptions?.add?.length ? input.prescriptions.add : [{}];
83
+ const started = ph.order();
84
+ // A save that fails (the draft order) shows on the order; only a record that can't be opened stops here.
85
+ await started.sync({ patient, prescriptions: { add } }).catch((e) => {
86
+ if (!started.prescriptions.length)
87
+ throw e;
88
+ });
89
+ // An order with no patient yet (none given, no prescription to take one from) has someone to find or add.
90
+ if (!started.patient)
91
+ await started.sync({ patient: ph.patient() });
92
+ return { order: started, missing };
93
+ })
94
+ .then(({ order: opening, missing }) => {
95
+ if (!handedOff && !opening.id)
96
+ ours.add(opening);
97
+ if (!live)
98
+ return;
99
+ setNext(null);
100
+ setOpened(opening);
101
+ setMissingPatient(missing);
102
+ })
103
+ .catch((error) => live && setFailed({ key, error }));
104
+ return () => {
105
+ live = false;
106
+ };
107
+ }, [ph, ours, sharedOrder, sharedPatient, key, handedOff]);
108
+ const error = !sharedOrder && failed?.key === key ? failed.error : null;
109
+ if (error)
110
+ return _jsx(Alert, { tone: "critical", title: openFailed("order", error), description: error.message });
111
+ if (!order)
112
+ return _jsx(Text, { tone: "tertiary", children: "Loading\u2026" });
113
+ return (_jsx(OrderView, { order: order, handoff: (!ours.has(order) && handedOff) || Boolean(props.fixed), missingPatient: order === opened ? missingPatient : null, events: props, onNewOrder: (started) => {
114
+ ours.add(started);
115
+ setNext(started);
116
+ } }, keyOf(order)));
117
+ }
118
+ function OrderView({ order, handoff, missingPatient, events, onNewOrder, }) {
119
+ const { Alert, Button, Stack } = useComponents();
120
+ const ph = usePhoton();
121
+ const snap = useLive(order);
122
+ const final = order.final;
123
+ const [sentHere, setSentHere] = useState(false);
124
+ const [added, setAdded] = useState(null);
125
+ const lines = snap.prescriptions;
126
+ const patient = snap.patient;
127
+ // New lines ("Add prescription", the next order) take the template the order's first line was started from.
128
+ const templateId = lines[0]?.templateId ?? null;
129
+ // A line has its drug once it has a record, or a pick waiting for the patient — "Add another" waits for all.
130
+ const filled = (line) => Boolean(line.id || line.snapshot.pick);
131
+ const allFilled = lines.length > 0 && lines.every(filled);
132
+ // An open order with no prescriptions (a draft saved that way, or its last one taken off) gets an empty line to
133
+ // write one in, as a new order starts with. Its live lines, not this render's: StrictMode runs this twice.
134
+ useEffect(() => {
135
+ if (!final && order.prescriptions.length === 0)
136
+ void change(order, { prescriptions: { add: [{}] } });
137
+ }, [order, final, lines.length]);
138
+ // Once a patient is found, the cursor moves on to the first line without a drug.
139
+ const [focus, setFocus] = useState(null);
140
+ const patientId = patient?.id ?? null;
141
+ if (patientId && focus?.patientId !== patientId) {
142
+ const next = lines.find((l) => !filled(l));
143
+ setFocus((f) => ({ line: next ?? lines[0], signal: (f?.signal ?? 0) + (next ? 1 : 0), patientId }));
144
+ }
145
+ // Another patient: an order not saved yet takes them; a saved draft keeps its patient, so it's a new order
146
+ // (the draft stays on the server).
147
+ const switchPatient = (next) => {
148
+ if (!order.id)
149
+ return void order.sync({ patient: next }).catch(() => { });
150
+ const fresh = ph.order();
151
+ void fresh.sync({ patient: next, prescriptions: { add: [{ templateId }] } }).then(() => onNewOrder(fresh), () => { });
152
+ };
153
+ const flow = useRef(null);
154
+ // ← / → move between the cards: the patient, each prescription, "Add another", Send (flow.ts).
155
+ return (_jsx("div", { ref: flow, onKeyDown: cardFlowKeys, children: _jsxs(Stack, { gap: "6", children: [final && !sentHere && _jsx(Alert, { tone: "info", title: "This order was already sent" }), _jsx("div", { ...cardProps, children: _jsx(PatientCard, { patient: patient, locked: final, fixed: handoff, addressRequest: final ? null : snap.contactRequest, notFound: snap.patient?.id ? null : missingPatient, onPatient: (next) => {
156
+ events.onPatient?.(next);
157
+ if (!next)
158
+ switchPatient(ph.patient()); // "Change patient": someone new to find or add
159
+ } }) }), !final && snap.candidates.length > 0 && (_jsx("div", { ...cardProps, children: _jsxs(Stack, { gap: "2", children: [_jsx(Alert, { tone: "warning", title: "Several draft orders for this patient" }), _jsx("div", { ...focusProps, children: _jsx(SearchResults, { label: "Draft orders", results: snap.candidates.map((c) => ({
160
+ key: c.id,
161
+ label: c.prescriptions.map((rx) => rx.treatment.name).join(", ") || "No prescriptions",
162
+ meta: c.pharmacy?.name,
163
+ })), onPick: (id) => void order.pick(id).catch(() => { }), busy: snap.status === "loading" || snap.status === "saving" }) })] }) })), !final && snap.draft && (_jsx(DraftOrderPrompt, { draft: snap.draft, onContinue: () => order.continueDraft(), onStartNew: () => order.startNew() })), !snap.draft &&
164
+ lines.map((line) => (_jsx("div", { ...cardProps, children: _jsx(PrescriptionCard, { prescription: line, locked: final,
165
+ // A line comes off; the only one, once it has a drug, gives way to a fresh line (a different drug).
166
+ onRemove: final
167
+ ? undefined
168
+ : lines.length > 1
169
+ ? () => void change(order, { prescriptions: { remove: [line] } })
170
+ : filled(line)
171
+ ? () => {
172
+ void change(order, { prescriptions: { remove: [line], add: [{ templateId }] } });
173
+ setAdded(order.prescriptions.at(-1) ?? null); // the fresh line, at once
174
+ }
175
+ : undefined, autoFocus: line === added, focusSignal: focus?.line === line ? focus.signal : undefined }) }, keyOf(line)))), !final && !snap.draft && allFilled && (_jsx("div", { "data-prx-card": "", children: _jsx("span", { ...focusProps, children: _jsx(Button, { variant: "ghost", icon: "add", onClick: () => {
176
+ void change(order, { prescriptions: { add: [{ templateId }] } });
177
+ setAdded(order.prescriptions.at(-1) ?? null); // a new line is added at once
178
+ }, children: "Add another prescription" }) }) })), _jsx("div", { ...cardProps, children: _jsx(SendSection, { order: order, scope: flow,
179
+ // Send appears once the order is ready — the patient found, each prescription signed — and saved.
180
+ ready: order.readyToSend, onSubmitted: () => {
181
+ setSentHere(true);
182
+ events.onSent?.(order);
183
+ } }) })] }) }));
184
+ }
185
+ /**
186
+ * Send, then the Sent summary — what's left to know once it's gone (the prescriptions are on their cards above;
187
+ * where to go next is the host's navigation). No pharmacy — the patient chooses from the marketplace (a pharmacy already on
188
+ * an opened order is shown and kept). Send shows only when the order can be sent, never as a greyed-out
189
+ * button; what stopped the last send stays shown.
190
+ */
191
+ function SendSection({ order, ready, onSubmitted, scope, }) {
192
+ const { ActionBar, Alert, Badge, Button, Card, CardBody, CardHeader, Row, Stack, Text } = useComponents();
193
+ const snap = useLive(order);
194
+ const [sending, setSending] = useState(false);
195
+ // What the last send left on the order (its changes, or its error) — told apart from a later save's.
196
+ const [sent, setSent] = useState(null);
197
+ const record = snap.state;
198
+ const pharmacy = record?.pharmacy ?? null;
199
+ const count = snap.prescriptions.length;
200
+ const patient = snap.patient?.state;
201
+ const first = patient?.demographic?.name.first ? displayName(patient.demographic.name.first) : null;
202
+ const send = () => {
203
+ if (sending)
204
+ return;
205
+ setSending(true);
206
+ order
207
+ .submit()
208
+ .then(() => order.final && onSubmitted())
209
+ .catch(() => { }) // a refusal or failure lands on the object (snap.error)
210
+ .finally(() => {
211
+ setSent({ changes: order.changes, error: order.snapshot.error });
212
+ setSending(false);
213
+ });
214
+ };
215
+ // ⌘↵ / Ctrl↵ sends from anywhere in the order — never page-wide: in a host's app the same keys are the
216
+ // host's (a ⌘↵ in its own chat box must not send prescriptions).
217
+ useEffect(() => {
218
+ const el = scope.current;
219
+ const onKey = (e) => {
220
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey) && ready && !sending) {
221
+ e.preventDefault();
222
+ e.stopPropagation();
223
+ send();
224
+ }
225
+ };
226
+ el?.addEventListener("keydown", onKey);
227
+ return () => el?.removeEventListener("keydown", onKey);
228
+ });
229
+ if (order.final && record) {
230
+ return (_jsxs(Card, { divided: true, children: [_jsx(CardHeader, { title: first ? `Sent to ${first}` : "Sent" }), _jsx(CardBody, { children: _jsxs(Stack, { gap: "3", children: [_jsxs(Row, { gap: "2", justify: "between", children: [_jsx(Text, { tone: "secondary", children: pharmacy ? `Sent to ${pharmacy.name}.` : "The patient will choose a pharmacy." }), _jsx(Badge, { tone: "success", icon: "check", children: "Sent" })] }), record.fulfillment?.exceptions.map((x) => (_jsx(Alert, { tone: "warning", title: x.type.replace(/_/g, " ").toLowerCase(), description: x.message ?? undefined }, x.id)))] }) })] }));
231
+ }
232
+ // What stopped the last send (the server's reasons, or a failure / refusal) — or, between sends, the draft
233
+ // order not saving (e.g. this patient's last order was sent).
234
+ const fromSend = Boolean(sent && sent.changes === snap.changes && sent.error === snap.error);
235
+ const notSent = fromSend ? reasons(snap.changes.unapplied) : [];
236
+ const notSaved = !fromSend && !sending && !snap.error ? reasons(snap.changes.unapplied) : [];
237
+ const contact = Boolean(snap.contactRequest);
238
+ const failure = snap.error;
239
+ const showSend = ready || sending;
240
+ // Every alert no one has acknowledged — the prescriptions' interactions with each other too — before Send.
241
+ const alerts = order.unacknowledgedAlerts;
242
+ if (!alerts.length && !notSent.length && !notSaved.length && !failure && !showSend)
243
+ return null;
244
+ return (_jsxs(Stack, { gap: "2", children: [_jsx(ScreeningAlerts, { alerts: alerts }), notSent.length > 0 && (_jsx(Alert, { tone: "warning", title: "Not sent", description: notSent.map((c) => c.reason ?? c.label).join(" ") })), failure && !(contact && asksForAddress(null, failure.message)) && (_jsx(Alert, { tone: failure.kind === "refused" ? "warning" : "critical", title: fromSend
245
+ ? failure.kind === "refused"
246
+ ? "Not sent"
247
+ : "Couldn't send"
248
+ : failure.kind === "refused"
249
+ ? "Order not saved"
250
+ : "Couldn't save the order", description: failure.message })), notSaved.length > 0 && (_jsx(Alert, { tone: "warning", title: "Order not saved", description: notSaved.map((c) => c.reason ?? c.label).join(" ") })), showSend && (_jsx(ActionBar, { children: _jsx("span", { ...focusProps, children: _jsx(Button, { loading: sending, onClick: send, children: pharmacy
251
+ ? `Send to ${pharmacy.name}`
252
+ : count > 1
253
+ ? "Send prescriptions to patient"
254
+ : "Send prescription to patient" }) }) }))] }));
255
+ }
256
+ /**
257
+ * What to tell the prescriber about an unsent order: the server's unapplied changes, minus the patient's
258
+ * contact (the patient card asks for it, and it's cleared once they've given it) and the order's own `state`
259
+ * when something else explains why it wasn't sent (network-api adds "a sibling change was rejected").
260
+ */
261
+ function reasons(unapplied) {
262
+ const own = unapplied.filter((c) => !c.key.startsWith("patient.contact."));
263
+ const explained = own.some((c) => c.key !== "state") || own.length < unapplied.length;
264
+ return explained ? own.filter((c) => c.key !== "state") : own;
265
+ }
266
+ /** A stable key per live object. */
267
+ const objectKeys = new WeakMap();
268
+ let nextKey = 0;
269
+ const keyOf = (obj) => {
270
+ if (!objectKeys.has(obj))
271
+ objectKeys.set(obj, ++nextKey);
272
+ return objectKeys.get(obj);
273
+ };
274
+ //# sourceMappingURL=PhotonOrder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhotonOrder.js","sourceRoot":"","sources":["../../src/components/PhotonOrder.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAA0C,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,KAAK,EACL,OAAO,EACP,YAAY,GAKb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EA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G,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IACtF,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAChE,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,GAAG,IAAI,OAAO,EAAkB,CAAC;AACjD,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;AAC9B,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { Patient, type PatientInput } from "@photonhealth/client";
2
+ import { NotFound, type Given } from "./open.ts";
3
+ /**
4
+ * "Who is this patient?" — standalone or inside PhotonOrder. Bound to a live Patient from @photonhealth/client:
5
+ * the one given (`patient`), one opened from what's given (get / update / sync, see `Given`), or a new one to
6
+ * find or add. Before it has a record, every field the prescriber leaves is synced — the server decides: the
7
+ * patient (found, or added), patients it might be (pick one), or what it still needs. Once it has one, edits
8
+ * update it.
9
+ */
10
+ export interface PhotonPatientProps {
11
+ /**
12
+ * The patient: a live Patient (used as given; anything else holding it sees the same changes), its id
13
+ * (`"pat_…"` or `{ id }`: read), its id with fields (that patient updated), or what's known of them without
14
+ * one (synced: found, matched or added).
15
+ */
16
+ patient?: Patient | Given<PatientInput> | null;
17
+ /**
18
+ * The card's patient, once it has a record (found, picked, added, or opened with) and each time that record
19
+ * changes from the backend. `null` on "Change patient": a card given `patient` leaves what's next to the
20
+ * host (pass it a new one); otherwise it starts over itself.
21
+ */
22
+ onPatient?: (patient: Patient | null) => void;
23
+ /** Read-only (e.g. on a sent order): nothing to edit, and no "Change patient". */
24
+ locked?: boolean;
25
+ /**
26
+ * The patient is fixed — e.g. beside the host's own view of them: no "Change patient", but still editable.
27
+ * (An embed whose link names the patient by id is fixed.)
28
+ */
29
+ fixed?: boolean;
30
+ }
31
+ /** A patient card. */
32
+ export declare function PhotonPatient(props: PhotonPatientProps): import("react").JSX.Element;
33
+ /**
34
+ * PhotonPatient, and what only PhotonOrder gives it: the server's request for a way to reach the patient (its
35
+ * reason), which opens the contact fields. Internal: the package index exports only PhotonPatient.
36
+ */
37
+ export declare function PatientCard({ patient, onPatient, locked, fixed, addressRequest, notFound, }: PhotonPatientProps & {
38
+ addressRequest?: string | null;
39
+ /** The patient it was given by id isn't there (PhotonOrder's): said in the form, with the matches. */
40
+ notFound?: NotFound | null;
41
+ }): import("react").JSX.Element;
42
+ /**
43
+ * Find or add the patient. Each field the prescriber leaves (and Enter) sends everything known so far to the
44
+ * live Patient — one query that searches and syncs. The server decides: the patient, patients it might be
45
+ * (listed to pick from), or what it still needs (shown; an address only when it asks). Fields left, not
46
+ * keystrokes: a query with enough to add a patient adds them.
47
+ */
48
+ //# sourceMappingURL=PhotonPatient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhotonPatient.d.ts","sourceRoot":"","sources":["../../src/components/PhotonPatient.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,OAAO,EAAqB,KAAK,YAAY,EAAsB,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAE,QAAQ,EAAiC,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAQhF;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC/C;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,sBAAsB;AACtB,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAQtD;AAYD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,SAAS,EACT,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,GACT,EAAE,kBAAkB,GAAG;IACtB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,sGAAsG;IACtG,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC5B,+BAoGA;AAED;;;;;GAKG"}
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useComponents, usePhoton } from "../primitives/index.js";
3
+ import { AnalyticsWorkflow } from "../analytics/PhotonAnalyticsProvider.js";
4
+ import { viewedPropertiesFromCardProps } from "../analytics/viewed.js";
5
+ import { SignedIn } from "./SignedIn.js";
6
+ import { classify, Patient } from "@photonhealth/client";
7
+ import { useLive, useOnChange } from "../hooks/index.js";
8
+ import { useState } from "react";
9
+ import { NotFound, openFailed, toOpen, useOpened } from "./open.js";
10
+ import { ChangeList } from "./ChangeList.js";
11
+ import { PatientIntakeForm } from "./patient/IntakeForm.js";
12
+ import { diagnosisRef, withoutInline } from "./patient/Clinical.js";
13
+ import { PatientSummary } from "./patient/Summary.js";
14
+ /** A patient card. */
15
+ export function PhotonPatient(props) {
16
+ return (_jsx(AnalyticsWorkflow, { card: "PhotonPatient", viewedProperties: viewedPropertiesFromCardProps(props), children: _jsx(SignedIn, { children: _jsx(PatientCard, { ...props }) }) }));
17
+ }
18
+ /** A stable key per live object: a different patient object gets a fresh form. */
19
+ const objectKeys = new WeakMap();
20
+ let nextKey = 0;
21
+ const keyOf = (obj) => {
22
+ if (!objectKeys.has(obj))
23
+ objectKeys.set(obj, ++nextKey);
24
+ return objectKeys.get(obj);
25
+ };
26
+ const patientOf = (r) => r.patient;
27
+ /**
28
+ * PhotonPatient, and what only PhotonOrder gives it: the server's request for a way to reach the patient (its
29
+ * reason), which opens the contact fields. Internal: the package index exports only PhotonPatient.
30
+ */
31
+ export function PatientCard({ patient, onPatient, locked, fixed, addressRequest, notFound, }) {
32
+ const { Alert, Card, CardHeader } = useComponents();
33
+ const ph = usePhoton();
34
+ // A new patient to find or add when the host gives none (and none to open) — and after "Change patient",
35
+ // when the host didn't give one.
36
+ const shared = patient instanceof Patient ? patient : null;
37
+ const given = toOpen(patient, Boolean(shared));
38
+ const [own, setOwn] = useState(() => (shared || given ? null : ph.patient()));
39
+ const { opened, error: openError } = useOpened(ph.patient, given, patientOf, "patient");
40
+ // Given by id and not there: someone to find or add instead, the reason said in the form — where its matches,
41
+ // and anything else the server says, show. (Read-only, there's nothing to find: just the reason.)
42
+ const missing = openError instanceof NotFound && !locked ? openError : null;
43
+ // One patient object, always: the one given, the one opened from what's given, or the card's own — made once
44
+ // there's none to show (nothing given, "Change patient", or an id the server doesn't have).
45
+ if (missing && !own && !shared)
46
+ setOwn(ph.patient());
47
+ // The host gives another patient: that one, not the card's own.
48
+ const givenKey = JSON.stringify(given);
49
+ const [ownFor, setOwnFor] = useState(givenKey);
50
+ if (givenKey !== ownFor) {
51
+ setOwnFor(givenKey);
52
+ if (given && own)
53
+ setOwn(null);
54
+ }
55
+ const live = shared ?? own ?? opened;
56
+ const snap = useLive(live);
57
+ const record = snap?.state ?? null;
58
+ useOnChange(live, (p) => p.state, onPatient);
59
+ if (openError && !missing)
60
+ return _jsx(Alert, { tone: "critical", title: openFailed("patient", openError), description: openError.message });
61
+ if (!live || !snap) {
62
+ return (_jsx(Card, { divided: true, children: _jsx(CardHeader, { title: "Patient", description: "Loading\u2026" }) }));
63
+ }
64
+ const changes = classify(snap.changes);
65
+ const update = (input) => void live.update(input).catch(() => { }); // failures land on the object
66
+ const patchClinical = (clinical) => update({ clinical });
67
+ const choose = (option) => void live.choose(option).catch(() => { });
68
+ if (record) {
69
+ const messages = withoutInline(changes);
70
+ const hasMessages = messages.needsChoice.length + messages.blocking.length + messages.advisories.length > 0 || Boolean(snap.error);
71
+ return (_jsx(PatientSummary, { patient: record, pickedNames: snap.pickedNames, saving: snap.status === "saving", changes:
72
+ // Only when there's something to say — the card has no body otherwise.
73
+ hasMessages && (_jsxs(_Fragment, { children: [_jsx(ChangeList, { changes: messages, onChoose: choose, busy: snap.status === "saving" }), snap.error && _jsx(Alert, { tone: "critical", title: "Couldn't save", description: snap.error.message })] })), choices: changes.needsChoice, problems: changes.blocking, onChoose: choose, onAddAllergy: (name) => patchClinical({ allergies: { add: [{ name }] } }), onConfirmNone: (list) => patchClinical({ [list]: { none: true } }), onRemoveAllergy: (a) => patchClinical({ allergies: { remove: [{ id: a.id }] } }), onRemoveMedication: (m) => patchClinical({ medications: { remove: [{ id: m.id, status: m.status }] } }), onAddDiagnosis: (text) => patchClinical({ diagnoses: { add: [diagnosisRef(text)] } }), onRemoveDiagnosis: (d) => patchClinical({ diagnoses: { remove: [{ id: d.id }] } }), onAddBenefit: (b) => update({ benefits: { add: [b] } }), onRemoveBenefit: (b) => update({ benefits: { remove: [{ id: b.id }] } }), onConfirmNoBenefits: () => update({ benefits: { none: true } }), onAddMedication: (name) => patchClinical({ medications: { add: [{ name, status: "ACTIVE" }] } }), onSaveContact: (contact) => update({ contact }), onSaveDetails: (details) => update({ demographic: details }), addressRequest: locked ? null : (addressRequest ?? null), readOnly: locked, onChangePatient: locked || fixed
74
+ ? undefined
75
+ : () => {
76
+ onPatient?.(null); // given a patient, the host decides what's next
77
+ if (!shared)
78
+ setOwn(ph.patient());
79
+ } }, record.id));
80
+ }
81
+ // A different patient object (e.g. after "Change patient") starts a fresh form.
82
+ const why = notFound ?? missing;
83
+ return (_jsx(PatientIntakeForm, { patient: live, notice: why && { title: openFailed("patient", why), description: why.message } }, keyOf(live)));
84
+ }
85
+ //# sourceMappingURL=PhotonPatient.js.map