@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Display formatting, plus the one normalisation we send back (phone → E.164). */
|
|
2
|
-
/** "+
|
|
2
|
+
/** "+13175550147" / "3175550147" → "+1 (317) 555-0147"; anything else is shown as given. */
|
|
3
3
|
export declare function formatPhone(phone: string | null | undefined): string;
|
|
4
4
|
/** Native validation for type="tel": a US number, punctuated any common way (+1 optional). */
|
|
5
5
|
export declare const PHONE_PATTERN: string;
|
|
6
|
-
/** "(317)
|
|
6
|
+
/** "(317) 555-0147" → "+13175550147" (what network-api stores); non-US kept as typed; blank → undefined. */
|
|
7
7
|
export declare function toE164(phone: string): string | undefined;
|
|
8
8
|
/** Whole years old on `today` for an ISO date of birth; null if there's no valid DOB. */
|
|
9
9
|
export declare function ageOn(dob: string | null | undefined, today?: Date): number | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Display formatting, plus the one normalisation we send back (phone → E.164). */
|
|
2
|
-
/** "+
|
|
2
|
+
/** "+13175550147" / "3175550147" → "+1 (317) 555-0147"; anything else is shown as given. */
|
|
3
3
|
export function formatPhone(phone) {
|
|
4
4
|
if (!phone)
|
|
5
5
|
return "";
|
|
@@ -9,7 +9,7 @@ export function formatPhone(phone) {
|
|
|
9
9
|
}
|
|
10
10
|
/** Native validation for type="tel": a US number, punctuated any common way (+1 optional). */
|
|
11
11
|
export const PHONE_PATTERN = String.raw `\+?1?[\s.\-]*\(?\d{3}\)?[\s.\-]*\d{3}[\s.\-]*\d{4}`;
|
|
12
|
-
/** "(317)
|
|
12
|
+
/** "(317) 555-0147" → "+13175550147" (what network-api stores); non-US kept as typed; blank → undefined. */
|
|
13
13
|
export function toE164(phone) {
|
|
14
14
|
const trimmed = phone.trim();
|
|
15
15
|
if (!trimmed)
|
|
@@ -2,5 +2,5 @@ export * from "./ChangeList.tsx";
|
|
|
2
2
|
export { PhotonPatient, type PhotonPatientProps } from "./PhotonPatient.tsx";
|
|
3
3
|
export { PhotonPrescription, type PhotonPrescriptionProps } from "./PhotonPrescription.tsx";
|
|
4
4
|
export * from "./PhotonOrder.tsx";
|
|
5
|
-
export * from "./TreatmentPicker.tsx";
|
|
5
|
+
export * from "./prescription/TreatmentSearch/TreatmentPicker.tsx";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,cAAc,mBAAmB,CAAC;AAClC,cAAc,oDAAoD,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -2,5 +2,5 @@ export * from "./ChangeList.js";
|
|
|
2
2
|
export { PhotonPatient } from "./PhotonPatient.js";
|
|
3
3
|
export { PhotonPrescription } from "./PhotonPrescription.js";
|
|
4
4
|
export * from "./PhotonOrder.js";
|
|
5
|
-
export * from "./TreatmentPicker.js";
|
|
5
|
+
export * from "./prescription/TreatmentSearch/TreatmentPicker.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAkB,CAAC;AACjC,OAAO,EAAE,aAAa,EAA2B,MAAM,oBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAgC,MAAM,yBAA0B,CAAC;AAC5F,cAAc,kBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAkB,CAAC;AACjC,OAAO,EAAE,aAAa,EAA2B,MAAM,oBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAgC,MAAM,yBAA0B,CAAC;AAC5F,cAAc,kBAAmB,CAAC;AAClC,cAAc,mDAAoD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PrescriptionRecord } from "@photonhealth/client";
|
|
2
|
+
export interface DraftOrderPromptProps {
|
|
3
|
+
/** The patient's draft order: what's already on it, shown read-only until the prescriber decides. */
|
|
4
|
+
draft: {
|
|
5
|
+
prescriptions: readonly PrescriptionRecord[];
|
|
6
|
+
};
|
|
7
|
+
/** Go on with this draft: its prescriptions become the order's, and what's added goes on it. */
|
|
8
|
+
onContinue: () => void | Promise<unknown>;
|
|
9
|
+
/** Write a new order instead: the draft's prescriptions come off it, and the order starts over. */
|
|
10
|
+
onStartNew: () => void | Promise<unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A patient's draft order, found when they're chosen: its prescriptions, each on its own card as the order's lines
|
|
14
|
+
* are, then the question — continue it, or start a new order. Nothing changes until one is picked. Renders cards
|
|
15
|
+
* only, for PhotonOrder's flow.
|
|
16
|
+
*/
|
|
17
|
+
export declare function DraftOrderPrompt({ draft, onContinue, onStartNew }: DraftOrderPromptProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=DraftOrderPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraftOrderPrompt.d.ts","sourceRoot":"","sources":["../../../src/components/order/DraftOrderPrompt.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO/D,MAAM,WAAW,qBAAqB;IACpC,qGAAqG;IACrG,KAAK,EAAE;QAAE,aAAa,EAAE,SAAS,kBAAkB,EAAE,CAAA;KAAE,CAAC;IACxD,gGAAgG;IAChG,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,mGAAmG;IACnG,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,qBAAqB,+BA2DxF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useComponents } from "../../primitives/index.js";
|
|
4
|
+
import { treatmentHeading } from "../display.js";
|
|
5
|
+
import { cardProps, focusProps } from "../flow.js";
|
|
6
|
+
import { ReadOnlyRx, StatusBadge } from "../prescription/PrescriptionCard.js";
|
|
7
|
+
/**
|
|
8
|
+
* A patient's draft order, found when they're chosen: its prescriptions, each on its own card as the order's lines
|
|
9
|
+
* are, then the question — continue it, or start a new order. Nothing changes until one is picked. Renders cards
|
|
10
|
+
* only, for PhotonOrder's flow.
|
|
11
|
+
*/
|
|
12
|
+
export function DraftOrderPrompt({ draft, onContinue, onStartNew }) {
|
|
13
|
+
const { Button, Card, CardBody, CardFooter, CardHeader, Row, Stack, Text } = useComponents();
|
|
14
|
+
// Which choice is in flight: that button spins, and neither can be pressed again until it settles.
|
|
15
|
+
const [choosing, setChoosing] = useState(null);
|
|
16
|
+
const choose = (which, act) => {
|
|
17
|
+
setChoosing(which);
|
|
18
|
+
// A failure lands on the order (snapshot.error), where the card shows it.
|
|
19
|
+
void new Promise((resolve) => resolve(act())).catch(() => { }).finally(() => setChoosing(null));
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs(_Fragment, { children: [draft.prescriptions.map((rx) => {
|
|
22
|
+
const heading = treatmentHeading(rx.treatment.name, rx.treatment);
|
|
23
|
+
return (_jsx("div", { ...cardProps, children: _jsxs(Card, { divided: true, label: heading.title, children: [_jsx(CardHeader, { title: heading.title, description: heading.detail }), _jsx(CardBody, { children: _jsx(ReadOnlyRx, { rx: rx, status: _jsx(StatusBadge, { rx: rx }) }) })] }) }, rx.id));
|
|
24
|
+
}), _jsx("div", { ...cardProps, children: _jsx(Card, { children: _jsx(CardFooter, { start: _jsxs(Stack, { gap: "3", children: [_jsx(Text, { children: "Would you like to continue this order?" }), _jsxs(Row, { gap: "2", children: [_jsx("span", { ...focusProps, children: _jsx(Button, { loading: choosing === "continue", disabled: choosing !== null, onClick: () => choose("continue", onContinue), children: "Continue" }) }), _jsx(Button, { variant: "secondary", loading: choosing === "new", disabled: choosing !== null, onClick: () => choose("new", onStartNew), children: "Start a new order" })] })] }) }) }) })] }));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=DraftOrderPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraftOrderPrompt.js","sourceRoot":"","sources":["../../../src/components/order/DraftOrderPrompt.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,aAAa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WAAW,EAAE,OAAO,CAAC,MAAM,GAAI,EACjE,KAAC,QAAQ,cACP,KAAC,UAAU,IAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAC,WAAW,IAAC,EAAE,EAAE,EAAE,GAAI,GAAI,GAC9C,IACN,IANC,EAAE,CAAC,EAAE,CAOT,CACP,CAAC;YACJ,CAAC,CAAC,EACF,iBAAS,SAAS,YAChB,KAAC,IAAI,cAGH,KAAC,UAAU,IACT,KAAK,EACH,MAAC,KAAK,IAAC,GAAG,EAAC,GAAG,aACZ,KAAC,IAAI,yDAA8C,EACnD,MAAC,GAAG,IAAC,GAAG,EAAC,GAAG,aACV,kBAAU,UAAU,YAClB,KAAC,MAAM,IACL,OAAO,EAAE,QAAQ,KAAK,UAAU,EAChC,QAAQ,EAAE,QAAQ,KAAK,IAAI,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,yBAGtC,GACJ,EACP,KAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,QAAQ,KAAK,KAAK,EAC3B,QAAQ,EAAE,QAAQ,KAAK,IAAI,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,kCAGjC,IACL,IACA,GAEV,GACG,GACH,IACL,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Benefits.d.ts","sourceRoot":"","sources":["../../../src/components/patient/Benefits.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Benefits.d.ts","sourceRoot":"","sources":["../../../src/components/patient/Benefits.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,eAAe,CAAC,EAC9B,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"}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useComponents } from "../../primitives/index.js";
|
|
5
5
|
import { noAutofill } from "./fields.js";
|
|
6
|
+
import { TrackedField } from "../../analytics/fieldInteraction.js";
|
|
6
7
|
/** Insurance on file: chips, "Add insurance" (BIN + member id required, PCN / group optional), "No insurance". */
|
|
7
8
|
export function BenefitsSection({ benefits, saving, onAdd, onRemove, onNone, }) {
|
|
8
9
|
const { Badge, Button, Grid, Input, Row, Stack, Text } = useComponents();
|
|
@@ -42,6 +43,6 @@ export function BenefitsSection({ benefits, saving, onAdd, onRemove, onNone, })
|
|
|
42
43
|
groupId: groupId.trim() || undefined,
|
|
43
44
|
});
|
|
44
45
|
reset();
|
|
45
|
-
}, children: _jsxs(Stack, { gap: "2", 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" })] })] }) }))] }));
|
|
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" })] })] }) }))] }));
|
|
46
47
|
}
|
|
47
48
|
//# sourceMappingURL=Benefits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Benefits.js","sourceRoot":"","sources":["../../../src/components/patient/Benefits.tsx"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,M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AC,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"}
|
|
@@ -16,7 +16,7 @@ export declare const diagnosisRef: (text: string) => {
|
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* A clinical list (allergies, medications, diagnoses): chips for what's on file, plus "Add …" and "No …"
|
|
19
|
-
* (records none — `confirmedNone` is the record's `[]`; network-api can't read it back yet
|
|
19
|
+
* (records none — `confirmedNone` is the record's `[]`; network-api can't read it back yet).
|
|
20
20
|
*
|
|
21
21
|
* "Add …" is a search field (search.tsx) — type-ahead, its spinner, its results (the server's choices, e.g.
|
|
22
22
|
* which penicillin) and keys. Each search is an add, by design: what's typed, once it matches one entry, is that
|
|
@@ -26,8 +26,9 @@ export declare const diagnosisRef: (text: string) => {
|
|
|
26
26
|
export declare function ClinicalList<T extends {
|
|
27
27
|
id: string;
|
|
28
28
|
name: string;
|
|
29
|
-
}>({ label, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, pickedNames, saving, onAdd, onRemove, onNone, choices, problems, onChoose, }: {
|
|
29
|
+
}>({ label, fieldName, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, pickedNames, saving, onAdd, onRemove, onNone, choices, problems, onChoose, }: {
|
|
30
30
|
label: string;
|
|
31
|
+
fieldName: "allergies" | "medications" | "diagnoses";
|
|
31
32
|
items: T[];
|
|
32
33
|
tone: "warning" | "neutral";
|
|
33
34
|
addLabel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clinical.d.ts","sourceRoot":"","sources":["../../../src/components/patient/Clinical.tsx"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Clinical.d.ts","sourceRoot":"","sources":["../../../src/components/patient/Clinical.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,qGAAqG;AACrG,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM;;;;;;CAC6D,CAAC;AAEvG;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,I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
import { afterPress, searchKeys, useTypeAhead } from "../search.js";
|
|
9
9
|
import { noAutofill } from "./fields.js";
|
|
10
|
+
import { TrackedField } from "../../analytics/fieldInteraction.js";
|
|
10
11
|
/** Which clinical list a server change belongs to (keys look like "clinical.allergies.add.0" / "allergies.0"). */
|
|
11
12
|
const CLINICAL_SECTIONS = ["allergies", "medications", "diagnoses"];
|
|
12
13
|
export const sectionOf = (key) => CLINICAL_SECTIONS.find((section) => key.includes(section)) ?? null;
|
|
@@ -21,14 +22,14 @@ export const withoutInline = (changes) => ({
|
|
|
21
22
|
export const diagnosisRef = (text) => /^[A-TV-Z]\d{2}(\.[0-9A-Z]{1,4})?$/i.test(text) ? { icd10Code: text.toUpperCase() } : { name: text };
|
|
22
23
|
/**
|
|
23
24
|
* A clinical list (allergies, medications, diagnoses): chips for what's on file, plus "Add …" and "No …"
|
|
24
|
-
* (records none — `confirmedNone` is the record's `[]`; network-api can't read it back yet
|
|
25
|
+
* (records none — `confirmedNone` is the record's `[]`; network-api can't read it back yet).
|
|
25
26
|
*
|
|
26
27
|
* "Add …" is a search field (search.tsx) — type-ahead, its spinner, its results (the server's choices, e.g.
|
|
27
28
|
* which penicillin) and keys. Each search is an add, by design: what's typed, once it matches one entry, is that
|
|
28
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,
|
|
29
30
|
* leaving it, a choice) is answered. Escape closes it.
|
|
30
31
|
*/
|
|
31
|
-
export function ClinicalList({ label, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, pickedNames, saving, onAdd, onRemove, onNone, choices, problems = [], onChoose, }) {
|
|
32
|
+
export function ClinicalList({ label, fieldName, items, tone, addLabel, noneLabel, noneAction, confirmedNone, unknownLabel, pickedNames, saving, onAdd, onRemove, onNone, choices, problems = [], onChoose, }) {
|
|
32
33
|
const { Badge, Button, Input, Row, Stack, Text } = useComponents();
|
|
33
34
|
const [adding, setAdding] = useState(false);
|
|
34
35
|
const [value, setValue] = useState("");
|
|
@@ -95,23 +96,23 @@ export function ClinicalList({ label, items, tone, addLabel, noneLabel, noneActi
|
|
|
95
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) => {
|
|
96
97
|
const name = item.name && item.name !== item.id ? item.name : (pickedNames[item.id] ?? unknownLabel);
|
|
97
98
|
return (_jsx(Badge, { tone: tone, onRemove: () => onRemove(item), removeLabel: `Remove ${name}`, children: name }, item.id));
|
|
98
|
-
}), 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(Input, { label: addLabel, value: value, autoFocus: true, loading: spinning, ...noAutofill, onChange: (e) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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) => {
|
|
100
|
+
setValue(e.target.value);
|
|
101
|
+
typeAhead.typed("add", e.target.value);
|
|
102
|
+
}, onBlur: (e) => {
|
|
103
|
+
// Into its results isn't leaving; anywhere else sends what's typed (or closes an empty field).
|
|
104
|
+
if (field.current?.contains(e.relatedTarget) || results.current?.pointing?.())
|
|
105
|
+
return;
|
|
106
|
+
afterPress(add); // e.g. pressing "Mark none" below: it mustn't move before the click lands
|
|
107
|
+
}, onKeyDown: (e) => {
|
|
108
|
+
if (searchKeys(e, results.current, value.trim() === sent && !saving))
|
|
109
|
+
return;
|
|
110
|
+
if (e.key === "Enter") {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
add();
|
|
113
|
+
}
|
|
114
|
+
if (e.key === "Escape")
|
|
115
|
+
close();
|
|
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() }))] }) }))] }));
|
|
116
117
|
}
|
|
117
118
|
//# sourceMappingURL=Clinical.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clinical.js","sourceRoot":"","sources":["../../../src/components/patient/Clinical.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,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB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AI,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntakeForm.d.ts","sourceRoot":"","sources":["../../../src/components/patient/IntakeForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,OAAO,EAAY,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"IntakeForm.d.ts","sourceRoot":"","sources":["../../../src/components/patient/IntakeForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAiBxF,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,sHAAsH;IACtH,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACxD,+BAyhBA"}
|
|
@@ -10,7 +10,8 @@ import { formatDate, formatPhone, PHONE_PATTERN, toE164 } from "../format.js";
|
|
|
10
10
|
import { FEW, searchKeys, SearchResults, useTypeAhead } from "../search.js";
|
|
11
11
|
import { noAutofill, SEX_OPTIONS } from "./fields.js";
|
|
12
12
|
import { focusProps, searchProps } from "../flow.js";
|
|
13
|
-
import { isSearchable, parseQuery, searchBoth } from "./query.js";
|
|
13
|
+
import { isSearchable, parseQuery, searchBoth, toSearchInput } from "./query.js";
|
|
14
|
+
import { TrackedField, useFieldInteractions } from "../../analytics/fieldInteraction.js";
|
|
14
15
|
const IDENTITY_KEYS = ["demographic.name.first", "demographic.name.last", "demographic.dateOfBirth", "demographic.sex"];
|
|
15
16
|
export function PatientIntakeForm({ patient, notice, }) {
|
|
16
17
|
const { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Grid, Input, Select, Spinner, Stack } = useComponents();
|
|
@@ -18,24 +19,27 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
18
19
|
const formId = useId();
|
|
19
20
|
// Starts from what's already been sent — e.g. a host's details the server hasn't matched yet — to edit on.
|
|
20
21
|
const known = patient.known;
|
|
21
|
-
const [first, setFirst] = useState(known.name?.first ?? "");
|
|
22
|
-
const [last, setLast] = useState(known.name?.last ?? "");
|
|
23
|
-
const [dob, setDob] = useState(known.dateOfBirth ?? "");
|
|
24
|
-
const [sex, setSex] = useState(known.sex ?? null);
|
|
25
|
-
const
|
|
26
|
-
const [
|
|
27
|
-
const [
|
|
28
|
-
const [
|
|
29
|
-
const [
|
|
30
|
-
const [
|
|
31
|
-
const [
|
|
22
|
+
const [first, setFirst] = useState(known.demographic?.name?.first ?? "");
|
|
23
|
+
const [last, setLast] = useState(known.demographic?.name?.last ?? "");
|
|
24
|
+
const [dob, setDob] = useState(known.demographic?.dateOfBirth ?? "");
|
|
25
|
+
const [sex, setSex] = useState(known.demographic?.sex ?? null);
|
|
26
|
+
const sexPicked = useFieldInteractions("new_patient_form")("sex", { isOptional: false, hasValue: Boolean(sex) });
|
|
27
|
+
const [email, setEmail] = useState(known.contact?.email ?? "");
|
|
28
|
+
const [phone, setPhone] = useState(known.contact?.phone ? formatPhone(known.contact.phone) : "");
|
|
29
|
+
const [street1, setStreet1] = useState(known.contact?.address?.street1 ?? "");
|
|
30
|
+
const [street2, setStreet2] = useState(known.contact?.address?.street2 ?? "");
|
|
31
|
+
const [city, setCity] = useState(known.contact?.address?.city ?? "");
|
|
32
|
+
const [state, setState] = useState(known.contact?.address?.state ?? "");
|
|
33
|
+
const [postalCode, setPostalCode] = useState(known.contact?.address?.postalCode ?? "");
|
|
32
34
|
/**
|
|
33
35
|
* Finding someone and adding them are two different jobs, so the card does one at a time. Searching is
|
|
34
36
|
* one field and never writes (`search` goes without `sex`, which is what network-api needs to create).
|
|
35
37
|
* "Create a new patient" is the prescriber saying none of these — it opens the form, filled in from what
|
|
36
38
|
* they typed. Details handed in that the server hasn't matched start there, as they always did.
|
|
37
39
|
*/
|
|
38
|
-
const [mode, setMode] = useState(() => known.name?.first || known.name?.last || known.dateOfBirth
|
|
40
|
+
const [mode, setMode] = useState(() => known.demographic?.name?.first || known.demographic?.name?.last || known.demographic?.dateOfBirth
|
|
41
|
+
? "create"
|
|
42
|
+
: "search");
|
|
39
43
|
const [query, setQuery] = useState("");
|
|
40
44
|
const creating = mode === "create";
|
|
41
45
|
/** What the matches below answer — the query as it was typed when the search went out. */
|
|
@@ -58,14 +62,16 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
58
62
|
unapplied: snap.changes.unapplied.filter((c) => identityFilled || !IDENTITY_KEYS.includes(c.key)),
|
|
59
63
|
});
|
|
60
64
|
/** Everything known on the form. Phone / email ride along once they're valid; the browser shows why otherwise. */
|
|
61
|
-
const
|
|
65
|
+
const form = (overrides = {}) => {
|
|
62
66
|
const chosenSex = overrides.sex !== undefined ? overrides.sex : sex;
|
|
63
67
|
const validPhone = new RegExp(`^(?:${PHONE_PATTERN})$`).test(phone.trim());
|
|
64
68
|
const validEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
|
|
65
|
-
|
|
69
|
+
const demographic = {
|
|
66
70
|
name: { first, last },
|
|
67
71
|
dateOfBirth: dob,
|
|
68
72
|
...(chosenSex ? { sex: chosenSex } : {}),
|
|
73
|
+
};
|
|
74
|
+
const contact = {
|
|
69
75
|
...(validPhone ? { phone: toE164(phone) } : {}),
|
|
70
76
|
...(validEmail ? { email: email.trim() } : {}),
|
|
71
77
|
...(addressComplete
|
|
@@ -81,6 +87,7 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
81
87
|
}
|
|
82
88
|
: {}),
|
|
83
89
|
};
|
|
90
|
+
return { demographic, contact };
|
|
84
91
|
};
|
|
85
92
|
// What the list of matches answers: the form as it was last sent — and whether typing sent it (a search), not
|
|
86
93
|
// leaving a field.
|
|
@@ -96,8 +103,8 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
96
103
|
* it only lists who it might be). The object adds it to what it sent before; the same query isn't sent twice.
|
|
97
104
|
*/
|
|
98
105
|
const send = (from, kind = "sync", overrides = {}) => {
|
|
99
|
-
const input =
|
|
100
|
-
sent.current = JSON.stringify(input
|
|
106
|
+
const input = form(overrides);
|
|
107
|
+
sent.current = JSON.stringify(input);
|
|
101
108
|
typedSearch.current = kind === "search";
|
|
102
109
|
void (kind === "sync" ? patient.sync(input) : patient.search(input)).catch(() => { }); // failures land on the object
|
|
103
110
|
if (patient.busy)
|
|
@@ -117,10 +124,10 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
117
124
|
setSentFrom("query");
|
|
118
125
|
void (async () => {
|
|
119
126
|
try {
|
|
120
|
-
await patient.search(
|
|
127
|
+
await patient.search(toSearchInput(parsed));
|
|
121
128
|
const alsoLast = searchBoth(parsed);
|
|
122
129
|
if (alsoLast && patient.snapshot.candidates.length === 0)
|
|
123
|
-
await patient.search(
|
|
130
|
+
await patient.search(toSearchInput(alsoLast));
|
|
124
131
|
}
|
|
125
132
|
catch {
|
|
126
133
|
// failures land on the object
|
|
@@ -175,7 +182,7 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
175
182
|
const onKeys = (e, field) => {
|
|
176
183
|
const answered = !typeAhead.waiting() &&
|
|
177
184
|
!busy &&
|
|
178
|
-
(field === "query" ? searched === query.trim() : sent.current === JSON.stringify(
|
|
185
|
+
(field === "query" ? searched === query.trim() : sent.current === JSON.stringify(form()));
|
|
179
186
|
if (searchKeys(e, matches.current, answered))
|
|
180
187
|
return;
|
|
181
188
|
if (e.key === "Tab" && !e.shiftKey && field !== "query")
|
|
@@ -191,7 +198,7 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
191
198
|
const field = lastField.current;
|
|
192
199
|
const answered = !typeAhead.waiting() &&
|
|
193
200
|
!busy &&
|
|
194
|
-
(mode === "search" ? searched === query.trim() : sent.current === JSON.stringify(
|
|
201
|
+
(mode === "search" ? searched === query.trim() : sent.current === JSON.stringify(form()));
|
|
195
202
|
if (!few || !answered || !typedSearch.current || !field || document.activeElement !== field)
|
|
196
203
|
return;
|
|
197
204
|
if (focusedFor.current === matchesFor)
|
|
@@ -284,33 +291,35 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
284
291
|
return (_jsxs(Card, { divided: true, children: [_jsx(CardHeader, { title: "Patient" }), _jsx(CardBody, { children: _jsx("form", { ...noAutofill, ref: fields, id: formId, onSubmit: submit, onFocus: (e) => {
|
|
285
292
|
if (e.target instanceof HTMLInputElement)
|
|
286
293
|
lastField.current = e.target;
|
|
287
|
-
}, children: _jsxs(Stack, { gap: "3", children: [mode === "search" && (_jsx("div", { ...focusProps, ...searchProps, children: _jsx(Input, { label: "Find patient", placeholder: "Name, date of birth, phone or email", value: query, onChange: (e) => {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
294
|
+
}, children: _jsxs(Stack, { gap: "3", children: [mode === "search" && (_jsx("div", { ...focusProps, ...searchProps, 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) => {
|
|
295
|
+
setQuery(e.target.value);
|
|
296
|
+
typeAhead.typed("query", e.target.value);
|
|
297
|
+
// Too little left to search on: the matches on screen answer a query that isn't there
|
|
298
|
+
// any more, so they go, and the card is back where it started — including what it has
|
|
299
|
+
// already moved the cursor to, or typing the same name again would land nowhere.
|
|
300
|
+
if (typeAhead.tooShort(e.target.value)) {
|
|
301
|
+
setSearched(null);
|
|
302
|
+
focusedFor.current = null;
|
|
303
|
+
}
|
|
304
|
+
}, onBlur: () => {
|
|
305
|
+
// Leaving asks now rather than after the pause — a search, never a sync: it can't
|
|
306
|
+
// create anyone and it can't change whoever it finds.
|
|
307
|
+
typeAhead.cancel();
|
|
308
|
+
if (query.trim() !== searched)
|
|
309
|
+
runSearch();
|
|
310
|
+
}, onKeyDown: (e) => onKeys(e, "query"), loading: spinning === "query", role: "combobox", "aria-expanded": searched !== null, "aria-autocomplete": "list", "aria-activedescendant": activeId ?? undefined, autoFocus: true, ...noAutofill }) }) })), creating && (_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), onBlur: () => leaveField("first"), onKeyDown: (e) => onKeys(e, "first"), loading: spinning === "first", 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), onBlur: () => leaveField("last"), onKeyDown: (e) => onKeys(e, "last"), loading: spinning === "last", ...noAutofill }) }), rows >= 2 && (_jsxs(_Fragment, { children: [_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), onBlur: () => leaveField("dob"), onKeyDown: (e) => onKeys(e, "dob"), loading: spinning === "dob" }) }), _jsx("div", { ref: sexField, onFocus: sexPicked.onFocus, onBlur: (e) => {
|
|
311
|
+
sexPicked.onBlur(e);
|
|
304
312
|
if (!e.currentTarget.contains(e.relatedTarget))
|
|
305
313
|
visit("sex");
|
|
306
314
|
}, onKeyDown: (e) => onKeys(e, "sex"), children: _jsx(Select, { ...gap("sex"), label: "Sex", placeholder: "Select\u2026", options: SEX_OPTIONS, value: sex, onChange: (next) => {
|
|
315
|
+
sexPicked.onChange(true);
|
|
307
316
|
setSex(next);
|
|
308
317
|
visit("sex");
|
|
309
318
|
setMissing((m) => m.filter((f) => f !== "sex"));
|
|
310
|
-
} }) }), rows >= 3 && (_jsxs(_Fragment, { 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("phone", setPhone), onBlur: () => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
319
|
+
} }) }), rows >= 3 && (_jsxs(_Fragment, { children: [_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("phone", setPhone), onBlur: () => {
|
|
320
|
+
setPhone(formatPhone(phone));
|
|
321
|
+
leaveField("phone");
|
|
322
|
+
}, onKeyDown: (e) => onKeys(e, "phone"), loading: spinning === "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("email", setEmail), onBlur: () => leaveField("email"), onKeyDown: (e) => onKeys(e, "email"), loading: spinning === "email", ...noAutofill }) })] }))] }))] })), mode === "search" && answeredNothing && (_jsx(Alert, { title: "Spelling has to be exact.", description: "Try another spelling, fewer letters, or a date of birth." })), mode === "search" && searched !== null && (_jsx(SearchResults, { label: candidates.length > 0 ? "Matching patients" : "No matching patients", results: candidates.map((m) => ({
|
|
314
323
|
key: m.id,
|
|
315
324
|
label: [m.firstName, m.lastName].filter(Boolean).join(" "),
|
|
316
325
|
meta: m.dateOfBirth ? formatDate(m.dateOfBirth) : undefined,
|
|
@@ -319,6 +328,6 @@ export function PatientIntakeForm({ patient, notice, }) {
|
|
|
319
328
|
// Backspace always lands in the field — the prescriber can narrow or start over mid-list.
|
|
320
329
|
inField: true, onActive: setActiveId,
|
|
321
330
|
// The last row: ↓ past the final match lands on it, and Return takes it.
|
|
322
|
-
action: { label: "Add new patient", icon: "add", onChoose: startCreate } })), notice && _jsx(Alert, { tone: "critical", title: notice.title, description: notice.description }), _jsx(ChangeList, { changes: changes }), snap.error && !asksForAddress(null, snap.error.message) && (_jsx(Badge, { tone: "critical", children: snap.error.message })), asksAddress && (_jsx("div", { onBlur: () => addressComplete && send("address"), children: _jsxs(Stack, { gap: "2", children: [snap.error && asksForAddress(null, snap.error.message) && (_jsx(Alert, { tone: "warning", title: "Address needed", description: snap.error.message })), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(Input, { label: "Street", value: street1, onChange: (e) => setStreet1(e.target.value), ...noAutofill }), _jsx(Input, { label: "Apt / suite", value: street2, onChange: (e) => setStreet2(e.target.value), ...noAutofill })] }), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(Input, { label: "City", value: city, onChange: (e) => setCity(e.target.value), ...noAutofill }), _jsx(Input, { label: "State", value: state, onChange: (e) => setState(e.target.value), maxLength: 2, ...noAutofill }), _jsx(Input, { label: "ZIP", value: postalCode, onChange: (e) => setPostalCode(e.target.value), inputMode: "numeric", ...noAutofill })] })] }) }))] }) }) }), creating && (_jsx(CardFooter, { start: busy ? _jsx(Spinner, { label: "Adding\u2026" }) : undefined, children: _jsx(Button, { type: "submit", form: formId, loading: busy, children: "Save patient" }) }))] }));
|
|
331
|
+
action: { label: "Add new patient", icon: "add", onChoose: startCreate } })), notice && _jsx(Alert, { tone: "critical", title: notice.title, description: notice.description }), _jsx(ChangeList, { changes: changes }), snap.error && !asksForAddress(null, snap.error.message) && (_jsx(Badge, { tone: "critical", children: snap.error.message })), asksAddress && (_jsx("div", { onBlur: () => addressComplete && send("address"), children: _jsxs(Stack, { gap: "2", children: [snap.error && asksForAddress(null, snap.error.message) && (_jsx(Alert, { tone: "warning", title: "Address needed", description: snap.error.message })), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "new_patient_form", fieldName: "address_street1", isOptional: false, children: _jsx(Input, { label: "Street", value: street1, onChange: (e) => setStreet1(e.target.value), ...noAutofill }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "address_street2", isOptional: true, children: _jsx(Input, { label: "Apt / suite", value: street2, onChange: (e) => setStreet2(e.target.value), ...noAutofill }) })] }), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "new_patient_form", fieldName: "address_city", isOptional: false, children: _jsx(Input, { label: "City", value: city, onChange: (e) => setCity(e.target.value), ...noAutofill }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "address_state", isOptional: false, children: _jsx(Input, { label: "State", value: state, onChange: (e) => setState(e.target.value), maxLength: 2, ...noAutofill }) }), _jsx(TrackedField, { formName: "new_patient_form", fieldName: "address_zip", isOptional: false, children: _jsx(Input, { label: "ZIP", value: postalCode, onChange: (e) => setPostalCode(e.target.value), inputMode: "numeric", ...noAutofill }) })] })] }) }))] }) }) }), creating && (_jsx(CardFooter, { start: busy ? _jsx(Spinner, { label: "Adding\u2026" }) : undefined, children: _jsx(Button, { type: "submit", form: formId, loading: busy, children: "Save patient" }) }))] }));
|
|
323
332
|
}
|
|
324
333
|
//# sourceMappingURL=IntakeForm.js.map
|