diff --git a/htdocs/app/Http/Controllers/Controller.php b/htdocs/app/Http/Controllers/Controller.php index bcf2b43d..dfbbeea6 100644 --- a/htdocs/app/Http/Controllers/Controller.php +++ b/htdocs/app/Http/Controllers/Controller.php @@ -32,6 +32,47 @@ use Session; class Controller extends BaseController { use AuthorizesRequests, ValidatesRequests; + private function cekBatasAtas($value, $rule) { + if (!$rule || !str_contains($rule, '>')) return false; + + $angka = (int) filter_var($rule, FILTER_SANITIZE_NUMBER_INT); + + return $value > $angka; + } + private function cekMidRange($value, $rule) { + if (!$rule) return false; + $rule = trim($rule); + + if ($rule === '-' || $rule === '') return false; + + if (!str_contains($rule, '-')) return false; + + [$min, $max] = array_map('trim', explode('-', $rule)); + + if (!is_numeric($min) || !is_numeric($max)) return false; + + return $value >= (int)$min && $value <= (int)$max; + } + private function cekBatasBawah($value, $rule) { + if (!$rule || !str_contains($rule, '<')) return false; + + $angka = (int) filter_var($rule, FILTER_SANITIZE_NUMBER_INT); + + return $value < $angka; + } + protected function cekInterpretasi($value, $data) { + if ($this->cekBatasAtas($value, $data->batasatas)) { + return "S"; + } + if ($this->cekMidRange($value, $data->midrange)) { + return "I"; + } + if ($this->cekBatasBawah($value, $data->batasbawah)) { + return "R"; + } + return null; + } + protected function getStyledValue($value, $color, $strong = false) { return $strong ? "$value" : "$value"; } diff --git a/htdocs/app/Http/Controllers/DokterController.php b/htdocs/app/Http/Controllers/DokterController.php index ba838825..90a96a50 100644 --- a/htdocs/app/Http/Controllers/DokterController.php +++ b/htdocs/app/Http/Controllers/DokterController.php @@ -1677,9 +1677,14 @@ class DokterController extends Controller ]); } if ($request->input('isi') == 'updatevaluemic'){ - RekapAntibiotik::where('id', $nofoto)->update([ - 'value' => $request->input('komponen') + $value = (int) $request->input('komponen'); + $data = RekapAntibiotik::findOrFail($nofoto); + $interpretation = $this->cekInterpretasi($value, $data); + $data->update([ + 'value' => $value, + 'interpretation' => $interpretation ]); + $pesan = $interpretation; } if ($request->input('isi') == 'updateinterpretationmic'){ RekapAntibiotik::where('id', $nofoto)->update([ @@ -2118,8 +2123,8 @@ class DokterController extends Controller } } public function getAdendum(Request $request) { - $nofoto = $request->input('val01'); - $arrayfiles = []; + $nofoto = $request->input('val01'); + $arrayfiles = []; $files = Riwayat::where('nofoto', $nofoto)->orderBy('created_at', 'ASC')->get(); foreach ($files as $file) { $arrayfiles[] = array( diff --git a/htdocs/app/Http/Controllers/FrontpageController.php b/htdocs/app/Http/Controllers/FrontpageController.php index cca4c425..d4fc62ba 100644 --- a/htdocs/app/Http/Controllers/FrontpageController.php +++ b/htdocs/app/Http/Controllers/FrontpageController.php @@ -40,7 +40,6 @@ use Carbon\Carbon; class FrontpageController extends Controller { protected $lisServiceUrl; - public function __construct() { $this->lisServiceUrl = env('LIS_SERVICE_URL', 'http://10.10.120.72:5000'); } diff --git a/htdocs/app/Http/Controllers/ReportController.php b/htdocs/app/Http/Controllers/ReportController.php index adae8b74..8f4f1ccc 100644 --- a/htdocs/app/Http/Controllers/ReportController.php +++ b/htdocs/app/Http/Controllers/ReportController.php @@ -309,65 +309,108 @@ class ReportController extends Controller } echo json_encode($lists); } else { - $query = Periksa::select('*'); + $query = Periksa::select('id', 'nofoto', 'noregister', 'nmpasien', 'tlppasien', 'tgllahirpasien', 'usia', 'alamatpasien', 'ktp', 'bpjs', 'asuransi', 'urgensi', 'asalpasien', 'klinisi', 'klinis', 'nmanalis', 'nmppdssenior', 'kd_spesimen', 'nm_spesimen', 'dlp', 'diagnosa2', 'mulai', 'verifikasi', 'status')->whereYear('mulai', $tahun); + if ($bulan !== 'ALL') { $query->whereMonth('mulai', $bulan); } - $periksa = $query - ->whereYear('mulai', $tahun) - ->orderBy('mulai', 'ASC') - ->get(); - if ($periksa->count() == 0) { + /** + * CURSOR → Streaming data, tidak boros memori + */ + $periksaCursor = $query->orderBy('mulai', 'ASC')->cursor(); + + $hasil = []; + + /** + * Karena cursor tidak bisa pluck di awal, + * kita kumpulkan accnumber & poli_id sambil streaming + */ + $acc = []; + $poli_ids = []; + + foreach ($periksaCursor as $r) { + $acc[] = $r->nofoto; + $poli_ids[] = $r->poli_id; + $hasil[] = $r; // simpan pointer row + } + + /** Jika tidak ada data */ + if (empty($hasil)) { return response()->json([]); } - $accnumbers = $periksa->pluck('nofoto')->toArray(); - $komponen = DB::table('db_komponenjawaban')->whereIn('accnumber', $accnumbers)->whereIn('komponen', ['id_bakteri01','id_bakteri02','id_mikroorganisme'])->get()->groupBy('accnumber'); - $poli = DB::table('poli')->whereIn('id', $periksa->pluck('poli_id'))->get()->keyBy('id'); - $hasil = $periksa->map(function($row) use ($komponen, $poli){ - $k = $komponen[$row->nofoto] ?? collect([]); - $row->id_bakteri01 = optional($k->firstWhere('komponen', 'id_bakteri01'))->isidata; - $row->id_bakteri02 = optional($k->firstWhere('komponen', 'id_bakteri02'))->isidata; - $row->bakteri = optional($k->firstWhere('komponen', 'bakteri'))->isidata; - $row->filefoto = "nofoto)."'>$row->nofoto"; - $p = $poli[$row->poli_id] ?? null; - $row->subpoli = $p->subpoli ?? null; - $target = $p->modaliti2 ?? '1'; - $row->modaliti2 = $target; + + /** + * Ambil komponen terkait (1 query saja) + */ + $komponen = DB::table('db_komponenjawaban') + ->select('accnumber','komponen','isidata') + ->whereIn('accnumber', array_unique($acc)) + ->whereIn('komponen', [ + 'id_bakteri01','id_bakteri02','id_mikroorganisme' + ]) + ->get() + ->groupBy('accnumber'); + + /** + * Ambil poli terkait (1 query) + */ + $poli = DB::table('poli') + ->select('id','subpoli','modaliti2') + ->whereIn('id', array_unique($poli_ids)) + ->get() + ->keyBy('id'); + + /** + * Proses setiap row → tidak ada map() untuk hemat memori + */ + foreach ($hasil as $row) { + + $k = $komponen[$row->nofoto] ?? collect([]); + + $row->id_bakteri01 = optional($k->firstWhere('komponen','id_bakteri01'))->isidata; + $row->id_bakteri02 = optional($k->firstWhere('komponen','id_bakteri02'))->isidata; + $row->bakteri = optional($k->firstWhere('komponen','bakteri'))->isidata; + + $row->filefoto = "nofoto)."'>$row->nofoto"; + + $p = $poli[$row->poli_id] ?? null; + $row->subpoli = $p->subpoli ?? null; + $row->modaliti2 = $p->modaliti2 ?? '1'; + + // Hitung status target if (!empty($row->verifikasi)) { - $selisih_hari = Carbon::parse($row->mulai)->diffInDays(Carbon::parse($row->verifikasi)); - $target = intval($target); - $hari = intval($selisih_hari); - $row->selisih_hari = $selisih_hari; - if ($hari <= $target) { - $row->status_target = "MEMENUHI TARGET"; - } else { - $row->status_target = "TIDAK MEMENUHI TARGET"; - } + $selisih = Carbon::parse($row->mulai)->diffInDays($row->verifikasi); + $row->selisih_hari = $selisih; + $row->status_target = ($selisih <= intval($row->modaliti2)) + ? "MEMENUHI TARGET" + : "TIDAK MEMENUHI TARGET"; } else { - $row->selisih_hari = null; + $row->selisih_hari = null; $row->status_target = "TIDAK ADA HASIL"; } - return $row; - }); - if ($jenisreport == 'rekaptat'){ - $rekap = $hasil->groupBy('kd_spesimen')->map(function($group){ - - return [ - 'jenis_pemeriksaan' => $group->first()->kd_spesimen, - 'memenuhi' => $group->where('status_target', 'MEMENUHI TARGET')->count(), - 'tidak_memenuhi' => $group->where('status_target', 'TIDAK MEMENUHI TARGET')->count(), - 'tidak_ada_hasil' => $group->where('status_target', 'TIDAK ADA HASIL')->count(), - 'total' => $group->count() - ]; - - })->values(); - return response()->json($rekap); - } else { - return response()->json($hasil); } + + /** + * Return untuk dua mode (rekaptat / data penuh) + */ + if ($jenisreport == 'rekaptat') { + $rekap = collect($hasil)->groupBy('kd_spesimen')->map(function($g){ + return [ + 'jenis_pemeriksaan' => $g->first()->kd_spesimen, + 'memenuhi' => $g->where('status_target','MEMENUHI TARGET')->count(), + 'tidak_memenuhi' => $g->where('status_target','TIDAK MEMENUHI TARGET')->count(), + 'tidak_ada_hasil' => $g->where('status_target','TIDAK ADA HASIL')->count(), + 'total' => $g->count(), + ]; + })->values(); + + return response()->json($rekap); + } + + return response()->json($hasil); + } - } public function genRekapAntibiotik(Request $request) { $data = []; diff --git a/htdocs/resources/views/base/partials/header-plain.blade.php b/htdocs/resources/views/base/partials/header-plain.blade.php index acbd4378..c9062fc1 100644 --- a/htdocs/resources/views/base/partials/header-plain.blade.php +++ b/htdocs/resources/views/base/partials/header-plain.blade.php @@ -123,36 +123,20 @@
  • Specimen
  • Patient
  • @@ -180,36 +164,20 @@
  • Specimen
  • Registration
  • @@ -228,36 +196,20 @@
  • Specimen
  • Registration
  • diff --git a/htdocs/resources/views/dokter/ppdsdeveloper.blade.php b/htdocs/resources/views/dokter/ppdsdeveloper.blade.php index b5127860..be3f95c1 100644 --- a/htdocs/resources/views/dokter/ppdsdeveloper.blade.php +++ b/htdocs/resources/views/dokter/ppdsdeveloper.blade.php @@ -1883,7 +1883,7 @@
    - @if(isset($antibiotics) && count($antibiotics) > 0) @foreach($antibiotics as $antibiotic) @@ -1980,7 +1980,7 @@
    - @if(isset($antibiotics) && count($antibiotics) > 0) @foreach($antibiotics as $antibiotic) @@ -2699,7 +2699,7 @@ $('#micvalue_id').val(id); $('#modaleditormic').modal('show'); } - function updateValue(id, value) { + function updateValueManOne(id, value) { $.ajax({ url: '{{ route("getResult") }}', type: 'POST', @@ -2711,6 +2711,24 @@ _token: '{{ csrf_token() }}' }, success: function(res) { + $("#tblkumanmanual1").DataTable().ajax.reload(); + console.log("Value updated", res); + } + }); + } + function updateValueManTwo(id, value) { + $.ajax({ + url: '{{ route("getResult") }}', + type: 'POST', + data: { + nofoto: id, + isi: 'updatevaluemic', + keterangan: 'printunprinttblantibiotik', + komponen: value, + _token: '{{ csrf_token() }}' + }, + success: function(res) { + $("#tblkumanmanual2").DataTable().ajax.reload(); console.log("Value updated", res); } }); @@ -2732,11 +2750,16 @@ }); } function btncreateantibiotikkumanmanual1(jQuery){ - var idne = document.getElementById('periksa_id').value; + var idne = $('#periksa_id').val(); var kuman01 = $('#id_bakteri01').val(); + var antibio1= $('#id_antibiotikmanual1').val(); + if (kuman01 == '' || kuman01 == null) { + return; + } if ( $.fn.DataTable.isDataTable('#tblkumanmanual1') ) { $('#tblkumanmanual1').DataTable().clear().destroy(); } + console.log('Creating DataTable for kuman manual 1 with kuman ID:'+kuman01+antibio1); $('#tblkumanmanual1').DataTable({ ajax: { url: '{{ route("getResult") }}', @@ -2781,7 +2804,7 @@ render: function (data, type, full) { return ``; + onblur="updateValueManOne(${full.id}, this.value)">`; } }, { @@ -2836,11 +2859,17 @@ }); } function btncreateantibiotikkumanmanual2(jQuery){ - var idne = document.getElementById('periksa_id').value; + var idne = $('#periksa_id').val(); var kuman02 = $('#id_bakteri02').val(); + var antibio2= $('#id_antibiotikmanual2').val(); + + if (kuman02 == '' || kuman02 == null) { + return; + } if ( $.fn.DataTable.isDataTable('#tblkumanmanual2') ) { $('#tblkumanmanual2').DataTable().clear().destroy(); } + console.log('Creating DataTable for kuman manual 2 with kuman ID:'+kuman02+antibio2); $('#tblkumanmanual2').DataTable({ ajax: { url: '{{ route("getResult") }}', @@ -2885,7 +2914,7 @@ render: function (data, type, full) { return ``; + onblur="updateValueManTwo(${full.id}, this.value)">`; } }, { @@ -3383,7 +3412,6 @@ $('#id_bakterihitungkol01teks').hide(); $('#id_bakterihitungkol02select').show(); $('#id_bakterihitungkol02teks').hide(); - $('input[type="checkbox"]').prop('disabled', false); if (dlp == 'CCI'){ $('#templatecci').show(); @@ -3464,6 +3492,7 @@ } } else { $("#" + rows.komponen).val(rows.isidata); + console.log(rows.komponen+' | '+rows.isidata); if (rows.komponen === 'id_jenispemeriksaantb') { if (rows.isidata === 'TCM MTB Rif (Xpert)' || rows.isidata === 'TCM MTB Rif (Truenat)' || rows.isidata === 'TCM MTB Rif INH (BDMAX)' || rows.isidata === 'LPA lini 2' || rows.isidata === 'LPA lini 1') { $('#hasilpemeriksaanttcmmtbrifxpert').show(); @@ -3512,9 +3541,6 @@ console.log(traceText); } }); - btncreateantibiotikvitek(); - btncreateantibiotikkumanmanual1(); - btncreateantibiotikkumanmanual2(); } function openedpage( jQuery ){ var jenis = document.getElementById('master_set01').value; @@ -3865,9 +3891,9 @@ altrows : true, selectionmode : 'multiplecellsextended', columns : [ - { text: 'Date', datafield: 'tanggal', width: '25%', cellsalign: 'left', align: 'center' }, - { text: 'Excutor', datafield: 'inputor', width: '40%', cellsalign: 'left', align: 'center' }, - { text: 'Type', datafield: 'keterangan', width: '25%', cellsalign: 'left', align: 'center' }, + { text: 'Date', datafield: 'tanggal', width: '20%', cellsalign: 'left', align: 'center' }, + { text: 'Excutor', datafield: 'inputor', width: '20%', cellsalign: 'left', align: 'center' }, + { text: 'Type', datafield: 'keterangan', width: '50%', cellsalign: 'left', align: 'center' }, { text: 'Report', filterable: false, columntype: 'button', align: 'center', width: '10%', cellsrenderer: function () { return "View"; }, buttonclick: function (row) { @@ -4026,6 +4052,9 @@ }); } else { openlamanekpertise(); + btncreateantibiotikvitek(); + btncreateantibiotikkumanmanual1(); + btncreateantibiotikkumanmanual2(); } } else if (statuse.includes("Dibatalkan")){ swal({ @@ -4040,6 +4069,9 @@ $('#divperiksa').show(); $('#divawal').hide(); openlamanekpertise(); + btncreateantibiotikvitek(); + btncreateantibiotikkumanmanual1(); + btncreateantibiotikkumanmanual2(); } else { swal({ title : 'Ekspertise Final', @@ -4057,6 +4089,9 @@ $('.setelahdipilihtemplate').hide(); } else { openlamanekpertise(); + btncreateantibiotikvitek(); + btncreateantibiotikkumanmanual1(); + btncreateantibiotikkumanmanual2(); } } }