1799 lines
57 KiB
PHP
1799 lines
57 KiB
PHP
<?php
|
|
class Anamnese extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Patient API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
$this->db_oneklinik = $this->load->database("onedev", true);
|
|
}
|
|
|
|
function search_x()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$norm = $prm["snorm"];
|
|
$nama = str_replace("'", "\\'", $prm["name"]);
|
|
|
|
// echo $norm;
|
|
|
|
$sql_where = "WHERE M_PatientIsActive = 'Y' ";
|
|
$sql_param = array();
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " M_PatientName like ? ";
|
|
$sql_param[] = "%$nama%";
|
|
}
|
|
if ($norm != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " M_PatientNoReg like ? ";
|
|
$sql_param[] = "%$norm%";
|
|
}
|
|
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 100';
|
|
}
|
|
$number_limit = 100;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
|
|
|
|
$sql = "SELECT
|
|
M_PatientID,
|
|
M_PatientNoReg,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientHP,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientPhone,
|
|
M_PatientIDNumber,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientM_SexID,
|
|
M_SexName,
|
|
M_PatientM_TitleID,
|
|
M_TitleName,
|
|
M_PatientM_ReligionID,
|
|
M_ReligionName,
|
|
M_PatientM_IdTypeID,
|
|
M_IdTypeName,
|
|
M_PatientIDNumber,
|
|
IF(ISNULL(M_PatientSuspendID),'active','suspend' ) as status
|
|
FROM m_patient
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
LEFT JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
LEFT JOIN m_religion ON M_PatientM_ReligionID = M_ReligionID
|
|
LEFT JOIN m_idtype ON M_PatientM_IdTypeID = M_IdTypeID
|
|
LEFT JOIN m_patientsuspend ON M_PatientSuspendM_PatientID = M_PatientID AND M_PatientSuspendIsActive = 'Y'
|
|
$sql_where
|
|
ORDER BY M_PatientName ASC
|
|
limit 100
|
|
";
|
|
// $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']);
|
|
$rows[$k]['M_PatientPOB'] = stripslashes($rows[$k]['M_PatientPOB']);
|
|
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
function getsexreg(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$rows['default_location'] = array();
|
|
$query ="SELECT *
|
|
FROM m_title
|
|
WHERE
|
|
M_TitleIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['titles'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_sex
|
|
WHERE
|
|
M_SexIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
|
$query =" SELECT *
|
|
FROM m_religion
|
|
WHERE
|
|
M_ReligionIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_idtype
|
|
WHERE
|
|
M_IdTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['kartuidentitass'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="SELECT *
|
|
FROM m_branch
|
|
WHERE
|
|
M_BranchIsDefault = 'Y' AND M_BranchIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$branch_default = $this->db_onedev->query($query)->row_array();
|
|
|
|
if($branch_default){
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['city_address'] = $this->db_onedev->query($query,array($branch_default['M_BranchM_CityID']))->row_array();
|
|
|
|
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityM_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['cities'] = $this->db_onedev->query($query,array($rows['default_location']['city_address']['M_CityM_ProvinceID']))->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y' AND M_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['province_address'] = $this->db_onedev->query($query,array($rows['default_location']['city_address']['M_CityM_ProvinceID']))->row_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['provinces'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['districts'] = $this->db_onedev->query($query,array($branch_default['M_BranchM_CityID']))->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['district_address'] = $this->db_onedev->query($query,array($branch_default['M_BranchM_DistrictID']))->row_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['kelurahans'] = $this->db_onedev->query($query,array($branch_default['M_BranchM_DistrictID']))->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['default_location']['kelurahan_address'] = $this->db_onedev->query($query,array($branch_default['M_BranchM_KelurahanID']))->row_array();
|
|
}
|
|
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function searchcity(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'
|
|
ORDER BY M_CityName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function getprovinces(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getcities(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityM_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function getdistricts(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getkelurahans(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sql = "SELECT * FROM m_patient WHERE M_PatientID = {$prm['M_PatientID']}";
|
|
$rows_before = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
|
$prm['M_PatientName'] = str_replace("'", "\\'", $prm['M_PatientName']);
|
|
$prm['M_PatientPOB'] = str_replace("'", "\\'", $prm['M_PatientPOB']);
|
|
$query ="UPDATE m_patient SET
|
|
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
|
M_PatientPrefix = '{$prm['M_PatientPrefix']}',
|
|
M_PatientName = '{$prm['M_PatientName']}',
|
|
M_PatientSuffix = '{$prm['M_PatientSuffix']}',
|
|
M_PatientDOB = '{$pdob}',
|
|
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
|
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
|
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
|
M_PatientPOB = '{$prm['M_PatientPOB']}',
|
|
M_PatientHP = '{$prm['M_PatientHP']}',
|
|
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
|
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
|
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
|
M_PatientNote = '{$prm['M_PatientNote']}',
|
|
M_PatientNIK = '{$prm['M_PatientNIK']}',
|
|
M_PatientJabatan = '{$prm['M_PatientJabatan']}',
|
|
M_PatientKedudukan = '{$prm['M_PatientKedudukan']}',
|
|
M_PatientPJ = '{$prm['M_PatientPJ']}',
|
|
M_PatientLocation = '{$prm['M_PatientLocation']}',
|
|
M_PatientJob = '{$prm['M_PatientJob']}',
|
|
M_PatientUserID = '{$userid}'
|
|
WHERE
|
|
M_PatientID = '{$prm['M_PatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
|
|
$sql = "SELECT *
|
|
FROM m_patientaddress
|
|
WHERE M_PatientAddressM_PatientID = {$prm['M_PatientID']} AND M_PatientAddressIsActive = 'Y'
|
|
ORDER BY M_PatientAddressID ASC LIMIT 1";
|
|
|
|
$d_address = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$sql = "UPDATE m_patientaddress SET
|
|
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}',
|
|
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}'
|
|
WHERE
|
|
M_PatientAddressID = {$d_address['M_PatientAddressID']}
|
|
";
|
|
$this->db_onedev->query($sql);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_PatientDOB"] = $pdob;
|
|
$xbefore = json_encode($rows_before);
|
|
$ptn = json_encode($ptn);
|
|
/*$this->db_onedev->query("INSERT INTO one_log.log_patient (
|
|
Log_PatientCode,
|
|
Log_PatientJson,
|
|
Log_PatientJsonBefore,
|
|
Log_PatientUserID
|
|
)
|
|
VALUES(
|
|
'PATIENT.EDIT',
|
|
'{$ptn}',
|
|
'{$xbefore}',
|
|
'{$userid}'
|
|
)");*/
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function newtext(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$activeid = $prm['activeid'];
|
|
$note = $prm['note'];
|
|
$id = $prm['orderid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$anamneses = $this->db_oneklinik->query("SELECT orderAnamnesisID as anamnesesid FROM one_klinik.order_anamnesis WHERE orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisOrderID = $id AND orderAnamnesisIsActive = 'Y'")->row();
|
|
$anamnesesid = $anamneses->anamnesesid;
|
|
if($anamnesesid == 0){
|
|
if($activeid == 1){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisKeluhanUtama,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 2){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPenyakitDanAlergiDahulu,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 3){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPenyakitDanAlergiSekarang,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
|
|
}elseif($activeid == 4){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPenyakitKeluarga,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 5){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPengobatan,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 6){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatSosial,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 7){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatOperasi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 8){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatAlergi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 9){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatImunisasi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'TEXT',
|
|
$id,
|
|
'{$note}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}
|
|
$last_id = $this->db_oneklinik->insert_id();
|
|
}else{
|
|
if($activeid == 1){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisKeluhanUtama = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 2){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPenyakitDanAlergiDahulu = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
//echo $query;
|
|
}elseif($activeid == 3){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPenyakitDanAlergiSekarang = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 4){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPenyakitKeluarga = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 5){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPengobatan = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 6){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatSosial = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 7){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatOperasi = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 8){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatAlergi = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 9){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatImunisasi = '{$note}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}
|
|
$last_id = $anamnesesid;
|
|
}
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id);
|
|
$ptn = $prm;
|
|
$ptn = json_encode($ptn);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function newform(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$activeid = $prm['activeid'];
|
|
$id = $prm['orderid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$riwayats = str_replace('\'', '\\\'', json_encode($prm["riwayats"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$riwayats = addslashes(str_replace('\"', '\\\"',$riwayats));
|
|
$keluhans = str_replace('\'', '\\\'', json_encode($prm["keluhans"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$keluhans = addslashes(str_replace('\"', '\\\"',$keluhans));
|
|
|
|
$penyakitdulus = str_replace('\'', '\\\'', json_encode($prm["penyakitdulus"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$penyakitdulus = addslashes(str_replace('\"', '\\\"',$penyakitdulus));
|
|
|
|
$penyakitsekarangs = str_replace('\'', '\\\'', json_encode($prm["penyakitsekarangs"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$penyakitsekarangs = addslashes(str_replace('\"', '\\\"',$penyakitsekarangs));
|
|
|
|
$penyakitkeluargas = str_replace('\'', '\\\'', json_encode($prm["penyakitkeluargas"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$penyakitkeluargas = addslashes(str_replace('\"', '\\\"',$penyakitkeluargas));
|
|
|
|
$pengobatans = str_replace('\'', '\\\'', json_encode($prm["pengobatans"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$pengobatans = addslashes(str_replace('\"', '\\\"',$pengobatans));
|
|
|
|
$sosials = str_replace('\'', '\\\'', json_encode($prm["sosials"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$sosials = addslashes(str_replace('\"', '\\\"',$sosials));
|
|
|
|
$imunisasis = str_replace('\'', '\\\'', json_encode($prm["imunisasis"],JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
$imunisasis = addslashes(str_replace('\"', '\\\"',$imunisasis));
|
|
|
|
|
|
$anamneses = $this->db_oneklinik->query("SELECT orderAnamnesisID as anamnesesid FROM one_klinik.order_anamnesis WHERE orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisOrderID = $id AND orderAnamnesisIsActive = 'Y'")->row();
|
|
$anamnesesid = $anamneses->anamnesesid;
|
|
if($anamnesesid == 0){
|
|
if($activeid == 1){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisKeluhanUtama,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$keluhans}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 2){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPenyakitDanAlergiDahulu,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$penyakitdulus}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 3){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPenyakitDanAlergiSekarang,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$penyakitsekarangs}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 4){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPenyakitKeluarga,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$penyakitkeluargas}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 5){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatPengobatan,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$pengobatans}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 6){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatSosial,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$sosials}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 7){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatOperasi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$riwayats}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 8){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatAlergi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$riwayats}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 9){
|
|
$query ="INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisRiwayatImunisasi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisLastUpdated,
|
|
orderAnamnesisUserID)
|
|
VALUES(
|
|
'FORM',
|
|
$id,
|
|
'{$imunisasis}',
|
|
now(),
|
|
now(),
|
|
$userid)";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}
|
|
$last_id = $this->db_oneklinik->insert_id();
|
|
}else{
|
|
if($activeid == 1){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisKeluhanUtama = '{$keluhans}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 2){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPenyakitDanAlergiDahulu = '{$penyakitdulus}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 3){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPenyakitDanAlergiSekarang = '{$penyakitsekarangs}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 4){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPenyakitKeluarga = '{$penyakitkeluargas}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 5){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatPengobatan = '{$pengobatans}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 6){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatSosial = '{$sosials}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 7){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatOperasi = '{$riwayats}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 8){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatAlergi = '{$riwayats}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}elseif($activeid == 9){
|
|
$query ="UPDATE one_klinik.order_anamnesis SET orderAnamnesisRiwayatImunisasi = '{$imunisasis}' WHERE orderAnamnesisID = $anamnesesid";
|
|
$rows = $this->db_oneklinik->query($query);
|
|
}
|
|
$last_id = $anamnesesid;
|
|
}
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id);
|
|
$ptn = $prm;
|
|
$ptn = json_encode($ptn);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function newpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
|
$prm['M_PatientName'] = str_replace("'", "\\'", $prm['M_PatientName']);
|
|
$query ="INSERT INTO m_patient (
|
|
M_PatientM_TitleID,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientDOB,
|
|
M_PatientM_SexID,
|
|
M_PatientM_ReligionID,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientHP,
|
|
M_PatientPhone,
|
|
M_PatientM_IdTypeID,
|
|
M_PatientIDNumber,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientUserID
|
|
)
|
|
VALUES(
|
|
'{$prm['M_PatientM_TitleID']}',
|
|
'{$prm['M_PatientPrefix']}',
|
|
'{$prm['M_PatientName']}',
|
|
'{$prm['M_PatientSuffix']}',
|
|
'{$pdob}',
|
|
'{$prm['M_PatientM_SexID']}',
|
|
'{$prm['M_PatientM_ReligionID']}',
|
|
'{$prm['M_PatientEmail']}',
|
|
'{$prm['M_PatientPOB']}',
|
|
'{$prm['M_PatientHP']}',
|
|
'{$prm['M_PatientPhone']}',
|
|
'{$prm['M_PatientM_IdTypeID']}',
|
|
'{$prm['M_PatientIDNumber']}',
|
|
'{$prm['M_PatientNote']}',
|
|
'{$prm['M_PatientNIK']}',
|
|
'{$prm['M_PatientJabatan']}',
|
|
'{$prm['M_PatientKedudukan']}',
|
|
'{$prm['M_PatientPJ']}',
|
|
'{$prm['M_PatientLocation']}',
|
|
'{$prm['M_PatientJob']}',
|
|
$userid
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
if($last_id){
|
|
$sql ="SELECT * FROM m_patient
|
|
LEFT JOIN m_branch ON M_BranchIsDefault = 'Y' AND M_BranchIsActive = 'Y'
|
|
WHERE M_PatientID = {$last_id}
|
|
LIMIT 1";
|
|
//echo $sql;
|
|
$data_patient = $this->db_onedev->query($sql)->row_array();
|
|
if($data_patient){
|
|
if(intval($prm['M_PatientM_IdTypeID']) == 4){
|
|
$new_nik_varchar = "00".$data_patient['M_BranchCode'].str_pad($data_patient['M_PatientNoReg'],12,"0",STR_PAD_LEFT);
|
|
$sql = "UPDATE m_patient SET M_PatientIDNumber = '{$new_nik_varchar}' WHERE M_PatientID = {$last_id}";
|
|
$this->db_onedev->query($sql);
|
|
//echo $sql;
|
|
}
|
|
}
|
|
|
|
$address_description = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
|
// save address
|
|
$add = [
|
|
'M_PatientAddressM_PatientID' => $last_id,
|
|
'M_PatientAddressDescription' => $address_description,
|
|
'M_PatientAddressUserID'=> $userid,
|
|
'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
|
];
|
|
$this->db_onedev->insert('m_patientaddress', $add);
|
|
//echo $this->db_onedev->last_query();
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_PatientID"] = $last_id;
|
|
$ptn["M_PatientDOB"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function deletepatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$query ="UPDATE m_patient SET
|
|
M_PatientIsActive = 'N',
|
|
M_PatientUserID = {$userid}
|
|
WHERE
|
|
M_PatientID = '{$prm['M_PatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_PatientDOB"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.DELETE', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT m_patientaddress.*,
|
|
M_KelurahanName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_CityID,
|
|
M_CityName,
|
|
'' as action
|
|
FROM m_patientaddress
|
|
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
|
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
|
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
|
WHERE
|
|
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
|
ORDER BY M_PatientAddressID ASC
|
|
LIMIT 1
|
|
|
|
";
|
|
//echo $query;
|
|
$address = $this->db_onedev->query($query,array($prm['id']))->row_array();
|
|
$address['M_PatientAddressDescription'] = stripslashes($address['M_PatientAddressDescription']);
|
|
$rows['address'] = $address;
|
|
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['city_address'] = $this->db_onedev->query($query,array($address['M_CityID']))->row_array();
|
|
|
|
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityM_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['cities'] = $this->db_onedev->query($query,array($rows['city_address']['M_CityM_ProvinceID']))->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y' AND M_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['province_address'] = $this->db_onedev->query($query,array($rows['city_address']['M_CityM_ProvinceID']))->row_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['provinces'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['districts'] = $this->db_onedev->query($query,array($rows['city_address']['M_CityID']))->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['district_address'] = $this->db_onedev->query($query,array($address['M_DistrictID']))->row_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['kelurahans'] = $this->db_onedev->query($query,array($address['M_DistrictID']))->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanID = ?
|
|
";
|
|
//echo $query;
|
|
$rows['kelurahan_address'] = $this->db_onedev->query($query,array($address['M_PatientAddressM_KelurahanID']))->row_array();
|
|
|
|
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function savenewaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
if($count_addrs == 0){
|
|
$prm['M_PatientAddressNote'] = 'Utama';
|
|
}
|
|
else{
|
|
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
|
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
|
$rx = date('YmdHis');
|
|
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
|
}
|
|
}
|
|
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
|
$query ="INSERT INTO m_patientaddress (
|
|
M_PatientAddressM_PatientID,
|
|
M_PatientAddressNote,
|
|
M_PatientAddressDescription,
|
|
M_PatientAddressM_KelurahanID,
|
|
M_PatientAddressCreated,
|
|
M_PatientAddressUserID
|
|
)
|
|
VALUES(
|
|
'{$prm['M_PatientAddressM_PatientID']}',
|
|
'{$prm['M_PatientAddressNote']}',
|
|
'{$prm['M_PatientAddressDescription']}',
|
|
'{$prm['M_PatientAddressM_KelurahanID']}',
|
|
NOW(),
|
|
'{$userid}'
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_UserID"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function saveeditaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
|
$sql = "SELECT * FROM m_patientaddress WHERE M_PatientAddressID = {$prm['M_PatientAddressID']}";
|
|
$rows_before = $this->db_onedev->query($sql)->row_array();
|
|
$query ="UPDATE m_patientaddress SET
|
|
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
|
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
|
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
|
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}',
|
|
M_PatientAddressUserID = {$userid}
|
|
WHERE
|
|
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_UserID"] = $pdob;
|
|
$xbefore = json_encode($rows_before);
|
|
$ptn = json_encode($ptn);
|
|
/*$this->db_onedev->query("INSERT INTO one_log.log_patient (
|
|
Log_PatientCode,
|
|
Log_PatientJson,
|
|
Log_PatientJsonBefore,
|
|
Log_PatientUserID
|
|
)
|
|
VALUES(
|
|
'PATIENT.ADDR_EDIT',
|
|
'{$ptn}',
|
|
'{$xbefore}',
|
|
'{$userid}'
|
|
)");*/
|
|
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function deleteaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
|
|
$query ="UPDATE m_patientaddress SET
|
|
M_PatientAddressIsActive = 'N',
|
|
M_PatientAddressUserID = {$userid}
|
|
WHERE
|
|
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_UserID"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_DELETE', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
|
|
$sql = "SELECT orderID,
|
|
orderDate,
|
|
orderNumber,
|
|
orderIsAnamnese,
|
|
orderIsCheck,
|
|
DATE_FORMAT(orderDate,'%d-%m-%Y') as order_date,
|
|
'N' divider,
|
|
M_PatientID,
|
|
M_PatientNoReg,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientHP,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientPhone,
|
|
M_PatientIDNumber,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientM_SexID,
|
|
M_SexName,
|
|
M_PatientM_TitleID,
|
|
M_TitleName,
|
|
M_PatientM_ReligionID,
|
|
M_ReligionName,
|
|
M_PatientM_IdTypeID,
|
|
M_IdTypeName,
|
|
M_PatientIDNumber,
|
|
IF(ISNULL(M_PatientSuspendID),'active','suspend' ) as status,
|
|
M_PatientAddressM_KelurahanID M_KelurahanID,
|
|
0 M_DistrictID,
|
|
0 M_CityID,
|
|
0 M_ProvinceID,
|
|
'' as KeluhanUtamaText,
|
|
'' as RiwayatPenyakitDanAlergiDahuluText,
|
|
'' as RiwayatPenyakitDanAlergiSekarangText,
|
|
'' as RiwayatPenyakitKeluargaText,
|
|
'' as RiwayatPengobatanText,
|
|
'' as RiwayatSosialText,
|
|
'' as RiwayatOperasiText,
|
|
'' as RiwayatAlergiText,
|
|
'' as RiwayatImunisasiText,
|
|
'' as KeluhanUtamaForm,
|
|
'' as RiwayatPenyakitDanAlergiDahuluForm,
|
|
'' as RiwayatPenyakitDanAlergiSekarangForm,
|
|
'' as RiwayatPenyakitKeluargaForm,
|
|
'' as RiwayatPengobatanForm,
|
|
'' as RiwayatSosialForm,
|
|
'' as RiwayatOperasiForm,
|
|
'' as RiwayatAlergiForm,
|
|
'' as RiwayatImunisasiForm,
|
|
'' as riwayats
|
|
FROM one_klinik.order
|
|
JOIN m_patient ON M_PatientID = orderM_PatientID AND M_PatientIsActive = 'Y'
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
JOIN m_branch ON M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
|
JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressIsActive = 'Y'
|
|
LEFT JOIN m_idtype ON M_IdTypeID = M_PatientM_IdTypeID AND M_IdTypeIsActive = 'Y'
|
|
LEFT JOIN m_religion ON m_patientm_religionid = m_religionid
|
|
LEFT JOIN m_patientsuspend ON M_PatientSuspendM_PatientID = M_PatientID AND M_PatientSuspendIsActive = 'Y'
|
|
WHERE
|
|
orderNumber = '{$id}' AND
|
|
M_PatientSuspendID IS NULL
|
|
|
|
GROUP BY M_PatientID";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
foreach ($rows as $k => $v)
|
|
{
|
|
$rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']);
|
|
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
|
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
|
$sql = "SELECT *, concat('{$rows[$k]['M_PatientAddressDescription'] }', '\n\n',
|
|
m_kelurahanname, ', ',
|
|
m_districtname,'\n',
|
|
m_cityname, ', ',
|
|
m_provincename) as xaddress
|
|
FROM m_kelurahan
|
|
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
|
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
|
JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID
|
|
WHERE
|
|
M_KelurahanID = {$v['M_KelurahanID']} ";
|
|
//echo $sql;
|
|
$row_address = $this->db_onedev->query($sql)->row_array();
|
|
$rows[$k]['M_PatientAddress'] = stripslashes($row_address['xaddress']);
|
|
$rows[$k]['M_DistrictID'] = $row_address['M_DistrictID'];
|
|
$rows[$k]['M_CityID'] = $row_address['M_CityID'];
|
|
$rows[$k]['M_ProvinceID'] = $row_address['M_ProvinceID'];
|
|
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row();
|
|
$rows[$k]['info'] = json_decode($info->info);
|
|
|
|
$sqlanamnese_text = "SELECT * FROM one_klinik.order_anamnesis WHERE orderAnamnesisOrderID = {$v['orderID']} AND orderAnamnesisTypeForm = 'TEXT' ";
|
|
$row_anamnese_text = $this->db_oneklinik->query($sqlanamnese_text)->row_array();
|
|
$rows[$k]['KeluhanUtamaText'] = $row_anamnese_text['orderAnamnesisKeluhanUtama'];
|
|
$rows[$k]['RiwayatPenyakitDanAlergiDahuluText'] = $row_anamnese_text['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'];
|
|
$rows[$k]['RiwayatPenyakitDanAlergiSekarangText'] = $row_anamnese_text['orderAnamnesisRiwayatPenyakitDanAlergiSekarang'];
|
|
$rows[$k]['RiwayatPenyakitKeluargaText'] = $row_anamnese_text['orderAnamnesisRiwayatPenyakitKeluarga'];
|
|
$rows[$k]['RiwayatPengobatanText'] = $row_anamnese_text['orderAnamnesisRiwayatPengobatan'];
|
|
$rows[$k]['RiwayatSosialText'] = $row_anamnese_text['orderAnamnesisRiwayatSosial'];
|
|
$rows[$k]['RiwayatOperasiText'] = $row_anamnese_text['orderAnamnesisRiwayatOperasi'];
|
|
$rows[$k]['RiwayatAlergiText'] = $row_anamnese_text['orderAnamnesisRiwayatAlergi'];
|
|
$rows[$k]['RiwayatImunisasiText'] = $row_anamnese_text['orderAnamnesisRiwayatImunisasi'];
|
|
$sql = "SELECT * FROM fisik_templateresult WHERE
|
|
Fisik_TemplateResultM_LangID = 1 AND
|
|
Fisik_TemplateResultType = 'riwayat' AND
|
|
Fisik_TemplateResultIsActive = 'Y' LIMIT 1";
|
|
|
|
$rows[$k]['riwayats'] = json_decode($this->db_onedev->query($sql)->row()->Fisik_TemplateResultText);
|
|
|
|
$sqlanamnese_form = "SELECT * FROM one_klinik.order_anamnesis WHERE orderAnamnesisOrderID = {$v['orderID']} AND orderAnamnesisTypeForm = 'FORM'";
|
|
$row_anamnese_form = $this->db_oneklinik->query($sqlanamnese_form)->row_array();
|
|
|
|
if(!$row_anamnese_form['orderAnamnesisKeluhanUtama'] || $row_anamnese_form['orderAnamnesisKeluhanUtama'] == ''){
|
|
$a1 = array_search('KELUHAN SAAT INI', array_column($rows[$k]['riwayats'], 'title'));
|
|
$rows[$k]['KeluhanUtamaForm'] = $rows[$k]['riwayats'][$a1];
|
|
}else{
|
|
$rows[$k]['KeluhanUtamaForm'] = json_decode($row_anamnese_form['orderAnamnesisKeluhanUtama']);
|
|
}
|
|
//echo $row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'];
|
|
if(!$row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'] || $row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'] == ''){
|
|
$a2 = array_search('RIWAYAT PENYAKIT', array_column($rows[$k]['riwayats'], 'title'));
|
|
//echo $a2;
|
|
$rows[$k]['RiwayatPenyakitDanAlergiDahuluForm'] = $rows[$k]['riwayats'][$a2];
|
|
}else{
|
|
$rows[$k]['RiwayatPenyakitDanAlergiDahuluForm'] = json_decode($row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiDahulu']);
|
|
}
|
|
|
|
if(!$row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiSekarang'] || $row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiSekarang'] == ''){
|
|
$a3 = array_search('RIWAYAT PENYAKIT', array_column($rows[$k]['riwayats'], 'title'));
|
|
$rows[$k]['RiwayatPenyakitDanAlergiSekarangForm'] = $rows[$k]['riwayats'][$a3];
|
|
}else{
|
|
$rows[$k]['RiwayatPenyakitDanAlergiSekarangForm'] = json_decode($row_anamnese_form['orderAnamnesisRiwayatPenyakitDanAlergiSekarang']);
|
|
}
|
|
|
|
if(!$row_anamnese_form['orderAnamnesisRiwayatPenyakitKeluarga'] || $row_anamnese_form['orderAnamnesisRiwayatPenyakitKeluarga'] == ''){
|
|
$a4 = array_search('RIWAYAT PENYAKIT KELUARGA', array_column($rows[$k]['riwayats'], 'title'));
|
|
$rows[$k]['RiwayatPenyakitKeluargaForm'] = $rows[$k]['riwayats'][$a4];
|
|
}else{
|
|
$rows[$k]['RiwayatPenyakitKeluargaForm'] = json_decode($row_anamnese_form['orderAnamnesisRiwayatPenyakitKeluarga']);
|
|
}
|
|
|
|
if(!$row_anamnese_form['orderAnamnesisRiwayatPengobatan'] || $row_anamnese_form['orderAnamnesisRiwayatPengobatan'] == ''){
|
|
$a5 = array_search('RIWAYAT KONSUMSI OBAT TERATUR', array_column($rows[$k]['riwayats'], 'title'));
|
|
$rows[$k]['RiwayatPengobatanForm'] = $rows[$k]['riwayats'][$a5];
|
|
}else{
|
|
$rows[$k]['RiwayatPengobatanForm'] = json_decode($row_anamnese_form['orderAnamnesisRiwayatPengobatan']);
|
|
}
|
|
|
|
if(!$row_anamnese_form['orderAnamnesisRiwayatSosial'] || $row_anamnese_form['orderAnamnesisRiwayatSosial'] == ''){
|
|
$a6 = array_search('RIWAYAT KEBIASAAN HIDUP', array_column($rows[$k]['riwayats'], 'title'));
|
|
$rows[$k]['RiwayatSosialForm'] = $rows[$k]['riwayats'][$a6];
|
|
}else{
|
|
$rows[$k]['RiwayatSosialForm'] = json_decode($row_anamnese_form['orderAnamnesisRiwayatSosial']);
|
|
}
|
|
|
|
if(!$row_anamnese_form['orderAnamnesisRiwayatImunisasi'] || $row_anamnese_form['orderAnamnesisRiwayatImunisasi'] == ''){
|
|
$a7 = array_search('RIWAYAT IMUNISASI', array_column($rows[$k]['riwayats'], 'title'));
|
|
$rows[$k]['RiwayatImunisasiForm'] = $rows[$k]['riwayats'][$a7];
|
|
}else{
|
|
$rows[$k]['RiwayatImunisasiForm'] = json_decode($row_anamnese_form['orderAnamnesisRiwayatImunisasi']);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|
|
public function search_old()
|
|
{
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 100;
|
|
$tot_count =0;
|
|
$number_limit = 10;
|
|
$number_offset = (!isset($prm['current_page'])?1:$prm['current_page'] - 1) * $number_limit ;
|
|
|
|
$q = [
|
|
'noreg' => "",
|
|
'name' => '',
|
|
'hp' => '',
|
|
'dob' => '',
|
|
'address' => '',
|
|
'nik' =>''
|
|
];
|
|
|
|
$q_pid = "";
|
|
|
|
if ($prm['noreg'] != '')
|
|
$q['noreg'] = "AND M_PatientNoReg like '%{$prm['noreg']}%'";
|
|
|
|
if($prm['snorm'] == ''){
|
|
if ($prm['search'] != '')
|
|
{
|
|
$e = explode('+', $prm['search']);
|
|
if (isset($e[0])){
|
|
$e[0] = str_replace("'", "\\'", $e[0]);
|
|
$q['name'] = "AND M_PatientName LIKE '%{$e[0]}%'";
|
|
}
|
|
if (isset($e[1]))
|
|
$q['hp'] = "AND ((M_PatientHP LIKE '%{$e[1]}%' and M_PatientHP IS NOT NULL) OR (M_PatientHP IS NULL AND '{$e[1]}' = ''))";
|
|
if (isset($e[2]))
|
|
$q['dob'] = "AND ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE '%{$e[2]}%' and M_PatientDOB IS NOT NULL) OR (M_PatientDOB IS NULL AND '{$e[2]}' = ''))";
|
|
if (isset($e[3]))
|
|
$q['address'] = "AND M_PatientAddressDescription LIKE '%{$e[3]}%'";
|
|
if (isset($e[4]))
|
|
$q['nik'] = "AND M_PatientIDNumber = '{$e[4]}'";
|
|
}
|
|
}else{
|
|
$q_pid = "AND M_PatientNoReg = '{$prm['snorm']}'";
|
|
}
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT 'N' divider,M_PatientID,
|
|
M_PatientNoReg,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientHP,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientPhone,
|
|
M_PatientIDNumber,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientM_SexID,
|
|
M_SexName,
|
|
M_PatientM_TitleID,
|
|
M_TitleName,
|
|
M_PatientM_ReligionID,
|
|
M_ReligionName,
|
|
M_PatientM_IdTypeID,
|
|
M_IdTypeName,
|
|
M_PatientIDNumber,
|
|
IF(ISNULL(M_PatientSuspendID),'active','suspend' ) as status,
|
|
M_PatientAddressM_KelurahanID M_KelurahanID,
|
|
0 M_DistrictID, 0 M_CityID, 0 M_ProvinceID
|
|
FROM m_patient
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
JOIN m_branch ON M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
|
JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressIsActive = 'Y'
|
|
LEFT JOIN m_idtype ON M_IdTypeID = M_PatientM_IdTypeID AND M_IdTypeIsActive = 'Y'
|
|
LEFT JOIN m_religion ON m_patientm_religionid = m_religionid
|
|
LEFT JOIN m_patientsuspend ON M_PatientSuspendM_PatientID = M_PatientID AND M_PatientSuspendIsActive = 'Y'
|
|
WHERE
|
|
M_PatientSuspendID IS NULL AND M_PatientIsActive = 'Y'
|
|
{$q['address']}
|
|
{$q['noreg']}
|
|
{$q['name']}
|
|
{$q['hp']}
|
|
{$q['dob']}
|
|
{$q['nik']}
|
|
{$q_pid}
|
|
|
|
GROUP BY M_PatientID
|
|
LIMIT $number_limit offset $number_offset";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
foreach ($rows as $k => $v)
|
|
{
|
|
$rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']);
|
|
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
|
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
|
$sql = "SELECT *, concat('{$rows[$k]['M_PatientAddressDescription'] }', '\n\n',
|
|
m_kelurahanname, ', ',
|
|
m_districtname,'\n',
|
|
m_cityname, ', ',
|
|
m_provincename) as xaddress
|
|
FROM m_kelurahan
|
|
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
|
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
|
JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID
|
|
WHERE
|
|
M_KelurahanID = {$v['M_KelurahanID']} ";
|
|
//echo $sql;
|
|
$row_address = $this->db_onedev->query($sql)->row_array();
|
|
$rows[$k]['M_PatientAddress'] = stripslashes($row_address['xaddress']);
|
|
$rows[$k]['M_DistrictID'] = $row_address['M_DistrictID'];
|
|
$rows[$k]['M_CityID'] = $row_address['M_CityID'];
|
|
$rows[$k]['M_ProvinceID'] = $row_address['M_ProvinceID'];
|
|
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row();
|
|
$rows[$k]['info'] = json_decode($info->info);
|
|
}
|
|
|
|
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function saveorder(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "SELECT * FROM one_klinik.setting WHERE settingIsActive = 'Y' LIMIT 1";
|
|
$setting_data = $this->db_oneklinik->query($sql)->row_array();
|
|
|
|
$sql = "INSERT INTO one_klinik.`order` (`orderDate`,`orderM_PatientID`,`orderKeluhan`, `orderSubtotal`, `orderTotal`, `orderUserID`,`orderCreated`)
|
|
VALUES (NOW(),?,?,?,?,$userid,NOW())";
|
|
|
|
$save_order = $this->db_oneklinik->query($sql,array(
|
|
$prm['patient']['M_PatientID'],
|
|
$prm['keluhan'],
|
|
$setting_data['settingPriceDefault'],
|
|
$setting_data['settingPriceDefault']
|
|
));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if($save_order){
|
|
$last_id = $this->db_oneklinik->insert_id();
|
|
//echo $last_id;
|
|
$sql = "SELECT * FROM one_klinik.`order` WHERE orderID = {$last_id}";
|
|
//echo $sql;
|
|
$data_order = $this->db_oneklinik->query($sql)->row_array();
|
|
|
|
$this->sys_ok($data_order);
|
|
}else{
|
|
$this->sys_error_db("error order save",$this->db_oneklinik);
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public function list_patient()
|
|
{
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 20;
|
|
$tot_count = 0;
|
|
$number_limit = 20;
|
|
$number_offset = (!isset($prm['current_page'])?1:$prm['current_page'] - 1) * $number_limit ;
|
|
$xdate = $prm['date'];
|
|
$status = $prm['status'];
|
|
|
|
$sql = "SELECT 'N' divider,
|
|
CONCAT(M_TitleName,' ',IF(M_PatientPrefix = NULL,'',CONCAT(M_PatientPrefix,' ')),M_PatientName,IF(M_PatientPrefix = NULL,'',CONCAT(M_PatientSuffix,' '))) as patient_name,
|
|
`order`.*,DATE_FORMAT(orderDate,'%d-%m-%Y') as date_order,
|
|
'' as kode_status, '' as status
|
|
FROM one_klinik.`order`
|
|
JOIN m_patient ON orderM_PatientID = M_PatientID
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
WHERE
|
|
orderIsActive = 'Y' AND DATE(orderDate) = ? AND orderIsAnamnese = ?
|
|
LIMIT $number_limit offset $number_offset";
|
|
//echo $sql;
|
|
$query = $this->db_oneklinik->query($sql,array($xdate,$status));
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
foreach ($rows as $key => $value) {
|
|
$sql = "SELECT
|
|
FROM one_klinik.order_status
|
|
WHERE
|
|
orderStatusOrderID = ?
|
|
ORDER BY ";
|
|
}
|
|
|
|
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function process_now(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID
|
|
)
|
|
VALUES(
|
|
?,?,?,?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'A','Y',$userID));
|
|
if(!$query){
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderIsAnamnese = 'Y', orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
|
|
if(!$query){
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
|
|
$result = array('process'=>'OK');
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function cancel_now(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID
|
|
)
|
|
VALUES(
|
|
?,?,?,?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'A','N',$userID));
|
|
if(!$query){
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderIsAnamnese = 'N', orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
|
|
if(!$query){
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
|
|
$result = array('process'=>'OK');
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function end_session(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID
|
|
)
|
|
VALUES(
|
|
?,?,?,?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'A','D',$userID));
|
|
if(!$query){
|
|
$this->sys_error("Gagal End");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderIsAnamnese = 'D', orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
|
|
if(!$query){
|
|
$this->sys_error("Gagal ENd");
|
|
}
|
|
|
|
|
|
$result = array('process'=>'OK');
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|