FHM08062601IBL - ganti pre_cache/delete_cache dengan proxy stream pattern: Reporturl semua kode lewat stream_by_code, tambah stream_report di Rv_patient untuk resultprintadm-v7

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sas.fajri
2026-06-08 16:34:40 +07:00
parent edf60f5574
commit 7e3cd75ce5
2 changed files with 28 additions and 35 deletions

View File

@@ -1069,34 +1069,39 @@ private function get_fallback_report($group_name, $type, $ready_print)
exit;
}
public function pre_cache()
public function stream_report()
{
$prm = $this->sys_input;
$order_id = intval($prm['order_id'] ?? 0);
if ($order_id <= 0) {
$this->sys_ok(['cached' => false]);
$rptname = preg_replace('/[^a-zA-Z0-9_\-]/', '', $prm['rptname'] ?? '');
$folder = preg_replace('/[^a-zA-Z0-9_\-]/', '', $prm['folder'] ?? 'lab');
$atr = ($prm['atr_print'] ?? 'frameset') === 'run' ? 'run' : 'frameset';
if ($order_id <= 0 || $rptname === '') {
$this->sys_error('order_id dan rptname wajib diisi');
return;
}
$user = $this->sys_user['M_StaffName'] ?? $this->sys_user['M_UserUsername'] ?? 'system';
$tm = round(microtime(true) * 1000);
$birt_url = '/birt/' . $atr . '?__report=report/onelab/' . $folder . '/' . $rptname
. '.rptdesign&__format=pdf&username=' . rawurlencode("'" . $user . "'")
. '&PID=' . $order_id . '&tm=' . $tm;
$this->load->library('ibl_patient_decrypt');
$this->ibl_patient_decrypt->populate_cache_by_order($order_id);
$this->sys_ok(['cached' => true]);
$pdf = $this->ibl_patient_decrypt->fetch_birt_pdf($birt_url);
if ($pdf === false || $pdf === '') {
$this->sys_error('Gagal generate report dari BIRT server');
return;
}
public function delete_cache()
{
$prm = $this->sys_input;
$order_id = intval($prm['order_id'] ?? 0);
if ($order_id > 0) {
$this->db_smartone->query(
"DELETE FROM patient_print_cache WHERE ppc_order_id = ? OR ppc_created < NOW() - INTERVAL 5 MINUTE",
[$order_id]
);
} else {
$this->db_smartone->query(
"DELETE FROM patient_print_cache WHERE ppc_created < NOW() - INTERVAL 5 MINUTE"
);
}
$this->sys_ok(['deleted' => true]);
$filename = $rptname . '_' . $order_id . '_' . date('Ymd') . '.pdf';
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Length: ' . strlen($pdf));
echo $pdf;
exit;
}
}

View File

@@ -56,15 +56,8 @@ class Reporturl
}
if($show == 'N'){
if ($this->should_use_proxy_stream($report_code)) {
return array(true, $this->build_proxy_stream_url($report_code, $params));
}
// Populate decrypt cache sebelum return URL raw ke browser
$CI->load->library('ibl_patient_decrypt');
$CI->ibl_patient_decrypt->pre_cache_and_get_url($final_url);
return array(true, $final_url);
}
else{
$CI->load->library('ibl_patient_decrypt');
$pdf = $CI->ibl_patient_decrypt->fetch_birt_pdf($final_url);
@@ -74,11 +67,6 @@ class Reporturl
}
}
private function should_use_proxy_stream($report_code)
{
return strpos((string)$report_code, 'FO-') === 0;
}
private function build_proxy_stream_url($report_code, $params = array())
{
$CI = &get_instance();