add sequencing tab

This commit is contained in:
2026-03-30 11:04:03 +07:00
parent 34358e3ee7
commit f0a5079b15
12 changed files with 125979 additions and 271 deletions

View File

@@ -727,28 +727,20 @@ class DashboardService
$q->select('lab_code')
->from('surveillance_cases')
->where('surveillance_id', $surveillanceId)
->whereRaw(
"(year_data > ? OR (year_data = ? AND week_data >= ?))",
[$startYear, $startYear, $startWeek]
)
->whereRaw(
"(year_data < ? OR (year_data = ? AND week_data <= ?))",
[$endYear, $endYear, $endWeek]
);
->whereRaw("(year_data > ? OR (year_data = ? AND week_data >= ?))", [$startYear, $startYear, $startWeek])
->whereRaw("(year_data < ? OR (year_data = ? AND week_data <= ?))", [$endYear, $endYear, $endWeek]);
})
->where('case_lab_results.is_positive', 1)
->selectRaw("
case_lab_results.subtype,
COALESCE(NULLIF(case_lab_results.subtype, ''), 'Unsubtyped') as subtype,
COUNT(DISTINCT case_lab_results.lab_code) as total
")
->whereNotNull('case_lab_results.subtype')
->where('case_lab_results.subtype', '!=', '')
->where('case_lab_results.subtype', '!=', 'Positive')
->groupBy('case_lab_results.subtype')
->groupBy('subtype')
->orderByDesc('total')
->get();
@@ -846,5 +838,40 @@ class DashboardService
->get();
}
/*
|--------------------------------------------------------------------------
| sequencing trend
|--------------------------------------------------------------------------
*/
public function sequencingTrend($surveillanceId, $startYear, $startWeek, $endYear, $endWeek)
{
return CaseLabResult::join(
'surveillance_cases',
'case_lab_results.lab_code',
'=',
'surveillance_cases.lab_code'
)
->where('surveillance_cases.surveillance_id', $surveillanceId)
->where('case_lab_results.is_positive', 1)
->whereNotNull('subtype')
->where(function ($q) use ($startYear, $startWeek, $endYear, $endWeek) {
$q->whereRaw("(year_data > ? OR (year_data = ? AND week_data >= ?))", [$startYear, $startYear, $startWeek])
->whereRaw("(year_data < ? OR (year_data = ? AND week_data <= ?))", [$endYear, $endYear, $endWeek]);
})
->selectRaw("
surveillance_cases.week_data as period,
subtype,
COUNT(DISTINCT surveillance_cases.lab_code) as total
")
->groupBy('period', 'subtype')
->orderBy('period')
->get();
}
}