Compare commits

...

4 Commits

2 changed files with 84 additions and 80 deletions

View File

@@ -440,59 +440,63 @@ class Rv_patient extends MY_Controller
foreach ($rows['groups'] as $k => $v) {
$ready_print = $v['ready_print'];
$gn = $v['group_name'];
// MAPPING GROUP NAME KE REPORT CODE
$report_codes = $this->get_report_codes_by_group($gn);
if ($report_codes) {
// Gunakan database untuk ambil report name
$rpt = $this->get_report_name_from_db($report_codes['P'], $ready_print);
$e_rpt = $this->get_report_name_from_db($report_codes['E'], $ready_print);
$rptqrcode = isset($report_codes['Q']) ? $this->get_report_name_from_db($report_codes['Q'], $ready_print) : '';
// Jika QR tidak ada, gunakan P
if (empty($rptqrcode)) {
$rptqrcode = $rpt;
}
$rpt_code = $ready_print == 'Y' ? $report_codes['P'] : ($report_codes['NP'] ?? $report_codes['P']);
$e_rpt_code = $ready_print == 'Y' ? ($report_codes['E'] ?? $report_codes['P']) : ($report_codes['NE'] ?? $report_codes['NP'] ?? $report_codes['E'] ?? $report_codes['P']);
$rptq_code = $ready_print == 'Y' ? ($report_codes['Q'] ?? $report_codes['P']) : ($report_codes['NQ'] ?? $report_codes['NP'] ?? $report_codes['P']);
$rpt = $this->get_report_name_from_code($rpt_code);
$e_rpt = $this->get_report_name_from_code($e_rpt_code);
$rptqrcode = $this->get_report_name_from_code($rptq_code);
if (empty($rptqrcode)) $rptqrcode = $rpt;
} else {
// FALLBACK untuk group yang belum ada di database
$rpt = $this->get_fallback_report($gn, 'P', $ready_print);
$e_rpt = $this->get_fallback_report($gn, 'E', $ready_print);
$rpt_code = $e_rpt_code = '';
$rpt = $this->get_fallback_report($gn, 'P', $ready_print);
$e_rpt = $this->get_fallback_report($gn, 'E', $ready_print);
$rptqrcode = $this->get_fallback_report($gn, 'Q', $ready_print);
if (empty($rptqrcode)) $rptqrcode = $rpt;
}
// LOGIC KHUSUS MIKRO
if ($gn == 'Mikro') {
$sql = "SELECT T_OrderDetailResult as result
FROM t_orderdetail
$sql = "SELECT T_OrderDetailResult as result
FROM t_orderdetail
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_OrderDetailT_TestID AND Group_ResultDetailIsActive = 'Y'
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N' AND
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N' AND
Group_ResultName = 'Mikro'
WHERE T_OrderDetailID = {$v['id']} AND T_OrderDetailIsActive = 'Y' LIMIT 1";
$xresult = $this->db_smartone->query($sql)->row()->result;
if ($xresult != 'Terlampir') {
$rpt = $this->get_report_name_from_db('LAB-RESULT-P-01', $ready_print);
$e_rpt = $this->get_report_name_from_db('LAB-RESULT-E-01', $ready_print);
$rpt_code = $ready_print == 'Y' ? 'LAB-RESULT-P-01' : 'LAB-RESULT-NP-01';
$e_rpt_code = $ready_print == 'Y' ? 'LAB-RESULT-P-02' : 'LAB-RESULT-NP-02';
$rpt = $this->get_report_name_from_code($rpt_code);
$e_rpt = $this->get_report_name_from_code($e_rpt_code);
}
if ($xresult == 'Terlampir' && $exist_lab == 'N') {
$rows['groups'][$k]['group_name'] = 'Lampiran Mikro';
$new_group = $rows['groups'][$k];
$new_group['group_name'] = 'Mikro';
$new_group['rpt'] = $this->get_report_name_from_db('LAB-RESULT-P-01', 'Y');
$new_group['e_rpt'] = $this->get_report_name_from_db('LAB-RESULT-E-01', 'Y');
$new_group['rptqrcode'] = $new_group['rpt'];
$new_group['rpt_code'] = 'LAB-RESULT-P-01';
$new_group['e_rpt_code'] = 'LAB-RESULT-P-02';
$new_group['rpt'] = $this->get_report_name_from_code('LAB-RESULT-P-01');
$new_group['e_rpt'] = $this->get_report_name_from_code('LAB-RESULT-P-02');
$new_group['rptqrcode'] = $new_group['rpt'];
array_push($rows['groups'], $new_group);
}
}
$rows['groups'][$k]['rpt'] = $rpt;
$rows['groups'][$k]['e_rpt'] = $e_rpt;
$rows['groups'][$k]['rptqrcode'] = $rptqrcode;
$rows['groups'][$k]['rpt'] = $rpt;
$rows['groups'][$k]['e_rpt'] = $e_rpt;
$rows['groups'][$k]['rptqrcode'] = $rptqrcode;
$rows['groups'][$k]['rpt_code'] = $rpt_code;
$rows['groups'][$k]['e_rpt_code'] = $e_rpt_code;
}
$rows['groups'][0]['selected'] = 'Y';
@@ -529,43 +533,55 @@ class Rv_patient extends MY_Controller
}
private function get_report_codes_by_group($group_name)
{
$mapping = [
'LAB' => ['P' => 'LAB-RESULT-P-01', 'E' => 'LAB-RESULT-E-01', 'Q' => 'LAB-RESULT-Q-01'],
'LAB_EN' => ['P' => 'LAB-RESULT-EN-P-01', 'E' => 'LAB-RESULT-EN-E-01'],
'Mikro_EN' => ['P' => 'LAB-RESULT-EN-P-01', 'E' => 'LAB-RESULT-EN-E-01'],
'FNA' => ['P' => 'FNA-P-01', 'E' => 'FNA-E-01'],
'Patologi Anatomi' => ['P' => 'PA-P-01', 'E' => 'PA-E-01'],
'Papsmear' => ['P' => 'PAP-P-01', 'E' => 'PAP-E-01'],
'Pap Smear (Liquid C Prep)' => ['P' => 'LCP-P-01', 'E' => 'LCP-E-01', 'Q' => 'LCP-Q-01'],
'Pap Smear (Liquid C Prep)_EN' => ['P' => 'LCP-P-01', 'E' => 'LCP-E-01', 'Q' => 'LCP-Q-01'],
'Papsmear_EN' => ['P' => 'LCP-P-01', 'E' => 'LCP-E-01', 'Q' => 'LCP-Q-01']
];
return isset($mapping[$group_name]) ? $mapping[$group_name] : null;
}
{
// P = siap cetak, NP = belum siap cetak, E = email siap, NE = email belum siap
$mapping = [
'LAB' => ['P' => 'LAB-RESULT-P-01', 'NP' => 'LAB-RESULT-NP-01', 'E' => 'LAB-RESULT-P-02', 'NE' => 'LAB-RESULT-NP-02'],
'LAB_EN' => ['P' => 'LABEN-RESULT-P-01', 'NP' => 'LABEN-RESULT-NP-01', 'E' => 'LABEN-RESULT-P-02'],
'Mikro' => ['P' => 'MIKRO-RESULT-P-01', 'NP' => 'MIKRO-RESULT-NP-01', 'E' => 'MIKRO-RESULT-P-02'],
'Mikro_EN' => ['P' => 'MIKROEN-RESULT-P-01', 'NP' => 'MIKROEN-RESULT-NP-01', 'E' => 'MIKROEN-RESULT-P-02'],
'FNA' => ['P' => 'FNA-RESULT-P-01', 'NP' => 'FNA-RESULT-NP-01', 'E' => 'FNA-RESULT-P-02'],
'Patologi Anatomi' => ['P' => 'PA-RESULT-P-01', 'NP' => 'PA-RESULT-NP-01', 'E' => 'PA-RESULT-P-02'],
'Papsmear' => ['P' => 'PAP-RESULT-P-01', 'NP' => 'PAP-RESULT-NP-01', 'E' => 'PAP-RESULT-P-02'],
'Pap Smear (Liquid C Prep)' => ['P' => 'PAPLCP-RESULT-P-01', 'NP' => 'PAPLCP-RESULT-NP-01', 'E' => 'PAPLCP-RESULT-P-02'],
'Pap Smear (Liquid C Prep)_EN' => ['P' => 'PAPLEN-RESULT-P-01', 'NP' => 'PAPLEN-RESULT-NP-01', 'E' => 'PAPLEN-RESULT-P-02'],
'Papsmear_EN' => ['P' => 'PAPLEN-RESULT-P-01', 'NP' => 'PAPLEN-RESULT-NP-01', 'E' => 'PAPLEN-RESULT-P-02'],
'Preparasi Sperma' => ['P' => 'PS-RESULT-P-01', 'NP' => 'PS-RESULT-NP-01', 'E' => 'PS-RESULT-P-02'],
'dfi' => ['P' => 'DFI-RESULT-P-01', 'NP' => 'DFI-RESULT-NP-01', 'E' => 'DFI-RESULT-P-02'],
'DFI' => ['P' => 'DFI-RESULT-P-01', 'NP' => 'DFI-RESULT-NP-01', 'E' => 'DFI-RESULT-P-02'],
'Cytologi' => ['P' => 'CT-RESULT-P-01', 'NP' => 'CT-RESULT-NP-01', 'E' => 'CT-RESULT-P-02'],
];
private function get_report_name_from_db($report_code, $ready_print = 'Y')
{
if (empty($report_code)) return '';
$sql = "SELECT Print_TransactionUrl FROM print_transaction WHERE Print_TransactionCode = ? LIMIT 1";
$row = $this->db_smartone->query($sql, [$report_code])->row();
if (!$row) return '';
// Extract report name from URL
$url = $row->Print_TransactionUrl;
preg_match('/\/([^\/]+)\.rptdesign/', $url, $matches);
$report_name = isset($matches[1]) ? $matches[1] : '';
// Tambahkan suffix jika belum ready print
if ($ready_print != 'Y' && !empty($report_name)) {
$report_name .= '_not_print';
}
return $report_name;
}
return $mapping[$group_name] ?? null;
}
private function get_report_name_from_code($report_code)
{
if (empty($report_code)) return '';
$row = $this->db_smartone->query(
"SELECT Print_TransactionUrl FROM print_transaction WHERE Print_TransactionCode = ? LIMIT 1",
[$report_code]
)->row();
if (!$row) return '';
preg_match('/\/([^\/]+)\.rptdesign/', $row->Print_TransactionUrl, $matches);
return $matches[1] ?? '';
}
private function get_report_name_from_db($report_code, $ready_print = 'Y')
{
if (empty($report_code)) return '';
$row = $this->db_smartone->query(
"SELECT Print_TransactionUrl FROM print_transaction WHERE Print_TransactionCode = ? LIMIT 1",
[$report_code]
)->row();
if (!$row) return '';
preg_match('/\/([^\/]+)\.rptdesign/', $row->Print_TransactionUrl, $matches);
$report_name = $matches[1] ?? '';
if ($ready_print != 'Y' && !empty($report_name)) {
$report_name .= '_not_print';
}
return $report_name;
}
private function get_fallback_report($group_name, $type, $ready_print)
{

View File

@@ -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();