fix: match PDF-imported patients by member ID when DOB is missing on record

MassHealth eligibility lookups via the AI chatbot only matched existing
patients on memberId+DOB, so patients imported from PDF extraction (which
have a member ID but no stored birthday) were treated as new/unknown even
though they already exist in the system.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 11:11:47 -04:00
co-authored by Claude Sonnet 5
parent 8c65c3d625
commit b30bed8903
5 changed files with 47 additions and 41 deletions
@@ -11,6 +11,7 @@ export interface IStorage {
getPatient(id: number): Promise<Patient | undefined>;
getPatientByInsuranceId(insuranceId: string): Promise<Patient | null>;
getPatientByInsuranceIdAndDob(insuranceId: string, dob: Date): Promise<Patient | null>;
getPatientByInsuranceIdNoDob(insuranceId: string): Promise<Patient | null>;
getAllPatients(): Promise<Patient[]>;
getRecentPatients(limit: number, offset: number): Promise<Patient[]>;
getPatientsByIds(ids: number[]): Promise<Patient[]>;
@@ -74,6 +75,12 @@ export const patientsStorage: IStorage = {
});
},
async getPatientByInsuranceIdNoDob(insuranceId: string): Promise<Patient | null> {
return db.patient.findFirst({
where: { insuranceId, dateOfBirth: null },
});
},
async getRecentPatients(limit: number, offset: number): Promise<Patient[]> {
return db.patient.findMany({
skip: offset,