claim-page - lastvisit fixed
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -37,6 +37,3 @@ dist/
|
|||||||
|
|
||||||
# env
|
# env
|
||||||
*.env
|
*.env
|
||||||
|
|
||||||
#temp
|
|
||||||
1.html
|
|
||||||
@@ -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(
|
||||||
|
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
|
||||||
|
); // Sort descending by date
|
||||||
|
|
||||||
|
if (patientAppointments.length > 0) {
|
||||||
|
const latestAppointment = patientAppointments[0];
|
||||||
acc.push({
|
acc.push({
|
||||||
patientId: patient.id,
|
patientId: patient.id,
|
||||||
patientName: `${patient.firstName} ${patient.lastName}`,
|
patientName: `${patient.firstName} ${patient.lastName}`,
|
||||||
appointmentId: Number(appointment.id),
|
appointmentId: latestAppointment!.id,
|
||||||
insuranceProvider: patient.insuranceProvider || "N/A",
|
insuranceProvider: patient.insuranceProvider || "N/A",
|
||||||
insuranceId: patient.insuranceId || "N/A",
|
insuranceId: patient.insuranceId || "N/A",
|
||||||
lastAppointment: String(appointment.date),
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user