sys_input; $pid = $prm['pid']; $pid = ""; if (isset($prm['pid'])) { $pid = trim($prm["pid"]); } $username = "ADMIN"; if ($pid == "") { $this->sys_error_db("pid is mandatory"); exit; } $sql = "call sp_rpt_t_hasil_rspad(?, ?)"; $qry = $this->db->query($sql, array($pid, $username)); if (!$qry) { $this->sys_error_db("Erro call SP", $this->db->last_query()); exit; } $this->clean_mysqli_connection($this->db->conn_id); $rows = $qry->result_array(); $data = array( "no_reg" => $rows[0]["T_OrderHeaderLabNumber"], "nama" => $rows[0]["M_PatientName"], "pengirim" => $rows[0]["M_DoctorName"], "kel_pelanggan" => $rows[0]["M_CompanyName"], "alamat" => $rows[0]["M_PatientAddressDescription"], "tanggal_reg" => $rows[0]["T_OrderHeaderDate"], "pid" => $rows[0]["T_OrderHeaderLabNumber"], "jenis_kelamin" => $rows[0]["M_SexName"], "tgl_lahir" => $rows[0]["T_OrderHeaderM_PatientAge"], "no_tlp" => $rows[0]["M_PatientHP"], "hp" => $rows[0]["M_PatientPhone"], ); // $dtl = array(); // $rawGroup = array(); // foreach ($rows as $key => $val) { // $rawGroup[] = $val['Nat_SubGroupName']; // } // $rawSubGroup = array(); // foreach ($rows as $key => $val) { // $rawSubGroup[] = $val['Nat_SubgroupID']; // } // $grup = array_unique($rawGroup); $details = array(); foreach ($rows as $key => $val) { $rawResult = $val['T_OrderDetailResult']; $result = str_replace("
", '', $rawResult); $result = str_replace(".", '', $result); $result = str_replace(",", '.', $result); $result = str_replace("*", '', $result); $result = trim($result); $maxResult = $val['T_OrderDetailMaxValue']; $minResult = $val['T_OrderDetailMinValue']; $minInclusive = $val['T_OrderDetailMinValueInclusive']; $maxInclusive = $val['T_OrderDetailMinValueInclusive']; $interpretation = ""; $operatorMin = "<"; if ($minInclusive == "Y") { $operatorMin = "<="; } $operatorMax = "<"; if ($maxInclusive == "Y") { $operatorMax = "<="; } $rule = "{$minResult} {$operatorMin} X {$operatorMax} {$maxResult}"; if (is_numeric($result)) { if ($minInclusive == "Y" && $maxInclusive == "N") { if ($result < $minResult) { $interpretation = "low"; } else if ($result >= $minResult && $result < $maxResult) { $interpretation = "normal"; } else if ($result >= $maxResult) { $interpretation = "high"; } } if ($minInclusive == "N" && $maxInclusive == "Y") { if ($result <= $minResult) { $interpretation = "low"; } else if ($result > $minResult && $result <= $maxResult) { $interpretation = "normal"; } else if ($result > $maxResult) { $interpretation = "high"; } } if ($minInclusive == "Y" && $maxInclusive == "Y") { if ($result < $minResult) { $interpretation = "low"; } else if ($result >= $minResult && $result <= $maxResult) { $interpretation = "normal"; } else if ($result > $maxResult) { $interpretation = "high"; } } } $dtl = array( "jenis_pemeriksaan" => $val["T_TestNameAA"], "hasil" => $val["T_OrderDetailResult"], "nilai_rujukan" => $val["T_OrderDetailNormalValueNote"], "satuan" => $val["Nat_UnitName"], "metode" => $val["T_OrderdetailNat_MethodeName"], "interpretation" => $interpretation, // "rule" => $rule, // "is_numeric" => is_numeric($result), // "minInclusive" => $val['T_OrderDetailMinValueInclusive'], // "maxInclusive" => $val['T_OrderDetailMinValueInclusive'], // "rslt" => $result ); $details[] = $dtl; } $data['details'] = $details; $result = array( "records" => $data, ); $this->sys_ok($result); } catch (Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } }