claim-page - lastvisit fixed

This commit is contained in:
2025-06-12 19:45:32 +05:30
parent 20431a268f
commit dd814b902d
2 changed files with 20 additions and 18 deletions

3
.gitignore vendored
View File

@@ -37,6 +37,3 @@ dist/
# env # env
*.env *.env
#temp
1.html

View File

@@ -451,21 +451,26 @@ export default function ClaimsPage() {
}; };
// Get unique patients with appointments // Get unique patients with appointments
const patientsWithAppointments = appointments.reduce( const patientsWithAppointments = patients.reduce(
(acc, appointment) => { (acc, patient) => {
if (!acc.some((item) => item.patientId === appointment.patientId)) { const patientAppointments = appointments
const patient = patients.find((p) => p.id === appointment.patientId); .filter((appt) => appt.patientId === patient.id)
if (patient) { .sort(
acc.push({ (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
patientId: patient.id, ); // Sort descending by date
patientName: `${patient.firstName} ${patient.lastName}`,
appointmentId: Number(appointment.id), if (patientAppointments.length > 0) {
insuranceProvider: patient.insuranceProvider || "N/A", const latestAppointment = patientAppointments[0];
insuranceId: patient.insuranceId || "N/A", acc.push({
lastAppointment: String(appointment.date), patientId: patient.id,
}); patientName: `${patient.firstName} ${patient.lastName}`,
} appointmentId: latestAppointment!.id,
insuranceProvider: patient.insuranceProvider || "N/A",
insuranceId: patient.insuranceId || "N/A",
lastAppointment: String(latestAppointment!.date),
});
} }
return acc; return acc;
}, },
[] as Array<{ [] as Array<{
@@ -591,7 +596,7 @@ export default function ClaimsPage() {
</div> </div>
) : patientsWithAppointments.length > 0 ? ( ) : patientsWithAppointments.length > 0 ? (
<div className="divide-y"> <div className="divide-y">
{patientsWithAppointments.map((item) => ( {patientsWithAppointments.map((item: typeof patientsWithAppointments[number]) => (
<div <div
key={item.patientId} key={item.patientId}
className="py-4 flex items-center justify-between cursor-pointer hover:bg-gray-50" className="py-4 flex items-center justify-between cursor-pointer hover:bg-gray-50"