290 lines
8.6 KiB
PHP
290 lines
8.6 KiB
PHP
<?php
|
|
namespace App\Controllers;
|
|
|
|
class PrintResult extends BaseController {
|
|
|
|
public function otherTests($access, $collection){
|
|
|
|
$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 ="";
|
|
|
|
$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 = "
|
|
<br>
|
|
|
|
<table class='result t_center'>
|
|
<tr>
|
|
<th align='left' class='padmaColor'>Notes</th>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
".$items['RESVALUE']."
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
|
|
<table class='t_center table_collection' >
|
|
<tr>
|
|
<td><pre>Collection datetime : $collectionText </pre></td>
|
|
</tr>
|
|
<tr>
|
|
<td><pre>Reception datetime : $receptionText </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();
|
|
|
|
// 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]);
|
|
}
|
|
|
|
} |