998 lines
30 KiB
PHP
998 lines
30 KiB
PHP
<?php
|
|
class Normalvaluev3 extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Normal Value API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$code = $prm["code"];
|
|
$nama = $prm["nama"];
|
|
|
|
// echo $norm;
|
|
|
|
$sql_where = "WHERE Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'";
|
|
$sql_param = array();
|
|
if ($code != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " Nat_TestCode like ? ";
|
|
$sql_param[] = "%$code%";
|
|
}
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " Nat_TestName like ? ";
|
|
$sql_param[] = "%$nama%";
|
|
}
|
|
|
|
//if ($sql_where != "") $sql_where .= " and ";
|
|
|
|
// Order masih dalam status registrasi
|
|
//$sql_where .= " M_PatientIsActive = 'Y' ";
|
|
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM nat_test
|
|
$sql_where
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
|
|
$tot_count = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
} else {
|
|
$this->sys_error_db("nat_test count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT *
|
|
FROM nat_test
|
|
$sql_where
|
|
ORDER BY Nat_TestCode ASC
|
|
limit 0,$tot_count";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
function searchmethode(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM nat_methode
|
|
WHERE
|
|
Nat_MethodeName like ?
|
|
AND Nat_MethodeIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_methode count",$this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM nat_methode
|
|
WHERE
|
|
Nat_MethodeName like ?
|
|
AND Nat_MethodeIsActive = 'Y'
|
|
ORDER BY Nat_MethodeName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_methode rows",$this->db);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcompany(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_company
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND Nat_TestIsActive = 'Y' AND Nat_TestIsLabFrom = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_company
|
|
WHERE
|
|
Nat_TestName like ?
|
|
AND Nat_TestIsActive = 'Y' AND Nat_TestIsLabFrom = 'Y'
|
|
ORDER BY Nat_TestName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function getmou(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_mou
|
|
WHERE
|
|
M_MouIsActive = 'Y' AND M_MouNat_TestID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getsexreg(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM nat_sex
|
|
WHERE
|
|
Nat_SexIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM nat_normalvaluetype
|
|
WHERE
|
|
Nat_NormalValueTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM nat_flag
|
|
WHERE
|
|
Nat_FlagIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
|
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
|
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
|
";
|
|
//echo $query;
|
|
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="
|
|
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
|
UNION
|
|
SELECT Nat_SexID, Nat_SexName
|
|
FROM nat_sex
|
|
WHERE
|
|
Nat_SexIsActive = 'Y'
|
|
|
|
";
|
|
//echo $query;
|
|
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="
|
|
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
|
UNION
|
|
SELECT Nat_FlagID, Nat_FlagName
|
|
FROM nat_flag
|
|
WHERE
|
|
Nat_FlagIsActive = 'Y'";
|
|
//echo $query;
|
|
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
|
$query ="UPDATE m_patient SET
|
|
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
|
M_PatientName = '{$prm['M_PatientName']}',
|
|
M_PatientDOB = '{$pdob}',
|
|
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
|
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
|
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
|
M_PatientHP = '{$prm['M_PatientHP']}',
|
|
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
|
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
|
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
|
M_PatientNote = '{$prm['M_PatientNote']}'
|
|
WHERE
|
|
M_PatientID = '{$prm['M_PatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function newreceivereference(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="INSERT INTO nat_test (
|
|
Nat_TestNat_TestID,
|
|
Nat_TestM_MouID,
|
|
Nat_TestDate,
|
|
Nat_TestNote,
|
|
Nat_TestUserID,
|
|
Nat_TestCreated
|
|
)
|
|
VALUES(
|
|
'{$prm['companyid']}',
|
|
'{$prm['mouid']}',
|
|
'{$pdate}',
|
|
'{$prm['note']}',
|
|
'{$userid}',
|
|
NOW()
|
|
)
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
|
G_ReceiveReferenceHeaderStatusLogDate,
|
|
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
|
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
|
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
|
G_ReceiveReferenceHeaderStatusLogUserID,
|
|
G_ReceiveReferenceHeaderStatusLogCreated,
|
|
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$last_id}',
|
|
'1',
|
|
'{$userid}',
|
|
'{$userid}',
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
//echo $querylog;
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function sendorder(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$query ="UPDATE nat_test SET
|
|
Nat_TestIsSent = 'Y',
|
|
Nat_TestSentDate = now(),
|
|
Nat_TestUserID = '{$userid}'
|
|
WHERE
|
|
Nat_TestID = '{$prm['Nat_TestID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
|
G_ReceiveReferenceHeaderStatusLogDate,
|
|
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
|
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
|
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
|
G_ReceiveReferenceHeaderStatusLogUserID,
|
|
G_ReceiveReferenceHeaderStatusLogCreated,
|
|
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$prm['Nat_TestID']}',
|
|
'2',
|
|
'{$userid}',
|
|
'{$userid}',
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
//echo $querylog;
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getnilainormal(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$methodename = $prm['methodename'];
|
|
$sexid = $prm['sexid'];
|
|
$flagid = $prm['flagid'];
|
|
$filter = '';
|
|
if(isset($sexid)){
|
|
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
|
}
|
|
if(isset($flagid)){
|
|
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
|
}
|
|
$query =" SELECT nat_normalvalue.*,
|
|
Nat_TestName,
|
|
Nat_SexID,
|
|
Nat_SexName,
|
|
Nat_MethodeID,
|
|
Nat_MethodeName,
|
|
Nat_NormalValueTypeID,
|
|
Nat_NormalValueTypeName,
|
|
Nat_FlagID,
|
|
Nat_FlagName,
|
|
CASE
|
|
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' - ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
|
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'N' THEN CONCAT(Nat_NormalValueMinAge,' > ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
|
WHEN Nat_NormalValueMinAgeInclusive = 'N' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' < ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
|
ELSE '-'
|
|
END as Nat_NormalValueAge,
|
|
CASE
|
|
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' - ',Nat_NormalValueMaxValue)
|
|
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'N' THEN CONCAT(Nat_NormalValueMinValue,' > ',Nat_NormalValueMaxValue)
|
|
WHEN Nat_NormalValueMinValueInclusive = 'N' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' < ',Nat_NormalValueMaxValue)
|
|
ELSE '-'
|
|
END as Nat_NormalValueValue,
|
|
CASE
|
|
WHEN Nat_NormalValueAgeUnit = 'HARI' THEN '1'
|
|
WHEN Nat_NormalValueAgeUnit = 'BULAN' THEN '2'
|
|
WHEN Nat_NormalValueAgeUnit = 'TAHUN' THEN '3'
|
|
ELSE '4'
|
|
END as ageunit,
|
|
IF(Nat_NormalValueIsAbnormal = 'N',Nat_NormalValueID,Nat_NormalValueParentID) as parentid,
|
|
DATE_FORMAT(Nat_NormalValueValidDate,'%d-%m-%Y') as Nat_NormalValueValidDatex,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
'N' as show_detail
|
|
|
|
FROM nat_normalvalue
|
|
LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID
|
|
JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID
|
|
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y'
|
|
JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID
|
|
LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID
|
|
WHERE
|
|
Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueNat_TestID = {$prm['id']} AND
|
|
Nat_MethodeName like '%{$methodename}%'
|
|
$filter
|
|
GROUP BY Nat_NormalValueID
|
|
ORDER BY Nat_NormalValueNat_SexID ASC, ageunit ASC, Nat_NormalValueMinAge ASC, Nat_NormalValueMaxAge ASC, parentid ASC
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
if($rows){
|
|
|
|
foreach($rows as $k => $v){
|
|
//$rows[$k]['tesx'] = json_decode($x->n);
|
|
$rows[$k]['tests'] = $this->add_test($v['Nat_NormalValueID']);
|
|
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
|
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
|
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function add_test($orderid){
|
|
$query ="SELECT IFNULL(Nat_NormalValueLangID,0) as id,
|
|
IFNULL(Nat_NormalValueLangNat_NormalValueID,$orderid) as Nat_NormalValueLangNat_NormalValueID,
|
|
Nat_LangName,
|
|
IFNULL(Nat_NormalValueLangNote, '') as Nat_NormalValueLangNote,
|
|
IFNULL(Nat_NormalValueLangNoteSI, '') as Nat_NormalValueLangNoteSI,
|
|
IFNULL(Nat_NormalValueLangDescription, '') as Nat_NormalValueLangDescription,
|
|
IFNULL(Nat_NormalValueLangDescriptionSI, '') as Nat_NormalValueLangDescriptionSI,
|
|
IFNULL(Nat_NormalValueLangNat_LangID, Nat_LangID) as Nat_NormalValueLangNat_LangID,
|
|
'xxx' as action,
|
|
'Y' as show_detail,
|
|
Nat_LangID as idx,
|
|
Nat_LangID
|
|
from nat_lang
|
|
left join nat_normalvaluelang ON Nat_LangID = Nat_NormalValueLangNat_LangID AND Nat_NormalValueLangNat_NormalValueID = {$orderid}
|
|
left join nat_normalvalue ON Nat_NormalValueLangNat_NormalValueID = Nat_NormalValueID
|
|
where
|
|
Nat_LangIsActive = 'Y'";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if(!$rows)
|
|
$rows = array();
|
|
return $rows;
|
|
}
|
|
|
|
function savenewnilainormal(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="INSERT INTO nat_normalvalue (
|
|
Nat_NormalValueNat_TestID,
|
|
Nat_NormalValueNat_MethodeID,
|
|
Nat_NormalValueNat_NormalValueTypeID,
|
|
Nat_NormalValueNat_FlagID,
|
|
Nat_NormalValueValidDate,
|
|
Nat_NormalValueMinAge,
|
|
Nat_NormalValueMaxAge,
|
|
Nat_NormalValueMinAgeInclusive,
|
|
Nat_NormalValueMaxAgeInclusive,
|
|
Nat_NormalValueAgeUnit,
|
|
Nat_NormalValueNat_SexID,
|
|
Nat_NormalValueNote,
|
|
Nat_NormalValueMinValue,
|
|
Nat_NormalValueMaxValue,
|
|
Nat_NormalValueMinValueInclusive,
|
|
Nat_NormalValueMaxValueInclusive,
|
|
Nat_NormalValueDescription,
|
|
Nat_NormalValueIsAbnormal,
|
|
Nat_NormalValueUserID,
|
|
Nat_NormalValueLastUpdated
|
|
|
|
)
|
|
VALUES(
|
|
'{$prm['Nat_NormalValueNat_TestID']}',
|
|
'{$prm['Nat_NormalValueNat_MethodeID']}',
|
|
'{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
|
'{$prm['Nat_NormalValueNat_FlagID']}',
|
|
'{$prm['Nat_NormalValueValidDate']}',
|
|
'{$prm['Nat_NormalValueMinAge']}',
|
|
'{$prm['Nat_NormalValueMaxAge']}',
|
|
'{$prm['Nat_NormalValueMinAgeInclusive']}',
|
|
'{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
|
'{$prm['Nat_NormalValueAgeUnit']}',
|
|
'{$prm['Nat_NormalValueNat_SexID']}',
|
|
'{$prm['Nat_NormalValueNote']}',
|
|
'{$prm['Nat_NormalValueMinValue']}',
|
|
'{$prm['Nat_NormalValueMaxValue']}',
|
|
'{$prm['Nat_NormalValueMinValueInclusive']}',
|
|
'{$prm['Nat_NormalValueMaxValueInclusive']}',
|
|
'{$prm['Nat_NormalValueDescription']}',
|
|
'{$prm['Nat_NormalValueIsAbnormal']}',
|
|
'{$userid}',
|
|
NOW()
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$ordernormalvalue_id = $this->db_onedev->insert_id();
|
|
$sql_param = $ordernormalvalue_id;
|
|
$sql = "select * from nat_normalvalue
|
|
where Nat_NormalValueID= ?";
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
|
exit;
|
|
}
|
|
/*$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
|
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
|
$data = json_encode($rows);
|
|
$userID = $this->sys_user["M_UserID"];
|
|
$sql_param = array("NormalValue.Add", $data , $userID);
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
if (! $query) {
|
|
$this->sys_error_db( $this->db_onedev->last_query());
|
|
exit;
|
|
}*/
|
|
$querylang ="INSERT INTO nat_normalvaluelang (
|
|
Nat_NormalValueLangNat_NormalValueID,
|
|
Nat_NormalValueLangNat_LangID,
|
|
Nat_NormalValueLangNote,
|
|
Nat_NormalValueLangDescription,
|
|
Nat_NormalValueLangUserID,
|
|
Nat_NormalValueLangCreated,
|
|
Nat_NormalValueLangLastUpdated
|
|
|
|
)
|
|
VALUES(
|
|
'{$ordernormalvalue_id}',
|
|
'1',
|
|
'{$prm['Nat_NormalValueNote']}',
|
|
'{$prm['Nat_NormalValueDescription']}',
|
|
'{$userid}',
|
|
NOW(),
|
|
now()
|
|
)
|
|
";
|
|
$rows = $this->db_onedev->query($querylang);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function saveeditnilainormal(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$order_id = $prm['Nat_NormalValueID'];
|
|
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['Nat_NormalValueNat_NormalValueTypeID'] == '4'){
|
|
$prm['Nat_NormalValueMinAge'] = 0;
|
|
$prm['Nat_NormalValueMaxAge'] = 0;
|
|
$prm['Nat_NormalValueMinAgeInclusive'] = 'N';
|
|
$prm['Nat_NormalValueMaxAgeInclusive'] = 'N';
|
|
$prm['Nat_NormalValueAgeUnit'] = '';
|
|
$prm['Nat_NormalValueNat_SexID'] = 0;
|
|
|
|
}
|
|
if($prm['Nat_NormalValueNat_NormalValueTypeID'] == '2'){
|
|
$prm['Nat_NormalValueNat_SexID'] = 0;
|
|
|
|
}
|
|
if($prm['Nat_NormalValueNat_NormalValueTypeID'] == '3'){
|
|
$prm['Nat_NormalValueMinAge'] = 0;
|
|
$prm['Nat_NormalValueMaxAge'] = 0;
|
|
$prm['Nat_NormalValueMinAgeInclusive'] = 'N';
|
|
$prm['Nat_NormalValueMaxAgeInclusive'] = 'N';
|
|
$prm['Nat_NormalValueAgeUnit'] = '';
|
|
}
|
|
|
|
$query ="UPDATE nat_normalvalue SET
|
|
Nat_NormalValueNat_TestID = '{$prm['Nat_NormalValueNat_TestID']}',
|
|
Nat_NormalValueNat_MethodeID = '{$prm['Nat_NormalValueNat_MethodeID']}',
|
|
Nat_NormalValueNat_NormalValueTypeID = '{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
|
Nat_NormalValueNat_FlagID = '{$prm['Nat_NormalValueNat_FlagID']}',
|
|
Nat_NormalValueValidDate = '{$prm['Nat_NormalValueValidDate']}',
|
|
Nat_NormalValueMinAge = '{$prm['Nat_NormalValueMinAge']}',
|
|
Nat_NormalValueMaxAge = '{$prm['Nat_NormalValueMaxAge']}',
|
|
Nat_NormalValueMinAgeInclusive = '{$prm['Nat_NormalValueMinAgeInclusive']}',
|
|
Nat_NormalValueMaxAgeInclusive = '{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
|
Nat_NormalValueAgeUnit = '{$prm['Nat_NormalValueAgeUnit']}',
|
|
Nat_NormalValueNat_SexID = '{$prm['Nat_NormalValueNat_SexID']}',
|
|
Nat_NormalValueNote = '{$prm['Nat_NormalValueNote']}',
|
|
Nat_NormalValueMinValue = '{$prm['Nat_NormalValueMinValue']}',
|
|
Nat_NormalValueMaxValue = '{$prm['Nat_NormalValueMaxValue']}',
|
|
Nat_NormalValueMinValueInclusive = '{$prm['Nat_NormalValueMinValueInclusive']}',
|
|
Nat_NormalValueMaxValueInclusive = '{$prm['Nat_NormalValueMaxValueInclusive']}',
|
|
Nat_NormalValueDescription = '{$prm['Nat_NormalValueDescription']}',
|
|
Nat_NormalValueIsAbnormal = '{$prm['Nat_NormalValueIsAbnormal']}',
|
|
Nat_NormalValueUserID = '{$userid}',
|
|
Nat_NormalValueLastUpdated = now()
|
|
WHERE
|
|
Nat_NormalValueID = '{$prm['Nat_NormalValueID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$sql_param = $order_id;
|
|
$sql = "select * from nat_normalvalue
|
|
where Nat_NormalValueID= ?";
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
|
exit;
|
|
}
|
|
/* $sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
|
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
|
$data = json_encode($rows);
|
|
$userID = $this->sys_user["M_UserID"];
|
|
$sql_param = array("NormalValue.Update", $data , $userID);
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
if (! $query) {
|
|
$this->sys_error_db( $this->db_onedev->last_query());
|
|
exit;
|
|
}*/
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function savenewnilaiabnormal(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="INSERT INTO nat_normalvalue (
|
|
Nat_NormalValueNat_TestID,
|
|
Nat_NormalValueNat_MethodeID,
|
|
Nat_NormalValueNat_NormalValueTypeID,
|
|
Nat_NormalValueNat_FlagID,
|
|
Nat_NormalValueValidDate,
|
|
Nat_NormalValueMinAge,
|
|
Nat_NormalValueMaxAge,
|
|
Nat_NormalValueMinAgeInclusive,
|
|
Nat_NormalValueMaxAgeInclusive,
|
|
Nat_NormalValueAgeUnit,
|
|
Nat_NormalValueNat_SexID,
|
|
Nat_NormalValueNote,
|
|
Nat_NormalValueMinValue,
|
|
Nat_NormalValueMaxValue,
|
|
Nat_NormalValueMinValueInclusive,
|
|
Nat_NormalValueMaxValueInclusive,
|
|
Nat_NormalValueDescription,
|
|
Nat_NormalValueParentID,
|
|
Nat_NormalValueIsAbnormal,
|
|
Nat_NormalValueUserID,
|
|
Nat_NormalValueLastUpdated
|
|
|
|
)
|
|
VALUES(
|
|
'{$prm['Nat_NormalValueNat_TestID']}',
|
|
'{$prm['Nat_NormalValueNat_MethodeID']}',
|
|
'{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
|
'{$prm['Nat_NormalValueNat_FlagID']}',
|
|
'{$prm['Nat_NormalValueValidDate']}',
|
|
'{$prm['Nat_NormalValueMinAge']}',
|
|
'{$prm['Nat_NormalValueMaxAge']}',
|
|
'{$prm['Nat_NormalValueMinAgeInclusive']}',
|
|
'{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
|
'{$prm['Nat_NormalValueAgeUnit']}',
|
|
'{$prm['Nat_NormalValueNat_SexID']}',
|
|
'{$prm['Nat_NormalValueNote']}',
|
|
'{$prm['Nat_NormalValueMinValue']}',
|
|
'{$prm['Nat_NormalValueMaxValue']}',
|
|
'{$prm['Nat_NormalValueMinValueInclusive']}',
|
|
'{$prm['Nat_NormalValueMaxValueInclusive']}',
|
|
'{$prm['Nat_NormalValueDescription']}',
|
|
'{$prm['Nat_NormalValueParentID']}',
|
|
'{$prm['Nat_NormalValueIsAbnormal']}',
|
|
'{$userid}',
|
|
NOW()
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$ordernormalvalue_id = $this->db_onedev->insert_id();
|
|
$sql_param = $ordernormalvalue_id;
|
|
$sql = "select * from nat_normalvalue
|
|
where Nat_NormalValueID= ?";
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
|
exit;
|
|
}
|
|
/*$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
|
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
|
$data = json_encode($rows);
|
|
$userID = $this->sys_user["M_UserID"];
|
|
$sql_param = array("NormalValue.Add", $data , $userID);
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
if (! $query) {
|
|
$this->sys_error_db( $this->db_onedev->last_query());
|
|
exit;
|
|
}*/
|
|
$querylang ="INSERT INTO nat_normalvaluelang (
|
|
Nat_NormalValueLangNat_NormalValueID,
|
|
Nat_NormalValueLangNat_LangID,
|
|
Nat_NormalValueLangNote,
|
|
Nat_NormalValueLangDescription,
|
|
Nat_NormalValueLangUserID,
|
|
Nat_NormalValueLangCreated,
|
|
Nat_NormalValueLangLastUpdated
|
|
|
|
)
|
|
VALUES(
|
|
'{$ordernormalvalue_id}',
|
|
'1',
|
|
'{$prm['Nat_NormalValueNote']}',
|
|
'{$prm['Nat_NormalValueDescription']}',
|
|
'{$userid}',
|
|
NOW(),
|
|
now()
|
|
)
|
|
";
|
|
$rows = $this->db_onedev->query($querylang);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function deletenilainormal(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE nat_normalvalue SET
|
|
Nat_NormalValueIsActive = 'N',
|
|
Nat_NormalValueUserID = '{$userid}'
|
|
WHERE
|
|
Nat_NormalValueID = '{$prm['Nat_NormalValueID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$sql_param = $prm['Nat_NormalValueID'];
|
|
$sql = "select * from nat_normalvalue
|
|
where Nat_NormalValueID= ?";
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
|
exit;
|
|
}
|
|
/* $sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
|
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
|
$data = json_encode($rows);
|
|
$userID = $this->sys_user["M_UserID"];
|
|
$sql_param = array("NormalValue.Delete", $data , $userID);
|
|
$query = $this->db_onedev->query($sql,$sql_param);
|
|
if (! $query) {
|
|
$this->sys_error_db( $this->db_onedev->last_query());
|
|
exit;
|
|
}*/
|
|
$query ="UPDATE nat_normalvaluelang SET
|
|
Nat_NormalValueLangIsActive = 'N',
|
|
Nat_NormalValueLangUserID = '{$userid}'
|
|
WHERE
|
|
Nat_NormalValueLangNat_NormalValueID = '{$prm['Nat_NormalValueID']}' AND Nat_NormalValueLangIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function savenormalvaluelang(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$normalvalue_id = $prm['normalvalueid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['ordertests'] as $k=>$v){
|
|
if($v['id'] == 0 || $v['id'] == '0'){
|
|
$query = "INSERT INTO nat_normalvaluelang (
|
|
Nat_NormalValueLangNat_NormalValueID,
|
|
Nat_NormalValueLangNat_LangID,
|
|
Nat_NormalValueLangNote,
|
|
Nat_NormalValueLangNoteSI,
|
|
Nat_NormalValueLangDescription,
|
|
Nat_NormalValueLangDescriptionSI,
|
|
Nat_NormalValueLangUserID,
|
|
Nat_NormalValueLangCreated,
|
|
Nat_NormalValueLangLastUpdated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_normalvaluelang = $this->db_onedev->query($query,array(
|
|
$normalvalue_id,
|
|
$v['Nat_LangID'],
|
|
$v['Nat_NormalValueLangNote'],
|
|
$v['Nat_NormalValueLangNoteSI'],
|
|
$v['Nat_NormalValueLangDescription'],
|
|
$v['Nat_NormalValueLangDescriptionSI'],
|
|
$userid
|
|
));
|
|
} else {
|
|
$query = "UPDATE nat_normalvaluelang SET
|
|
Nat_NormalValueLangNat_LangID = ?,
|
|
Nat_NormalValueLangNote = ?,
|
|
Nat_NormalValueLangNoteSI = ?,
|
|
Nat_NormalValueLangDescription = ?,
|
|
Nat_NormalValueLangDescriptionSI = ?,
|
|
Nat_NormalValueLangUserID = ?
|
|
WHERE
|
|
Nat_NormalValueLangID = ?";
|
|
$update_normalvaluelang = $this->db_onedev->query($query,array($v['Nat_LangID'],$v['Nat_NormalValueLangNote'],$v['Nat_NormalValueLangNoteSI'],$v['Nat_NormalValueLangDescription'],$v['Nat_NormalValueLangDescriptionSI'],$userid,$v['id']));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function searchtest(){
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count = 0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
$mou_id = $prm['mouid'];
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_test
|
|
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
|
WHERE
|
|
T_TestName like ? AND
|
|
T_TestIsActive = 'Y'
|
|
ORDER BY T_TestName ASC";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("test count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT 'Y' as editable, 0 as xid, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
|
Nat_TestID, Nat_TestIsBill, Nat_TestMinDP
|
|
FROM one.t_test
|
|
JOIN one.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
|
JOIN one.m_mou ON M_MouID = '{$mou_id}'
|
|
JOIN one.m_company ON M_MouNat_TestID = Nat_TestID
|
|
WHERE
|
|
T_TestName like ? AND
|
|
T_TestIsActive = 'Y'
|
|
ORDER BY T_TestName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("test rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
}
|