get('userrole'); $networkPath = ""; $db = \Config\Database::connect(); $sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, p.NAME, p.SEX, p.BIRTHDATE, st.SAMPLETYPE, ds.FULLTEXT, st.SAMPLETYPE+right(sr.SP_ACCESSNUMBER,5) as barcode from SP_TUBES st left join SP_REQUESTS sr on st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER left join PATIENTS p on p.PATID=sr.PATID left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE=st.SAMPLETYPE where st.SP_ACCESSNUMBER='$access' AND ds.FULLTEXT = '$sample'"; $query = $db->query($sql); $results = $query->getResultArray(); $item = $results[0]; $uhid = substr($item['UHID'], -10); $bv = $item['BV']; $sex = $item['SEX'] == 1 ? "M" : "F"; $title = $item['SEX'] == 1 ? "Mr" : "Mrs"; $name = $item['NAME']; $sample = $item['FULLTEXT']; $barcode = $item['barcode']; // Ruang Analis Printer POSTEK C168/200s if ($role === 'admin' || $role === 'user') { // Buka Mapping Drive PC Laboratorium exec('net use L: \\\\10.148.5.20\\Labelshare /user:Administrator 2>&1', $output, $return_var); $pathNetworkFolder = 'L:/Sampling_Labels/'; $letterPath = 'L:'; // Printer Posteck $sampleLable ="N OD q400 Q200,10+0 I8,A,001 D10 A4,3,0,2,1,1,N,\"$title.$name\" A4,25,0,2,1,1,N,\"$sex USIA\" A4,55,0,2,1,1,N,\"$sample\" A4,75,0,2,1,1,N,\"Chapter\" B149,35,0,1,3,8,70,N,\"$barcode\" A199,110,0,2,1,1,N,\"LAB $barcode\" A4,140,0,2,1,1,N,\"UH : $uhid\" A4,160,0,2,1,1,N,\"BV : $bv\" A195,156,0,2,1,1,N,\"Tgl Coll\" P1 "; // Ruang Analis Printer Zebra } else if ($role === 'sampling') { // Buka Mapping Drive PC Sampling exec('net use S: \\\\10.148.3.169\\Labelshare /user:Administrator 2>&1', $output, $return_var); $pathNetworkFolder = 'S:/Sampling_Labels/'; $letterPath = 'S:'; // Printer Zebra $sampleLable ="N OD q400 Q185,10+0 I8,A,001 D10 A4,3,0,2,1,1,N,\"$title.$name\" A4,25,0,2,1,1,N,\"$sex USIA\" A4,55,0,2,1,1,N,\"$sample\" A4,75,0,2,1,1,N,\"Chapter\" B149,35,0,1,3,8,70,N,\"$barcode\" A199,110,0,2,1,1,N,\"LAB $barcode\" A4,140,0,2,1,1,N,\"UH : $uhid\" A4,160,0,2,1,1,N,\"BV : $bv\" A195,156,0,2,1,1,N,\"Tgl Coll\" P1 "; } else { // Eksekusi Kode Berikut Apabila Role Bukan Analis atau Sampling return $this->response->setJSON([ 'message' => "Akses Tidak Berwenang", 'error' => "Hak Akses Anda Tidak Dikenali", 'status' => false, ]); } $fullPath = $pathNetworkFolder . $filename; // Tulis file ke folder tujuan if (!file_put_contents($fullPath, $sampleLable)) { exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var); // Eksekusi Kode Berikut Apabila Ada Error return $this->response->setJSON([ 'error' => $output, 'message' => "Gagal Melakukan Print, Mohon Ulangi Atau Cek Koneksi Printer Anda", 'status' => false, ]); } else { // Hapus Koneksi exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var); return $this->response->setJSON( [ 'message' => "Print Berhasil", 'status' => true, ] ); } } public function printAllSampleBarcode($access) { $role = session()->get('userrole'); $networkPath = ""; $db = \Config\Database::connect(); $sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, p.NAME, p.SEX, p.BIRTHDATE, st.SAMPLETYPE, ds.FULLTEXT, st.SAMPLETYPE+right(sr.SP_ACCESSNUMBER,5) as barcode from SP_TUBES st left join SP_REQUESTS sr on st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER left join PATIENTS p on p.PATID=sr.PATID left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE=st.SAMPLETYPE where st.SP_ACCESSNUMBER='$access'"; $query = $db->query($sql); $results = $query->getResultArray(); // Ruang Analis Printer POSTEK if ($role === 'admin' || $role === 'user') { // Buka Mapping Drive PC Laboratorium exec('net use L: \\\\10.148.5.20\\Labelshare /user:Administrator 2>&1', $output, $return_var); $pathNetworkFolder = 'L:/Sampling_Labels/'; $letterPath = 'L:'; // for ($i=0; $i<$data; $i++) { foreach($results as $item) { $time = microtime(true); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); $filename = "sample_".$logTime; $uhid = substr($item['UHID'], -10); $bv = $item['BV']; $sex = $item['SEX'] == 1 ? "M" : "F"; $title = $item['SEX'] == 1 ? "Mr" : "Mrs"; $name = $item['NAME']; $sample = $item['FULLTEXT']; $barcode = $item['barcode']; // Printer Posteck $sampleLable ="N OD q400 Q200,10+0 I8,A,001 D10 A4,3,0,2,1,1,N,\"$title.$name\" A4,25,0,2,1,1,N,\"$sex USIA\" A4,55,0,2,1,1,N,\"$sample\" A4,75,0,2,1,1,N,\"Chapter\" B149,35,0,1,3,8,70,N,\"$barcode\" A199,110,0,2,1,1,N,\"LAB $barcode\" A4,140,0,2,1,1,N,\"UH : $uhid\" A4,160,0,2,1,1,N,\"BV : $bv\" A195,156,0,2,1,1,N,\"Tgl Coll\" P1 "; $fullPath = $pathNetworkFolder . $filename; // Tulis file ke folder tujuan if (!file_put_contents($fullPath, $sampleLable)) { exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var); // Eksekusi Kode Berikut Apabila Ada Error return $this->response->setJSON([ 'error' => $output, 'message' => "Gagal Melakukan Print, Mohon Ulangi Atau Cek Koneksi Printer Anda", 'status' => false, ]); } } // Ruang Analis Printer Zebra } else if ($role === 'sampling') { // Buka Mapping Drive PC Sampling exec('net use S: \\\\10.148.3.169\\Labelshare /user:Administrator 2>&1', $output, $return_var); $pathNetworkFolder = 'S:/Sampling_Labels/'; $letterPath = 'S:'; foreach($results as $item) { $time = microtime(true); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); $filename = "sample_".$logTime; $uhid = substr($item['UHID'], -10); $bv = $item['BV']; $sex = $item['SEX'] == 1 ? "M" : "F"; $title = $item['SEX'] == 1 ? "Mr" : "Mrs"; $name = $item['NAME']; $sample = $item['FULLTEXT']; $barcode = $item['barcode']; // Printer Zebra $sampleLable ="N OD q400 Q185,10+0 I8,A,001 D10 A4,3,0,2,1,1,N,\"$title.$name\" A4,25,0,2,1,1,N,\"$sex USIA\" A4,55,0,2,1,1,N,\"$sample\" A4,75,0,2,1,1,N,\"Chapter\" B149,35,0,1,3,8,70,N,\"$barcode\" A199,110,0,2,1,1,N,\"LAB $barcode\" A4,140,0,2,1,1,N,\"UH : $uhid\" A4,160,0,2,1,1,N,\"BV : $bv\" A195,156,0,2,1,1,N,\"Tgl Coll\" P1 "; $fullPath = $pathNetworkFolder . $filename; // Tulis file ke folder tujuan if (!file_put_contents($fullPath, $sampleLable)) { exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var); // Eksekusi Kode Berikut Apabila Ada Error return $this->response->setJSON([ 'error' => $output, 'message' => "Gagal Melakukan Print, Mohon Ulangi Atau Cek Koneksi Printer Anda", 'status' => false, ]); } } } else { // Eksekusi Kode Berikut Apabila Role Bukan Analis atau Sampling return $this->response->setJSON([ 'message' => "Akses Tidak Berwenang", 'error' => "Hak Akses Anda Tidak Dikenali", 'status' => false, ]); } // Hapus Koneksi exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var); return $this->response->setJSON( [ 'message' => "Print Berhasil", 'status' => true, ] ); } public function otherTests($access){ $fullPage=""; $headPage = "
CLINICAL LABORATORY
UHID : 1BCJJAJSDK Sample ID : LAB2420076951
Name : Ni Luh Putu Eka Putri Saraswati Specimen : Serum
Age/Gender : 22 year(s) / Male Collection Date/Time : 26-10-2024 / 11:55:04
Speciality : Result Date/Time : 26-10-2024 / 11:52:04

"; $resultTest =""; $item = end($access); $resultNoteandSpecimen = "
Parameter Result Unit Normal Range Notes
Notes
".$item['RESVALUE']."

Collection datetime : - 
Reception datetime  : - 
"; $footerPage = " "; $lastDiv="
"; $tempChapEng = ""; $tempChapInd = ""; array_pop($access); $i=0; foreach ($access as $item) { if ($tempChapEng != $item['chap_eng']) { $tempChapEng = $item['chap_eng']; $tempChapInd = $item['chap_ind']; $i++; // Untuk Chapter $resultTest .= "
".$tempChapEng."
 ".$tempChapInd."
"; } // Melebihi batas Kertas if($i % 24 == 0) { $resultTest .= "
"; $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; $i=0; $resultTest = ""; } $i++; if ($item['RESTYPE'] == "CE"){ $resvalue = $item['RESULT']; } else { $resvalue = $item['RESVALUE']; } $resultTest .= "
 ".$item["test_eng"]."
  ".$item["test_ind"]."
" . $resvalue . " " . $item["UNIT"] . " " . $item["REFRANGE"] . " " . " " . " "; // Melebihi batas Kertas if($i % 24 == 0) { $resultTest .= ""; $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; $i=0; $resultTest = ""; } } $resultTest .= " ".$resultNoteandSpecimen." "; $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; return $fullPage; } public function printResultTest($access) { $db = \Config\Database::connect(); $sql = " select dc.CHAPID, dc.FULLTEXT as chap_eng,dc.FULLTEXT as chap_ind, RESULT=case when cr.RESTYPE in('NM','TX') then cr.RESVALUE when cr.RESTYPE='CE' then tx.FULLTEXT end, cr.*, cdt.TEXT1 as test_eng, cdt.TEXT2 as test_ind from cmod.dbo.CM_RESULTS cr left join REQUESTS r on r.ACCESSNUMBER=cr.ACCESSNUMBER left join cmod.dbo.CM_DICT_TESTS cdt on cr.TESTCODE=cdt.TESTCODE left join DICT_TESTS dt on dt.TESTCODE=cr.TESTCODE and dt.ENDVALIDDATE is null left join TESTS t on t.REQUESTID = r.REQUESTID and t.TESTID=dt.TESTID left join DICT_TEXTS tx on tx.TEXTID=t.CODEDRESULTID left join DICT_CHAPTERS dc on dc.CHAPID=dt.CHAPID and dc.ENDVALIDDATE is null left join cmod.dbo.CM_DICT_CHAPTERS cdc on cdc.CHAPCODE=dc.CHAPCODE where cr.ACCESSNUMBER='$access' ORDER BY CASE WHEN cr.TESTCODE = 'NOTE' THEN 1 ELSE 0 END, t.TESTORDER; "; $query = $db->query($sql); $results = $query->getResultArray(); $data_urine = array_filter($results, function($item) { $chapterid = $item["CHAPID"]; // Memfilter data dengan CHAPID 3, 61, atau 62 return $chapterid == 3 || $chapterid == 61 || $chapterid == 62; }); // Seleksi data yang mengandung "FESES" $data_feces = array_filter($results, function($item) { $chapterid = $item["CHAPID"]; // Memfilter data yang 4 return $chapterid == 4; }); // Seleksi data yang tidak mengandung "urine" dan "feces" $data_others = array_filter($results, function($item) { $chapterid = $item["CHAPID"]; // Memfilter data yang bukan 61 atau 3 return $chapterid !== 3 && $chapterid !== 4 && $chapterid !== 61 && $chapterid !== 62; }); $fullPage = ""; if ($data_urine != null) { $fullPage .= $this->otherTests($data_urine); } if ($data_feces != null) { $fullPage .= $this->otherTests($data_feces); } if ($data_others != null) { $fullPage .= $this->otherTests($data_others); } return view('result_report', ['data' => $fullPage]); } }