Initial import

This commit is contained in:
sas.fajri
2026-05-25 20:01:37 +07:00
commit 710d7c1b97
10371 changed files with 2381698 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
<?php
class Order extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "ORDER API";
}
public function __construct()
{
parent::__construct();
$this->db_smartone = $this->load->database("clinicdev", true);
}
function save()
{
$prm = $this->sys_input;
$prm['header']['complaint'] = str_replace(PHP_EOL, '<br>', $prm['header']['complaint']);
$prm['header']['suggestion'] = str_replace(PHP_EOL, '<br>', $prm['header']['suggestion']);
$header_json = json_encode($prm['header']);
$header_json = str_replace("\\", "\\\\", "$header_json");
$lab_json = json_encode($prm['lab']);
$med_json = json_encode($prm['med']);
$server = "http";
$uid = $this->sys_user['M_UserID'];
$sql = "CALL sp_clinic_poly_save('{$prm['order_id']}', '{$header_json}', '{$med_json}', '{$lab_json}', '{$uid}');";
$query = $this->db_smartone->query($sql);
$this->clean_mysqli_connection($this->db_smartone->conn_id);
if ($query)
{
$rst = $query->row();
$rst->data = json_decode($rst->data);
if ($rst->data->is_lab == "Y" && $rst->status == "OK")
{
// persiapkan curl
$ch = curl_init();
// set url
global $_SERVER;
$current_host = $_SERVER["SERVER_ADDR"];
if ($server == "https")
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, "{$server}://{$current_host}:9090/ticket/UMUM");
//file_put_contents("/xtmp/url", "{$server}://{$current_host}:9090/ticket/UMUM" );
// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = json_decode(curl_exec($ch));
// tutup curl
curl_close($ch);
// menampilkan hasil curl
// echo $output;
if ($output != null)
if ($output->status == "OK") {
$rst->data->queue = $output->data[0]->number;
$x = json_encode($output->data[0]);
$sql = "CALL sp_clinic_fo_labqueue('{$rst->data->id}', '{$rst->data->queue}', '{$x}');";
$query = $this->db_smartone->query($sql);
}
}
echo json_encode($rst);
}
else
{
$this->sys_error_db("save order", $this->db_smartone);
exit;
}
}
function process()
{
$prm = $this->sys_input;
$sql = "CALL sp_clinic_poly_process('{$prm['order_id']}');";
$query = $this->db_smartone->query($sql);
if ($query)
{
$rst = $query->row();
echo json_encode($rst);
}
else
{
$this->sys_error_db("save order", $this->db_smartone);
exit;
}
}
function get_one()
{
$prm = $this->sys_input;
$sql = "select *
from c_orderheader
where C_OrderHeaderID = ?";
$query = $this->db_smartone->query($sql, array($prm['id']));
if ($query) {
$rows = $query->row();
$rows->C_OrderHeaderQueueJSON = json_decode($rows->C_OrderHeaderQueueJSON);
$result = $rows;
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_patient get",$this->db_smartone);
exit;
}
}
function clean_mysqli_connection( $dbc )
{
while( mysqli_more_results($dbc) )
{
if(mysqli_next_result($dbc))
{
$result = mysqli_use_result($dbc);
unset($result);
}
}
}
}

View File

@@ -0,0 +1,127 @@
<?php
/*
template function {
$this->sys_debug();
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
*/
class Patient extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "Patient API";
}
public function __construct()
{
parent::__construct();
$this->db_smartone = $this->load->database("clinicdev", true);
}
public function search()
{
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'nolab' => '%',
'noreg' => '%',
'name' => '%',
'hp' => '%',
'dob' => '%',
'address' => '%',
'status' => 0
];
if ($prm['noreg'] != '')
$q['noreg'] = "%{$prm['noreg']}%";
if ($prm['nolab'] != '')
$q['nolab'] = "%{$prm['nolab']}%";
if ($prm['status'] != '')
$q['status'] = $prm['status'];
if ($prm['search'] != '')
{
$e = explode('+', $prm['search']);
if (isset($e[0]))
$q['name'] = "%{$e[0]}%";
if (isset($e[1]))
$q['hp'] = "%{$e[1]}%";
if (isset($e[2]))
$q['dob'] = "%{$e[2]}%";
if (isset($e[3]))
$q['address'] = "%{$e[3]}%";
}
// QUERY TOTAL
$sql = "select count(*) total
from c_orderheader
join one.m_patient on c_orderheaderm_patientid = m_patientid
join one.m_title on M_PatientM_TitleID = M_TitleID
where C_OrderHeaderNumber like ?
and M_PatientName LIKE ?
and M_PatientHP LIKE ?
and M_PatientDOB LIKE ?
and C_OrderHeaderIsActive = 'Y'
and ((C_OrderHeaderM_StatusID = ? and ? <> 0) or C_OrderHeaderM_StatusID = 0)";
$query = $this->db_smartone->query($sql, array($q['nolab'], $q['name'], $q['hp'], $q['dob'], $q['status'], $q['status']));
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_patient count",$this->db_smartone);
exit;
}
// set locales
$this->db_smartone->query("SET @@lc_time_names = 'id_ID'");
$sql = "select M_PatientID, M_PatientNoReg,
concat(M_TitleName,' ',M_PatientName) M_PatientName,
M_PatientHP, M_PatientDOB, M_PatientNote, 'X' as M_PatientAddress,
M_PatientNote, C_OrderHeaderID, C_OrderHeaderNumber, M_StatusCode,
C_OrderHeaderM_PatientAge, C_OrderHeaderComplaint, C_OrderHeaderIsLab, C_OrderHeaderIsReceipt,
C_OrderHeaderDate, dayname(C_OrderHeaderDate) `day`
from c_orderheader
join one.m_patient on c_orderheaderm_patientid = m_patientid
join one.m_title on M_PatientM_TitleID = M_TitleID
join m_status on c_orderheaderm_statusid = m_statusid
where C_OrderHeaderNumber like ?
and M_PatientName LIKE ?
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
and M_PatientDOB LIKE ?
and C_OrderHeaderIsActive = 'Y'
and ((C_OrderHeaderM_StatusID = ? and ? <> 0) or C_OrderHeaderM_StatusID = 0)
limit 0,{$max_rst}";
$query = $this->db_smartone->query($sql, array($q['nolab'], $q['name'], $q['hp'], $q['dob'], $q['status'], $q['status']));
if ($query) {
$rows = $query->result_array();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_patient rows",$this->db_smartone);
exit;
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
class Status extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "STATUS API";
}
public function __construct()
{
parent::__construct();
$this->db_smartone = $this->load->database("clinicdev", true);
}
public function search()
{
$prm = $this->sys_input;
$max_rst = 25;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "select count(*) total
from
m_status
where M_StatusIsActive = 'Y'
and M_StatusName like ?";
$query = $this->db_smartone->query($sql, array($q['search']));
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_status count",$this->db_smartone);
exit;
}
$sql = "select M_StatusID, M_StatusName
from m_status
where M_StatusIsActive = 'Y'
and M_StatusName like ?
limit {$max_rst}";
$query = $this->db_smartone->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
// $rows = $rows;
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_status rows",$this->db_smartone);
exit;
}
}
}