first refactor printLabel printResult

This commit is contained in:
mahdahar 2024-12-09 13:10:16 +07:00
parent c12efe19d2
commit 924ed2354a
12 changed files with 435 additions and 562 deletions

View File

@ -92,6 +92,6 @@ $routes->group('fo', ['filter' => 'role:fo'], static function ($routes) {
});
// Printers
$routes->get('prints/single_sample/(:any)/(:any)', 'PrinterController::printSingleSampleBarcode/$1/$2');
$routes->get('prints/all_sample/(:any)', 'PrinterController::printAllSampleBarcode/$1');
$routes->get('prints/result_test/(:any)', 'PrinterController::printResultTest/$1');
$routes->get('printLabel/single/(:any)/(:any)', 'PrintLabel::printSingle/$1/$2');
$routes->get('printLabel/all/(:any)', 'PrintLabel::printAll/$1');
$routes->get('printResult/(:any)', 'PrintResult::printResultTest/$1');

View File

@ -0,0 +1,150 @@
<?php
namespace App\Controllers;
class PrintLabel extends BaseController {
public function labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv ) {
// Printer Posteck
$sampleLabel ="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 {$age}Y\"
A4,55,0,2,1,1,N,\"$sample\"
A4,75,0,2,1,1,N,\"\"
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
";
return $sampleLabel;
}
public function labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv ) {
$sampleLabel ="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 {$age}Y\"
A4,55,0,2,1,1,N,\"$sample\"
A4,75,0,2,1,1,N,\"\"
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
";
}
public function printerLab() {
exec('net use L: \\\\10.148.5.20\\Labelshare /user:Administrator 2>&1', $output, $return_var);
$pathNetworkFolder = 'L:/Sampling_Labels/';
$letterPath = 'L:';
return array($pathNetworkFolder, $letterPath);
}
public function printerSampling() {
exec('net use S: \\\\10.148.3.169\\Labelshare /user:Administrator 2>&1', $output, $return_var);
$pathNetworkFolder = 'S:/Sampling_Labels/';
$letterPath = 'S:';
return array($pathNetworkFolder, $letterPath);
}
public function printSingle($access, $sampletype) {
$time = microtime(true);
$logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000);
$filename = "sample_".$logTime;
$role = session()->get('userrole');
$networkPath = "";
$db = \Config\Database::connect();
$sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, p.NAME, p.SEX,
DATEDIFF(YEAR, BirthDate, GETDATE()) -
CASE WHEN MONTH(BirthDate) > MONTH(GETDATE()) OR (MONTH(BirthDate) = MONTH(GETDATE()) AND DAY(BirthDate) > DAY(GETDATE())) THEN 1
ELSE 0 END AS AGE,
ds.FULLTEXT, st.SAMPLETYPE+right(sr.SP_ACCESSNUMBER,5) as BARCODE, getdate() as COLLDATE
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.SAMPCODE = '$sampletype'";
$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'];
$age = $item['AGE'];
$colldate = $item['COLLDATE'];
// Ruang Analis Printer POSTEK C168/200s
if ($role === 'admin' || $role === 'user') {
//$printer = $this->printerLab();
$label = $this->labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv );
} else if ($role === 'sampling') {
//$printer = $this->printerSampling();
$label = $this->labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv );
} 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,
]);
}
$folder = "C:/data/";
$fullPath = $folder . $filename;
// Tulis file ke folder tujuan
if (!file_put_contents($fullPath, $label)) {
//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 printAll($access) {
$db = \Config\Database::connect();
$sql = "select SAMPLETYPE from SP_TUBES where SP_ACCESSNUMBER='$access'";
$query = $db->query($sql);
$results = $query->getResultArray();
foreach($results as $data) {
$sample = $data['SAMPLETYPE'];
$this->printSingle($access, $sample);
}
}
}

View File

@ -0,0 +1,265 @@
<?php
namespace App\Controllers;
class PrintResult extends BaseController {
public function otherTests($access){
$fullPage="";
$headPage = "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>
<img src='".base_url()."assets/img/padma-header.png' class='img' />
<div id='dinfo'>
<table class='information t_center'>
<tr>
<th class='padmaColor' colspan='6' align='center'>CLINICAL LABORATORY</th>
</tr>
<tr>
<th style='width:12%' align='left'>UHID</th>
<td style='width:2%'>:</td>
<td style='width:44%'>1BCJJAJSDK</td>
<th style='width:20%' align='left'>Sample ID</th>
<td style='width:2%'>:</td>
<td style='width:20%'>LAB2420076951</td>
</tr>
<tr>
<th align='left'>Name</th>
<td>:</td>
<td>Ni Luh Putu Eka Putri Saraswati </td>
<th align='left'>Specimen</th>
<td>:</td>
<td>Serum</td>
</tr>
<tr>
<th align='left'>Age/Gender</th>
<td>:</td>
<td>22 year(s) / Male</td>
<th align='left'>Collection Date/Time</th>
<td>:</td>
<td>26-10-2024 / 11:55:04</td>
</tr>
<tr>
<th align='left'>Speciality</th>
<td>:</td>
<td></td>
<th align='left'>Result Date/Time</th>
<td>:</td>
<td>26-10-2024 / 11:52:04</td>
</tr>
</table>
</div>
<div id='dresult'>
<br>
<table class='result t_center'>
<tr align='left'>
<th class='padmaColor' style='width:35%'>Parameter</th>
<th class='padmaColor' style='width:14%'>Result</th>
<th class='padmaColor' style='width:14%'>Unit</th>
<th class='padmaColor' style='width:17%'>Normal Range</th>
<th class='padmaColor' style='width:20%'>Notes</th>
</tr>
";
$resultTest ="";
$item = end($access);
$resultNoteandSpecimen = "
<br>
<table class='result t_center'>
<tr>
<th align='left' class='padmaColor'>Notes</th>
</tr>
<tr>
<td>
".$item['RESVALUE']."
</td>
</tr>
</table>
<br>
<table class='t_center table_collection' >
<tr>
<td><pre>Collection datetime : - </pre></td>
</tr>
<tr>
<td><pre>Reception datetime : - </pre></td>
</tr>
</table>
";
$footerPage = "
<div id='footer'>
<table class='table_footer t_center'>
<tr>
<td></td>
<td align='right'><img src='http://cmod.id/assets/img/ttd.png' alt=''></td>
</tr>
<tr>
<td><u>Entered By</u></td>
<td align='right'><u>Verified By</u></td>
</tr>
<tr>
<td>Lab Technician</td>
<td align='right'>dr. I Komang Parwata Sp.PK</td>
</tr>
<tr>
<td>Mrs. Gst Ayu Riska Mastari</td>
<td align='right'>Reg. No: 570/SIPDS/0001/I/DPMPTSP/2023</td>
</tr>
</table>
</div>
";
$lastDiv="</div>";
$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 .= "
<tr align='left' class='chapter'>
<td colspan='5'>
<pre><b>".$tempChapEng."</b></pre>
<pre> <small><b>".$tempChapInd."</b></small></pre>
</td>
</tr>
";
}
// Melebihi batas Kertas
if($i % 24 == 0) {
$resultTest .= "</table></div>";
$fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
$i=0;
$resultTest = "";
}
$i++;
if ($item['RESTYPE'] == "CE"){
$resvalue = $item['RESULT'];
} else {
$resvalue = $item['RESVALUE'];
}
$resultTest .= "
<tr>
<td colspan='1' class=''>
<pre> ".$item["test_eng"]."</pre>
<pre> <small>".$item["test_ind"]."</small></pre>
</td>
<td class=''>" . $resvalue . "</td>
<td class=''>" . $item["UNIT"] . "</td>
<td class=''>" . $item["REFRANGE"] . "</td>
<td class=''>" . " " . "</td>
</tr>
";
// Melebihi batas Kertas
if($i % 24 == 0) {
$resultTest .= "</table></div>";
$fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
$i=0;
$resultTest = "";
}
}
$resultTest .= "
</table>
".$resultNoteandSpecimen."
</div>";
$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"];
$tesscode = $item['TESTCODE'];
// Memfilter data dengan CHAPID 3, 61, atau 62
return $chapterid == 3 || $chapterid == 61 || $chapterid == 62 || $tesscode == 'NOTE';
});
// Seleksi data yang mengandung "FESES"
$data_feces = array_filter($results, function($item) {
$chapterid = $item["CHAPID"];
$tesscode = $item['TESTCODE'];
// Memfilter data yang 4
return $chapterid == 4 || $tesscode == 'NOTE';
});
// Seleksi data yang tidak mengandung "urine" dan "feces"
$data_others = array_filter($results, function($item) {
$chapterid = $item["CHAPID"];
$tesscode = $item['TESTCODE'];
// Memfilter data yang bukan 61 atau 3
return $chapterid !== 3 && $chapterid !== 4 && $chapterid !== 61 && $chapterid !== 62 || $tesscode == 'NOTE';
});
$fullPage = "";
if ($data_urine != null && count($data_urine) > 1) {
$fullPage .= $this->otherTests($data_urine);
}
if ($data_feces != null && count($data_feces) > 1) {
$fullPage .= $this->otherTests($data_feces);
}
if ($data_others != null && count($data_others) > 1) {
$fullPage .= $this->otherTests($data_others);
}
return view('result_report', ['data' => $fullPage]);
}
}

View File

@ -1,548 +0,0 @@
<?php
namespace App\Controllers;
class PrinterController extends BaseController {
// Data ZPL untuk mencetak label
// $startSection = "^XA\n^PW400\n^LL224\n";
// $nameSection = "^FO10,2\n^A0N,23,23\n^FD MRS. I PUTU AYU PUTRI PERTIWI ^FS\n";
// $yearSection = "^FO12,25\n^A0N,22,22\n^FD F 24Y ^FS\n";
// $labelBarcodeSection = "^FO85,50\n^BY2,2.0,45\n^BCN,100,N,N,N\n^FD25082257^FS\n";
// $numberCodeSection = "^FO374,43\n^A0B,25,25\n^FD 25082257 ^FS\n";
// $sampleSection = "^FO19,45\n^A0B,27,27\n^FD $sample ^FS\n";
// $parameterSection = "^FO10,165\n^A0N,23,23\n^FD PSA, HDL, LDL, BUN, SGOT ^FS\n";
// $lisNumSection = "^FO10,195\n^A0N,17,20\n^FD LIS 4112082257 ^FS\n";
// $hisNumSection = "^FO10,210\n^A0N,20,20\n^FD HIS 01241101855 ^FS\n";
// $numSampleSection = "^FO240,200\n^A0N,27,27\n^FD $access 115 ^FS\n";
// $endSection = "^XZ";
public function printSingleSampleBarcode($access, $sample) {
$time = microtime(true);
$logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000);
$filename = "sample_".$logTime;
$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' 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 = "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>
<img src='".base_url()."assets/img/padma-header.png' class='img' />
<div id='dinfo'>
<table class='information t_center'>
<tr>
<th class='padmaColor' colspan='6' align='center'>CLINICAL LABORATORY</th>
</tr>
<tr>
<th style='width:12%' align='left'>UHID</th>
<td style='width:2%'>:</td>
<td style='width:44%'>1BCJJAJSDK</td>
<th style='width:20%' align='left'>Sample ID</th>
<td style='width:2%'>:</td>
<td style='width:20%'>LAB2420076951</td>
</tr>
<tr>
<th align='left'>Name</th>
<td>:</td>
<td>Ni Luh Putu Eka Putri Saraswati </td>
<th align='left'>Specimen</th>
<td>:</td>
<td>Serum</td>
</tr>
<tr>
<th align='left'>Age/Gender</th>
<td>:</td>
<td>22 year(s) / Male</td>
<th align='left'>Collection Date/Time</th>
<td>:</td>
<td>26-10-2024 / 11:55:04</td>
</tr>
<tr>
<th align='left'>Speciality</th>
<td>:</td>
<td></td>
<th align='left'>Result Date/Time</th>
<td>:</td>
<td>26-10-2024 / 11:52:04</td>
</tr>
</table>
</div>
<div id='dresult'>
<br>
<table class='result t_center'>
<tr align='left'>
<th class='padmaColor' style='width:35%'>Parameter</th>
<th class='padmaColor' style='width:14%'>Result</th>
<th class='padmaColor' style='width:14%'>Unit</th>
<th class='padmaColor' style='width:17%'>Normal Range</th>
<th class='padmaColor' style='width:20%'>Notes</th>
</tr>
";
$resultTest ="";
$item = end($access);
$resultNoteandSpecimen = "
<br>
<table class='result t_center'>
<tr>
<th align='left' class='padmaColor'>Notes</th>
</tr>
<tr>
<td>
".$item['RESVALUE']."
</td>
</tr>
</table>
<br>
<table class='t_center table_collection' >
<tr>
<td><pre>Collection datetime : - </pre></td>
</tr>
<tr>
<td><pre>Reception datetime : - </pre></td>
</tr>
</table>
";
$footerPage = "
<div id='footer'>
<table class='table_footer t_center'>
<tr>
<td></td>
<td align='right'><img src='http://cmod.id/assets/img/ttd.png' alt=''></td>
</tr>
<tr>
<td><u>Entered By</u></td>
<td align='right'><u>Verified By</u></td>
</tr>
<tr>
<td>Lab Technician</td>
<td align='right'>dr. I Komang Parwata Sp.PK</td>
</tr>
<tr>
<td>Mrs. Gst Ayu Riska Mastari</td>
<td align='right'>Reg. No: 570/SIPDS/0001/I/DPMPTSP/2023</td>
</tr>
</table>
</div>
";
$lastDiv="</div>";
$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 .= "
<tr align='left' class='chapter'>
<td colspan='5'>
<pre><b>".$tempChapEng."</b></pre>
<pre> <small><b>".$tempChapInd."</b></small></pre>
</td>
</tr>
";
}
// Melebihi batas Kertas
if($i % 24 == 0) {
$resultTest .= "</table></div>";
$fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
$i=0;
$resultTest = "";
}
$i++;
if ($item['RESTYPE'] == "CE"){
$resvalue = $item['RESULT'];
} else {
$resvalue = $item['RESVALUE'];
}
$resultTest .= "
<tr>
<td colspan='1' class=''>
<pre> ".$item["test_eng"]."</pre>
<pre> <small>".$item["test_ind"]."</small></pre>
</td>
<td class=''>" . $resvalue . "</td>
<td class=''>" . $item["UNIT"] . "</td>
<td class=''>" . $item["REFRANGE"] . "</td>
<td class=''>" . " " . "</td>
</tr>
";
// Melebihi batas Kertas
if($i % 24 == 0) {
$resultTest .= "</table></div>";
$fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
$i=0;
$resultTest = "";
}
}
$resultTest .= "
</table>
".$resultNoteandSpecimen."
</div>";
$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"];
$tesscode = $item['TESTCODE'];
// Memfilter data dengan CHAPID 3, 61, atau 62
return $chapterid == 3 || $chapterid == 61 || $chapterid == 62 || $tesscode == 'NOTE';
});
// Seleksi data yang mengandung "FESES"
$data_feces = array_filter($results, function($item) {
$chapterid = $item["CHAPID"];
$tesscode = $item['TESTCODE'];
// Memfilter data yang 4
return $chapterid == 4 || $tesscode == 'NOTE';
});
// Seleksi data yang tidak mengandung "urine" dan "feces"
$data_others = array_filter($results, function($item) {
$chapterid = $item["CHAPID"];
$tesscode = $item['TESTCODE'];
// Memfilter data yang bukan 61 atau 3
return $chapterid !== 3 && $chapterid !== 4 && $chapterid !== 61 && $chapterid !== 62 || $tesscode == 'NOTE';
});
$fullPage = "";
if ($data_urine != null && count($data_urine) > 1) {
$fullPage .= $this->otherTests($data_urine);
}
if ($data_feces != null && count($data_feces) > 1) {
$fullPage .= $this->otherTests($data_feces);
}
if ($data_others != null && count($data_others) > 1) {
$fullPage .= $this->otherTests($data_others);
}
return view('result_report', ['data' => $fullPage]);
}
}

View File

@ -204,7 +204,7 @@ function viewAccess(access) {
}
function resultPdfAccess(access, event) {
event.stopPropagation(); // Mencegah klik pada <tr> dieksekusi
let url = '<?=base_url();?>prints/result_test/'+access;
let url = '<?=base_url();?>printResult/'+access;
window.open(url, '_blank');
}
</script>

View File

@ -34,10 +34,12 @@ $name = $row['NAME'];
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceiveAll(<?=$accessnumber;?>)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
</td>
</tr>
<!--
<tr>
<td></td> <td></td> <td>Collection</td>
<td><button type='button' class='btn btn-dark m-0 px-2 py-1'><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
</tr>
-->
<?php
foreach($data as $row) {
$sampletype = $row['SAMPLETYPE'];
@ -58,7 +60,7 @@ $name = $row['NAME'];
}
echo "<td>$sampletext</td>";
echo "<td>
<button type='button' class='btn btn-dark m-0 px-2 py-1' " . "onclick='printSingleLabel($accessnumber, \"$sampletext\")'" . "><h6 class='p-0 m-0'><i class='bi bi-printer'></i></h6></button>
<button type='button' class='btn btn-dark m-0 px-2 py-1' " . "onclick='printSingleLabel($accessnumber, $sampletype)'" . "><h6 class='p-0 m-0'><i class='bi bi-printer'></i></h6></button>
<button type='button' class='btn btn-success m-0 px-2 py-1' onclick='collect($sampletype, $accessnumber)'><h6 class='p-0 m-0'>Coll.</h6></button>
<button type='button' class='btn btn-warning m-0 px-2 py-1' onclick='uncollect($sampletype, $accessnumber)'><h6 class='p-0 m-0'>Un-Coll.</h6></button>
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceive($sampletype, $accessnumber)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
@ -76,10 +78,10 @@ $name = $row['NAME'];
</div>
<script>
function printSingleLabel(access, sample) {
const url = '<?=base_url();?>prints/single_sample/'+access.toString()+'/'+sample.toString();
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
fetch(url)
.then(response => response.json()) // Mengonversi response menjadi JSON (atau gunakan .text() jika formatnya teks)
.then(response => response.json())
.then(data => {
if (data['status']) {
@ -96,12 +98,11 @@ function printSingleLabel(access, sample) {
});
}
function printAllLabel(access) {
const url = '<?=base_url();?>prints/all_sample/'+access.toString();
const url = '<?=base_url();?>printLabel/all/'+access.toString();
fetch(url)
.then(response => response.json()) // Mengonversi response menjadi JSON (atau gunakan .text() jika formatnya teks)
.then(response => response.json())
.then(data => {
if (data['status']) {
console.log(data['message']);
} else {
@ -109,7 +110,6 @@ function printAllLabel(access) {
message = data['message']+"\n"+data['error'];
alert(message);
}
})
.catch(error => {
console.error('Error:', error);

View File

@ -204,7 +204,7 @@ function viewAccess(access) {
}
function resultPdfAccess(access, event) {
event.stopPropagation(); // Mencegah klik pada <tr> dieksekusi
let url = '<?=base_url();?>prints/result_test/'+access;
let url = '<?=base_url();?>printResult/'+access;
window.open(url, '_blank');
}
</script>

View File

@ -34,10 +34,12 @@ $name = $row['NAME'];
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceiveAll(<?=$accessnumber;?>)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
</td>
</tr>
<!--
<tr>
<td></td> <td></td> <td>Collection</td>
<td><button type='button' class='btn btn-dark m-0 px-2 py-1'><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
</tr>
-->
<?php
foreach($data as $row) {
$sampletype = $row['SAMPLETYPE'];

View File

@ -204,7 +204,7 @@ function viewAccess(access) {
}
function resultPdfAccess(access, event) {
event.stopPropagation(); // Mencegah klik pada <tr> dieksekusi
let url = '<?=base_url();?>prints/result_test/'+access;
let url = '<?=base_url();?>printResult/'+access;
window.open(url, '_blank');
}
</script>

View File

@ -34,10 +34,12 @@ $name = $row['NAME'];
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceiveAll(<?=$accessnumber;?>)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
</td>
</tr>
<!--
<tr>
<td></td> <td></td> <td>Collection</td>
<td><button type='button' class='btn btn-dark m-0 px-2 py-1'><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
</tr>
-->
<?php
foreach($data as $row) {
$sampletype = $row['SAMPLETYPE'];

View File

@ -204,7 +204,7 @@ function viewAccess(access) {
}
function resultPdfAccess(access, event) {
event.stopPropagation(); // Mencegah klik pada <tr> dieksekusi
let url = '<?=base_url();?>prints/result_test/'+access;
let url = '<?=base_url();?>printResult/'+access;
window.open(url, '_blank');
}
</script>

View File

@ -34,10 +34,12 @@ $name = $row['NAME'];
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceiveAll(<?=$accessnumber;?>)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
</td>
</tr>
<!--
<tr>
<td></td> <td></td> <td>Collection</td>
<td><button type='button' class='btn btn-dark m-0 px-2 py-1'><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
</tr>
-->
<?php
foreach($data as $row) {
$sampletype = $row['SAMPLETYPE'];