3646 lines
125 KiB
PHP
3646 lines
125 KiB
PHP
<?php
|
|
class Anamnesedoctor extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
var $IP_SOCKET_IO;
|
|
var $db_oneklinik;
|
|
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);
|
|
$this->load->library('ibl_encryptor');
|
|
$this->IP_SOCKET_IO = "localhost";
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
|
|
$sql = "SELECT orderID,
|
|
orderIsReopen,
|
|
orderReOpenM_DoctorID,
|
|
orderDate,
|
|
orderNumber,
|
|
orderIsAnamnese,
|
|
orderIsCheck,
|
|
orderAge as patient_age,
|
|
DATE_FORMAT(orderDate,'%d-%m-%Y') as order_date,
|
|
'N' divider,
|
|
M_PatientID,
|
|
M_PatientNoReg,
|
|
M_PatientPhoto,
|
|
M_PatientPhotoThumb,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientName_enc,
|
|
M_PatientSuffix,
|
|
M_PatientHP,
|
|
M_PatientHP_enc,
|
|
M_PatientEmail,
|
|
M_PatientEmail_enc,
|
|
M_PatientPOB,
|
|
M_PatientPOB_enc,
|
|
M_PatientPhone,
|
|
M_PatientPhone_enc,
|
|
M_PatientIDNumber,
|
|
M_PatientIDNumber_enc,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
|
M_PatientDOB_enc,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientNIK_enc,
|
|
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,
|
|
M_PatientAddressRegionalCd,
|
|
M_PatientAddressDescription,
|
|
M_PatientAddressDescription_enc,
|
|
0 M_DistrictID,
|
|
0 M_CityID,
|
|
0 M_ProvinceID
|
|
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) {
|
|
$enc = $this->ibl_encryptor;
|
|
$rows[$k]['M_PatientName'] = $enc->decrypt($v['M_PatientName_enc'] ?? '') ?: stripslashes($v['M_PatientName']);
|
|
$rows[$k]['M_PatientHP'] = $enc->decrypt($v['M_PatientHP_enc'] ?? '') ?: $v['M_PatientHP'];
|
|
$rows[$k]['M_PatientEmail'] = $enc->decrypt($v['M_PatientEmail_enc'] ?? '') ?: $v['M_PatientEmail'];
|
|
$rows[$k]['M_PatientPOB'] = $enc->decrypt($v['M_PatientPOB_enc'] ?? '') ?: $v['M_PatientPOB'];
|
|
$rows[$k]['M_PatientPhone'] = $enc->decrypt($v['M_PatientPhone_enc'] ?? '') ?: $v['M_PatientPhone'];
|
|
$rows[$k]['M_PatientIDNumber'] = $enc->decrypt($v['M_PatientIDNumber_enc'] ?? '') ?: $v['M_PatientIDNumber'];
|
|
$rows[$k]['M_PatientDOB'] = $enc->decrypt($v['M_PatientDOB_enc'] ?? '') ?: $v['M_PatientDOB'];
|
|
$rows[$k]['M_PatientNIK'] = $enc->decrypt($v['M_PatientNIK_enc'] ?? '') ?: $v['M_PatientNIK'];
|
|
$rows[$k]['M_PatientAddressDescription'] = $enc->decrypt($v['M_PatientAddressDescription_enc'] ?? '') ?: stripslashes($v['M_PatientAddressDescription'] ?? '');
|
|
|
|
$reg_cd = $v['M_PatientAddressRegionalCd'] ?? '';
|
|
if ($reg_cd) {
|
|
$reg = $this->db_onedev->query(
|
|
"SELECT r_kel.regional_nm as kel_name, r_kec.regional_nm as kec_name, r_kab.regional_nm as kab_name, r_pro.regional_nm as pro_name
|
|
FROM regional r_kel
|
|
LEFT JOIN regional r_kec ON r_kec.regional_cd = CONCAT(r_kel.pro_cd, r_kel.kab_cd, r_kel.kec_cd, '000')
|
|
LEFT JOIN regional r_kab ON r_kab.regional_cd = CONCAT(r_kel.pro_cd, r_kel.kab_cd, '000', '000')
|
|
LEFT JOIN regional r_pro ON r_pro.regional_cd = CONCAT(r_kel.pro_cd, '00', '000', '000')
|
|
WHERE r_kel.regional_cd = ?", [$reg_cd]
|
|
)->row_array();
|
|
$rows[$k]['M_PatientAddress'] = $rows[$k]['M_PatientAddressDescription'] . "\n\n" .
|
|
implode(', ', array_filter([$reg['kel_name'] ?? '', $reg['kec_name'] ?? '', $reg['kab_name'] ?? '', $reg['pro_name'] ?? '']));
|
|
} else {
|
|
$rows[$k]['M_PatientAddress'] = $rows[$k]['M_PatientAddressDescription'];
|
|
}
|
|
|
|
$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" => 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;
|
|
}
|
|
}
|
|
|
|
|
|
function get_data()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$result = array('data' => '');
|
|
|
|
if ($prm['type_field'] == 'TEXT') {
|
|
if ($prm['selected_doctor_tab']['id'] == 'VITAL' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderDoctorVitalSign,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'FISIK') {
|
|
$sql = "SELECT IFNULL(orderDoctorFisik,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'RECEIPT') {
|
|
$sql = "SELECT IFNULL(orderDoctorReceipt,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER') {
|
|
$sql = "SELECT IFNULL(orderDoctorDiagnosePrimer,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER') {
|
|
$sql = "SELECT IFNULL(orderDoctorDiagnoseSekunder,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'MEDIC' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderDoctorMedic,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'SARAN') {
|
|
$sql = "SELECT IFNULL(orderDoctorSaran,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'TEXT' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'ADDITIONAL') {
|
|
$sql = "SELECT Nat_GroupID as id, Nat_GroupName as name
|
|
FROM nat_group
|
|
WHERE
|
|
Nat_GroupIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
}
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get nat_group");
|
|
exit;
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] != 'ADDITIONAL') {
|
|
$rst = $query->row_array();
|
|
if ($rst) {
|
|
$result['data'] = $rst['value'];
|
|
} else {
|
|
$result['data'] = '';
|
|
}
|
|
|
|
$sql = "SELECT * ,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order
|
|
JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderIsActive = 'Y' AND orderID = ?";
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order information");
|
|
exit;
|
|
}
|
|
$order_info = $query->row_array();
|
|
if ($order_info['orderIsReopen'] == 'Y' && ( $prm['selected_doctor_tab']['id'] != 'VITAL' || $prm['selected_doctor_tab']['id'] == 'ADDITIONAL')) {
|
|
$data_value_combine = array();
|
|
$data_value_combine[] = array('doctor' => $order_info['doctor_name'],'value' => $result['data']);
|
|
$sql = "SELECT *, CONCAT(code,' | ', display) as display_name, IFNULL(display,'X') as status_icd10
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
LEFT JOIN one_terminology.terminology ON code = orderDoctorAdditionalICD10Code AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = ? AND
|
|
orderDoctorAdditionalReOpenCount < ? AND
|
|
orderDoctorAdditionalIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid'],$prm['selected_doctor_tab']['id'],$order_info['orderReOpenCount']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order addditional");
|
|
exit;
|
|
}
|
|
|
|
$order_additionals = $query->result_array();
|
|
if($order_additionals){
|
|
foreach ($order_additionals as $key => $valueadd) {
|
|
$data_value_combine[] = array('doctor' => $valueadd['M_DoctorName'],'value' => $valueadd['orderDoctorAdditionalValue']);
|
|
|
|
if($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER' || $prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER'){
|
|
if($valueadd['status_icd10'] != 'X')
|
|
$result['icd10'] = $valueadd;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
$result['data'] = $data_value_combine;
|
|
$result_now = "";
|
|
$sql = "SELECT *, CONCAT(code,' | ', display) as display_name, IFNULL(display,'X') as status_icd10
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
LEFT JOIN one_terminology.terminology ON code = orderDoctorAdditionalICD10Code AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = ? AND
|
|
orderDoctorAdditionalReOpenCount = ? AND
|
|
orderDoctorAdditionalIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid'],$prm['selected_doctor_tab']['id'],$order_info['orderReOpenCount']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order addditional now");
|
|
exit;
|
|
}
|
|
|
|
$order_additional_now = $query->row_array();
|
|
if($order_additional_now)
|
|
$result_now = $order_additional_now['orderDoctorAdditionalValue'];
|
|
|
|
$result['value'] = $result_now;
|
|
if($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER' || $prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER'){
|
|
if($valueadd['status_icd10'] != 'X')
|
|
$result['icd10'] = $order_additional_now;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] === 'ADDITIONAL') {
|
|
$group_tests = $query->result_array();
|
|
if ($group_tests) {
|
|
$result['group_tests'] = $group_tests;
|
|
$group_id = $group_tests[0]['id'];
|
|
$result['subgroups'] = $this->get_subgroup($group_id);
|
|
$result['tests'] = $this->get_tests($group_id, [], '');
|
|
|
|
//$mouID = $this->getMouID();
|
|
$sql = "SELECT settingM_MouID as id
|
|
FROM one_klinik.setting
|
|
WHERE
|
|
settingIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get setting");
|
|
return 0;
|
|
}
|
|
|
|
$mouID = $query->row()->id;
|
|
|
|
$result['selected_test'] = $this->getSelectedTest($prm['orderid'], $mouID);
|
|
} else {
|
|
$result['data'] = '';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'VITAL' && $prm['type_field'] == 'FORM') {
|
|
$sql = "SELECT IFNULL(orderDoctorVitalSign,'') as value
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = 'FORM' AND orderDoctorIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get orderDoctorVitalSign FORM");
|
|
exit;
|
|
}
|
|
|
|
$data_vital = $query->row_array();
|
|
if ($data_vital) {
|
|
$jsonData = stripslashes(html_entity_decode($data_vital['value']));
|
|
$vital_sign = json_decode($jsonData, true);
|
|
$result['data'] = $vital_sign;
|
|
} else {
|
|
$result['data'] = $this->get_form_vital($prm['orderid']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER' && $order_info['orderIsReopen'] == 'N') {
|
|
$result['icd10'] = array();
|
|
$xcount = $this->check_exist_icd10_row($prm['orderid']);
|
|
//echo $xcount;
|
|
if ($xcount > 0) {
|
|
$sql = "SELECT terminology.*, CONCAT(code,' | ', display) as display_name
|
|
FROM one_klinik.order_diagnose_icd10
|
|
JOIN one_terminology.terminology ON code = orderDiagnoseIcd10Primary AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order_diagnose_icd10");
|
|
exit;
|
|
}
|
|
|
|
$result['icd10'] = $query->row_array();
|
|
}
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER' && $order_info['orderIsReopen'] == 'N') {
|
|
$result['icd10'] = array();
|
|
$xcount = $this->check_exist_icd10_row($prm['orderid']);
|
|
//echo $xcount;
|
|
if ($xcount > 0) {
|
|
$sql = "SELECT terminology.*, CONCAT(code,' | ', display) as display_name
|
|
FROM one_klinik.order_diagnose_icd10
|
|
JOIN one_terminology.terminology ON code = orderDiagnoseIcd10Primary AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order_diagnose_icd10");
|
|
exit;
|
|
}
|
|
|
|
$result['icd10'] = $query->row_array();
|
|
}
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER' && $order_info['orderIsReopen'] == 'N') {
|
|
$result['icd10'] = array();
|
|
$xcount = $this->check_exist_icd10_row($prm['orderid']);
|
|
if ($xcount > 0) {
|
|
$sql = "SELECT terminology.*, CONCAT(code,' | ', display) as display_name
|
|
FROM one_klinik.order_diagnose_icd10
|
|
JOIN one_terminology.terminology ON code = orderDiagnoseIcd10Sekunder AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order_diagnose_icd10");
|
|
exit;
|
|
}
|
|
|
|
$result['icd10'] = $query->row_array();
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT M_DoctorID as id,
|
|
M_DoctorMcuDefaultKlinik as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM m_doctormcu
|
|
JOIN m_doctor ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
M_DoctorMcuIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get doctors");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$result['doctors'] = $query->result_array();
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE
|
|
orderIsActive = 'Y' AND orderID = ?";
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order information");
|
|
exit;
|
|
}
|
|
|
|
$order_info = $query->row_array();
|
|
|
|
if($order_info['orderIsReopen'] == 'N'){
|
|
$sql = "SELECT IFNULL(M_DoctorID,0) as id,
|
|
IFNULL(M_DoctorMcuDefaultKlinik,'N') as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',IFNULL(M_DoctorName,''),' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM one_klinik.order
|
|
LEFT JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctormcu ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderID = ?";
|
|
}else{
|
|
$sql = "SELECT IFNULL(M_DoctorID,0) as id,
|
|
IFNULL(M_DoctorMcuDefaultKlinik,'N') as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',IFNULL(M_DoctorName,''),' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM one_klinik.order
|
|
LEFT JOIN m_doctor ON orderReOpenM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctormcu ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderID = ?";
|
|
}
|
|
|
|
$query = $this->db_onedev->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("error get doctor order");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$selected_doctor = $query->row_array();
|
|
if ($selected_doctor['id'] == 0) {
|
|
$selected_doctor = array();
|
|
foreach ($result['doctors'] as $key => $value) {
|
|
if ($value['isDefault'] == 'Y') {
|
|
$selected_doctor = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
$result['selected_doctor'] = $selected_doctor;
|
|
|
|
$sql = "SELECT * FROM one_klinik.order
|
|
WHERE
|
|
orderID = ?";
|
|
$query = $this->db_onedev->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("error get order");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$result['order'] = $query->row_array();
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function get_data_anamnese()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$result = array('data' => '');
|
|
|
|
if ($prm['type_field'] == 'TEXT') {
|
|
if ($prm['selected_anamnese_tab']['id'] == 'SYMPTOM' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisKeluhanUtama,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'HYSOLD' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPenyakitDanAlergiDahulu,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'HYSNOW' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPenyakitDanAlergiSekarang,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'FAMILY' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPenyakitKeluarga,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'MEDICINE' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPengobatan,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'SOSIAL' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatSosial,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'OPERATING' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatOperasi,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'VAKSIN' && $prm['type_field'] == 'TEXT') {
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatImunisasi,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'TEXT' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get data");
|
|
exit;
|
|
}
|
|
|
|
$rst = $query->row_array();
|
|
if ($rst) {
|
|
$result['data'] = $rst['value'];
|
|
} else {
|
|
$result['data'] = '';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($prm['type_field'] == 'FORM') {
|
|
$formName = '';
|
|
if ($prm['selected_anamnese_tab']['id'] == 'SYMPTOM') {
|
|
$formName = 'KELUHAN SAAT INI';
|
|
$sql = "SELECT IFNULL(orderAnamnesisKeluhanUtama,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
if ($prm['selected_anamnese_tab']['id'] == 'HYSOLD') {
|
|
$formName = 'RIWAYAT PENYAKIT';
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPenyakitDanAlergiDahulu,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
if ($prm['selected_anamnese_tab']['id'] == 'HYSNOW') {
|
|
$formName = 'RIWAYAT PENYAKIT';
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPenyakitDanAlergiSekarang,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
if ($prm['selected_anamnese_tab']['id'] == 'FAMILY') {
|
|
$formName = 'RIWAYAT PENYAKIT KELUARGA';
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPenyakitKeluarga,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
if ($prm['selected_anamnese_tab']['id'] == 'MEDICINE') {
|
|
$formName = 'RIWAYAT KONSUMSI OBAT TERATUR';
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatPengobatan,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
if ($prm['selected_anamnese_tab']['id'] == 'SOSIAL') {
|
|
$formName = 'RIWAYAT KEBIASAAN HIDUP';
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatSosial,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
if ($prm['selected_anamnese_tab']['id'] == 'VAKSIN') {
|
|
$formName = 'RIWAYAT IMUNISASI';
|
|
$sql = "SELECT IFNULL(orderAnamnesisRiwayatImunisasi,'') as value
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y'
|
|
LIMIT 1";
|
|
}
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get FORM");
|
|
exit;
|
|
}
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
$data_vital = $query->row_array();
|
|
|
|
|
|
if ($data_vital && $data_vital['value'] != '') {
|
|
//echo 'in';
|
|
$jsonData = stripslashes(html_entity_decode($data_vital['value']));
|
|
$vital_sign = json_decode($jsonData, true);
|
|
$result['data'] = $vital_sign;
|
|
} else {
|
|
//echo 'dasdas';
|
|
$result['data'] = $this->get_form_anamnese($prm['orderid'], $formName);
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT M_DoctorID as id,
|
|
M_DoctorMcuDefaultKlinik as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM m_doctormcu
|
|
JOIN m_doctor ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
M_DoctorMcuIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get doctors");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$result['doctors'] = $query->result_array();
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE
|
|
orderIsActive = 'Y' AND orderID = ?";
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order information");
|
|
exit;
|
|
}
|
|
|
|
$order_info = $query->row_array();
|
|
|
|
if($order_info['orderIsReopen'] == 'N'){
|
|
$sql = "SELECT IFNULL(M_DoctorID,0) as id,
|
|
IFNULL(M_DoctorMcuDefaultKlinik,'N') as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',IFNULL(M_DoctorName,''),' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM one_klinik.order
|
|
LEFT JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctormcu ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderID = ?";
|
|
}else{
|
|
$sql = "SELECT IFNULL(M_DoctorID,0) as id,
|
|
IFNULL(M_DoctorMcuDefaultKlinik,'N') as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',IFNULL(M_DoctorName,''),' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM one_klinik.order
|
|
LEFT JOIN m_doctor ON orderReOpenM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctormcu ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderID = ?";
|
|
}
|
|
|
|
$query = $this->db_onedev->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("error get doctor order");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$selected_doctor = $query->row_array();
|
|
if ($selected_doctor['id'] == 0) {
|
|
$selected_doctor = array();
|
|
foreach ($result['doctors'] as $key => $value) {
|
|
if ($value['isDefault'] == 'Y') {
|
|
$selected_doctor = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
$result['selected_doctor'] = $selected_doctor;
|
|
|
|
$sql = "SELECT * FROM one_klinik.order
|
|
WHERE
|
|
orderID = ?";
|
|
$query = $this->db_onedev->query($sql, array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("error get order");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$result['order'] = $query->row_array();
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getSelectedTest($orderID, $mouID)
|
|
{
|
|
$selected_tests = [];
|
|
$rst = [];
|
|
$sql = "SELECT orderPenunjangT_TestID as test_id
|
|
FROM one_klinik.order_penunjang
|
|
WHERE
|
|
orderPenunjangOrderID = ? AND
|
|
orderPenunjangIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("error get ss_price_mou");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
//echo $this->db_onedev->last_query();
|
|
$rst_sel_tests = $query->result_array();
|
|
if(count($rst_sel_tests) > 0){
|
|
foreach ($rst_sel_tests as $xkey => $xval) {
|
|
$selected_tests[] = $xval['test_id'];
|
|
}
|
|
$fitered_test = join(",",$selected_tests);
|
|
$sql = "SELECT ss_price_mou.*, 'N' as selected
|
|
FROM ss_price_mou
|
|
WHERE
|
|
ss_price_mou.T_PriceM_MouID = ? AND ss_price_mou.is_packet = 'N' AND
|
|
ss_price_mou.T_TestID IN ({$fitered_test})
|
|
GROUP BY ss_price_mou.T_TestID
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql, array($mouID));
|
|
if (!$query) {
|
|
$this->sys_error("error get ss_price_mou");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$rst = $query->result_array();
|
|
foreach ($rst as $k => $v) {
|
|
if ($v['selected'] == 'N')
|
|
$rst[$k]['selected'] = false;
|
|
|
|
$rst[$k]['nat_test'] = json_decode($v['nat_test']);
|
|
$child_test = json_decode($v['child_test']);
|
|
if ($v['px_type'] == 'PR' || $v['px_type'] == 'PXR') {
|
|
foreach ($child_test as $key => $value) {
|
|
//print_r($child_test[$key]);
|
|
$child_test[$key] = $this->objToArray($value);
|
|
$child_test[$key]['Ss_PriceMouID'] = $v['Ss_PriceMouID'];
|
|
}
|
|
}
|
|
$rst[$k]['child_test'] = $child_test;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return $rst;
|
|
}
|
|
|
|
|
|
|
|
function get_subgroup($group_id)
|
|
{
|
|
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
|
FROM nat_subgroup
|
|
WHERE
|
|
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = ?";
|
|
$query = $this->db_onedev->query($sql, array($group_id));
|
|
if (!$query) {
|
|
$this->sys_error("error get nat_subgroup");
|
|
exit;
|
|
}
|
|
|
|
$subgroups = $query->result_array();
|
|
|
|
return $subgroups;
|
|
}
|
|
|
|
function getMouID()
|
|
{
|
|
$sql = "SELECT settingM_MouID as id
|
|
FROM one_klinik.setting
|
|
WHERE
|
|
settingIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get setting");
|
|
return 0;
|
|
}
|
|
|
|
return $query->row()->id;
|
|
}
|
|
|
|
function get_tests($group_id, $filter_subgroup, $search_test)
|
|
{
|
|
|
|
//$mouID = $this->getMouID();
|
|
$sql = "SELECT settingM_MouID as id
|
|
FROM one_klinik.setting
|
|
WHERE
|
|
settingIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get setting");
|
|
return 0;
|
|
}
|
|
|
|
$mouID = $query->row()->id;
|
|
//echo $mouID;
|
|
|
|
$query_filter_subgroup = "";
|
|
if (count($filter_subgroup) > 0) {
|
|
//echo count($filter_subgroup) ;
|
|
$query_filter_subgroup = " AND ( ";
|
|
foreach ($filter_subgroup as $key => $value) {
|
|
if ($key > 0)
|
|
$query_filter_subgroup .= " OR ";
|
|
|
|
$query_filter_subgroup .= " Nat_TestNat_SubGroupID = {$value['id']}";
|
|
}
|
|
|
|
$query_filter_subgroup .= " ) ";
|
|
}
|
|
|
|
$query_search_test = "";
|
|
if ($search_test != '') {
|
|
$query_search_test = "AND xtest.T_TestName LIKE CONCAT('%','{$search_test}','%')";
|
|
}
|
|
|
|
/*$sql = "SELECT ss_price_mou.*, 'N' as selected
|
|
FROM t_test xtest
|
|
JOIN nat_test ON Nat_TestNat_GroupID = ? AND nat_test.Nat_TestID = xtest.T_TestNat_TestID AND
|
|
Nat_TestIsActive = 'Y' AND
|
|
xtest.T_TestIsActive = 'Y'
|
|
{$query_filter_subgroup}
|
|
JOIN ss_price_mou ON T_PriceM_MouID = ? AND xtest.T_TestID = ss_price_mou.T_TestID AND is_packet = 'N'
|
|
{$query_search_test}
|
|
GROUP BY ss_price_mou.T_TestID
|
|
LIMIT 50";*/
|
|
/*$sql = "SELECT ss_price_mou.*, 'N' as selected
|
|
FROM ss_price_mou
|
|
JOIN t_test xtest ON T_PriceM_MouID = ? AND
|
|
is_packet = 'N' AND
|
|
xtest.T_TestID = ss_price_mou.T_TestID
|
|
JOIN nat_test ON Nat_TestNat_GroupID = ? AND nat_test.Nat_TestID = xtest.T_TestNat_TestID AND
|
|
Nat_TestIsActive = 'Y' AND
|
|
xtest.T_TestIsActive = 'Y'
|
|
{$query_filter_subgroup}
|
|
{$query_search_test}
|
|
GROUP BY ss_price_mou.T_TestID
|
|
LIMIT 50";*/
|
|
$sql ="SELECT spm.*, 'N' as selected
|
|
FROM `ss_price_mou` spm
|
|
JOIN nat_test nt ON nt.Nat_TestID = spm.Nat_TestID AND nt.Nat_TestNat_GroupID = ?
|
|
JOIN t_test xtest ON xtest.T_TEstID = spm.T_TestID
|
|
{$query_filter_subgroup}
|
|
WHERE `Ss_PriceMouM_MouID` = ? AND `is_packet` = 'N'
|
|
{$query_search_test}
|
|
LIMIT 50";
|
|
|
|
|
|
$query = $this->db_onedev->query($sql, array($group_id, $mouID));
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("error get ss_price_mou");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
//echo $this->db_onedev->last_query();
|
|
|
|
$tests = $query->result_array();
|
|
foreach ($tests as $k => $v) {
|
|
if ($v['selected'] == 'N')
|
|
$tests[$k]['selected'] = false;
|
|
|
|
$tests[$k]['nat_test'] = json_decode($v['nat_test']);
|
|
$child_test = json_decode($v['child_test']);
|
|
if ($v['px_type'] == 'PR' || $v['px_type'] == 'PXR') {
|
|
foreach ($child_test as $key => $value) {
|
|
//print_r($child_test[$key]);
|
|
$child_test[$key] = $this->objToArray($value);
|
|
$child_test[$key]['Ss_PriceMouID'] = $v['Ss_PriceMouID'];
|
|
}
|
|
}
|
|
$tests[$k]['child_test'] = $child_test;
|
|
}
|
|
|
|
return $tests;
|
|
}
|
|
|
|
protected function objToArray($obj)
|
|
{
|
|
// Not an object or array
|
|
if (!is_object($obj) && !is_array($obj)) {
|
|
return $obj;
|
|
}
|
|
|
|
// Parse array
|
|
foreach ($obj as $key => $value) {
|
|
$arr[$key] = $this->objToArray($value);
|
|
}
|
|
|
|
// Return parsed array
|
|
return $arr;
|
|
}
|
|
|
|
function do_gettests()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
//print_r($prm['subgroup']);
|
|
$result['tests'] = $this->get_tests($prm['group_id']['id'], $prm['subgroup'], $prm['search']);
|
|
$result['subgroups'] = $this->get_subgroup($prm['group_id']['id']);
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function get_doctorpj()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$result = array();
|
|
|
|
/*$sql = "SELECT M_DoctorID as doctor_id,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM m_doctor_schedule
|
|
JOIN one_aditya.m_doctor ON M_DoctorScheduleM_DoctorID = M_DoctorID
|
|
WHERE
|
|
M_DoctorScheduleM_RegDayID = DAYOFWEEK(DATE(NOW())) AND
|
|
M_DoctorScheduleIsActive = 'Y'";
|
|
*/
|
|
$sql = " SELECT M_DoctorID as doctor_id,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.`order`
|
|
JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderNumber = ?";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderNumber']));
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query m_doctor_schedule");
|
|
exit;
|
|
}
|
|
|
|
$rst = $query->row_array();
|
|
if ($rst) {
|
|
$result['doctor_pj'] = $rst;
|
|
} else {
|
|
$result['doctor_pj'] = [];
|
|
}
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function get_doctors()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE
|
|
orderIsActive = 'Y' AND orderID = ?";
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order information");
|
|
exit;
|
|
}
|
|
$order_info = $query->row_array();
|
|
|
|
|
|
|
|
$sql = "SELECT M_DoctorID as id,
|
|
M_DoctorMcuDefaultKlinik as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM m_doctormcu
|
|
JOIN m_doctor ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
M_DoctorMcuIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get doctors");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$result['doctors'] = $query->result_array();
|
|
|
|
if($order_info['orderIsReopen'] == 'N'){
|
|
$sql = "SELECT IFNULL(M_DoctorID,0) as id,
|
|
IFNULL(M_DoctorMcuDefaultKlinik,'N') as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',IFNULL(M_DoctorName,''),' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM one_klinik.order
|
|
LEFT JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctormcu ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderNumber = ?";
|
|
$query = $this->db_onedev->query($sql, array($prm['orderNumber']));
|
|
if (!$query) {
|
|
$this->sys_error("error get doctor order");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$selected_doctor = $query->row_array();
|
|
if ($selected_doctor['id'] == 0) {
|
|
$selected_doctor = array();
|
|
foreach ($result['doctors'] as $key => $value) {
|
|
if ($value['isDefault'] == 'Y') {
|
|
$selected_doctor = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
$result['selected_doctor'] = $selected_doctor;
|
|
}else{
|
|
$sql = "SELECT IFNULL(M_DoctorID,0) as id,
|
|
IFNULL(M_DoctorMcuDefaultKlinik,'N') as isDefault,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',IFNULL(M_DoctorName,''),' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name
|
|
FROM one_klinik.order
|
|
LEFT JOIN m_doctor ON orderReOpenM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_doctormcu ON M_DoctorMcuM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderNumber = ?";
|
|
$query = $this->db_onedev->query($sql, array($prm['orderNumber']));
|
|
if (!$query) {
|
|
$this->sys_error("error get doctor order");
|
|
echo $this->db_onedev->last_query();
|
|
exit;
|
|
}
|
|
|
|
$selected_doctor = $query->row_array();
|
|
if ($selected_doctor['id'] == 0) {
|
|
$selected_doctor = array();
|
|
foreach ($result['doctors'] as $key => $value) {
|
|
if ($value['isDefault'] == 'Y') {
|
|
$selected_doctor = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
$result['selected_doctor'] = $selected_doctor;
|
|
}
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save_text()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm);
|
|
|
|
$result = array();
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE
|
|
orderID = ?
|
|
LIMIT 1";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid order data");
|
|
exit;
|
|
}
|
|
|
|
$xxx_order_data = $query->row_array();
|
|
|
|
if($xxx_order_data['orderIsReopen'] == 'N'){
|
|
$sql = "UPDATE one_klinik.`order` SET orderM_DoctorID = ?, orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $userID, $prm['orderid']));
|
|
|
|
if (!$query) {
|
|
echo $this->db_oneklinik->last_query();
|
|
$this->sys_error("Invalid update doctor");
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT COUNT(*) as xcount
|
|
FROM one_klinik.order_doctor
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid'], $prm['type']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query XCOUNT");
|
|
exit;
|
|
}
|
|
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
$xcount_exist = $query->row()->xcount;
|
|
if ($xcount_exist == 0) {
|
|
$sql = "INSERT INTO one_klinik.order_doctor (
|
|
orderDoctorType,
|
|
orderDoctorOrderID,
|
|
orderDoctorVitalSign,
|
|
orderDoctorFisik,
|
|
orderDoctorReceipt,
|
|
orderDoctorDiagnosePrimer,
|
|
orderDoctorDiagnoseSekunder,
|
|
orderDoctorSaran,
|
|
orderDoctorUserID,
|
|
orderDoctorCreated
|
|
)
|
|
VALUES(
|
|
?,?,'','','','','','',?,NOW()
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array(
|
|
$prm['type'],
|
|
$prm['orderid'],
|
|
$userID
|
|
));
|
|
|
|
echo $this->db_oneklinik->last_query();
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid INSERT NEW VITAL SIGN");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'VITAL') {
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorVitalSign = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'FISIK') {
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorFisik = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'RECEIPT') {
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorReceipt = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'MEDIC') {
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorMedic = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER') {
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorDiagnosePrimer = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER') {
|
|
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorDiagnoseSekunder = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
//echo $sql;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if ($prm['selected_doctor_tab']['id'] == 'SARAN') {
|
|
$sql = "UPDATE one_klinik.order_doctor SET
|
|
orderDoctorSaran = ?, orderDoctorUserID = ?
|
|
WHERE
|
|
orderDoctorOrderID = ? AND orderDoctorType = ? AND orderDoctorIsActive = 'Y'";
|
|
}
|
|
|
|
|
|
$value = $prm['note'];
|
|
if ($prm['type'] == 'FORM') {
|
|
$vital_sign = str_replace('\'', '\\\'', json_encode($prm["vital_sign"], JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
//$value = addslashes(str_replace('\"', '\\\"',$vital_sign));
|
|
$value = $vital_sign;
|
|
}
|
|
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($value, $userID, $prm['orderid'], $prm['type']));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query update " . $prm['selected_doctor_tab']['id']);
|
|
exit;
|
|
}
|
|
|
|
if ($prm['icd10_primer'])
|
|
$save_icd10 = $this->save_icd10_primer($prm['orderid'], $prm['icd10_primer']['code'], $prm['icd10_primer']['display']);
|
|
|
|
if ($prm['icd10_sekunder'])
|
|
$save_icd10 = $this->save_icd10_sekunder($prm['orderid'], $prm['icd10_sekunder']['code'], $prm['icd10_sekunder']['display']);
|
|
|
|
}else{
|
|
if($prm['selected_doctor_tab']['id'] != 'VITAL' && $prm['selected_doctor_tab']['id'] != 'ADDITIONAL' ){
|
|
$sql = "UPDATE one_klinik.`order` SET orderReOpenM_DoctorID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $prm['orderid']));
|
|
|
|
if (!$query) {
|
|
echo $this->db_oneklinik->last_query();
|
|
$this->sys_error("Invalid update doctor");
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE orderID = ? LIMIT 1";
|
|
$qry = $this->db_onedev->query($sql,array($prm['orderid']));
|
|
if (!$qry) {
|
|
$this->sys_error("Gagal get data order");
|
|
exit;
|
|
}
|
|
|
|
$data_order = $qry->row_array();
|
|
|
|
$sql = "SELECT COUNT(*) as xcount
|
|
FROM one_klinik.order_doctor_additional
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalM_DoctorID = ? AND
|
|
orderDoctorAdditionalReOpenCount = ? AND
|
|
orderDoctorAdditionalType = ? AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array(
|
|
$prm['orderid'],
|
|
$prm['doctor']['id'],
|
|
$data_order['orderReOpenCount'],
|
|
$prm['selected_doctor_tab']['id']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query XCOUNT add");
|
|
exit;
|
|
}
|
|
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
$xcount_exist_add = $query->row()->xcount;
|
|
if($xcount_exist_add == 0){
|
|
$icd10_code = "";
|
|
$icd10_text = "";
|
|
if($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER' && $prm['icd10_primer']){
|
|
$icd10_code = $prm['icd10_primer']['code'];
|
|
$icd10_text = $prm['icd10_primer']['display'];
|
|
}
|
|
if($prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER' && $prm['icd10_sekunder']){
|
|
$icd10_code = $prm['icd10_sekunder']['code'];
|
|
$icd10_text = $prm['icd10_sekunder']['display'];
|
|
}
|
|
|
|
if($prm['note'] != '' || $icd10_code != ''){
|
|
$sql = "INSERT INTO one_klinik.order_doctor_additional (
|
|
orderDoctorAdditionalOrderID,
|
|
orderDoctorAdditionalReOpenCount,
|
|
orderDoctorAdditionalM_DoctorID,
|
|
orderDoctorAdditionalType,
|
|
orderDoctorAdditionalValue,
|
|
orderDoctorAdditionalICD10Code,
|
|
orderDoctorAdditionalICD10Text,
|
|
orderDoctorAdditionalUserID,
|
|
orderDoctorAdditionalCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,?,?,?,NOW()
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array(
|
|
$prm['orderid'],
|
|
$data_order['orderReOpenCount'],
|
|
$prm['doctor']['id'],
|
|
$prm['selected_doctor_tab']['id'],
|
|
$prm['note'],
|
|
$icd10_code,
|
|
$icd10_text,
|
|
$userID
|
|
));
|
|
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid INSERT NEW VITAL SIGN");
|
|
exit;
|
|
}
|
|
}
|
|
}else{
|
|
$icd10_code = "";
|
|
$icd10_text = "";
|
|
if($prm['selected_doctor_tab']['id'] == 'DIAGPRIMER' && $prm['icd10_primer']){
|
|
$icd10_code = $prm['icd10_primer']['code'];
|
|
$icd10_text = $prm['icd10_primer']['display'];
|
|
}
|
|
if($prm['selected_doctor_tab']['id'] == 'DIAGSEKUNDER' && $prm['icd10_sekunder']){
|
|
$icd10_code = $prm['icd10_sekunder']['code'];
|
|
$icd10_text = $prm['icd10_sekunder']['display'];
|
|
}
|
|
$sql = "UPDATE one_klinik.order_doctor_additional SET
|
|
orderDoctorAdditionalValue = ?,
|
|
orderDoctorAdditionalICD10Code = ?,
|
|
orderDoctorAdditionalICD10Text = ?,
|
|
orderDoctorAdditionalUserID = ?,
|
|
orderDoctorAdditionalLastUdated = NOW()
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalReOpenCount = ? AND
|
|
orderDoctorAdditionalType = ? AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array(
|
|
$prm['note'],
|
|
$icd10_code,
|
|
$icd10_text,
|
|
$userID,
|
|
$prm['orderid'],
|
|
$data_order['orderReOpenCount'],
|
|
$prm['selected_doctor_tab']['id']
|
|
));
|
|
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid UPDATE additional");
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save_text_anamnese()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
$result = array();
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderM_DoctorID = ?, orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $userID, $prm['orderid']));
|
|
|
|
if (!$query) {
|
|
echo $this->db_oneklinik->last_query();
|
|
$this->sys_error("Invalid update doctor");
|
|
exit;
|
|
}
|
|
|
|
|
|
$sql = "SELECT COUNT(*) as xcount
|
|
FROM one_klinik.order_anamnesis
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid'], $prm['type']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query XCOUNT");
|
|
exit;
|
|
}
|
|
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
$xcount_exist = $query->row()->xcount;
|
|
if ($xcount_exist == 0) {
|
|
$sql = "INSERT INTO one_klinik.order_anamnesis (
|
|
orderAnamnesisTypeForm,
|
|
orderAnamnesisOrderID,
|
|
orderAnamnesisKeluhanUtama,
|
|
orderAnamnesisRiwayatPenyakitDanAlergiDahulu,
|
|
orderAnamnesisRiwayatPenyakitDanAlergiSekarang,
|
|
orderAnamnesisRiwayatPenyakitKeluarga,
|
|
orderAnamnesisRiwayatPengobatan,
|
|
orderAnamnesisRiwayatSosial,
|
|
orderAnamnesisRiwayatOperasi,
|
|
orderAnamnesisRiwayatAlergi,
|
|
orderAnamnesisRiwayatImunisasi,
|
|
orderAnamnesisCreated,
|
|
orderAnamnesisUserID
|
|
)
|
|
VALUES(
|
|
?,?,'','','','','','','','','',NOW(),?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array(
|
|
$prm['type'],
|
|
$prm['orderid'],
|
|
$userID
|
|
));
|
|
|
|
//echo $this->db_oneklinik->last_query();
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid INSERT ANAMNESE");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'SYMPTOM') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisKeluhanUtama = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'HYSOLD') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatPenyakitDanAlergiDahulu = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'HYSNOW') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatPenyakitDanAlergiSekarang = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'FAMILY') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatPenyakitKeluarga = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'MEDICINE') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatPengobatan = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'SOSIAL') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatSosial = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'OPERATING') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatOperasi = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
if ($prm['selected_anamnese_tab']['id'] == 'VAKSIN') {
|
|
$sql = "UPDATE one_klinik.order_anamnesis SET
|
|
orderAnamnesisRiwayatImunisasi = ?, orderAnamnesisUserID = ?
|
|
WHERE
|
|
orderAnamnesisOrderID = ? AND orderAnamnesisTypeForm = ? AND orderAnamnesisIsActive = 'Y'";
|
|
}
|
|
|
|
|
|
|
|
$value = $prm['note'];
|
|
if ($prm['type'] == 'FORM') {
|
|
$value = str_replace('\'', '\\\'', json_encode($prm["json_form"], JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT));
|
|
}
|
|
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($value, $userID, $prm['orderid'], $prm['type']));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query update " . $prm['selected_anamnese_tab']['id']);
|
|
exit;
|
|
}
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function change_doctor()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE
|
|
orderIsActive = 'Y' AND orderID = ?";
|
|
$query = $this->db_oneklinik->query($sql,array($prm['orderid']));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order information");
|
|
exit;
|
|
}
|
|
$order_info = $query->row_array();
|
|
|
|
if($order_info['orderIsReopen'] == 'N'){
|
|
$sql = "UPDATE one_klinik.`order` SET orderM_DoctorID = ?, orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $userID, $prm['orderid']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid update doctor");
|
|
exit;
|
|
}
|
|
}else{
|
|
$sql = "UPDATE one_klinik.`order` SET orderReOpenM_DoctorID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $prm['orderid']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid update doctor");
|
|
exit;
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order_doctor_additional` SET orderDoctorAdditionalM_DoctorID = ?
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND orderDoctorAdditionalReOpenCount = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $prm['orderid'],$order_info['orderReOpenCount']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid update doctor addtional");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
$result = array('status' => 'saved');
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save_px()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderM_DoctorID = ?, orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['doctor']['id'], $userID, $prm['orderid']));
|
|
|
|
if (!$query) {
|
|
$this->sys_error("Invalid update doctor");
|
|
exit;
|
|
}
|
|
|
|
|
|
if (count($prm['selected_test']) > 0) {
|
|
$sql = "UPDATE one_klinik.order_penunjang SET orderPenunjangIsActive = 'N'
|
|
WHERE
|
|
orderPenunjangOrderID = ? AND orderPenunjangIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid']));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query Is Active N");
|
|
exit;
|
|
}
|
|
|
|
foreach ($prm['selected_test'] as $key => $value) {
|
|
$sql = "INSERT INTO one_klinik.order_penunjang(
|
|
orderPenunjangOrderID,
|
|
orderPenunjangT_TestID,
|
|
orderPenunjangCreated
|
|
)
|
|
VALUES(
|
|
?,?,NOW()
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderid'], $value['T_TestID']));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Invalid Query Insert " . $value['T_TestName']);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
//$mouID = $this->getMouID();
|
|
$sql = "SELECT settingM_MouID as id
|
|
FROM one_klinik.setting
|
|
WHERE
|
|
settingIsActive = 'Y'";
|
|
|
|
$query = $this->db_oneklinik->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error("error get setting");
|
|
return 0;
|
|
}
|
|
|
|
$mouID = $query->row()->id;
|
|
|
|
|
|
$result['selected_test'] = $this->getSelectedTest($prm['orderid'], $mouID);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function get_form_vital($orderID)
|
|
{
|
|
|
|
|
|
|
|
$sql = "SELECT *
|
|
FROM fisik_templateresult
|
|
WHERE
|
|
Fisik_TemplateResultM_LangID = 1 AND
|
|
Fisik_TemplateResultType = 'fisik' AND
|
|
Fisik_TemplateResultIsActive = 'Y' LIMIT 1
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql, array($langID));
|
|
if (!$query) {
|
|
$this->sys_error("error get fisik template");
|
|
//echo $this->db_onedev->last_query();
|
|
return array("data" => 'error');
|
|
}
|
|
|
|
$fisik = json_decode($query->row()->Fisik_TemplateResultText);
|
|
$tanda_vital = [];
|
|
foreach ($fisik as $key => $value) {
|
|
if ($value->title == 'TANDA VITAL' || $value->title == 'STATUS GIZI')
|
|
$tanda_vital[] = $value;
|
|
}
|
|
|
|
return $tanda_vital;
|
|
}
|
|
|
|
function get_form_anamnese($orderID, $formName)
|
|
{
|
|
|
|
|
|
|
|
$sql = "SELECT *
|
|
FROM fisik_templateresult
|
|
WHERE
|
|
Fisik_TemplateResultM_LangID = 1 AND
|
|
Fisik_TemplateResultType = 'riwayat' AND
|
|
Fisik_TemplateResultIsActive = 'Y' LIMIT 1
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql, array($langID));
|
|
if (!$query) {
|
|
$this->sys_error("error get riwayat template");
|
|
//echo $this->db_onedev->last_query();
|
|
return array("data" => 'error');
|
|
}
|
|
|
|
$riwayat = json_decode($query->row()->Fisik_TemplateResultText);
|
|
$json_form = [];
|
|
foreach ($riwayat as $key => $value) {
|
|
if ($value->title == $formName)
|
|
$json_form[] = $value;
|
|
}
|
|
|
|
return $json_form;
|
|
}
|
|
|
|
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(ISNULL(M_PatientPrefix),'',CONCAT(M_PatientPrefix,' ')),M_PatientName,IF(ISNULL(M_PatientSuffix),'',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
|
|
LEFT JOIN s_menu ON ( S_MenuUrl LIKE CONCAT('%test/vuex/one-klinik-fo-registration-v') OR S_MenuName = 'Periksa dokter')
|
|
WHERE
|
|
orderIsActive = 'Y' AND DATE(orderDate) = ? AND orderIsScreening = 'D' AND orderIsCheck = ?
|
|
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 = "SELECT
|
|
orderID,
|
|
orderQueueNumber AS queueNumber,
|
|
orderM_LocationID AS locationID,
|
|
M_LocationName AS locationName,
|
|
M_LocationT_SampleStationID
|
|
FROM one_klinik.order
|
|
JOIN m_location ON orderM_LocationID = M_LocationID
|
|
WHERE orderID = {$prm['orderID']}";
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
$this->sys_error("Gagal cek data");
|
|
exit;
|
|
}
|
|
$location = $qry->row_array();
|
|
$locationID = $location['locationID'];
|
|
$stationID = $location['M_LocationT_SampleStationID'];
|
|
$locationName = $location['locationName'];
|
|
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID
|
|
)
|
|
VALUES(
|
|
?,?,?,?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID'], 'C', 'Y', $userID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderIsCheck = 'Y', orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($userID, $prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal Update");
|
|
}
|
|
|
|
$query = "INSERT INTO t_sampling_clinic_queue_last_status (
|
|
T_SamplingQueueLastStatusT_SampleStationID,
|
|
T_SamplingQueueLastStatusT_OrderHeaderID,
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
|
T_SamplingQueueLastStatusUserID)
|
|
VALUES(
|
|
{$stationID},
|
|
{$prm['orderID']},
|
|
3,
|
|
{$userID}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = 3";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
if (!$rows) {
|
|
$this->sys_error("Gagal insert / update t_sampling_queue_last_status");
|
|
exit;
|
|
}
|
|
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/serve.sm.{$locationID}");
|
|
|
|
$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 = "SELECT
|
|
orderID,
|
|
orderQueueNumber AS queueNumber,
|
|
orderM_LocationID AS locationID,
|
|
M_LocationName AS locationName,
|
|
M_LocationT_SampleStationID
|
|
FROM one_klinik.order
|
|
JOIN m_location ON orderM_LocationID = M_LocationID
|
|
WHERE orderID = {$prm['orderID']}";
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
$this->sys_error("Gagal cek data");
|
|
exit;
|
|
}
|
|
$location = $qry->row_array();
|
|
$locationID = $location['locationID'];
|
|
$stationID = $location['M_LocationT_SampleStationID'];
|
|
$locationName = $location['locationName'];
|
|
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID
|
|
)
|
|
VALUES(
|
|
?,?,?,?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID'], 'C', 'N', $userID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderIsCheck = 'N', orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($userID, $prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$query = "INSERT INTO t_sampling_clinic_queue_last_status (
|
|
T_SamplingQueueLastStatusT_SampleStationID,
|
|
T_SamplingQueueLastStatusT_OrderHeaderID,
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
|
T_SamplingQueueLastStatusUserID)
|
|
VALUES(
|
|
{$stationID},
|
|
{$prm['orderID']},
|
|
2,
|
|
{$userID}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = 2";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
if (!$rows) {
|
|
$this->sys_error("Gagal insert / update t_sampling_queue_last_status");
|
|
exit;
|
|
}
|
|
|
|
$query = "SELECT S_MenuUrl as url
|
|
FROM s_menu
|
|
WHERE
|
|
S_MenuName = 'Antrian Klinik' AND S_MenuIsActive = 'Y' LIMIT 1";
|
|
//echo $query;
|
|
$query = $this->db_onedev->query($query);
|
|
if (!$rows) {
|
|
$this->sys_error("Gagal get menu antrian");
|
|
exit;
|
|
}
|
|
|
|
$menu_antrian = $query->row()->url;
|
|
|
|
|
|
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/skip.sm.{$locationID}");
|
|
|
|
|
|
$result = array('process' => 'OK','redirect' => $menu_antrian);
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function reopen()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
$userReopen = isset($prm['reopenDoctor'])?$prm['reopenDoctor']:'N';
|
|
$sql = "SELECT
|
|
orderID,
|
|
orderDate,
|
|
orderQueueNumber AS queueNumber,
|
|
orderM_LocationID AS locationID,
|
|
M_LocationName AS locationName,
|
|
M_LocationT_SampleStationID
|
|
FROM one_klinik.order
|
|
JOIN m_location ON orderM_LocationID = M_LocationID
|
|
WHERE orderID = {$prm['orderID']}";
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
$this->sys_error("Gagal cek data");
|
|
exit;
|
|
}
|
|
$location = $qry->row_array();
|
|
$locationID = $location['locationID'];
|
|
$stationID = $location['M_LocationT_SampleStationID'];
|
|
$locationName = $location['locationName'];
|
|
$orderDate = $location['orderDate'];
|
|
$orderDateFormatted = date('Y-m-d', strtotime($orderDate));
|
|
if ($orderDateFormatted == date('Y-m-d')) {
|
|
// if orderDate is equal to the current date
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID,
|
|
orderStatusCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,NOW()
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID'], 'C', 'N', $userID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET
|
|
orderIsCheck = ?,
|
|
orderIsReopen = 'Y',
|
|
orderReOpenCount = orderReOpenCount + 1,
|
|
orderReOpenM_DoctorID = orderM_DoctorID,
|
|
orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($userReopen, $userID, $prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal Process");
|
|
}
|
|
|
|
$query = "INSERT INTO t_sampling_clinic_queue_last_status (
|
|
T_SamplingQueueLastStatusT_SampleStationID,
|
|
T_SamplingQueueLastStatusT_OrderHeaderID,
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
|
T_SamplingQueueLastStatusUserID)
|
|
VALUES(
|
|
{$stationID},
|
|
{$prm['orderID']},
|
|
2,
|
|
{$userID}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = 2";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
if (!$rows) {
|
|
$this->sys_error("Gagal insert / update t_sampling_queue_last_status");
|
|
exit;
|
|
}
|
|
|
|
$query = "SELECT S_MenuUrl as url
|
|
FROM s_menu
|
|
WHERE
|
|
S_MenuName = 'Antrian Klinik' AND S_MenuIsActive = 'Y' LIMIT 1";
|
|
//echo $query;
|
|
$query = $this->db_onedev->query($query);
|
|
if (!$rows) {
|
|
$this->sys_error("Gagal get menu antrian");
|
|
exit;
|
|
}
|
|
|
|
$menu_antrian = $query->row()->url;
|
|
|
|
|
|
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/skip.sm.{$locationID}");
|
|
|
|
|
|
$result = array('process' => 'OK','redirect' => $menu_antrian);
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}else{
|
|
$this->sys_error("Tidak dapat reopen, hanya bisa dihari yang sama");
|
|
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 = "SELECT
|
|
orderID,
|
|
orderQueueNumber AS queueNumber,
|
|
orderM_LocationID AS locationID,
|
|
M_LocationName AS locationName,
|
|
M_LocationT_SampleStationID
|
|
FROM one_klinik.order
|
|
JOIN m_location ON orderM_LocationID = M_LocationID
|
|
WHERE orderID = {$prm['orderID']}";
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
$this->sys_error("Gagal cek data");
|
|
exit;
|
|
}
|
|
$location = $qry->row_array();
|
|
$locationID = $location['locationID'];
|
|
$stationID = $location['M_LocationT_SampleStationID'];
|
|
$locationName = $location['locationName'];
|
|
|
|
$sql = "INSERT INTO one_klinik.order_status (
|
|
orderStatusOrderID,
|
|
orderStatusCode,
|
|
orderStatusValue,
|
|
orderStatusUserID
|
|
)
|
|
VALUES(
|
|
?,?,?,?
|
|
)";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID'], 'C', 'D', $userID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal End");
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.`order` SET orderIsCheck = 'D', orderIsReopen = 'N', orderReOpenM_DoctorID = 0, orderUserID = ?
|
|
WHERE
|
|
orderID = ?";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($userID, $prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal ENd");
|
|
}
|
|
$query = "INSERT INTO t_sampling_clinic_queue_last_status (
|
|
T_SamplingQueueLastStatusT_SampleStationID,
|
|
T_SamplingQueueLastStatusT_OrderHeaderID,
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
|
T_SamplingQueueLastStatusUserID)
|
|
VALUES(
|
|
{$stationID},
|
|
{$prm['orderID']},
|
|
5,
|
|
{$userID}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = 5";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
if (!$rows) {
|
|
$this->sys_error("Gagal insert / update t_sampling_queue_last_status");
|
|
exit;
|
|
}
|
|
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/done.sm.{$locationID}");
|
|
|
|
|
|
|
|
$result = array('process' => 'OK');
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function search_icd10()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
|
|
$sql = "SELECT terminology.*, CONCAT(code,' | ', display) as display_name
|
|
FROM one_terminology.terminology
|
|
WHERE
|
|
attribute_path = 'icd10' AND ( code LIKE CONCAT('%',?,'%') OR MATCH (display) AGAINST (? IN NATURAL LANGUAGE MODE) OR CONCAT(code,' | ', display) LIKE CONCAT('%',?,'%'))
|
|
GROUP BY code";
|
|
$query = $this->db_onedev->query($sql, array($prm['search'], $prm['search'], $prm['search']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal cari End");
|
|
}
|
|
|
|
$result = $query->result_array();
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save_icd10_primer($orderID, $icd10_code, $icd10_display)
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//$prm = $this->sys_input;
|
|
$prm['orderID'] = $orderID;
|
|
$prm['icd10']['code'] = $icd10_code;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
|
|
$sql = "SELECT COUNT(*) as xcount
|
|
FROM one_klinik.order_diagnose_icd10
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y' LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal hitung");
|
|
}
|
|
|
|
$xcount = $query->row()->xcount;
|
|
if ($xcount == 0) {
|
|
$sql = "INSERT INTO one_klinik.order_diagnose_icd10 (
|
|
orderDiagnoseIcd10OrderID,
|
|
orderDiagnoseIcd10Created,
|
|
orderDiagnoseIcd10UserID
|
|
)
|
|
VALUES(
|
|
?,NOW(),?
|
|
)";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID'], $userID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal insert");
|
|
}
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.order_diagnose_icd10 SET orderDiagnoseIcd10Primary = ?, orderDiagnoseIcd10PrimaryText = ?, orderDiagnoseIcd10UserID = ?
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? ";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['icd10']['code'], $icd10_display, $userID, $prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal update");
|
|
}
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function check_exist_icd10_row($orderID)
|
|
{
|
|
$sql = "SELECT COUNT(*) as xcount
|
|
FROM one_klinik.order_diagnose_icd10
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y' LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal hitung");
|
|
}
|
|
|
|
return $query->row()->xcount;
|
|
}
|
|
|
|
function save_icd10_sekunder($orderID, $icd10_code, $icd10_display)
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//$prm = $this->sys_input;
|
|
$prm['orderID'] = $orderID;
|
|
$prm['icd10']['code'] = $icd10_code;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
//print_r($prm['subgroup']);
|
|
|
|
$xcount = $this->check_exist_icd10_row($prm['orderID']);
|
|
if ($xcount == 0) {
|
|
$sql = "INSERT INTO one_klinik.order_diagnose_icd10 (
|
|
orderDiagnoseIcd10OrderID,
|
|
orderDiagnoseIcd10Created,
|
|
orderDiagnoseIcd10UserID
|
|
)
|
|
VALUES(
|
|
?,NOW(),?
|
|
)";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['orderID'], $userID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal insert");
|
|
}
|
|
}
|
|
|
|
$sql = "UPDATE one_klinik.order_diagnose_icd10 SET orderDiagnoseIcd10Sekunder = ?, orderDiagnoseIcd10SekunderText = ?, orderDiagnoseIcd10UserID = ?
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? ";
|
|
$query = $this->db_oneklinik->query($sql, array($prm['icd10']['code'], $icd10_display, $userID, $prm['orderID']));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal update");
|
|
}
|
|
|
|
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function get_resume_medic(){
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$patientID = $prm['id'];
|
|
$orderID = $prm['orderID'];
|
|
$Isreopen = isset($prm['reOpen'])?$prm['reOpen']:'N';
|
|
$data_orders = $this->get_order_by_patientID($patientID,$orderID,'Y');
|
|
$date_orders = [];
|
|
$keluhan_utama = [];
|
|
$riwayat_penyakit_alergi_dahulu = [];
|
|
$riwayat_penyakit_alergi_sekarang = [];
|
|
$riwayat_penyakit_alergi_keluarga = [];
|
|
$riwayat_pengobatan = [];
|
|
$riwayat_sosial = [];
|
|
$riwayat_operasi = [];
|
|
$hepatitis_a = [];
|
|
$hepatitis_b = [];
|
|
$covid_1 = [];
|
|
$covid_2 = [];
|
|
$covid_3 = [];
|
|
$anamnesa = [];
|
|
$periksa_doctor = [];
|
|
$denyut_nadi = [];
|
|
$ritme_denyut_nadi = [];
|
|
$laju_pernapasan = [];
|
|
$pola_nafas = [];
|
|
$tekanan_darah = [];
|
|
$suhu = [];
|
|
$berat_badan = [];
|
|
$tinggi_badan = [];
|
|
$lingkar_perut = [];
|
|
$bmi = [];
|
|
$lingkar_pinggang = [];
|
|
$klasifikasi_bmi = [];
|
|
$order_penunjang = [];
|
|
$fisik = [];
|
|
$diagnosis_primer = [];
|
|
$diagnosis_sekunder = [];
|
|
$receipt = [];
|
|
$saran = [];
|
|
$tindakan = [];
|
|
$vaksinasi_list = [];
|
|
$tindakan_medis_list = [];
|
|
$doctor = [];
|
|
$pemeriksaan_penunjang = [];
|
|
|
|
foreach ($data_orders as $key => $value) {
|
|
$doctor[] = $value['doctor_name'];
|
|
$date_orders[] = date('d-m-Y H:i', strtotime($value['orderDate']));
|
|
$pemeriksaan_penunjang[] = $this->get_order_penunjang($value['orderID']);
|
|
$data_anamesa = $this->get_data_order_anamnesis($value['orderID']);
|
|
$data_anamesa_text = $data_anamesa['text'];
|
|
$data_anamesa_form = $data_anamesa['form'];
|
|
$keluhan_utama_f = $data_anamesa_form['keluhanUtama'];
|
|
$keluhan_utama_form = [];
|
|
if(count($keluhan_utama_f) > 0){
|
|
foreach ($keluhan_utama_f as $k_ku => $v_ku) {
|
|
$value_keluhan = $v_ku['label'];
|
|
if($v_ku['value'] != '')
|
|
$value_keluhan = $v_ku['label'].' ( '.$v_ku['value'].' ) ';
|
|
$keluhan_utama_form[] = $value_keluhan;
|
|
}
|
|
}
|
|
$keluhan_utama_form = join(", ",$keluhan_utama_form);
|
|
$keluhan_utama_x = $data_anamesa_text['keluhanUtama'];
|
|
if($keluhan_utama_x == '')
|
|
$keluhan_utama_x = $keluhan_utama_form;
|
|
$keluhan_utama[] = $keluhan_utama_x;
|
|
|
|
//$riwayat_penyakit_alergi_dahulu[] = array('text' => $data_anamesa_text['riwayatPenyakitDanAlergiDahulu'], 'form' => $data_anamesa_form['riwayatPenyakitDanAlergiDahulu'] );
|
|
$riwayat_penyakit_alergi_dahulu_form = [];
|
|
$riwayat_penyakit_alergi_dahulu_f = $data_anamesa_form['riwayatPenyakitDanAlergiDahulu'];
|
|
if(count($riwayat_penyakit_alergi_dahulu_f) > 0){
|
|
foreach ($riwayat_penyakit_alergi_dahulu_f as $k_rpad => $v_rpad) {
|
|
foreach ($v_rpad['value'] as $k_rpadc => $v_rpadc) {
|
|
$value_rpad = $v_rpadc['segment_name'].' - '.$v_rpadc['label'];
|
|
if($v_rpadc['value'] != '')
|
|
$value_rpad = $value_rpad.' : '.$v_rpadc['value'];
|
|
$riwayat_penyakit_alergi_dahulu_form[] = $value_rpad;
|
|
}
|
|
}
|
|
}
|
|
$riwayat_penyakit_alergi_dahulu_form = join(", ",$riwayat_penyakit_alergi_dahulu_form);
|
|
$riwayat_penyakit_alergi_dahulu_x = $data_anamesa_text['riwayatPenyakitDanAlergiDahulu'];
|
|
if($riwayat_penyakit_alergi_dahulu_x == '')
|
|
$riwayat_penyakit_alergi_dahulu_x = $riwayat_penyakit_alergi_dahulu_form;
|
|
$riwayat_penyakit_alergi_dahulu[] = $riwayat_penyakit_alergi_dahulu_x;
|
|
|
|
//$riwayat_penyakit_alergi_sekarang[] = array('text' => $data_anamesa_text['riwayatPenyakitDanAlergiSekarang'], 'form' => $data_anamesa_form['riwayatPenyakitDanAlergiSekarang'] );
|
|
$riwayat_penyakit_alergi_sekarang_form = [];
|
|
$riwayat_penyakit_alergi_sekarang_f = $data_anamesa_form['riwayatPenyakitDanAlergiSekarang'];
|
|
if(count($riwayat_penyakit_alergi_sekarang_f) > 0){
|
|
foreach ($riwayat_penyakit_alergi_sekarang_f as $k_rpas => $v_rpas) {
|
|
foreach ($v_rpas['value'] as $k_rpasc => $v_rpasc) {
|
|
$value_rpas = $v_rpasc['segment_name'].' - '.$v_rpasc['label'];
|
|
if($v_rpasc['value'] != '')
|
|
$value_rpas = $value_rpas.' : '.$v_rpasc['value'];
|
|
$riwayat_penyakit_alergi_sekarang_form[] = $value_rpas;
|
|
}
|
|
}
|
|
}
|
|
$riwayat_penyakit_alergi_sekarang_form = join(", ",$riwayat_penyakit_alergi_sekarang_form);
|
|
$riwayat_penyakit_alergi_sekarang_x = $data_anamesa_text['riwayatPenyakitDanAlergiSekarang'];
|
|
if($riwayat_penyakit_alergi_sekarang_x == '')
|
|
$riwayat_penyakit_alergi_sekarang_x = $riwayat_penyakit_alergi_sekarang_form;
|
|
$riwayat_penyakit_alergi_sekarang[] = $riwayat_penyakit_alergi_sekarang_x;
|
|
|
|
//$riwayat_penyakit_alergi_keluarga[] = array('text' => $data_anamesa_text['riwayatPenyakitKeluarga'], 'form' => $data_anamesa_form['riwayatPenyakitKeluarga'] );
|
|
$riwayat_penyakit_alergi_keluarga_form = [];
|
|
foreach ($data_anamesa_form['riwayatPenyakitKeluarga'] as $v_rpak) {
|
|
foreach ($v_rpak['value'] as $v_rpakc) {
|
|
$riwayat_penyakit_alergi_keluarga_form[] = $v_rpak['name'] . ' - ' . $v_rpakc;
|
|
}
|
|
}
|
|
$riwayat_penyakit_alergi_keluarga_form = implode(", ", $riwayat_penyakit_alergi_keluarga_form);
|
|
$riwayat_penyakit_alergi_keluarga_x = $data_anamesa_text['riwayatPenyakitKeluarga'] ?: $riwayat_penyakit_alergi_keluarga_form;
|
|
$riwayat_penyakit_alergi_keluarga[] = $riwayat_penyakit_alergi_keluarga_x;
|
|
|
|
//$riwayat_pengobatan[] = array('text' => $data_anamesa_text['riwayatPengobatan'], 'form' => $data_anamesa_form['riwayatPengobatan'] );
|
|
$riwayat_pengobatan_form = [];
|
|
foreach ($data_anamesa_form['riwayatPengobatan'] as $v_rpak) {
|
|
$value_pengobatan = $v_rpak['label'];
|
|
if($v_rpak['value'] != '')
|
|
$value_pengobatan = $v_rpak['label'].' - ' . $v_rpak['value'];
|
|
$riwayat_pengobatan_form[] = $value_pengobatan;
|
|
}
|
|
$riwayat_pengobatan_form = implode(", ", $riwayat_pengobatan_form);
|
|
$riwayat_pengobatan_x = $data_anamesa_text['riwayatPengobatan'] ?: $riwayat_pengobatan_form;
|
|
$riwayat_pengobatan[] = $riwayat_pengobatan_x;
|
|
|
|
//$riwayat_sosial[] = array('text' => $data_anamesa_text['riwayatSosial'], 'form' => $data_anamesa_form['riwayatSosial'] );
|
|
$riwayat_sosial_form = [];
|
|
foreach ($data_anamesa_form['riwayatSosial'] as $v_rpak) {
|
|
$value_sosial = $v_rpak['name'].' : ' . $v_rpak['value'];
|
|
$riwayat_sosial_form[] = $value_sosial;
|
|
}
|
|
$riwayat_sosial_form = implode(", ", $riwayat_sosial_form);
|
|
$riwayat_sosial_x = $data_anamesa_text['riwayatSosial'] ?: $riwayat_sosial_form;
|
|
$riwayat_sosial[] = $riwayat_sosial_x == ''?'-':$riwayat_sosial_x;
|
|
|
|
$riwayat_operasi[] = $data_anamesa_text['riwayatOperasi'] == ''?'-':$data_anamesa_text['riwayatOperasi'];
|
|
|
|
$hepatitis_a_label = $data_anamesa_form['riwayatImunisasi'][0]['value'][0]['label'];
|
|
$hepatitis_a_value = $data_anamesa_form['riwayatImunisasi'][0]['value'][0]['value'];
|
|
$hepatitis_a_form = $hepatitis_a_label;
|
|
if($hepatitis_a_value != '')
|
|
$hepatitis_a_form = $hepatitis_a_label.' ( '.$hepatitis_a_value.' )';
|
|
$hepatitis_a[] = $hepatitis_a_form?$hepatitis_a_form:'-';
|
|
|
|
$hepatitis_b_label = $data_anamesa_form['riwayatImunisasi'][1]['value'][0]['label'];
|
|
$hepatitis_b_value = $data_anamesa_form['riwayatImunisasi'][1]['value'][0]['value'];
|
|
$hepatitis_b_form = $hepatitis_b_label;
|
|
if($hepatitis_b_value != '')
|
|
$hepatitis_b_form = $hepatitis_b_label.' ( '.$hepatitis_b_value.' )';
|
|
$hepatitis_b[] = $hepatitis_b_form?$hepatitis_b_form:'-';
|
|
|
|
$covid_1_label = $data_anamesa_form['riwayatImunisasi'][2]['value'][0]['label'];
|
|
$covid_1_value = $data_anamesa_form['riwayatImunisasi'][2]['value'][0]['value'];
|
|
$covid_1_form = $covid_1_label;
|
|
if($covid_1_value != '')
|
|
$covid_1_form = $covid_1_label.' ( '.$covid_1_value.' )';
|
|
$covid_1[] = $covid_1_form?$covid_1_form:'-';
|
|
|
|
$covid_2_label = $data_anamesa_form['riwayatImunisasi'][3]['value'][0]['label'];
|
|
$covid_2_value = $data_anamesa_form['riwayatImunisasi'][3]['value'][0]['value'];
|
|
$covid_2_form = $covid_2_label;
|
|
if($covid_2_value != '')
|
|
$covid_2_form = $covid_2_label.' ( '.$covid_2_value.' )';
|
|
$covid_2[] = $covid_2_form?$covid_2_form:'-';
|
|
|
|
$covid_3_label = $data_anamesa_form['riwayatImunisasi'][4]['value'][0]['label'];
|
|
$covid_3_value = $data_anamesa_form['riwayatImunisasi'][4]['value'][0]['value'];
|
|
$covid_3_form = $covid_3_label;
|
|
if($covid_3_value != '')
|
|
$covid_3_form = $covid_3_label.' ( '.$covid_3_value.' )';
|
|
$covid_3[] = $covid_3_form?$covid_3_form:'-';
|
|
|
|
//$anamnesa[] = $data_anamesa;
|
|
$data_periksa_doctor = $this->get_data_order_doctor($value['orderID']);
|
|
$periksa_doctor[] = $data_periksa_doctor;
|
|
$dena = $data_periksa_doctor['form']['vitalSign'][0]['details'][0]['value'];
|
|
//echo $dena;
|
|
$denyut_nadi[] = $dena == ''?'-':$dena;
|
|
$ritme_x = $data_periksa_doctor['form']['vitalSign'][0]['details'][1]['chx_x'];
|
|
$label_ritme_x = $data_periksa_doctor['form']['vitalSign'][0]['details'][1]['label_x'];
|
|
$ritme_y = $data_periksa_doctor['form']['vitalSign'][0]['details'][1]['chx_y'];
|
|
$label_ritme_y = $data_periksa_doctor['form']['vitalSign'][0]['details'][1]['label_y'];
|
|
$ritme_denyut_nadi[] = $ritme_x?$label_ritme_x:$label_ritme_y;
|
|
$lper = $data_periksa_doctor['form']['vitalSign'][0]['details'][2]['value'];
|
|
$laju_pernapasan[] = $lper == ''?'-':$lper;
|
|
$polanapas = $data_periksa_doctor['form']['vitalSign'][0]['details'][3]['value'];
|
|
$polanapas_x = $data_periksa_doctor['form']['vitalSign'][0]['details'][3]['chx_x'];
|
|
$label_polanapas_x = $data_periksa_doctor['form']['vitalSign'][0]['details'][3]['label_x'];
|
|
$polanapas_y = $data_periksa_doctor['form']['vitalSign'][0]['details'][3]['chx_y'];
|
|
$label_polanapas_y = $data_periksa_doctor['form']['vitalSign'][0]['details'][3]['label_y'];
|
|
$pola_nafas[] = $polanapas_x?$label_polanapas_x:$label_polanapas_y;
|
|
$tdx = '-';
|
|
if($data_periksa_doctor['form']['vitalSign'][0]['details'][4]['value'] != '')
|
|
$tdx = $data_periksa_doctor['form']['vitalSign'][0]['details'][4]['value'].' ( '.$data_periksa_doctor['form']['vitalSign'][0]['details'][4]['value_x'].' ) [ '.$data_periksa_doctor['form']['vitalSign'][0]['details'][4]['standart'].' ]';
|
|
$tekanan_darah[] = $tdx;
|
|
$value_suhu = $data_periksa_doctor['form']['vitalSign'][0]['details'][5]['value'];
|
|
$suhu_demam = $data_periksa_doctor['form']['vitalSign'][0]['details'][5]['chx_x'];
|
|
$suhu_unit = $data_periksa_doctor['form']['vitalSign'][0]['details'][5]['unit'];
|
|
$suhux = "";
|
|
if($value_suhu != "")
|
|
$suhux = $value_suhu." ".$suhu_unit;
|
|
else
|
|
$suhux = $suhu_demam ? "Demam":"Normal";
|
|
|
|
//echo $suhux;
|
|
$suhu[] = $suhux == ""?"-":$suhux;
|
|
$bb = $data_periksa_doctor['form']['vitalSign'][1]['details'][0]['value'];
|
|
$berat_badan[] = $bb == ''?'-':$bb;
|
|
$tb = $data_periksa_doctor['form']['vitalSign'][1]['details'][1]['value'];
|
|
$tinggi_badan[] = $tb == ''?'-':$tb;
|
|
$lp = $data_periksa_doctor['form']['vitalSign'][1]['details'][2]['value'];
|
|
$lingkar_perut[] = $lp == ''?'-':$lp;
|
|
$bmix = $data_periksa_doctor['form']['vitalSign'][1]['details'][3]['value'];
|
|
$bmi[] = $bmix == ''?'-':$bmix;
|
|
$lping = $data_periksa_doctor['form']['vitalSign'][1]['details'][4]['value'];
|
|
$lingkar_pinggang[] = $lping == ''?'-':$lping;
|
|
$klas_bmi = $data_periksa_doctor['form']['vitalSign'][1]['details'][5]['value'];
|
|
if($klas_bmi != '')
|
|
$klas_bmi = $data_periksa_doctor['form']['vitalSign'][1]['details'][5]['value'].' [ '.$data_periksa_doctor['form']['vitalSign'][1]['standart_bmi'].' ]';
|
|
else
|
|
$klas_bmi = '-';
|
|
$klasifikasi_bmi[] = $klas_bmi;
|
|
$order_penunjang[] = $this->get_order_penunjang($orderID);
|
|
$xfisik = $data_periksa_doctor['text']['fisik'];
|
|
$fisik[] = $xfisik;
|
|
$diagnosisPrimer = $data_periksa_doctor['text']['diagnosisPrimer'];
|
|
$diagnosis_primer[] = $diagnosisPrimer;
|
|
$diagnosisSekunder = $data_periksa_doctor['text']['diagnosisSekunder'];
|
|
$diagnosis_sekunder[] = $diagnosisSekunder;
|
|
$receipt[] = $data_periksa_doctor['text']['receipt'];
|
|
$saran[] = $data_periksa_doctor['text']['saran'];
|
|
$tindakan[] = $data_periksa_doctor['text']['tindakan'];
|
|
|
|
// Vaksinasi per order
|
|
$qv = $this->db_oneklinik->query(
|
|
"SELECT ov.*,
|
|
t.T_TestName as jenis_vaksin_name,
|
|
t.T_TestSasCode as jenis_vaksin_code,
|
|
ins.M_InjectionSiteName as injection_site_name,
|
|
rv.M_RouteVaccineName as route_name,
|
|
s.M_StaffName as petugas_name
|
|
FROM one_klinik.order_vaccine ov
|
|
LEFT JOIN one_lab.t_test t ON ov.orderVaccineT_TestID = t.T_TestID
|
|
LEFT JOIN one_klinik.m_injection_site ins ON ov.orderVaccineInjectionSiteCode = ins.M_InjectionSiteCode
|
|
LEFT JOIN one_klinik.m_route_vaccine rv ON ov.orderVaccineRouteCode = rv.M_RouteVaccineCode
|
|
LEFT JOIN one_lab.m_staff s ON ov.orderVaccinePetugasM_StaffID = s.M_StaffID
|
|
WHERE ov.orderVaccineOrderID = ? AND ov.orderVaccineIsActive = 'Y'
|
|
ORDER BY ov.orderVaccineCreated ASC",
|
|
[$value['orderID']]
|
|
);
|
|
$vaksinasi_list[] = $qv ? $qv->result_array() : [];
|
|
|
|
// Tindakan medis per order
|
|
$qt = $this->db_oneklinik->query(
|
|
"SELECT ot.*,
|
|
t.T_TestName as jenis_tindakan_name,
|
|
t.T_TestSasCode as jenis_tindakan_code,
|
|
d.M_DoctorName as dokter_name
|
|
FROM one_klinik.order_tindakan ot
|
|
LEFT JOIN one_lab.t_test t ON ot.orderTindakanT_TestID = t.T_TestID
|
|
LEFT JOIN one_lab.m_doctor d ON ot.orderTindakanM_DoctorID = d.M_DoctorID
|
|
WHERE ot.orderTindakanOrderID = ? AND ot.orderTindakanIsActive = 'Y'
|
|
ORDER BY ot.orderTindakanCreated ASC",
|
|
[$value['orderID']]
|
|
);
|
|
$tindakan_medis_list[] = $qt ? $qt->result_array() : [];
|
|
}
|
|
|
|
$data_orders['date_orders'] = $date_orders;
|
|
$data_orders['doctor'] = $doctor;
|
|
$data_orders['keluhan_utama'] = $keluhan_utama;
|
|
$data_orders['riwayat_penyakit_alergi_dahulu'] = $riwayat_penyakit_alergi_dahulu;
|
|
$data_orders['riwayat_penyakit_alergi_sekarang'] = $riwayat_penyakit_alergi_sekarang;
|
|
$data_orders['riwayat_penyakit_alergi_keluarga'] = $riwayat_penyakit_alergi_keluarga;
|
|
$data_orders['riwayat_pengobatan'] = $riwayat_pengobatan;
|
|
$data_orders['riwayat_sosial'] = $riwayat_sosial;
|
|
$data_orders['riwayat_operasi'] = $riwayat_operasi;
|
|
$data_orders['hepatitis_a'] = $hepatitis_a;
|
|
$data_orders['hepatitis_b'] = $hepatitis_b;
|
|
$data_orders['covid_1'] = $covid_1;
|
|
$data_orders['covid_2'] = $covid_2;
|
|
$data_orders['covid_3'] = $covid_3;
|
|
$data_orders['anamnesa'] = $anamnesa;
|
|
$data_orders['periksa_doctor'] = $periksa_doctor;
|
|
$data_orders['denyut_nadi'] = $denyut_nadi;
|
|
$data_orders['ritme_denyut_nadi'] = $ritme_denyut_nadi;
|
|
$data_orders['laju_pernapasan'] = $laju_pernapasan;
|
|
$data_orders['pola_nafas'] = $pola_nafas;
|
|
$data_orders['tekanan_darah'] = $tekanan_darah;
|
|
$data_orders['berat_badan'] = $berat_badan;
|
|
$data_orders['tinggi_badan'] = $tinggi_badan;
|
|
$data_orders['lingkar_perut'] = $lingkar_perut;
|
|
$data_orders['suhu'] = $suhu;
|
|
$data_orders['bmi'] = $bmi;
|
|
$data_orders['lingkar_pinggang'] = $lingkar_pinggang;
|
|
$data_orders['klasifikasi_bmi'] = $klasifikasi_bmi;
|
|
$data_orders['fisik'] = $fisik;
|
|
$data_orders['diagnosis_primer'] = $diagnosis_primer;
|
|
$data_orders['diagnosis_sekunder'] = $diagnosis_sekunder;
|
|
$data_orders['receipt'] = $receipt;
|
|
$data_orders['saran'] = $saran;
|
|
$data_orders['tindakan'] = $tindakan;
|
|
$data_orders['vaksinasi_list'] = $vaksinasi_list;
|
|
$data_orders['tindakan_medis_list'] = $tindakan_medis_list;
|
|
$data_orders['pemeriksaan_penunjang'] = $pemeriksaan_penunjang;
|
|
|
|
$this->sys_ok($data_orders);
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
function get_patient_id_by_orderID($orderID){
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order
|
|
WHERE orderID = ?
|
|
AND orderIsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order");
|
|
}
|
|
$order = $query->row_array();
|
|
return $order['orderM_PatientID'];
|
|
}
|
|
|
|
|
|
function get_order_by_patientID($patientID,$orderID,$Isreopen){
|
|
if($Isreopen == 'Y'){
|
|
$sql = "SELECT * , CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order
|
|
JOIN m_patient ON orderM_PatientID = M_PatientID
|
|
JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
WHERE orderM_PatientID = ? AND orderIsActive = 'Y' AND orderID <= ?
|
|
ORDER BY orderDate DESC";
|
|
}else{
|
|
$sql = "SELECT * , CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order
|
|
JOIN m_patient ON orderM_PatientID = M_PatientID
|
|
JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
WHERE orderM_PatientID = ? AND orderIsActive = 'Y' AND orderID < ?
|
|
ORDER BY orderDate DESC";
|
|
}
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($patientID,$orderID));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order by patient");
|
|
}
|
|
|
|
$rtn = $query->result_array();
|
|
//print_r($rtn);
|
|
return $rtn;
|
|
}
|
|
|
|
|
|
function get_order_penunjang($orderID){
|
|
$sql = "SELECT T_TestName
|
|
FROM one_klinik.order_penunjang
|
|
JOIN t_test ON orderPenunjangT_TestID = T_TestID
|
|
WHERE orderPenunjangOrderID = ? AND orderPenunjangIsActive = 'Y' ";
|
|
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
//echo $this->db_oneklinik->last_query();
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get_order_penunjang");
|
|
}
|
|
|
|
$rtn = $query->result_array();
|
|
$tests = [];
|
|
foreach ($rtn as $key => $value) {
|
|
$tests[] = $value['T_TestName'];
|
|
}
|
|
//print_r($rtn);
|
|
$rtnx = join(', ',$tests);
|
|
return $rtnx;
|
|
}
|
|
|
|
function get_data_order_anamnesis($orderID){
|
|
$riwayats_text = array(
|
|
'keluhanUtama' => "",
|
|
'riwayatPenyakitDanAlergiDahulu' => "",
|
|
'riwayatPenyakitDanAlergiSekarang' => "",
|
|
'riwayatPenyakitKeluarga' => "",
|
|
'riwayatPengobatan' =>"",
|
|
'riwayatSosial' => "",
|
|
'riwayatOperasi' => "",
|
|
'riwayatAlergi' => "",
|
|
'riwayatImunisasi' => ""
|
|
);
|
|
|
|
$sql = "SELECT * FROM one_klinik.order_anamnesis
|
|
WHERE orderAnamnesisOrderID = ? AND
|
|
orderAnamnesisIsActive = 'Y' AND
|
|
orderAnamnesisTypeForm = 'TEXT'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data anamnesis text");
|
|
}
|
|
|
|
$data_order_anamnesis_text = $query->row_array();
|
|
if($data_order_anamnesis_text){
|
|
$riwayats_text['keluhanUtama'] = $data_order_anamnesis_text['orderAnamnesisKeluhanUtama'];
|
|
$riwayats_text['riwayatPenyakitDanAlergiDahulu'] = $data_order_anamnesis_text['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'];
|
|
$riwayats_text['riwayatPenyakitDanAlergiSekarang'] = $data_order_anamnesis_text['orderAnamnesisRiwayatPenyakitDanAlergiSekarang'];
|
|
$riwayats_text['riwayatPenyakitKeluarga'] = $data_order_anamnesis_text['orderAnamnesisRiwayatPenyakitKeluarga'];
|
|
$riwayats_text['riwayatPengobatan'] = $data_order_anamnesis_text['orderAnamnesisRiwayatPengobatan'];
|
|
$riwayats_text['riwayatSosial'] = $data_order_anamnesis_text['orderAnamnesisRiwayatSosial'];
|
|
$riwayats_text['riwayatOperasi'] = $data_order_anamnesis_text['orderAnamnesisRiwayatOperasi'];
|
|
$riwayats_text['riwayatAlergi'] = $data_order_anamnesis_text['orderAnamnesisRiwayatAlergi'];
|
|
$riwayats_text['riwayatImunisasi'] = $data_order_anamnesis_text['orderAnamnesisRiwayatImunisasi'];
|
|
}
|
|
|
|
$riwayats_form = array(
|
|
'keluhanUtama' => "",
|
|
'riwayatPenyakitDanAlergiDahulu' => "",
|
|
'riwayatPenyakitDanAlergiSekarang' => "",
|
|
'riwayatPenyakitKeluarga' => "",
|
|
'riwayatPengobatan' => "",
|
|
'riwayatSosial' => "",
|
|
'riwayatOperasi' => "",
|
|
'riwayatAlergi' => "",
|
|
'riwayatImunisasi' => ""
|
|
);
|
|
|
|
$sql = "SELECT * FROM one_klinik.order_anamnesis
|
|
WHERE orderAnamnesisOrderID = ? AND
|
|
orderAnamnesisIsActive = 'Y' AND
|
|
orderAnamnesisTypeForm = 'FORM'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data anamnesis form");
|
|
}
|
|
//echo $this->db_oneklinik->last_query();
|
|
$data_order_anamnesis_form = $query->row_array();
|
|
if($data_order_anamnesis_form){
|
|
|
|
$keluhanSaatIniValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisKeluhanUtama'] != ""){
|
|
$keluhanSaatIni = json_decode($data_order_anamnesis_form['orderAnamnesisKeluhanUtama'], true);
|
|
foreach ($keluhanSaatIni[0]['details'] as $detail) {
|
|
if ($detail['chx']) {
|
|
$keluhanSaatIniValue[] = $detail;
|
|
}
|
|
}
|
|
}
|
|
|
|
$riwayats_form['keluhanUtama'] = $keluhanSaatIniValue;
|
|
|
|
$riwayatPenyakitDahuluValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'] != ""){
|
|
$riwayatPenyakitDahulu = json_decode($data_order_anamnesis_form['orderAnamnesisRiwayatPenyakitDanAlergiDahulu'], true);
|
|
|
|
foreach ($riwayatPenyakitDahulu[0]['details'] as $detail) {
|
|
$detail_sub = [];
|
|
foreach ($detail['details'] as $value) {
|
|
if($value['chx'] == 1){
|
|
$detail_sub[] = $value;
|
|
}
|
|
}
|
|
if(count($detail_sub) > 0){
|
|
$riwayatPenyakitDahuluValue[] = array(
|
|
'name' => $detail['name'],
|
|
'value' => $detail_sub
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
$riwayats_form['riwayatPenyakitDanAlergiDahulu'] = $riwayatPenyakitDahuluValue;
|
|
|
|
$riwayatPenyakitSekarangValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisRiwayatPenyakitDanAlergiSekarang'] != ""){
|
|
$riwayatPenyakitSekarang = json_decode($data_order_anamnesis_form['orderAnamnesisRiwayatPenyakitDanAlergiSekarang'], true);
|
|
foreach ($riwayatPenyakitSekarang[0]['details'] as $detail) {
|
|
$detail_sub = [];
|
|
foreach ($detail['details'] as $value) {
|
|
if($value['chx'] == 1){
|
|
$detail_sub[] = $value;
|
|
}
|
|
}
|
|
if(count($detail_sub) > 0){
|
|
$riwayatPenyakitSekarangValue[] = array(
|
|
'name' => $detail['name'],
|
|
'value' => $detail_sub
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
$riwayats_form['riwayatPenyakitDanAlergiSekarang'] = $riwayatPenyakitSekarangValue;
|
|
|
|
$riwayatPenyakitKeluargaValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisRiwayatPenyakitKeluarga'] != ""){
|
|
$riwayatPenyakitKeluarga = json_decode($data_order_anamnesis_form['orderAnamnesisRiwayatPenyakitKeluarga'], true);
|
|
foreach ($riwayatPenyakitKeluarga[0]['details'] as $detail) {
|
|
$detail_sub = [];
|
|
foreach ($detail['options'] as $value) {
|
|
if($value['selected']){
|
|
$detail_sub[] = $value['label'];
|
|
}
|
|
}
|
|
if(count($detail_sub) > 0){
|
|
$riwayatPenyakitKeluargaValue[] = array(
|
|
'name' => $detail['label'],
|
|
'value' => $detail_sub
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
$riwayats_form['riwayatPenyakitKeluarga'] = $riwayatPenyakitKeluargaValue;
|
|
|
|
$riwayatPengobatanValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisRiwayatPengobatan'] != ""){
|
|
$riwayatPengobatan = json_decode($data_order_anamnesis_form['orderAnamnesisRiwayatPengobatan'], true);
|
|
foreach ($riwayatPengobatan[0]['details'] as $detail) {
|
|
if ($detail['chx']) {
|
|
$riwayatPengobatanValue[] = $detail;
|
|
}
|
|
}
|
|
}
|
|
|
|
$riwayats_form['riwayatPengobatan'] = $riwayatPengobatanValue;
|
|
|
|
$riwayatSosialValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisRiwayatSosial'] != ""){
|
|
$riwayatSosial = json_decode($data_order_anamnesis_form['orderAnamnesisRiwayatSosial'], true);
|
|
foreach ($riwayatSosial[0]['details'] as $detail) {
|
|
$detail_sub = '';
|
|
foreach ($detail['details'] as $value) {
|
|
if($value['chx']){
|
|
$xvalue = $value['label'];
|
|
if($value['value'] != '')
|
|
$xvalue = $xvalue.' - '.$value['value'];
|
|
$detail_sub = $xvalue;
|
|
}
|
|
}
|
|
if($detail_sub != ''){
|
|
$riwayatSosialValue[] = array(
|
|
'name' => $detail['name'],
|
|
'value' => $detail_sub
|
|
);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
$riwayats_form['riwayatSosial'] = $riwayatSosialValue;
|
|
|
|
$riwayatImunisasiValue = [];
|
|
if($data_order_anamnesis_form['orderAnamnesisRiwayatImunisasi'] != ""){
|
|
$riwayatImunisasi = json_decode($data_order_anamnesis_form['orderAnamnesisRiwayatImunisasi'], true);
|
|
foreach ($riwayatImunisasi[0]['details'] as $detail) {
|
|
$detail_sub = [];
|
|
foreach ($detail['details'] as $value) {
|
|
if($value['chx']){
|
|
$detail_sub[] = $value;
|
|
}
|
|
}
|
|
if(count($detail_sub) > 0){
|
|
$riwayatImunisasiValue[] = array(
|
|
'name' => $detail['label'],
|
|
'value' => $detail_sub
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
$riwayats_form['riwayatImunisasi'] = $riwayatImunisasiValue;
|
|
|
|
|
|
}
|
|
|
|
return array('text'=>$riwayats_text,'form'=>$riwayats_form);
|
|
}
|
|
|
|
function get_data_order_doctor($orderID){
|
|
$doctor_text = array(
|
|
'vitalSign' => "",
|
|
'fisik' => "",
|
|
'receipt' => "",
|
|
'diagnosisPrimer' => "",
|
|
'diagnosisSekunder' => "",
|
|
'saran' => "",
|
|
'tindakan' => ""
|
|
);
|
|
$sql = "SELECT * , CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order_doctor
|
|
JOIN one_klinik.order ON orderDoctorOrderID = orderID
|
|
JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
|
WHERE orderDoctorOrderID = ?
|
|
AND orderDoctorIsActive = 'Y'
|
|
AND orderDoctorType = 'TEXT'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
echo $this->db_oneklinik->last_query();
|
|
$this->sys_error("Gagal get data order doctor");
|
|
}
|
|
|
|
$data_order_doctor_text = $query->row_array();
|
|
if($data_order_doctor_text){
|
|
$doctor_text['vitalSign'] = $data_order_doctor_text['orderDoctorVitalSign'];
|
|
|
|
$doctor_text['fisik'] = array();
|
|
if($data_order_doctor_text['orderDoctorFisik'] != '')
|
|
$doctor_text['fisik'][] = array('doctor' => $data_order_doctor_text['doctor_name'],'value' => $data_order_doctor_text['orderDoctorFisik']);
|
|
|
|
$doctor_text['receipt'] = array();
|
|
if($data_order_doctor_text['orderDoctorReceipt'] != '')
|
|
$doctor_text['receipt'][] = array('doctor' => $data_order_doctor_text['doctor_name'],'value' => $data_order_doctor_text['orderDoctorReceipt']);
|
|
|
|
$doctor_text['diagnosisPrimer'] = array();
|
|
if($data_order_doctor_text['orderDoctorDiagnosePrimer'] != ''){
|
|
$icd10 = '';
|
|
$sql = "SELECT CONCAT(code,' | ', display) as display_name
|
|
FROM one_klinik.order_diagnose_icd10
|
|
JOIN one_terminology.terminology ON code = orderDiagnoseIcd10Primary AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order_diagnose_icd10");
|
|
exit;
|
|
}
|
|
|
|
$data_icd10 = $query->row_array();
|
|
if($data_icd10)
|
|
$icd10 = $data_icd10['display_name'];
|
|
|
|
$doctor_text['diagnosisPrimer'][] = array(
|
|
'doctor' => $data_order_doctor_text['doctor_name'],
|
|
'value' => $data_order_doctor_text['orderDoctorDiagnosePrimer'],
|
|
'icd10' => $icd10
|
|
);
|
|
}
|
|
|
|
|
|
$doctor_text['saran'] = array();
|
|
if($data_order_doctor_text['orderDoctorSaran'] != '')
|
|
$doctor_text['saran'][] = array('doctor' => $data_order_doctor_text['doctor_name'],'value' => $data_order_doctor_text['orderDoctorSaran']);
|
|
|
|
$doctor_text['diagnosisSekunder'] = array();
|
|
if($data_order_doctor_text['orderDoctorDiagnoseSekunder'] != ''){
|
|
$icd10 = '';
|
|
$sql = "SELECT CONCAT(code,' | ', display) as display_name
|
|
FROM one_klinik.order_diagnose_icd10
|
|
JOIN one_terminology.terminology ON code = orderDiagnoseIcd10Sekunder AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDiagnoseIcd10OrderID = ? AND orderDiagnoseIcd10IsActive = 'Y'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Invalid get order_diagnose_icd10");
|
|
exit;
|
|
}
|
|
|
|
$data_icd10 = $query->row_array();
|
|
if($data_icd10)
|
|
$icd10 = $data_icd10['display_name'];
|
|
|
|
$doctor_text['diagnosisSekunder'][] = array(
|
|
'doctor' => $data_order_doctor_text['doctor_name'],
|
|
'value' => $data_order_doctor_text['orderDoctorDiagnoseSekunder'],
|
|
'icd10' => $icd10
|
|
);
|
|
}
|
|
|
|
$doctor_text['tindakan'] = array();
|
|
if($data_order_doctor_text['orderDoctorMedic'] != '')
|
|
$doctor_text['tindakan'][] = array('doctor' => $data_order_doctor_text['doctor_name'],'value' => $data_order_doctor_text['orderDoctorMedic']);
|
|
}
|
|
|
|
$doctor_form = array(
|
|
'vitalSign' => "",
|
|
'receipt' => "",
|
|
'diagnosisPrimer' => "",
|
|
'diagnosisSekunder' => "",
|
|
'saran' => "",
|
|
'tindakan' => ""
|
|
);
|
|
|
|
$sql = "SELECT *
|
|
FROM one_klinik.order_doctor
|
|
WHERE orderDoctorOrderID = ?
|
|
AND orderDoctorIsActive = 'Y'
|
|
AND orderDoctorType = 'FORM'
|
|
LIMIT 1";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order doctor");
|
|
}
|
|
$data_order_doctor_form = $query->row_array();
|
|
if($data_order_doctor_form){
|
|
if($data_order_doctor_form['orderDoctorVitalSign'] != ""){
|
|
$doctor_form['vitalSign'] = json_decode($data_order_doctor_form['orderDoctorVitalSign'], true);
|
|
}
|
|
}
|
|
|
|
|
|
$sql = "SELECT * , CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = 'RECEIPT' AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order doctor additional receipt");
|
|
}
|
|
$data_order_doctor_additional_r = $query->result_array();
|
|
foreach ($data_order_doctor_additional_r as $key_receipt => $value_receipt) {
|
|
$doctor_text['receipt'][] = array('doctor' => $value_receipt['doctor_name'],'value' => $value_receipt['orderDoctorAdditionalValue']);
|
|
}
|
|
|
|
$sql = "SELECT * ,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name,
|
|
CONCAT(code,' | ', display) as display_name, IFNULL(display,'X') as status_icd10
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
LEFT JOIN one_terminology.terminology ON code = orderDoctorAdditionalICD10Code AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = 'DIAGPRIMER' AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order doctor additional diagprimer");
|
|
}
|
|
$data_order_doctor_additional_dp = $query->result_array();
|
|
foreach ($data_order_doctor_additional_dp as $key_dprimer => $value_dprimer) {
|
|
$doctor_text['diagnosisPrimer'][] = array(
|
|
'doctor' => $value_dprimer['doctor_name'],
|
|
'value' => $value_dprimer['orderDoctorAdditionalValue'],
|
|
'icd10' => $value_dprimer['display_name']
|
|
);
|
|
}
|
|
|
|
$sql = "SELECT * ,
|
|
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name,
|
|
CONCAT(code,' | ', display) as display_name, IFNULL(display,'X') as status_icd10
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
LEFT JOIN one_terminology.terminology ON code = orderDoctorAdditionalICD10Code AND attribute_path = 'icd10'
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = 'DIAGSEKUNDER' AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order doctor additional diagsekunder");
|
|
}
|
|
$data_order_doctor_additional_ds = $query->result_array();
|
|
foreach ($data_order_doctor_additional_ds as $key_dsekunder => $value_dsekunder) {
|
|
$doctor_text['diagnosisSekunder'][] = array(
|
|
'doctor' => $value_dsekunder['doctor_name'],
|
|
'value' => $value_dsekunder['orderDoctorAdditionalValue'],
|
|
'icd10' => $value_dprimer['display_name']
|
|
);
|
|
}
|
|
|
|
$sql = "SELECT * , CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = 'MEDIC' AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order doctor additional tindakan");
|
|
}
|
|
$data_order_doctor_additional_tindakan = $query->result_array();
|
|
foreach ($data_order_doctor_additional_tindakan as $key_tindakan => $value_tindakan) {
|
|
$doctor_text['tindakan'][] = array('doctor' => $value_tindakan['doctor_name'],'value' => $value_tindakan['orderDoctorAdditionalValue']);
|
|
}
|
|
|
|
$sql = "SELECT * , CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_name
|
|
FROM one_klinik.order_doctor_additional
|
|
JOIN m_doctor ON orderDoctorAdditionalM_DoctorID = M_DoctorID
|
|
WHERE
|
|
orderDoctorAdditionalOrderID = ? AND
|
|
orderDoctorAdditionalType = 'SARAN' AND
|
|
orderDoctorAdditionalIsActive = 'Y'";
|
|
$query = $this->db_oneklinik->query($sql, array($orderID));
|
|
if (!$query) {
|
|
$this->sys_error("Gagal get data order doctor additional saran");
|
|
}
|
|
$data_order_doctor_additional_saran = $query->result_array();
|
|
foreach ($data_order_doctor_additional_saran as $key_saran => $value_saran) {
|
|
$doctor_text['saran'][] = array('doctor' => $value_saran['doctor_name'],'value' => $value_saran['orderDoctorAdditionalValue']);
|
|
}
|
|
|
|
|
|
return array('text'=>$doctor_text,'form'=>$doctor_form);
|
|
}
|
|
|
|
// ─── Vaksin ────────────────────────────────────────────────────────────────
|
|
|
|
// Master statis: injection_sites, routes (dipanggil sekali saat form dibuka)
|
|
function get_vaccine_masters()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
// Lokasi suntik
|
|
$q = $this->db_oneklinik->query(
|
|
"SELECT M_InjectionSiteCode as code, M_InjectionSiteName as name
|
|
FROM one_klinik.m_injection_site
|
|
WHERE M_InjectionSiteIsActive = 'Y'
|
|
ORDER BY M_InjectionSiteID"
|
|
);
|
|
if (!$q) { $this->sys_error_db("get m_injection_site", $this->db_oneklinik); exit; }
|
|
$result['injection_sites'] = $q->result_array();
|
|
|
|
// Rute vaksin
|
|
$q = $this->db_oneklinik->query(
|
|
"SELECT M_RouteVaccineCode as code, M_RouteVaccineName as name
|
|
FROM one_klinik.m_route_vaccine
|
|
WHERE M_RouteVaccineIsActive = 'Y'
|
|
ORDER BY M_RouteVaccineID"
|
|
);
|
|
if (!$q) { $this->sys_error_db("get m_route_vaccine", $this->db_oneklinik); exit; }
|
|
$result['routes'] = $q->result_array();
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
// Autocomplete petugas penyuntik dari one_lab.m_staff, param: search
|
|
function get_vaccine_petugas()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$search = trim($this->sys_input['search'] ?? '');
|
|
$search_esc = $this->db_onedev->escape_str($search);
|
|
|
|
$sql = "SELECT M_StaffID as id, M_StaffName as name, M_StaffCode as code
|
|
FROM one_lab.m_staff
|
|
WHERE M_StaffIsActive = 'Y'
|
|
AND M_StaffName LIKE CONCAT('%', '{$search_esc}', '%')
|
|
ORDER BY M_StaffName
|
|
LIMIT 30";
|
|
|
|
$q = $this->db_onedev->query($sql);
|
|
if (!$q) { $this->sys_error_db("get m_staff", $this->db_onedev); exit; }
|
|
|
|
$this->sys_ok(['records' => $q->result_array()]);
|
|
exit;
|
|
}
|
|
|
|
// Autocomplete jenis vaksin: filter by MOU order, param: orderid + search
|
|
function get_vaccines()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$orderid = intval($prm['orderid'] ?? 0);
|
|
$search = trim($prm['search'] ?? '');
|
|
|
|
if (!$orderid) { $this->sys_error("orderid required"); exit; }
|
|
|
|
// Ambil MOU dari order
|
|
$order_row = $this->db_oneklinik->query(
|
|
"SELECT orderM_MouID FROM one_klinik.`order` WHERE orderID = ? LIMIT 1",
|
|
[$orderid]
|
|
)->row_array();
|
|
|
|
if (!$order_row || !$order_row['orderM_MouID']) {
|
|
$this->sys_ok(['records' => []]);
|
|
exit;
|
|
}
|
|
|
|
$mou_id = intval($order_row['orderM_MouID']);
|
|
$search_esc = $this->db_onedev->escape_str($search);
|
|
|
|
$sql = "SELECT
|
|
spm.Ss_PriceMouID as ss_price_mou_id,
|
|
spm.Ss_PriceMouM_MouID as mouid,
|
|
0 as xid,
|
|
spm.Nat_TestID as nat_testid,
|
|
spm.nat_test,
|
|
spm.is_packet,
|
|
spm.packet_id,
|
|
spm.px_type as type,
|
|
spm.T_TestID as pxid,
|
|
t.T_TestCode as pxcode,
|
|
t.T_TestSasCode as pxsascode,
|
|
t.T_TestName as test_name,
|
|
CONCAT(t.T_TestSasCode,' ',t.T_TestName) as pxname,
|
|
t.T_TestIsResult as isresult,
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount')) as bruto,
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) as discountpersen,
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp')) as discountrp,
|
|
if(JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) <> 0,
|
|
(((JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) / 100)
|
|
* JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount')))
|
|
+ JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp'))),
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp'))
|
|
) as discount,
|
|
( JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount'))
|
|
- ((JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) / 100)
|
|
* JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount')))
|
|
- JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp'))
|
|
) as total,
|
|
spm.child_test
|
|
FROM one_lab.ss_price_mou spm
|
|
JOIN one_lab.t_test t ON spm.T_TestID = t.T_TestID AND t.T_TestIsActive = 'Y'
|
|
WHERE spm.Ss_PriceMouM_MouID = {$mou_id}
|
|
AND spm.is_packet = 'N'
|
|
AND spm.px_type = 'PX'
|
|
AND CONCAT(t.T_TestSasCode,' ',t.T_TestName) LIKE CONCAT('%', '{$search_esc}', '%')
|
|
ORDER BY t.T_TestName
|
|
LIMIT 50";
|
|
|
|
$q = $this->db_onedev->query($sql);
|
|
if (!$q) { $this->sys_error_db("get jenis vaksin", $this->db_onedev); exit; }
|
|
|
|
$records = array_map(function($row) {
|
|
$row['nat_test'] = json_decode($row['nat_test'] ?? '[]', true) ?: [];
|
|
$row['child_test'] = json_decode($row['child_test'] ?? '[]', true) ?: [];
|
|
return $row;
|
|
}, $q->result_array());
|
|
|
|
$this->sys_ok(['records' => $records]);
|
|
exit;
|
|
}
|
|
|
|
// List vaksin yang sudah tersimpan untuk satu order
|
|
function list_order_vaccines()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$orderid = intval($prm['orderid'] ?? 0);
|
|
if (!$orderid) { $this->sys_error("orderid required"); exit; }
|
|
|
|
$sql = "SELECT
|
|
ov.*,
|
|
t.T_TestName as jenis_vaksin_name,
|
|
t.T_TestSasCode as jenis_vaksin_code,
|
|
ins.M_InjectionSiteName as injection_site_name,
|
|
rv.M_RouteVaccineName as route_name,
|
|
s.M_StaffName as petugas_name
|
|
FROM one_klinik.order_vaccine ov
|
|
LEFT JOIN one_lab.t_test t ON ov.orderVaccineT_TestID = t.T_TestID
|
|
LEFT JOIN one_klinik.m_injection_site ins
|
|
ON ov.orderVaccineInjectionSiteCode = ins.M_InjectionSiteCode
|
|
LEFT JOIN one_klinik.m_route_vaccine rv
|
|
ON ov.orderVaccineRouteCode = rv.M_RouteVaccineCode
|
|
LEFT JOIN one_lab.m_staff s ON ov.orderVaccinePetugasM_StaffID = s.M_StaffID
|
|
WHERE ov.orderVaccineOrderID = ?
|
|
AND ov.orderVaccineIsActive = 'Y'
|
|
ORDER BY ov.orderVaccineCreated ASC";
|
|
|
|
$q = $this->db_oneklinik->query($sql, [$orderid]);
|
|
if (!$q) { $this->sys_error_db("list order_vaccine", $this->db_oneklinik); exit; }
|
|
|
|
$this->sys_ok(['records' => $q->result_array()]);
|
|
exit;
|
|
}
|
|
|
|
function save_vaccine()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
$orderid = intval($prm['orderid'] ?? 0);
|
|
$vaccine_id = intval($prm['vaccine_id'] ?? 0); // orderVaccineID; 0 = insert baru
|
|
$t_test_id = intval($prm['t_test_id'] ?? 0);
|
|
|
|
if (!$orderid || !$t_test_id) {
|
|
$this->sys_error("orderid dan t_test_id wajib diisi");
|
|
exit;
|
|
}
|
|
|
|
$batch = trim($prm['batch_number'] ?? '');
|
|
$expired = trim($prm['expired_date'] ?? '');
|
|
$dosis = max(1, intval($prm['dosis'] ?? 1));
|
|
$site_code = trim($prm['injection_site_code'] ?? '');
|
|
$route_code = trim($prm['route_code'] ?? '');
|
|
$petugas_id = isset($prm['petugas_id']) && $prm['petugas_id'] ? intval($prm['petugas_id']) : null;
|
|
$given_at = trim($prm['given_at'] ?? '');
|
|
$next_date = trim($prm['next_date'] ?? '');
|
|
$catatan = trim($prm['catatan'] ?? '');
|
|
$kipi = trim($prm['kipi'] ?? '');
|
|
$observasi15 = ($prm['observasi_15'] ?? false) ? 'Y' : 'N';
|
|
$reaksi_alergi = ($prm['reaksi_alergi'] ?? false) ? 'Y' : 'N';
|
|
$ss_price_mou_id = isset($prm['ss_price_mou_id']) && $prm['ss_price_mou_id'] ? intval($prm['ss_price_mou_id']) : null;
|
|
$bruto = floatval($prm['bruto'] ?? 0);
|
|
$disc_persen = floatval($prm['discountpersen'] ?? 0);
|
|
$disc_rp = floatval($prm['discountrp'] ?? 0);
|
|
$total = floatval($prm['total'] ?? 0);
|
|
|
|
$given_at_sql = ($given_at && strtotime($given_at)) ? date('Y-m-d H:i:s', strtotime($given_at)) : date('Y-m-d H:i:s');
|
|
$expired_val = ($expired && strtotime($expired)) ? date('Y-m-d', strtotime($expired)) : null;
|
|
$next_date_val = ($next_date && strtotime($next_date)) ? date('Y-m-d', strtotime($next_date)) : null;
|
|
|
|
if ($vaccine_id > 0) {
|
|
$ok = $this->db_oneklinik->query(
|
|
"UPDATE one_klinik.order_vaccine SET
|
|
orderVaccineT_TestID = ?,
|
|
orderVaccineSsPriceMouID = ?,
|
|
orderVaccineBruto = ?,
|
|
orderVaccineDiscPersen = ?,
|
|
orderVaccineDiscRp = ?,
|
|
orderVaccineTotal = ?,
|
|
orderVaccineBatchNumber = ?,
|
|
orderVaccineExpiredDate = ?,
|
|
orderVaccineDosis = ?,
|
|
orderVaccineInjectionSiteCode = ?,
|
|
orderVaccineRouteCode = ?,
|
|
orderVaccinePetugasM_StaffID = ?,
|
|
orderVaccineGivenAt = ?,
|
|
orderVaccineNextDate = ?,
|
|
orderVaccineCatatan = ?,
|
|
orderVaccineKipi = ?,
|
|
orderVaccineObservasi15 = ?,
|
|
orderVaccineReaksiAlergi = ?,
|
|
orderVaccineUserID = ?
|
|
WHERE orderVaccineID = ? AND orderVaccineOrderID = ?",
|
|
[
|
|
$t_test_id, $ss_price_mou_id, $bruto, $disc_persen, $disc_rp, $total,
|
|
$batch ?: null, $expired_val, $dosis,
|
|
$site_code ?: null, $route_code ?: null, $petugas_id,
|
|
$given_at_sql, $next_date_val, $catatan ?: null,
|
|
$kipi ?: null, $observasi15, $reaksi_alergi,
|
|
$userID, $vaccine_id, $orderid
|
|
]
|
|
);
|
|
} else {
|
|
$ok = $this->db_oneklinik->query(
|
|
"INSERT INTO one_klinik.order_vaccine
|
|
(orderVaccineOrderID, orderVaccineT_TestID,
|
|
orderVaccineSsPriceMouID, orderVaccineBruto, orderVaccineDiscPersen,
|
|
orderVaccineDiscRp, orderVaccineTotal,
|
|
orderVaccineBatchNumber, orderVaccineExpiredDate, orderVaccineDosis,
|
|
orderVaccineInjectionSiteCode, orderVaccineRouteCode,
|
|
orderVaccinePetugasM_StaffID, orderVaccineGivenAt,
|
|
orderVaccineNextDate, orderVaccineCatatan,
|
|
orderVaccineKipi, orderVaccineObservasi15, orderVaccineReaksiAlergi,
|
|
orderVaccineUserID)
|
|
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
[
|
|
$orderid, $t_test_id,
|
|
$ss_price_mou_id, $bruto, $disc_persen, $disc_rp, $total,
|
|
$batch ?: null, $expired_val, $dosis,
|
|
$site_code ?: null, $route_code ?: null, $petugas_id,
|
|
$given_at_sql, $next_date_val, $catatan ?: null,
|
|
$kipi ?: null, $observasi15, $reaksi_alergi, $userID
|
|
]
|
|
);
|
|
$vaccine_id = $this->db_oneklinik->insert_id();
|
|
}
|
|
|
|
if (!$ok) { $this->sys_error_db("save order_vaccine", $this->db_oneklinik); exit; }
|
|
|
|
$this->sys_ok(['orderVaccineID' => $vaccine_id]);
|
|
exit;
|
|
}
|
|
|
|
function delete_vaccine()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$vaccine_id = intval($prm['orderVaccineID'] ?? 0);
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
if (!$vaccine_id) { $this->sys_error("orderVaccineID required"); exit; }
|
|
|
|
$ok = $this->db_oneklinik->query(
|
|
"UPDATE one_klinik.order_vaccine SET orderVaccineIsActive = 'N', orderVaccineUserID = ?
|
|
WHERE orderVaccineID = ?",
|
|
[$userID, $vaccine_id]
|
|
);
|
|
if (!$ok) { $this->sys_error_db("delete order_vaccine", $this->db_oneklinik); exit; }
|
|
|
|
$this->sys_ok(['msg' => 'deleted']);
|
|
exit;
|
|
}
|
|
|
|
// ── TINDAKAN MEDIS ────────────────────────────────────────────────────────
|
|
|
|
// Autocomplete jenis tindakan dari ss_price_mou berdasarkan MOU order
|
|
function get_tindakan()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$orderid = intval($prm['orderid'] ?? 0);
|
|
$search = trim($prm['search'] ?? '');
|
|
|
|
if (!$orderid) { $this->sys_error("orderid required"); exit; }
|
|
|
|
$order_row = $this->db_oneklinik->query(
|
|
"SELECT orderM_MouID FROM one_klinik.`order` WHERE orderID = ? LIMIT 1",
|
|
[$orderid]
|
|
)->row_array();
|
|
|
|
if (!$order_row || !$order_row['orderM_MouID']) {
|
|
$this->sys_ok(['records' => []]);
|
|
exit;
|
|
}
|
|
|
|
$mou_id = intval($order_row['orderM_MouID']);
|
|
$search_esc = $this->db_onedev->escape_str($search);
|
|
|
|
$sql = "SELECT
|
|
spm.Ss_PriceMouID as ss_price_mou_id,
|
|
spm.Ss_PriceMouM_MouID as mouid,
|
|
0 as xid,
|
|
spm.Nat_TestID as nat_testid,
|
|
spm.nat_test,
|
|
spm.is_packet,
|
|
spm.packet_id,
|
|
spm.px_type as type,
|
|
spm.T_TestID as pxid,
|
|
t.T_TestCode as pxcode,
|
|
t.T_TestSasCode as pxsascode,
|
|
t.T_TestName as test_name,
|
|
CONCAT(t.T_TestSasCode,' ',t.T_TestName) as pxname,
|
|
t.T_TestIsResult as isresult,
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount')) as bruto,
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) as discountpersen,
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp')) as discountrp,
|
|
if(JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) <> 0,
|
|
(((JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) / 100)
|
|
* JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount')))
|
|
+ JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp'))),
|
|
JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp'))
|
|
) as discount,
|
|
( JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount'))
|
|
- ((JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDisc')) / 100)
|
|
* JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceAmount')))
|
|
- JSON_UNQUOTE(JSON_EXTRACT(one_json_sum(spm.Ss_PriceMouID),'$.T_PriceDiscRp'))
|
|
) as total,
|
|
spm.child_test
|
|
FROM one_lab.ss_price_mou spm
|
|
JOIN one_lab.t_test t ON spm.T_TestID = t.T_TestID AND t.T_TestIsActive = 'Y'
|
|
WHERE spm.Ss_PriceMouM_MouID = {$mou_id}
|
|
AND spm.is_packet = 'N'
|
|
AND spm.px_type = 'PX'
|
|
AND CONCAT(t.T_TestSasCode,' ',t.T_TestName) LIKE CONCAT('%', '{$search_esc}', '%')
|
|
ORDER BY t.T_TestName
|
|
LIMIT 50";
|
|
|
|
$q = $this->db_onedev->query($sql);
|
|
if (!$q) { $this->sys_error_db("get jenis tindakan", $this->db_onedev); exit; }
|
|
|
|
$records = array_map(function($row) {
|
|
$row['nat_test'] = json_decode($row['nat_test'] ?? '[]', true) ?: [];
|
|
$row['child_test'] = json_decode($row['child_test'] ?? '[]', true) ?: [];
|
|
return $row;
|
|
}, $q->result_array());
|
|
|
|
$this->sys_ok(['records' => $records]);
|
|
exit;
|
|
}
|
|
|
|
// List tindakan yang sudah tersimpan untuk satu order
|
|
function list_order_tindakan()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$orderid = intval($prm['orderid'] ?? 0);
|
|
if (!$orderid) { $this->sys_error("orderid required"); exit; }
|
|
|
|
$sql = "SELECT
|
|
ot.*,
|
|
t.T_TestName as jenis_tindakan_name,
|
|
t.T_TestSasCode as jenis_tindakan_code,
|
|
d.M_DoctorName as dokter_name
|
|
FROM one_klinik.order_tindakan ot
|
|
LEFT JOIN one_lab.t_test t ON ot.orderTindakanT_TestID = t.T_TestID
|
|
LEFT JOIN one_lab.m_doctor d ON ot.orderTindakanM_DoctorID = d.M_DoctorID
|
|
WHERE ot.orderTindakanOrderID = ?
|
|
AND ot.orderTindakanIsActive = 'Y'
|
|
ORDER BY ot.orderTindakanCreated ASC";
|
|
|
|
$q = $this->db_oneklinik->query($sql, [$orderid]);
|
|
if (!$q) { $this->sys_error_db("list order_tindakan", $this->db_oneklinik); exit; }
|
|
|
|
$this->sys_ok(['records' => $q->result_array()]);
|
|
exit;
|
|
}
|
|
|
|
function save_tindakan()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
$orderid = intval($prm['orderid'] ?? 0);
|
|
$tindakan_id = intval($prm['tindakan_id'] ?? 0); // orderTindakanID; 0 = insert baru
|
|
$t_test_id = intval($prm['t_test_id'] ?? 0);
|
|
|
|
if (!$orderid || !$t_test_id) {
|
|
$this->sys_error("orderid dan t_test_id wajib diisi");
|
|
exit;
|
|
}
|
|
|
|
$doctor_id = isset($prm['doctor_id']) && $prm['doctor_id'] ? intval($prm['doctor_id']) : null;
|
|
$performed_at = trim($prm['performed_at'] ?? '');
|
|
$catatan = trim($prm['catatan'] ?? '');
|
|
$ss_price_mou_id = isset($prm['ss_price_mou_id']) && $prm['ss_price_mou_id'] ? intval($prm['ss_price_mou_id']) : null;
|
|
$bruto = floatval($prm['bruto'] ?? 0);
|
|
$disc_persen = floatval($prm['discountpersen'] ?? 0);
|
|
$disc_rp = floatval($prm['discountrp'] ?? 0);
|
|
$total = floatval($prm['total'] ?? 0);
|
|
|
|
$performed_at_sql = ($performed_at && strtotime($performed_at))
|
|
? date('Y-m-d H:i:s', strtotime($performed_at))
|
|
: date('Y-m-d H:i:s');
|
|
|
|
if ($tindakan_id > 0) {
|
|
$ok = $this->db_oneklinik->query(
|
|
"UPDATE one_klinik.order_tindakan SET
|
|
orderTindakanT_TestID = ?,
|
|
orderTindakanSsPriceMouID = ?,
|
|
orderTindakanBruto = ?,
|
|
orderTindakanDiscPersen = ?,
|
|
orderTindakanDiscRp = ?,
|
|
orderTindakanTotal = ?,
|
|
orderTindakanM_DoctorID = ?,
|
|
orderTindakanPerformedAt = ?,
|
|
orderTindakanCatatan = ?,
|
|
orderTindakanUserID = ?
|
|
WHERE orderTindakanID = ? AND orderTindakanOrderID = ?",
|
|
[
|
|
$t_test_id, $ss_price_mou_id, $bruto, $disc_persen, $disc_rp, $total,
|
|
$doctor_id, $performed_at_sql, $catatan ?: null,
|
|
$userID, $tindakan_id, $orderid
|
|
]
|
|
);
|
|
} else {
|
|
$ok = $this->db_oneklinik->query(
|
|
"INSERT INTO one_klinik.order_tindakan
|
|
(orderTindakanOrderID, orderTindakanT_TestID,
|
|
orderTindakanSsPriceMouID, orderTindakanBruto, orderTindakanDiscPersen,
|
|
orderTindakanDiscRp, orderTindakanTotal,
|
|
orderTindakanM_DoctorID, orderTindakanPerformedAt,
|
|
orderTindakanCatatan, orderTindakanUserID)
|
|
VALUES (?,?,?,?,?,?,?,?,?,?,?)",
|
|
[
|
|
$orderid, $t_test_id,
|
|
$ss_price_mou_id, $bruto, $disc_persen, $disc_rp, $total,
|
|
$doctor_id, $performed_at_sql, $catatan ?: null, $userID
|
|
]
|
|
);
|
|
$tindakan_id = $this->db_oneklinik->insert_id();
|
|
}
|
|
|
|
if (!$ok) { $this->sys_error_db("save order_tindakan", $this->db_oneklinik); exit; }
|
|
|
|
$this->sys_ok(['orderTindakanID' => $tindakan_id]);
|
|
exit;
|
|
}
|
|
|
|
function delete_tindakan()
|
|
{
|
|
if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; }
|
|
|
|
$prm = $this->sys_input;
|
|
$tindakan_id = intval($prm['orderTindakanID'] ?? 0);
|
|
$userID = $this->sys_user['M_UserID'];
|
|
|
|
if (!$tindakan_id) { $this->sys_error("orderTindakanID required"); exit; }
|
|
|
|
$ok = $this->db_oneklinik->query(
|
|
"UPDATE one_klinik.order_tindakan SET orderTindakanIsActive = 'N', orderTindakanUserID = ?
|
|
WHERE orderTindakanID = ?",
|
|
[$userID, $tindakan_id]
|
|
);
|
|
if (!$ok) { $this->sys_error_db("delete order_tindakan", $this->db_oneklinik); exit; }
|
|
|
|
$this->sys_ok(['msg' => 'deleted']);
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|