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; exit;
} }
public function pre_cache() public function stream_report()
{ {
$prm = $this->sys_input; $prm = $this->sys_input;
$order_id = intval($prm['order_id'] ?? 0); $order_id = intval($prm['order_id'] ?? 0);
if ($order_id <= 0) { $rptname = preg_replace('/[^a-zA-Z0-9_\-]/', '', $prm['rptname'] ?? '');
$this->sys_ok(['cached' => false]); $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; return;
} }
$this->load->library('ibl_patient_decrypt');
$this->ibl_patient_decrypt->populate_cache_by_order($order_id);
$this->sys_ok(['cached' => true]);
}
public function delete_cache() $user = $this->sys_user['M_StaffName'] ?? $this->sys_user['M_UserUsername'] ?? 'system';
{ $tm = round(microtime(true) * 1000);
$prm = $this->sys_input; $birt_url = '/birt/' . $atr . '?__report=report/onelab/' . $folder . '/' . $rptname
$order_id = intval($prm['order_id'] ?? 0); . '.rptdesign&__format=pdf&username=' . rawurlencode("'" . $user . "'")
if ($order_id > 0) { . '&PID=' . $order_id . '&tm=' . $tm;
$this->db_smartone->query(
"DELETE FROM patient_print_cache WHERE ppc_order_id = ? OR ppc_created < NOW() - INTERVAL 5 MINUTE", $this->load->library('ibl_patient_decrypt');
[$order_id] $pdf = $this->ibl_patient_decrypt->fetch_birt_pdf($birt_url);
);
} else { if ($pdf === false || $pdf === '') {
$this->db_smartone->query( $this->sys_error('Gagal generate report dari BIRT server');
"DELETE FROM patient_print_cache WHERE ppc_created < NOW() - INTERVAL 5 MINUTE" return;
);
} }
$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,14 +56,7 @@ class Reporturl
} }
if($show == 'N'){ if($show == 'N'){
if ($this->should_use_proxy_stream($report_code)) { return array(true, $this->build_proxy_stream_url($report_code, $params));
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{ else{
$CI->load->library('ibl_patient_decrypt'); $CI->load->library('ibl_patient_decrypt');
@@ -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()) private function build_proxy_stream_url($report_code, $params = array())
{ {
$CI = &get_instance(); $CI = &get_instance();