@photonhealth/react 2.0.0-rc.1 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -8
- package/dist/adapters/tailwind.d.ts.map +1 -1
- package/dist/adapters/tailwind.js +7 -4
- package/dist/adapters/tailwind.js.map +1 -1
- package/dist/analytics/PhotonAnalyticsProvider.d.ts +16 -0
- package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -0
- package/dist/analytics/PhotonAnalyticsProvider.js +57 -0
- package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -0
- package/dist/analytics/fieldInteraction.d.ts +18 -0
- package/dist/analytics/fieldInteraction.d.ts.map +1 -0
- package/dist/analytics/fieldInteraction.js +102 -0
- package/dist/analytics/fieldInteraction.js.map +1 -0
- package/dist/analytics/tracker.d.ts +17 -0
- package/dist/analytics/tracker.d.ts.map +1 -0
- package/dist/analytics/tracker.js +36 -0
- package/dist/analytics/tracker.js.map +1 -0
- package/dist/analytics/viewed.d.ts +11 -0
- package/dist/analytics/viewed.d.ts.map +1 -0
- package/dist/analytics/viewed.js +16 -0
- package/dist/analytics/viewed.js.map +1 -0
- package/dist/components/PhotonOrder.d.ts.map +1 -1
- package/dist/components/PhotonOrder.js +20 -16
- package/dist/components/PhotonOrder.js.map +1 -1
- package/dist/components/PhotonPatient.d.ts.map +1 -1
- package/dist/components/PhotonPatient.js +4 -2
- package/dist/components/PhotonPatient.js.map +1 -1
- package/dist/components/PhotonPrescription.d.ts +1 -12
- package/dist/components/PhotonPrescription.d.ts.map +1 -1
- package/dist/components/PhotonPrescription.js +7 -360
- package/dist/components/PhotonPrescription.js.map +1 -1
- package/dist/components/format.d.ts +2 -2
- package/dist/components/format.js +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/order/DraftOrderPrompt.d.ts +18 -0
- package/dist/components/order/DraftOrderPrompt.d.ts.map +1 -0
- package/dist/components/order/DraftOrderPrompt.js +26 -0
- package/dist/components/order/DraftOrderPrompt.js.map +1 -0
- package/dist/components/patient/Benefits.d.ts.map +1 -1
- package/dist/components/patient/Benefits.js +2 -1
- package/dist/components/patient/Benefits.js.map +1 -1
- package/dist/components/patient/Clinical.d.ts +3 -2
- package/dist/components/patient/Clinical.d.ts.map +1 -1
- package/dist/components/patient/Clinical.js +21 -20
- package/dist/components/patient/Clinical.js.map +1 -1
- package/dist/components/patient/IntakeForm.d.ts.map +1 -1
- package/dist/components/patient/IntakeForm.js +52 -43
- package/dist/components/patient/IntakeForm.js.map +1 -1
- package/dist/components/patient/Summary.d.ts +1 -1
- package/dist/components/patient/Summary.d.ts.map +1 -1
- package/dist/components/patient/Summary.js +13 -3
- package/dist/components/patient/Summary.js.map +1 -1
- package/dist/components/patient/fields.d.ts +1 -2
- package/dist/components/patient/fields.d.ts.map +1 -1
- package/dist/components/patient/fields.js +2 -1
- package/dist/components/patient/fields.js.map +1 -1
- package/dist/components/patient/query.d.ts +14 -0
- package/dist/components/patient/query.d.ts.map +1 -1
- package/dist/components/patient/query.js +5 -0
- package/dist/components/patient/query.js.map +1 -1
- package/dist/components/prescription/PrescriptionCard.d.ts +45 -0
- package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -0
- package/dist/components/prescription/PrescriptionCard.js +179 -0
- package/dist/components/prescription/PrescriptionCard.js.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.d.ts +15 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.d.ts.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.js +18 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.js.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.d.ts +23 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.d.ts.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.js +42 -0
- package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.js.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +27 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +169 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts +8 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js +12 -0
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.d.ts +11 -0
- package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.d.ts.map +1 -0
- package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.js +25 -0
- package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.js.map +1 -0
- package/dist/components/prescription/TreatmentSearch/TreatmentPicker.d.ts +50 -0
- package/dist/components/prescription/TreatmentSearch/TreatmentPicker.d.ts.map +1 -0
- package/dist/components/{TreatmentPicker.js → prescription/TreatmentSearch/TreatmentPicker.js} +113 -105
- package/dist/components/prescription/TreatmentSearch/TreatmentPicker.js.map +1 -0
- package/dist/components/prescription/TreatmentSearch/TreatmentSearch.d.ts +28 -0
- package/dist/components/prescription/TreatmentSearch/TreatmentSearch.d.ts.map +1 -0
- package/dist/components/prescription/TreatmentSearch/TreatmentSearch.js +146 -0
- package/dist/components/prescription/TreatmentSearch/TreatmentSearch.js.map +1 -0
- package/dist/components/schemaErrors.d.ts +12 -0
- package/dist/components/schemaErrors.d.ts.map +1 -0
- package/dist/components/schemaErrors.js +24 -0
- package/dist/components/schemaErrors.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/meta/version.d.ts +5 -0
- package/dist/meta/version.d.ts.map +1 -0
- package/dist/meta/version.js +5 -0
- package/dist/meta/version.js.map +1 -0
- package/dist/primitives/PhotonProvider.d.ts +3 -1
- package/dist/primitives/PhotonProvider.d.ts.map +1 -1
- package/dist/primitives/PhotonProvider.js +23 -11
- package/dist/primitives/PhotonProvider.js.map +1 -1
- package/dist/primitives/defaults.d.ts.map +1 -1
- package/dist/primitives/defaults.js +6 -3
- package/dist/primitives/defaults.js.map +1 -1
- package/dist/primitives/photonContext.d.ts +3 -0
- package/dist/primitives/photonContext.d.ts.map +1 -0
- package/dist/primitives/photonContext.js +3 -0
- package/dist/primitives/photonContext.js.map +1 -0
- package/dist/primitives/types.d.ts +15 -3
- package/dist/primitives/types.d.ts.map +1 -1
- package/dist/primitives/types.js.map +1 -1
- package/dist/primitives/useProvidedPhoton.d.ts +8 -0
- package/dist/primitives/useProvidedPhoton.d.ts.map +1 -0
- package/dist/primitives/useProvidedPhoton.js +8 -0
- package/dist/primitives/useProvidedPhoton.js.map +1 -0
- package/dist/styles.css +45 -3
- package/dist/test-utils/contract.d.ts.map +1 -1
- package/dist/test-utils/contract.js +23 -2
- package/dist/test-utils/contract.js.map +1 -1
- package/package.json +5 -3
- package/src/adapters/tailwind.tsx +52 -24
- package/src/analytics/PhotonAnalyticsProvider.test.tsx +191 -0
- package/src/analytics/PhotonAnalyticsProvider.tsx +96 -0
- package/src/analytics/fieldInteraction.test.tsx +184 -0
- package/src/analytics/fieldInteraction.tsx +148 -0
- package/src/analytics/tracker.test.ts +52 -0
- package/src/analytics/tracker.ts +42 -0
- package/src/analytics/viewed.ts +27 -0
- package/src/components/PhotonOrder.test.tsx +256 -0
- package/src/components/PhotonOrder.tsx +45 -30
- package/src/components/PhotonPatient.tsx +11 -7
- package/src/components/PhotonPrescription.test.tsx +116 -0
- package/src/components/PhotonPrescription.tsx +10 -570
- package/src/components/format.ts +2 -2
- package/src/components/index.ts +1 -1
- package/src/components/order/DraftOrderPrompt.test.tsx +80 -0
- package/src/components/order/DraftOrderPrompt.tsx +81 -0
- package/src/components/patient/Benefits.tsx +21 -13
- package/src/components/patient/Clinical.tsx +31 -26
- package/src/components/patient/IntakeForm.test.tsx +89 -0
- package/src/components/patient/IntakeForm.tsx +168 -136
- package/src/components/patient/Summary.test.tsx +106 -0
- package/src/components/patient/Summary.tsx +54 -34
- package/src/components/patient/fields.tsx +52 -38
- package/src/components/patient/query.ts +6 -0
- package/src/components/prescription/PrescriptionCard.test.tsx +85 -0
- package/src/components/prescription/PrescriptionCard.tsx +347 -0
- package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +85 -0
- package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.tsx +41 -0
- package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +209 -0
- package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.tsx +99 -0
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +456 -0
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +238 -0
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.test.ts +63 -0
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.ts +15 -0
- package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +75 -0
- package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.tsx +41 -0
- package/src/components/prescription/TreatmentSearch/TreatmentPicker.tsx +375 -0
- package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +699 -0
- package/src/components/prescription/TreatmentSearch/TreatmentSearch.tsx +220 -0
- package/src/components/schemaErrors.test.ts +49 -0
- package/src/components/schemaErrors.ts +33 -0
- package/src/index.ts +2 -0
- package/src/meta/version.test.ts +10 -0
- package/src/meta/version.ts +4 -0
- package/src/primitives/PhotonProvider.tsx +30 -15
- package/src/primitives/defaults.tsx +44 -21
- package/src/primitives/photonContext.ts +4 -0
- package/src/primitives/types.ts +15 -3
- package/src/primitives/useProvidedPhoton.ts +21 -0
- package/src/styles.css +45 -3
- package/src/test-utils/contract.tsx +45 -2
- package/dist/components/TreatmentPicker.d.ts +0 -45
- package/dist/components/TreatmentPicker.d.ts.map +0 -1
- package/dist/components/TreatmentPicker.js.map +0 -1
- package/src/components/TreatmentPicker.tsx +0 -350
package/dist/components/{TreatmentPicker.js → prescription/TreatmentSearch/TreatmentPicker.js}
RENAMED
|
@@ -1,65 +1,61 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useComponents } from "
|
|
3
|
-
import { describeTreatmentDrug, groupTreatmentOptions, orderedOptions, strengthsOf } from "
|
|
4
|
-
import { digitKey, edge, SHOWN, took, typesBack, vertical } from "
|
|
2
|
+
import { useComponents } from "../../../primitives/index.js";
|
|
3
|
+
import { describeTreatmentDrug, groupTreatmentOptions, orderedOptions, strengthsOf } from "../../display.js";
|
|
4
|
+
import { afterPress, digitKey, edge, SHOWN, took, typesBack, vertical } from "../../search.js";
|
|
5
5
|
import { useEffect, useRef, useState } from "react";
|
|
6
|
-
|
|
6
|
+
import { useFieldInteractions } from "../../../analytics/fieldInteraction.js";
|
|
7
|
+
export function TreatmentPicker({ change, drug: drugName, listOpen, onDrug, onChoose, busy, chosen, handleRef, onBack, }) {
|
|
7
8
|
const { Button, OptionList, Stack, ToggleGroup } = useComponents();
|
|
9
|
+
const fieldInteraction = useFieldInteractions("add_prescription_form");
|
|
8
10
|
const typed = change.inputText;
|
|
9
11
|
const all = groupTreatmentOptions(orderedOptions({ options: change.options.filter((o) => o.path) }, typed));
|
|
10
12
|
const [showAll, setShowAll] = useState(false);
|
|
11
13
|
const drugs = showAll ? all : all.slice(0, SHOWN);
|
|
12
|
-
// The
|
|
13
|
-
const [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// The row the list's keys act on.
|
|
15
|
+
const [highlight, setHighlight] = useState(0);
|
|
16
|
+
const at = Math.min(highlight, Math.max(0, drugs.length - 1));
|
|
17
|
+
// The picked drug, and its form and strength as the prescriber picks them (null: not yet) — kept per drug, so
|
|
18
|
+
// picking another drug starts it empty.
|
|
19
|
+
const drug = all.find((d) => d.name === drugName) ?? null;
|
|
20
|
+
const [picks, setPicks] = useState(() => empty(null));
|
|
21
|
+
const pick = picks.drug === drugName ? picks : empty(drugName);
|
|
22
|
+
const setPick = (next) => setPicks({ drug: drugName, ...next });
|
|
18
23
|
const root = useRef(null);
|
|
19
24
|
const list = () => root.current?.querySelector('[tabindex="0"]');
|
|
20
25
|
const chips = (group) => [
|
|
21
26
|
...(root.current?.querySelectorAll(`[data-chips="${group}"] button:not(:disabled)`) ?? []),
|
|
22
27
|
];
|
|
23
|
-
// Focus is on the list itself (not a
|
|
28
|
+
// Focus is on the list itself (not a row): the highlighted row has the outline.
|
|
24
29
|
const [onList, setOnList] = useState(false);
|
|
25
|
-
// Focus is in the open drug's chips (Enter took it there): Tab moves between them.
|
|
26
|
-
const [inChips, setInChips] = useState(false);
|
|
27
30
|
// Focus was put here for the prescriber, mid-typing: keys that type go back to Treatment (typesBack).
|
|
28
31
|
const typing = useRef(false);
|
|
29
|
-
// Where focus goes once the next render is in: the list, or a chip (the
|
|
32
|
+
// Where focus goes once the next render is in: the list, or a chip (the first that fits, once a drug is picked).
|
|
30
33
|
const focusNext = useRef(null);
|
|
31
|
-
const firstRender = useRef(true);
|
|
32
34
|
useEffect(() => {
|
|
33
|
-
// One tab stop
|
|
34
|
-
// with the keys; once Enter takes focus into the chips, Tab moves between them.
|
|
35
|
+
// One tab stop for the list: Tab moves the highlight (onKeyDown), not into a row.
|
|
35
36
|
list()
|
|
36
37
|
?.querySelectorAll("button")
|
|
37
|
-
.forEach((button) => (button.tabIndex =
|
|
38
|
+
.forEach((button) => (button.tabIndex = -1));
|
|
38
39
|
const next = focusNext.current;
|
|
39
40
|
focusNext.current = null;
|
|
40
41
|
if (next === "list")
|
|
41
42
|
list()?.focus();
|
|
43
|
+
else if (next === "chips")
|
|
44
|
+
(chips("form")[0] ?? chips("strength")[0])?.focus();
|
|
42
45
|
else if (next)
|
|
43
46
|
chips(next.group)[next.at]?.focus();
|
|
44
|
-
else if (!firstRender.current) {
|
|
45
|
-
// Opening a drug replaces the row button that had focus; keep focus in the list so keys still work.
|
|
46
|
-
// Never on first render (focus stays wherever the prescriber is).
|
|
47
|
-
const active = document.activeElement;
|
|
48
|
-
if (!active || active === document.body || !active.isConnected)
|
|
49
|
-
list()?.focus();
|
|
50
|
-
}
|
|
51
|
-
firstRender.current = false;
|
|
52
47
|
});
|
|
53
48
|
// What's shown picked: the prescriber's picks — or, while a choice saves, the product chosen.
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const drug = drugs[drugAt];
|
|
49
|
+
const saving = chosen ? locate(all, chosen) : null;
|
|
50
|
+
const view = saving && all[saving.drug]?.name === drugName ? saving : pick;
|
|
57
51
|
// One form is the drug's form; with more, none until it's picked.
|
|
58
52
|
const formAt = drug?.forms.length === 1 ? 0 : view.form;
|
|
59
53
|
// The product a form comes in at a strength, if it does.
|
|
60
54
|
const productOf = (formIndex, strength) => drug?.forms[formIndex]?.strengths.find((s) => s.label === strength)?.option ?? null;
|
|
61
55
|
// The forms a strength could be: those that come in it — of the one picked, once it is.
|
|
62
56
|
const formsFor = (strength) => drug?.forms.flatMap((_, i) => ((formAt === null || i === formAt) && productOf(i, strength) ? [i] : [])) ?? [];
|
|
57
|
+
const formPicked = fieldInteraction("form", { isOptional: false, hasValue: formAt !== null });
|
|
58
|
+
const strengthPicked = fieldInteraction("strength", { isOptional: false, hasValue: view.strength !== null });
|
|
63
59
|
// Busy, or a choice saving: nothing can be picked (a saving choice still looks as picked, not disabled).
|
|
64
60
|
const disabled = (busy && !chosen) || !onChoose;
|
|
65
61
|
const locked = disabled || Boolean(chosen);
|
|
@@ -69,33 +65,29 @@ export function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onB
|
|
|
69
65
|
const forms = drugs[i].forms;
|
|
70
66
|
return forms.length === 1 && forms[0].strengths.length === 1 ? forms[0].strengths[0].option : null;
|
|
71
67
|
};
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
68
|
+
const pickDrug = (i) => {
|
|
69
|
+
if (locked || !drugs[i])
|
|
74
70
|
return;
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
const only = onlyOption(i);
|
|
72
|
+
onDrug(drugs[i].name);
|
|
73
|
+
if (only)
|
|
74
|
+
choose(only);
|
|
75
|
+
else
|
|
76
|
+
focusNext.current = "chips";
|
|
77
77
|
};
|
|
78
78
|
// The first chip in a group that goes with the other group's pick (`form` / `strength`; null: nothing picked).
|
|
79
79
|
const firstFitting = (group, form, strength) => {
|
|
80
80
|
if (!drug)
|
|
81
81
|
return 0;
|
|
82
|
-
const
|
|
82
|
+
const found = group === "form"
|
|
83
83
|
? drug.forms.findIndex((_, i) => strength === null || productOf(i, strength))
|
|
84
84
|
: strengthsOf(drug).findIndex((s) => form === null || productOf(form, s));
|
|
85
|
-
return Math.max(0,
|
|
86
|
-
};
|
|
87
|
-
const enter = () => {
|
|
88
|
-
if (!drug || chosen)
|
|
89
|
-
return;
|
|
90
|
-
const only = onlyOption(drugAt);
|
|
91
|
-
if (only)
|
|
92
|
-
return choose(only);
|
|
93
|
-
const group = drug.forms.length > 1 && pick.form === null ? "form" : "strength";
|
|
94
|
-
chips(group)[firstFitting(group, formAt, pick.strength)]?.focus();
|
|
85
|
+
return Math.max(0, found);
|
|
95
86
|
};
|
|
96
87
|
const pickForm = (i) => {
|
|
97
|
-
if (locked)
|
|
88
|
+
if (locked || !drug)
|
|
98
89
|
return;
|
|
90
|
+
formPicked.onChange(pick.form !== i);
|
|
99
91
|
if (pick.form === i) {
|
|
100
92
|
setPick({ ...pick, form: null }); // picked again: taken back
|
|
101
93
|
focusNext.current = { group: "form", at: i };
|
|
@@ -103,55 +95,64 @@ export function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onB
|
|
|
103
95
|
}
|
|
104
96
|
if (pick.strength !== null && !productOf(i, pick.strength)) {
|
|
105
97
|
// Greyed (not in the strength picked): the strength goes, and it's the prescriber's to pick again.
|
|
106
|
-
setPick({
|
|
98
|
+
setPick({ form: i, strength: null });
|
|
107
99
|
focusNext.current = { group: "strength", at: firstFitting("strength", i, null) };
|
|
108
100
|
return;
|
|
109
101
|
}
|
|
110
102
|
const strengths = drug.forms[i].strengths;
|
|
111
103
|
const product = pick.strength !== null ? productOf(i, pick.strength) : strengths.length === 1 ? strengths[0].option : null;
|
|
112
|
-
setPick({ ...pick,
|
|
104
|
+
setPick({ ...pick, form: i });
|
|
113
105
|
if (product)
|
|
114
106
|
choose(product);
|
|
115
107
|
else
|
|
116
108
|
focusNext.current = { group: "strength", at: firstFitting("strength", i, null) };
|
|
117
109
|
};
|
|
118
110
|
const pickStrength = (strength) => {
|
|
119
|
-
if (locked)
|
|
111
|
+
if (locked || !drug)
|
|
120
112
|
return;
|
|
121
|
-
|
|
113
|
+
strengthPicked.onChange(pick.strength !== strength);
|
|
114
|
+
const index = strengthsOf(drug).indexOf(strength);
|
|
122
115
|
if (pick.strength === strength) {
|
|
123
116
|
setPick({ ...pick, strength: null }); // picked again: taken back
|
|
124
|
-
focusNext.current = { group: "strength", at };
|
|
117
|
+
focusNext.current = { group: "strength", at: index };
|
|
125
118
|
return;
|
|
126
119
|
}
|
|
127
120
|
if (drug.forms.length > 1 && pick.form !== null && !productOf(pick.form, strength)) {
|
|
128
121
|
// Greyed (the form picked doesn't come in it): the form goes, and it's the prescriber's to pick again.
|
|
129
|
-
setPick({
|
|
122
|
+
setPick({ form: null, strength });
|
|
130
123
|
focusNext.current = { group: "form", at: firstFitting("form", null, strength) };
|
|
131
124
|
return;
|
|
132
125
|
}
|
|
133
126
|
const forms = formsFor(strength);
|
|
134
|
-
setPick({ ...pick,
|
|
127
|
+
setPick({ ...pick, strength });
|
|
135
128
|
if (forms.length === 1)
|
|
136
129
|
choose(productOf(forms[0], strength));
|
|
137
130
|
else
|
|
138
131
|
focusNext.current = { group: "form", at: firstFitting("form", null, strength) };
|
|
139
132
|
};
|
|
133
|
+
const enter = () => {
|
|
134
|
+
if (chosen)
|
|
135
|
+
return;
|
|
136
|
+
if (listOpen)
|
|
137
|
+
return pickDrug(at);
|
|
138
|
+
(chips("form")[0] ?? chips("strength")[0])?.focus();
|
|
139
|
+
};
|
|
140
140
|
useEffect(() => {
|
|
141
141
|
if (!handleRef)
|
|
142
142
|
return;
|
|
143
143
|
handleRef.current = {
|
|
144
|
-
total: all.length,
|
|
144
|
+
total: listOpen ? all.length : 0,
|
|
145
145
|
enter,
|
|
146
146
|
focus: (fromTyping) => {
|
|
147
147
|
typing.current = Boolean(fromTyping && onBack);
|
|
148
|
-
list()
|
|
149
|
-
|
|
148
|
+
const target = listOpen ? list() : (chips("form")[0] ?? chips("strength")[0]);
|
|
149
|
+
target?.focus();
|
|
150
|
+
return Boolean(target);
|
|
150
151
|
},
|
|
151
152
|
pick: (index) => {
|
|
152
|
-
if (index >= drugs.length)
|
|
153
|
+
if (!listOpen || index >= drugs.length)
|
|
153
154
|
return false;
|
|
154
|
-
|
|
155
|
+
pickDrug(index);
|
|
155
156
|
return true;
|
|
156
157
|
},
|
|
157
158
|
};
|
|
@@ -159,11 +160,6 @@ export function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onB
|
|
|
159
160
|
handleRef.current = null;
|
|
160
161
|
};
|
|
161
162
|
});
|
|
162
|
-
if (!drug)
|
|
163
|
-
return null;
|
|
164
|
-
const strengths = strengthsOf(drug);
|
|
165
|
-
// The drug's strengths differ by form (the row can't say one): a form with one strength says it on its chip.
|
|
166
|
-
const strengthByForm = strengths.length > 1;
|
|
167
163
|
// F / S: the next chip in that group after the one focused (the first, from anywhere else).
|
|
168
164
|
const nextChip = (group) => {
|
|
169
165
|
const buttons = chips(group);
|
|
@@ -172,7 +168,7 @@ export function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onB
|
|
|
172
168
|
buttons[(buttons.indexOf(document.activeElement) + 1) % buttons.length].focus();
|
|
173
169
|
return true;
|
|
174
170
|
};
|
|
175
|
-
const
|
|
171
|
+
const onListKeyDown = (e) => {
|
|
176
172
|
if (typing.current && typesBack(e))
|
|
177
173
|
return onBack?.(); // not taken: the browser types it in Treatment
|
|
178
174
|
typing.current = false;
|
|
@@ -181,80 +177,88 @@ export function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onB
|
|
|
181
177
|
const digit = digitKey(e);
|
|
182
178
|
if (e.altKey && digit < 0)
|
|
183
179
|
return;
|
|
184
|
-
const
|
|
185
|
-
|
|
180
|
+
const move = (to) => {
|
|
181
|
+
setHighlight(to);
|
|
182
|
+
focusNext.current = "list";
|
|
183
|
+
};
|
|
186
184
|
if (digit >= 0 && digit < drugs.length)
|
|
187
|
-
|
|
188
|
-
else if (key === "d")
|
|
189
|
-
|
|
185
|
+
pickDrug(digit);
|
|
186
|
+
else if (e.key.toLowerCase() === "d")
|
|
187
|
+
move((at + 1) % drugs.length);
|
|
190
188
|
else if (vertical(e))
|
|
191
|
-
|
|
189
|
+
move(Math.max(0, Math.min(drugs.length - 1, at + vertical(e))));
|
|
192
190
|
else if (edge(e))
|
|
193
|
-
|
|
194
|
-
else if (e.key === "Tab" &&
|
|
191
|
+
move(edge(e) === "first" ? 0 : drugs.length - 1);
|
|
192
|
+
else if (e.key === "Tab" && !e.altKey) {
|
|
195
193
|
// The next / previous drug — past the last / first, on out of the list (the browser's Tab).
|
|
196
|
-
const to =
|
|
194
|
+
const to = at + (e.shiftKey ? -1 : 1);
|
|
197
195
|
if (to < 0 || to >= drugs.length)
|
|
198
196
|
return;
|
|
199
|
-
|
|
197
|
+
move(to);
|
|
200
198
|
}
|
|
201
|
-
else if (e.key === "
|
|
202
|
-
|
|
199
|
+
else if (e.key === "Enter")
|
|
200
|
+
pickDrug(at);
|
|
203
201
|
else if (e.key === "Escape" && onBack)
|
|
204
202
|
onBack();
|
|
205
|
-
|
|
203
|
+
// A key that types and isn't one of the list's: back to Treatment, where the browser types it.
|
|
204
|
+
else if (typesBack(e))
|
|
205
|
+
return onBack?.();
|
|
206
|
+
else
|
|
207
|
+
return;
|
|
208
|
+
took(e);
|
|
209
|
+
};
|
|
210
|
+
const onChipsKeyDown = (e) => {
|
|
211
|
+
if (e.metaKey || e.ctrlKey || e.altKey)
|
|
212
|
+
return;
|
|
213
|
+
const key = e.key.toLowerCase();
|
|
214
|
+
if (key === "f" || key === "s") {
|
|
206
215
|
if (!nextChip(key === "f" ? "form" : "strength"))
|
|
207
216
|
return;
|
|
208
217
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
enter();
|
|
218
|
+
else if (e.key === "Escape" && onBack)
|
|
219
|
+
onBack();
|
|
212
220
|
else
|
|
213
221
|
return;
|
|
214
222
|
took(e);
|
|
215
223
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
224
|
+
const strengths = drug ? strengthsOf(drug) : [];
|
|
225
|
+
// The drug's strengths differ by form (the row can't say one): a form with one strength says it on its chip.
|
|
226
|
+
const strengthByForm = strengths.length > 1;
|
|
227
|
+
return (_jsx("div", { ref: root, style: { paddingBottom: "0.75em" }, onFocus: (e) => setOnList((highlighted) => e.target === list() || (highlighted && Boolean(list()?.contains(e.target)))), onBlur: (e) => {
|
|
220
228
|
if (root.current?.contains(e.relatedTarget))
|
|
221
229
|
return;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
afterPress(() => {
|
|
231
|
+
if (root.current?.contains(document.activeElement))
|
|
232
|
+
return;
|
|
233
|
+
setOnList(false);
|
|
234
|
+
typing.current = false;
|
|
235
|
+
});
|
|
236
|
+
}, children: _jsxs(Stack, { gap: "3", children: [listOpen && drugs.length > 0 && (_jsx(OptionList, { label: "Pick a treatment", disabled: disabled,
|
|
237
|
+
// The highlight shows only while the keys act on it (focus on the list).
|
|
238
|
+
activeKey: onList ? String(at) : null, activeSelected: onList, onKeyDown: onListKeyDown, options: drugs.map((d, i) => {
|
|
226
239
|
const only = onlyOption(i);
|
|
227
240
|
return {
|
|
228
241
|
key: String(i),
|
|
229
242
|
label: d.name,
|
|
230
|
-
|
|
231
|
-
description: describeTreatmentDrug(d, i !== drugAt) ?? undefined,
|
|
243
|
+
description: describeTreatmentDrug(d) ?? undefined,
|
|
232
244
|
// The row chooses the product, so it's named as the product.
|
|
233
245
|
ariaLabel: only?.displayName,
|
|
234
246
|
direct: Boolean(only),
|
|
235
|
-
loading: Boolean(chosen) &&
|
|
247
|
+
loading: Boolean(chosen) && chosen === only,
|
|
236
248
|
};
|
|
237
|
-
}), onSelect: (key) => {
|
|
238
|
-
|
|
239
|
-
return;
|
|
240
|
-
const only = onlyOption(Number(key));
|
|
241
|
-
if (only)
|
|
242
|
-
choose(only);
|
|
243
|
-
else
|
|
244
|
-
openDrug(Number(key));
|
|
245
|
-
}, children: [drug.forms.length > 1 && (_jsx("div", { "data-chips": "form", style: { display: "contents" }, children: _jsx(ToggleGroup, { label: "Form", disabled: disabled, value: formAt === null ? null : String(formAt), onChange: (value) => pickForm(Number(value)), options: drug.forms.map((f, i) => {
|
|
246
|
-
const only = f.strengths.length === 1 ? f.strengths[0] : null;
|
|
249
|
+
}), onSelect: (key) => pickDrug(Number(key)) })), listOpen && all.length > drugs.length && (_jsx("div", { children: _jsxs(Button, { variant: "ghost", onClick: () => setShowAll(true), children: ["Show ", all.length - drugs.length, " more"] }) })), !listOpen && drug && (_jsxs("div", { onKeyDown: onChipsKeyDown, style: { display: "contents" }, children: [drug.forms.length > 1 && (_jsx("div", { "data-chips": "form", onFocus: formPicked.onFocus, onBlur: formPicked.onBlur, children: _jsx(ToggleGroup, { label: "Form", disabled: disabled, value: formAt === null ? null : String(formAt), onChange: (value) => pickForm(Number(value)), options: drug.forms.map((f, i) => {
|
|
250
|
+
const one = f.strengths.length === 1 ? f.strengths[0] : null;
|
|
247
251
|
// With the strength picked (or its only one), the chip chooses the product: named as the product.
|
|
248
|
-
const product = view.strength !== null ? productOf(i, view.strength) : (
|
|
252
|
+
const product = view.strength !== null ? productOf(i, view.strength) : (one?.option ?? null);
|
|
249
253
|
return {
|
|
250
254
|
value: String(i),
|
|
251
255
|
label: f.label || "As listed",
|
|
252
|
-
detail: (
|
|
256
|
+
detail: (one && strengthByForm && one.label) || undefined,
|
|
253
257
|
ariaLabel: product?.displayName,
|
|
254
258
|
// Not in the strength picked: greyed, still pickable (it drops the strength).
|
|
255
259
|
muted: view.strength !== null && !product,
|
|
256
260
|
};
|
|
257
|
-
}) }) })), strengths.length > 1 && (_jsx("div", { "data-chips": "strength",
|
|
261
|
+
}) }) })), strengths.length > 1 && (_jsx("div", { "data-chips": "strength", onFocus: strengthPicked.onFocus, onBlur: strengthPicked.onBlur, children: _jsx(ToggleGroup, { label: "Strength", disabled: disabled, value: view.strength === null ? null : String(strengths.indexOf(view.strength)), onChange: (value) => pickStrength(strengths[Number(value)]), options: strengths.map((strength, i) => {
|
|
258
262
|
const forms = formsFor(strength);
|
|
259
263
|
// In one form (the one picked, or the only one with it), the chip chooses the product: named as it.
|
|
260
264
|
const product = forms.length === 1 ? productOf(forms[0], strength) : null;
|
|
@@ -265,14 +269,18 @@ export function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onB
|
|
|
265
269
|
// The form picked doesn't come in it: greyed, still pickable (it drops the form).
|
|
266
270
|
muted: forms.length === 0,
|
|
267
271
|
};
|
|
268
|
-
}) }) }))] })
|
|
272
|
+
}) }) }))] }))] }) }));
|
|
269
273
|
}
|
|
274
|
+
const empty = (drug) => ({ drug, form: null, strength: null });
|
|
270
275
|
/** Where a product is among the drugs: its drug, its form, its strength — as picks. Null if it isn't there. */
|
|
271
276
|
function locate(drugs, option) {
|
|
277
|
+
if (!option)
|
|
278
|
+
return null;
|
|
279
|
+
const same = (o) => o === option || (option.id !== null && o.id === option.id);
|
|
272
280
|
for (const [drug, { forms }] of drugs.entries())
|
|
273
281
|
for (const [form, { strengths }] of forms.entries())
|
|
274
282
|
for (const strength of strengths)
|
|
275
|
-
if (strength.option
|
|
283
|
+
if (same(strength.option))
|
|
276
284
|
return { drug, form: forms.length > 1 ? form : null, strength: strength.label };
|
|
277
285
|
return null;
|
|
278
286
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreatmentPicker.js","sourceRoot":"","sources":["../../../../src/components/prescription/TreatmentSearch/TreatmentPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7G,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAqB,MAAM,iBAAkB,CAAC;AACnH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAyC,CAAC;AAmC/E,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,IAAI,EAAE,QAAQ,EACd,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,MAAM,GAgBP;IACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,CAAC;IACnE,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC;IAC/B,MAAM,GAAG,GAAG,qBAAqB,CAAC,cAAc,CAAC,EAA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AAK,EAAE,CAAC;IACjH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Change, ChangeOption, Prescription, PrescriptionEdits, PrescriptionRecord } from "@photonhealth/client";
|
|
2
|
+
/** A drug chosen from one of the server's choices: the choice, and the option taken. */
|
|
3
|
+
export interface TreatmentChoice {
|
|
4
|
+
change: Change;
|
|
5
|
+
option: ChangeOption;
|
|
6
|
+
}
|
|
7
|
+
export interface TreatmentSearchProps {
|
|
8
|
+
live: Prescription | null;
|
|
9
|
+
rx: PrescriptionRecord | null;
|
|
10
|
+
/** The drug picked before the line has a record (the server drafts it once the patient is known). */
|
|
11
|
+
pickId: string | null;
|
|
12
|
+
/** The server's choices for the drug typed. */
|
|
13
|
+
drugChoices: readonly Change[];
|
|
14
|
+
/** A product chosen, saving: nothing to pick until the server answers. */
|
|
15
|
+
choosing: TreatmentChoice | null;
|
|
16
|
+
/** Shown until a product is set. Kept mounted while closed. */
|
|
17
|
+
open: boolean;
|
|
18
|
+
busy: boolean;
|
|
19
|
+
/** The field whose save is in flight. */
|
|
20
|
+
spinning: string | null;
|
|
21
|
+
autoFocus?: boolean;
|
|
22
|
+
/** Put the cursor in Treatment each time this changes. */
|
|
23
|
+
focusSignal?: number;
|
|
24
|
+
save: (edits: PrescriptionEdits, from?: string) => void;
|
|
25
|
+
onChoose: (choice: TreatmentChoice) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function TreatmentSearch({ live, rx, pickId, drugChoices, choosing, open, busy, spinning, autoFocus, focusSignal, save, onChoose, }: TreatmentSearchProps): import("react").JSX.Element | null;
|
|
28
|
+
//# sourceMappingURL=TreatmentSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreatmentSearch.d.ts","sourceRoot":"","sources":["../../../../src/components/prescription/TreatmentSearch/TreatmentSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAStH,wFAAwF;AACxF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,EAAE,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9B,qGAAqG;IACrG,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+CAA+C;IAC/C,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,+DAA+D;IAC/D,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,yCAAyC;IACzC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,EAAE,EACF,MAAM,EACN,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAI,EACJ,QAAQ,GACT,EAAE,oBAAoB,sCA0KtB"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useLatestCallback } from "../../../hooks/index.js";
|
|
4
|
+
import { useComponents } from "../../../primitives/index.js";
|
|
5
|
+
import { focusProps, searchProps } from "../../flow.js";
|
|
6
|
+
import { FEW, searchKeys, useTypeAhead } from "../../search.js";
|
|
7
|
+
import { TreatmentPicker } from "./TreatmentPicker.js";
|
|
8
|
+
import { useFieldInteractions } from "../../../analytics/fieldInteraction.js";
|
|
9
|
+
export function TreatmentSearch({ live, rx, pickId, drugChoices, choosing, open, busy, spinning, autoFocus, focusSignal, save, onChoose, }) {
|
|
10
|
+
const { Input } = useComponents();
|
|
11
|
+
const treatmentField = useFieldInteractions("add_prescription_form")("treatment", { isOptional: false });
|
|
12
|
+
const [treatment, setTreatment] = useState(rx?.treatment.name ?? "");
|
|
13
|
+
// Only send free-text medication when it actually changed (see submitTreatment).
|
|
14
|
+
const [sentTreatment, setSentTreatment] = useState(rx?.treatment.name ?? "");
|
|
15
|
+
// When the server's copy changes (a hydrate, a chosen option, signing), show its drug.
|
|
16
|
+
// Adjusted during render, keyed on id + contentHash — React's pattern for deriving state from props.
|
|
17
|
+
const serverKey = rx ? `${rx.id}:${rx.signing.contentHash}:${rx.signing.state}` : null;
|
|
18
|
+
const [syncedKey, setSyncedKey] = useState(serverKey);
|
|
19
|
+
if (rx && serverKey !== syncedKey) {
|
|
20
|
+
setSyncedKey(serverKey);
|
|
21
|
+
const shownName = live?.name ?? rx.treatment.name;
|
|
22
|
+
setTreatment(shownName);
|
|
23
|
+
setSentTreatment(shownName); // what's shown was the pick — leaving the field mustn't re-send it as text
|
|
24
|
+
}
|
|
25
|
+
// A line without a record shows the drug entered on it — e.g. given as props: once per object.
|
|
26
|
+
const [filledFrom, setFilledFrom] = useState(null);
|
|
27
|
+
if (live && live !== filledFrom) {
|
|
28
|
+
setFilledFrom(live);
|
|
29
|
+
const text = live.name ?? (rx ? undefined : live.entered.treatment?.name);
|
|
30
|
+
if (!rx && text) {
|
|
31
|
+
setTreatment(text);
|
|
32
|
+
setSentTreatment(text); // already sent: leaving the field mustn't send it again
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// The pick's name — never its id (a drug given by id alone is named once it's drafted).
|
|
36
|
+
const [shownPick, setShownPick] = useState(pickId);
|
|
37
|
+
if (pickId !== shownPick) {
|
|
38
|
+
setShownPick(pickId);
|
|
39
|
+
const name = pickId && live?.name;
|
|
40
|
+
if (name) {
|
|
41
|
+
setTreatment(name);
|
|
42
|
+
setSentTreatment(name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const picker = useRef(null);
|
|
46
|
+
// Treatment works like a select: the drug picked from the list (its name is the field's value), and whether the
|
|
47
|
+
// list of drugs is open — else the picked drug's form and strength show under the field.
|
|
48
|
+
const [drug, setDrug] = useState(null);
|
|
49
|
+
const [listOpen, setListOpen] = useState(true);
|
|
50
|
+
// The Input building block takes no ref, so focus reaches its field through a wrapper.
|
|
51
|
+
const searchBox = useRef(null);
|
|
52
|
+
const focusField = () => searchBox.current?.querySelector("input")?.focus();
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (focusSignal)
|
|
55
|
+
focusField();
|
|
56
|
+
}, [focusSignal]);
|
|
57
|
+
// Only send free-text medication when it actually changed. Otherwise clicking one of the server's
|
|
58
|
+
// choices blurs this field first, re-sends the same text, and the "saving" state swallows the click.
|
|
59
|
+
const submitTreatment = () => {
|
|
60
|
+
const text = treatment.trim();
|
|
61
|
+
if (!text || text === sentTreatment || text === rx?.treatment.name)
|
|
62
|
+
return;
|
|
63
|
+
setSentTreatment(text);
|
|
64
|
+
save({ treatment: { name: text } }, "treatment");
|
|
65
|
+
};
|
|
66
|
+
// Type-ahead: once there are 3+ characters, the medication text is sent when typing pauses — before the
|
|
67
|
+
// record it's a lookup (the object aborts the one for older text), and the server's choices render live
|
|
68
|
+
// below. Enter / blur send at once; unchanged text is never re-sent (so a wait that ends after them is a no-op).
|
|
69
|
+
// Not two, as a patient's name: two letters of a drug match thousands of products.
|
|
70
|
+
const typeAhead = useTypeAhead(submitTreatment, { minChars: 3 });
|
|
71
|
+
// A drug picked: its name in the field (already looked up — leaving the field mustn't send it), the list closed.
|
|
72
|
+
const showDrug = (name) => {
|
|
73
|
+
typeAhead.cancel();
|
|
74
|
+
setDrug(name);
|
|
75
|
+
setListOpen(false);
|
|
76
|
+
setTreatment(name ?? "");
|
|
77
|
+
setSentTreatment(name ?? "");
|
|
78
|
+
};
|
|
79
|
+
// The drugs to pick from: none while a product chosen saves (it heads the card at once).
|
|
80
|
+
const shownChoices = choosing ? [] : drugChoices;
|
|
81
|
+
const pickerUp = shownChoices.length > 0;
|
|
82
|
+
// A few drugs for what's typed, and the prescriber is still in Treatment: focus goes to the first, ready to
|
|
83
|
+
// pick — typing carries on in Treatment (search.tsx). Once per answer.
|
|
84
|
+
const choicesFor = drugChoices[0]
|
|
85
|
+
? `${drugChoices[0].inputText}|${drugChoices[0].options.map((o) => o.displayName).join("|")}`
|
|
86
|
+
: null;
|
|
87
|
+
// A new answer opens the list on its drugs, nothing picked.
|
|
88
|
+
const [listedFor, setListedFor] = useState(choicesFor);
|
|
89
|
+
if (choicesFor !== listedFor) {
|
|
90
|
+
setListedFor(choicesFor);
|
|
91
|
+
if (choicesFor) {
|
|
92
|
+
setDrug(null);
|
|
93
|
+
setListOpen(true);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const focusedFor = useRef(null);
|
|
97
|
+
const focusFew = useLatestCallback(() => {
|
|
98
|
+
const field = searchBox.current?.querySelector("input");
|
|
99
|
+
const answered = treatment.trim() === sentTreatment && !busy && !typeAhead.waiting();
|
|
100
|
+
if (!choicesFor || !answered || !field || document.activeElement !== field)
|
|
101
|
+
return;
|
|
102
|
+
if (focusedFor.current === choicesFor || (picker.current?.total ?? FEW) >= FEW)
|
|
103
|
+
return;
|
|
104
|
+
focusedFor.current = choicesFor;
|
|
105
|
+
picker.current.focus(true);
|
|
106
|
+
});
|
|
107
|
+
useEffect(() => focusFew(), [choicesFor, busy, focusFew]);
|
|
108
|
+
if (!open)
|
|
109
|
+
return null;
|
|
110
|
+
return (_jsxs("div", { style: { display: "contents" }, ...treatmentField, children: [_jsx("div", { ref: searchBox, ...searchProps, ...(pickerUp ? {} : focusProps), children: _jsx(Input, { label: "Treatment", autoFocus: autoFocus, value: treatment, onChange: (e) => {
|
|
111
|
+
setTreatment(e.target.value);
|
|
112
|
+
setDrug(null); // typing searches anew: the list, with no drug picked
|
|
113
|
+
setListOpen(true);
|
|
114
|
+
typeAhead.typed("treatment", e.target.value);
|
|
115
|
+
},
|
|
116
|
+
// The picked drug's field, clicked: the last search's drugs again, without searching.
|
|
117
|
+
onClick: () => drug && !listOpen && setListOpen(true), onBlur: submitTreatment, loading: spinning === "treatment", clearLabel: "Clear treatment", onClear: () => {
|
|
118
|
+
showDrug(null);
|
|
119
|
+
focusField();
|
|
120
|
+
}, onKeyDown: (e) => {
|
|
121
|
+
// Esc with the list open over a picked drug: closed again, back to its form and strength.
|
|
122
|
+
if (e.key === "Escape" && drug && listOpen) {
|
|
123
|
+
setListOpen(false);
|
|
124
|
+
return e.preventDefault();
|
|
125
|
+
}
|
|
126
|
+
const choices = pickerUp ? picker.current : null;
|
|
127
|
+
// A search field over the drugs (searchKeys); and Enter is on the open drug when the
|
|
128
|
+
// choices are for what's typed (chosen if it's one product, else on to its chips).
|
|
129
|
+
const answered = treatment.trim() === sentTreatment && !busy;
|
|
130
|
+
if (searchKeys(e, choices, answered))
|
|
131
|
+
return;
|
|
132
|
+
if (e.key === "Enter" && choices && treatment.trim() === sentTreatment)
|
|
133
|
+
choices.enter();
|
|
134
|
+
else if (e.key === "Enter")
|
|
135
|
+
submitTreatment();
|
|
136
|
+
else
|
|
137
|
+
return;
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
} }) }), pickerUp && (_jsx("div", { ...focusProps, children: shownChoices.map((change) => (_jsx(TreatmentPicker
|
|
140
|
+
// Each search's own: what's picked in one doesn't carry over to the next.
|
|
141
|
+
, { change: change, drug: drug, listOpen: listOpen, onDrug: (name) => {
|
|
142
|
+
treatmentField.onChange(true);
|
|
143
|
+
showDrug(name);
|
|
144
|
+
}, onChoose: (option) => onChoose({ change, option }), busy: busy, handleRef: picker, onBack: focusField }, `${change.key}:${change.inputText ?? ""}`))) }))] }));
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=TreatmentSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreatmentSearch.js","sourceRoot":"","sources":["../../../../src/components/prescription/TreatmentSearch/TreatmentSearch.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAkB,CAAC;AACjE,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAuB,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAyC,CAAC;AA6B/E,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EACJ,EAAE,EACF,MAAM,EACN,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAI,EACJ,QAAQ,GACa;IACrB,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAC;IAClC,MAAM,cAAc,GAAG,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACzG,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACrE,iFAAiF;IACjF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ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AEL,QAAQ,IAAI,CACX,iBAAS,UAAU,YAChB,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC5B,KAAC,eAAe;gBACd,0EAA0E;oBAE1E,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;wBACf,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBAC9B,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACjB,CAAC,EACD,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,IAXb,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,CAY9C,CACH,CAAC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/** Simplified error object shape that mirros the Zod schema shape */
|
|
3
|
+
export type SchemaErrors<T> = T extends readonly (infer Item)[] ? {
|
|
4
|
+
[index: number]: SchemaErrors<Item> | undefined;
|
|
5
|
+
} : T extends object ? {
|
|
6
|
+
[K in keyof T]?: SchemaErrors<T[K]>;
|
|
7
|
+
} : string;
|
|
8
|
+
/**
|
|
9
|
+
* Return errors from Zod schema.parse in a friendlier shape
|
|
10
|
+
*/
|
|
11
|
+
export declare function schemaErrors<S extends z.ZodType<unknown, object>>(schema: S, input: z.input<S>): SchemaErrors<z.input<S>>;
|
|
12
|
+
//# sourceMappingURL=schemaErrors.d.ts.map
|