FHM09062601IBL - move patient visit info to php
This commit is contained in:
@@ -979,20 +979,58 @@ class Registrationv3 extends MY_Controller
|
||||
}
|
||||
unset($rows[$k]['M_PatientNameRaw']);
|
||||
|
||||
$info_query = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']]);
|
||||
if ($info_query) {
|
||||
$info = $info_query->row();
|
||||
$rows[$k]['info'] = ($info && isset($info->info)) ? json_decode($info->info) : null;
|
||||
} else {
|
||||
$rows[$k]['info'] = null;
|
||||
$rows[$k]['info'] = $this->build_patient_visit_info($v['M_PatientID'], $dob_dec);
|
||||
}
|
||||
|
||||
$this->sys_ok(["total" => 0, "records" => $rows]);
|
||||
}
|
||||
|
||||
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'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_ok(["total" => 0, "records" => $rows]);
|
||||
}
|
||||
|
||||
function calculateAge($tanggal_lahir)
|
||||
{
|
||||
|
||||
$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 calculateAge($tanggal_lahir)
|
||||
{
|
||||
// Ambil tanggal sekarang
|
||||
$tanggal_sekarang = new DateTime();
|
||||
|
||||
|
||||
@@ -92,8 +92,7 @@ class Screening extends MY_Controller
|
||||
}
|
||||
unset($rows[$k]['M_PatientNameRaw']);
|
||||
|
||||
$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']);
|
||||
|
||||
// Screening template berdasarkan poli order
|
||||
$cu_id = $v['orderM_ClinicUnitID'] ?? null;
|
||||
@@ -168,11 +167,55 @@ class Screening extends MY_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_ok(["total" => count($rows), "records" => $rows]);
|
||||
}
|
||||
|
||||
|
||||
function get_data(){
|
||||
$this->sys_ok(["total" => count($rows), "records" => $rows]);
|
||||
}
|
||||
|
||||
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(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
|
||||
@@ -55,17 +55,61 @@ class Order extends MY_Controller
|
||||
return $rst;
|
||||
}
|
||||
|
||||
function convert_to_normal_text($text)
|
||||
{
|
||||
function convert_to_normal_text($text)
|
||||
{
|
||||
|
||||
$normal_characters = "a-zA-Z0-9\s`~!@#$%^&*()_+-={}|:;<>?,.\/\"\'\\\[\]";
|
||||
$normal_text = preg_replace("/[^$normal_characters]/", '', $text);
|
||||
|
||||
return $normal_text;
|
||||
}
|
||||
|
||||
function genqrcode($nomorlab, $id)
|
||||
{
|
||||
return $normal_text;
|
||||
}
|
||||
|
||||
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 genqrcode($nomorlab, $id)
|
||||
{
|
||||
$this->load->library('ciqrcode'); //pemanggilan library QR CODE
|
||||
$home_dir = "/home/one/project/one/";
|
||||
$target_dir = $home_dir . "one-media/one-qrcontrolcard/";
|
||||
@@ -4017,8 +4061,7 @@ GROUP BY T_SampleStationID ";
|
||||
$patient = $query->row_array();
|
||||
$patient['M_PatientName'] = stripslashes($patient['M_PatientName']);
|
||||
$patient['M_PatientAddress'] = stripslashes($patient['full_address']);
|
||||
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$patient['M_PatientID']])->row();
|
||||
$patient['info'] = json_decode($info->info);
|
||||
$patient['info'] = $this->build_patient_visit_info($patient['M_PatientID'], $patient['M_PatientDOB']);
|
||||
$rst['patient'] = $patient;
|
||||
|
||||
}
|
||||
@@ -4770,8 +4813,7 @@ GROUP BY T_SampleStationID ";
|
||||
}
|
||||
}
|
||||
|
||||
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$patient_row['M_PatientID']])->row();
|
||||
$patient_row['info'] = $info ? json_decode($info->info) : null;
|
||||
$patient_row['info'] = $this->build_patient_visit_info($patient_row['M_PatientID'], $patient_row['M_PatientDOB']);
|
||||
|
||||
// Hapus kolom enc sebelum return
|
||||
foreach (['M_PatientName_enc','M_PatientName_bidx','M_PatientHP_enc','M_PatientHP_bidx',
|
||||
|
||||
@@ -234,8 +234,7 @@ class Patient extends MY_Controller
|
||||
}
|
||||
unset($rows[$k]['M_PatientNameRaw'], $rows[$k]['M_PatientDOB']);
|
||||
|
||||
$info = $this->db_smartone->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'], $dob_dec);
|
||||
|
||||
$ref_query = $this->db_smartone->query(
|
||||
"SELECT M_ReferenceID, M_ReferenceName
|
||||
@@ -250,6 +249,50 @@ class Patient extends MY_Controller
|
||||
$this->sys_ok(["total" => 0, "records" => $rows]);
|
||||
}
|
||||
|
||||
protected function build_patient_visit_info($patient_id, $patient_dob)
|
||||
{
|
||||
$visit = 1;
|
||||
$birthday = 'N';
|
||||
|
||||
$visit_query = $this->db_smartone->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_smartone->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 add_new()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user