From e2b6d6ae290c5182f5b11f6e746196318cb76f74 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Sun, 9 Mar 2025 22:28:56 +0700 Subject: [PATCH] Update Laporan Hasil Sesuai Dengan TM --- app/Controllers/PrintResult.php | 702 +++++++++++++++++---- app/Views/result_report.php | 4 +- public/assets/css/pdf_new.css | 161 +++++ public/assets/css/{pdf.css => pdf_old.css} | 0 4 files changed, 748 insertions(+), 119 deletions(-) create mode 100644 public/assets/css/pdf_new.css rename public/assets/css/{pdf.css => pdf_old.css} (100%) diff --git a/app/Controllers/PrintResult.php b/app/Controllers/PrintResult.php index 5b034e6..03f4445 100644 --- a/app/Controllers/PrintResult.php +++ b/app/Controllers/PrintResult.php @@ -24,9 +24,456 @@ class PrintResult extends BaseController { return true; } - public function otherTests($resultData, $data, $note) { + // public function pdfViewerOld($resultData, $data, $note) { + // // Mengetahui Apakah User Login adalah Bali atau Surabaya + // $cityid = session()->get('usercityid'); + + // // Digunakan untuk mengetahui user yang melakukan Validasi khusus analis surabaya + // foreach($resultData as $result) { + // $uservalidator = $result['validator']; + // break; + // } + + // if ($cityid == 1) { + + // if ($uservalidator != null){ + // $doctor = "dr. I Komang Parwata Sp.PK"; + // $analyst = "Mrs. Gusti Ayu Riska Mastari"; + // $noreg = "Reg. No: 570/SIPDS/0001/I/DPMPTSP/2023"; + // $signature = ""; + // $enteredby = "Entered By"; + // $labtech = "Lab Technician"; + // $verifiedby = "Verified By"; + + // } else { + // $verifiedby = "Waiting for Validation"; + // $enteredby = "Waiting for Validation"; + // $labtech = ""; + // $doctor = ""; + // $analyst = ""; + // $noreg = ""; + // $signature = ""; + // } + + // } elseif ($cityid == 2) { + + // if ($uservalidator == "MG") { + // $doctor = "dr. I.G.A.A Putri Sri Rejeki, Sp.PK"; + // $noreg = "SIP : 503.446/1091/B/IP.DS/436.7.15/2022"; + // $signature = ""; + // $enteredby = "Entered By"; + // $labtech = "Lab Technician"; + // $analyst = "Mrs. Mega Rahayu Ningsih"; + // $verifiedby = "Verified By"; + // } else if ($uservalidator == "ACP") { + // $doctor = "dr. I.G.A.A Putri Sri Rejeki, Sp.PK"; + // $noreg = "SIP : 503.446/1091/B/IP.DS/436.7.15/2022"; + // $signature = ""; + // $enteredby = "Entered By"; + // $labtech = "Lab Technician"; + // $analyst = "Mrs. Afrita Catur Pratiwi"; + // $verifiedby = "Verified By"; + // } else { + // $verifiedby = "Waiting for Validation"; + // $enteredby = "Waiting for Validation"; + // $labtech = ""; + // $doctor = ""; + // $analyst = ""; + // $noreg = ""; + // $signature = ""; + // } + + // } else { //Jika Login Adalah Sistem dan tidak punya city id + // $verifiedby = "LISFSE/SYSTEM/ADMIN"; + // $enteredby = "LISFSE/SYSTEM/ADMIN"; + // $labtech = ""; + // $doctor = ""; + // $analyst = ""; + // $noreg = ""; + // $signature = ""; + // } + + // if ($data[0] != null) { + + // $accessnumber = $data[0]['SP_ACCESSNUMBER']; + + // $sex = $data[0]['SEX'] == 1 ? "Male" : "Female"; + + // $rm_number = $data[0]['PATNUMBER']; + // $rm_number = substr($rm_number, -10); + + // $first_name = $data[0]['FIRSTNAME']; + // $last_name = $data[0]['NAME']; + + // $birth_date = $data[0]['BIRTHDATE']; + // $birth_date = \DateTime::createFromFormat('Y-m-d H:i:s.u', $birth_date); + // if ($birth_date) { $birth_date = $birth_date->format('d-m-Y'); } + + // $hostordernumber = $data[0]['HOSTORDERNUMBER']; + + // $collection_date = $data[0]['COLLECTIONDATE']; + // $dateTimeCol = \DateTime::createFromFormat('Y-m-d H:i:s.u', $collection_date); + // if ($dateTimeCol) { + // $collection_date = $dateTimeCol->format('d-m-Y H:i'); + // } + + // $result_date = end($resultData); + // $result_date = $result_date["RESDATE_FIX"]; + // $dateTimeRes = \DateTime::createFromFormat('Y-m-d H:i:s.u', $result_date); + // if ($dateTimeRes) { + // $result_date = $dateTimeRes->format('d-m-Y H:i'); + // } + + // } else { + // $sex =''; + // $accessnumber = ""; + // $rm_number = ""; + // $first_name = ""; + // $last_name = ""; + // $birth_date = ""; + // $hostordernumber = ""; + // $collection_date = ""; + // $result_date = ""; + // } + // $fullPage=""; + // $headPage = " + //
+ //
+ + //
+ + // + // + // + // + + // + // + // + // + // + // + // + // + + // + // + // + // + // + // + // + // + + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + + //
CLINICAL LABORATORY
RM Number:$rm_numberVisit Number:$hostordernumber
First Name:$first_nameRequest Number:$accessnumber
Last Name:$last_nameOrder Date/Time:$collection_date
DoB/Gender:$birth_date / $sexResult Date/Time:$result_date
+ + //
+ + //
+ //
+ // + + // + // + // + // + // + // + // + // + // "; + + // $resultTest =""; + + // // Untuk Collection + // if ($data[1] != null) { + // $colltext = ''; + // $recvtext = ''; + // $qcolldate = ''; + // $qcolltime = ''; + // $qrecvdate = ''; + // $qrecvtime = ''; + // foreach ($data[1] as $item) { + // $samp = $item['SHORTTEXT']; + // $colldate = $item['colldate']; + // $recvdate = $item['recvdate']; + // $colltime = $item['colltime']; + // $recvtime = $item['recvtime']; + // if($colldate !='') { + // if($colldate != $qcolldate) { $colltext .= "$colldate $colltime $samp"; $qcolldate = $colldate; $qcolltime = $colltime; } + // else { + // if($colltime != $qcolltime) { $colltext .= ", $colltime $samp"; $qcolltime = $colltime; } + // else { $colltext .= ", $samp"; } + // } + // } + // if($recvdate !='') { + // if($recvdate != $qrecvdate) { $recvtext .= "$recvdate $recvtime $samp"; $qrecvdate = $recvdate; $qrecvtime = $recvtime; } + // else { + // if($recvtime != $qrecvtime) { $recvtext .= ", $recvtime $samp"; $qrecvtime = $recvtime; } + // else { $recvtext .= ", $samp"; } + // } + // } + // } + // } + + // $resultNoteandSpecimen = " + //
+ + //
Parameter ResultUnitNormal RangeSample
+ // + // + // + // + // + // + //
Notes
+ // ".$note." + //
+ + //
+ + // + // + // + // + // + // + // + // + // + //
Collection datetime : $colltext
Reception datetime : $recvtext
+ // "; + // $footerPage = " + // + // "; + // $lastDiv="
"; + + // $tempChapEng = ""; + // $tempChapInd = ""; + + // $i=0; + // foreach ($resultData as $item) { + + // // Untuk Spasi Depth + // $space=""; + // if ($item['RESULT'] != null) { + // $j=0; + + // $space.=" "; + // for ($j=0; $j<=$item['DEPTH']; $j++) { + // $space .= "  "; + // } + // if ($item['DEPTH']==0){ + // $space.=" "; + // } + + // } else { + + // for ($j=0; $j<=$item['DEPTH']; $j++) { + // $space .= "  "; + // } + + // } + + // // Untuk Penamaan Serum Khusus test + // if ($item["RESULT"] == null) { + // $serum_type = ""; + // }else { + // $serum_type = $item["serum_type"]; + // } + + // $resflag = $item["RESFLAG"] == "N" ? '' : $item["RESFLAG"]; + + // if ($tempChapEng != $item['chap_eng']) { + // $tempChapEng = $item['chap_eng']; + // $tempChapInd = $item['chap_ind']; + + // $i++; + + // // Melebihi batas Kertas + // if($i % 25 == 0) { + // $resultTest .= "
"; + // $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; + // $i=0; + // $resultTest = ""; + // } + + // if($i==0){ + // $i++; + // } + // // Untuk Chapter + // $resultTest .= " + // + // + //
".$tempChapEng."
+ // + // + // + // "; + // } + + // // Melebihi batas Kertas + // if($i % 25 == 0 && $i!=0) { + // $resultTest .= ""; + // $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; + // $i=0; + // $resultTest = ""; + // } + + // $i++; + // if ($item['RESTYPE'] == "CE"){ + // $resvalue = $item['RESULT']; + // } else if ($item['RESTYPE'] == null) { + // $resvalue = $item['RESULT']; + // } else { + // $resvalue = $item['RESVALUE']; + // } + // $reff = $item["REFRANGE"]; + // $refftext = $item["REFFTEXT"]; + // if($refftext !='') {$reff = $refftext;} + // $unit = $item['UNIT']; + // $unittext = $item['UNITTEXT']; + // if($unittext !='') {$unit = $unittext;} + + // // Untuk mewarnai value yang tidak beda dengan nilai normal + // $color = ""; + // if ($resflag == 'L' || $resflag == 'H') { + // $color = "red_font"; + // } + + // // Hanya Untuk Yang Kode Nya Adalah CODE/CM + // $range = $this->checkRange($item['RESULT'], $item['REFFTEXT']); + // if ($item['code_type'] == 6 && $item['REFFTEXT'] != null) { + + // if ($range == true) { // Jika nilai masih dalam rentang nilai normal misal : 0 - 1 + // $color = ""; + // } elseif ($range == false) { // Jika nilai bukan merupakan rentang alias hanya code + // $redWord = ["positive", "reactive"]; + // if (in_array(strtolower($item['RESULT']), $redWord)) { + // $color = "red_font"; + // } + // } + // else { // Jika Rentang diatas nilai normal + // $color = "red_font"; + // } + // } + + // // Hanya Untuk Kondisi Ada Komentar Dibawah Result + // if ($item['RESCOMMENT'] != null) { + // $redWord = ["positive", "reactive", "pos", "reac"]; + // if (in_array(strtolower($item['RESCOMMENT']), $redWord)) { + // $color = "red_font"; + // } + + // $comment = $item['RESCOMMENT']; + // // Kondisi Sangat Khusus + // if ($item['RESCOMMENT'] == "NREAC") { + // $comment = "Non Reactive"; + // } else if ($item['RESCOMMENT'] == "REAC") { + // $comment = "Reactive"; + // } + // $rescomment = "
" . $comment . ""; + + // } else { + // $rescomment = ""; + // } + + + // $test = ""; + // // Untuk Nama Test Apakah lebih dari 25 karaktera + // if ( strlen($item['test_eng']) > 25 || strlen($item['test_ind']) > 25) { + // $test = "
" . $space . $item["test_eng"]."
$space".$item["test_ind"]."
"; + // } else { + // $test = "
" . $space . $item["test_eng"]." "."".$item["test_ind"]."
"; + // } + + // if ($item['code_type'] == 5) { + // $resultTest .= " + // + // + // ".$test." + // + // " . $resflag . " + // " . $resvalue . $rescomment ." + // " . $serum_type . " + // + // "; + // } else { + // $resultTest .= " + // + // + // ".$test." + // + // " . $resflag . " + // " . $resvalue . $rescomment ." + // " . "
" .$unit. "
" . "
+	// 					" . "
" .$reff. "
" . "
+	// 					" . $serum_type . "
+	// 				
+	// 			";
+	// 		}
+			
+			
+            
+    //         // Melebihi batas Kertas
+    //         if($i % 25 == 0 && $i != 0) {
+    //             $resultTest .= "";
+    //             $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
+    //             $i=0;
+    //             $resultTest = "";
+    //         }
+	
+	// 	}
+
+	// 	$resultTest .= "
+	// 			
+	// 			".$resultNoteandSpecimen."
+	// 			";
+		
+	// 	$fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
+
+	// 	return $fullPage;
+	// }
+
+	public function pdfViewerNew($resultData, $data, $note) {
 
 		// Mengetahui Apakah User Login adalah Bali atau Surabaya
 		$cityid = session()->get('usercityid');
@@ -37,7 +484,9 @@ class PrintResult extends BaseController {
 			break;
 		}
 
-		if ($cityid == 1) {
+		// Untuk Membedakan Laporan Bali dan Surabaya
+		$hostordernumber = $data[0]['HOSTORDERNUMBER'];
+		if ($hostordernumber[0] == 'B' || $hostordernumber[0] == 'Z') {
 
 			if ($uservalidator != null){
 				$doctor = "dr. I Komang Parwata Sp.PK";
@@ -58,24 +507,19 @@ class PrintResult extends BaseController {
 				$signature = "";
 			}
 			
-		} elseif ($cityid == 2) {
+		} elseif ($hostordernumber[0] == 'S' || $hostordernumber[0] == 'X') {
+
+			$doctor = "dr. I.G.A.A Putri Sri Rejeki, Sp.PK";
+			$noreg = "SIP : 503.446/1091/B/IP.DS/436.7.15/2022";
+			$signature = "";
+			$enteredby = "Entered By";
+			$labtech = "Lab Technician";
+			$verifiedby = "Verified By";
 
 			if ($uservalidator == "MG") {
-				$doctor = "dr. I.G.A.A Putri Sri Rejeki, Sp.PK";
-				$noreg = "SIP : 503.446/1091/B/IP.DS/436.7.15/2022";
-				$signature = "";
-				$enteredby = "Entered By";
-				$labtech = "Lab Technician";
 				$analyst = "Mrs. Mega Rahayu Ningsih";
-				$verifiedby = "Verified By";
 			} else if ($uservalidator == "ACP") {
-				$doctor = "dr. I.G.A.A Putri Sri Rejeki, Sp.PK";
-				$noreg = "SIP : 503.446/1091/B/IP.DS/436.7.15/2022";
-				$signature = "";
-				$enteredby = "Entered By";
-				$labtech = "Lab Technician";
 				$analyst = "Mrs. Afrita Catur Pratiwi";
-				$verifiedby = "Verified By";
 			} else {
 				$verifiedby = "Waiting for Validation";
 				$enteredby = "Waiting for Validation";
@@ -86,7 +530,8 @@ class PrintResult extends BaseController {
 				$signature = "";
 			}
 
-		} else { //Jika Login Adalah Sistem dan tidak punya city id
+		} 
+		else { //Jika Login Adalah Sistem dan tidak punya city id
 			$verifiedby = "LISFSE/SYSTEM/ADMIN";
 			$enteredby = "LISFSE/SYSTEM/ADMIN";
 			$labtech = "";
@@ -96,6 +541,7 @@ class PrintResult extends BaseController {
 			$signature = "";
 		}
 
+		// Khusus untuk value Header
 		if ($data[0] != null) {
 
 			$accessnumber = $data[0]['SP_ACCESSNUMBER'];
@@ -112,7 +558,13 @@ class PrintResult extends BaseController {
 			$birth_date = \DateTime::createFromFormat('Y-m-d H:i:s.u', $birth_date);
 			if ($birth_date) { $birth_date = $birth_date->format('d-m-Y'); }
 
-			$hostordernumber = $data[0]['HOSTORDERNUMBER'];
+			if ($hostordernumber[0] == 'B' || $hostordernumber[0] == 'Z') {
+				$branch = "PMG Bali";
+			} elseif ($hostordernumber[0] == 'S' || $hostordernumber[0] == 'X') {
+				$branch = "PMG Surabaya";
+			} else {
+				$branch = "Unknown";
+			}
 			
 			$collection_date = $data[0]['COLLECTIONDATE'];
 			$dateTimeCol = \DateTime::createFromFormat('Y-m-d H:i:s.u', $collection_date);
@@ -126,6 +578,9 @@ class PrintResult extends BaseController {
 			if ($dateTimeRes) {
 				$result_date = $dateTimeRes->format('d-m-Y H:i');
 			}
+
+			$company = $data[0]['AGENT'];
+			$visittype = $data[0]['VISITTYPE'];
 			
 		} else {
 			$sex ='';
@@ -137,6 +592,9 @@ class PrintResult extends BaseController {
 			$hostordernumber = "";
 			$collection_date = "";
 			$result_date = "";
+			$branch = "";
+			$company = "";
+			$visittype = "";
 		}
 		
 		$fullPage="";
@@ -152,58 +610,46 @@ class PrintResult extends BaseController {
 					
 
 					
-						RM Number
-						:
-						$rm_number
-						Visit Number
-						:
-						$hostordernumber
+						
RM Number: $rm_number
+ + +
Visit Number: $hostordernumber
+ - First Name - : - $first_name - Request Number - : - $accessnumber +
Name: $first_name $last_name
+ +
Company: $company
+ - Last Name - : - $last_name - Order Date/Time - : - $collection_date +
DOB: $birth_date
+ +
Visit Type: $visittype
+ - DoB/Gender - : - $birth_date / $sex - Result Date/Time - : - $result_date +
Gender: $sex
+
Order Date / Time: $collection_date
+ + + +
Branch: $branch
+
Result Date / Time: $result_date
+ - +
-
- - - - - - - - - - +
+
Parameter ResultUnitNormal RangeSample
"; - + $resultTest =""; // Untuk Collection @@ -242,10 +688,10 @@ class PrintResult extends BaseController {
- + - @@ -262,30 +708,28 @@ class PrintResult extends BaseController { -
NotesNotes
+ ".$note."
Reception datetime : $recvtext
- "; + "; $footerPage = " - - "; + "; $lastDiv="
"; $tempChapEng = ""; @@ -331,7 +775,7 @@ class PrintResult extends BaseController { $i++; // Melebihi batas Kertas - if($i % 28 == 0) { + if($i % 18 == 0) { $resultTest .= ""; $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; $i=0; @@ -343,17 +787,35 @@ class PrintResult extends BaseController { } // Untuk Chapter $resultTest .= " - - -
".$tempChapEng."
- - + + + + + + + + + + + + + + + $tempChapEng + + + + Parameter + Result + Unit + Normal Range + Sample "; } // Melebihi batas Kertas - if($i % 28 == 0 && $i!=0) { + if($i % 18 == 0 && $i!=0) { $resultTest .= ""; $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv; $i=0; @@ -378,6 +840,7 @@ class PrintResult extends BaseController { // Untuk mewarnai value yang tidak beda dengan nilai normal $color = ""; if ($resflag == 'L' || $resflag == 'H') { + $resflag .= "  "; $color = "red_font"; } @@ -420,22 +883,30 @@ class PrintResult extends BaseController { $test = ""; - // Untuk Nama Test Apakah lebih dari 24 karaktera - if ( strlen($item['test_eng']) > 24 || strlen($item['test_ind']) > 24) { + // Untuk Nama Test Apakah lebih dari 25 karaktera + if ( strlen($item['test_eng']) > 25 || strlen($item['test_ind']) > 25) { $test = "
" . $space . $item["test_eng"]."
$space".$item["test_ind"]."
"; } else { $test = "
" . $space . $item["test_eng"]." "."".$item["test_ind"]."
"; } - if ($item['code_type'] == 5) { + // Untuk Mengeluarkan Result + if ($item['code_type'] == 5) { //Jika dia adalah Komentar $resultTest .= " ".$test." - " . $resflag . " - " . $resvalue . $rescomment ." - " . $serum_type . " + " . $resflag ." ". $resvalue . $rescomment ." + " . $serum_type . " + + "; + } else if ($resvalue==null && $rescomment == null && $unit == null && $reff==null && $serum_type == null) { //Jika Ini adalah nama chapter + $resultTest .= " + + + ".$test." + "; } else { @@ -444,19 +915,16 @@ class PrintResult extends BaseController { ".$test." - " . $resflag . " - " . $resvalue . $rescomment ." - " . "
" .$unit. "
" . "
-						" . "
" .$reff. "
" . "
-						" . $serum_type . "
+						" . $resflag ." ". $resvalue .  $rescomment ."
+						" . "
" .$unit. "
" . "
+						" . "
" .$reff. "
" . "
+						" . $serum_type . "
 					
 				";
 			}
 			
-			
-            
             // Melebihi batas Kertas
-            if($i % 28 == 0 && $i != 0) {
+            if($i % 18 == 0 && $i != 0) {
                 $resultTest .= "";
                 $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
                 $i=0;
@@ -491,19 +959,21 @@ class PrintResult extends BaseController {
 		// Untuk Header
 		$sql = "SELECT 
 					p.PATNUMBER, 
-					p.FIRSTNAMESK as FIRSTNAME, 
+					p.FIRSTNAMESK AS FIRSTNAME, 
 					p.NAME,  
 					p.BIRTHDATE, 
 					sr.HOSTORDERNUMBER, 
 					sr.COLLECTIONDATE, 
 					sr.SP_ACCESSNUMBER, 
 					p.SEX, 
-					".$filter_query_result."
-				FROM 
-					PATIENTS p
-				LEFT JOIN 
-					SP_REQUESTS sr 
-					ON p.PATID = sr.PATID
+					".$filter_query_result.",
+					ctr.AGENT,
+					ctr.VISITTYPE
+				
+				FROM PATIENTS p
+				LEFT JOIN SP_REQUESTS sr ON p.PATID = sr.PATID
+				LEFT JOIN cmod.dbo.CM_TM_REQUESTS ctr ON ctr.REFFID = sr.HOSTORDERNUMBER
+				
 				LEFT JOIN 
 					(
 						SELECT 
@@ -593,8 +1063,6 @@ class PrintResult extends BaseController {
         $query = $db->query($sql);
         $results = $query->getResultArray();
 
-		// var_dump($results);die();
-		
 		$data_pregnancy = array_filter($results, function($item) {
             $serum_type = $item["serum_type"];
 			$tesscode = $item["TESTCODE"];
@@ -661,31 +1129,31 @@ class PrintResult extends BaseController {
         $fullPage = "";
 
 		if ($data_others != null) {
-            $fullPage .= $this->otherTests($data_others, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_others, $data, $note);
         }
 
 		if ($data_RCS != null) {
-            $fullPage .= $this->otherTests($data_RCS, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_RCS, $data, $note);
         }
 
 		if ($data_urine_kultur != null) {
-            $fullPage .= $this->otherTests($data_urine_kultur, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_urine_kultur, $data, $note);
         }
 		if ($data_pregnancy != null) {
-            $fullPage .= $this->otherTests($data_pregnancy, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_pregnancy, $data, $note);
         }
 		if ($data_urine_lengkap != null) {
-            $fullPage .= $this->otherTests($data_urine_lengkap, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_urine_lengkap, $data, $note);
         }
 		
         if ($data_feces_stc2 != null) {
-            $fullPage .= $this->otherTests($data_feces_stc2, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_feces_stc2, $data, $note);
         }
 		if ($data_feces_stc4 != null) {
-            $fullPage .= $this->otherTests($data_feces_stc4, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_feces_stc4, $data, $note);
         }
 		if ($data_feces_lengkap != null) {
-            $fullPage .= $this->otherTests($data_feces_lengkap, $data, $note);
+            $fullPage .= $this->pdfViewerNew($data_feces_lengkap, $data, $note);
         }
         
         return view('result_report', ['data' => $fullPage, 'site' => $header['HOSTORDERNUMBER']]);
diff --git a/app/Views/result_report.php b/app/Views/result_report.php
index 86a0ad8..060e1c1 100644
--- a/app/Views/result_report.php
+++ b/app/Views/result_report.php
@@ -1,5 +1,5 @@
 
 
 	
-	
+