@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/src/styles.css
CHANGED
|
@@ -182,6 +182,31 @@
|
|
|
182
182
|
position: relative;
|
|
183
183
|
display: block;
|
|
184
184
|
}
|
|
185
|
+
/* The field's ×: where the spinner goes, the text kept clear of it. */
|
|
186
|
+
:where(.prx-input[data-clearable]) {
|
|
187
|
+
padding-right: 2.2em;
|
|
188
|
+
}
|
|
189
|
+
:where(.prx-input-clear) {
|
|
190
|
+
position: absolute;
|
|
191
|
+
right: 0.35em;
|
|
192
|
+
top: 50%;
|
|
193
|
+
transform: translateY(-50%);
|
|
194
|
+
display: grid;
|
|
195
|
+
place-items: center;
|
|
196
|
+
padding: 0.25em;
|
|
197
|
+
font: inherit;
|
|
198
|
+
color: inherit;
|
|
199
|
+
background: none;
|
|
200
|
+
border: 0;
|
|
201
|
+
border-radius: var(--prx-radius, 0.5em);
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
opacity: 0.7;
|
|
204
|
+
}
|
|
205
|
+
:where(.prx-input-clear:hover, .prx-input-clear:focus-visible) {
|
|
206
|
+
opacity: 1;
|
|
207
|
+
outline: 2px solid var(--prx-accent, AccentColor);
|
|
208
|
+
outline-offset: 0;
|
|
209
|
+
}
|
|
185
210
|
:where(.prx-spinner) {
|
|
186
211
|
position: absolute;
|
|
187
212
|
right: 0.65em;
|
|
@@ -280,7 +305,7 @@
|
|
|
280
305
|
padding: 0.35em;
|
|
281
306
|
line-height: 0;
|
|
282
307
|
}
|
|
283
|
-
:where(.prx-badge
|
|
308
|
+
:where(.prx-badge .prx-icon) {
|
|
284
309
|
width: 1em;
|
|
285
310
|
height: 1em;
|
|
286
311
|
}
|
|
@@ -428,6 +453,21 @@
|
|
|
428
453
|
align-items: center;
|
|
429
454
|
gap: 0.6em;
|
|
430
455
|
}
|
|
456
|
+
/* The open row's heading: a button (it reports its key), drawn as the row's text. */
|
|
457
|
+
:where(button.prx-option-row) {
|
|
458
|
+
font: inherit;
|
|
459
|
+
color: inherit;
|
|
460
|
+
background: none;
|
|
461
|
+
border: 0;
|
|
462
|
+
padding: 0;
|
|
463
|
+
width: 100%;
|
|
464
|
+
text-align: left;
|
|
465
|
+
cursor: pointer;
|
|
466
|
+
}
|
|
467
|
+
:where(button.prx-option-row:focus-visible) {
|
|
468
|
+
outline: 2px solid var(--prx-accent, AccentColor);
|
|
469
|
+
outline-offset: 2px;
|
|
470
|
+
}
|
|
431
471
|
:where(.prx-option-text) {
|
|
432
472
|
display: flex;
|
|
433
473
|
flex-direction: column;
|
|
@@ -524,7 +564,9 @@
|
|
|
524
564
|
}
|
|
525
565
|
|
|
526
566
|
:where(.prx-badge) {
|
|
527
|
-
display: inline-
|
|
567
|
+
display: inline-flex;
|
|
568
|
+
align-items: center;
|
|
569
|
+
gap: 0.3em;
|
|
528
570
|
font-size: 0.8em;
|
|
529
571
|
padding: 0.1em 0.6em;
|
|
530
572
|
border-radius: 999px;
|
|
@@ -535,7 +577,7 @@
|
|
|
535
577
|
color: inherit;
|
|
536
578
|
background: none;
|
|
537
579
|
border: 0;
|
|
538
|
-
padding: 0
|
|
580
|
+
padding: 0;
|
|
539
581
|
cursor: pointer;
|
|
540
582
|
opacity: 0.7;
|
|
541
583
|
}
|
|
@@ -117,16 +117,56 @@ export function buildingBlocksContract(brands: Brand[]): void {
|
|
|
117
117
|
delete (HTMLSelectElement.prototype as { showPicker?: unknown }).showPicker;
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
it("Input with onClear: a × named clearLabel while it has a value — not while it's empty or loading", () => {
|
|
121
|
+
const onClear = vi.fn();
|
|
122
|
+
const { rerender } = render(
|
|
123
|
+
<c.Input
|
|
124
|
+
label="Treatment"
|
|
125
|
+
value="Amoxicillin"
|
|
126
|
+
onChange={() => {}}
|
|
127
|
+
onClear={onClear}
|
|
128
|
+
clearLabel="Clear treatment"
|
|
129
|
+
/>,
|
|
130
|
+
);
|
|
131
|
+
fireEvent.click(screen.getByRole("button", { name: "Clear treatment" }));
|
|
132
|
+
expect(onClear).toHaveBeenCalled();
|
|
133
|
+
rerender(
|
|
134
|
+
<c.Input label="Treatment" value="" onChange={() => {}} onClear={onClear} clearLabel="Clear treatment" />,
|
|
135
|
+
);
|
|
136
|
+
expect(screen.queryByRole("button", { name: "Clear treatment" })).toBeNull();
|
|
137
|
+
rerender(
|
|
138
|
+
<c.Input
|
|
139
|
+
label="Treatment"
|
|
140
|
+
value="amox"
|
|
141
|
+
onChange={() => {}}
|
|
142
|
+
onClear={onClear}
|
|
143
|
+
clearLabel="Clear treatment"
|
|
144
|
+
loading
|
|
145
|
+
/>,
|
|
146
|
+
);
|
|
147
|
+
expect(screen.queryByRole("button", { name: "Clear treatment" })).toBeNull();
|
|
148
|
+
});
|
|
149
|
+
|
|
120
150
|
it("Input with loading is marked busy", () => {
|
|
121
151
|
render(<c.Input label="First name" value="Otto" onChange={() => {}} loading />);
|
|
122
152
|
expect(screen.getByLabelText("First name").getAttribute("aria-busy")).toBe("true");
|
|
123
153
|
});
|
|
124
154
|
|
|
155
|
+
it("Spinner alone (no label) is still a status", () => {
|
|
156
|
+
render(<c.Spinner />);
|
|
157
|
+
expect(screen.getByRole("status")).toBeTruthy();
|
|
158
|
+
});
|
|
159
|
+
|
|
125
160
|
it("Spinner says what's happening, as a status", () => {
|
|
126
161
|
render(<c.Spinner label="Saving…" />);
|
|
127
162
|
expect(screen.getByRole("status").textContent).toBe("Saving…");
|
|
128
163
|
});
|
|
129
164
|
|
|
165
|
+
it("Card with a label is a region by that name", () => {
|
|
166
|
+
render(<c.Card label="Amoxicillin">body</c.Card>);
|
|
167
|
+
expect(screen.getByRole("region", { name: "Amoxicillin" }).textContent).toBe("body");
|
|
168
|
+
});
|
|
169
|
+
|
|
130
170
|
it("CardFooter puts `start` before the actions", () => {
|
|
131
171
|
render(
|
|
132
172
|
<c.CardFooter start={<span>left</span>}>
|
|
@@ -250,7 +290,7 @@ export function buildingBlocksContract(brands: Brand[]): void {
|
|
|
250
290
|
expect(within(option).getByText("Last seen 2026").parentElement).not.toBe(name.parentElement);
|
|
251
291
|
});
|
|
252
292
|
|
|
253
|
-
it("OptionList: rows are buttons reporting their key; the active row is open
|
|
293
|
+
it("OptionList: rows are buttons reporting their key; the active row is open, its heading a button too, and shows its details", () => {
|
|
254
294
|
const onSelect = vi.fn();
|
|
255
295
|
const onKeyDown = vi.fn();
|
|
256
296
|
render(
|
|
@@ -269,7 +309,10 @@ export function buildingBlocksContract(brands: Brand[]): void {
|
|
|
269
309
|
</c.OptionList>,
|
|
270
310
|
);
|
|
271
311
|
expect(screen.getByText("Lisinopril details")).toBeTruthy();
|
|
272
|
-
|
|
312
|
+
const open = screen.getByRole("button", { name: /Lisinopril/, expanded: true });
|
|
313
|
+
expect(open.contains(screen.getByText("Lisinopril details"))).toBe(false); // the details sit beside it
|
|
314
|
+
fireEvent.click(open);
|
|
315
|
+
expect(onSelect).toHaveBeenCalledWith("a");
|
|
273
316
|
fireEvent.click(screen.getByRole("button", { name: /Amlodipine/ }));
|
|
274
317
|
expect(onSelect).toHaveBeenCalledWith("b");
|
|
275
318
|
fireEvent.click(screen.getByRole("button", { name: "Losartan Potassium Oral Tablet 50 MG" }));
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Change, ChangeOption } from "@photonhealth/client";
|
|
2
|
-
import { type SearchHandle } from "./search.tsx";
|
|
3
|
-
/**
|
|
4
|
-
* The drug search's results (search.tsx): the server's drug choices, grouped the way a prescriber decides —
|
|
5
|
-
* drug, then form, then strength (instead of one long list of product names), from the parts each option's
|
|
6
|
-
* treatment carries (display.ts). A drug's one form or one strength is said under its name, not offered as
|
|
7
|
-
* a chip; more than one, and its row says how many ("2 forms · 3 strengths") and opens to chips for them.
|
|
8
|
-
*
|
|
9
|
-
* Nothing is picked for the prescriber: no chip starts pressed. A drug with more than one form and strength opens
|
|
10
|
-
* to both — every strength it comes in — and they're picked in either order. A pick greys out what doesn't go with
|
|
11
|
-
* it in the other group (a form: the strengths it doesn't come in; a strength: the forms that don't come in it);
|
|
12
|
-
* picking it again takes it back. A greyed chip can still be picked: it drops the other group's pick, and that's
|
|
13
|
-
* the prescriber's to pick again — nothing is chosen for them. The pick that leaves nothing more to pick chooses
|
|
14
|
-
* the product: a drug with one product is its row (no chevron); otherwise the second chip — or the first, when it
|
|
15
|
-
* settles both (a form with one strength, a strength only one form comes in). While the choice saves (`chosen`),
|
|
16
|
-
* the picker stays as it was picked, a spinner on the drug's row where the chevron goes.
|
|
17
|
-
*
|
|
18
|
-
* One outline at a time — wherever focus is. The first drug starts open, and reads as selected (accent
|
|
19
|
-
* outline) only while focus is on the list — that's when the keys below act on it; in its chips, the chip
|
|
20
|
-
* focused has the outline. Keys as every search's (1–9 / 0 opens a drug; Option/Alt + the digit from
|
|
21
|
-
* Treatment), plus: ↓ ↑ (or J K, or Tab / Shift+Tab — past the last / first, Tab leaves the list) move between
|
|
22
|
-
* drugs, Home / End (or g / G) to the first / last, D to the next one; the list is one tab stop, so Tab never goes
|
|
23
|
-
* into a drug. Enter on a drug chooses one with one product, else goes to its first chips to pick from (from
|
|
24
|
-
* Treatment too); there, Tab moves between chips, F / S to the next form / strength chip, and Enter (or Space)
|
|
25
|
-
* picks the one focused; Esc goes back a step — from a chip to its drug, from the drug to Treatment. ← → leave the card (the card flow's: flow.ts).
|
|
26
|
-
* A few drugs for what's typed and Treatment puts focus on the first (`focus(true)`): typing carries on there
|
|
27
|
-
* until a key acts on the list (search.tsx). `handleRef` is how the Treatment field reaches the list.
|
|
28
|
-
*/
|
|
29
|
-
export interface TreatmentPickerHandle extends SearchHandle {
|
|
30
|
-
/** Enter on the open drug: choose it if it's one product, else go to its first chips. */
|
|
31
|
-
enter: () => void;
|
|
32
|
-
}
|
|
33
|
-
export declare function TreatmentPicker({ change, onChoose, busy, chosen, handleRef, onBack, }: {
|
|
34
|
-
change: Change;
|
|
35
|
-
onChoose?: (option: ChangeOption) => void;
|
|
36
|
-
busy?: boolean;
|
|
37
|
-
/** The product chosen, while its save runs: shown picked, with a spinner on its row; nothing else can be picked. */
|
|
38
|
-
chosen?: ChangeOption | null;
|
|
39
|
-
handleRef?: {
|
|
40
|
-
current: TreatmentPickerHandle | null;
|
|
41
|
-
};
|
|
42
|
-
/** Esc in the list: back to the field that searched (Treatment). */
|
|
43
|
-
onBack?: () => void;
|
|
44
|
-
}): import("react").JSX.Element | null;
|
|
45
|
-
//# sourceMappingURL=TreatmentPicker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreatmentPicker.d.ts","sourceRoot":"","sources":["../../src/components/TreatmentPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAoD,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAGnG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,yFAAyF;IACzF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oHAAoH;IACpH,MAAM,CAAC,EAAE,YAAY,G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CAAC;AAED,+GAA+G;AAC/G,SAAS,MAAM,CAAC,KAA6D,EAAE,MAAoB;IACjG,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE;QAC7C,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE;YACjD,KAAK,MAAM,QAAQ,IAAI,SAAS;gBAC9B,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM;oBAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;IACtH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { useComponents } from "../primitives/index.ts";
|
|
2
|
-
import type { Change, ChangeOption } from "@photonhealth/client";
|
|
3
|
-
import { describeTreatmentDrug, groupTreatmentOptions, orderedOptions, strengthsOf } from "./display.ts";
|
|
4
|
-
import { digitKey, edge, SHOWN, took, typesBack, vertical, type SearchHandle } from "./search.tsx";
|
|
5
|
-
import { useEffect, useRef, useState, type KeyboardEvent } from "react";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The drug search's results (search.tsx): the server's drug choices, grouped the way a prescriber decides —
|
|
9
|
-
* drug, then form, then strength (instead of one long list of product names), from the parts each option's
|
|
10
|
-
* treatment carries (display.ts). A drug's one form or one strength is said under its name, not offered as
|
|
11
|
-
* a chip; more than one, and its row says how many ("2 forms · 3 strengths") and opens to chips for them.
|
|
12
|
-
*
|
|
13
|
-
* Nothing is picked for the prescriber: no chip starts pressed. A drug with more than one form and strength opens
|
|
14
|
-
* to both — every strength it comes in — and they're picked in either order. A pick greys out what doesn't go with
|
|
15
|
-
* it in the other group (a form: the strengths it doesn't come in; a strength: the forms that don't come in it);
|
|
16
|
-
* picking it again takes it back. A greyed chip can still be picked: it drops the other group's pick, and that's
|
|
17
|
-
* the prescriber's to pick again — nothing is chosen for them. The pick that leaves nothing more to pick chooses
|
|
18
|
-
* the product: a drug with one product is its row (no chevron); otherwise the second chip — or the first, when it
|
|
19
|
-
* settles both (a form with one strength, a strength only one form comes in). While the choice saves (`chosen`),
|
|
20
|
-
* the picker stays as it was picked, a spinner on the drug's row where the chevron goes.
|
|
21
|
-
*
|
|
22
|
-
* One outline at a time — wherever focus is. The first drug starts open, and reads as selected (accent
|
|
23
|
-
* outline) only while focus is on the list — that's when the keys below act on it; in its chips, the chip
|
|
24
|
-
* focused has the outline. Keys as every search's (1–9 / 0 opens a drug; Option/Alt + the digit from
|
|
25
|
-
* Treatment), plus: ↓ ↑ (or J K, or Tab / Shift+Tab — past the last / first, Tab leaves the list) move between
|
|
26
|
-
* drugs, Home / End (or g / G) to the first / last, D to the next one; the list is one tab stop, so Tab never goes
|
|
27
|
-
* into a drug. Enter on a drug chooses one with one product, else goes to its first chips to pick from (from
|
|
28
|
-
* Treatment too); there, Tab moves between chips, F / S to the next form / strength chip, and Enter (or Space)
|
|
29
|
-
* picks the one focused; Esc goes back a step — from a chip to its drug, from the drug to Treatment. ← → leave the card (the card flow's: flow.ts).
|
|
30
|
-
* A few drugs for what's typed and Treatment puts focus on the first (`focus(true)`): typing carries on there
|
|
31
|
-
* until a key acts on the list (search.tsx). `handleRef` is how the Treatment field reaches the list.
|
|
32
|
-
*/
|
|
33
|
-
export interface TreatmentPickerHandle extends SearchHandle {
|
|
34
|
-
/** Enter on the open drug: choose it if it's one product, else go to its first chips. */
|
|
35
|
-
enter: () => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type Chips = "form" | "strength";
|
|
39
|
-
|
|
40
|
-
export function TreatmentPicker({
|
|
41
|
-
change,
|
|
42
|
-
onChoose,
|
|
43
|
-
busy,
|
|
44
|
-
chosen,
|
|
45
|
-
handleRef,
|
|
46
|
-
onBack,
|
|
47
|
-
}: {
|
|
48
|
-
change: Change;
|
|
49
|
-
onChoose?: (option: ChangeOption) => void;
|
|
50
|
-
busy?: boolean;
|
|
51
|
-
/** The product chosen, while its save runs: shown picked, with a spinner on its row; nothing else can be picked. */
|
|
52
|
-
chosen?: ChangeOption | null;
|
|
53
|
-
handleRef?: { current: TreatmentPickerHandle | null };
|
|
54
|
-
/** Esc in the list: back to the field that searched (Treatment). */
|
|
55
|
-
onBack?: () => void;
|
|
56
|
-
}) {
|
|
57
|
-
const { Button, OptionList, Stack, ToggleGroup } = useComponents();
|
|
58
|
-
const typed = change.inputText;
|
|
59
|
-
const all = groupTreatmentOptions(orderedOptions({ options: change.options.filter((o) => o.path) }, typed));
|
|
60
|
-
const [showAll, setShowAll] = useState(false);
|
|
61
|
-
const drugs = showAll ? all : all.slice(0, SHOWN);
|
|
62
|
-
// The open drug, and its form and strength as the prescriber picks them (null: not yet).
|
|
63
|
-
const [pick, setPick] = useState<{ drug: number; form: number | null; strength: string | null }>({
|
|
64
|
-
drug: 0,
|
|
65
|
-
form: null,
|
|
66
|
-
strength: null,
|
|
67
|
-
});
|
|
68
|
-
const root = useRef<HTMLDivElement>(null);
|
|
69
|
-
const list = () => root.current?.querySelector<HTMLElement>('[tabindex="0"]');
|
|
70
|
-
const chips = (group: Chips) => [
|
|
71
|
-
...(root.current?.querySelectorAll<HTMLElement>(`[data-chips="${group}"] button:not(:disabled)`) ?? []),
|
|
72
|
-
];
|
|
73
|
-
// Focus is on the list itself (not a chip or a row): the open drug has the outline.
|
|
74
|
-
const [onList, setOnList] = useState(false);
|
|
75
|
-
// Focus is in the open drug's chips (Enter took it there): Tab moves between them.
|
|
76
|
-
const [inChips, setInChips] = useState(false);
|
|
77
|
-
// Focus was put here for the prescriber, mid-typing: keys that type go back to Treatment (typesBack).
|
|
78
|
-
const typing = useRef(false);
|
|
79
|
-
// Where focus goes once the next render is in: the list, or a chip (the other group's, once one is picked).
|
|
80
|
-
const focusNext = useRef<"list" | { group: Chips; at: number } | null>(null);
|
|
81
|
-
const firstRender = useRef(true);
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
// One tab stop — the list: Tab moves between drugs (onKeyDown), not into one. Its rows and chips are reached
|
|
84
|
-
// with the keys; once Enter takes focus into the chips, Tab moves between them.
|
|
85
|
-
list()
|
|
86
|
-
?.querySelectorAll<HTMLElement>("button")
|
|
87
|
-
.forEach((button) => (button.tabIndex = inChips && button.closest("[data-chips]") ? 0 : -1));
|
|
88
|
-
const next = focusNext.current;
|
|
89
|
-
focusNext.current = null;
|
|
90
|
-
if (next === "list") list()?.focus();
|
|
91
|
-
else if (next) chips(next.group)[next.at]?.focus();
|
|
92
|
-
else if (!firstRender.current) {
|
|
93
|
-
// Opening a drug replaces the row button that had focus; keep focus in the list so keys still work.
|
|
94
|
-
// Never on first render (focus stays wherever the prescriber is).
|
|
95
|
-
const active = document.activeElement;
|
|
96
|
-
if (!active || active === document.body || !active.isConnected) list()?.focus();
|
|
97
|
-
}
|
|
98
|
-
firstRender.current = false;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// What's shown picked: the prescriber's picks — or, while a choice saves, the product chosen.
|
|
102
|
-
const view = (chosen && locate(drugs, chosen)) || pick;
|
|
103
|
-
const drugAt = Math.min(view.drug, drugs.length - 1);
|
|
104
|
-
const drug = drugs[drugAt];
|
|
105
|
-
// One form is the drug's form; with more, none until it's picked.
|
|
106
|
-
const formAt = drug?.forms.length === 1 ? 0 : view.form;
|
|
107
|
-
// The product a form comes in at a strength, if it does.
|
|
108
|
-
const productOf = (formIndex: number, strength: string) =>
|
|
109
|
-
drug?.forms[formIndex]?.strengths.find((s) => s.label === strength)?.option ?? null;
|
|
110
|
-
// The forms a strength could be: those that come in it — of the one picked, once it is.
|
|
111
|
-
const formsFor = (strength: string) =>
|
|
112
|
-
drug?.forms.flatMap((_, i) => ((formAt === null || i === formAt) && productOf(i, strength) ? [i] : [])) ?? [];
|
|
113
|
-
|
|
114
|
-
// Busy, or a choice saving: nothing can be picked (a saving choice still looks as picked, not disabled).
|
|
115
|
-
const disabled = (busy && !chosen) || !onChoose;
|
|
116
|
-
const locked = disabled || Boolean(chosen);
|
|
117
|
-
const choose = (option: ChangeOption) => !locked && onChoose?.(option);
|
|
118
|
-
// A drug with one product: its row is the choice.
|
|
119
|
-
const onlyOption = (i: number) => {
|
|
120
|
-
const forms = drugs[i]!.forms;
|
|
121
|
-
return forms.length === 1 && forms[0]!.strengths.length === 1 ? forms[0]!.strengths[0]!.option : null;
|
|
122
|
-
};
|
|
123
|
-
const openDrug = (i: number) => {
|
|
124
|
-
if (chosen) return;
|
|
125
|
-
setPick({ drug: i, form: null, strength: null });
|
|
126
|
-
focusNext.current = "list";
|
|
127
|
-
};
|
|
128
|
-
// The first chip in a group that goes with the other group's pick (`form` / `strength`; null: nothing picked).
|
|
129
|
-
const firstFitting = (group: Chips, form: number | null, strength: string | null) => {
|
|
130
|
-
if (!drug) return 0;
|
|
131
|
-
const at =
|
|
132
|
-
group === "form"
|
|
133
|
-
? drug.forms.findIndex((_, i) => strength === null || productOf(i, strength))
|
|
134
|
-
: strengthsOf(drug).findIndex((s) => form === null || productOf(form, s));
|
|
135
|
-
return Math.max(0, at);
|
|
136
|
-
};
|
|
137
|
-
const enter = () => {
|
|
138
|
-
if (!drug || chosen) return;
|
|
139
|
-
const only = onlyOption(drugAt);
|
|
140
|
-
if (only) return choose(only);
|
|
141
|
-
const group = drug.forms.length > 1 && pick.form === null ? "form" : "strength";
|
|
142
|
-
chips(group)[firstFitting(group, formAt, pick.strength)]?.focus();
|
|
143
|
-
};
|
|
144
|
-
const pickForm = (i: number) => {
|
|
145
|
-
if (locked) return;
|
|
146
|
-
if (pick.form === i) {
|
|
147
|
-
setPick({ ...pick, form: null }); // picked again: taken back
|
|
148
|
-
focusNext.current = { group: "form", at: i };
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (pick.strength !== null && !productOf(i, pick.strength)) {
|
|
152
|
-
// Greyed (not in the strength picked): the strength goes, and it's the prescriber's to pick again.
|
|
153
|
-
setPick({ drug: drugAt, form: i, strength: null });
|
|
154
|
-
focusNext.current = { group: "strength", at: firstFitting("strength", i, null) };
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const strengths = drug!.forms[i]!.strengths;
|
|
158
|
-
const product =
|
|
159
|
-
pick.strength !== null ? productOf(i, pick.strength) : strengths.length === 1 ? strengths[0]!.option : null;
|
|
160
|
-
setPick({ ...pick, drug: drugAt, form: i });
|
|
161
|
-
if (product) choose(product);
|
|
162
|
-
else focusNext.current = { group: "strength", at: firstFitting("strength", i, null) };
|
|
163
|
-
};
|
|
164
|
-
const pickStrength = (strength: string) => {
|
|
165
|
-
if (locked) return;
|
|
166
|
-
const at = strengthsOf(drug!).indexOf(strength);
|
|
167
|
-
if (pick.strength === strength) {
|
|
168
|
-
setPick({ ...pick, strength: null }); // picked again: taken back
|
|
169
|
-
focusNext.current = { group: "strength", at };
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (drug!.forms.length > 1 && pick.form !== null && !productOf(pick.form, strength)) {
|
|
173
|
-
// Greyed (the form picked doesn't come in it): the form goes, and it's the prescriber's to pick again.
|
|
174
|
-
setPick({ drug: drugAt, form: null, strength });
|
|
175
|
-
focusNext.current = { group: "form", at: firstFitting("form", null, strength) };
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
const forms = formsFor(strength);
|
|
179
|
-
setPick({ ...pick, drug: drugAt, strength });
|
|
180
|
-
if (forms.length === 1) choose(productOf(forms[0]!, strength)!);
|
|
181
|
-
else focusNext.current = { group: "form", at: firstFitting("form", null, strength) };
|
|
182
|
-
};
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
if (!handleRef) return;
|
|
185
|
-
handleRef.current = {
|
|
186
|
-
total: all.length,
|
|
187
|
-
enter,
|
|
188
|
-
focus: (fromTyping) => {
|
|
189
|
-
typing.current = Boolean(fromTyping && onBack);
|
|
190
|
-
list()?.focus();
|
|
191
|
-
return true;
|
|
192
|
-
},
|
|
193
|
-
pick: (index) => {
|
|
194
|
-
if (index >= drugs.length) return false;
|
|
195
|
-
openDrug(index);
|
|
196
|
-
return true;
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
return () => {
|
|
200
|
-
handleRef.current = null;
|
|
201
|
-
};
|
|
202
|
-
});
|
|
203
|
-
if (!drug) return null;
|
|
204
|
-
const strengths = strengthsOf(drug);
|
|
205
|
-
// The drug's strengths differ by form (the row can't say one): a form with one strength says it on its chip.
|
|
206
|
-
const strengthByForm = strengths.length > 1;
|
|
207
|
-
// F / S: the next chip in that group after the one focused (the first, from anywhere else).
|
|
208
|
-
const nextChip = (group: Chips) => {
|
|
209
|
-
const buttons = chips(group);
|
|
210
|
-
if (!buttons.length) return false;
|
|
211
|
-
buttons[(buttons.indexOf(document.activeElement as HTMLElement) + 1) % buttons.length]!.focus();
|
|
212
|
-
return true;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const onKeyDown = (e: KeyboardEvent<HTMLElement>) => {
|
|
216
|
-
if (typing.current && typesBack(e)) return onBack?.(); // not taken: the browser types it in Treatment
|
|
217
|
-
typing.current = false;
|
|
218
|
-
if (e.metaKey || e.ctrlKey) return;
|
|
219
|
-
const digit = digitKey(e);
|
|
220
|
-
if (e.altKey && digit < 0) return;
|
|
221
|
-
const key = e.key.toLowerCase();
|
|
222
|
-
const atList = e.target === e.currentTarget;
|
|
223
|
-
if (digit >= 0 && digit < drugs.length) openDrug(digit);
|
|
224
|
-
else if (key === "d") openDrug((drugAt + 1) % drugs.length);
|
|
225
|
-
else if (vertical(e)) openDrug(Math.max(0, Math.min(drugs.length - 1, drugAt + vertical(e))));
|
|
226
|
-
else if (edge(e)) openDrug(edge(e) === "first" ? 0 : drugs.length - 1);
|
|
227
|
-
else if (e.key === "Tab" && atList && !e.altKey) {
|
|
228
|
-
// The next / previous drug — past the last / first, on out of the list (the browser's Tab).
|
|
229
|
-
const to = drugAt + (e.shiftKey ? -1 : 1);
|
|
230
|
-
if (to < 0 || to >= drugs.length) return;
|
|
231
|
-
openDrug(to);
|
|
232
|
-
} else if (e.key === "Escape" && !atList) list()?.focus();
|
|
233
|
-
else if (e.key === "Escape" && onBack) onBack();
|
|
234
|
-
else if (key === "f" || key === "s") {
|
|
235
|
-
if (!nextChip(key === "f" ? "form" : "strength")) return;
|
|
236
|
-
}
|
|
237
|
-
// Enter on the list is on the open drug. On a chip or a row it's that button's own click.
|
|
238
|
-
else if (e.key === "Enter" && atList) enter();
|
|
239
|
-
else return;
|
|
240
|
-
took(e);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
return (
|
|
244
|
-
<div
|
|
245
|
-
ref={root}
|
|
246
|
-
style={{ paddingBottom: "0.75em" }}
|
|
247
|
-
onFocus={(e) => {
|
|
248
|
-
setOnList(e.target === list());
|
|
249
|
-
setInChips(Boolean((e.target as Element).closest("[data-chips]")));
|
|
250
|
-
}}
|
|
251
|
-
onBlur={(e) => {
|
|
252
|
-
if (root.current?.contains(e.relatedTarget)) return;
|
|
253
|
-
setOnList(false);
|
|
254
|
-
setInChips(false);
|
|
255
|
-
typing.current = false;
|
|
256
|
-
}}
|
|
257
|
-
>
|
|
258
|
-
<Stack gap="3">
|
|
259
|
-
<OptionList
|
|
260
|
-
label="Pick a treatment"
|
|
261
|
-
disabled={disabled}
|
|
262
|
-
activeKey={String(drugAt)}
|
|
263
|
-
activeSelected={onList}
|
|
264
|
-
onKeyDown={onKeyDown}
|
|
265
|
-
options={drugs.map((d, i) => {
|
|
266
|
-
const only = onlyOption(i);
|
|
267
|
-
return {
|
|
268
|
-
key: String(i),
|
|
269
|
-
label: d.name,
|
|
270
|
-
// Open, its chips say its forms and strengths; closed, how many.
|
|
271
|
-
description: describeTreatmentDrug(d, i !== drugAt) ?? undefined,
|
|
272
|
-
// The row chooses the product, so it's named as the product.
|
|
273
|
-
ariaLabel: only?.displayName,
|
|
274
|
-
direct: Boolean(only),
|
|
275
|
-
loading: Boolean(chosen) && i === drugAt,
|
|
276
|
-
};
|
|
277
|
-
})}
|
|
278
|
-
onSelect={(key) => {
|
|
279
|
-
if (locked) return;
|
|
280
|
-
const only = onlyOption(Number(key));
|
|
281
|
-
if (only) choose(only);
|
|
282
|
-
else openDrug(Number(key));
|
|
283
|
-
}}
|
|
284
|
-
>
|
|
285
|
-
{drug.forms.length > 1 && (
|
|
286
|
-
<div data-chips="form" style={{ display: "contents" }}>
|
|
287
|
-
<ToggleGroup
|
|
288
|
-
label="Form"
|
|
289
|
-
disabled={disabled}
|
|
290
|
-
value={formAt === null ? null : String(formAt)}
|
|
291
|
-
onChange={(value) => pickForm(Number(value))}
|
|
292
|
-
options={drug.forms.map((f, i) => {
|
|
293
|
-
const only = f.strengths.length === 1 ? f.strengths[0]! : null;
|
|
294
|
-
// With the strength picked (or its only one), the chip chooses the product: named as the product.
|
|
295
|
-
const product = view.strength !== null ? productOf(i, view.strength) : (only?.option ?? null);
|
|
296
|
-
return {
|
|
297
|
-
value: String(i),
|
|
298
|
-
label: f.label || "As listed",
|
|
299
|
-
detail: (only && strengthByForm && only.label) || undefined,
|
|
300
|
-
ariaLabel: product?.displayName,
|
|
301
|
-
// Not in the strength picked: greyed, still pickable (it drops the strength).
|
|
302
|
-
muted: view.strength !== null && !product,
|
|
303
|
-
};
|
|
304
|
-
})}
|
|
305
|
-
/>
|
|
306
|
-
</div>
|
|
307
|
-
)}
|
|
308
|
-
{strengths.length > 1 && (
|
|
309
|
-
<div data-chips="strength" style={{ display: "contents" }}>
|
|
310
|
-
<ToggleGroup
|
|
311
|
-
label="Strength"
|
|
312
|
-
disabled={disabled}
|
|
313
|
-
value={view.strength === null ? null : String(strengths.indexOf(view.strength))}
|
|
314
|
-
onChange={(value) => pickStrength(strengths[Number(value)]!)}
|
|
315
|
-
options={strengths.map((strength, i) => {
|
|
316
|
-
const forms = formsFor(strength);
|
|
317
|
-
// In one form (the one picked, or the only one with it), the chip chooses the product: named as it.
|
|
318
|
-
const product = forms.length === 1 ? productOf(forms[0]!, strength) : null;
|
|
319
|
-
return {
|
|
320
|
-
value: String(i),
|
|
321
|
-
label: strength || "As listed",
|
|
322
|
-
ariaLabel: product?.displayName,
|
|
323
|
-
// The form picked doesn't come in it: greyed, still pickable (it drops the form).
|
|
324
|
-
muted: forms.length === 0,
|
|
325
|
-
};
|
|
326
|
-
})}
|
|
327
|
-
/>
|
|
328
|
-
</div>
|
|
329
|
-
)}
|
|
330
|
-
</OptionList>
|
|
331
|
-
{all.length > drugs.length && (
|
|
332
|
-
<div>
|
|
333
|
-
<Button variant="ghost" onClick={() => setShowAll(true)}>
|
|
334
|
-
Show {all.length - drugs.length} more
|
|
335
|
-
</Button>
|
|
336
|
-
</div>
|
|
337
|
-
)}
|
|
338
|
-
</Stack>
|
|
339
|
-
</div>
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/** Where a product is among the drugs: its drug, its form, its strength — as picks. Null if it isn't there. */
|
|
344
|
-
function locate(drugs: ReturnType<typeof groupTreatmentOptions<ChangeOption>>, option: ChangeOption) {
|
|
345
|
-
for (const [drug, { forms }] of drugs.entries())
|
|
346
|
-
for (const [form, { strengths }] of forms.entries())
|
|
347
|
-
for (const strength of strengths)
|
|
348
|
-
if (strength.option === option) return { drug, form: forms.length > 1 ? form : null, strength: strength.label };
|
|
349
|
-
return null;
|
|
350
|
-
}
|