FHM09062601IBL - move anamnesis visit info to php
This commit is contained in:
@@ -127,20 +127,63 @@ class Anamnesedoctor extends MY_Controller
|
|||||||
$rows[$k]['M_PatientAddress'] = $rows[$k]['M_PatientAddressDescription'];
|
$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'] = $this->build_patient_visit_info($v['M_PatientID'], $rows[$k]['M_PatientDOB']);
|
||||||
$rows[$k]['info'] = json_decode($info->info);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$result = array("total" => 1, "records" => $rows, "sql" => $this->db_onedev->last_query());
|
$result = array("total" => 1, "records" => $rows, "sql" => $this->db_onedev->last_query());
|
||||||
$this->sys_ok($result);
|
$this->sys_ok($result);
|
||||||
} else {
|
} else {
|
||||||
$this->sys_error_db("m_patient rows", $this->db_onedev);
|
$this->sys_error_db("m_patient rows", $this->db_onedev);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function build_patient_visit_info($patient_id, $patient_dob)
|
||||||
function get_data()
|
{
|
||||||
|
$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()
|
||||||
{
|
{
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
$this->sys_error("Invalid Token");
|
$this->sys_error("Invalid Token");
|
||||||
|
|||||||
Reference in New Issue
Block a user