FHM09062601IBL - move anamnesis visit info to php
This commit is contained in:
@@ -127,8 +127,7 @@ class Anamnesedoctor extends MY_Controller
|
||||
$rows[$k]['M_PatientAddress'] = $rows[$k]['M_PatientAddressDescription'];
|
||||
}
|
||||
|
||||
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row();
|
||||
$rows[$k]['info'] = json_decode($info->info);
|
||||
$rows[$k]['info'] = $this->build_patient_visit_info($v['M_PatientID'], $rows[$k]['M_PatientDOB']);
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => $rows, "sql" => $this->db_onedev->last_query());
|
||||
@@ -139,6 +138,50 @@ class Anamnesedoctor extends MY_Controller
|
||||
}
|
||||
}
|
||||
|
||||
protected function build_patient_visit_info($patient_id, $patient_dob)
|
||||
{
|
||||
$visit = 1;
|
||||
$birthday = 'N';
|
||||
|
||||
$visit_query = $this->db_onedev->query(
|
||||
"SELECT COUNT(DISTINCT T_OrderHeaderID) AS n
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
WHERE T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderM_PatientID = ?",
|
||||
[$patient_id]
|
||||
);
|
||||
|
||||
if ($visit_query) {
|
||||
$visit_row = $visit_query->row_array();
|
||||
$visit += (int) ($visit_row['n'] ?? 0);
|
||||
}
|
||||
|
||||
$init_visit_query = $this->db_onedev->query(
|
||||
"SELECT M_PatientInitialVisit
|
||||
FROM m_patient
|
||||
WHERE M_PatientID = ?",
|
||||
[$patient_id]
|
||||
);
|
||||
|
||||
if ($init_visit_query) {
|
||||
$init_visit_row = $init_visit_query->row_array();
|
||||
if (!empty($init_visit_row['M_PatientInitialVisit'])) {
|
||||
$visit += (int) $init_visit_row['M_PatientInitialVisit'];
|
||||
}
|
||||
}
|
||||
|
||||
$dob_time = empty($patient_dob) ? false : strtotime($patient_dob);
|
||||
if ($dob_time !== false) {
|
||||
$birthday = date('m-d', $dob_time) === date('m-d') ? 'Y' : 'N';
|
||||
}
|
||||
|
||||
return json_decode(json_encode([
|
||||
'visit' => $visit,
|
||||
'birthday' => $birthday,
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
function get_data()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user