88 lines
2.6 KiB
PHP
88 lines
2.6 KiB
PHP
<?php
|
|
class Newpatient extends MY_Controller{
|
|
var $db;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->library('Satusehat');
|
|
}
|
|
|
|
function index()
|
|
{
|
|
echo "Satu Sehat New Patient";
|
|
}
|
|
|
|
function getnewpatient() {
|
|
|
|
try{
|
|
$prm = $this->sys_input;
|
|
$orderheaderID = $prm['orderheaderID'];
|
|
|
|
// get organization
|
|
$sql = "SELECT organizationID
|
|
FROM one_health.organization
|
|
WHERE organizationIsActive = 'Y'";
|
|
|
|
$qry = $this->db->query($sql, []);
|
|
$last_qry = $this->db->last_query();
|
|
|
|
if (!$qry) {
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
|
|
$organizationID = $qry->result_array()[0]['organizationID'];
|
|
|
|
$sql_data_nik = "SELECT M_PatientIDNumber
|
|
FROM m_patient
|
|
WHERE M_PatientM_IdTypeID = '1'";
|
|
|
|
$qry = $this->db->last_query($sql_data_nik, []);
|
|
$last_qry = $this->db->last_query();
|
|
|
|
if (!$qry) {
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
|
|
$sql_data_new_patient = "SELECT
|
|
(SELECT M_PatientIDNumber WHERE M_PatientM_IdTypeID = 1) As NIK,
|
|
(SELECT M_PatientIDNumber WHERE M_PatientM_IdTypeID = 3) As PASPORT,
|
|
M_PatientName,
|
|
M_PatientHP,
|
|
M_PatientEmail,
|
|
CASE
|
|
WHEN M_PatientM_SexID= '1' THEN 'male'
|
|
WHEN M_PatientM_SexID= '2' THEN 'female'
|
|
END AS M_SexCode,
|
|
M_PatientDOB,
|
|
M_PatientAddressDescription,
|
|
OHPatientMapMaritalStatusCode,
|
|
OHPatientMapCitizeship
|
|
from t_orderheader
|
|
JOIN m_patient
|
|
ON M_PatientID = T_OrderHeaderM_PatientID
|
|
AND M_PatientIsActive = 'Y'
|
|
JOIN m_patientaddress
|
|
ON M_PatientAddressM_PatientID= M_PatientID
|
|
AND M_PatientAddressIsActive= 'Y'
|
|
LEFT JOIN one_health.oh_patient_map
|
|
ON OHPatientMapM_PatientID = M_PatientID
|
|
AND OHPatientMapIsActive
|
|
Group by NIK, PASPORT
|
|
Limit 40;
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
?>
|