update
This commit is contained in:
@@ -340,6 +340,108 @@ class ReportController extends Controller
|
||||
? 'MEMENUHI TARGET'
|
||||
: 'TIDAK MEMENUHI TARGET';
|
||||
}
|
||||
private function normalizeBtaSpValue($value) {
|
||||
$value = trim(strip_tags((string) $value));
|
||||
$normalized = strtolower(str_replace(' ', '', $value));
|
||||
|
||||
if ($normalized === '+++' || $normalized === '3+') {
|
||||
return '+++';
|
||||
}
|
||||
if ($normalized === '++' || $normalized === '2+') {
|
||||
return '++';
|
||||
}
|
||||
if ($normalized === '+' || $normalized === '1+') {
|
||||
return '+';
|
||||
}
|
||||
if (in_array($normalized, ['1-9', '1s/d9', '1sd9'], true)) {
|
||||
return '1-9';
|
||||
}
|
||||
if (in_array($normalized, ['neg', 'negatif', 'negative'], true)) {
|
||||
return 'Neg';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private function buildMikroskopisBtaSpReport($bulan, $tahun) {
|
||||
$nilaiList = ['+++', '++', '+', '1-9', 'Neg'];
|
||||
$report = [];
|
||||
|
||||
foreach (['L' => 'Laki-laki', 'P' => 'Perempuan'] as $kodeKelamin => $labelKelamin) {
|
||||
foreach ($nilaiList as $nilai) {
|
||||
$report[$kodeKelamin][$nilai] = [
|
||||
'kelamin' => $labelKelamin,
|
||||
'nilai' => $nilai,
|
||||
'pagi' => 0,
|
||||
'sewaktu' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$query = DB::table('db_komponenjawaban')
|
||||
->select('db_komponenjawaban.komponen', 'db_komponenjawaban.isidata', 'periksa.jkpasien')
|
||||
->leftJoin('periksa', 'db_komponenjawaban.accnumber', 'periksa.nofoto')
|
||||
->where(function ($q) {
|
||||
$q->where('db_komponenjawaban.komponen', 'LIKE', '%hasilpemeriksaantbbiakan_pagi%')
|
||||
->orWhere('db_komponenjawaban.komponen', 'LIKE', '%hasilpemeriksaantbbiakan_sewaktu%');
|
||||
})
|
||||
->whereNotNull('db_komponenjawaban.isidata')
|
||||
->where('db_komponenjawaban.isidata', '!=', '')
|
||||
->whereYear('periksa.daftar', $tahun);
|
||||
|
||||
if ($bulan != 'ALL' && $bulan != 'Pick Month') {
|
||||
$query->whereMonth('periksa.daftar', $bulan);
|
||||
}
|
||||
|
||||
foreach ($query->get() as $row) {
|
||||
$kelamin = $row->jkpasien == 'L' ? 'L' : 'P';
|
||||
$nilai = $this->normalizeBtaSpValue($row->isidata);
|
||||
|
||||
if ($nilai === null || !isset($report[$kelamin][$nilai])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stripos($row->komponen, 'hasilpemeriksaantbbiakan_pagi') !== false) {
|
||||
$report[$kelamin][$nilai]['pagi']++;
|
||||
}
|
||||
|
||||
if (stripos($row->komponen, 'hasilpemeriksaantbbiakan_sewaktu') !== false) {
|
||||
$report[$kelamin][$nilai]['sewaktu']++;
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge(array_values($report['L']), array_values($report['P']));
|
||||
}
|
||||
public function genMikroskopisBtaSpReport(Request $request) {
|
||||
$bulan = $request->input('bulan');
|
||||
$tahun = $request->input('tahun');
|
||||
|
||||
if ($tahun == '' OR is_null($tahun)){
|
||||
$getarray = explode('?', $bulan);
|
||||
$bulan = $getarray[0] ?? date('m');
|
||||
$tahun = $getarray[1] ?? date('Y');
|
||||
$bulan = str_replace('bulan=', '', $bulan);
|
||||
$tahun = str_replace('tahun=', '', $tahun);
|
||||
}
|
||||
|
||||
$nilaiList = ['+++', '++', '+', '1-9', 'Neg'];
|
||||
$reportRows = collect($this->buildMikroskopisBtaSpReport($bulan, $tahun));
|
||||
$rekapLaki = $reportRows
|
||||
->where('kelamin', 'Laki-laki')
|
||||
->keyBy('nilai')
|
||||
->toArray();
|
||||
$rekapPerempuan = $reportRows
|
||||
->where('kelamin', 'Perempuan')
|
||||
->keyBy('nilai')
|
||||
->toArray();
|
||||
|
||||
return view('cetak.mikroskopisbtasp', compact(
|
||||
'rekapLaki',
|
||||
'rekapPerempuan',
|
||||
'nilaiList',
|
||||
'bulan',
|
||||
'tahun'
|
||||
));
|
||||
}
|
||||
public function report(Request $request) {
|
||||
$bulan = $request->input('bulan');
|
||||
$tahun = $request->input('tahun');
|
||||
@@ -355,6 +457,9 @@ class ReportController extends Controller
|
||||
$order = $request->input('order') ?? 'id desc';
|
||||
$filterscount = $request->input('filterscount') ?? 0;
|
||||
$isMdrReport = $jenisreport == 'list_hasil_mdr';
|
||||
if ($jenisreport == 'mikroskopis_bta_sp') {
|
||||
return response()->json($this->buildMikroskopisBtaSpReport($bulan, $tahun));
|
||||
}
|
||||
if ($jenisreport == 'biorepository'){
|
||||
if ($bulan == 'ALL'){
|
||||
$queryBiorepo = DB::table('db_komponenjawaban')
|
||||
|
||||
Reference in New Issue
Block a user