@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,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useComponents } from "../../../primitives/index.js";
|
|
3
|
+
import {} from "@photonhealth/client";
|
|
4
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
5
|
+
import { Controller, useForm } from "react-hook-form";
|
|
6
|
+
import { formatPhone } from "../../format.js";
|
|
7
|
+
import { noAutofill, SEX_OPTIONS } from "../fields.js";
|
|
8
|
+
import { TrackedField, useFieldInteractions } from "../../../analytics/fieldInteraction.js";
|
|
9
|
+
import { PatientDetailsSchema } from "./PatientDetailsSchema.js";
|
|
10
|
+
export function PatientDetailsForm({ patient, addressRequest, onSave, }) {
|
|
11
|
+
const { Alert, Button, Grid, Input, Row, Select, Stack } = useComponents();
|
|
12
|
+
const phone = patient.contact?.phone ?? null;
|
|
13
|
+
const { control, handleSubmit, formState: { isSubmitting }, } = useForm({
|
|
14
|
+
resolver: zodResolver(PatientDetailsSchema),
|
|
15
|
+
defaultValues: formValuesFrom(patient),
|
|
16
|
+
mode: "onTouched",
|
|
17
|
+
});
|
|
18
|
+
const fieldInteraction = useFieldInteractions("update_patient_form");
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Grid, { min: "200px", gap: "3", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "firstName", isOptional: false, children: _jsx(Controller, { control: control, name: "firstName", render: ({ field, fieldState }) => (_jsx(Input, { label: "First name", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "lastName", isOptional: false, children: _jsx(Controller, { control: control, name: "lastName", render: ({ field, fieldState }) => (_jsx(Input, { label: "Last name", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "dateOfBirth", isOptional: false, children: _jsx(Controller, { control: control, name: "dateOfBirth", render: ({ field, fieldState }) => (_jsx(Input, { label: "Date of birth", type: "date", ...noAutofill, name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message })) }) }), _jsx(Controller, { control: control, name: "sex", render: ({ field, fieldState }) => {
|
|
20
|
+
const sexInteractions = fieldInteraction("sex", { isOptional: false, hasValue: Boolean(field.value) });
|
|
21
|
+
return (_jsx("div", { style: { display: "contents" }, onFocus: sexInteractions.onFocus, onBlur: sexInteractions.onBlur, children: _jsx(Select, { label: "Sex", placeholder: "Select\u2026", options: SEX_OPTIONS, value: field.value, onChange: (sex) => {
|
|
22
|
+
sexInteractions.onChange(true);
|
|
23
|
+
field.onChange(sex);
|
|
24
|
+
}, invalid: fieldState.invalid, errorMessage: fieldState.error?.message }) }));
|
|
25
|
+
} })] }), _jsxs(Stack, { gap: "2", children: [addressRequest && _jsx(Alert, { tone: "warning", title: phone ? "Address needed to send" : "Phone needed to send" }), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "phone", isOptional: true, children: _jsx(Controller, { control: control, name: "phone", render: ({ field, fieldState }) => (_jsx(Input, { label: "Phone", type: "tel", inputMode: "tel", name: field.name, value: field.value, onChange: field.onChange,
|
|
26
|
+
// Leaving the field shows the number formatted, e.g. "+1 (415) 555-0172".
|
|
27
|
+
onBlur: () => {
|
|
28
|
+
field.onChange(formatPhone(field.value));
|
|
29
|
+
field.onBlur();
|
|
30
|
+
}, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "email", isOptional: true, children: _jsx(Controller, { control: control, name: "email", render: ({ field, fieldState }) => (_jsx(Input, { label: "Email", type: "email", inputMode: "email", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) })] }), _jsxs(Stack, { gap: "3", children: [_jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_street1", isOptional: true, children: _jsx(Controller, { control: control, name: "address.street1", render: ({ field, fieldState }) => (_jsx(Input, { label: "Street", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_street2", isOptional: true, children: _jsx(Controller, { control: control, name: "address.street2", render: ({ field, fieldState }) => (_jsx(Input, { label: "Apt / suite", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) })] }), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_city", isOptional: true, children: _jsx(Controller, { control: control, name: "address.city", render: ({ field, fieldState }) => (_jsx(Input, { label: "City", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_state", isOptional: true, children: _jsx(Controller, { control: control, name: "address.state", render: ({ field, fieldState }) => (_jsx(Input, { label: "State", maxLength: 2, name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_zip", isOptional: true, children: _jsx(Controller, { control: control, name: "address.postalCode", render: ({ field, fieldState }) => (_jsx(Input, { label: "ZIP", inputMode: "numeric", name: field.name, value: field.value, onChange: field.onChange, onBlur: field.onBlur, invalid: fieldState.invalid, errorMessage: fieldState.error?.message, ...noAutofill })) }) })] })] })] }), _jsx(Row, { justify: "end", children: _jsx(Button, { variant: "secondary", loading: isSubmitting, onClick: handleSubmit((details) => onSave(toPatientInput(details))), children: "Save" }) })] }));
|
|
31
|
+
}
|
|
32
|
+
function formValuesFrom(patient) {
|
|
33
|
+
const demographic = patient.demographic;
|
|
34
|
+
const address = patient.contact?.address;
|
|
35
|
+
return {
|
|
36
|
+
firstName: demographic?.name.first ?? "",
|
|
37
|
+
lastName: demographic?.name.last ?? "",
|
|
38
|
+
dateOfBirth: demographic?.dateOfBirth ?? "",
|
|
39
|
+
sex: demographic?.sex ?? null,
|
|
40
|
+
phone: formatPhone(patient.contact?.phone),
|
|
41
|
+
email: patient.contact?.email ?? "",
|
|
42
|
+
address: {
|
|
43
|
+
street1: address?.street1 ?? "",
|
|
44
|
+
street2: address?.street2 ?? "",
|
|
45
|
+
city: address?.city ?? "",
|
|
46
|
+
state: address?.state ?? "",
|
|
47
|
+
postalCode: address?.postalCode ?? "",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function toPatientInput(details) {
|
|
52
|
+
return {
|
|
53
|
+
demographic: {
|
|
54
|
+
name: { first: details.firstName, last: details.lastName },
|
|
55
|
+
dateOfBirth: details.dateOfBirth,
|
|
56
|
+
sex: details.sex,
|
|
57
|
+
},
|
|
58
|
+
contact: {
|
|
59
|
+
phone: details.phone,
|
|
60
|
+
email: details.email,
|
|
61
|
+
...(details.address && { address: details.address }),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=PatientDetailsForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatientDetailsForm.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/PatientDetailsForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAyC,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAe,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wCAAyC,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAsD,MAAM,2BAA2B,CAAC;AAKrH,MAAM,UAAU,kBAAkB,CAAC,EACjC,OAAO,EACP,cAAc,EACd,MAAM,GAMP;IACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAC;IAC3E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;IAE7C,MAAM,EACJ,OAAO,EACP,YAAY,EACZ,SAAS,EAAE,EAAE,YAAY,EAAE,GAC5B,GAAG,OAAO,CAAoD;QAC7D,QAAQ,EAAE,WAAW,CAAC,oBAAoB,CAIzC;QACD,aAAa,EAAE,cAAc,CAAC,OAAO,CAAC;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th/client";
|
|
3
|
+
export declare const PatientDetailsSchema: z.ZodObject<{
|
|
4
|
+
firstName: z.ZodString;
|
|
5
|
+
lastName: z.ZodString;
|
|
6
|
+
dateOfBirth: z.ZodString;
|
|
7
|
+
sex: z.ZodEnum<{
|
|
8
|
+
FEMALE: "FEMALE";
|
|
9
|
+
MALE: "MALE";
|
|
10
|
+
UNKNOWN: "UNKNOWN";
|
|
11
|
+
}>;
|
|
12
|
+
phone: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
13
|
+
email: z.ZodString;
|
|
14
|
+
address: z.ZodPipe<z.ZodObject<{
|
|
15
|
+
street1: z.ZodString;
|
|
16
|
+
street2: z.ZodString;
|
|
17
|
+
city: z.ZodString;
|
|
18
|
+
state: z.ZodString;
|
|
19
|
+
postalCode: z.ZodString;
|
|
20
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
21
|
+
street1: string;
|
|
22
|
+
street2: string | undefined;
|
|
23
|
+
city: string;
|
|
24
|
+
state: string;
|
|
25
|
+
postalCode: string;
|
|
26
|
+
country: string;
|
|
27
|
+
} | undefined, {
|
|
28
|
+
street1: string;
|
|
29
|
+
street2: string;
|
|
30
|
+
city: string;
|
|
31
|
+
state: string;
|
|
32
|
+
postalCode: string;
|
|
33
|
+
}>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
/** The values to send, once every field is valid. */
|
|
36
|
+
export type PatientDetails = z.output<typeof PatientDetailsSchema>;
|
|
37
|
+
/** What the form holds while the prescriber edits it*/
|
|
38
|
+
export type PatientDetailsFormValues = {
|
|
39
|
+
firstName: string;
|
|
40
|
+
lastName: string;
|
|
41
|
+
dateOfBirth: string;
|
|
42
|
+
sex: Sex | null;
|
|
43
|
+
phone: string;
|
|
44
|
+
email: string;
|
|
45
|
+
address: {
|
|
46
|
+
street1: string;
|
|
47
|
+
street2: string;
|
|
48
|
+
city: string;
|
|
49
|
+
state: string;
|
|
50
|
+
postalCode: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=PatientDetailsSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatientDetailsSchema.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/PatientDetailsSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAKhD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsD/B,CAAC;AAEH,qDAAqD;AACrD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE,uDAAuD;AACvD,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAChG,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {} from "@photonhealth/client";
|
|
3
|
+
import { PHONE_PATTERN, toE164 } from "../../format.js";
|
|
4
|
+
const sexes = ["MALE", "FEMALE", "UNKNOWN"];
|
|
5
|
+
export const PatientDetailsSchema = z.object({
|
|
6
|
+
firstName: z.string().trim().min(1, "Required"),
|
|
7
|
+
lastName: z.string().trim().min(1, "Required"),
|
|
8
|
+
dateOfBirth: z
|
|
9
|
+
.string()
|
|
10
|
+
.trim()
|
|
11
|
+
.min(1, "Required")
|
|
12
|
+
.refine(isIsoDate, "Enter a valid date")
|
|
13
|
+
.refine((value) => value <= today(), "Date of birth can't be in the future"),
|
|
14
|
+
sex: z.enum(sexes, { error: "Required" }),
|
|
15
|
+
// network-api clears a phone or email sent as an empty string, so a blank phone or email parses as ""
|
|
16
|
+
phone: z
|
|
17
|
+
.string()
|
|
18
|
+
.trim()
|
|
19
|
+
.refine((value) => !value || isUsPhone(value), "Enter a valid phone number")
|
|
20
|
+
.transform((value) => toE164(value) ?? ""),
|
|
21
|
+
email: z
|
|
22
|
+
.string()
|
|
23
|
+
.trim()
|
|
24
|
+
.refine((value) => !value || z.email().safeParse(value).success, "Enter a valid email"),
|
|
25
|
+
address: z
|
|
26
|
+
.object({
|
|
27
|
+
street1: z.string().trim(),
|
|
28
|
+
street2: z.string().trim(),
|
|
29
|
+
city: z.string().trim(),
|
|
30
|
+
state: z.string().trim(),
|
|
31
|
+
postalCode: z.string().trim(),
|
|
32
|
+
})
|
|
33
|
+
.transform((value) => Object.values(value).some(Boolean)
|
|
34
|
+
? {
|
|
35
|
+
street1: value.street1,
|
|
36
|
+
street2: value.street2 || undefined,
|
|
37
|
+
city: value.city,
|
|
38
|
+
state: value.state.toUpperCase(),
|
|
39
|
+
postalCode: value.postalCode,
|
|
40
|
+
// network-api's schema marks country optional, but its patient planner refuses an address without one.
|
|
41
|
+
// The form only takes US addresses (a 2-letter state, a 5-digit ZIP), so it always sends "US".
|
|
42
|
+
country: "US",
|
|
43
|
+
}
|
|
44
|
+
: undefined)
|
|
45
|
+
.superRefine((value, ctx) => {
|
|
46
|
+
if (!value)
|
|
47
|
+
return;
|
|
48
|
+
for (const key of ["street1", "city", "state", "postalCode"]) {
|
|
49
|
+
if (!value[key])
|
|
50
|
+
ctx.addIssue({ code: "custom", path: [key], message: "Required" });
|
|
51
|
+
}
|
|
52
|
+
if (value.state && !/^[A-Z]{2}$/.test(value.state)) {
|
|
53
|
+
ctx.addIssue({ code: "custom", path: ["state"], message: "Enter a 2-letter state" });
|
|
54
|
+
}
|
|
55
|
+
if (value.postalCode && !/^\d{5}(-\d{4})?$/.test(value.postalCode)) {
|
|
56
|
+
ctx.addIssue({ code: "custom", path: ["postalCode"], message: "Enter a 5-digit ZIP" });
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
function isUsPhone(value) {
|
|
61
|
+
return new RegExp(`^(?:${PHONE_PATTERN})$`).test(value);
|
|
62
|
+
}
|
|
63
|
+
/** A real calendar date written as YYYY-MM-DD: "2023-02-30" is refused. */
|
|
64
|
+
function isIsoDate(value) {
|
|
65
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
66
|
+
if (!match)
|
|
67
|
+
return false;
|
|
68
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
69
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
70
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
71
|
+
}
|
|
72
|
+
/** Today's date in the prescriber's time zone, as YYYY-MM-DD, so it compares with a date of birth as text. */
|
|
73
|
+
function today() {
|
|
74
|
+
const now = new Date();
|
|
75
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
76
|
+
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=PatientDetailsSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatientDetailsSchema.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/PatientDetailsSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,KAAK,GAA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AI,IAAI,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ChangeOption, type ClassifiedChanges, type MedicationStatus, type PatientRecord, type PhotonError } from "@photonhealth/client";
|
|
2
|
+
import { type BenefitInput } from "./BenefitsInputForm.tsx";
|
|
3
|
+
import { type DiagnosisInput } from "./ClinicalInputForm.tsx";
|
|
4
|
+
import { type PatientDetailsInput } from "./PatientDetailsForm.tsx";
|
|
5
|
+
export declare function PatientSummary({ patient, saving, changes, error, onChoose, onAddAllergy, onConfirmNone, onRemoveAllergy, onRemoveMedication, onAddMedication, onAddDiagnosis, onRemoveDiagnosis, onAddBenefit, onRemoveBenefit, onConfirmNoBenefits, onSaveDetails, addressRequest, onChangePatient, readOnly, }: {
|
|
6
|
+
patient: PatientRecord;
|
|
7
|
+
saving: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The server's changes. Each clinical list shows its own choices (AMBIGUOUS changes) and problems (e.g. a name
|
|
10
|
+
* nothing matches) under its field; the rest show at the bottom of the card.
|
|
11
|
+
*/
|
|
12
|
+
changes: ClassifiedChanges;
|
|
13
|
+
/** The last save's failure, if any. */
|
|
14
|
+
error: PhotonError | null;
|
|
15
|
+
onChoose: (option: ChangeOption) => void;
|
|
16
|
+
onAddAllergy: (name: string) => void;
|
|
17
|
+
/** Record "none" for a clinical list (NKDA, no medications, no diagnoses). */
|
|
18
|
+
onConfirmNone: (list: "allergies" | "medications" | "diagnoses") => void;
|
|
19
|
+
onRemoveAllergy: (allergy: {
|
|
20
|
+
id: string;
|
|
21
|
+
}) => void;
|
|
22
|
+
onRemoveMedication: (medication: {
|
|
23
|
+
id: string;
|
|
24
|
+
status: MedicationStatus;
|
|
25
|
+
}) => void;
|
|
26
|
+
onAddMedication: (name: string) => void;
|
|
27
|
+
onAddDiagnosis: (diagnosis: DiagnosisInput) => void;
|
|
28
|
+
onRemoveDiagnosis: (diagnosis: {
|
|
29
|
+
id: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
onAddBenefit: (benefit: BenefitInput) => void;
|
|
32
|
+
onRemoveBenefit: (benefit: {
|
|
33
|
+
id: string;
|
|
34
|
+
}) => void;
|
|
35
|
+
onConfirmNoBenefits: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Send what PatientDetailsForm saved, as one UpdatePatient. Resolves to true once network-api has saved it, or
|
|
38
|
+
* false when the update failed.
|
|
39
|
+
*/
|
|
40
|
+
onSaveDetails: (input: PatientDetailsInput) => Promise<boolean>;
|
|
41
|
+
addressRequest: string | null;
|
|
42
|
+
onChangePatient?: () => void;
|
|
43
|
+
/** Read-only (e.g. on a sent order): the summary alone — no editors, no pencil. */
|
|
44
|
+
readOnly?: boolean;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
//# sourceMappingURL=PatientSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatientSummary.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/PatientSummary.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,0BA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CAAC;IACnD,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,+BAqJA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** PhotonPatient with a record: the summary and its details editor, with the clinical lists and benefits. */
|
|
3
|
+
import { useComponents } from "../../../primitives/index.js";
|
|
4
|
+
import {} from "@photonhealth/client";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { ChangeList } from "../../ChangeList.js";
|
|
7
|
+
import { BenefitsInputForm } from "./BenefitsInputForm.js";
|
|
8
|
+
import { choicesIn, ClinicalInputForm, diagnosisRef, sectionOf, withoutInline, } from "./ClinicalInputForm.js";
|
|
9
|
+
import { PatientDetailsForm } from "./PatientDetailsForm.js";
|
|
10
|
+
import { SummaryHeader } from "./SummaryHeader.js";
|
|
11
|
+
import { CollapsedSummary } from "./CollapsedSummary.js";
|
|
12
|
+
export function PatientSummary({ patient, saving, changes, error, onChoose, onAddAllergy, onConfirmNone, onRemoveAllergy, onRemoveMedication, onAddMedication, onAddDiagnosis, onRemoveDiagnosis, onAddBenefit, onRemoveBenefit, onConfirmNoBenefits, onSaveDetails, addressRequest, onChangePatient, readOnly, }) {
|
|
13
|
+
const { Alert, Card, CardBody, Stack } = useComponents();
|
|
14
|
+
const choices = changes.needsChoice;
|
|
15
|
+
const problems = changes.blocking;
|
|
16
|
+
// What the clinical lists don't show under their own fields goes at the bottom of the card.
|
|
17
|
+
const messages = withoutInline(changes);
|
|
18
|
+
const hasMessages = messages.needsChoice.length + messages.blocking.length + messages.advisories.length > 0 || Boolean(error);
|
|
19
|
+
// Allergies / medications / diagnoses / insurance are summarized under the header (CollapsedSummary); the
|
|
20
|
+
// pencil opens their lists to add or remove, and they open by themselves when the server asks the prescriber
|
|
21
|
+
// to choose (e.g. which penicillin).
|
|
22
|
+
// A list with something to pick or fix opens by itself, and shows it under its field.
|
|
23
|
+
const clinicalChoices = [...choices, ...problems].filter((c) => sectionOf(c.key));
|
|
24
|
+
// One card, two states. Shut, it says who the patient is; open, it is everything about them that can be
|
|
25
|
+
// changed — the fields they were added with, their contact details, and their clinical lists. Each saves
|
|
26
|
+
// as it is answered (`UpdatePatient` on a record that already exists), so there is nothing to confirm.
|
|
27
|
+
// It also opens itself when a send fails for want of an address, and shuts again once that is answered.
|
|
28
|
+
const [editing, setEditing] = useState(Boolean(addressRequest));
|
|
29
|
+
const [seenRequest, setSeenRequest] = useState(addressRequest);
|
|
30
|
+
if (addressRequest !== seenRequest) {
|
|
31
|
+
setSeenRequest(addressRequest);
|
|
32
|
+
setEditing(Boolean(addressRequest));
|
|
33
|
+
}
|
|
34
|
+
// Each list: null when nothing is recorded, [] when "none" is (core's PatientRecord).
|
|
35
|
+
const recorded = {
|
|
36
|
+
allergies: patient.clinical?.allergies ?? null,
|
|
37
|
+
medications: patient.clinical?.medications ?? null,
|
|
38
|
+
diagnoses: patient.clinical?.diagnoses ?? null,
|
|
39
|
+
benefits: patient.benefits,
|
|
40
|
+
};
|
|
41
|
+
const confirmedNkda = recorded.allergies?.length === 0;
|
|
42
|
+
const allergies = recorded.allergies ?? [];
|
|
43
|
+
const meds = (recorded.medications ?? []).filter((m) => m.status === "ACTIVE");
|
|
44
|
+
const diagnoses = (recorded.diagnoses ?? []).map((x) => ({ ...x, name: x.name ?? x.icd10Code ?? "" }));
|
|
45
|
+
// A choice the server is waiting on (which penicillin?) opens the card too — the answer lives in here.
|
|
46
|
+
const expanded = !readOnly && (editing || clinicalChoices.length > 0);
|
|
47
|
+
// What the server said (choices, problems, a failed save) goes at the bottom of whichever section is shown.
|
|
48
|
+
const messageList = hasMessages && (_jsxs(_Fragment, { children: [_jsx(ChangeList, { changes: messages, onChoose: onChoose, busy: saving }), error && _jsx(Alert, { tone: "critical", title: "Couldn't save", description: error.message })] }));
|
|
49
|
+
return (_jsxs(Card, { divided: true, children: [_jsx(SummaryHeader, { patient: patient, expanded: expanded, readOnly: readOnly, onStartEditing: () => setEditing(true), onCancelEditing: () => setEditing(false), onChangePatient: onChangePatient }), !expanded && (_jsx(CardBody, { children: _jsxs(Stack, { gap: "4", children: [_jsx(CollapsedSummary, { patient: patient }), messageList] }) })), expanded && (_jsx(CardBody, { children: _jsx(Stack, { gap: "4", children: _jsx(PatientDetailsForm, { patient: patient, addressRequest: addressRequest,
|
|
50
|
+
// The editors stay open until network-api answers, and stay open with what was typed if it fails.
|
|
51
|
+
onSave: async (input) => {
|
|
52
|
+
const success = await onSaveDetails(input);
|
|
53
|
+
if (success)
|
|
54
|
+
setEditing(false);
|
|
55
|
+
} }) }) })), expanded && (_jsx(CardBody, { children: _jsxs(Stack, { gap: "4", children: [_jsx(ClinicalInputForm, { label: "Allergies", fieldName: "allergies", choices: choicesIn(choices, "allergies"), problems: choicesIn(problems, "allergies"), onChoose: onChoose, items: allergies, tone: "warning", addLabel: "Add allergy", noneLabel: "No known allergies", noneAction: "Mark NKDA", confirmedNone: confirmedNkda, unknownLabel: "Unknown allergy", saving: saving, onAdd: onAddAllergy, onRemove: onRemoveAllergy, onNone: () => onConfirmNone("allergies") }), _jsx(ClinicalInputForm, { label: "Medications", fieldName: "medications", choices: choicesIn(choices, "medications"), problems: choicesIn(problems, "medications"), onChoose: onChoose, items: meds, tone: "neutral", addLabel: "Add medication", noneLabel: "No active meds", noneAction: "Mark none", confirmedNone: recorded.medications?.length === 0, onNone: () => onConfirmNone("medications"), unknownLabel: "Unknown medication", saving: saving, onAdd: onAddMedication, onRemove: onRemoveMedication }), _jsx(ClinicalInputForm, { label: "Diagnoses", fieldName: "diagnoses", choices: choicesIn(choices, "diagnoses"), problems: choicesIn(problems, "diagnoses"), onChoose: onChoose, items: diagnoses, tone: "neutral", addLabel: "Add diagnosis", noneLabel: "No diagnoses", noneAction: "Mark none", confirmedNone: recorded.diagnoses?.length === 0, onNone: () => onConfirmNone("diagnoses"), unknownLabel: "Unknown diagnosis", saving: saving, onAdd: (text) => onAddDiagnosis(diagnosisRef(text)), onRemove: onRemoveDiagnosis }), _jsx(BenefitsInputForm, { benefits: recorded.benefits, saving: saving, onAdd: onAddBenefit, onRemove: onRemoveBenefit, onNone: onConfirmNoBenefits }), messageList] }) }))] }));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=PatientSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatientSummary.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/PatientSummary.tsx"],"names":[],"mappings":";AAAA,6GAA6G;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAMN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAsB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,wBAAyB,CAAC;AAC/E,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,aAAa,GAEd,MAAM,wBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAA4B,MAAM,yBAA0B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAE1D,MAAM,UAAU,cAAc,CAAC,EAC7B,OAAO,EACP,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,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,EACnD,QAAQ,EAAE,iBAAiB,GAC3B,EACF,KAAC,iBAAiB,IAChB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,mBAAmB,GAC3B,EACD,WAAW,IACN,GACC,CACZ,IACI,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PatientRecord } from "@photonhealth/client";
|
|
2
|
+
type Demographic = NonNullable<PatientRecord["demographic"]>;
|
|
3
|
+
type Name = Demographic["name"];
|
|
4
|
+
export declare const fullName: (name: Name | undefined) => string;
|
|
5
|
+
export declare const demographicLine: (d: Pick<Demographic, "sex" | "dateOfBirth"> | undefined) => string;
|
|
6
|
+
export declare function SummaryHeader({ patient, expanded, readOnly, onStartEditing, onCancelEditing, onChangePatient, }: {
|
|
7
|
+
patient: PatientRecord;
|
|
8
|
+
/** Whether the card's editors are showing: the pencil is hidden, and Cancel shows in place of Change patient. */
|
|
9
|
+
expanded: boolean;
|
|
10
|
+
/** Read-only (e.g. on a sent order): no pencil. */
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
/** Open the editors. Shown while collapsed; PatientDetailsForm's Save closes them again. */
|
|
13
|
+
onStartEditing: () => void;
|
|
14
|
+
/** Close the editors without saving. Shown while `expanded`, in place of Change patient. */
|
|
15
|
+
onCancelEditing: () => void;
|
|
16
|
+
onChangePatient?: () => void;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=SummaryHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SummaryHeader.d.ts","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/SummaryHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,KAAK,WAAW,GAAG,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;AAC7D,KAAK,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAEhC,eAAO,MAAM,QAAQ,GAAI,MAAM,IAAI,GAAG,SAAS,WAC2B,CAAC;AAE3E,eAAO,MAAM,eAAe,GAAI,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,aAAa,CAAC,GAAG,SAAS,WAKtF,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,eAAe,EACf,eAAe,GAChB,EAAE;IACD,OAAO,EAAE,aAAa,CAAC;IACvB,iHAAiH;IACjH,QAAQ,EAAE,OAAO,CAAC;IAClB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4FAA4F;IAC5F,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,4FAA4F;IAC5F,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,+BA+CA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** PatientSummary's header: who the patient is, and the buttons to edit them, cancel an edit, or change them. */
|
|
3
|
+
import { useComponents } from "../../../primitives/index.js";
|
|
4
|
+
import {} from "@photonhealth/client";
|
|
5
|
+
import { ageOn, shortDate } from "../../format.js";
|
|
6
|
+
import { focusProps } from "../../flow.js";
|
|
7
|
+
export const fullName = (name) => [name?.first, name?.last].filter(Boolean).join(" ") || "Unnamed patient";
|
|
8
|
+
export const demographicLine = (d) => {
|
|
9
|
+
const age = ageOn(d?.dateOfBirth);
|
|
10
|
+
const sex = d?.sex === "FEMALE" ? "Female" : d?.sex === "MALE" ? "Male" : null;
|
|
11
|
+
const ageGroup = age != null ? `${age >= 18 ? "Adult" : "Pediatric"} (${age})` : null;
|
|
12
|
+
return [sex, ageGroup, d?.dateOfBirth ? shortDate(d.dateOfBirth) : null].filter(Boolean).join(" · ");
|
|
13
|
+
};
|
|
14
|
+
export function SummaryHeader({ patient, expanded, readOnly, onStartEditing, onCancelEditing, onChangePatient, }) {
|
|
15
|
+
const { Button, CardHeader, Row } = useComponents();
|
|
16
|
+
const line = demographicLine(patient.demographic ?? undefined);
|
|
17
|
+
return (_jsx(CardHeader, { title: fullName(patient.demographic?.name), description: line || undefined, action: _jsxs(Row, { gap: "1", children: [!readOnly && !expanded && (_jsx("span", { ...focusProps, children: _jsx(Button, { variant: "ghost", icon: "edit", "aria-label": "Edit patient", title: "Edit patient", "aria-expanded": false, onClick: onStartEditing }) })), expanded ? (_jsx(Button, { variant: "ghost",
|
|
18
|
+
// Pressing the button would take focus from the field being typed in first, and leaving a field shows
|
|
19
|
+
// its error. Keep focus where it is, so the click closes the editors without flashing an error.
|
|
20
|
+
onMouseDown: (e) => e.preventDefault(), onClick: onCancelEditing, "aria-label": "Cancel editing patient", title: "Cancel", icon: "close" })) : (onChangePatient && (_jsx(Button, { variant: "ghost", onClick: onChangePatient, "aria-label": "Change patient", title: "Change patient", icon: "close" })))] }) }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=SummaryHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SummaryHeader.js","sourceRoot":"","sources":["../../../../src/components/patient/PatientSummary/SummaryHeader.tsx"],"names":[],"mappings":";AAAA,iHAAiH;AACjH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAsB,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAsB,EAAE,EAAE,CACjD,CAAC,IAAI,EAAE,KAAK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EAC9B,MAAM,EACJ,MAAC,GAAG,IAAC,GAAG,EAAC,GAAG,aACT,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,CACzB,kBAAU,UAAU,YAClB,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,MAAM,gBACA,cAAc,EACzB,KAAK,EAAC,cAAc,mBACL,KAAK,EACpB,OAAO,EAAE,cAAc,GACvB,GACG,CACR,EACA,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,MAAM,IACL,OAAO,EAAC,OAAO;oBACf,sGAAsG;oBACtG,gGAAgG;oBAChG,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EACtC,OAAO,EAAE,eAAe,gBACb,wBAAwB,EACnC,KAAK,EAAC,QAAQ,EACd,IAAI,EAAC,OAAO,GACZ,CACH,CAAC,CAAC,CAAC,CACF,eAAe,IAAI,CACjB,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,eAAe,gBACb,gBAAgB,EAC3B,KAAK,EAAC,gBAAgB,EACtB,IAAI,EAAC,OAAO,GACZ,CACH,CACF,IACG,GAER,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
1
|
+
/** What PatientCard's forms share: the identity keys, the sex options, and no autofill. */
|
|
2
|
+
import { type Sex } from "@photonhealth/client";
|
|
3
|
+
/**
|
|
4
|
+
* What network-api needs to add a patient. While the prescriber is still finding or filling them in, the server's
|
|
5
|
+
* "still needed" about these is what the card asks for next, not an error to show.
|
|
6
|
+
*/
|
|
7
|
+
export declare const IDENTITY_KEYS: string[];
|
|
3
8
|
/**
|
|
4
9
|
* These fields describe the patient, not the prescriber: keep the browser's autofill and password managers
|
|
5
10
|
* (1Password, LastPass, Bitwarden, Dashlane) from offering the prescriber's own name, birthday, phone or address.
|
|
@@ -16,27 +21,4 @@ export declare const SEX_OPTIONS: {
|
|
|
16
21
|
value: Sex;
|
|
17
22
|
label: string;
|
|
18
23
|
}[];
|
|
19
|
-
/**
|
|
20
|
-
* Phone / email / address, inside the demographics editor. Nothing here is required up front: the server
|
|
21
|
-
* decides (a send needs a phone), and the editor opens itself when a send fails for want of one —
|
|
22
|
-
* `addressRequest`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function ContactFields({ phone, email, address, onSave, addressRequest, }: {
|
|
25
|
-
phone: string | null;
|
|
26
|
-
email: string | null;
|
|
27
|
-
address: {
|
|
28
|
-
street1: string | null;
|
|
29
|
-
street2: string | null;
|
|
30
|
-
city: string | null;
|
|
31
|
-
state: string | null;
|
|
32
|
-
postalCode: string | null;
|
|
33
|
-
} | null;
|
|
34
|
-
onSave: (contact: {
|
|
35
|
-
phone?: string;
|
|
36
|
-
email?: string;
|
|
37
|
-
address?: AddressInput;
|
|
38
|
-
}) => void;
|
|
39
|
-
addressRequest: string | null;
|
|
40
|
-
}): import("react").JSX.Element;
|
|
41
|
-
export {};
|
|
42
24
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/components/patient/fields.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/components/patient/fields.tsx"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,aAAa,UAKzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAEX,mGAAmG;AACnG,eAAO,MAAM,WAAW,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAItD,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
/** Fields both the intake form and the details editor use: sex, contact, no autofill. */
|
|
3
|
-
import { useComponents } from "../../primitives/index.js";
|
|
1
|
+
/** What PatientCard's forms share: the identity keys, the sex options, and no autofill. */
|
|
4
2
|
import {} from "@photonhealth/client";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
/**
|
|
4
|
+
* What network-api needs to add a patient. While the prescriber is still finding or filling them in, the server's
|
|
5
|
+
* "still needed" about these is what the card asks for next, not an error to show.
|
|
6
|
+
*/
|
|
7
|
+
export const IDENTITY_KEYS = [
|
|
8
|
+
"demographic.name.first",
|
|
9
|
+
"demographic.name.last",
|
|
10
|
+
"demographic.dateOfBirth",
|
|
11
|
+
"demographic.sex",
|
|
12
|
+
];
|
|
8
13
|
/**
|
|
9
14
|
* These fields describe the patient, not the prescriber: keep the browser's autofill and password managers
|
|
10
15
|
* (1Password, LastPass, Bitwarden, Dashlane) from offering the prescriber's own name, birthday, phone or address.
|
|
@@ -22,51 +27,4 @@ export const SEX_OPTIONS = [
|
|
|
22
27
|
{ value: "FEMALE", label: "Female" },
|
|
23
28
|
{ value: "UNKNOWN", label: "Unknown" },
|
|
24
29
|
];
|
|
25
|
-
/**
|
|
26
|
-
* Phone / email / address, inside the demographics editor. Nothing here is required up front: the server
|
|
27
|
-
* decides (a send needs a phone), and the editor opens itself when a send fails for want of one —
|
|
28
|
-
* `addressRequest`.
|
|
29
|
-
*/
|
|
30
|
-
export function ContactFields({ phone, email, address, onSave, addressRequest, }) {
|
|
31
|
-
const { Alert, Grid, Input, Stack } = useComponents();
|
|
32
|
-
const [phoneValue, setPhone] = useState(formatPhone(phone));
|
|
33
|
-
const [emailValue, setEmail] = useState(email ?? "");
|
|
34
|
-
const [street1, setStreet1] = useState(address?.street1 ?? "");
|
|
35
|
-
const [street2, setStreet2] = useState(address?.street2 ?? "");
|
|
36
|
-
const [city, setCity] = useState(address?.city ?? "");
|
|
37
|
-
const [state, setState] = useState(address?.state ?? "");
|
|
38
|
-
const [postalCode, setPostalCode] = useState(address?.postalCode ?? "");
|
|
39
|
-
// Save early: each field saves when you leave it (the browser validates phone / email first);
|
|
40
|
-
// the address saves once it's complete and you leave it.
|
|
41
|
-
const addressComplete = Boolean(street1.trim() && city.trim() && state.trim() && postalCode.trim());
|
|
42
|
-
const savePhone = (input) => {
|
|
43
|
-
setPhone(formatPhone(phoneValue));
|
|
44
|
-
if (input.checkValidity() && toE164(phoneValue) !== (phone || undefined))
|
|
45
|
-
onSave({ phone: toE164(phoneValue) ?? "" });
|
|
46
|
-
};
|
|
47
|
-
const saveEmail = (input) => {
|
|
48
|
-
if (input.checkValidity() && emailValue.trim() !== (email ?? ""))
|
|
49
|
-
onSave({ email: emailValue.trim() });
|
|
50
|
-
};
|
|
51
|
-
const saveAddress = () => {
|
|
52
|
-
if (!addressComplete)
|
|
53
|
-
return;
|
|
54
|
-
const next = {
|
|
55
|
-
street1: street1.trim(),
|
|
56
|
-
street2: street2.trim() || undefined,
|
|
57
|
-
city: city.trim(),
|
|
58
|
-
state: state.trim().toUpperCase(),
|
|
59
|
-
postalCode: postalCode.trim(),
|
|
60
|
-
country: "US",
|
|
61
|
-
};
|
|
62
|
-
const same = next.street1 === (address?.street1 ?? "") &&
|
|
63
|
-
(next.street2 ?? "") === (address?.street2 ?? "") &&
|
|
64
|
-
next.city === (address?.city ?? "") &&
|
|
65
|
-
next.state === (address?.state ?? "") &&
|
|
66
|
-
next.postalCode === (address?.postalCode ?? "");
|
|
67
|
-
if (!same)
|
|
68
|
-
onSave({ address: next });
|
|
69
|
-
};
|
|
70
|
-
return (_jsxs(Stack, { gap: "2", children: [addressRequest && _jsx(Alert, { tone: "warning", title: phone ? "Address needed to send" : "Phone needed to send" }), _jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "phone", isOptional: true, children: _jsx(Input, { label: "Phone", type: "tel", inputMode: "tel", pattern: PHONE_PATTERN, value: phoneValue, onChange: (e) => setPhone(e.target.value), onBlur: (e) => savePhone(e.currentTarget), ...noAutofill }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "email", isOptional: true, children: _jsx(Input, { label: "Email", type: "email", inputMode: "email", value: emailValue, onChange: (e) => setEmail(e.target.value), onBlur: (e) => saveEmail(e.currentTarget), ...noAutofill }) })] }), _jsx("div", { onBlur: saveAddress, children: _jsxs(Stack, { gap: "3", children: [_jsxs(Grid, { min: "120px", gap: "3", children: [_jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_street1", isOptional: true, children: _jsx(Input, { label: "Street", value: street1, onChange: (e) => setStreet1(e.target.value), ...noAutofill }) }), _jsx(TrackedField, { formName: "update_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: "update_patient_form", fieldName: "address_city", isOptional: true, children: _jsx(Input, { label: "City", value: city, onChange: (e) => setCity(e.target.value), ...noAutofill }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_state", isOptional: true, children: _jsx(Input, { label: "State", value: state, onChange: (e) => setState(e.target.value), maxLength: 2, ...noAutofill }) }), _jsx(TrackedField, { formName: "update_patient_form", fieldName: "address_zip", isOptional: true, children: _jsx(Input, { label: "ZIP", value: postalCode, onChange: (e) => setPostalCode(e.target.value), inputMode: "numeric", ...noAutofill }) })] })] }) })] }));
|
|
71
|
-
}
|
|
72
30
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/components/patient/fields.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/components/patient/fields.tsx"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,wBAAwB;IACxB,uBAAuB;IACvB,yBAAyB;IACzB,iBAAiB;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY,EAAE,KAAK;IACnB,gBAAgB,EAAE,MAAM;IACxB,eAAe,EAAE,MAAM;IACvB,eAAe,EAAE,MAAM;IACvB,gBAAgB,EAAE,OAAO;CACjB,CAAC;AAEX,mGAAmG;AACnG,MAAM,CAAC,MAAM,WAAW,GAAoC;IAC1D,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;CACvC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ParsedPatientSearchQuery {
|
|
2
|
+
name?: {
|
|
3
|
+
first?: string;
|
|
4
|
+
last?: string;
|
|
5
|
+
};
|
|
6
|
+
dateOfBirth?: string;
|
|
7
|
+
phone?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* What was typed, as the server takes it. Anything that reads as a date, a phone or an email is taken as
|
|
12
|
+
* one; what's left is the name, first word first. A single word is a first name — PatientSearch's `searchBoth` says when
|
|
13
|
+
* it's worth trying as a last name too.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parsePatientSearchQuery(text: string): ParsedPatientSearchQuery;
|
|
16
|
+
//# sourceMappingURL=parsePatientSearchQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePatientSearchQuery.d.ts","sourceRoot":"","sources":["../../../src/components/patient/parsePatientSearchQuery.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAuB9E"}
|