modified Sequencing Page

This commit is contained in:
pcalengratha
2026-04-20 16:02:08 +07:00
parent 90865276e1
commit b021f4c2ba
8 changed files with 465 additions and 45 deletions

View File

@@ -184,7 +184,6 @@ class DashboardController extends Controller
public function covidLineageRelativeOverTime(Request $request)
{
$range = $this->getEpiRange($request);
if (!$range) {
return response()->json(['error' => 'Missing epiweek range'], 400);
}
@@ -202,7 +201,6 @@ class DashboardController extends Controller
public function influenzaRelativeOverTime(Request $request)
{
$range = $this->getEpiRange($request);
if (!$range) {
return response()->json(['error' => 'Missing epiweek range'], 400);
}
@@ -218,6 +216,24 @@ class DashboardController extends Controller
}
public function influenzaRelativeOverTimeSequencing(Request $request)
{
$range = $this->getEpiRange($request);
if (!$range) {
return response()->json(['error' => 'Missing epiweek range'], 400);
}
$data = $this->service->influenzaRelativeOverTimeSequencing(
$range['startYear'],
$range['startWeek'],
$range['endYear'],
$range['endWeek']
);
return response()->json($data);
}

View File

@@ -1020,7 +1020,7 @@ class DashboardService
})
->selectRaw("
surveillance_cases.week_data as period,
concat(surveillance_cases.year_data,'-',surveillance_cases.week_data) as period,
subtype,
COUNT(DISTINCT surveillance_cases.lab_code) as total
")
@@ -1029,4 +1029,34 @@ class DashboardService
->orderBy('period')
->get();
}
public function influenzaRelativeOverTimeSequencing($startYear, $startWeek, $endYear, $endWeek)
{
return SurveillanceCase::join('case_lab_results', function ($join) {
$join->on('surveillance_cases.lab_code', '=', 'case_lab_results.lab_code')
->on('surveillance_cases.surveillance_id', '=', 'case_lab_results.surveillance_id');
})
->where(function ($q) use ($startYear, $startWeek, $endYear, $endWeek) {
$q->whereRaw(
"(surveillance_cases.year_data * 100 + surveillance_cases.week_data) BETWEEN ? AND ?",
[
$startYear * 100 + $startWeek,
$endYear * 100 + $endWeek
]
);
})
->whereRaw('case_lab_results.is_positive = 1 and surveillance_cases.surveillance_id in(6) and case_lab_results.indicator="Influenza"')
->selectRaw("
case_lab_results.pathogen_name as lineage,
concat(surveillance_cases.year_data,'-',surveillance_cases.week_data) as week,
COUNT(DISTINCT surveillance_cases.lab_code) as total
")
->groupBy(
'case_lab_results.pathogen_name',
'week'
)
->get();
}
}