feat: MassHealth PDF import auto-pays full balance + patient name fix
- PDF import now marks payments as PAID when MassHealth patient's mhPaidAmount >= totalBilled (no patient balance) - Newly created patients from MH vouchers get insuranceProvider = 'MassHealth' - Existing patients with blank insuranceProvider get it filled on import - Fix: update patient name from PDF if existing record has empty name - Various frontend/selenium/route updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,22 +18,38 @@ export const PatientForm = forwardRef(({ patient, extractedInfo, onSubmit }, ref
|
||||
: insertPatientSchema.extend({ userId: z.number().optional() }), [isEditing]);
|
||||
const normalizeInsuranceProvider = (val) => {
|
||||
const p = (val || "").toLowerCase().trim();
|
||||
if (p.includes("masshealth") || p === "mh" || p === "mass health") return "MassHealth";
|
||||
if (p.includes("commonwealth care alliance") || p === "cca") return "CCA";
|
||||
if (p.includes("ddma")) return "DDMA";
|
||||
if (p.includes("delta dental") || p.includes("delta ins") || p === "deltains") return "DeltaIns";
|
||||
if (p.includes("tufts") || p.includes("dentaquest") || p === "tuftssco") return "TuftsSCO";
|
||||
if (p.includes("united sco") || p === "unitedsco") return "UnitedSCO";
|
||||
if (p.includes("cmsp")) return "CMSP";
|
||||
if (p.includes("bcbs") || p.includes("blue cross")) return "BCBS";
|
||||
if (p.includes("united aapr") || p === "unitedaapr") return "UnitedAAPR";
|
||||
if (p.includes("aetna")) return "Aetna";
|
||||
if (p.includes("altus")) return "Altus";
|
||||
if (p.includes("metlife")) return "MetlifeDental";
|
||||
if (p.includes("cigna")) return "Cigna";
|
||||
if (p.includes("delta wa") || p === "deltawa") return "DeltaWA";
|
||||
if (p.includes("delta il") || p === "deltail") return "DeltaIL";
|
||||
if (p.includes("other")) return "Others";
|
||||
if (p.includes("masshealth") || p === "mh" || p === "mass health")
|
||||
return "MassHealth";
|
||||
if (p.includes("commonwealth care alliance") || p === "cca")
|
||||
return "CCA";
|
||||
if (p.includes("ddma"))
|
||||
return "DDMA";
|
||||
if (p.includes("delta dental") || p.includes("delta ins") || p === "deltains")
|
||||
return "DeltaIns";
|
||||
if (p.includes("tufts") || p.includes("dentaquest") || p === "tuftssco")
|
||||
return "TuftsSCO";
|
||||
if (p.includes("united sco") || p === "unitedsco")
|
||||
return "UnitedSCO";
|
||||
if (p.includes("cmsp"))
|
||||
return "CMSP";
|
||||
if (p.includes("bcbs") || p.includes("blue cross"))
|
||||
return "BCBS";
|
||||
if (p.includes("united aapr") || p === "unitedaapr")
|
||||
return "UnitedAAPR";
|
||||
if (p.includes("aetna"))
|
||||
return "Aetna";
|
||||
if (p.includes("altus"))
|
||||
return "Altus";
|
||||
if (p.includes("metlife"))
|
||||
return "MetlifeDental";
|
||||
if (p.includes("cigna"))
|
||||
return "Cigna";
|
||||
if (p.includes("delta wa") || p === "deltawa")
|
||||
return "DeltaWA";
|
||||
if (p.includes("delta il") || p === "deltail")
|
||||
return "DeltaIL";
|
||||
if (p.includes("other"))
|
||||
return "Others";
|
||||
return val || "";
|
||||
};
|
||||
const computedDefaultValues = useMemo(() => {
|
||||
@@ -87,15 +103,16 @@ export const PatientForm = forwardRef(({ patient, extractedInfo, onSubmit }, ref
|
||||
useEffect(() => {
|
||||
if (patient) {
|
||||
const { id, userId, createdAt, ...sanitizedPatient } = patient;
|
||||
const normalized = normalizeInsuranceProvider(patient.insuranceProvider);
|
||||
const resetValues = {
|
||||
...sanitizedPatient,
|
||||
dateOfBirth: patient.dateOfBirth
|
||||
? formatLocalDate(new Date(patient.dateOfBirth))
|
||||
: null,
|
||||
insuranceProvider: normalizeInsuranceProvider(patient.insuranceProvider),
|
||||
insuranceProvider: normalized,
|
||||
};
|
||||
const normalized = normalizeInsuranceProvider(patient.insuranceProvider);
|
||||
form.reset(resetValues);
|
||||
// Explicit setValue ensures the controlled Select re-renders with the new value
|
||||
form.setValue("insuranceProvider", normalized);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -579,7 +579,7 @@ export default function PaymentsRecentTable({
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isMhChecking ? "Checking..." : "Check MH Payment"}
|
||||
{isMhChecking ? "Checking..." : "Check Single MH Payment"}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
|
||||
Reference in New Issue
Block a user