@photonhealth/react 2.0.0-rc.2 → 2.0.0-rc.4

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 (185) hide show
  1. package/README.md +17 -1
  2. package/dist/analytics/PhotonAnalyticsProvider.d.ts +5 -2
  3. package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -1
  4. package/dist/analytics/PhotonAnalyticsProvider.js +34 -15
  5. package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -1
  6. package/dist/analytics/cardLifecycle.d.ts +10 -0
  7. package/dist/analytics/cardLifecycle.d.ts.map +1 -0
  8. package/dist/analytics/cardLifecycle.js +43 -0
  9. package/dist/analytics/cardLifecycle.js.map +1 -0
  10. package/dist/analytics/lifecycleOutcomes.d.ts +8 -0
  11. package/dist/analytics/lifecycleOutcomes.d.ts.map +1 -0
  12. package/dist/analytics/lifecycleOutcomes.js +16 -0
  13. package/dist/analytics/lifecycleOutcomes.js.map +1 -0
  14. package/dist/analytics/tracker.d.ts +5 -3
  15. package/dist/analytics/tracker.d.ts.map +1 -1
  16. package/dist/analytics/tracker.js +10 -5
  17. package/dist/analytics/tracker.js.map +1 -1
  18. package/dist/components/PhotonOrder.d.ts +18 -18
  19. package/dist/components/PhotonOrder.d.ts.map +1 -1
  20. package/dist/components/PhotonOrder.js +17 -6
  21. package/dist/components/PhotonOrder.js.map +1 -1
  22. package/dist/components/PhotonPatient.d.ts +7 -35
  23. package/dist/components/PhotonPatient.d.ts.map +1 -1
  24. package/dist/components/PhotonPatient.js +3 -77
  25. package/dist/components/PhotonPatient.js.map +1 -1
  26. package/dist/components/PhotonPrescription.d.ts +14 -14
  27. package/dist/components/PhotonPrescription.d.ts.map +1 -1
  28. package/dist/components/PhotonPrescription.js +0 -1
  29. package/dist/components/PhotonPrescription.js.map +1 -1
  30. package/dist/components/open.d.ts +11 -13
  31. package/dist/components/open.d.ts.map +1 -1
  32. package/dist/components/open.js +7 -2
  33. package/dist/components/open.js.map +1 -1
  34. package/dist/components/patient/PatientCard/PatientCard.d.ts +30 -0
  35. package/dist/components/patient/PatientCard/PatientCard.d.ts.map +1 -0
  36. package/dist/components/patient/PatientCard/PatientCard.js +101 -0
  37. package/dist/components/patient/PatientCard/PatientCard.js.map +1 -0
  38. package/dist/components/patient/PatientCard/usePatientToShow.d.ts +22 -0
  39. package/dist/components/patient/PatientCard/usePatientToShow.d.ts.map +1 -0
  40. package/dist/components/patient/PatientCard/usePatientToShow.js +40 -0
  41. package/dist/components/patient/PatientCard/usePatientToShow.js.map +1 -0
  42. package/dist/components/patient/PatientIntakeForm.d.ts +16 -0
  43. package/dist/components/patient/PatientIntakeForm.d.ts.map +1 -0
  44. package/dist/components/patient/PatientIntakeForm.js +114 -0
  45. package/dist/components/patient/PatientIntakeForm.js.map +1 -0
  46. package/dist/components/patient/PatientSearch.d.ts +12 -0
  47. package/dist/components/patient/PatientSearch.d.ts.map +1 -0
  48. package/dist/components/patient/PatientSearch.js +148 -0
  49. package/dist/components/patient/PatientSearch.js.map +1 -0
  50. package/dist/components/patient/{Benefits.d.ts → PatientSummary/BenefitsInputForm.d.ts} +2 -2
  51. package/dist/components/patient/PatientSummary/BenefitsInputForm.d.ts.map +1 -0
  52. package/dist/components/patient/{Benefits.js → PatientSummary/BenefitsInputForm.js} +5 -5
  53. package/dist/components/patient/PatientSummary/BenefitsInputForm.js.map +1 -0
  54. package/dist/components/patient/{Clinical.d.ts → PatientSummary/ClinicalInputForm.d.ts} +13 -15
  55. package/dist/components/patient/PatientSummary/ClinicalInputForm.d.ts.map +1 -0
  56. package/dist/components/patient/{Clinical.js → PatientSummary/ClinicalInputForm.js} +11 -11
  57. package/dist/components/patient/PatientSummary/ClinicalInputForm.js.map +1 -0
  58. package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts +5 -0
  59. package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts.map +1 -0
  60. package/dist/components/patient/PatientSummary/CollapsedSummary.js +30 -0
  61. package/dist/components/patient/PatientSummary/CollapsedSummary.js.map +1 -0
  62. package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts +10 -0
  63. package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts.map +1 -0
  64. package/dist/components/patient/PatientSummary/PatientDetailsForm.js +65 -0
  65. package/dist/components/patient/PatientSummary/PatientDetailsForm.js.map +1 -0
  66. package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts +53 -0
  67. package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts.map +1 -0
  68. package/dist/components/patient/PatientSummary/PatientDetailsSchema.js +78 -0
  69. package/dist/components/patient/PatientSummary/PatientDetailsSchema.js.map +1 -0
  70. package/dist/components/patient/PatientSummary/PatientSummary.d.ts +46 -0
  71. package/dist/components/patient/PatientSummary/PatientSummary.d.ts.map +1 -0
  72. package/dist/components/patient/PatientSummary/PatientSummary.js +57 -0
  73. package/dist/components/patient/PatientSummary/PatientSummary.js.map +1 -0
  74. package/dist/components/patient/PatientSummary/SummaryHeader.d.ts +19 -0
  75. package/dist/components/patient/PatientSummary/SummaryHeader.d.ts.map +1 -0
  76. package/dist/components/patient/PatientSummary/SummaryHeader.js +22 -0
  77. package/dist/components/patient/PatientSummary/SummaryHeader.js.map +1 -0
  78. package/dist/components/patient/fields.d.ts +7 -25
  79. package/dist/components/patient/fields.d.ts.map +1 -1
  80. package/dist/components/patient/fields.js +11 -53
  81. package/dist/components/patient/fields.js.map +1 -1
  82. package/dist/components/patient/parsePatientSearchQuery.d.ts +16 -0
  83. package/dist/components/patient/parsePatientSearchQuery.d.ts.map +1 -0
  84. package/dist/components/patient/{query.js → parsePatientSearchQuery.js} +3 -15
  85. package/dist/components/patient/parsePatientSearchQuery.js.map +1 -0
  86. package/dist/components/prescription/PrescriptionCard.d.ts +14 -8
  87. package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -1
  88. package/dist/components/prescription/PrescriptionCard.js +10 -3
  89. package/dist/components/prescription/PrescriptionCard.js.map +1 -1
  90. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +6 -6
  91. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -1
  92. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +16 -8
  93. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -1
  94. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts +14 -1
  95. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts.map +1 -1
  96. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js +25 -7
  97. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js.map +1 -1
  98. package/dist/components/schemaErrors.d.ts +3 -2
  99. package/dist/components/schemaErrors.d.ts.map +1 -1
  100. package/dist/components/schemaErrors.js +2 -1
  101. package/dist/components/schemaErrors.js.map +1 -1
  102. package/dist/components/search.d.ts +1 -1
  103. package/dist/components/search.js +1 -1
  104. package/dist/index.d.ts +1 -1
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +1 -1
  107. package/dist/index.js.map +1 -1
  108. package/dist/meta/version.js +1 -1
  109. package/package.json +5 -2
  110. package/src/analytics/PhotonAnalyticsProvider.test.tsx +0 -1
  111. package/src/analytics/PhotonAnalyticsProvider.tsx +75 -20
  112. package/src/analytics/cardLifecycle.test.tsx +272 -0
  113. package/src/analytics/cardLifecycle.ts +44 -0
  114. package/src/analytics/fieldInteraction.test.tsx +11 -9
  115. package/src/analytics/lifecycleOutcomes.test.ts +78 -0
  116. package/src/analytics/lifecycleOutcomes.ts +29 -0
  117. package/src/analytics/tracker.test.ts +1 -1
  118. package/src/analytics/tracker.ts +13 -6
  119. package/src/analytics/usePhotonAnalytics.test.tsx +106 -0
  120. package/src/components/PhotonOrder.test.tsx +146 -8
  121. package/src/components/PhotonOrder.tsx +37 -26
  122. package/src/components/PhotonPatient.tsx +8 -163
  123. package/src/components/PhotonPrescription.test.tsx +22 -18
  124. package/src/components/PhotonPrescription.tsx +14 -14
  125. package/src/components/ScreeningAlerts.test.tsx +81 -0
  126. package/src/components/open.ts +13 -16
  127. package/src/components/order/DraftOrderPrompt.test.tsx +3 -6
  128. package/src/components/patient/PatientCard/PatientCard.test.tsx +255 -0
  129. package/src/components/patient/PatientCard/PatientCard.tsx +177 -0
  130. package/src/components/patient/PatientCard/usePatientToShow.ts +44 -0
  131. package/src/components/patient/PatientIntakeForm.test.tsx +262 -0
  132. package/src/components/patient/PatientIntakeForm.tsx +222 -0
  133. package/src/components/patient/PatientSearch.test.tsx +204 -0
  134. package/src/components/patient/PatientSearch.tsx +221 -0
  135. package/src/components/patient/PatientSummary/BenefitsInputForm.test.tsx +164 -0
  136. package/src/components/patient/{Benefits.tsx → PatientSummary/BenefitsInputForm.tsx} +4 -4
  137. package/src/components/patient/PatientSummary/ClinicalInputForm.test.tsx +247 -0
  138. package/src/components/patient/{Clinical.tsx → PatientSummary/ClinicalInputForm.tsx} +23 -23
  139. package/src/components/patient/PatientSummary/CollapsedSummary.test.tsx +90 -0
  140. package/src/components/patient/PatientSummary/CollapsedSummary.tsx +46 -0
  141. package/src/components/patient/PatientSummary/PatientDetailsForm.test.tsx +201 -0
  142. package/src/components/patient/PatientSummary/PatientDetailsForm.tsx +320 -0
  143. package/src/components/patient/PatientSummary/PatientDetailsSchema.test.ts +296 -0
  144. package/src/components/patient/PatientSummary/PatientDetailsSchema.ts +95 -0
  145. package/src/components/patient/PatientSummary/PatientSummary.test.tsx +194 -0
  146. package/src/components/patient/PatientSummary/PatientSummary.tsx +225 -0
  147. package/src/components/patient/PatientSummary/SummaryHeader.test.tsx +183 -0
  148. package/src/components/patient/PatientSummary/SummaryHeader.tsx +85 -0
  149. package/src/components/patient/fields.tsx +12 -138
  150. package/src/components/patient/parsePatientSearchQuery.test.ts +107 -0
  151. package/src/components/patient/{query.ts → parsePatientSearchQuery.ts} +4 -21
  152. package/src/components/prescription/PrescriptionCard.test.tsx +175 -12
  153. package/src/components/prescription/PrescriptionCard.tsx +28 -14
  154. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +2 -5
  155. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +3 -6
  156. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +34 -37
  157. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +24 -16
  158. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.test.ts +166 -41
  159. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.ts +41 -9
  160. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +2 -5
  161. package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +3 -7
  162. package/src/components/schemaErrors.ts +3 -2
  163. package/src/components/search.tsx +1 -1
  164. package/src/index.ts +1 -1
  165. package/src/meta/version.test.ts +1 -0
  166. package/src/meta/version.ts +1 -1
  167. package/dist/components/patient/Benefits.d.ts.map +0 -1
  168. package/dist/components/patient/Benefits.js.map +0 -1
  169. package/dist/components/patient/Clinical.d.ts.map +0 -1
  170. package/dist/components/patient/Clinical.js.map +0 -1
  171. package/dist/components/patient/IntakeForm.d.ts +0 -10
  172. package/dist/components/patient/IntakeForm.d.ts.map +0 -1
  173. package/dist/components/patient/IntakeForm.js +0 -333
  174. package/dist/components/patient/IntakeForm.js.map +0 -1
  175. package/dist/components/patient/Summary.d.ts +0 -48
  176. package/dist/components/patient/Summary.d.ts.map +0 -1
  177. package/dist/components/patient/Summary.js +0 -90
  178. package/dist/components/patient/Summary.js.map +0 -1
  179. package/dist/components/patient/query.d.ts +0 -37
  180. package/dist/components/patient/query.d.ts.map +0 -1
  181. package/dist/components/patient/query.js.map +0 -1
  182. package/src/components/patient/IntakeForm.test.tsx +0 -89
  183. package/src/components/patient/IntakeForm.tsx +0 -564
  184. package/src/components/patient/Summary.test.tsx +0 -106
  185. package/src/components/patient/Summary.tsx +0 -330
@@ -1 +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"}
1
+ {"version":3,"file":"PhotonPatient.d.ts","sourceRoot":"","sources":["../../src/components/PhotonPatient.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,MAAM,GAAG,IAAI,CAAC;IACjD;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/C;AAED,sBAAsB;AACtB,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAQtD"}
@@ -1,85 +1,11 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useComponents, usePhoton } from "../primitives/index.js";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { AnalyticsWorkflow } from "../analytics/PhotonAnalyticsProvider.js";
4
3
  import { viewedPropertiesFromCardProps } from "../analytics/viewed.js";
5
4
  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";
5
+ import {} from "@photonhealth/client";
6
+ import { PatientCard } from "./patient/PatientCard/PatientCard.js";
14
7
  /** A patient card. */
15
8
  export function PhotonPatient(props) {
16
9
  return (_jsx(AnalyticsWorkflow, { card: "PhotonPatient", viewedProperties: viewedPropertiesFromCardProps(props), children: _jsx(SignedIn, { children: _jsx(PatientCard, { ...props }) }) }));
17
10
  }
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
11
  //# sourceMappingURL=PhotonPatient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhotonPatient.js","sourceRoot":"","sources":["../../src/components/PhotonPatient.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAA0C,CA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EAAE,WAAW,EAAE,MAAM,sCAAuC,CAAC;AAmBpE,sBAAsB;AACtB,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,OAAO,CACL,KAAC,iBAAiB,IAAC,IAAI,EAAC,eAAe,EAAC,gBAAgB,EAAE,6BAA6B,CAAC,KAAK,CAAC,YAC5F,KAAC,QAAQ,cACP,KAAC,WAAW,OAAK,KAAK,GAAI,GACjB,GACO,CACrB,CAAC;AACJ,CAAC"}
@@ -1,23 +1,23 @@
1
1
  import { type Patient, type Prescription, type PatientInput, type PrescriptionInput } from "@photonhealth/client";
2
- import { type Given } from "./open.ts";
3
- /**
4
- * One prescription: free-text drug → the server resolves it (or offers choices) → sig and dispense →
5
- * screening → Sign. Standalone or inside PhotonOrder. Bound to a live Prescription from @photonhealth/client: the
6
- * one given (`prescription` — a line before its record, or an existing one), one opened from its id and / or an
7
- * input (get / sync / update), or else a new line. The rules are the object's; this renders it.
8
- */
9
2
  export interface PhotonPrescriptionProps {
10
3
  /**
11
- * The prescription: a live Prescription (used as given; anything else holding it sees the same changes), its
12
- * id (`"rx_…"` or `{ id }`: read), its id with fields (that prescription updated), or fields without one
13
- * (synced — e.g. `{ templateId }` or `{ treatment: { name } }`).
4
+ * The prescription, one of:
5
+ * - a live `Prescription`: used as is; anything else holding it sees the same changes
6
+ * - its id, `"rx_…"` or `{ id }`: gets the prescription
7
+ * - its id with fields, `{ id, … }`: updates the prescription
8
+ * - fields without an id, e.g. `{ templateId }` or `{ treatment: { name } }`: upserts the prescription
14
9
  */
15
- prescription?: Prescription | Given<PrescriptionInput> | null;
10
+ prescription?: Prescription | PrescriptionInput | string | null;
16
11
  /**
17
- * Who it's for — given as a patient card's `patient` is. Until it's known, a new line only looks drugs up
18
- * (a line from an order already knows).
12
+ * Who it's for, one of:
13
+ * - a live `Patient`: used as is
14
+ * - its id, `"pat_…"` or `{ id }`: gets the patient
15
+ * - its id with fields, `{ id, … }`: updates the patient
16
+ * - fields without an id: upserts the patient
17
+ *
18
+ * Until it's known, a new line only looks drugs up.
19
19
  */
20
- patient?: Patient | Given<PatientInput> | null;
20
+ patient?: Patient | PatientInput | string | null;
21
21
  /** Read-only (e.g. on a finalized order). A signed prescription is always read-only. */
22
22
  locked?: boolean;
23
23
  /** The prescriber signed it on this card — once per prescription. */
@@ -1 +1 @@
1
- {"version":3,"file":"PhotonPrescription.d.ts","sourceRoot":"","sources":["../../src/components/PhotonPrescription.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAC9D;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC/C,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+BAQhE"}
1
+ {"version":3,"file":"PhotonPrescription.d.ts","sourceRoot":"","sources":["../../src/components/PhotonPrescription.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGlH,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAAC;IAChE;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,MAAM,GAAG,IAAI,CAAC;IACjD,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+BAQhE"}
@@ -4,7 +4,6 @@ import { viewedPropertiesFromCardProps } from "../analytics/viewed.js";
4
4
  import { SignedIn } from "./SignedIn.js";
5
5
  import {} from "@photonhealth/client";
6
6
  import { PrescriptionCard } from "./prescription/PrescriptionCard.js";
7
- import {} from "./open.js";
8
7
  export function PhotonPrescription(props) {
9
8
  return (_jsx(AnalyticsWorkflow, { card: "PhotonPrescription", viewedProperties: viewedPropertiesFromCardProps(props), children: _jsx(SignedIn, { children: _jsx(PrescriptionCard, { ...props }) }) }));
10
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PhotonPrescription.js","sourceRoot":"","sources":["../../src/components/PhotonPrescription.tsx"],"names":[],"mappings":";AAAA,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,EAA8E,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAqC,CAAC;AACvE,OAAO,EAAc,MAAM,WAAW,CAAC;AA+BvC,MAAM,UAAU,kBAAkB,CAAC,KAA8B;IAC/D,OAAO,CACL,KAAC,iBAAiB,IAAC,IAAI,EAAC,oBAAoB,EAAC,gBAAgB,EAAE,6BAA6B,CAAC,KAAK,CAAC,YACjG,KAAC,QAAQ,cACP,KAAC,gBAAgB,OAAK,KAAK,GAAI,GACtB,GACO,CACrB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"PhotonPrescription.js","sourceRoot":"","sources":["../../src/components/PhotonPrescription.tsx"],"names":[],"mappings":";AAAA,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,EAA8E,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAqC,CAAC;AAgCvE,MAAM,UAAU,kBAAkB,CAAC,KAA8B;IAC/D,OAAO,CACL,KAAC,iBAAiB,IAAC,IAAI,EAAC,oBAAoB,EAAC,gBAAgB,EAAE,6BAA6B,CAAC,KAAK,CAAC,YACjG,KAAC,QAAQ,cACP,KAAC,gBAAgB,OAAK,KAAK,GAAI,GACtB,GACO,CACrB,CAAC;AACJ,CAAC"}
@@ -1,11 +1,4 @@
1
1
  import type { Calls } from "@photonhealth/client";
2
- /**
3
- * What a card is given for one record — any of: its id (`"pat_…"` or `{ id }`: read, `get`), the record's fields
4
- * with its id (`update(id, fields)`: only those change), or fields without one (`sync`: the server finds,
5
- * matches or creates). A live object instead is used as given and never comes here. Links give records the same
6
- * way.
7
- */
8
- export type Given<I extends object> = I | string;
9
2
  /**
10
3
  * A record given by id that the server doesn't have — network-api opens records only in the prescriber's own
11
4
  * organization, so a link from another one lands here too.
@@ -15,8 +8,13 @@ export declare class NotFound extends Error {
15
8
  }
16
9
  /** A card's title for a record it couldn't open: not found, or couldn't. */
17
10
  export declare const openFailed: (what: string, error: Error) => string;
18
- /** How a given record opens: `get`, `update` or `sync` — and with what. */
19
- export declare function callFor<I extends object>(value: Given<I>): {
11
+ /**
12
+ * How a record a card is given (an id, or an input) opens: `get`, `update` or `sync` — and with what. Its id
13
+ * (`"pat_…"` or `{ id }`) is read (`get`); the record's fields with its id update it (`update(id, fields)`: only
14
+ * those change); fields without one sync (`sync`: the server finds, matches or creates). A live object is used as
15
+ * given and never comes here. Links give records the same way.
16
+ */
17
+ export declare function callFor<I extends object>(value: I | string): {
20
18
  call: "get";
21
19
  id: string;
22
20
  } | {
@@ -27,20 +25,20 @@ export declare function callFor<I extends object>(value: Given<I>): {
27
25
  call: "sync";
28
26
  input: I;
29
27
  };
30
- /** Open a given record (see `Given`); null when an id has no record. */
31
- export declare function openGiven<T, I extends object, R>(calls: Calls<T, I, Omit<I, "id">, R>, value: Given<I>, objectOf: (result: R) => T | null): Promise<T | null>;
28
+ /** Open a given record (see `callFor`); null when an id has no record. */
29
+ export declare function openGiven<T, I extends object, R>(calls: Calls<T, I, Omit<I, "id">, R>, value: I | string, objectOf: (result: R) => T | null): Promise<T | null>;
32
30
  /**
33
31
  * The same open already in flight, shared: React's StrictMode runs an effect twice, and opening from an input
34
32
  * writes (a sync). `scope` is what it's opened through (the calls, a photon instance), `key` what it's given.
35
33
  */
36
34
  export declare function shared<T>(scope: object, key: string, run: () => Promise<T>): Promise<T>;
37
35
  /** A record given as something to open: an id, or an input with something in it (an empty input is none). */
38
- export declare const toOpen: <I extends object>(value: Given<I> | object | null | undefined, isLive: boolean) => Given<I> | null;
36
+ export declare const toOpen: <I extends object>(value: I | string | object | null | undefined, isLive: boolean) => string | I | null;
39
37
  /**
40
38
  * `openGiven` for a card: the object once it's open, or why it couldn't be. Opens again when what it's given
41
39
  * changes (by value).
42
40
  */
43
- export declare function useOpened<T, I extends object, R>(calls: Calls<T, I, Omit<I, "id">, R>, value: Given<I> | null, objectOf: (result: R) => T | null, what: string): {
41
+ export declare function useOpened<T, I extends object, R>(calls: Calls<T, I, Omit<I, "id">, R>, value: I | string | null, objectOf: (result: R) => T | null, what: string): {
44
42
  opened: T | null;
45
43
  error: Error | null;
46
44
  };
@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,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,CAqB3C"}
@@ -11,7 +11,12 @@ export class NotFound extends Error {
11
11
  }
12
12
  /** A card's title for a record it couldn't open: not found, or couldn't. */
13
13
  export const openFailed = (what, error) => error instanceof NotFound ? `${what[0].toUpperCase()}${what.slice(1)} not found` : `Couldn't open this ${what}`;
14
- /** How a given record opens: `get`, `update` or `sync` — and with what. */
14
+ /**
15
+ * How a record a card is given (an id, or an input) opens: `get`, `update` or `sync` — and with what. Its id
16
+ * (`"pat_…"` or `{ id }`) is read (`get`); the record's fields with its id update it (`update(id, fields)`: only
17
+ * those change); fields without one sync (`sync`: the server finds, matches or creates). A live object is used as
18
+ * given and never comes here. Links give records the same way.
19
+ */
15
20
  export function callFor(value) {
16
21
  if (typeof value === "string")
17
22
  return { call: "get", id: value };
@@ -20,7 +25,7 @@ export function callFor(value) {
20
25
  return { call: "sync", input: value };
21
26
  return Object.keys(fields).length ? { call: "update", id, fields: fields } : { call: "get", id };
22
27
  }
23
- /** Open a given record (see `Given`); null when an id has no record. */
28
+ /** Open a given record (see `callFor`); null when an id has no record. */
24
29
  export function openGiven(calls, value, objectOf) {
25
30
  return shared(calls, JSON.stringify(value), async () => {
26
31
  const how = callFor(value);
@@ -1 +1 @@
1
- {"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/components/open.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU5C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,YAAY,IAAY,EAAE,EAAU;QAClC,KAAK,CAAC,cAAc,IAAI,IAAI,EAAE,wBAAwB,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,KAAY,EAAE,EAAE,CACvD,KAA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,CAAC;IACjC,OAAO,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACnE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type NotFound } from "../../open.ts";
2
+ import type { PhotonPatientProps } from "../../PhotonPatient.tsx";
3
+ /** What PatientCard renders, in the order its body checks for each. */
4
+ export declare enum PatientCardState {
5
+ /** The patient couldn't be opened for a reason other than not found: an error alert. */
6
+ FAILED_TO_OPEN = "failedToOpen",
7
+ /** No live patient yet, or no snapshot of it: the "Loading…" card. */
8
+ LOADING = "loading",
9
+ /** The patient has a record: PatientSummary. */
10
+ SUMMARY = "summary",
11
+ /** The patient has no record yet: PatientSearch, to match any existing records. */
12
+ SEARCH = "search",
13
+ /** The patient has no record yet, and user is adding the patient to Photon: PatientIntakeForm. */
14
+ INTAKE_FORM = "intakeForm"
15
+ }
16
+ /**
17
+ * PhotonPatient, and what only PhotonOrder gives it: read-only and no "Change patient" (a sent order), no "Change
18
+ * patient" (an order handed off to it), and the server's request for a way to reach the patient (its reason),
19
+ * which opens the contact fields. Internal: the package index exports only PhotonPatient.
20
+ */
21
+ export declare function PatientCard({ patient: patientProp, onPatient, readOnly, hideChangePatient, addressRequest, notFound: notFoundInOrder, }: PhotonPatientProps & {
22
+ /** Nothing to edit, and no "Change patient" (a sent order's patient). */
23
+ readOnly?: boolean;
24
+ /** No "Change patient", but still editable (an order handed off to PhotonOrder). */
25
+ hideChangePatient?: boolean;
26
+ addressRequest?: string | null;
27
+ /** The patient it was given by id isn't there (PhotonOrder's): said in the form, with the matches. */
28
+ notFound?: NotFound | null;
29
+ }): import("react").JSX.Element;
30
+ //# sourceMappingURL=PatientCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientCard.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientCard/PatientCard.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAiBlE,uEAAuE;AACvE,oBAAY,gBAAgB;IAC1B,wFAAwF;IACxF,cAAc,iBAAiB;IAC/B,sEAAsE;IACtE,OAAO,YAAY;IACnB,gDAAgD;IAChD,OAAO,YAAY;IACnB,mFAAmF;IACnF,MAAM,WAAW;IACjB,kGAAkG;IAClG,WAAW,eAAe;CAC3B;AA8BD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EAAE,WAAW,EACpB,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAAE,eAAe,GAC1B,EAAE,kBAAkB,GAAG;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,sGAAsG;IACtG,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC5B,+BA4FA"}
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useComponents } from "../../../primitives/index.js";
3
+ import { classify } from "@photonhealth/client";
4
+ import { useLive, useOnChange } from "../../../hooks/index.js";
5
+ import { useState } from "react";
6
+ import { openFailed } from "../../open.js";
7
+ import { PatientIntakeForm } from "../PatientIntakeForm.js";
8
+ import { PatientSearch } from "../PatientSearch.js";
9
+ import { PatientSummary } from "../PatientSummary/PatientSummary.js";
10
+ import { usePatientToShow } from "./usePatientToShow.js";
11
+ import { useSavePatientAndSendEvent } from "../../../analytics/cardLifecycle.js";
12
+ /** A stable key per live object: a different patient object gets a fresh form. */
13
+ const objectKeys = new WeakMap();
14
+ let nextKey = 0;
15
+ const keyOf = (obj) => {
16
+ if (!objectKeys.has(obj))
17
+ objectKeys.set(obj, ++nextKey);
18
+ return objectKeys.get(obj);
19
+ };
20
+ /** What PatientCard renders, in the order its body checks for each. */
21
+ export var PatientCardState;
22
+ (function (PatientCardState) {
23
+ /** The patient couldn't be opened for a reason other than not found: an error alert. */
24
+ PatientCardState["FAILED_TO_OPEN"] = "failedToOpen";
25
+ /** No live patient yet, or no snapshot of it: the "Loading…" card. */
26
+ PatientCardState["LOADING"] = "loading";
27
+ /** The patient has a record: PatientSummary. */
28
+ PatientCardState["SUMMARY"] = "summary";
29
+ /** The patient has no record yet: PatientSearch, to match any existing records. */
30
+ PatientCardState["SEARCH"] = "search";
31
+ /** The patient has no record yet, and user is adding the patient to Photon: PatientIntakeForm. */
32
+ PatientCardState["INTAKE_FORM"] = "intakeForm";
33
+ })(PatientCardState || (PatientCardState = {}));
34
+ /** Which state PatientCard is in, from what usePatientToShow and useLive give it. */
35
+ const getPatientCardState = ({ failedToOpen, patient, snap, adding, }) => {
36
+ if (failedToOpen)
37
+ return PatientCardState.FAILED_TO_OPEN;
38
+ if (!patient || !snap)
39
+ return PatientCardState.LOADING;
40
+ if (snap.state)
41
+ return PatientCardState.SUMMARY;
42
+ return adding ? PatientCardState.INTAKE_FORM : PatientCardState.SEARCH;
43
+ };
44
+ /**
45
+ * Whether a patient without a record starts on PatientIntakeForm rather than PatientSearch: when it already has
46
+ * a name or date of birth (e.g. a host's details the server hasn't matched), there's nothing left to search for.
47
+ */
48
+ const startsAdding = (patient) => {
49
+ const demographic = patient.known.demographic;
50
+ return Boolean(demographic?.name?.first || demographic?.name?.last || demographic?.dateOfBirth);
51
+ };
52
+ /**
53
+ * PhotonPatient, and what only PhotonOrder gives it: read-only and no "Change patient" (a sent order), no "Change
54
+ * patient" (an order handed off to it), and the server's request for a way to reach the patient (its reason),
55
+ * which opens the contact fields. Internal: the package index exports only PhotonPatient.
56
+ */
57
+ export function PatientCard({ patient: patientProp, onPatient, readOnly, hideChangePatient, addressRequest, notFound: notFoundInOrder, }) {
58
+ const { Alert, Card, CardHeader } = useComponents();
59
+ const { patient, notFound, failedToOpen, startOver } = usePatientToShow(patientProp, { readOnly });
60
+ const snap = useLive(patient);
61
+ useOnChange(patient, (p) => p.state, onPatient);
62
+ const savePatientAndSendEvent = useSavePatientAndSendEvent();
63
+ // Finding someone and adding them are two different jobs, so the card does one at a time. Decided once per patient
64
+ // object: "Add new patient" switches to adding, with what was typed; a different patient object starts over.
65
+ const [intake, setIntake] = useState(null);
66
+ const intakeForPatient = intake?.patient === patient ? intake : null;
67
+ if (patient && !intakeForPatient)
68
+ setIntake({ patient, adding: startsAdding(patient), query: null });
69
+ const adding = intakeForPatient?.adding ?? (patient ? startsAdding(patient) : false);
70
+ const state = getPatientCardState({ failedToOpen, patient, snap, adding });
71
+ if (state === PatientCardState.FAILED_TO_OPEN)
72
+ return _jsx(Alert, { tone: "critical", title: openFailed("patient", failedToOpen), description: failedToOpen.message });
73
+ if (state === PatientCardState.LOADING) {
74
+ return (_jsx(Card, { divided: true, children: _jsx(CardHeader, { title: "Patient", description: "Loading\u2026" }) }));
75
+ }
76
+ // Past LOADING, getPatientCardState guarantees both are set.
77
+ const livePatient = patient;
78
+ const snapshot = snap;
79
+ const changes = classify(snapshot.changes);
80
+ const update = (input) => void savePatientAndSendEvent(livePatient, () => livePatient.update(input)).catch(() => { }); // failures land on the object
81
+ const patchClinical = (clinical) => update({ clinical });
82
+ const choose = (option) => void savePatientAndSendEvent(livePatient, () => livePatient.choose(option)).catch(() => { });
83
+ if (state === PatientCardState.SUMMARY) {
84
+ const record = snapshot.state;
85
+ return (_jsx(PatientSummary, { patient: record, saving: snapshot.status === "saving", changes: changes, error: snapshot.error, 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: (diagnosis) => patchClinical({ diagnoses: { add: [diagnosis] } }), 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" }] } }), onSaveDetails: (input) => savePatientAndSendEvent(livePatient, () => livePatient.update(input)).then(() => true, () => false), addressRequest: readOnly ? null : (addressRequest ?? null), readOnly: readOnly, onChangePatient: readOnly || hideChangePatient
86
+ ? undefined
87
+ : () => {
88
+ onPatient?.(null); // given a patient, the host decides what's next
89
+ startOver();
90
+ } }, record.id));
91
+ }
92
+ // SEARCH or INTAKE_FORM. An id that was not found: said with the search, or on the form, for someone else.
93
+ const notFoundError = notFoundInOrder ?? notFound;
94
+ const notice = notFoundError && { title: openFailed("patient", notFoundError), description: notFoundError.message };
95
+ // A different patient object (e.g. after "Change patient") starts a fresh search or form.
96
+ if (state === PatientCardState.SEARCH) {
97
+ return (_jsx(PatientSearch, { patient: livePatient, notice: notice, onAddNew: (query) => setIntake({ patient: livePatient, adding: true, query }) }, keyOf(livePatient)));
98
+ }
99
+ return (_jsx(PatientIntakeForm, { patient: livePatient, query: intakeForPatient?.query, notice: notice }, keyOf(livePatient)));
100
+ }
101
+ //# sourceMappingURL=PatientCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientCard.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientCard/PatientCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAsD,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OA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CAAC,GAAG,EAAE;oBACH,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,gDAAgD;oBACnE,SAAS,EAAE,CAAC;gBACd,CAAC,IA9BF,MAAM,CAAC,EAAE,CAgCd,CACH,CAAC;IACJ,CAAC;IAED,2GAA2G;IAC3G,MAAM,aAAa,GAAG,eAAe,IAAI,QAAQ,CAAC;IAClD,MAAM,MAAM,GAAG,aAAa,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;IACpH,0FAA0F;IAC1F,IAAI,KAAK,KAAK,gBAAgB,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,CACL,KAAC,aAAa,IAEZ,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,IAHxE,KAAK,CAAC,WAAW,CAAC,CAIvB,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,iBAAiB,IAA0B,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,IAAxF,KAAK,CAAC,WAAW,CAAC,CAA0E,CACrH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Patient } from "@photonhealth/client";
2
+ import { NotFound } from "../../open.ts";
3
+ import type { PhotonPatientProps } from "../../PhotonPatient.tsx";
4
+ /**
5
+ * Which live Patient a patient card shows, from its `patient` prop:
6
+ * - the host's live `Patient`, if it passed one;
7
+ * - otherwise a blank patient the card made to find or add someone, if it has one for this prop — made when the
8
+ * prop has nothing to open, when its id isn't found, or on "Change patient" (`startOver`);
9
+ * - otherwise the one opened from the prop's id or fields (`null` while it opens).
10
+ *
11
+ * A blank patient belongs to the prop value it was made for, so when the host passes something else the card
12
+ * shows that instead, and passing nothing again gives a fresh blank patient.
13
+ */
14
+ export declare function usePatientToShow(patientProp: PhotonPatientProps["patient"], { readOnly }?: {
15
+ readOnly?: boolean | undefined;
16
+ }): {
17
+ patient: Patient | null;
18
+ notFound: NotFound | null;
19
+ failedToOpen: Error | null;
20
+ startOver: () => void;
21
+ };
22
+ //# sourceMappingURL=usePatientToShow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePatientToShow.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientCard/usePatientToShow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyC,MAAM,sBAAsB,CAAC;AAGtF,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKlE;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,EAAE,QAAgB,EAAE;;CAAK;;;;;EAwBrG"}
@@ -0,0 +1,40 @@
1
+ import { Patient } from "@photonhealth/client";
2
+ import { useState } from "react";
3
+ import { usePhoton } from "../../../primitives/index.js";
4
+ import { NotFound, toOpen, useOpened } from "../../open.js";
5
+ // At module level, not inline: useOpened re-runs its server call when this function changes.
6
+ const patientOf = (result) => result.patient;
7
+ /**
8
+ * Which live Patient a patient card shows, from its `patient` prop:
9
+ * - the host's live `Patient`, if it passed one;
10
+ * - otherwise a blank patient the card made to find or add someone, if it has one for this prop — made when the
11
+ * prop has nothing to open, when its id isn't found, or on "Change patient" (`startOver`);
12
+ * - otherwise the one opened from the prop's id or fields (`null` while it opens).
13
+ *
14
+ * A blank patient belongs to the prop value it was made for, so when the host passes something else the card
15
+ * shows that instead, and passing nothing again gives a fresh blank patient.
16
+ */
17
+ export function usePatientToShow(patientProp, { readOnly = false } = {}) {
18
+ const ph = usePhoton();
19
+ const hostPatient = patientProp instanceof Patient ? patientProp : null;
20
+ const patientToOpen = toOpen(patientProp, Boolean(hostPatient));
21
+ // Hooks run on every render, before any return (React's rule). With a host patient there's nothing to open.
22
+ const { opened: openedPatient, error: openError } = useOpened(ph.patient, patientToOpen, patientOf, "patient");
23
+ const [blank, setBlank] = useState(null);
24
+ // The host's live Patient: shown as is. "Change patient" is the host's to handle (the card calls onPatient(null)).
25
+ if (hostPatient)
26
+ return { patient: hostPatient, notFound: null, failedToOpen: null, startOver: () => { } };
27
+ const propKey = JSON.stringify(patientToOpen);
28
+ const startOver = () => setBlank({ forProp: propKey, patient: ph.patient() });
29
+ const blankPatient = blank?.forProp === propKey ? blank.patient : null;
30
+ // An id the server doesn't have: the card asks for someone to find or add instead, saying why. A read-only card
31
+ // can't add anyone, so it shows the error instead.
32
+ const notFound = openError instanceof NotFound && !readOnly ? openError : null;
33
+ // Any other failure to open: the card shows it.
34
+ const failedToOpen = openError && !notFound ? openError : null;
35
+ // Nothing to open, or not found: a blank patient to find or add someone.
36
+ if (!blankPatient && (!patientToOpen || notFound))
37
+ startOver();
38
+ return { patient: blankPatient ?? openedPatient, notFound, failedToOpen, startOver };
39
+ }
40
+ //# sourceMappingURL=usePatientToShow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePatientToShow.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientCard/usePatientToShow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyC,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG5D,6FAA6F;AAC7F,MAAM,SAAS,GAAG,CAAC,MAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,UA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AAG,SAAS,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAE/D,yEAAyE;IACzE,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,aAAa,IAAI,QAAQ,CAAC;QAAE,SAAS,EAAE,CAAC;IAE/D,OAAO,EAAE,OAAO,EAAE,YAAY,IAAI,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AACvF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type Patient } from "@photonhealth/client";
2
+ export declare function PatientIntakeForm({ patient, query, notice, }: {
3
+ patient: Patient;
4
+ /**
5
+ * What was typed in PatientSearch before "Add new patient": split into the fields, so nothing is retyped and the
6
+ * prescriber can see, and correct, how it was read. Without one, the fields start from what the patient already
7
+ * has (e.g. a host's details the server hasn't matched yet).
8
+ */
9
+ query?: string | null;
10
+ /** Why someone else is being added (e.g. the patient given by id isn't there). */
11
+ notice?: {
12
+ title: string;
13
+ description: string;
14
+ } | null;
15
+ }): import("react").JSX.Element;
16
+ //# sourceMappingURL=PatientIntakeForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientIntakeForm.d.ts","sourceRoot":"","sources":["../../../src/components/patient/PatientIntakeForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAcxE,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,KAAK,EACL,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,kFAAkF;IAClF,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACxD,+BA+LA"}