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

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 (179) 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 +6 -6
  93. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -1
  94. package/dist/components/schemaErrors.d.ts +3 -2
  95. package/dist/components/schemaErrors.d.ts.map +1 -1
  96. package/dist/components/schemaErrors.js +2 -1
  97. package/dist/components/schemaErrors.js.map +1 -1
  98. package/dist/components/search.d.ts +1 -1
  99. package/dist/components/search.js +1 -1
  100. package/dist/index.d.ts +1 -1
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +1 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/meta/version.js +1 -1
  105. package/package.json +5 -2
  106. package/src/analytics/PhotonAnalyticsProvider.test.tsx +0 -1
  107. package/src/analytics/PhotonAnalyticsProvider.tsx +75 -20
  108. package/src/analytics/cardLifecycle.test.tsx +272 -0
  109. package/src/analytics/cardLifecycle.ts +44 -0
  110. package/src/analytics/fieldInteraction.test.tsx +11 -9
  111. package/src/analytics/lifecycleOutcomes.test.ts +78 -0
  112. package/src/analytics/lifecycleOutcomes.ts +29 -0
  113. package/src/analytics/tracker.test.ts +1 -1
  114. package/src/analytics/tracker.ts +13 -6
  115. package/src/analytics/usePhotonAnalytics.test.tsx +106 -0
  116. package/src/components/PhotonOrder.test.tsx +146 -8
  117. package/src/components/PhotonOrder.tsx +37 -26
  118. package/src/components/PhotonPatient.tsx +8 -163
  119. package/src/components/PhotonPrescription.test.tsx +22 -18
  120. package/src/components/PhotonPrescription.tsx +14 -14
  121. package/src/components/ScreeningAlerts.test.tsx +81 -0
  122. package/src/components/open.ts +13 -16
  123. package/src/components/order/DraftOrderPrompt.test.tsx +3 -6
  124. package/src/components/patient/PatientCard/PatientCard.test.tsx +255 -0
  125. package/src/components/patient/PatientCard/PatientCard.tsx +177 -0
  126. package/src/components/patient/PatientCard/usePatientToShow.ts +44 -0
  127. package/src/components/patient/PatientIntakeForm.test.tsx +262 -0
  128. package/src/components/patient/PatientIntakeForm.tsx +222 -0
  129. package/src/components/patient/PatientSearch.test.tsx +204 -0
  130. package/src/components/patient/PatientSearch.tsx +221 -0
  131. package/src/components/patient/PatientSummary/BenefitsInputForm.test.tsx +164 -0
  132. package/src/components/patient/{Benefits.tsx → PatientSummary/BenefitsInputForm.tsx} +4 -4
  133. package/src/components/patient/PatientSummary/ClinicalInputForm.test.tsx +247 -0
  134. package/src/components/patient/{Clinical.tsx → PatientSummary/ClinicalInputForm.tsx} +23 -23
  135. package/src/components/patient/PatientSummary/CollapsedSummary.test.tsx +90 -0
  136. package/src/components/patient/PatientSummary/CollapsedSummary.tsx +46 -0
  137. package/src/components/patient/PatientSummary/PatientDetailsForm.test.tsx +201 -0
  138. package/src/components/patient/PatientSummary/PatientDetailsForm.tsx +320 -0
  139. package/src/components/patient/PatientSummary/PatientDetailsSchema.test.ts +296 -0
  140. package/src/components/patient/PatientSummary/PatientDetailsSchema.ts +95 -0
  141. package/src/components/patient/PatientSummary/PatientSummary.test.tsx +194 -0
  142. package/src/components/patient/PatientSummary/PatientSummary.tsx +225 -0
  143. package/src/components/patient/PatientSummary/SummaryHeader.test.tsx +183 -0
  144. package/src/components/patient/PatientSummary/SummaryHeader.tsx +85 -0
  145. package/src/components/patient/fields.tsx +12 -138
  146. package/src/components/patient/parsePatientSearchQuery.test.ts +107 -0
  147. package/src/components/patient/{query.ts → parsePatientSearchQuery.ts} +4 -21
  148. package/src/components/prescription/PrescriptionCard.test.tsx +174 -12
  149. package/src/components/prescription/PrescriptionCard.tsx +28 -14
  150. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +2 -5
  151. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +3 -6
  152. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +34 -37
  153. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +14 -14
  154. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +2 -5
  155. package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +3 -7
  156. package/src/components/schemaErrors.ts +3 -2
  157. package/src/components/search.tsx +1 -1
  158. package/src/index.ts +1 -1
  159. package/src/meta/version.test.ts +1 -0
  160. package/src/meta/version.ts +1 -1
  161. package/dist/components/patient/Benefits.d.ts.map +0 -1
  162. package/dist/components/patient/Benefits.js.map +0 -1
  163. package/dist/components/patient/Clinical.d.ts.map +0 -1
  164. package/dist/components/patient/Clinical.js.map +0 -1
  165. package/dist/components/patient/IntakeForm.d.ts +0 -10
  166. package/dist/components/patient/IntakeForm.d.ts.map +0 -1
  167. package/dist/components/patient/IntakeForm.js +0 -333
  168. package/dist/components/patient/IntakeForm.js.map +0 -1
  169. package/dist/components/patient/Summary.d.ts +0 -48
  170. package/dist/components/patient/Summary.d.ts.map +0 -1
  171. package/dist/components/patient/Summary.js +0 -90
  172. package/dist/components/patient/Summary.js.map +0 -1
  173. package/dist/components/patient/query.d.ts +0 -37
  174. package/dist/components/patient/query.d.ts.map +0 -1
  175. package/dist/components/patient/query.js.map +0 -1
  176. package/src/components/patient/IntakeForm.test.tsx +0 -89
  177. package/src/components/patient/IntakeForm.tsx +0 -564
  178. package/src/components/patient/Summary.test.tsx +0 -106
  179. package/src/components/patient/Summary.tsx +0 -330
@@ -0,0 +1,114 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /** PhotonPatient before a record, adding them: the fields network-api needs, and what the server says about them. */
3
+ import { useComponents } from "../../primitives/index.js";
4
+ import { classify } from "@photonhealth/client";
5
+ import { useLive } from "../../hooks/index.js";
6
+ import { useEffect, useId, useRef, useState } from "react";
7
+ import { ChangeList } from "../ChangeList.js";
8
+ import { formatPhone, PHONE_PATTERN, toE164 } from "../format.js";
9
+ import { IDENTITY_KEYS, noAutofill, SEX_OPTIONS } from "./fields.js";
10
+ import { focusProps } from "../flow.js";
11
+ import { parsePatientSearchQuery } from "./parsePatientSearchQuery.js";
12
+ import { TrackedField, useFieldInteractions } from "../../analytics/fieldInteraction.js";
13
+ import { useSavePatientAndSendEvent } from "../../analytics/cardLifecycle.js";
14
+ export function PatientIntakeForm({ patient, query, notice, }) {
15
+ const { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Grid, Input, Select, Spinner, Stack } = useComponents();
16
+ const snap = useLive(patient);
17
+ const formId = useId();
18
+ const savePatientAndSendEvent = useSavePatientAndSendEvent();
19
+ const known = patient.known;
20
+ const typed = query != null ? parsePatientSearchQuery(query) : null;
21
+ const [first, setFirst] = useState((typed ? typed.name?.first : known.demographic?.name?.first) ?? "");
22
+ const [last, setLast] = useState((typed ? typed.name?.last : known.demographic?.name?.last) ?? "");
23
+ const [dob, setDob] = useState((typed ? typed.dateOfBirth : known.demographic?.dateOfBirth) ?? "");
24
+ const [sex, setSex] = useState(known.demographic?.sex ?? null);
25
+ const sexPicked = useFieldInteractions("new_patient_form")("sex", { isOptional: false, hasValue: Boolean(sex) });
26
+ const [email, setEmail] = useState(typed?.email ?? known.contact?.email ?? "");
27
+ const knownPhone = typed?.phone ?? known.contact?.phone;
28
+ const [phone, setPhone] = useState(knownPhone ? formatPhone(knownPhone) : "");
29
+ /** Which of the four network-api needs were empty when Save was last pressed. */
30
+ const [missing, setMissing] = useState([]);
31
+ /** What a required field says while Save is waiting on it. The server names all four at once; we don't. */
32
+ const gap = (field) => missing.includes(field) ? { invalid: true, errorMessage: "Needed to add a patient" } : {};
33
+ const busy = snap.status === "loading" || snap.status === "saving";
34
+ // What the server still needs to add the patient (name, DOB, sex) is what this form asks for next — not an
35
+ // error. Once the prescriber has filled all four, anything it still rejects about them is shown.
36
+ const identityFilled = Boolean(first.trim() && last.trim() && dob && sex);
37
+ const changes = classify({
38
+ ...snap.changes,
39
+ unapplied: snap.changes.unapplied.filter((c) => identityFilled || !IDENTITY_KEYS.includes(c.key)),
40
+ });
41
+ /** Everything known on the form. Phone / email ride along once they're valid; the browser shows why otherwise. */
42
+ const form = () => {
43
+ const validPhone = new RegExp(`^(?:${PHONE_PATTERN})$`).test(phone.trim());
44
+ const validEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
45
+ const demographic = {
46
+ name: { first, last },
47
+ dateOfBirth: dob,
48
+ ...(sex ? { sex } : {}),
49
+ };
50
+ const contact = {
51
+ ...(validPhone ? { phone: toE164(phone) } : {}),
52
+ ...(validEmail ? { email: email.trim() } : {}),
53
+ };
54
+ return { demographic, contact };
55
+ };
56
+ /** Send everything known: the server may find or add the patient. The object adds it to what it sent before. */
57
+ const send = () => void savePatientAndSendEvent(patient, () => patient.sync(form())).catch(() => { }); // failures land on the object
58
+ /** A field changed: keep it. Answering what Save asked for puts it right at once. */
59
+ const type = (field, set) => (e) => {
60
+ set(e.target.value);
61
+ if (field && e.target.value.trim())
62
+ setMissing((m) => m.filter((f) => f !== field));
63
+ };
64
+ const submit = (e) => {
65
+ e.preventDefault();
66
+ save();
67
+ };
68
+ /**
69
+ * Add them. network-api creates a patient only with a first name, a last name, a date of birth and a sex
70
+ * (`Sex` has UNKNOWN, so there is always an answer), and the schema says nothing about which of them a
71
+ * payload is short of — so the form checks before it sends, rather than Save failing with a rejection
72
+ * naming every field at once.
73
+ *
74
+ * The server still decides what this means: it may find the patient instead of adding them, or come back
75
+ * with people it might be. Only this press asks it.
76
+ */
77
+ const REQUIRED = [
78
+ ["first", Boolean(first.trim())],
79
+ ["last", Boolean(last.trim())],
80
+ ["dob", Boolean(dob)],
81
+ ["sex", Boolean(sex)],
82
+ ];
83
+ const save = () => {
84
+ const empty = REQUIRED.filter(([, filled]) => !filled).map(([field]) => field);
85
+ setMissing(empty);
86
+ if (empty.length)
87
+ return; // the fields say which; the cursor goes to the first of them (below)
88
+ send();
89
+ };
90
+ // Sex is the one thing a search never fills in, and the one network-api needs to create, so that's where focus
91
+ // goes: the form is filled in and the deliberate act is choosing it.
92
+ const sexField = useRef(null);
93
+ const fields = useRef(null);
94
+ // Save pressed with gaps: the cursor goes to the first field it is waiting on, so answering starts there.
95
+ useEffect(() => {
96
+ if (!missing.length)
97
+ return;
98
+ fields.current?.querySelector('[aria-invalid="true"], [data-invalid]')?.focus();
99
+ }, [missing]);
100
+ // Once the form is up, the cursor goes to Sex (the Select is a building block, so by where it lands).
101
+ const landed = useRef(false);
102
+ useEffect(() => {
103
+ if (landed.current || !sexField.current)
104
+ return;
105
+ landed.current = true;
106
+ sexField.current.querySelector("input, select, button")?.focus();
107
+ }, []);
108
+ return (_jsxs(Card, { divided: true, children: [_jsx(CardHeader, { title: "Patient" }), _jsx(CardBody, { children: _jsx("form", { ...noAutofill, ref: fields, id: formId, onSubmit: submit, children: _jsxs(Stack, { gap: "3", children: [_jsxs(Grid, { min: "200px", gap: "3", children: [_jsx("div", { ...focusProps, children: _jsx(TrackedField, { formName: "new_patient_form", fieldName: "firstName", isOptional: false, children: _jsx(Input, { ...gap("first"), label: "First name", value: first, onChange: type("first", setFirst), autoFocus: true, ...noAutofill }) }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "lastName", isOptional: false, children: _jsx(Input, { ...gap("last"), label: "Last name", value: last, onChange: type("last", setLast), ...noAutofill }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "dateOfBirth", isOptional: false, children: _jsx(Input, { ...gap("dob"), label: "Date of birth", type: "date", ...noAutofill, value: dob, onChange: type("dob", setDob) }) }), _jsx("div", { ref: sexField, onFocus: sexPicked.onFocus, onBlur: sexPicked.onBlur, children: _jsx(Select, { ...gap("sex"), label: "Sex", placeholder: "Select\u2026", options: SEX_OPTIONS, value: sex, onChange: (next) => {
109
+ sexPicked.onChange(true);
110
+ setSex(next);
111
+ setMissing((m) => m.filter((f) => f !== "sex"));
112
+ } }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "phone", isOptional: true, children: _jsx(Input, { label: "Phone", helper: "The patient is texted their order link here, so a mobile number.", type: "tel", inputMode: "tel", pattern: PHONE_PATTERN, value: phone, onChange: type(null, setPhone), onBlur: () => setPhone(formatPhone(phone)), ...noAutofill }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "email", isOptional: true, children: _jsx(Input, { label: "Email", type: "email", inputMode: "email", value: email, onChange: type(null, setEmail), ...noAutofill }) })] }), notice && _jsx(Alert, { tone: "critical", title: notice.title, description: notice.description }), _jsx(ChangeList, { changes: changes }), snap.error && _jsx(Badge, { tone: "critical", children: snap.error.message })] }) }) }), _jsx(CardFooter, { start: busy ? _jsx(Spinner, { label: "Adding\u2026" }) : undefined, children: _jsx(Button, { type: "submit", form: formId, loading: busy, children: "Save patient" }) })] }));
113
+ }
114
+ //# sourceMappingURL=PatientIntakeForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientIntakeForm.js","sourceRoot":"","sources":["../../../src/components/patient/PatientIntakeForm.tsx"],"names":[],"mappings":";AAAA,qHAAqH;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAA0B,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAc,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE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@photonhealth/client";
2
+ export declare function PatientSearch({ patient, notice, onAddNew, }: {
3
+ patient: Patient;
4
+ /** Why someone else is being found (e.g. the patient given by id isn't there): shown with the matches. */
5
+ notice?: {
6
+ title: string;
7
+ description: string;
8
+ } | null;
9
+ /** "Add new patient": none of these. Gets what was typed, to fill PatientIntakeForm from. */
10
+ onAddNew: (query: string) => void;
11
+ }): import("react").JSX.Element;
12
+ //# sourceMappingURL=PatientSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientSearch.d.ts","sourceRoot":"","sources":["../../../src/components/patient/PatientSearch.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AA6B9D,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,0GAA0G;IAC1G,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACvD,6FAA6F;IAC7F,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,+BAmLA"}
@@ -0,0 +1,148 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /** PhotonPatient before a record, finding them: one field that searches as it's typed in, and who they might be. */
3
+ import { useComponents } from "../../primitives/index.js";
4
+ import { classify } from "@photonhealth/client";
5
+ import { useLatestCallback, useLive } from "../../hooks/index.js";
6
+ import { useEffect, useRef, useState } from "react";
7
+ import { useHeldActivity } from "../activity.js";
8
+ import { ChangeList } from "../ChangeList.js";
9
+ import { formatDate } from "../format.js";
10
+ import { FEW, searchKeys, SearchResults, useTypeAhead } from "../search.js";
11
+ import { focusProps, searchProps } from "../flow.js";
12
+ import { IDENTITY_KEYS, noAutofill } from "./fields.js";
13
+ import { parsePatientSearchQuery } from "./parsePatientSearchQuery.js";
14
+ import { TrackedField } from "../../analytics/fieldInteraction.js";
15
+ /** query as patient input */
16
+ const toSearchInput = ({ phone, email, ...demographic }) => ({
17
+ demographic,
18
+ contact: { ...(phone ? { phone } : {}), ...(email ? { email } : {}) },
19
+ });
20
+ /** Whether a query says anything the server can match on. */
21
+ const isSearchable = (q) => Boolean(q.name?.first || q.name?.last || q.dateOfBirth || q.phone || q.email);
22
+ /**
23
+ * One word could be either name. It goes as a first name; if nothing comes back, it's worth asking again
24
+ * as a last name — "Lovelace" is as likely as "Ada".
25
+ */
26
+ const searchBoth = (q) => q.name?.first && !q.name.last && !q.dateOfBirth && !q.phone && !q.email ? { name: { last: q.name.first } } : null;
27
+ export function PatientSearch({ patient, notice, onAddNew, }) {
28
+ const { Alert, Badge, Card, CardBody, CardHeader, Input, Stack } = useComponents();
29
+ const snap = useLive(patient);
30
+ const [query, setQuery] = useState("");
31
+ /** What the matches below answer — the query as it was typed when the search went out. */
32
+ const [searched, setSearched] = useState(null);
33
+ /** The row the keys are on, by DOM id: the field says so with `aria-activedescendant`. */
34
+ const [activeId, setActiveId] = useState(null);
35
+ const busy = snap.status === "loading" || snap.status === "saving";
36
+ const candidates = snap.candidates;
37
+ // What the server says. While searching, nothing about the patient's name, date of birth or sex is missing yet:
38
+ // the search only lists who it might be.
39
+ const changes = classify({
40
+ ...snap.changes,
41
+ unapplied: snap.changes.unapplied.filter((c) => !IDENTITY_KEYS.includes(c.key)),
42
+ });
43
+ // The field shows a spinner while its search is out (held briefly, so it doesn't flicker).
44
+ const [searching, setSearching] = useState(false);
45
+ if (searching && !busy)
46
+ setSearching(false); // answered
47
+ const spinning = useHeldActivity(searching ? "query" : null) === "query";
48
+ /**
49
+ * The search, answered. Only ever `search`: it can't create, and it can't change whoever it finds. One word
50
+ * could be either name, so if it draws a blank as a first name it's asked again as a last name — "Lovelace"
51
+ * is as likely to be typed as "Ada".
52
+ */
53
+ const runSearch = useLatestCallback(() => {
54
+ const text = query.trim();
55
+ const parsed = parsePatientSearchQuery(text);
56
+ if (!isSearchable(parsed))
57
+ return;
58
+ setSearching(true);
59
+ void (async () => {
60
+ try {
61
+ await patient.search(toSearchInput(parsed));
62
+ const alsoLast = searchBoth(parsed);
63
+ if (alsoLast && patient.snapshot.candidates.length === 0)
64
+ await patient.search(toSearchInput(alsoLast));
65
+ }
66
+ catch {
67
+ // failures land on the object
68
+ }
69
+ setSearched(text);
70
+ })();
71
+ });
72
+ // Two characters: network-api matches "a first/last name prefix of 2+ characters" (`AmbiguousPatientMatch`),
73
+ // and short surnames are real — Ng, Wu, Li. Not one: that would match thousands, and the server returns at
74
+ // most twenty candidates, so it would hand back an arbitrary slice — a list without your patient in it reads
75
+ // as "not here", which is how a duplicate gets made.
76
+ const typeAhead = useTypeAhead(() => runSearch(), { minChars: 2 });
77
+ // A few matches listed: they're the next thing to look at.
78
+ const few = candidates.length > 0 && candidates.length < FEW;
79
+ const answered = () => !typeAhead.waiting() && !busy && searched === query.trim();
80
+ /** The search is answered, and nobody came back. Not the same as nobody being there. */
81
+ const answeredNothing = searched !== null && searched === query.trim() && candidates.length === 0 && !busy && !typeAhead.waiting();
82
+ const matches = useRef(null);
83
+ // The search field: Esc in the matches goes back to it.
84
+ const field = useRef(null);
85
+ // The field is a search field over the matches (searchKeys): ↑ ↓ move a highlight, Return takes it. Return
86
+ // with nothing to take searches now, rather than after the pause.
87
+ const onKeyDown = (e) => {
88
+ if (searchKeys(e, matches.current, answered()))
89
+ return;
90
+ if (e.key !== "Enter")
91
+ return;
92
+ e.preventDefault();
93
+ typeAhead.cancel();
94
+ runSearch();
95
+ };
96
+ // A few matches for what's being typed, and the prescriber is still in the field: focus goes to the first,
97
+ // ready to pick — typing carries on in the field (search.tsx). Once per answer.
98
+ const matchesFor = candidates.map((c) => c.id).join();
99
+ const focusedFor = useRef(null);
100
+ const focusFew = useLatestCallback(() => {
101
+ if (!few || !answered() || !field.current || document.activeElement !== field.current)
102
+ return;
103
+ if (focusedFor.current === matchesFor)
104
+ return;
105
+ focusedFor.current = matchesFor;
106
+ matches.current?.focus(true);
107
+ });
108
+ // Also on `searched`: the matches can land before the card has noted which query they answer, and until
109
+ // it has, they aren't an answer to move to.
110
+ useEffect(() => focusFew(), [matchesFor, busy, searched, focusFew]);
111
+ return (_jsxs(Card, { divided: true, children: [_jsx(CardHeader, { title: "Patient" }), _jsx(CardBody, { children: _jsxs(Stack, { gap: "3", children: [_jsx("div", { ...focusProps, ...searchProps, onFocus: (e) => {
112
+ if (e.target instanceof HTMLInputElement)
113
+ field.current = e.target;
114
+ }, children: _jsx(TrackedField, { formName: "find_patient", fieldName: "patientSearch", isOptional: false, children: _jsx(Input, { label: "Find patient", placeholder: "Name, date of birth, phone or email", value: query, onChange: (e) => {
115
+ setQuery(e.target.value);
116
+ typeAhead.typed("query", e.target.value);
117
+ // Too little left to search on: the matches on screen answer a query that isn't there any more,
118
+ // so they go, and the card is back where it started — including what it has already moved the
119
+ // cursor to, or typing the same name again would land nowhere.
120
+ if (typeAhead.tooShort(e.target.value)) {
121
+ setSearched(null);
122
+ focusedFor.current = null;
123
+ }
124
+ }, onBlur: () => {
125
+ // Leaving asks now rather than after the pause — a search, never a sync: it can't create anyone
126
+ // and it can't change whoever it finds.
127
+ typeAhead.cancel();
128
+ if (query.trim() !== searched)
129
+ runSearch();
130
+ }, onKeyDown: onKeyDown, loading: spinning, role: "combobox", "aria-expanded": searched !== null, "aria-autocomplete": "list", "aria-activedescendant": activeId ?? undefined, autoFocus: true, ...noAutofill }) }) }), answeredNothing && (_jsx(Alert, { title: "Spelling has to be exact.", description: "Try another spelling, fewer letters, or a date of birth." })), searched !== null && (_jsx(SearchResults, { label: candidates.length > 0 ? "Matching patients" : "No matching patients", results: candidates.map((m) => ({
131
+ key: m.id,
132
+ label: [m.firstName, m.lastName].filter(Boolean).join(" "),
133
+ meta: m.dateOfBirth ? formatDate(m.dateOfBirth) : undefined,
134
+ })), onPick: (id) => void patient.pick(id).catch(() => { }), busy: busy, handleRef: matches, onBack: () => field.current?.focus(),
135
+ // The cursor stays in the field: ↑ ↓ move a highlight, Return takes it, and a letter or a Backspace
136
+ // always lands in the field — the prescriber can narrow or start over mid-list.
137
+ inField: true, onActive: setActiveId,
138
+ // The last row: ↓ past the final match lands on it, and Return takes it.
139
+ action: {
140
+ label: "Add new patient",
141
+ icon: "add",
142
+ onChoose: () => {
143
+ typeAhead.cancel();
144
+ onAddNew(query);
145
+ },
146
+ } })), notice && _jsx(Alert, { tone: "critical", title: notice.title, description: notice.description }), _jsx(ChangeList, { changes: changes }), snap.error && _jsx(Badge, { tone: "critical", children: snap.error.message })] }) })] }));
147
+ }
148
+ //# sourceMappingURL=PatientSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientSearch.js","sourceRoot":"","sources":["../../../src/components/patient/PatientSearch.tsx"],"names":[],"mappings":";AAAA,oHAAoH;AACpH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAqB,MAAM,cAAe,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAc,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAiC,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM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AW,EAAE,MAAM,CAAC,WAAW,GAAI,EAC1F,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,GAAI,EAC/B,IAAI,CAAC,KAAK,IAAI,KAAC,KAAK,IAAC,IAAI,EAAC,UAAU,YAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAS,IAC5D,GACC,IACN,CACR,CAAC;AACJ,CAAC"}
@@ -6,7 +6,7 @@ export type BenefitInput = {
6
6
  memberId?: string;
7
7
  };
8
8
  /** Insurance on file: chips, "Add insurance" (BIN + member id required, PCN / group optional), "No insurance". */
9
- export declare function BenefitsSection({ benefits, saving, onAdd, onRemove, onNone, }: {
9
+ export declare function BenefitsInputForm({ benefits, saving, onAdd, onRemove, onNone, }: {
10
10
  /** null: not recorded; []: "no insurance" recorded. */
11
11
  benefits: {
12
12
  id: string;
@@ -22,4 +22,4 @@ export declare function BenefitsSection({ benefits, saving, onAdd, onRemove, onN
22
22
  }) => void;
23
23
  onNone: () => void;
24
24
  }): import("react").JSX.Element;
25
- //# sourceMappingURL=Benefits.d.ts.map
25
+ //# sourceMappingURL=BenefitsInputForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenefitsInputForm.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/BenefitsInputForm.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5G,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;IACD,uDAAuD;IACvD,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;IAC7G,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,CAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,+BA8GA"}
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /** The patient's insurance on file. */
3
3
  import { useState } from "react";
4
- import { useComponents } from "../../primitives/index.js";
5
- import { noAutofill } from "./fields.js";
6
- import { TrackedField } from "../../analytics/fieldInteraction.js";
4
+ import { useComponents } from "../../../primitives/index.js";
5
+ import { noAutofill } from "../fields.js";
6
+ import { TrackedField } from "../../../analytics/fieldInteraction.js";
7
7
  /** Insurance on file: chips, "Add insurance" (BIN + member id required, PCN / group optional), "No insurance". */
8
- export function BenefitsSection({ benefits, saving, onAdd, onRemove, onNone, }) {
8
+ export function BenefitsInputForm({ benefits, saving, onAdd, onRemove, onNone, }) {
9
9
  const { Badge, Button, Grid, Input, Row, Stack, Text } = useComponents();
10
10
  const [adding, setAdding] = useState(false);
11
11
  const [bin, setBin] = useState("");
@@ -45,4 +45,4 @@ export function BenefitsSection({ benefits, saving, onAdd, onRemove, onNone, })
45
45
  reset();
46
46
  }, children: _jsxs(Stack, { gap: "2", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "insurance", isOptional: true, children: _jsxs(Grid, { min: "72px", gap: "2", children: [_jsx(Input, { label: "BIN", value: bin, onChange: (e) => setBin(e.target.value), inputMode: "numeric", autoFocus: true, ...noAutofill }), _jsx(Input, { label: "PCN", value: pcn, onChange: (e) => setPcn(e.target.value), ...noAutofill }), _jsx(Input, { label: "Group", value: groupId, onChange: (e) => setGroupId(e.target.value), ...noAutofill }), _jsx(Input, { label: "Member ID", value: memberId, onChange: (e) => setMemberId(e.target.value), ...noAutofill })] }) }), _jsxs(Row, { justify: "end", gap: "2", children: [_jsx(Button, { variant: "ghost", onClick: reset, children: "Cancel" }), _jsx(Button, { type: "submit", variant: "secondary", loading: saving, disabled: !canSave, children: "Save insurance" })] })] }) }))] }));
47
47
  }
48
- //# sourceMappingURL=Benefits.js.map
48
+ //# sourceMappingURL=BenefitsInputForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenefitsInputForm.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/BenefitsInputForm.tsx"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAyC,CAAC;AAIvE,kHAAkH;AAClH,MAAM,UAAU,iBAAiB,CAAC,EAChC,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,GAQP;IACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CAAC;IACzE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAA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G,EAAC,MAAM,EAAC,GAAG,EAAC,GAAG,aACtB,KAAC,KAAK,IACJ,KAAK,EAAC,KAAK,EACX,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACvC,SAAS,EAAC,SAAS,EACnB,SAAS,WACL,UAAU,GACd,EACF,KAAC,KAAK,IAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAM,UAAU,GAAI,EAC1F,KAAC,KAAK,IAAC,KAAK,EAAC,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAM,UAAU,GAAI,EACpG,KAAC,KAAK,IACJ,KAAK,EAAC,WAAW,EACjB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KACxC,UAAU,GACd,IACG,GACM,EACf,MAAC,GAAG,IAAC,OAAO,EAAC,KAAK,EAAC,GAAG,EAAC,GAAG,aACxB,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,KAAK,uBAE7B,EACT,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,WAAW,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,+BAEpE,IACL,IACA,GACH,CACR,IACK,CACT,CAAC;AACJ,CAAC"}
@@ -6,14 +6,13 @@ export declare const sectionOf: (key: string) => "allergies" | "medications" | "
6
6
  export declare const choicesIn: (choices: ClassifiedChanges["needsChoice"], section: (typeof CLINICAL_SECTIONS)[number]) => import("@photonhealth/client").Change[];
7
7
  /** Everything but what a clinical list shows under its own field — its choices and its problems (e.g. a rejected name). */
8
8
  export declare const withoutInline: (changes: ClassifiedChanges) => ClassifiedChanges;
9
- /** An ICD-10 code ("J02.0") goes as a code; anything else as free text for the server to resolve. */
10
- export declare const diagnosisRef: (text: string) => {
9
+ export type DiagnosisInput = {
11
10
  icd10Code: string;
12
- name?: undefined;
13
11
  } | {
14
12
  name: string;
15
- icd10Code?: undefined;
16
13
  };
14
+ /** An ICD-10 code ("J02.0") goes as a code; anything else as free text for the server to resolve. */
15
+ export declare const diagnosisRef: (text: string) => DiagnosisInput;
17
16
  /**
18
17
  * A clinical list (allergies, medications, diagnoses): chips for what's on file, plus "Add …" and "No …"
19
18
  * (records none — `confirmedNone` is the record's `[]`; network-api can't read it back yet).
@@ -23,29 +22,28 @@ export declare const diagnosisRef: (text: string) => {
23
22
  * entry — added then, as is a single row or the one match the server is sure of (core takes it). The field closes as soon as an entry lands, or once what's committed (Enter,
24
23
  * leaving it, a choice) is answered. Escape closes it.
25
24
  */
26
- export declare function ClinicalList<T extends {
25
+ export declare function ClinicalInputForm<T extends {
27
26
  id: string;
28
27
  name: string;
29
- }>({ label, fieldName, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, pickedNames, saving, onAdd, onRemove, onNone, choices, problems, onChoose, }: {
28
+ }>({ label, fieldName, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, saving, onAdd, onRemove, onNone, choices, problems, onChoose, }: {
30
29
  label: string;
31
30
  fieldName: "allergies" | "medications" | "diagnoses";
32
31
  items: T[];
33
32
  tone: "warning" | "neutral";
34
33
  addLabel: string;
35
- /** Offer "none" (e.g. No known allergies). Omit for lists where "none" isn't worth recording. */
36
- noneLabel?: string;
34
+ /** Shown once "none" is recorded (e.g. No known allergies). */
35
+ noneLabel: string;
37
36
  /** The button that records "none" (e.g. "Mark NKDA") — an action, so it can't be read as a status. */
38
- noneAction?: string;
37
+ noneAction: string;
39
38
  /** "None" was recorded this session. */
40
- confirmedNone?: boolean;
41
- /** Shown when the server returns no real name (today allergies come back with name = id). */
39
+ confirmedNone: boolean;
40
+ /** Shown for an entry the server returns without a name. */
42
41
  unknownLabel: string;
43
- /** Names the prescriber picked this session, by id — shown when the server returns only the id. */
44
- pickedNames: Readonly<Record<string, string>>;
45
42
  saving: boolean;
46
43
  onAdd: (name: string) => void;
47
44
  onRemove: (item: T) => void;
48
- onNone?: () => void;
45
+ /** Records "none" for this list. */
46
+ onNone: () => void;
49
47
  /** The server's choices for what was just entered (e.g. which penicillin) — shown right under the field. */
50
48
  choices: ClassifiedChanges["needsChoice"];
51
49
  /** What the server rejected for this list (e.g. a name nothing matches) — shown in the same place. */
@@ -53,4 +51,4 @@ export declare function ClinicalList<T extends {
53
51
  onChoose: (option: ChangeOption) => void;
54
52
  }): import("react").JSX.Element;
55
53
  export {};
56
- //# sourceMappingURL=Clinical.d.ts.map
54
+ //# sourceMappingURL=ClinicalInputForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClinicalInputForm.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/ClinicalInputForm.tsx"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AASjF,kHAAkH;AAClH,QAAA,MAAM,iBAAiB,oDAAqD,CAAC;AAC7E,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,qDAAuE,CAAC;AAC7G,eAAO,MAAM,SAAS,GAAI,SAAS,iBAAiB,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,OAAO,iBAAiB,EAAE,MAAM,CAAC,4CAC3D,CAAC;AACtD,2HAA2H;AAC3H,eAAO,MAAM,aAAa,GAAI,SAAS,iBAAiB,KAAG,iBAIzD,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CA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AAC;CAC1C,+BAwIA"}
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /** The patient's clinical lists — allergies, medications, diagnoses — and which server changes belong to them. */
3
3
  import {} from "@photonhealth/client";
4
4
  import { useRef, useState } from "react";
5
- import { useComponents } from "../../primitives/index.js";
6
- import { useHeldActivity } from "../activity.js";
7
- import { ChangeList } from "../ChangeList.js";
8
- import { afterPress, searchKeys, useTypeAhead } from "../search.js";
9
- import { noAutofill } from "./fields.js";
10
- import { TrackedField } from "../../analytics/fieldInteraction.js";
5
+ import { useComponents } from "../../../primitives/index.js";
6
+ import { useHeldActivity } from "../../activity.js";
7
+ import { ChangeList } from "../../ChangeList.js";
8
+ import { afterPress, searchKeys, useTypeAhead } from "../../search.js";
9
+ import { noAutofill } from "../fields.js";
10
+ import { TrackedField } from "../../../analytics/fieldInteraction.js";
11
11
  /** Which clinical list a server change belongs to (keys look like "clinical.allergies.add.0" / "allergies.0"). */
12
12
  const CLINICAL_SECTIONS = ["allergies", "medications", "diagnoses"];
13
13
  export const sectionOf = (key) => CLINICAL_SECTIONS.find((section) => key.includes(section)) ?? null;
@@ -29,7 +29,7 @@ export const diagnosisRef = (text) => /^[A-TV-Z]\d{2}(\.[0-9A-Z]{1,4})?$/i.test(
29
29
  * entry — added then, as is a single row or the one match the server is sure of (core takes it). The field closes as soon as an entry lands, or once what's committed (Enter,
30
30
  * leaving it, a choice) is answered. Escape closes it.
31
31
  */
32
- export function ClinicalList({ label, fieldName, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, pickedNames, saving, onAdd, onRemove, onNone, choices, problems = [], onChoose, }) {
32
+ export function ClinicalInputForm({ label, fieldName, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, saving, onAdd, onRemove, onNone, choices, problems = [], onChoose, }) {
33
33
  const { Badge, Button, Input, Row, Stack, Text } = useComponents();
34
34
  const [adding, setAdding] = useState(false);
35
35
  const [value, setValue] = useState("");
@@ -60,7 +60,7 @@ export function ClinicalList({ label, fieldName, items, tone, addLabel, noneLabe
60
60
  const spinning = useHeldActivity(adding && before !== null && saving ? "add" : null) === "add";
61
61
  const results = useRef(null);
62
62
  const field = useRef(null);
63
- const none = Boolean(confirmedNone) && items.length === 0;
63
+ const none = confirmedNone && items.length === 0;
64
64
  /** Add what's typed — unless it was just sent. */
65
65
  const send = (name) => {
66
66
  if (name === sent)
@@ -94,9 +94,9 @@ export function ClinicalList({ label, fieldName, items, tone, addLabel, noneLabe
94
94
  onChoose(option);
95
95
  };
96
96
  return (_jsxs(Stack, { gap: "2", children: [_jsxs(Row, { gap: "2", justify: "between", children: [_jsxs(Row, { gap: "2", children: [_jsx("strong", { children: label }), !adding && (_jsx(Button, { variant: "ghost", "aria-label": addLabel, title: addLabel, onClick: () => setAdding(true), icon: "add" })), items.map((item) => {
97
- const name = item.name && item.name !== item.id ? item.name : (pickedNames[item.id] ?? unknownLabel);
97
+ const name = item.name || unknownLabel;
98
98
  return (_jsx(Badge, { tone: tone, onRemove: () => onRemove(item), removeLabel: `Remove ${name}`, children: name }, item.id));
99
- }), none && noneLabel && _jsx(Badge, { tone: "success", children: noneLabel }), noneLabel && !none && items.length === 0 && !adding && _jsx(Text, { tone: "tertiary", children: "Not recorded" })] }), noneLabel && onNone && !adding && items.length === 0 && !none && (_jsx(Button, { variant: "ghost", onClick: onNone, "aria-label": noneAction === "Mark none" ? `Mark no ${label.toLowerCase()}` : undefined, children: noneAction ?? noneLabel }))] }), (adding || choices.length > 0 || problems.length > 0) && (_jsx("div", { ref: field, children: _jsxs(Stack, { gap: "2", children: [adding && (_jsx(TrackedField, { formName: "update_patient_form", fieldName: fieldName, isOptional: true, children: _jsx(Input, { label: addLabel, value: value, autoFocus: true, loading: spinning, ...noAutofill, onChange: (e) => {
99
+ }), none && _jsx(Badge, { tone: "success", children: noneLabel }), !none && items.length === 0 && !adding && _jsx(Text, { tone: "tertiary", children: "Not recorded" })] }), !adding && items.length === 0 && !none && (_jsx(Button, { variant: "ghost", onClick: onNone, "aria-label": noneAction === "Mark none" ? `Mark no ${label.toLowerCase()}` : undefined, children: noneAction }))] }), (adding || choices.length > 0 || problems.length > 0) && (_jsx("div", { ref: field, children: _jsxs(Stack, { gap: "2", children: [adding && (_jsx(TrackedField, { formName: "update_patient_form", fieldName: fieldName, isOptional: true, children: _jsx(Input, { label: addLabel, value: value, autoFocus: true, loading: spinning, ...noAutofill, onChange: (e) => {
100
100
  setValue(e.target.value);
101
101
  typeAhead.typed("add", e.target.value);
102
102
  }, onBlur: (e) => {
@@ -115,4 +115,4 @@ export function ClinicalList({ label, fieldName, items, tone, addLabel, noneLabe
115
115
  close();
116
116
  } }) })), (choices.length > 0 || problems.length > 0) && (_jsx(ChangeList, { changes: { needsChoice: choices, blocking: problems, advisories: [], applied: [], settled: false }, onChoose: choose, busy: saving, handleRef: results, onBack: () => field.current?.querySelector("input")?.focus() }))] }) }))] }));
117
117
  }
118
- //# sourceMappingURL=Clinical.js.map
118
+ //# sourceMappingURL=ClinicalInputForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClinicalInputForm.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/ClinicalInputForm.tsx"],"names":[],"mappings":";AAAA,kHAAkH;AAClH,OAAO,EAA6C,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAqB,MAAM,iBAAkB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,cAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAyC,CAAC;AAEvE,kHAA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E,EAAE;wCAAE,OAAO;oCACtF,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,0EAA0E;gCAC7F,CAAC,EACD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;oCACf,IAAI,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC;wCAAE,OAAO;oCAC7E,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;wCACtB,CAAC,CAAC,cAAc,EAAE,CAAC;wCACnB,GAAG,EAAE,CAAC;oCACR,CAAC;oCACD,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ;wCAAE,KAAK,EAAE,CAAC;gCAClC,CAAC,GACD,GACW,CAChB,EACA,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAC9C,KAAC,UAAU,IACT,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAClG,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,GAC5D,CACH,IACK,GACJ,CACP,IACK,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type PatientRecord } from "@photonhealth/client";
2
+ export declare function CollapsedSummary({ patient }: {
3
+ patient: PatientRecord;
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=CollapsedSummary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollapsedSummary.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/CollapsedSummary.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,+BAwCvE"}
@@ -0,0 +1,30 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /** PatientSummary's collapsed summary: the patient's allergies, active meds, diagnoses and insurance, in one line. */
3
+ import { useComponents } from "../../../primitives/index.js";
4
+ import {} from "@photonhealth/client";
5
+ import { Fragment } from "react";
6
+ export function CollapsedSummary({ patient }) {
7
+ const { Badge, Text } = useComponents();
8
+ // Each list: null when nothing is recorded, [] when "none" is (core's PatientRecord).
9
+ const recorded = {
10
+ allergies: patient.clinical?.allergies ?? null,
11
+ medications: patient.clinical?.medications ?? null,
12
+ diagnoses: patient.clinical?.diagnoses ?? null,
13
+ benefits: patient.benefits,
14
+ };
15
+ const allergies = recorded.allergies ?? [];
16
+ const meds = (recorded.medications ?? []).filter((m) => m.status === "ACTIVE");
17
+ const diagnoses = (recorded.diagnoses ?? []).map((x) => ({ ...x, name: x.name ?? x.icd10Code ?? "" }));
18
+ const benefits = recorded.benefits ?? [];
19
+ const named = (items, unknown) => items.map((x) => x.name || unknown).join(", ");
20
+ const facts = [
21
+ allergies.length ? (_jsxs(Badge, { tone: "warning", children: [allergies.length === 1 ? "Allergy" : "Allergies", ": ", named(allergies, "Unknown allergy")] })) : recorded.allergies?.length === 0 ? ("No known allergies") : ("Allergies not recorded"),
22
+ meds.length ? `Active meds: ${named(meds, "Unknown medication")}` : recorded.medications && "No active meds",
23
+ diagnoses.length ? `Diagnoses: ${named(diagnoses, "Unknown diagnosis")}` : recorded.diagnoses && "No diagnoses",
24
+ benefits.length
25
+ ? `Insurance: ${benefits.map((b) => `BIN ${b.bin}`).join(", ")}`
26
+ : recorded.benefits && "No insurance",
27
+ ].filter(Boolean);
28
+ return (_jsx(Text, { tone: "secondary", children: facts.map((fact, i) => (_jsxs(Fragment, { children: [i > 0 && " · ", _jsx("span", { children: fact })] }, i))) }));
29
+ }
30
+ //# sourceMappingURL=CollapsedSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollapsedSummary.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/CollapsedSummary.tsx"],"names":[],"mappings":";AAAA,sHAAsH;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAsB,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,UAAU,gBAAgB,CAAC,EAAE,OAAO,EAA8B;IACtE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CAAC;IACxC,sFAAsF;IACtF,MAAM,QAAQ,GAAG;QACf,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,IAAI,IAAI;QAC9C,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,IAAI,IAAI;QAClD,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,IAAI,IAAI;QAC9C,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,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CACL,KAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YACnB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,MAAC,QAAQ,eACN,CAAC,GAAG,CAAC,IAAI,KAAK,EACf,yBAAO,IAAI,GAAQ,KAFN,CAAC,CAGL,CACZ,CAAC,GACG,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type PatientInput, type PatientRecord } from "@photonhealth/client";
2
+ /** The part of an UpdatePatient that PatientDetailsForm sends. */
3
+ export type PatientDetailsInput = Pick<PatientInput, "demographic" | "contact">;
4
+ export declare function PatientDetailsForm({ patient, addressRequest, onSave, }: {
5
+ patient: PatientRecord;
6
+ addressRequest: string | null;
7
+ /** Called by Save once every field is valid, with every field to send. */
8
+ onSave: (input: PatientDetailsInput) => void | Promise<void>;
9
+ }): import("react").JSX.Element;
10
+ //# sourceMappingURL=PatientDetailsForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatientDetailsForm.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/PatientDetailsForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQ7E,kEAAkE;AAClE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC;AAEhF,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,cAAc,EACd,MAAM,GACP,EAAE;IACD,OAAO,EAAE,aAAa,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0EAA0E;IAC1E,MAAM,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,+BAuQA"}