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 =""; $items = end($access); // Untuk Collection if ($collection != null) { $cm_output = []; $sp_output = []; foreach ($collection as $item) { $cm_output[] = "{$item['SHORTTEXT']} " . date('Y-m-d H:i:s', strtotime($item['CM_collection_datetime'])); $sp_output[] = "{$item['SHORTTEXT']} " . date('Y-m-d H:i:s', strtotime($item['SP_reception_datetime'])); } $collectionText = implode(' | ', $cm_output) . "\n"; $receptionText = implode(' | ', $sp_output) . "\n"; } $resultNoteandSpecimen = "
Parameter Result Unit Normal Range Notes
Notes
".$items['RESVALUE']."

Collection datetime : $collectionText 
Reception datetime  : $receptionText 
"; $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(); // Untuk Collection $sql = "select tu.SAMPLETYPE, ds.SHORTTEXT, tu.COLLECTIONDATE as CM_collection_datetime, ct.COLLECTIONDATE as SP_reception_datetime from SP_TUBES tu left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE= tu.SAMPLETYPE left join cmod.dbo.CM_TUBES ct on ct.SAMPLETYPE=tu.SAMPLETYPE and ct.ACCESSNUMBER=tu.SP_ACCESSNUMBER where tu.SP_ACCESSNUMBER='$access' "; $query = $db->query($sql); $results = $query->getResultArray(); $collection = $results; $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, $collection); } if ($data_feces != null && count($data_feces) > 1) { $fullPage .= $this->otherTests($data_feces, $collection); } if ($data_others != null && count($data_others) > 1) { $fullPage .= $this->otherTests($data_others, $collection); } return view('result_report', ['data' => $fullPage]); } }