This commit is contained in:
Your Name
2026-08-07 09:16:15 +08:00
parent 8bbd6f7885
commit 16d301f302
354 changed files with 967 additions and 456 deletions
@@ -89,18 +89,17 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
$this->applyKeyword($query);
$statusFilter = $applyStatusFilter ? trim((string) ($this->params['status_filter'] ?? '')) : '';
if ($statusFilter === 'unconfirmed') {
$viewTable = (new DiagnosisViewRecord())->getTable();
$appointmentTable = (new Appointment())->getTable();
if ($statusFilter === 'unbooked') {
$query->whereNotExists(
"SELECT 1 FROM {$viewTable} confirm_row"
. ' WHERE confirm_row.diagnosis_id = d.id'
. ' AND confirm_row.is_confirmed = 1'
. ' AND confirm_row.delete_time IS NULL'
"SELECT 1 FROM {$appointmentTable} unbooked_apt"
. ' WHERE unbooked_apt.patient_id = d.id'
. ' AND unbooked_apt.status IN (' . implode(',', self::EFFECTIVE_APPOINTMENT_STATUSES) . ')'
);
}
$appointmentStatuses = self::EFFECTIVE_APPOINTMENT_STATUSES;
if ($statusFilter === 'booked') {
if (in_array($statusFilter, ['pending_interview', 'booked'], true)) {
$appointmentStatuses = [1];
} elseif ($statusFilter === 'completed') {
$appointmentStatuses = [3];
@@ -108,14 +107,17 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
$appointmentStatuses = [4];
}
$needsAppointmentFilter = in_array($statusFilter, ['booked', 'completed', 'missed'], true);
$needsAppointmentFilter = in_array(
$statusFilter,
['pending_interview', 'booked', 'completed', 'missed'],
true
);
[$startDate, $endDate] = $applyDateFilter ? $this->dateRange() : ['', ''];
if ($startDate !== '' || $endDate !== '') {
$needsAppointmentFilter = true;
}
if ($needsAppointmentFilter) {
$appointmentTable = (new Appointment())->getTable();
$conditions = [
'filter_apt.patient_id = d.id',
'filter_apt.status IN (' . implode(',', $appointmentStatuses) . ')',
@@ -245,6 +247,7 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
$today = date('Y-m-d');
$statusFilter = trim((string) ($this->params['status_filter'] ?? ''));
$preferredStatuses = [
'pending_interview' => [1],
'booked' => [1],
'completed' => [3],
'missed' => [4],
@@ -364,6 +367,6 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
private function appointmentStatusText(int $status): string
{
return [1 => '已挂号', 3 => '已完成', 4 => '已过号'][$status] ?? '未挂号';
return [1 => '待面诊', 3 => '已完成', 4 => '已过号'][$status] ?? '未预约';
}
}