feat: auto-populate patient fields from member ID on eligibility page

When a member ID is typed on the insurance eligibility page, debounced
lookup fills in date of birth, first name, and last name if the patient
already exists in the database.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-05-08 14:30:29 -04:00
parent 9908e5b5fd
commit e9296c68f9
7 changed files with 81 additions and 8 deletions

View File

@@ -110,6 +110,33 @@ export default function InsuranceStatusPage() {
}
}, [selectedPatient]);
// Auto-lookup patient by member ID when typed manually
useEffect(() => {
if (selectedPatient && memberId === (selectedPatient.insuranceId ?? "")) return;
if (!memberId) return;
const timer = setTimeout(async () => {
try {
const res = await apiRequest("GET", `/api/patients/by-insurance-id?insuranceId=${encodeURIComponent(memberId)}`);
if (!res.ok) return;
const patient: Patient | null = await res.json();
if (patient) {
setFirstName(patient.firstName ?? "");
setLastName(patient.lastName ?? "");
const dob =
typeof patient.dateOfBirth === "string"
? parseLocalDate(patient.dateOfBirth)
: patient.dateOfBirth ?? null;
setDateOfBirth(dob);
}
} catch {
// silently ignore lookup errors
}
}, 500);
return () => clearTimeout(timer);
}, [memberId, selectedPatient]);
// Add patient mutation
const addPatientMutation = useMutation({
mutationFn: async (patient: InsertPatient) => {