diff --git a/application/controllers/tools/Birt_proxy.php b/application/controllers/tools/Birt_proxy.php index ee478c70..6bf847ae 100644 --- a/application/controllers/tools/Birt_proxy.php +++ b/application/controllers/tools/Birt_proxy.php @@ -188,6 +188,16 @@ class Birt_proxy extends MY_Controller $username = $prm['PUsername'] ?? ($this->sys_user['userName'] ?? 'system'); $tm = round(microtime(true) * 1000); + $internal_url = $this->_build_internal_report_url_by_code($report_code, $order_id); + if ($internal_url !== false) { + if ($order_id > 0) { + $this->_populate_cache($order_id); + } + + $this->sys_ok(['url' => $internal_url]); + return; + } + $row = $this->db_onedev->query( "SELECT Print_TransactionUrl FROM print_transaction WHERE Print_TransactionCode = ? LIMIT 1", [$report_code] @@ -400,6 +410,11 @@ class Birt_proxy extends MY_Controller private function _build_birt_url_by_code($report_code, $order_id, $payment_id, $patient_name) { + $internal_url = $this->_build_internal_report_url_by_code($report_code, $order_id); + if ($internal_url !== false) { + return $internal_url; + } + $row = $this->db_onedev->query( "SELECT Print_TransactionUrl FROM print_transaction @@ -438,6 +453,28 @@ class Birt_proxy extends MY_Controller return $url; } + private function _build_internal_report_url_by_code($report_code, $order_id) + { + $report_routes = [ + 'LAB-RESULT-P-01' => '/tools/rpt_lab_result/pdf', + ]; + + if (!isset($report_routes[$report_code]) || $order_id <= 0) { + return false; + } + + $params = [ + 'PT_OrderHeaderID' => $order_id, + 'username' => $this->_resolve_report_username(), + ]; + + if (!empty($this->sys_input['token'])) { + $params['token'] = $this->sys_input['token']; + } + + return $report_routes[$report_code] . '?' . http_build_query($params); + } + private function _apply_report_template_hotfix($report_code, $url_template) { $print_report_hotfix = [