Initial import
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"php":"7.0.33-0ubuntu0.16.04.1","version":"2.14.2","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"Patient.php":3362798707}}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
class Bank extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Bank API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select Nat_BankID, Nat_BankName
|
||||
from nat_bank
|
||||
where Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("BANK rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_account()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select M_BankAccountID, CONCAT(Nat_BankCode, ' no ', M_BankAccountNo) M_BankAccountNo
|
||||
from nat_bank
|
||||
JOIN m_bank_account ON M_BankAccountNat_BankID = Nat_BankID AND M_BankAccountIsActive = 'Y'
|
||||
where Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("BANK rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Company API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_mou(&$companies) {
|
||||
if (count($companies) == 0) {
|
||||
return;
|
||||
}
|
||||
$company_list= "-1";
|
||||
foreach($companies as $idx => $c) {
|
||||
$company_list .= ", " . $c["M_PatientTypeID"];
|
||||
if (! isset($companies[$idx]["mou"])) $companies[$idx]["mou"] = array();
|
||||
}
|
||||
$sql = "select *
|
||||
from
|
||||
m_moucompany
|
||||
where M_MouCompanyM_PatientTypeID in ( $company_list )
|
||||
and ( M_MouCompanyStartDate <= now() and M_MouCompanyEndDate >= now() )
|
||||
and M_MouCompanyIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$patientTypeID= $r["M_MouCompanyM_PatientTypeID"];
|
||||
foreach($companies as $idx => $c) {
|
||||
if($c["M_PatientTypeID"] == $patientTypeID) {
|
||||
$companies[$idx]["mou"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_moucompany mou",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName 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_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouNote', M_MouNote, 'M_MouIsBill', M_MouIsBill, 'M_MouEmail', M_MouEmail, 'M_MouIsDefault', M_MouIsDefault, 'M_MouEmailIsDefault', M_MouEmailIsDefault, 'delivery_email_code', `fn_fo_delivery_code`('MOU', 'EMAIL', '0')) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName like ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_MouID, M_MouM_CompanyID FROM m_mou
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID ANd M_CompanyIsDefault = 'Y' ANd M_CompanyIsActive = 'Y'
|
||||
WHERE M_MouIsActive = 'Y' ANd M_MouIsDefault = 'Y' AND M_MouIsApproved = 'Y' AND M_MouIsReleased = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now())";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouNote', M_MouNote, 'M_MouIsBill', M_MouIsBill, 'M_MouEmail', M_MouEmail, 'M_MouIsDefault', M_MouIsDefault, 'M_MouEmailIsDefault', M_MouEmailIsDefault, 'delivery_email_code', `fn_fo_delivery_code`('MOU', 'EMAIL', '0')) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
|
||||
where M_CompanyID = ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($rows->M_MouM_CompanyID));
|
||||
$rows2 = $query->result_array();
|
||||
|
||||
foreach ($rows2 as $k => $v)
|
||||
$rows2[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => 1, "records" => $rows2, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("m_company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patienttype count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_PatientTypeID, M_PatientTypeName
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'
|
||||
limit 0,10";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$rows = $query->result_array();
|
||||
$this->_add_mou($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
class Delivery extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$q = [
|
||||
"patient_id" => 0,
|
||||
"doctor_id" => 0,
|
||||
"mou_id" => 0
|
||||
];
|
||||
|
||||
if (isset($prm['patient_id']))
|
||||
$q["patient_id"] = $prm['patient_id'];
|
||||
if (isset($prm['doctor_id']))
|
||||
$q["doctor_id"] = $prm['doctor_id'];
|
||||
if (isset($prm['mou_id']))
|
||||
$q["mou_id"] = $prm['mou_id'];
|
||||
|
||||
$sql = "CALL sp_fo_delivery_address('', '{$q['patient_id']}', '{$q['doctor_id']}', '{$q['mou_id']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->row();
|
||||
$data = json_decode($rows->x);
|
||||
|
||||
$result = array("records" => $data);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("delivery address",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = array();
|
||||
// $rows[] = array("id" =>1, "name" => "Ambil Sendiri", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>2, "name" => "Kirim ke dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>3, "name" => "Kirim ke email pasien", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>4, "name" => "Kirim ke email dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>5, "name" => "Kirim ke alamat utama pasien", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>6, "name" => "Kirim ke alamat utama dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>7, "name" => "Kirim ke rekanan");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_address(&$doc) {
|
||||
if (count($doc) == "0") {
|
||||
return;
|
||||
}
|
||||
$doc_ids = "-1";
|
||||
foreach($doc as $idx => $d ) {
|
||||
$doc_ids .= "," . $d["M_DoctorID"];
|
||||
$doc[$idx]["address"] = array();
|
||||
}
|
||||
$sql = "select M_DoctorAddressID,M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressDesc
|
||||
from
|
||||
m_doctoraddress
|
||||
where
|
||||
M_DoctorAddressM_DoctorID in ( $doc_ids )
|
||||
and M_DoctorAddressIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$doctorID= $r["M_DoctorAddressM_DoctorID"];
|
||||
foreach($doc as $idx => $d) {
|
||||
if($d["M_DoctorID"] == $doctorID) {
|
||||
$doc[$idx]["address"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function search_pj() {
|
||||
//sipe : M_DoctorPjIsDefault diganti ke M_DoctorPjIsDefaultPJ
|
||||
$sql = "select M_DoctorID, fn_global_doctor_name(M_DoctorID) M_DoctorName, M_DoctorPjIsDefaultPj M_DoctorIsDefaultPJ
|
||||
from m_doctor
|
||||
join m_doctorpj on M_DoctorPJM_DoctorID = M_DoctorID and M_DoctorPjIsactive = 'Y'
|
||||
and M_DoctorPjIsPJ = 'Y'
|
||||
where M_DoctorIsActive = 'Y' and
|
||||
( M_DoctorPJID is not null ) ";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => count($rows) , "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and M_DoctorName 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_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DoctorID, M_DoctorIsDefault, IF(M_DoctorPJID IS NULL, 'Y', 'N') M_DoctorIsPJ,
|
||||
fn_global_doctor_name(M_DoctorID) as M_DoctorName, fn_fo_delivery_code('DOCTOR', 'EMAIL', 0) as delivery_email_code,
|
||||
IF(M_DoctorEmail IS NULL OR M_DoctorEmail = '', 'N', M_DoctorEmailIsDefault) email_default,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID, 'delivery_default', M_DoctorAddressDeliveryDefault, 'delivery_code', fn_fo_delivery_code('DOCTOR', 'ADDRESS', M_DoctorAddressID)) SEPARATOR ','), ']'), '[]') as address,
|
||||
M_DoctorNote
|
||||
from m_doctor
|
||||
left join m_doctoraddress on M_DoctorAddressIsActive = 'Y'
|
||||
and M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
left join m_doctorpj on M_DoctorPJM_DoctorID = M_DoctorID and M_DoctorPjIsactive = 'Y'
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) like ?
|
||||
group by M_DoctorID
|
||||
limit 100";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
join (
|
||||
select distinct M_DoctorAddressM_DoctorID
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressIsActive = 'Y'
|
||||
) ma on M_DoctorID = M_DoctorAddressM_DoctorID
|
||||
where M_DoctorIsActive = 'Y' and M_DoctorName like ? ";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_DoctorID,M_DoctorName
|
||||
from
|
||||
m_doctor
|
||||
join (
|
||||
select distinct M_DoctorAddressM_DoctorID
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressIsActive = 'Y'
|
||||
) ma on M_DoctorID = M_DoctorAddressM_DoctorID
|
||||
where M_DoctorIsActive = 'Y' and M_DoctorName like ?
|
||||
limit 0,10";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$rows = $query->result_array();
|
||||
$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$prm = $prm['data'];
|
||||
|
||||
$q = [
|
||||
'name' => isset($prm['name']) ? $prm['name'] : '',
|
||||
'prefix1' => isset($prm['prefix1']) ? $prm['prefix1'] : '',
|
||||
'prefix2' => isset($prm['prefix2']) ? $prm['prefix2'] : '',
|
||||
'sufix1' => isset($prm['sufix1']) ? $prm['sufix1'] : '',
|
||||
'sufix2' => isset($prm['sufix2']) ? $prm['sufix2'] : '',
|
||||
'sufix3' => isset($prm['sufix3']) ? $prm['sufix3'] : '',
|
||||
'sex' => isset($prm['sex']) ? $prm['sex'] : '0',
|
||||
'hp' => isset($prm['hp']) ? $prm['hp'] : '',
|
||||
'note' => isset($prm['note']) ? $prm['note'] : '',
|
||||
'address' => isset($prm['address']) ? $prm['address'] : '',
|
||||
'province' => isset($prm['province']) ? $prm['province'] : '',
|
||||
'city' => isset($prm['city']) ? $prm['city'] : '',
|
||||
'district' => isset($prm['district']) ? $prm['district'] : '',
|
||||
'village' => isset($prm['village']) ? $prm['village'] : ''
|
||||
];
|
||||
|
||||
$sql = "INSERT INTO m_doctor(M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$q['prefix1'], $q['prefix2'], $q['name'], $q['sufix1'], $q['sufix2'], $q['sufix3'], $q['sex'], $q['hp'], $q['note']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
$sql = "INSERT INTO m_doctoraddress(M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID)
|
||||
VALUES(?, 'Utama', ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$id, $q['address'], $q['village']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$result = $this->get_one($id);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("DOCTOR SAVE", $this->db_smartone);
|
||||
}
|
||||
|
||||
private function get_one($id)
|
||||
{
|
||||
$sql = "SELECT M_DoctorID, M_DoctorIsDefault, 'N' M_DoctorIsPJ,
|
||||
fn_global_doctor_name(M_DoctorID) as M_DoctorName, M_DoctorName M_DoctorRealName,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID) SEPARATOR ','), ']'), '[]') as address
|
||||
FROM m_doctor
|
||||
LEFT JOIN m_doctoraddress ON M_DoctorAddressM_DoctorID = M_DoctorID AND M_DoctorAddressIsActive = 'Y'
|
||||
WHERE M_DoctorID = ?";
|
||||
$query = $this->db_smartone->query($sql, $id);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->result_array();
|
||||
foreach ($row as $k => $v)
|
||||
$row[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$result = array("total" => 1, "records" => $row, "total_display" => 1);
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID, T_OrderHeaderDate, T_OrderHeaderLabNumber,
|
||||
GROUP_CONCAT(T_OrderDetailT_TestName SEPARATOR ', ') T_TestName
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
WHERE T_OrderHeaderM_PatientID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_OrderHeaderID
|
||||
ORDER BY T_OrderHeaderDate DESC
|
||||
LIMIT 5";
|
||||
$query = $this->db_onedev->query($sql, [$prm['patient_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Patient History count", $this->db_onedev);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
class Language extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_lang
|
||||
where M_LangIsActive = 'Y'
|
||||
and M_LangName 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_lang count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_LangID as id, M_LangName as name
|
||||
from m_lang
|
||||
where M_LangIsActive = 'Y'
|
||||
and M_LangName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows_ = [];
|
||||
$si = [["is_si" => "N", "si_text" => ""], ["is_si" => "Y", "si_text" => "(SI)"]];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
foreach ($si as $l => $w)
|
||||
{
|
||||
$v['is_si'] = $w['is_si'];
|
||||
$v['name'] .= $w['si_text'] == '' ? '' : ' ' . $w['si_text'];
|
||||
$v['key'] = $v['id'] . '-' . $v['is_si'];
|
||||
$rows_[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows_, "total_display" => sizeof($rows_));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$rows = array();
|
||||
$rows[] = array("id" =>"ID", "name" => "Bahasa Indonesia");
|
||||
$rows[] = array("id" =>"EN", "name" => "Bahasa Inggris");
|
||||
$rows[] = array("id" =>"CH", "name" => "Bahasa Mandarin");
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
117
one-api/application/controllers/mockup/fo/registration/Order.php
Normal file
117
one-api/application/controllers/mockup/fo/registration/Order.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?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("onedev", true);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$hdr = $prm['header'];
|
||||
$header_json = addslashes(str_replace('\n', '\\\n', json_encode($hdr)));
|
||||
$detail_json = str_replace('\n', '\\\n', json_encode($prm['detail']));
|
||||
$delivery_json = addslashes(str_replace('\n', '\\\n', json_encode($prm['delivery'])));
|
||||
|
||||
$req_json = json_encode($prm['req']);
|
||||
|
||||
$sql = "CALL sp_fo_register_save('{$prm['order_id']}', '{$header_json}', '{$delivery_json}', '{$detail_json}', '{$req_json}', '{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
$x = preg_match("/janji hasi/", $rst->message);
|
||||
if ($x)
|
||||
$rst->message = "Masih ada pemeriksaan yang BELUM DISET JANJI HASILNYA !";
|
||||
$rst->message = ["text"=>$rst->message, "query"=>$this->db_smartone->last_query()];
|
||||
// pe : add broadcast notification
|
||||
$this->broadcast("fo-register");
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function load_from_clinic()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_clinic_load('{$prm['queue']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
$rst->data->doctor->address = $rst->data->doctor_address;
|
||||
unset($rst->data->doctor_address);
|
||||
|
||||
$rst->data->company->mou = [$rst->data->mou];
|
||||
unset($rst->data->mou);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_register_load('{$prm['id']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
$rst->data->doctor->address = $rst->data->doctor_address;
|
||||
unset($rst->data->doctor_address);
|
||||
|
||||
$rst->data->company->mou = [$rst->data->mou];
|
||||
unset($rst->data->mou);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
<?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("onedev", true);
|
||||
}
|
||||
function _add_address(&$pat) {
|
||||
if (count($pat) == "0") {
|
||||
return array();
|
||||
}
|
||||
foreach($pat as $idx => $p ) {
|
||||
$pat[$idx]["address"] = array($p["M_PatientAddress"]);
|
||||
}
|
||||
$this->_add_history($pat);
|
||||
}
|
||||
function _add_history(&$pat) {
|
||||
$pat_list = "-1";
|
||||
foreach($pat as $idx => $p) {
|
||||
$pat_list .= ", " . $p["M_PatientID"];
|
||||
if (! isset($pat[$idx]["history"])) $pat[$idx]["history"] = array();
|
||||
}
|
||||
$sql = "select T_OrderHeaderM_PatientID,T_OrderHeaderLabNumber,T_OrderHeaderDate,
|
||||
concat(T_OrderDetailT_TestName) T_TestName
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderdetail on
|
||||
T_OrderHeaderID = T_OrderDetailID and
|
||||
T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderM_PatientID in ( $pat_list )
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
order by T_OrderHeaderM_PatientID,T_OrderHeaderLabNumber";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$patientID = $r["T_OrderHeaderM_PatientID"];
|
||||
foreach($pat as $idx => $p) {
|
||||
if($p["M_PatientID"] == $patientID) {
|
||||
$pat[$idx]["history"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_patient history",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'noreg' => '%',
|
||||
'name' => '%',
|
||||
'hp' => '%',
|
||||
'dob' => '%',
|
||||
'address' => '%'
|
||||
];
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "%{$prm['noreg']}%";
|
||||
|
||||
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(distinct m_patientid) total
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
and M_PatientAddressDescription LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob'], $q['address']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientName M_PatientRealName, M_TitleID, M_TitleName, M_SexID, M_SexName,
|
||||
M_PatientHP, M_PatientPOB, M_PatientDOB, M_PatientNote,
|
||||
concat(M_PatientAddressDescription, '\n\n', m_kelurahanname, ', ', m_districtname,
|
||||
'\n', m_cityname, ', ', m_provincename) as M_PatientAddress,
|
||||
M_PatientAddressDescription, M_PatientM_IdTypeID, M_PatientIDNumber,
|
||||
IFNULL(M_PatientNote, '') M_PatientNote, M_PatientPhoto, IF(M_PatientPhone IS NULL OR M_PatientPhone = '', M_PatientHP, M_PatientPhone) hp,
|
||||
fn_fo_patient_visit(M_PatientID) info,
|
||||
M_KelurahanID, M_DistrictID, M_CityID, M_ProvinceID, M_PatientM_ReligionID,
|
||||
IFNULL(M_ReligionName, '-') M_ReligionName
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_sex on M_PatientM_SexID = M_SexID
|
||||
join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
left join m_district on m_kelurahanm_districtid = m_districtid
|
||||
left join m_city on m_districtm_cityid = m_cityid
|
||||
left join m_province on m_citym_provinceid = m_provinceid
|
||||
left join m_religion on m_patientm_religionid = m_religionid
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
and M_PatientAddressDescription LIKE ?
|
||||
group by m_patientid
|
||||
limit 0,{$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob'], $q['address']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['info'] = json_decode($v['info']);
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function add_new()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
|
||||
//sipe
|
||||
$M_IdTypeID = 0;
|
||||
if( $prm['M_PatientM_IdTypeID'] > 0 ) {
|
||||
$M_IdTypeID = $prm['M_PatientM_IdTypeID'];
|
||||
}
|
||||
$ptn = [
|
||||
'M_PatientName' => $prm['M_PatientName'],
|
||||
'M_PatientM_TitleID' => $prm['M_PatientM_TitleID'],
|
||||
'M_PatientSuffix' => $prm['M_PatientSuffix'],
|
||||
'M_PatientM_SexID' => $prm['M_PatientM_SexID'],
|
||||
'M_PatientM_ReligionID' => $prm['M_PatientM_ReligionID'],
|
||||
'M_PatientDOB' => $prm['M_PatientDOB'],
|
||||
'M_PatientPOB' => $prm['M_PatientPOB'],
|
||||
'M_PatientHP' => $prm['M_PatientHP'],
|
||||
'M_PatientPhone' => $prm['M_PatientPhone'],
|
||||
'M_PatientEmail' => $prm['M_PatientEmail'],
|
||||
'M_PatientM_IdTypeID' => $M_IdTypeID ,
|
||||
'M_PatientIDNumber' => $prm['M_PatientIDNumber'],
|
||||
'M_PatientNote' => $prm['M_PatientNote']
|
||||
];
|
||||
$this->db_smartone->insert('m_patient', $ptn);
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
// LOG FO
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADD', '{$ptn}', '0')");
|
||||
|
||||
// save address
|
||||
$add = [
|
||||
'M_PatientAddressM_PatientID' => $id,
|
||||
'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
];
|
||||
$this->db_smartone->insert('m_patientaddress', $add);
|
||||
|
||||
// LOG FO
|
||||
$add = json_encode($add);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.ADD', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
|
||||
$this->db_smartone->set('M_PatientName', $prm['M_PatientName'])
|
||||
->set('M_PatientM_TitleID', $prm['M_PatientM_TitleID'])
|
||||
->set('M_PatientSuffix', $prm['M_PatientSuffix'])
|
||||
->set('M_PatientM_SexID', $prm['M_PatientM_SexID'])
|
||||
->set('M_PatientM_ReligionID', $prm['M_PatientM_ReligionID'])
|
||||
->set('M_PatientDOB', $prm['M_PatientDOB'])
|
||||
->set('M_PatientPOB', $prm['M_PatientPOB'])
|
||||
->set('M_PatientHP', $prm['M_PatientHP'])
|
||||
->set('M_PatientPhone', $prm['M_PatientPhone'])
|
||||
->set('M_PatientEmail', $prm['M_PatientEmail'])
|
||||
->set('M_PatientM_IdTypeID', $prm['M_PatientM_IdTypeID'])
|
||||
->set('M_PatientIDNumber', $prm['M_PatientIDNumber'])
|
||||
->set('M_PatientNote', $prm['M_PatientNote'])
|
||||
->where('M_PatientID', $prm['id'])
|
||||
->update('m_patient');
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $prm['id'];
|
||||
|
||||
// LOG FO
|
||||
unset($prm['token']);
|
||||
$ptn = json_encode($prm);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.EDIT', '{$ptn}', '{$this->sys_user['M_UserID']}')");
|
||||
|
||||
// save address
|
||||
// $add = [
|
||||
// 'M_PatientAddressM_PatientID' => $id,
|
||||
// 'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
// 'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
// ];
|
||||
$this->db_smartone->set('M_PatientAddressM_KelurahanID', $prm['M_PatientAddressM_KelurahanID'])
|
||||
->set('M_PatientAddressDescription', $prm['M_PatientAddressDescription'])
|
||||
->where('M_PatientAddressM_PatientID', $id)
|
||||
->where('M_PatientAddressNote', 'Utama')
|
||||
->where('M_PatientAddressIsactive', 'Y')
|
||||
->update('m_patientaddress');
|
||||
|
||||
// LOG FO
|
||||
$add = $this->db_smartone->last_query();
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.EDIT', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
|
||||
public function search_idtype()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_IdTypeID, M_IdTypeName
|
||||
FROM m_idtype
|
||||
WHERE M_IdTypeIsActive = 'Y'
|
||||
ORDER BY M_IdTypeName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_idtype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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 Patientaddress extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select M_PatientAddressID, M_PatientAddressNote,
|
||||
M_PatientAddressDescription, M_KelurahanName as M_KelurahanName
|
||||
from m_patientaddress
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
where m_patientaddressm_patientid = ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['patient_id']));
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("status" => "OK", "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function get_order() {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$rst = ["order_header"=>[], "order_detail"=>[], "order_delivery"=>[]];
|
||||
|
||||
$sql = "
|
||||
select T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumber as order_no,
|
||||
T_OrderHeaderDate as order_date,
|
||||
T_OrderHeaderSubTotal as order_subtotal,
|
||||
T_OrderHeaderRounding as order_rounding,
|
||||
T_OrderHeaderTotal as order_total,
|
||||
concat(if(M_TitleID is null, '', concat(M_TitleName, ' ')), M_PatientName) as patient_name,
|
||||
M_PatientNoReg as patient_mr,
|
||||
M_MouName as order_mou,
|
||||
M_CompanyName as order_company,
|
||||
fn_global_doctor_name(da.M_DoctorID) doctor_sender,
|
||||
fn_global_doctor_name(db.M_DoctorID) doctor_pj,
|
||||
fn_global_doctor_address(aa.M_DoctorAddressID, 1) doctor_sender_address,
|
||||
M_MouIsBill M_CompanyIsBill, M_MouMinDP M_CompanyMinDP,
|
||||
M_MouIsAgingOnHold M_CompanyIsAgingOnHold, M_MouIsAgingOnHoldNote M_CompanyIsAgingOnHoldNote
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join m_doctor da on T_OrderHeaderSenderM_DoctorID = da.M_DoctorID
|
||||
join m_doctoraddress aa on T_OrderHeaderSenderM_DoctorAddressID = aa.M_DoctorAddressID
|
||||
join m_doctor db on T_OrderHeaderSenderM_DoctorID = db.M_DoctorID
|
||||
left join m_title on m_patientm_titleid = m_titleid
|
||||
where T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = (array) $query->row();
|
||||
$rst['order_header'] = $rows;
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "CALL sp_fo_payment_get_delivery('{$prm['id']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$rst['order_delivery'] = json_decode($rows->delivery);
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress delivery ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
// T_OrderDetailPrice double [0]
|
||||
// T_OrderDetailPriceForDisc double [0]
|
||||
// T_OrderDetailDisc double [0]
|
||||
// T_OrderDetailDiscAmount double [0]
|
||||
// T_OrderDetailTotal
|
||||
|
||||
$sql = "
|
||||
select T_OrderDetailID as d_id,
|
||||
T_OrderDetailT_TestID as t_id,
|
||||
IFNULL(T_OrderDetailT_TestName, T_PacketName) as t_name,
|
||||
T_OrderDetailPrice as t_price,
|
||||
T_OrderDetailDiscTotal as t_disctotal,
|
||||
T_OrderDetailTotal as t_total
|
||||
from t_orderdetail
|
||||
join t_orderdetailaddon on T_OrderDetailAddOnT_OrderDetailID = T_OrderDetailID
|
||||
left join t_test on t_orderdetailt_testid = t_testid
|
||||
left join t_packet on t_orderdetailaddonispacket = 'Y' and t_orderdetailaddont_packetid = t_packetid
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_ORderDetailIsActive = 'Y'
|
||||
and ((T_ORderDetailAddOnIsPacket = 'N' AND T_TestIsPrintNota = 'Y' AND T_OrderDetailT_TestIsPanelChildren = 'N')
|
||||
OR (T_OrderDetailT_TestIsPanelChildren = 'Y' AND T_OrderDetailT_TestIsPanelChildrenPrintNota = 'Y')
|
||||
OR (T_ORderDetailAddOnIsPacket = 'Y' AND T_PacketIsNOta = 'Y'))";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rst['order_detail'] = $rows;
|
||||
|
||||
$result = array("status" => "OK" , "data" => $rst);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName 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_paymenttype count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_PaymentTypeID payment_type_id, M_PaymentTypeName payment_type_name, M_PaymentTypeCode payment_type_code,
|
||||
0 payment_amount, '' payment_note, 'Nomor Kartu' payment_note_label, 'N' payment_enable,
|
||||
0 payment_change, 0 payment_actual, 0 payment_card_id, 0 payment_edc_id, 0 payment_account_id
|
||||
from m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v) {
|
||||
|
||||
if ($v['payment_type_code'] == 'CASH')
|
||||
$v['payment_note_label'] = 'Kembali';
|
||||
if ($v['payment_type_code'] == 'VOUCHER')
|
||||
$v['payment_note_label'] = 'Nomor Voucher';
|
||||
|
||||
$rows[$k] = $v;
|
||||
}
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$payment_json = json_encode($prm['payments']);
|
||||
|
||||
$sql = "CALL sp_fo_payment('{$prm['order_id']}', '{$payment_json}', '{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save payment", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_bank()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT Nat_BankID, Nat_BankName
|
||||
FROM nat_bank ORDER BY Nat_BankName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows, "total"=>sizeof($rows)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("NAT BANK",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
143
one-api/application/controllers/mockup/fo/registration/Photo.php
Normal file
143
one-api/application/controllers/mockup/fo/registration/Photo.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/project/one/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/patient/" . date("Y") . "/";
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
$p = $this->db_smartone->select("M_PatientNoReg")
|
||||
->where("M_PatientID", $inp['id'])
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_PatientNoReg . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
$this->db_smartone->set("M_PatientPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
->set("M_PatientPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
->set('M_PatientPhotoCounter', '`M_PatientPhotoCounter` + 1', false)
|
||||
->where('M_PatientID', $inp['id'])
|
||||
->update('m_patient');
|
||||
|
||||
// LOGGING
|
||||
$code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
$one_log = $this->load->database('onelog', true);
|
||||
$one_log->set('Log_PhotoCode', $code)
|
||||
->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
->insert('log_photo');
|
||||
|
||||
$this->sys_ok(["rename"=>$y, "patient_id"=>$inp['id'], "patient_mr"=>$p->M_PatientNoReg, "photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
$r = $this->db_smartone->select('m_patientphoto, m_patientphotocounter', false)
|
||||
->where('m_patientid', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
if ($r->m_patientphoto != null && $r->m_patientphotocounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->m_patientphoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->m_patientphotocounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
421
one-api/application/controllers/mockup/fo/registration/Px.php
Normal file
421
one-api/application/controllers/mockup/fo/registration/Px.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
//diberi tambahan pembeda IsFromPanel
|
||||
//utk contoh kasus yg ndak bisa di delete
|
||||
//sementara profile di ambilkan dari panel juga dengan IsFromPanel = N
|
||||
class Px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Px API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_ref_test(&$rows) {
|
||||
$ids = "-1";
|
||||
foreach($rows as $idx => $r) {
|
||||
$ids .= "," . $r["T_TestID"];
|
||||
if (! $rows[$idx]["ref_test"] ) $rows[$idx]["ref_test"] == array();
|
||||
}
|
||||
$sql="select T_TestID,T_RefTestName, T_TestName
|
||||
from
|
||||
t_reftest
|
||||
join t_test on T_RefTestID = T_TestT_RefTestID
|
||||
and T_RefTestIsActive = 'Y'
|
||||
where T_TestID in ( $ids )";
|
||||
|
||||
|
||||
}
|
||||
public function profile()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mou_id = $prm["mou_id"];
|
||||
$max_rst = 8;
|
||||
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(distinct T_ProfileID) total
|
||||
from t_profile
|
||||
join t_profiledetail on t_profileid = t_profiledetailt_profileid
|
||||
and t_profiledetailisactive = 'Y'
|
||||
where t_profilename like ?";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->row()->total;
|
||||
} else {
|
||||
$this->sys_error_db("Test Profile count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_ProfileID, T_ProfileName, CONCAT('[', GROUP_CONCAT( JSON_OBJECT('T_TestID', T_TestID, 'T_TestName', T_TestName, 'T_TestRequirement', T_TestRequirement) SEPARATOR ','), ']') detail
|
||||
from t_profile
|
||||
join t_profiledetail on t_profileid = t_profiledetailt_profileid
|
||||
and t_profiledetailisactive = 'Y'
|
||||
join t_test on t_profiledetailt_testid = t_testid
|
||||
where t_profilename like ?
|
||||
group by t_profileid
|
||||
limit 0, $max_rst";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $r)
|
||||
{
|
||||
$err = 0;
|
||||
$detail = json_decode($r['detail']);
|
||||
foreach ($detail as $l => $w)
|
||||
{
|
||||
$sql_param = array($w->T_TestID, date('Y-m-d'), 'N', $mou_id);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$price = json_decode($query->row()->price);
|
||||
|
||||
$detail[$l]->T_PriceAmount = $price->test_price;
|
||||
$detail[$l]->T_PriceDisc = $price->test_disc;
|
||||
$detail[$l]->T_PriceDiscRp = $price->test_discrp;
|
||||
$detail[$l]->T_PriceID = $price->price_id;
|
||||
$detail[$l]->T_PriceIsCito = "N";
|
||||
$detail[$l]->T_PriceM_CompanyID = $price->company_id;
|
||||
$detail[$l]->T_PriceM_MouID = $price->mou_id;
|
||||
$detail[$l]->T_PriceOther = $price->test_other;
|
||||
$detail[$l]->T_PriceSubTotal = $price->test_subtotal;
|
||||
$detail[$l]->T_PriceT_TestID = $price->test_id;
|
||||
$detail[$l]->T_PriceTotal = $price->test_total;
|
||||
|
||||
if ($price->test_price == 0)
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
$rows[$k]['detail'] = $detail;
|
||||
$rows[$k]['err'] = $err;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function panel() {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
$sql = "select count(distinct T_TestPanelID) total
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ? ";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_testpanel count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ?
|
||||
limit 0,20";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$xrows = $query->result_array();
|
||||
$a_tpid = "-1";
|
||||
foreach($xrows as $r) {
|
||||
$a_tpid .= "," . $r["T_TestPanelID"];
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID,T_TestPanelName,
|
||||
T_TestID,T_TestName, 'Y' IsFromPanel,T_TestRequirement,
|
||||
t_testprice.*
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelID in ( $a_tpid )
|
||||
order by T_TestPanelID";
|
||||
$query = $this->db_smartone->query($sql,array($mouCompanyID));
|
||||
$xrows = $query->result_array();
|
||||
$rows = array();
|
||||
$prev_tpanel_id = 0;
|
||||
foreach($xrows as $r) {
|
||||
$tpanel_id = $r["T_TestPanelID"];
|
||||
if ($tpanel_id != $prev_tpanel_id) {
|
||||
$rows[] = array(
|
||||
"T_TestPanelID" => $r["T_TestPanelID"],
|
||||
"T_TestPanelName" => $r["T_TestPanelName"],
|
||||
"test" => array()
|
||||
);
|
||||
}
|
||||
$idx = count($rows) - 1;
|
||||
$rows[$idx]["test"][] = $r;
|
||||
$prev_tpanel_id = $tpanel_id;
|
||||
}
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count_v2(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($prm['order_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byorder_v2(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
else if (isset($prm['clinic_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byclinic(?, ?)", [$prm['clinic_id'], $mouCompanyID]);
|
||||
else if ($search == "")
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_favorite_v2(?, ?)", $sql_param);
|
||||
else
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_v2(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows, "query" => $sqlx, "query2" => $sqly );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($prm['order_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byorder(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
else if (isset($prm['clinic_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byclinic(?, ?)", [$prm['clinic_id'], $mouCompanyID]);
|
||||
else if ($search == "")
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_favorite(?, ?)", $sql_param);
|
||||
else
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows, "query" => $sqlx, "query2" => $sqly );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_id'], date('Y-m-d'), $prm['cito'], $prm['mou_id']);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = json_decode($r['price']);
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get price", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function get_appx_schedule()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_ids'], $prm['panel_ids']);
|
||||
$sql = "select fn_fo_find_promise_by_px(?, ?) as x";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = $r['x'];
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get schedule", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_cito()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_CitoID, Nat_CitoName, Nat_CitoIsDefault
|
||||
FROM nat_cito WHERE Nat_CitoIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("CITO", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user