fix: BCBS MA — identify patient by member ID + DOB, prevent overwriting subscriber
- Added getPatientByInsuranceIdAndDob to storage - Processor uses insuranceId + DOB as unique key instead of insuranceId alone - Dependent with same subscriber ID but different DOB gets a new patient record (bypasses createOrUpdatePatientByInsuranceId which would overwrite subscriber) - Name extraction anchored to "Relationship:" to scope Patient Info column only Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ export interface IStorage {
|
||||
// Patient methods
|
||||
getPatient(id: number): Promise<Patient | undefined>;
|
||||
getPatientByInsuranceId(insuranceId: string): Promise<Patient | null>;
|
||||
getPatientByInsuranceIdAndDob(insuranceId: string, dob: Date): Promise<Patient | null>;
|
||||
getAllPatients(): Promise<Patient[]>;
|
||||
getRecentPatients(limit: number, offset: number): Promise<Patient[]>;
|
||||
getPatientsByIds(ids: number[]): Promise<Patient[]>;
|
||||
@@ -60,6 +61,19 @@ export const patientsStorage: IStorage = {
|
||||
});
|
||||
},
|
||||
|
||||
async getPatientByInsuranceIdAndDob(insuranceId: string, dob: Date): Promise<Patient | null> {
|
||||
const startOfDay = new Date(dob);
|
||||
startOfDay.setHours(0, 0, 0, 0);
|
||||
const endOfDay = new Date(dob);
|
||||
endOfDay.setHours(23, 59, 59, 999);
|
||||
return db.patient.findFirst({
|
||||
where: {
|
||||
insuranceId,
|
||||
dateOfBirth: { gte: startOfDay, lte: endOfDay },
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async getRecentPatients(limit: number, offset: number): Promise<Patient[]> {
|
||||
return db.patient.findMany({
|
||||
skip: offset,
|
||||
|
||||
Reference in New Issue
Block a user