diff --git a/app/Controllers/PrintResult.php b/app/Controllers/PrintResult.php
index f0f0081..5c2a4e3 100644
--- a/app/Controllers/PrintResult.php
+++ b/app/Controllers/PrintResult.php
@@ -3,7 +3,7 @@ namespace App\Controllers;
class PrintResult extends BaseController {
- public function otherTests($resultData, $data){
+ public function otherTests($resultData, $data, $note){
// var_dump($data);die();
@@ -111,10 +111,6 @@ class PrintResult extends BaseController {
$resultTest ="";
- $note = "-";
- // $notes = end($resultData);
- // $note = $notes['RESULT'] == "" ? "-" : $notes['RESULT'];
-
// Untuk Collection
if ($data[1] != null) {
$colltext = '';
@@ -197,15 +193,13 @@ class PrintResult extends BaseController {
";
$lastDiv="";
-
$tempChapEng = "";
$tempChapInd = "";
- // array_pop($resultData);
-
$i=0;
foreach ($resultData as $item) {
+ // Untuk Spasi Depth
$space="";
if ($item['RESULT'] != null) {
$j=0;
@@ -226,6 +220,7 @@ class PrintResult extends BaseController {
}
+ // Untuk Penamaan Serum Khusus test
if ($item["RESULT"] == null) {
$serum_type = "";
}else {
@@ -233,36 +228,49 @@ class PrintResult extends BaseController {
}
$resflag = $item["RESFLAG"] == "N" ? '' : $item["RESFLAG"];
-
+
if ($tempChapEng != $item['chap_eng']) {
$tempChapEng = $item['chap_eng'];
$tempChapInd = $item['chap_ind'];
$i++;
- // Untuk Chapter
- $resultTest .= "
-
-
- ".$tempChapEng."
+
+ // Melebihi batas Kertas
+ if($i % 30 == 0) {
+ $resultTest .= "";
+ $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
+ $i=0;
+ $resultTest = "";
+ }
+
+ if($i==0){
+ $i++;
+ }
+ // Untuk Chapter
+ $resultTest .= "
+ |
+
+ ".$tempChapEng."
- |
-
- ";
-
+
+
+ ";
}
- // // Melebihi batas Kertas
- // if($i % 30 == 0) {
- // $resultTest .= "";
- // $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
- // $i=0;
- // $resultTest = "";
- // }
+ // Melebihi batas Kertas
+ if($i % 30 == 0 && $i!=0) {
+ $resultTest .= "";
+ $fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
+ $i=0;
+ $resultTest = "";
+ }
$i++;
if ($item['RESTYPE'] == "CE"){
$resvalue = $item['RESULT'];
- } else {
+ } else if ($item['RESTYPE'] == null) {
+ $resvalue = $item['RESULT'];
+ } else {
$resvalue = $item['RESVALUE'];
}
$reff = $item["REFRANGE"];
@@ -275,7 +283,7 @@ class PrintResult extends BaseController {
- " . $space . $item["test_eng"]." "."".$item["test_ind"]."
+ " . $space . $i.". ". $item["test_eng"]." "."".$item["test_ind"]."
|
" . $resflag . " |
@@ -286,9 +294,8 @@ class PrintResult extends BaseController {
";
-
// Melebihi batas Kertas
- if($i % 30 == 0) {
+ if($i % 30 == 0 && $i != 0) {
$resultTest .= "";
$fullPage .= $headPage.$resultTest.$footerPage.$lastDiv;
$i=0;
@@ -380,45 +387,30 @@ class PrintResult extends BaseController {
left join cmod.dbo.CM_DICT_TESTS cdt on dt.TESTCODE=cdt.TESTCODE
left join cmod.dbo.CM_RESULTS cr on cr.ACCESSNUMBER=r.ACCESSNUMBER and cr.TESTCODE=cdt.TESTCODE and cr.TESTCODE=dt.TESTCODE
where r.ACCESSNUMBER='$access'
- ORDER BY dc.CHAPID, t.TESTORDER
+ ORDER BY t.TESTORDER
";
$query = $db->query($sql);
$results = $query->getResultArray();
- // // Seleksi data yang mengandung "URINE"
- // $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 || $chapterid == 5 || $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
- // return $chapterid !== 3 && $chapterid !== 4 && $chapterid !== 61 && $chapterid !== 62 || $tesscode == 'NOTE';
- // });
-
$data_pregnancy = array_filter($results, function($item) {
$serum_type = $item["serum_type"];
$tesscode = $item["TESTCODE"];
- return $serum_type == 'Urine' && $tesscode == 'PPT';
+ $test_eng = $item["test_eng"];
+ return $serum_type == 'Urine' && ($tesscode == 'PPT' || $test_eng == "Pregnancy Test");
});
$data_urine_lengkap = array_filter($results, function($item) {
$serum_type = $item["serum_type"];
$tesscode = $item["TESTCODE"];
- return $serum_type == 'Urine' && $tesscode != 'PPT';
+ $test_eng = $item["test_eng"];
+ $chap_eng = $item["chap_eng"];
+ return $serum_type == 'Urine' && $tesscode != 'PPT' && $test_eng != "Pregnancy Test" && $chap_eng != "MICROBIOLOGY";
+ });
+ $data_urine_kultur = array_filter($results, function($item) {
+ $serum_type = $item["serum_type"];
+ $chap_eng = $item["chap_eng"];
+ return $serum_type == 'Urine' && $chap_eng == "MICROBIOLOGY";
});
-
$data_feces_stc2 = array_filter($results, function($item) {
$serum_type = $item["serum_type"];
$tesscode = $item["TESTCODE"];
@@ -441,26 +433,42 @@ class PrintResult extends BaseController {
return $serum_type != 'Feces' && $serum_type != 'Urine' && $chapter_eng != 'Note';
});
+ $notes = array_filter($results, function($item) {
+ $chap_id = $item["CHAPID"];
+ $chap_eng = $item["chap_eng"];
+ return $chap_id == 54 && $chap_eng == "Note";
+ });
+ // Mengambil elemen pertama dari hasil filter
+ $notes = reset($notes); // Ambil elemen pertama
+ $note = $notes["RESULT"] ?? "-"; // Ambil nilai RESULT, atau null jika tidak ada
+
+
$fullPage = "";
- if ($data_urine_lengkap != null) {
- $fullPage .= $this->otherTests($data_urine_lengkap, $data);
- }
- if ($data_pregnancy != null) {
- $fullPage .= $this->otherTests($data_pregnancy, $data);
- }
- if ($data_feces_lengkap != null) {
- $fullPage .= $this->otherTests($data_feces_lengkap, $data);
- }
- if ($data_feces_stc2 != null) {
- $fullPage .= $this->otherTests($data_feces_stc2, $data);
- }
- if ($data_feces_stc4 != null) {
- $fullPage .= $this->otherTests($data_feces_stc4, $data);
- }
- if ($data_others != null) {
- $fullPage .= $this->otherTests($data_others, $data);
+
+ if ($data_others != null) {
+ $fullPage .= $this->otherTests($data_others, $data, $note);
}
+ if ($data_urine_kultur != null) {
+ $fullPage .= $this->otherTests($data_urine_kultur, $data, $note);
+ }
+ if ($data_pregnancy != null) {
+ $fullPage .= $this->otherTests($data_pregnancy, $data, $note);
+ }
+ if ($data_urine_lengkap != null) {
+ $fullPage .= $this->otherTests($data_urine_lengkap, $data, $note);
+ }
+
+ if ($data_feces_stc2 != null) {
+ $fullPage .= $this->otherTests($data_feces_stc2, $data, $note);
+ }
+ if ($data_feces_stc4 != null) {
+ $fullPage .= $this->otherTests($data_feces_stc4, $data, $note);
+ }
+ if ($data_feces_lengkap != null) {
+ $fullPage .= $this->otherTests($data_feces_lengkap, $data, $note);
+ }
+
return view('result_report', ['data' => $fullPage]);
}