feat(check-all-eligibility) - specific aptmnt status added

This commit is contained in:
2025-11-03 22:20:49 +05:30
parent e47041baf6
commit e86360a364
3 changed files with 22 additions and 4 deletions

View File

@@ -647,9 +647,23 @@ router.post(
// Update patient status based on seleniumResult.eligibility // Update patient status based on seleniumResult.eligibility
const newStatus = const newStatus =
seleniumResult?.eligibility === "Y" ? "ACTIVE" : "INACTIVE"; seleniumResult?.eligibility === "Y" ? "ACTIVE" : "INACTIVE";
// 1. updating patient
await storage.updatePatient(updatedPatient.id, { status: newStatus }); await storage.updatePatient(updatedPatient.id, { status: newStatus });
resultItem.patientUpdateStatus = `Patient status updated to ${newStatus}`; resultItem.patientUpdateStatus = `Patient status updated to ${newStatus}`;
// 2. updating appointment status - for aptmnt page
try {
await storage.updateAppointment(Number(apt.id), {
eligibilityStatus: newStatus,
});
resultItem.appointmentUpdateStatus = `Appointment eligibility set to ${newStatus}`;
} catch (apptUpdateErr: any) {
resultItem.warning =
(resultItem.warning ? resultItem.warning + " | " : "") +
`Failed to update appointment eligibility: ${apptUpdateErr?.message ?? String(apptUpdateErr)}`;
}
// If PDF exists, upload to PdfGroup (ELIGIBILITY_STATUS) // If PDF exists, upload to PdfGroup (ELIGIBILITY_STATUS)
if ( if (
seleniumResult?.pdf_path && seleniumResult?.pdf_path &&

View File

@@ -71,7 +71,7 @@ interface ScheduledAppointment {
id?: number; id?: number;
patientId: number; patientId: number;
patientName: string; patientName: string;
patientStatus: PatientStatus; eligibilityStatus: PatientStatus;
staffId: number; staffId: number;
date: string | Date; date: string | Date;
startTime: string | Date; startTime: string | Date;
@@ -403,10 +403,12 @@ export default function AppointmentsPage() {
).map((apt) => { ).map((apt) => {
// Find patient name // Find patient name
const patient = patientsFromDay.find((p) => p.id === apt.patientId); const patient = patientsFromDay.find((p) => p.id === apt.patientId);
const patientName = patient const patientName = patient
? `${patient.firstName} ${patient.lastName}` ? `${patient.firstName} ${patient.lastName}`
: "Unknown Patient"; : "Unknown Patient";
const patientStatus = patient?.status;
const eligibilityStatus = (apt as any).eligibilityStatus as PatientStatus;
const staffId = Number(apt.staffId ?? 1); const staffId = Number(apt.staffId ?? 1);
@@ -422,7 +424,7 @@ export default function AppointmentsPage() {
const processed = { const processed = {
...apt, ...apt,
patientName, patientName,
patientStatus, eligibilityStatus,
staffId, staffId,
status: apt.status ?? null, status: apt.status ?? null,
date: formatLocalDate(apt.date), date: formatLocalDate(apt.date),
@@ -621,7 +623,7 @@ export default function AppointmentsPage() {
onContextMenu={(e) => handleContextMenu(e, appointment.id ?? 0)} onContextMenu={(e) => handleContextMenu(e, appointment.id ?? 0)}
> >
<PatientStatusBadge <PatientStatusBadge
status={appointment.patientStatus ?? "UNKNOWN"} status={appointment.eligibilityStatus ?? "UNKNOWN"}
className="pointer-events-auto" // ensure tooltip works className="pointer-events-auto" // ensure tooltip works
size={30} // bump size up from 10 → 14 size={30} // bump size up from 10 → 14
/> />

View File

@@ -85,6 +85,8 @@ model Appointment {
status String @default("scheduled") // "scheduled", "completed", "cancelled", "no-show" status String @default("scheduled") // "scheduled", "completed", "cancelled", "no-show"
createdAt DateTime @default(now()) createdAt DateTime @default(now())
eligibilityStatus PatientStatus @default(UNKNOWN)
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade) patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id]) user User @relation(fields: [userId], references: [id])
staff Staff? @relation(fields: [staffId], references: [id]) staff Staff? @relation(fields: [staffId], references: [id])