@photonhealth/react 2.0.0-rc.2 → 2.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/analytics/PhotonAnalyticsProvider.d.ts +5 -2
- package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -1
- package/dist/analytics/PhotonAnalyticsProvider.js +34 -15
- package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -1
- package/dist/analytics/cardLifecycle.d.ts +10 -0
- package/dist/analytics/cardLifecycle.d.ts.map +1 -0
- package/dist/analytics/cardLifecycle.js +43 -0
- package/dist/analytics/cardLifecycle.js.map +1 -0
- package/dist/analytics/lifecycleOutcomes.d.ts +8 -0
- package/dist/analytics/lifecycleOutcomes.d.ts.map +1 -0
- package/dist/analytics/lifecycleOutcomes.js +16 -0
- package/dist/analytics/lifecycleOutcomes.js.map +1 -0
- package/dist/analytics/tracker.d.ts +5 -3
- package/dist/analytics/tracker.d.ts.map +1 -1
- package/dist/analytics/tracker.js +10 -5
- package/dist/analytics/tracker.js.map +1 -1
- package/dist/components/PhotonOrder.d.ts +18 -18
- package/dist/components/PhotonOrder.d.ts.map +1 -1
- package/dist/components/PhotonOrder.js +17 -6
- package/dist/components/PhotonOrder.js.map +1 -1
- package/dist/components/PhotonPatient.d.ts +7 -35
- package/dist/components/PhotonPatient.d.ts.map +1 -1
- package/dist/components/PhotonPatient.js +3 -77
- package/dist/components/PhotonPatient.js.map +1 -1
- package/dist/components/PhotonPrescription.d.ts +14 -14
- package/dist/components/PhotonPrescription.d.ts.map +1 -1
- package/dist/components/PhotonPrescription.js +0 -1
- package/dist/components/PhotonPrescription.js.map +1 -1
- package/dist/components/open.d.ts +11 -13
- package/dist/components/open.d.ts.map +1 -1
- package/dist/components/open.js +7 -2
- package/dist/components/open.js.map +1 -1
- package/dist/components/patient/PatientCard/PatientCard.d.ts +30 -0
- package/dist/components/patient/PatientCard/PatientCard.d.ts.map +1 -0
- package/dist/components/patient/PatientCard/PatientCard.js +101 -0
- package/dist/components/patient/PatientCard/PatientCard.js.map +1 -0
- package/dist/components/patient/PatientCard/usePatientToShow.d.ts +22 -0
- package/dist/components/patient/PatientCard/usePatientToShow.d.ts.map +1 -0
- package/dist/components/patient/PatientCard/usePatientToShow.js +40 -0
- package/dist/components/patient/PatientCard/usePatientToShow.js.map +1 -0
- package/dist/components/patient/PatientIntakeForm.d.ts +16 -0
- package/dist/components/patient/PatientIntakeForm.d.ts.map +1 -0
- package/dist/components/patient/PatientIntakeForm.js +114 -0
- package/dist/components/patient/PatientIntakeForm.js.map +1 -0
- package/dist/components/patient/PatientSearch.d.ts +12 -0
- package/dist/components/patient/PatientSearch.d.ts.map +1 -0
- package/dist/components/patient/PatientSearch.js +148 -0
- package/dist/components/patient/PatientSearch.js.map +1 -0
- package/dist/components/patient/{Benefits.d.ts → PatientSummary/BenefitsInputForm.d.ts} +2 -2
- package/dist/components/patient/PatientSummary/BenefitsInputForm.d.ts.map +1 -0
- package/dist/components/patient/{Benefits.js → PatientSummary/BenefitsInputForm.js} +5 -5
- package/dist/components/patient/PatientSummary/BenefitsInputForm.js.map +1 -0
- package/dist/components/patient/{Clinical.d.ts → PatientSummary/ClinicalInputForm.d.ts} +13 -15
- package/dist/components/patient/PatientSummary/ClinicalInputForm.d.ts.map +1 -0
- package/dist/components/patient/{Clinical.js → PatientSummary/ClinicalInputForm.js} +11 -11
- package/dist/components/patient/PatientSummary/ClinicalInputForm.js.map +1 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts +5 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.js +30 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.js.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts +10 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.js +65 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.js.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts +53 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.js +78 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.js.map +1 -0
- package/dist/components/patient/PatientSummary/PatientSummary.d.ts +46 -0
- package/dist/components/patient/PatientSummary/PatientSummary.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/PatientSummary.js +57 -0
- package/dist/components/patient/PatientSummary/PatientSummary.js.map +1 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.d.ts +19 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.js +22 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.js.map +1 -0
- package/dist/components/patient/fields.d.ts +7 -25
- package/dist/components/patient/fields.d.ts.map +1 -1
- package/dist/components/patient/fields.js +11 -53
- package/dist/components/patient/fields.js.map +1 -1
- package/dist/components/patient/parsePatientSearchQuery.d.ts +16 -0
- package/dist/components/patient/parsePatientSearchQuery.d.ts.map +1 -0
- package/dist/components/patient/{query.js → parsePatientSearchQuery.js} +3 -15
- package/dist/components/patient/parsePatientSearchQuery.js.map +1 -0
- package/dist/components/prescription/PrescriptionCard.d.ts +14 -8
- package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -1
- package/dist/components/prescription/PrescriptionCard.js +10 -3
- package/dist/components/prescription/PrescriptionCard.js.map +1 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +6 -6
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +6 -6
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -1
- package/dist/components/schemaErrors.d.ts +3 -2
- package/dist/components/schemaErrors.d.ts.map +1 -1
- package/dist/components/schemaErrors.js +2 -1
- package/dist/components/schemaErrors.js.map +1 -1
- package/dist/components/search.d.ts +1 -1
- package/dist/components/search.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/meta/version.js +1 -1
- package/package.json +5 -2
- package/src/analytics/PhotonAnalyticsProvider.test.tsx +0 -1
- package/src/analytics/PhotonAnalyticsProvider.tsx +75 -20
- package/src/analytics/cardLifecycle.test.tsx +272 -0
- package/src/analytics/cardLifecycle.ts +44 -0
- package/src/analytics/fieldInteraction.test.tsx +11 -9
- package/src/analytics/lifecycleOutcomes.test.ts +78 -0
- package/src/analytics/lifecycleOutcomes.ts +29 -0
- package/src/analytics/tracker.test.ts +1 -1
- package/src/analytics/tracker.ts +13 -6
- package/src/analytics/usePhotonAnalytics.test.tsx +106 -0
- package/src/components/PhotonOrder.test.tsx +146 -8
- package/src/components/PhotonOrder.tsx +37 -26
- package/src/components/PhotonPatient.tsx +8 -163
- package/src/components/PhotonPrescription.test.tsx +22 -18
- package/src/components/PhotonPrescription.tsx +14 -14
- package/src/components/ScreeningAlerts.test.tsx +81 -0
- package/src/components/open.ts +13 -16
- package/src/components/order/DraftOrderPrompt.test.tsx +3 -6
- package/src/components/patient/PatientCard/PatientCard.test.tsx +255 -0
- package/src/components/patient/PatientCard/PatientCard.tsx +177 -0
- package/src/components/patient/PatientCard/usePatientToShow.ts +44 -0
- package/src/components/patient/PatientIntakeForm.test.tsx +262 -0
- package/src/components/patient/PatientIntakeForm.tsx +222 -0
- package/src/components/patient/PatientSearch.test.tsx +204 -0
- package/src/components/patient/PatientSearch.tsx +221 -0
- package/src/components/patient/PatientSummary/BenefitsInputForm.test.tsx +164 -0
- package/src/components/patient/{Benefits.tsx → PatientSummary/BenefitsInputForm.tsx} +4 -4
- package/src/components/patient/PatientSummary/ClinicalInputForm.test.tsx +247 -0
- package/src/components/patient/{Clinical.tsx → PatientSummary/ClinicalInputForm.tsx} +23 -23
- package/src/components/patient/PatientSummary/CollapsedSummary.test.tsx +90 -0
- package/src/components/patient/PatientSummary/CollapsedSummary.tsx +46 -0
- package/src/components/patient/PatientSummary/PatientDetailsForm.test.tsx +201 -0
- package/src/components/patient/PatientSummary/PatientDetailsForm.tsx +320 -0
- package/src/components/patient/PatientSummary/PatientDetailsSchema.test.ts +296 -0
- package/src/components/patient/PatientSummary/PatientDetailsSchema.ts +95 -0
- package/src/components/patient/PatientSummary/PatientSummary.test.tsx +194 -0
- package/src/components/patient/PatientSummary/PatientSummary.tsx +225 -0
- package/src/components/patient/PatientSummary/SummaryHeader.test.tsx +183 -0
- package/src/components/patient/PatientSummary/SummaryHeader.tsx +85 -0
- package/src/components/patient/fields.tsx +12 -138
- package/src/components/patient/parsePatientSearchQuery.test.ts +107 -0
- package/src/components/patient/{query.ts → parsePatientSearchQuery.ts} +4 -21
- package/src/components/prescription/PrescriptionCard.test.tsx +174 -12
- package/src/components/prescription/PrescriptionCard.tsx +28 -14
- package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +2 -5
- package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +3 -6
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +34 -37
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +14 -14
- package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +2 -5
- package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +3 -7
- package/src/components/schemaErrors.ts +3 -2
- package/src/components/search.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/meta/version.test.ts +1 -0
- package/src/meta/version.ts +1 -1
- package/dist/components/patient/Benefits.d.ts.map +0 -1
- package/dist/components/patient/Benefits.js.map +0 -1
- package/dist/components/patient/Clinical.d.ts.map +0 -1
- package/dist/components/patient/Clinical.js.map +0 -1
- package/dist/components/patient/IntakeForm.d.ts +0 -10
- package/dist/components/patient/IntakeForm.d.ts.map +0 -1
- package/dist/components/patient/IntakeForm.js +0 -333
- package/dist/components/patient/IntakeForm.js.map +0 -1
- package/dist/components/patient/Summary.d.ts +0 -48
- package/dist/components/patient/Summary.d.ts.map +0 -1
- package/dist/components/patient/Summary.js +0 -90
- package/dist/components/patient/Summary.js.map +0 -1
- package/dist/components/patient/query.d.ts +0 -37
- package/dist/components/patient/query.d.ts.map +0 -1
- package/dist/components/patient/query.js.map +0 -1
- package/src/components/patient/IntakeForm.test.tsx +0 -89
- package/src/components/patient/IntakeForm.tsx +0 -564
- package/src/components/patient/Summary.test.tsx +0 -106
- package/src/components/patient/Summary.tsx +0 -330
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/** PhotonPatient with a record: the summary and its details editor, with the clinical lists and benefits. */
|
|
2
|
+
import { useComponents } from "../../../primitives/index.ts";
|
|
3
|
+
import {
|
|
4
|
+
type ChangeOption,
|
|
5
|
+
type ClassifiedChanges,
|
|
6
|
+
type MedicationStatus,
|
|
7
|
+
type PatientRecord,
|
|
8
|
+
type PhotonError,
|
|
9
|
+
} from "@photonhealth/client";
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { ChangeList } from "../../ChangeList.tsx";
|
|
12
|
+
import { BenefitsInputForm, type BenefitInput } from "./BenefitsInputForm.tsx";
|
|
13
|
+
import {
|
|
14
|
+
choicesIn,
|
|
15
|
+
ClinicalInputForm,
|
|
16
|
+
diagnosisRef,
|
|
17
|
+
sectionOf,
|
|
18
|
+
withoutInline,
|
|
19
|
+
type DiagnosisInput,
|
|
20
|
+
} from "./ClinicalInputForm.tsx";
|
|
21
|
+
import { PatientDetailsForm, type PatientDetailsInput } from "./PatientDetailsForm.tsx";
|
|
22
|
+
import { SummaryHeader } from "./SummaryHeader.tsx";
|
|
23
|
+
import { CollapsedSummary } from "./CollapsedSummary.tsx";
|
|
24
|
+
|
|
25
|
+
export function PatientSummary({
|
|
26
|
+
patient,
|
|
27
|
+
saving,
|
|
28
|
+
changes,
|
|
29
|
+
error,
|
|
30
|
+
onChoose,
|
|
31
|
+
onAddAllergy,
|
|
32
|
+
onConfirmNone,
|
|
33
|
+
onRemoveAllergy,
|
|
34
|
+
onRemoveMedication,
|
|
35
|
+
onAddMedication,
|
|
36
|
+
onAddDiagnosis,
|
|
37
|
+
onRemoveDiagnosis,
|
|
38
|
+
onAddBenefit,
|
|
39
|
+
onRemoveBenefit,
|
|
40
|
+
onConfirmNoBenefits,
|
|
41
|
+
onSaveDetails,
|
|
42
|
+
addressRequest,
|
|
43
|
+
onChangePatient,
|
|
44
|
+
readOnly,
|
|
45
|
+
}: {
|
|
46
|
+
patient: PatientRecord;
|
|
47
|
+
saving: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The server's changes. Each clinical list shows its own choices (AMBIGUOUS changes) and problems (e.g. a name
|
|
50
|
+
* nothing matches) under its field; the rest show at the bottom of the card.
|
|
51
|
+
*/
|
|
52
|
+
changes: ClassifiedChanges;
|
|
53
|
+
/** The last save's failure, if any. */
|
|
54
|
+
error: PhotonError | null;
|
|
55
|
+
onChoose: (option: ChangeOption) => void;
|
|
56
|
+
onAddAllergy: (name: string) => void;
|
|
57
|
+
/** Record "none" for a clinical list (NKDA, no medications, no diagnoses). */
|
|
58
|
+
onConfirmNone: (list: "allergies" | "medications" | "diagnoses") => void;
|
|
59
|
+
onRemoveAllergy: (allergy: { id: string }) => void;
|
|
60
|
+
onRemoveMedication: (medication: { id: string; status: MedicationStatus }) => void;
|
|
61
|
+
onAddMedication: (name: string) => void;
|
|
62
|
+
onAddDiagnosis: (diagnosis: DiagnosisInput) => void;
|
|
63
|
+
onRemoveDiagnosis: (diagnosis: { id: string }) => void;
|
|
64
|
+
onAddBenefit: (benefit: BenefitInput) => void;
|
|
65
|
+
onRemoveBenefit: (benefit: { id: string }) => void;
|
|
66
|
+
onConfirmNoBenefits: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Send what PatientDetailsForm saved, as one UpdatePatient. Resolves to true once network-api has saved it, or
|
|
69
|
+
* false when the update failed.
|
|
70
|
+
*/
|
|
71
|
+
onSaveDetails: (input: PatientDetailsInput) => Promise<boolean>;
|
|
72
|
+
addressRequest: string | null;
|
|
73
|
+
onChangePatient?: () => void;
|
|
74
|
+
/** Read-only (e.g. on a sent order): the summary alone — no editors, no pencil. */
|
|
75
|
+
readOnly?: boolean;
|
|
76
|
+
}) {
|
|
77
|
+
const { Alert, Card, CardBody, Stack } = useComponents();
|
|
78
|
+
const choices = changes.needsChoice;
|
|
79
|
+
const problems = changes.blocking;
|
|
80
|
+
// What the clinical lists don't show under their own fields goes at the bottom of the card.
|
|
81
|
+
const messages = withoutInline(changes);
|
|
82
|
+
const hasMessages =
|
|
83
|
+
messages.needsChoice.length + messages.blocking.length + messages.advisories.length > 0 || Boolean(error);
|
|
84
|
+
// Allergies / medications / diagnoses / insurance are summarized under the header (CollapsedSummary); the
|
|
85
|
+
// pencil opens their lists to add or remove, and they open by themselves when the server asks the prescriber
|
|
86
|
+
// to choose (e.g. which penicillin).
|
|
87
|
+
// A list with something to pick or fix opens by itself, and shows it under its field.
|
|
88
|
+
const clinicalChoices = [...choices, ...problems].filter((c) => sectionOf(c.key));
|
|
89
|
+
// One card, two states. Shut, it says who the patient is; open, it is everything about them that can be
|
|
90
|
+
// changed — the fields they were added with, their contact details, and their clinical lists. Each saves
|
|
91
|
+
// as it is answered (`UpdatePatient` on a record that already exists), so there is nothing to confirm.
|
|
92
|
+
// It also opens itself when a send fails for want of an address, and shuts again once that is answered.
|
|
93
|
+
const [editing, setEditing] = useState(Boolean(addressRequest));
|
|
94
|
+
const [seenRequest, setSeenRequest] = useState(addressRequest);
|
|
95
|
+
if (addressRequest !== seenRequest) {
|
|
96
|
+
setSeenRequest(addressRequest);
|
|
97
|
+
setEditing(Boolean(addressRequest));
|
|
98
|
+
}
|
|
99
|
+
// Each list: null when nothing is recorded, [] when "none" is (core's PatientRecord).
|
|
100
|
+
const recorded = {
|
|
101
|
+
allergies: patient.clinical?.allergies ?? null,
|
|
102
|
+
medications: patient.clinical?.medications ?? null,
|
|
103
|
+
diagnoses: patient.clinical?.diagnoses ?? null,
|
|
104
|
+
benefits: patient.benefits,
|
|
105
|
+
};
|
|
106
|
+
const confirmedNkda = recorded.allergies?.length === 0;
|
|
107
|
+
const allergies = recorded.allergies ?? [];
|
|
108
|
+
const meds = (recorded.medications ?? []).filter((m) => m.status === "ACTIVE");
|
|
109
|
+
const diagnoses = (recorded.diagnoses ?? []).map((x) => ({ ...x, name: x.name ?? x.icd10Code ?? "" }));
|
|
110
|
+
// A choice the server is waiting on (which penicillin?) opens the card too — the answer lives in here.
|
|
111
|
+
const expanded = !readOnly && (editing || clinicalChoices.length > 0);
|
|
112
|
+
|
|
113
|
+
// What the server said (choices, problems, a failed save) goes at the bottom of whichever section is shown.
|
|
114
|
+
const messageList = hasMessages && (
|
|
115
|
+
<>
|
|
116
|
+
<ChangeList changes={messages} onChoose={onChoose} busy={saving} />
|
|
117
|
+
{/* A failed save must never be silent (e.g. a rejected clinical patch). */}
|
|
118
|
+
{error && <Alert tone="critical" title="Couldn't save" description={error.message} />}
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Card divided>
|
|
124
|
+
<SummaryHeader
|
|
125
|
+
patient={patient}
|
|
126
|
+
expanded={expanded}
|
|
127
|
+
readOnly={readOnly}
|
|
128
|
+
onStartEditing={() => setEditing(true)}
|
|
129
|
+
onCancelEditing={() => setEditing(false)}
|
|
130
|
+
onChangePatient={onChangePatient}
|
|
131
|
+
/>
|
|
132
|
+
{!expanded && (
|
|
133
|
+
<CardBody>
|
|
134
|
+
<Stack gap="4">
|
|
135
|
+
<CollapsedSummary patient={patient} />
|
|
136
|
+
{messageList}
|
|
137
|
+
</Stack>
|
|
138
|
+
</CardBody>
|
|
139
|
+
)}
|
|
140
|
+
{expanded && (
|
|
141
|
+
<CardBody>
|
|
142
|
+
<Stack gap="4">
|
|
143
|
+
<PatientDetailsForm
|
|
144
|
+
patient={patient}
|
|
145
|
+
addressRequest={addressRequest}
|
|
146
|
+
// The editors stay open until network-api answers, and stay open with what was typed if it fails.
|
|
147
|
+
onSave={async (input) => {
|
|
148
|
+
const success = await onSaveDetails(input);
|
|
149
|
+
if (success) setEditing(false);
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
</Stack>
|
|
153
|
+
</CardBody>
|
|
154
|
+
)}
|
|
155
|
+
{expanded && (
|
|
156
|
+
<CardBody>
|
|
157
|
+
<Stack gap="4">
|
|
158
|
+
<ClinicalInputForm
|
|
159
|
+
label="Allergies"
|
|
160
|
+
fieldName="allergies"
|
|
161
|
+
choices={choicesIn(choices, "allergies")}
|
|
162
|
+
problems={choicesIn(problems, "allergies")}
|
|
163
|
+
onChoose={onChoose}
|
|
164
|
+
items={allergies}
|
|
165
|
+
tone="warning"
|
|
166
|
+
addLabel="Add allergy"
|
|
167
|
+
noneLabel="No known allergies"
|
|
168
|
+
noneAction="Mark NKDA"
|
|
169
|
+
confirmedNone={confirmedNkda}
|
|
170
|
+
unknownLabel="Unknown allergy"
|
|
171
|
+
saving={saving}
|
|
172
|
+
onAdd={onAddAllergy}
|
|
173
|
+
onRemove={onRemoveAllergy}
|
|
174
|
+
onNone={() => onConfirmNone("allergies")}
|
|
175
|
+
/>
|
|
176
|
+
<ClinicalInputForm
|
|
177
|
+
label="Medications"
|
|
178
|
+
fieldName="medications"
|
|
179
|
+
choices={choicesIn(choices, "medications")}
|
|
180
|
+
problems={choicesIn(problems, "medications")}
|
|
181
|
+
onChoose={onChoose}
|
|
182
|
+
items={meds}
|
|
183
|
+
tone="neutral"
|
|
184
|
+
addLabel="Add medication"
|
|
185
|
+
noneLabel="No active meds"
|
|
186
|
+
noneAction="Mark none"
|
|
187
|
+
confirmedNone={recorded.medications?.length === 0}
|
|
188
|
+
onNone={() => onConfirmNone("medications")}
|
|
189
|
+
unknownLabel="Unknown medication"
|
|
190
|
+
saving={saving}
|
|
191
|
+
onAdd={onAddMedication}
|
|
192
|
+
onRemove={onRemoveMedication}
|
|
193
|
+
/>
|
|
194
|
+
<ClinicalInputForm
|
|
195
|
+
label="Diagnoses"
|
|
196
|
+
fieldName="diagnoses"
|
|
197
|
+
choices={choicesIn(choices, "diagnoses")}
|
|
198
|
+
problems={choicesIn(problems, "diagnoses")}
|
|
199
|
+
onChoose={onChoose}
|
|
200
|
+
items={diagnoses}
|
|
201
|
+
tone="neutral"
|
|
202
|
+
addLabel="Add diagnosis"
|
|
203
|
+
noneLabel="No diagnoses"
|
|
204
|
+
noneAction="Mark none"
|
|
205
|
+
confirmedNone={recorded.diagnoses?.length === 0}
|
|
206
|
+
onNone={() => onConfirmNone("diagnoses")}
|
|
207
|
+
unknownLabel="Unknown diagnosis"
|
|
208
|
+
saving={saving}
|
|
209
|
+
onAdd={(text) => onAddDiagnosis(diagnosisRef(text))}
|
|
210
|
+
onRemove={onRemoveDiagnosis}
|
|
211
|
+
/>
|
|
212
|
+
<BenefitsInputForm
|
|
213
|
+
benefits={recorded.benefits}
|
|
214
|
+
saving={saving}
|
|
215
|
+
onAdd={onAddBenefit}
|
|
216
|
+
onRemove={onRemoveBenefit}
|
|
217
|
+
onNone={onConfirmNoBenefits}
|
|
218
|
+
/>
|
|
219
|
+
{messageList}
|
|
220
|
+
</Stack>
|
|
221
|
+
</CardBody>
|
|
222
|
+
)}
|
|
223
|
+
</Card>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { demographicLine, fullName, SummaryHeader } from "./SummaryHeader.tsx";
|
|
5
|
+
import { patientRecord as record } from "../../../../test/patientRecord.fixtures.ts";
|
|
6
|
+
|
|
7
|
+
const renderHeader = (props: Partial<Parameters<typeof SummaryHeader>[0]> = {}) =>
|
|
8
|
+
render(
|
|
9
|
+
<SummaryHeader
|
|
10
|
+
patient={record()}
|
|
11
|
+
expanded={false}
|
|
12
|
+
onStartEditing={() => {}}
|
|
13
|
+
onCancelEditing={() => {}}
|
|
14
|
+
{...props}
|
|
15
|
+
/>,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
/** The sex / age / date of birth line under the patient's name. */
|
|
19
|
+
const line = () => screen.getByRole("heading").nextElementSibling;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// Ages are counted from today.
|
|
23
|
+
vi.useFakeTimers({ toFake: ["Date"] });
|
|
24
|
+
vi.setSystemTime(new Date(2026, 5, 15));
|
|
25
|
+
});
|
|
26
|
+
afterEach(() => vi.useRealTimers());
|
|
27
|
+
|
|
28
|
+
describe("SummaryHeader", () => {
|
|
29
|
+
it("patient's name: shows it as the card title", () => {
|
|
30
|
+
renderHeader();
|
|
31
|
+
expect(screen.getByRole("heading", { name: "Ada Lovelace" })).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("sex or date of birth recorded: shows them on the line under the name", () => {
|
|
35
|
+
renderHeader({ patient: record({ demographic: { sex: "FEMALE", dateOfBirth: "1990-01-01" } }) });
|
|
36
|
+
expect(line()).toHaveTextContent("Female · Adult (36) · 1/1/90");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("no sex and no date of birth: shows no line under the name", () => {
|
|
40
|
+
renderHeader();
|
|
41
|
+
expect(line()).toBeNull();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("buttons", () => {
|
|
45
|
+
it('collapsed: shows "Edit patient" button, not expanded', () => {
|
|
46
|
+
renderHeader();
|
|
47
|
+
expect(screen.getByRole("button", { name: "Edit patient" })).toHaveAttribute("aria-expanded", "false");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('expanded: shows no "Edit patient" button', () => {
|
|
51
|
+
renderHeader({ expanded: true });
|
|
52
|
+
expect(screen.queryByRole("button", { name: "Edit patient" })).not.toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('clicking "Edit patient": calls onStartEditing', async () => {
|
|
56
|
+
const onStartEditing = vi.fn();
|
|
57
|
+
renderHeader({ onStartEditing });
|
|
58
|
+
await userEvent.click(screen.getByRole("button", { name: "Edit patient" }));
|
|
59
|
+
expect(onStartEditing).toHaveBeenCalledOnce();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('readOnly: shows no "Edit patient" button', () => {
|
|
63
|
+
renderHeader({ readOnly: true });
|
|
64
|
+
expect(screen.queryByRole("button", { name: "Edit patient" })).not.toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('onChangePatient passed: clicking "Change patient" calls onChangePatient', async () => {
|
|
68
|
+
const onChangePatient = vi.fn();
|
|
69
|
+
renderHeader({ onChangePatient });
|
|
70
|
+
await userEvent.click(screen.getByRole("button", { name: "Change patient" }));
|
|
71
|
+
expect(onChangePatient).toHaveBeenCalledOnce();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('onChangePatient passed and readOnly: still shows "Change patient" button', () => {
|
|
75
|
+
renderHeader({ onChangePatient: () => {}, readOnly: true });
|
|
76
|
+
expect(screen.getByRole("button", { name: "Change patient" })).toBeInTheDocument();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('no onChangePatient: shows no "Change patient" button', () => {
|
|
80
|
+
renderHeader();
|
|
81
|
+
expect(screen.queryByRole("button", { name: "Change patient" })).not.toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('collapsed: shows "Change patient" button', () => {
|
|
85
|
+
renderHeader({ onChangePatient: () => {} });
|
|
86
|
+
expect(screen.getByRole("button", { name: "Change patient" })).toBeInTheDocument();
|
|
87
|
+
expect(screen.queryByRole("button", { name: "Cancel editing patient" })).not.toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('expanded: shows "Cancel editing patient" button instead of "Change patient"', () => {
|
|
91
|
+
renderHeader({ expanded: true, onChangePatient: () => {} });
|
|
92
|
+
expect(screen.getByRole("button", { name: "Cancel editing patient" })).toBeInTheDocument();
|
|
93
|
+
expect(screen.queryByRole("button", { name: "Change patient" })).not.toBeInTheDocument();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('expanded and no onChangePatient: still shows "Cancel editing patient" button', () => {
|
|
97
|
+
renderHeader({ expanded: true });
|
|
98
|
+
expect(screen.getByRole("button", { name: "Cancel editing patient" })).toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('clicking "Cancel editing patient": calls onCancelEditing, not onChangePatient', async () => {
|
|
102
|
+
const onCancelEditing = vi.fn();
|
|
103
|
+
const onChangePatient = vi.fn();
|
|
104
|
+
renderHeader({ expanded: true, onCancelEditing, onChangePatient });
|
|
105
|
+
await userEvent.click(screen.getByRole("button", { name: "Cancel editing patient" }));
|
|
106
|
+
expect(onCancelEditing).toHaveBeenCalledOnce();
|
|
107
|
+
expect(onChangePatient).not.toHaveBeenCalled();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Leaving a field shows its error, and pressing Cancel would take focus from the field being typed in first.
|
|
111
|
+
// Keeping focus where it is lets Cancel close the editors without briefly showing an error.
|
|
112
|
+
it('pressing "Cancel editing patient": prevents the mousedown from moving focus', () => {
|
|
113
|
+
renderHeader({ expanded: true });
|
|
114
|
+
const notPrevented = fireEvent.mouseDown(screen.getByRole("button", { name: "Cancel editing patient" }));
|
|
115
|
+
expect(notPrevented).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("fullName", () => {
|
|
121
|
+
it('first and last name: returns "<first> <last>"', () => {
|
|
122
|
+
expect(fullName({ first: "Ada", middle: null, last: "Lovelace" })).toBe("Ada Lovelace");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Pins today's behavior: the middle name is recorded but never shown.
|
|
126
|
+
it("middle name: leaves the middle name out", () => {
|
|
127
|
+
expect(fullName({ first: "Ada", middle: "King", last: "Lovelace" })).toBe("Ada Lovelace");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("first name only: returns the first name", () => {
|
|
131
|
+
expect(fullName({ first: "Ada", middle: null, last: null })).toBe("Ada");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("last name only: returns the last name", () => {
|
|
135
|
+
expect(fullName({ first: null, middle: null, last: "Lovelace" })).toBe("Lovelace");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('first and last name empty: returns "Unnamed patient"', () => {
|
|
139
|
+
expect(fullName({ first: "", middle: null, last: "" })).toBe("Unnamed patient");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('no first or last name: returns "Unnamed patient"', () => {
|
|
143
|
+
expect(fullName({ first: null, middle: null, last: null })).toBe("Unnamed patient");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('no name object (the patient has no demographic details): returns "Unnamed patient"', () => {
|
|
147
|
+
expect(fullName(undefined)).toBe("Unnamed patient");
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe("demographicLine", () => {
|
|
152
|
+
it('sex and date of birth, 18 or older: returns "<sex> · Adult (<age>) · <M/D/YY>"', () => {
|
|
153
|
+
expect(demographicLine({ sex: "FEMALE", dateOfBirth: "1990-01-01" })).toBe("Female · Adult (36) · 1/1/90");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('sex and date of birth, under 18: returns "<sex> · Pediatric (<age>) · <M/D/YY>"', () => {
|
|
157
|
+
expect(demographicLine({ sex: "MALE", dateOfBirth: "2016-01-01" })).toBe("Male · Pediatric (10) · 1/1/16");
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("turns 18 today: returns Adult", () => {
|
|
161
|
+
expect(demographicLine({ sex: null, dateOfBirth: "2008-06-15" })).toBe("Adult (18) · 6/15/08");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("turns 18 tomorrow: returns Pediatric", () => {
|
|
165
|
+
expect(demographicLine({ sex: null, dateOfBirth: "2008-06-16" })).toBe("Pediatric (17) · 6/16/08");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("sex UNKNOWN: leaves sex out", () => {
|
|
169
|
+
expect(demographicLine({ sex: "UNKNOWN", dateOfBirth: "1990-01-01" })).toBe("Adult (36) · 1/1/90");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("sex but no date of birth: returns only sex", () => {
|
|
173
|
+
expect(demographicLine({ sex: "FEMALE", dateOfBirth: null })).toBe("Female");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("no sex and no date of birth: returns an empty string", () => {
|
|
177
|
+
expect(demographicLine({ sex: null, dateOfBirth: null })).toBe("");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("no demographic details: returns an empty string", () => {
|
|
181
|
+
expect(demographicLine(undefined)).toBe("");
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** PatientSummary's header: who the patient is, and the buttons to edit them, cancel an edit, or change them. */
|
|
2
|
+
import { useComponents } from "../../../primitives/index.ts";
|
|
3
|
+
import { type PatientRecord } from "@photonhealth/client";
|
|
4
|
+
import { ageOn, shortDate } from "../../format.ts";
|
|
5
|
+
import { focusProps } from "../../flow.ts";
|
|
6
|
+
|
|
7
|
+
type Demographic = NonNullable<PatientRecord["demographic"]>;
|
|
8
|
+
type Name = Demographic["name"];
|
|
9
|
+
|
|
10
|
+
export const fullName = (name: Name | undefined) =>
|
|
11
|
+
[name?.first, name?.last].filter(Boolean).join(" ") || "Unnamed patient";
|
|
12
|
+
|
|
13
|
+
export const demographicLine = (d: Pick<Demographic, "sex" | "dateOfBirth"> | undefined) => {
|
|
14
|
+
const age = ageOn(d?.dateOfBirth);
|
|
15
|
+
const sex = d?.sex === "FEMALE" ? "Female" : d?.sex === "MALE" ? "Male" : null;
|
|
16
|
+
const ageGroup = age != null ? `${age >= 18 ? "Adult" : "Pediatric"} (${age})` : null;
|
|
17
|
+
return [sex, ageGroup, d?.dateOfBirth ? shortDate(d.dateOfBirth) : null].filter(Boolean).join(" · ");
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function SummaryHeader({
|
|
21
|
+
patient,
|
|
22
|
+
expanded,
|
|
23
|
+
readOnly,
|
|
24
|
+
onStartEditing,
|
|
25
|
+
onCancelEditing,
|
|
26
|
+
onChangePatient,
|
|
27
|
+
}: {
|
|
28
|
+
patient: PatientRecord;
|
|
29
|
+
/** Whether the card's editors are showing: the pencil is hidden, and Cancel shows in place of Change patient. */
|
|
30
|
+
expanded: boolean;
|
|
31
|
+
/** Read-only (e.g. on a sent order): no pencil. */
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
/** Open the editors. Shown while collapsed; PatientDetailsForm's Save closes them again. */
|
|
34
|
+
onStartEditing: () => void;
|
|
35
|
+
/** Close the editors without saving. Shown while `expanded`, in place of Change patient. */
|
|
36
|
+
onCancelEditing: () => void;
|
|
37
|
+
onChangePatient?: () => void;
|
|
38
|
+
}) {
|
|
39
|
+
const { Button, CardHeader, Row } = useComponents();
|
|
40
|
+
const line = demographicLine(patient.demographic ?? undefined);
|
|
41
|
+
return (
|
|
42
|
+
<CardHeader
|
|
43
|
+
title={fullName(patient.demographic?.name)}
|
|
44
|
+
description={line || undefined}
|
|
45
|
+
action={
|
|
46
|
+
<Row gap="1">
|
|
47
|
+
{!readOnly && !expanded && (
|
|
48
|
+
<span {...focusProps}>
|
|
49
|
+
<Button
|
|
50
|
+
variant="ghost"
|
|
51
|
+
icon="edit"
|
|
52
|
+
aria-label="Edit patient"
|
|
53
|
+
title="Edit patient"
|
|
54
|
+
aria-expanded={false}
|
|
55
|
+
onClick={onStartEditing}
|
|
56
|
+
/>
|
|
57
|
+
</span>
|
|
58
|
+
)}
|
|
59
|
+
{expanded ? (
|
|
60
|
+
<Button
|
|
61
|
+
variant="ghost"
|
|
62
|
+
// Pressing the button would take focus from the field being typed in first, and leaving a field shows
|
|
63
|
+
// its error. Keep focus where it is, so the click closes the editors without flashing an error.
|
|
64
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
65
|
+
onClick={onCancelEditing}
|
|
66
|
+
aria-label="Cancel editing patient"
|
|
67
|
+
title="Cancel"
|
|
68
|
+
icon="close"
|
|
69
|
+
/>
|
|
70
|
+
) : (
|
|
71
|
+
onChangePatient && (
|
|
72
|
+
<Button
|
|
73
|
+
variant="ghost"
|
|
74
|
+
onClick={onChangePatient}
|
|
75
|
+
aria-label="Change patient"
|
|
76
|
+
title="Change patient"
|
|
77
|
+
icon="close"
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
)}
|
|
81
|
+
</Row>
|
|
82
|
+
}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
import {
|
|
3
|
-
import { type PatientInput, type Sex } from "@photonhealth/client";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { formatPhone, PHONE_PATTERN, toE164 } from "../format.ts";
|
|
6
|
-
import { TrackedField } from "../../analytics/fieldInteraction.tsx";
|
|
1
|
+
/** What PatientCard's forms share: the identity keys, the sex options, and no autofill. */
|
|
2
|
+
import { type Sex } from "@photonhealth/client";
|
|
7
3
|
|
|
8
|
-
|
|
4
|
+
/**
|
|
5
|
+
* What network-api needs to add a patient. While the prescriber is still finding or filling them in, the server's
|
|
6
|
+
* "still needed" about these is what the card asks for next, not an error to show.
|
|
7
|
+
*/
|
|
8
|
+
export const IDENTITY_KEYS = [
|
|
9
|
+
"demographic.name.first",
|
|
10
|
+
"demographic.name.last",
|
|
11
|
+
"demographic.dateOfBirth",
|
|
12
|
+
"demographic.sex",
|
|
13
|
+
];
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
16
|
* These fields describe the patient, not the prescriber: keep the browser's autofill and password managers
|
|
@@ -25,134 +30,3 @@ export const SEX_OPTIONS: { value: Sex; label: string }[] = [
|
|
|
25
30
|
{ value: "FEMALE", label: "Female" },
|
|
26
31
|
{ value: "UNKNOWN", label: "Unknown" },
|
|
27
32
|
];
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Phone / email / address, inside the demographics editor. Nothing here is required up front: the server
|
|
31
|
-
* decides (a send needs a phone), and the editor opens itself when a send fails for want of one —
|
|
32
|
-
* `addressRequest`.
|
|
33
|
-
*/
|
|
34
|
-
export function ContactFields({
|
|
35
|
-
phone,
|
|
36
|
-
email,
|
|
37
|
-
address,
|
|
38
|
-
onSave,
|
|
39
|
-
addressRequest,
|
|
40
|
-
}: {
|
|
41
|
-
phone: string | null;
|
|
42
|
-
email: string | null;
|
|
43
|
-
address: {
|
|
44
|
-
street1: string | null;
|
|
45
|
-
street2: string | null;
|
|
46
|
-
city: string | null;
|
|
47
|
-
state: string | null;
|
|
48
|
-
postalCode: string | null;
|
|
49
|
-
} | null;
|
|
50
|
-
onSave: (contact: { phone?: string; email?: string; address?: AddressInput }) => void;
|
|
51
|
-
addressRequest: string | null;
|
|
52
|
-
}) {
|
|
53
|
-
const { Alert, Grid, Input, Stack } = useComponents();
|
|
54
|
-
const [phoneValue, setPhone] = useState(formatPhone(phone));
|
|
55
|
-
const [emailValue, setEmail] = useState(email ?? "");
|
|
56
|
-
const [street1, setStreet1] = useState(address?.street1 ?? "");
|
|
57
|
-
const [street2, setStreet2] = useState(address?.street2 ?? "");
|
|
58
|
-
const [city, setCity] = useState(address?.city ?? "");
|
|
59
|
-
const [state, setState] = useState(address?.state ?? "");
|
|
60
|
-
const [postalCode, setPostalCode] = useState(address?.postalCode ?? "");
|
|
61
|
-
|
|
62
|
-
// Save early: each field saves when you leave it (the browser validates phone / email first);
|
|
63
|
-
// the address saves once it's complete and you leave it.
|
|
64
|
-
const addressComplete = Boolean(street1.trim() && city.trim() && state.trim() && postalCode.trim());
|
|
65
|
-
const savePhone = (input: HTMLInputElement) => {
|
|
66
|
-
setPhone(formatPhone(phoneValue));
|
|
67
|
-
if (input.checkValidity() && toE164(phoneValue) !== (phone || undefined))
|
|
68
|
-
onSave({ phone: toE164(phoneValue) ?? "" });
|
|
69
|
-
};
|
|
70
|
-
const saveEmail = (input: HTMLInputElement) => {
|
|
71
|
-
if (input.checkValidity() && emailValue.trim() !== (email ?? "")) onSave({ email: emailValue.trim() });
|
|
72
|
-
};
|
|
73
|
-
const saveAddress = () => {
|
|
74
|
-
if (!addressComplete) return;
|
|
75
|
-
const next = {
|
|
76
|
-
street1: street1.trim(),
|
|
77
|
-
street2: street2.trim() || undefined,
|
|
78
|
-
city: city.trim(),
|
|
79
|
-
state: state.trim().toUpperCase(),
|
|
80
|
-
postalCode: postalCode.trim(),
|
|
81
|
-
country: "US",
|
|
82
|
-
};
|
|
83
|
-
const same =
|
|
84
|
-
next.street1 === (address?.street1 ?? "") &&
|
|
85
|
-
(next.street2 ?? "") === (address?.street2 ?? "") &&
|
|
86
|
-
next.city === (address?.city ?? "") &&
|
|
87
|
-
next.state === (address?.state ?? "") &&
|
|
88
|
-
next.postalCode === (address?.postalCode ?? "");
|
|
89
|
-
if (!same) onSave({ address: next });
|
|
90
|
-
};
|
|
91
|
-
return (
|
|
92
|
-
<Stack gap="2">
|
|
93
|
-
{/* The server's message can name internal ids ("patient pat_… has no address"); the title says it. A send
|
|
94
|
-
needs a phone; an address only when the server still asks with a phone on file. */}
|
|
95
|
-
{addressRequest && <Alert tone="warning" title={phone ? "Address needed to send" : "Phone needed to send"} />}
|
|
96
|
-
<Grid min="120px" gap="3">
|
|
97
|
-
<TrackedField formName="update_patient_form" fieldName="phone" isOptional>
|
|
98
|
-
<Input
|
|
99
|
-
label="Phone"
|
|
100
|
-
type="tel"
|
|
101
|
-
inputMode="tel"
|
|
102
|
-
pattern={PHONE_PATTERN}
|
|
103
|
-
value={phoneValue}
|
|
104
|
-
onChange={(e) => setPhone(e.target.value)}
|
|
105
|
-
onBlur={(e) => savePhone(e.currentTarget)}
|
|
106
|
-
{...noAutofill}
|
|
107
|
-
/>
|
|
108
|
-
</TrackedField>
|
|
109
|
-
<TrackedField formName="update_patient_form" fieldName="email" isOptional>
|
|
110
|
-
<Input
|
|
111
|
-
label="Email"
|
|
112
|
-
type="email"
|
|
113
|
-
inputMode="email"
|
|
114
|
-
value={emailValue}
|
|
115
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
116
|
-
onBlur={(e) => saveEmail(e.currentTarget)}
|
|
117
|
-
{...noAutofill}
|
|
118
|
-
/>
|
|
119
|
-
</TrackedField>
|
|
120
|
-
</Grid>
|
|
121
|
-
<div onBlur={saveAddress}>
|
|
122
|
-
<Stack gap="3">
|
|
123
|
-
<Grid min="120px" gap="3">
|
|
124
|
-
<TrackedField formName="update_patient_form" fieldName="address_street1" isOptional>
|
|
125
|
-
<Input label="Street" value={street1} onChange={(e) => setStreet1(e.target.value)} {...noAutofill} />
|
|
126
|
-
</TrackedField>
|
|
127
|
-
<TrackedField formName="update_patient_form" fieldName="address_street2" isOptional>
|
|
128
|
-
<Input label="Apt / suite" value={street2} onChange={(e) => setStreet2(e.target.value)} {...noAutofill} />
|
|
129
|
-
</TrackedField>
|
|
130
|
-
</Grid>
|
|
131
|
-
<Grid min="120px" gap="3">
|
|
132
|
-
<TrackedField formName="update_patient_form" fieldName="address_city" isOptional>
|
|
133
|
-
<Input label="City" value={city} onChange={(e) => setCity(e.target.value)} {...noAutofill} />
|
|
134
|
-
</TrackedField>
|
|
135
|
-
<TrackedField formName="update_patient_form" fieldName="address_state" isOptional>
|
|
136
|
-
<Input
|
|
137
|
-
label="State"
|
|
138
|
-
value={state}
|
|
139
|
-
onChange={(e) => setState(e.target.value)}
|
|
140
|
-
maxLength={2}
|
|
141
|
-
{...noAutofill}
|
|
142
|
-
/>
|
|
143
|
-
</TrackedField>
|
|
144
|
-
<TrackedField formName="update_patient_form" fieldName="address_zip" isOptional>
|
|
145
|
-
<Input
|
|
146
|
-
label="ZIP"
|
|
147
|
-
value={postalCode}
|
|
148
|
-
onChange={(e) => setPostalCode(e.target.value)}
|
|
149
|
-
inputMode="numeric"
|
|
150
|
-
{...noAutofill}
|
|
151
|
-
/>
|
|
152
|
-
</TrackedField>
|
|
153
|
-
</Grid>
|
|
154
|
-
</Stack>
|
|
155
|
-
</div>
|
|
156
|
-
</Stack>
|
|
157
|
-
);
|
|
158
|
-
}
|