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:
@@ -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;
|
||||
$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;
|
||||
}
|
||||
$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()
|
||||
{
|
||||
$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"
|
||||
);
|
||||
$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');
|
||||
$pdf = $this->ibl_patient_decrypt->fetch_birt_pdf($birt_url);
|
||||
|
||||
if ($pdf === false || $pdf === '') {
|
||||
$this->sys_error('Gagal generate report dari BIRT server');
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,14 +56,7 @@ 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);
|
||||
return array(true, $this->build_proxy_stream_url($report_code, $params));
|
||||
}
|
||||
else{
|
||||
$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())
|
||||
{
|
||||
$CI = &get_instance();
|
||||
|
||||
Reference in New Issue
Block a user