Perbaikan Laporan Hasil, Menambahlan ResFlag, Menambahkan Depth dan menampilkan Serum Type

This commit is contained in:
mikael-zakaria 2024-12-12 22:17:15 +08:00
parent e39ea6544a
commit 4edc2ca96f

View File

@ -99,7 +99,8 @@ class PrintResult extends BaseController {
<table class='result t_center'>
<tr align='left'>
<th class='padmaColor' style='width:35%'>Parameter</th>
<th class='padmaColor' style='width:34%'>Parameter</th>
<th class='padmaColor' style='width:1%'> </th>
<th class='padmaColor' style='width:13%'>Result</th>
<th class='padmaColor' style='width:13%'>Unit</th>
<th class='padmaColor' style='width:20%'>Normal Range</th>
@ -135,7 +136,7 @@ class PrintResult extends BaseController {
</tr>
<tr>
<td>
".$items['RESVALUE']."
".$items['RESULT']."
</td>
</tr>
</table>
@ -184,6 +185,15 @@ class PrintResult extends BaseController {
$i=0;
foreach ($resultData as $item) {
$space="";
if ($item['DEPTH'] > 0) {
for ($i=0; $i<$item['DEPTH']; $i++) {
$space .= "&nbsp;";
}
}
$resflag = $item["RESFLAG"] == "N" ? '' : $item["RESFLAG"];
if ($tempChapEng != $item['chap_eng']) {
$tempChapEng = $item['chap_eng'];
$tempChapInd = $item['chap_ind'];
@ -217,13 +227,14 @@ class PrintResult extends BaseController {
$resultTest .= "
<tr>
<td colspan='1' class=''>
<pre> ".$item["test_eng"]."</pre>
<pre> <small>".$item["test_ind"]."</small></pre>
<pre> ".$space . $item["test_eng"]."</pre>
<pre> ".$space."<small>".$item["test_ind"]."</small></pre>
</td>
<td class=''>" . $resflag . "</td>
<td class=''>" . $resvalue . "</td>
<td class=''>" . $item["UNIT"] . "</td>
<td class=''>" . $item["REFRANGE"] . "</td>
<td class=''>" . " " . "</td>
<td class=''>" . $item["serum_type"] . "</td>
</tr>
";
@ -274,34 +285,65 @@ class PrintResult extends BaseController {
$data = [$header, $collection];
// var_dump($data[0]['PATNUMBER']);die();
$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;
";
// BACKUP
// $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;
// ";
$sql = "
select
dc.CHAPID,
dc.FULLTEXT as chap_eng,
dc.FULLTEXT as chap_ind,
st.FULLTEXT as serum_type,
cdt.TEXT1 as test_eng,
cdt.TEXT2 as test_ind,
t.DEPTH,
t.TESTORDER,
dt.SHORTTEXT,
RESULT = case when t.RESVALUE is null then tx.FULLTEXT else t.RESVALUE end,
cr.*
from REQUESTS r
left join TESTS t on t.REQUESTID = r.REQUESTID
left join DICT_TESTS dt on dt.ENDVALIDDATE is null 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 DICT_TEST_SAMPLES ts on ts.TESTID=t.TESTID and dt.TESTID=ts.TESTID
left join DICT_SAMPLES_TYPES st on st.SAMPTYPEID=ts.SAMPTYPEID
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 t.TESTORDER
";
$query = $db->query($sql);
$results = $query->getResultArray();
// var_dump($results);die();
$data_urine = array_filter($results, function($item) {
$chapterid = $item["CHAPID"];
$tesscode = $item['TESTCODE'];
// Memfilter data dengan CHAPID 3, 61, atau 62
// Memfilter data dengan CHAPID 3, 61, atau 62
return $chapterid == 3 || $chapterid == 61 || $chapterid == 62 || $tesscode == 'NOTE';
});
@ -320,6 +362,7 @@ class PrintResult extends BaseController {
return $chapterid !== 3 && $chapterid !== 4 && $chapterid !== 61 && $chapterid !== 62 || $tesscode == 'NOTE';
});
$fullPage = "";
if ($data_urine != null && count($data_urine) > 1) {