middleware('auth:api'); if(null == $request->header('x-token')) { return response()->json(['error' => 'Unauthorized'], 401); } $user = DB::table('webservice')->where('token',$request->header('x-token'))->first(); if(!$user || empty($user)){ return response()->json(['error' => 'Unauthorized'], 401); } } public function pasienFilter($nomr,Request $request) { $token = $request->header('x-token'); $user = DB::table('webservice')->where('token',$token)->first(); if(!$user || empty($user)){ return response()->json(['error' => 'Unauthorized'], 401); } if(null == $nomr) { return response()->json(['error' => 'Invalid Parameter!'],400); } elseif(strlen($nomr) < 8) { return response()->json(['error' => 'Parameter less than 8 digit!'],400); } elseif(strlen($nomr) > 8) { return response()->json(['error' => 'Parameter more than 8 digit!'],400); } $result = DB::table('m_pasien') ->leftJoin('m_agama_pasien','m_agama_pasien.id_agama','=','m_pasien.agama') ->leftJoin('m_status_pasien','m_status_pasien.id_status','=','m_pasien.status') ->leftJoin('m_pendidikan_pasien','m_pendidikan_pasien.id_pendidikan','=','m_pasien.pendidikan') ->select('nomr','nama','tgllahir','alamat','noktp','jeniskelamin','notelp','tgldaftar','no_kartu','txt_kelurahan','txt_kecamatan','txt_kota','txt_provinsi',DB::raw('case when m_status_pasien.nama_status is null then txt_status else m_status_pasien.nama_status end as txt_status,case when m_agama_pasien.nama_agama is null then txt_agama else m_agama_pasien.nama_agama end as txt_agama,case when m_pendidikan_pasien.nama_pendidikan is null then txt_pendidikan else m_pendidikan_pasien.nama_pendidikan end as txt_pendidikan')) ->where('nomr',$nomr) ->get(); // return $result; $arr_result = []; $i = 0; foreach($result->all() as $key => $detil) { // $row_detil = DB::table('t_icd') // ->join('icd','t_icd.icd','=','icd.icd_code') // ->join('m_dokter','m_dokter.kddokter','=','t_icd.kddokter') // ->join('t_pendaftaran','t_icd.idxdaftar','=','t_pendaftaran.idxdaftar') // ->join('m_ruang','m_ruang.no','=','t_pendaftaran.kdpoly') // ->join('m_pasien','m_pasien.nomr','=','t_pendaftaran.nomr') // ->leftJoin('m_statuskeluar','t_pendaftaran.status','=','m_statuskeluar.status') // ->select(DB::raw('m_pasien.jeniskelamin,age(m_pasien.tgllahir) as usia,m_statuskeluar.keterangan as status_keluar')) // ->where([ // ['status_rajal','=',1], // ['m_ruang.nama','=',$detil->namaruang], // ['icd.icd_code','=',$detil->icd_code], // ['m_dokter.namadokter','=',$detil->namadokter], // ['t_icd.tanggal','=',$detil->tanggal], // ]) // ->whereNotIn('t_pendaftaran.kdpoly',$arr_incovit) // ->get(); $set_result = collect($result[$key]); // $set_result->pull('jml'); // $set_result['pasien'] = $row_detil->all(); $arr_result[] = $set_result->all(); $result->forget($key); $i++; } return response()->json($arr_result); } public function labsentralFilter($nomr,Request $request) { $token = $request->header('x-token'); $user = DB::table('webservice')->where('token',$token)->first(); if(!$user || empty($user)){ return response()->json(['error' => 'Unauthorized'], 401); } if(null == $nomr) { return response()->json(['error' => 'Invalid Parameter!'],400); } elseif(strlen($nomr) < 8) { return response()->json(['error' => 'Parameter less than 8 digit!'],400); } elseif(strlen($nomr) > 8) { return response()->json(['error' => 'Parameter more than 8 digit!'],400); } $response = Http::get('http://192.168.2.9/viewer/api.php?get=1&nomr='.$nomr); $jsonData = $response->json(); return $jsonData; } public function labmikroFilter($nomr,Request $request) { $token = $request->header('x-token'); $user = DB::table('webservice')->where('token',$token)->first(); if(!$user || empty($user)){ return response()->json(['error' => 'Unauthorized'], 401); } if(null == $nomr) { return response()->json(['error' => 'Invalid Parameter!'],400); } elseif(strlen($nomr) < 8) { return response()->json(['error' => 'Parameter less than 8 digit!'],400); } elseif(strlen($nomr) > 8) { return response()->json(['error' => 'Parameter more than 8 digit!'],400); } $result = DB::table('t_orderlabmikro_main') ->join('t_orderlabmikro','t_orderlabmikro.nolab','=','t_orderlabmikro_main.nolab') ->select('no_lokal','tgl_hasil','jenis_hasil','idxordermikro') ->where('t_orderlabmikro_main.nomr',$nomr) ->where('t_orderlabmikro.status_final',1) ->get(); $arr_result = []; $i = 0; foreach($result->all() as $key => $detil) { $set_result = collect($result[$key]); $set_result['nama'] = $detil->jenis_hasil.' - '.$detil->tgl_hasil.' - '.$detil->no_lokal; $set_result['url'] = env('SIMRS_APP_URL').'lab/detil_hasil_labmikro.php?preview=1&no='.$detil->idxordermikro; $set_result->pull('idxordermikro'); $set_result->pull('jenis_hasil'); $set_result->pull('tgl_hasil'); $set_result->pull('no_lokal'); $arr_result[] = $set_result->all(); $result->forget($key); $i++; } $message = ($i > 0) ? 'Ditemukan beberapa hasil lab mikrobiologi.' : 'Tidak ditemukan hasil lab mikrobiologi.'; return response()->json(['message'=>$message,'data'=>$arr_result]); } public function labpatologiFilter($nomr,Request $request) { $token = $request->header('x-token'); $user = DB::table('webservice')->where('token',$token)->first(); if(!$user || empty($user)){ return response()->json(['error' => 'Unauthorized'], 401); } if(null == $nomr) { return response()->json(['error' => 'Invalid Parameter!'],400); } elseif(strlen($nomr) < 8) { return response()->json(['error' => 'Parameter less than 8 digit!'],400); } elseif(strlen($nomr) > 8) { return response()->json(['error' => 'Parameter more than 8 digit!'],400); } $result = DB::table('t_orderlabpa_main') ->select('no_reg_pa','tgljawab_lab as tgl_hasil','lokalisasi','noreglab','idxdaftar') ->where('nomr',$nomr) ->whereNotNull('tgljawab_lab') ->get(); $arr_result = []; $i = 0; foreach($result->all() as $key => $detil) { $set_result = collect($result[$key]); $set_result['nama'] = $detil->lokalisasi.' - '.$detil->tgl_hasil.' - '.$detil->no_reg_pa; $set_result['url'] = env('SIMRS_APP_URL').'lab/detil_hasil_labpa.php?preview=1&idx='.$detil->idxdaftar.'&nomr='.$nomr.'&nolab='.$detil->noreglab; $set_result->pull('no_reg_pa'); $set_result->pull('tgl_hasil'); $set_result->pull('lokalisasi'); $set_result->pull('noreglab'); $set_result->pull('idxdaftar'); $arr_result[] = $set_result->all(); $result->forget($key); $i++; } $message = ($i > 0) ? 'Ditemukan beberapa hasil lab patologi anatomi.' : 'Tidak ditemukan hasil lab patologi anatomi.'; return response()->json(['message'=>$message,'data'=>$arr_result]); } public function resumeFilter($nomr,Request $request) { $token = $request->header('x-token'); $user = DB::table('webservice')->where('token',$token)->first(); if(!$user || empty($user)){ return response()->json(['error' => 'Unauthorized'], 401); } if(null == $nomr) { return response()->json(['error' => 'Invalid Parameter!'],400); } elseif(strlen($nomr) < 8) { return response()->json(['error' => 'Parameter less than 8 digit!'],400); } elseif(strlen($nomr) > 8) { return response()->json(['error' => 'Parameter more than 8 digit!'],400); } // SELECT * from t_resumemedis a join m_dokter d on a.dpjp = d.kddokter // get resume $resume = DB::table('t_resumemedis') ->join('m_dokter','t_resumemedis.dpjp','=','m_dokter.kddokter') ->where([ ['nomr','=',$nomr] ]) ->orderBy('idx','desc') ->get(); $arr_result['resume'] = []; $i = 0; foreach($resume->all() as $key => $detil_resume) { $idx = ($detil_resume->idxrajal != 0) ? $detil_resume->idxrajal : $detil_resume->idxranap; $status_rajal = ($detil_resume->idxrajal != 0) ? 1 : 0; $arr_result['resume'][$idx] = [ 'tanggal_mrs' => $detil_resume->tanggalmasuk, 'diagnosa_utama' => $detil_resume->diagnosa_utama, 'diagnosa_klinis' => $detil_resume->keluhan_utama, 'icd_diagnosa' => [], 'icd_tindakan' => [], 'nama_ruang' => '', 'url_resume' => env('SIMRS_APP_URL').'include/master.php?load_resume_pdf=1&idx='.$idx.'&rajal_status='.$status_rajal.'&jenis_resume=dpjp&attach=1' ]; if($status_rajal == 1) { $icd_diagnosa_rajal = DB::table('t_icd') ->join('icd','t_icd.icd','=','icd.icd_code') ->join('t_pendaftaran','t_icd.idxdaftar','=','t_pendaftaran.idxdaftar') ->join('m_ruang','m_ruang.no','=','t_pendaftaran.kdpoly') ->select('m_ruang.nama as namaruang','icd.icd_code as icd', 'icd.jenis_penyakit as keterangan') ->where([ ['t_icd.idxdaftar','=',$idx], ['t_icd.status_rajal','=',1] ]) ->whereNull('t_icd.icd_verified') ->get(); foreach($icd_diagnosa_rajal->all() as $key => $detil) { $set_result = collect($icd_diagnosa_rajal[$key]); if(array_key_exists($idx,$arr_result['resume'])){ $arr_result['resume'][$idx]['icd_diagnosa'][] = $set_result->all(); } $icd_diagnosa_rajal->forget($key); } $icd_tindakan_rajal = DB::table('t_icd_cm') ->join('icd_cm','t_icd_cm.icd','=','icd_cm.kode') ->join('m_dokter','m_dokter.kddokter','=','t_icd_cm.kddokter') ->join('t_pendaftaran','t_icd_cm.idxdaftar','=','t_pendaftaran.idxdaftar') ->join('m_ruang','m_ruang.no','=','t_pendaftaran.kdpoly') ->select('m_ruang.nama as namaruang','icd_cm.kode as icd', 'icd_cm.keterangan') ->where([ ['t_icd_cm.idxdaftar','=',$idx], ['t_icd_cm.status_rajal','=',1] ]) ->whereNull('t_icd_cm.icd_verified') ->get(); foreach($icd_tindakan_rajal->all() as $key => $detil) { $set_result = collect($icd_tindakan_rajal[$key]); if(array_key_exists($idx,$arr_result['resume'])){ $arr_result['resume'][$idx]['icd_tindakan'][] = $set_result->all(); } $icd_tindakan_rajal->forget($key); } } else { $icd_diagnosa_ranap = DB::table('t_icd') ->join('icd','t_icd.icd','=','icd.icd_code') ->join('t_admission','t_icd.idxdaftar','=','t_admission.id_admission') ->join('m_ruang','m_ruang.no','=','t_admission.noruang') ->select('m_ruang.nama as namaruang','icd.icd_code as icd', 'icd.jenis_penyakit as keterangan') ->where([ ['t_icd.idxdaftar','=',$idx], ['t_icd.status_rajal','=',0] ]) ->whereNull('t_icd.icd_verified') ->get(); foreach($icd_diagnosa_ranap->all() as $key => $detil) { $set_result = collect($icd_diagnosa_ranap[$key]); if(array_key_exists($idx,$arr_result['resume'])){ $arr_result['resume'][$idx]['icd_diagnosa'][] = $set_result->all(); } $icd_diagnosa_ranap->forget($key); } $icd_tindakan_ranap = DB::table('t_icd_cm') ->join('icd_cm','t_icd_cm.icd','=','icd_cm.kode') ->join('m_dokter','m_dokter.kddokter','=','t_icd_cm.kddokter') ->join('t_admission','t_icd_cm.idxdaftar','=','t_admission.id_admission') ->join('m_ruang','m_ruang.no','=','t_admission.noruang') ->select('m_ruang.nama as namaruang','icd_cm.kode as icd', 'icd_cm.keterangan') ->where([ ['t_icd_cm.idxdaftar','=',$idx], ['t_icd_cm.status_rajal','=',0] ]) ->whereNull('t_icd_cm.icd_verified') ->get(); $arr_result['icd_tindakan'] = []; foreach($icd_tindakan_ranap->all() as $key => $detil) { $set_result = collect($icd_tindakan_ranap[$key]); if(array_key_exists($idx,$arr_result['resume'])){ $arr_result['resume'][$idx]['icd_tindakan'][] = $set_result->all(); } $icd_tindakan_ranap->forget($key); } } $i++; } $message = ($i > 0) ? 'Ditemukan beberapa hasil resume.' : 'Tidak ditemukan hasil resume.'; return response()->json(['message'=>$message,'data'=>$arr_result]); } }