This commit is contained in:
Your Name
2026-11-17 14:05:05 +08:00
parent 08892f4270
commit 64df667585
8 changed files with 2021 additions and 551 deletions
@@ -164,6 +164,21 @@ final class AssistantServiceAlert
'scan' => self::scanStatus(), 'coverage' => self::coverage(), 'empty_reason' => ''];
if (!$page['schema_ready']) { return $page; }
$base = self::scoped($adminId, $actor);
if (!empty($p['assistant_id'])) {
$aid = (int) $p['assistant_id'];
$patientSql = Db::name('tcm_diagnosis')
->alias('d')
->whereNull('d.delete_time')
->where('d.status', 1)
->where('d.assistant_id', $aid)
->distinct(true)
->field('d.patient_id')
->buildSql();
$base->where(static function ($nested) use ($aid, $patientSql): void {
$nested->where('a.staff_admin_id', $aid)
->whereOrRaw('a.patient_id IN ' . $patientSql);
});
}
$page['summary'] = [
'open' => self::count(clone $base, ['a.status' => 'open']),
'high_open' => self::count(clone $base, ['a.status' => 'open', 'a.severity' => 'high']),