fix: DDMA claim checkbox, eligibility patient name, and ID+DOB patient lookup

- Claim step2: robust member checkbox selection with page-wide fallback
- Eligibility: take patient name from 'Benefits for' heading, not subscriber name
- Processor: update the patient just created/matched by ID+DOB, not first ID match

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 15:56:03 -04:00
co-authored by Claude Sonnet 5
parent dcf2ff536a
commit ce25cdd2a2
4 changed files with 55 additions and 6 deletions
+7 -2
View File
@@ -167,12 +167,17 @@ export async function createOrUpdatePatientByInsuranceId(options: {
}
try {
await storage.createPatient(patientData);
const created = await storage.createPatient(patientData);
console.log(`[createOrUpdatePatient] patient created successfully for insuranceId="${normalizedId}"`);
// Return the record just created — family members share an insuranceId, so an
// id-only lookup could return a different member.
if (created?.id) return created;
} catch (dbErr: any) {
console.error(`[createOrUpdatePatient] DB create failed:`, dbErr?.message ?? dbErr);
throw dbErr;
}
return storage.getPatientByInsuranceId(normalizedId);
return dobDate
? storage.getPatientByInsuranceIdAndDob(normalizedId, dobDate)
: storage.getPatientByInsuranceId(normalizedId);
}