Add native CodeIgniter 4 report generation functionality replacing legacy spooler_db system. Provides centralized report generation with audit logging and multi-language support. New Features: - Report generation with Indonesian and English language support - Role-based access control (Lab, Admin, Superuser: generate; CS: print only) - Preview mode for validation workflow - Print audit logging to AUDIT_REQUESTS table - Multi-page report support with proper pagination - Dual unit system (Conventional and International units) Controllers: - ReportController: Main controller for report generation, preview, and print - generate(): Full report with audit logging - preview(): Preview mode without audit logging - print(): Print-only access for CS role - Home::printReport(): Route handler redirecting based on user role Libraries: - ReportHelper: Comprehensive report data retrieval - Patient information (name, MR number, demographics, referral) - Test results with reference ranges and unit conversions - Collection and reception data with timestamps - Validation status and validator information - Special handling for pending samples and Chinese translations Routes: - /report/(:num) - Generate report (Lab, Admin, Superuser) - /report/(:num)/preview - Preview without audit logging - /report/(:num)/eng - English language report - /report/print/(:num) - Print-only access (CS role) - /print/(:num) - Redirect based on role (all roles) Views: - report/template.php: Professional lab report template with Gleneagles branding - Header and footer images - Patient information table - Test results with dual unit columns - Collection and reception timestamps - Authorization signature area - Preview watermark Role Index Views: - Removed dialog_preview.php inclusion from all role dashboards - Consolidated print button directly linking to new report routes Assets: - Report-specific CSS files (normalize.min.css, style.css, pdf.css, style_qr.css) - Gleneagles header and footer images - Legacy spooler_db files preserved in public/spooler_db/ for reference Tests: - ReportTest.php: Unit tests for report generation functionality Database: - Uses existing tables: REQUESTS, TESTS, DICT_TESTS, SP_REQUESTS, PATIENTS - Inserts print audit records into AUDIT_REQUESTS table Security: - Parameterized queries throughout (SQL injection prevention) - Role-based access control enforced at route level - Proper output escaping with esc() in views
205 lines
6.0 KiB
PHP
205 lines
6.0 KiB
PHP
<?php
|
|
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
|
|
if(isset($_GET['reqnum'])) { $ACCESSNUMBER = $_GET['reqnum']; }
|
|
|
|
include("config.php");
|
|
include("_function.php");
|
|
|
|
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
|
|
$result = getResult($conn, $ACCESSNUMBER,$eng);
|
|
$info = getData2($conn,$ACCESSNUMBER);
|
|
$notes = getNotes($conn, $ACCESSNUMBER);
|
|
$others = getOthers($conn,$ACCESSNUMBER, $eng);
|
|
$collData = getCollData($conn, $ACCESSNUMBER);
|
|
$recvData = getRecvData($conn, $ACCESSNUMBER);
|
|
$noSample = getNoSample($conn,$ACCESSNUMBER);
|
|
if( $noSample == '' ) {
|
|
$status = getStatus($conn, $ACCESSNUMBER);
|
|
} else {
|
|
$status = "PENDING";
|
|
}
|
|
$userid = $_GET['userid'];
|
|
$val1 = getVal1($conn, $ACCESSNUMBER);
|
|
$valBy = $val1['valBy'];
|
|
$valDate = date_format($val1['valDate'], 'd-m-Y H:i');
|
|
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
|
|
else { $date = $_GET['date']; }
|
|
|
|
$npage = count($result);
|
|
$i=1;
|
|
$raw ='';
|
|
$pdf ='';
|
|
$tmp = "<head>
|
|
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
|
<link rel='stylesheet' href='assets/normalize.min.css' />";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
|
|
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
|
|
$tmp = "</head>
|
|
<body style='-webkit-print-color-adjust:exact;'>";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
|
|
|
|
if($eng==1) { $othertitle = "Non Laboratory Test"; }
|
|
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
|
|
$countpage = substr_count($result[$npage],"\r");
|
|
$countothers = substr_count("$others","\r");
|
|
$countline = $countpage + $countothers;
|
|
$pageadd = 0;
|
|
if($countline > 37) {
|
|
$npage += 1;
|
|
$pageadd = 1;
|
|
}
|
|
|
|
foreach($result as $page) {
|
|
$tmp .= "<div id='page'>
|
|
<div id='pagetop' style='height:0.01cm'> </div>";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
|
|
$tmp .= "<div id='dinfo'>
|
|
$info
|
|
</div>
|
|
<div id='dresult'>
|
|
<table class='result'>
|
|
<colgroup>
|
|
<col style='width:26%;'></col>
|
|
<col style='width:10%;'></col>
|
|
<col style='width:15%;'></col>
|
|
<col style='width:12%;'></col>
|
|
<col style='width:10%;'></col>
|
|
<col style='width:15%;'></col>
|
|
<col style='width:12%;'></col>
|
|
</colgroup>
|
|
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
|
|
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
|
|
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
|
|
$page
|
|
";
|
|
// lastpage show nosample, others and note
|
|
if($pageadd !=1) {
|
|
if( $i != $npage ) {
|
|
$tmp .="</table>";
|
|
} else {
|
|
$tmp .= "$noSample </table>";
|
|
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
|
|
</table> <br/>\r\n";
|
|
|
|
if($others != '' && $countline < 38) {
|
|
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
|
|
$tmp .= "$others</td></tr></table>";
|
|
$others = '';
|
|
}
|
|
}
|
|
} else { // page tambahan = 1
|
|
if( $i != $npage-1 ) {
|
|
$tmp .="</table>";
|
|
} else {
|
|
$tmp .= "$noSample </table>";
|
|
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
|
|
</table> <br/>\r\n";
|
|
}
|
|
}
|
|
$tmp .= "</div>";
|
|
|
|
$tmp .= "<div id='footer'>
|
|
<table class='footer'>
|
|
<tr> <td>";
|
|
if($i == $npage) { $tmp .= "Status : $status"; }
|
|
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
|
|
Page $i/$npage Val1 : $valBy $valDate | Val2 : $userid $date</td>";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
|
|
$tmp .="
|
|
<td class='right'><pre>
|
|
|
|
(__________________)
|
|
Authorised Signature
|
|
</pre></td>";
|
|
$raw .= $tmp; $tmp = '';
|
|
$pdf .= "<td class='right'><pre><b>”This result is valid without signature.”</b></pre></td>";
|
|
|
|
$tmp .="
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
|
|
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
|
|
$tmp .= "</div>";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
$i+=1;
|
|
}
|
|
|
|
if($others != '') {
|
|
$tmp .= "
|
|
<div id='page'>
|
|
<div id='pagetop' style='height:0.01cm'> </div>";
|
|
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
|
|
$tmp .= "<div id='dinfo'>
|
|
$info
|
|
</div>
|
|
<div id='dresult'>
|
|
<table class='others' style='width:15cm'>
|
|
<tr><td><b>$othertitle : </b><br/>\r\n
|
|
$others</td></tr></table>
|
|
</div>
|
|
";
|
|
$tmp .= "<div id='footer'>
|
|
<table class='footer'>
|
|
<tr> <td>";
|
|
if($i == $npage) { $tmp .= "Status : $status"; }
|
|
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData \r\n".
|
|
"Page $i/$npage Val1 : $valBy $valDate | Val2 : $userid $date</pre> </td>";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
|
|
$tmp .="
|
|
<td class='right'><pre>
|
|
|
|
(__________________)
|
|
Authorised Signature
|
|
</pre></td>";
|
|
$raw .= $tmp; $tmp = '';
|
|
|
|
$pdf .= "<td class='right'><pre><b>”This result is valid without signature.”</b></pre></td>";
|
|
|
|
$tmp .="
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
|
|
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
|
|
$tmp .= "</div>";
|
|
}
|
|
|
|
$tmp .="</body>";
|
|
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
|
|
echo $pdf;
|
|
|
|
if(isset($_POST['print'])) {
|
|
//pdf
|
|
$file = fopen("C:/inetpub/wwwroot/spooler_db/val2/$HOSTNUMBER.html","w+");
|
|
fwrite($file, $pdf);
|
|
fclose($file);
|
|
/*
|
|
$folder = date('Ym');
|
|
$date = date('YmdHi');
|
|
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
|
|
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
|
|
$dirname = dirname($filename);
|
|
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
|
|
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
|
|
fwrite($file, $pdf);
|
|
fclose($file);
|
|
//oru
|
|
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
|
|
$date = date('Y-m-d H:i');
|
|
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status");
|
|
fclose($file);
|
|
*/
|
|
}
|
|
?>
|