更新bug
This commit is contained in:
@@ -293,20 +293,32 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
$prescribedDiagnosisIds = $rxQ->column('diagnosis_id');
|
||||
$prescribedDiagnosisIds = array_flip($prescribedDiagnosisIds ?: []);
|
||||
}
|
||||
// 当前页预约关联的处方(按 appointment_id,取最新一条):用于「开方/查看」与审核状态
|
||||
// 当前页预约关联的处方(按 appointment_id,优先最新未作废,否则最新一条):
|
||||
// 用于本次挂号的「开方/编辑/查看」与审核状态。
|
||||
$appointmentIds = array_filter(array_map('intval', array_column($lists, 'id')));
|
||||
$rxByAppointmentId = [];
|
||||
$fallbackRxByAppointmentId = [];
|
||||
if (!empty($appointmentIds)) {
|
||||
$rxRows = Prescription::whereIn('appointment_id', $appointmentIds)
|
||||
->whereNull('delete_time')
|
||||
->where('void_status', 0)
|
||||
->order('id', 'desc')
|
||||
->field(['id', 'appointment_id', 'audit_status', 'void_status', 'is_system_auto'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($rxRows as $rx) {
|
||||
$aid = (int) ($rx['appointment_id'] ?? 0);
|
||||
if ($aid > 0 && !isset($rxByAppointmentId[$aid])) {
|
||||
if ($aid <= 0) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($fallbackRxByAppointmentId[$aid])) {
|
||||
$fallbackRxByAppointmentId[$aid] = $rx;
|
||||
}
|
||||
if ((int) ($rx['void_status'] ?? 0) === 0 && !isset($rxByAppointmentId[$aid])) {
|
||||
$rxByAppointmentId[$aid] = $rx;
|
||||
}
|
||||
}
|
||||
foreach ($fallbackRxByAppointmentId as $aid => $rx) {
|
||||
if (!isset($rxByAppointmentId[$aid])) {
|
||||
$rxByAppointmentId[$aid] = $rx;
|
||||
}
|
||||
}
|
||||
@@ -353,6 +365,8 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
|
||||
$apptId = (int) ($item['id'] ?? 0);
|
||||
$apptRx = $rxByAppointmentId[$apptId] ?? null;
|
||||
$item['current_has_prescription'] = $apptRx !== null ? 1 : 0;
|
||||
$item['current_prescription_id'] = $apptRx !== null ? (int) ($apptRx['id'] ?? 0) : 0;
|
||||
$item['prescription_audit_status'] = $apptRx !== null ? (int) ($apptRx['audit_status'] ?? -1) : -1;
|
||||
$item['prescription_void_status'] = $apptRx !== null ? (int) ($apptRx['void_status'] ?? 0) : 0;
|
||||
$item['prescription_is_system_auto'] = $apptRx !== null ? (int) ($apptRx['is_system_auto'] ?? 0) : 0;
|
||||
|
||||
Reference in New Issue
Block a user