187 lines
5.6 KiB
PHP
187 lines
5.6 KiB
PHP
<?php
|
|
class Bloodentry extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Doctor API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
public function getdatabynumber()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$bagnumber = $prm["bagnumber"];
|
|
$sql = "SELECT
|
|
Td_OrderBagID,
|
|
Td_OrderID,
|
|
Td_OrderBagNumber,
|
|
Td_BloodTypeID,
|
|
Td_BloodTypeName,
|
|
Td_BloodRhesusID,
|
|
Td_BloodRhesusName,
|
|
Td_BloodCategoryID,
|
|
Td_BloodCategoryName,
|
|
Td_OrderAftapStartDate,
|
|
Td_OrderAftapStartTime,
|
|
Td_OrderAftapEndDate,
|
|
Td_OrderAftapEndTime,
|
|
Td_OrderReleaseExpired,
|
|
Td_OrderDonorType,
|
|
IF(Td_OrderDonorType = 'Suka Rela','N','Y') as donortype,
|
|
Td_OrderPatientID,
|
|
Td_OrderPatientNoRM,
|
|
Td_OrderPatientNoReg,
|
|
Td_OrderPatientName,
|
|
Td_OrderPatientRoom
|
|
|
|
FROM
|
|
one_bb.td_orderbag
|
|
JOIN one_bb.td_order ON Td_OrderID = Td_OrderBagTd_OrderID AND Td_OrderBagNumber = '{$bagnumber}'
|
|
JOIN one_bb.td_donor ON Td_DonorID = Td_OrderTd_DonorID
|
|
JOIN one_bb.td_bloodtype ON Td_BloodTypeID = Td_DonorTd_BloodTypeID
|
|
JOIN one_bb.td_bloodrhesus ON Td_BloodRhesusID = Td_DonorTd_BloodRhesusID
|
|
JOIN one_bb.td_orderrelease ON Td_OrderReleaseTd_OrderID = Td_OrderID AND Td_OrderReleaseTd_OrderBagID = Td_OrderBagID
|
|
JOIN one_bb.td_bloodcategory ON Td_BloodCategoryID = Td_OrderReleaseTd_BloodCategoryID
|
|
JOIN one_bb.td_orderaftap ON Td_OrderAftapTd_OrderID = Td_OrderID
|
|
LEFT JOIN one_bb.td_orderpatient ON Td_OrderPatientTd_OrderID = Td_OrderID";
|
|
$query = $this->db_onedev->query($sql);
|
|
// echo $this->db_onedev->last_query();
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
|
|
}
|
|
}
|
|
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getlookup(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$rows = [];
|
|
$query ="SELECT Td_BloodTypeID,Td_BloodTypeCode, Td_BloodTypeName
|
|
FROM one_bb.td_bloodtype
|
|
WHERE
|
|
Td_BloodTypeIsActive = 'Y'";
|
|
$rows['bloodtypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$query ="SELECT Td_BloodRhesusID,Td_BloodRhesusCode,Td_BloodRhesusName
|
|
FROM one_bb.td_bloodrhesus
|
|
WHERE
|
|
Td_BloodRhesusIsActive = 'Y'";
|
|
$rows['bloodrhesus'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$query ="SELECT Td_BloodCategoryID,Td_BloodCategoryCode,Td_BloodCategoryName
|
|
FROM one_bb.td_bloodcategory
|
|
WHERE
|
|
Td_BloodCategoryIsActive = 'Y'";
|
|
$rows['bloodcategorys'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function save(){
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
$Bb_BloodEntryBagNumberBarcode = $prm["Bb_BloodEntryBagNumberBarcode"];
|
|
$Bb_BloodEntryTd_BloodTypeID = $prm["Bb_BloodEntryTd_BloodTypeID"];
|
|
$Bb_BloodEntryTd_BloodRhesusID = $prm["Bb_BloodEntryTd_BloodRhesusID"];
|
|
$Bb_BloodEntryTd_BloodCategoryID = $prm["Bb_BloodEntryTd_BloodCategoryID"];
|
|
$Bb_BloodEntryAftapDate = date('Y-m-d',strtotime($prm['Bb_BloodEntryAftapDate']));
|
|
$Bb_BloodEntryExpiredDate = date('Y-m-d',strtotime($prm['Bb_BloodEntryExpiredDate']));
|
|
$Bb_BloodEntryEntryDate = date('Y-m-d',strtotime($prm['Bb_BloodEntryEntryDate']));
|
|
$Bb_BloodEntryEntryTime = $prm["Bb_BloodEntryEntryTime"];
|
|
$Bb_BloodEntryBb_BloodSourceID = $prm["Bb_BloodEntryBb_BloodSourceID"];
|
|
$Bb_BloodEntryIsRequest = $prm["Bb_BloodEntryIsRequest"];
|
|
|
|
$this->db_onedev->trans_start();
|
|
$this->db_onedev->trans_strict(FALSE);
|
|
|
|
$numbering = '';
|
|
$sql = "SELECT one_bb.fn_numbering('B') as numbering";
|
|
$qry = $this->db_onedev->query($sql);
|
|
if($qry){
|
|
$numbering = $qry->row()->numbering;
|
|
}
|
|
else{
|
|
$this->sys_error_db("get numbering error", $this->db_onedev->last_query());
|
|
exit;
|
|
}
|
|
|
|
$sql = "INSERT INTO one_bb.bb_bloodentry(
|
|
Bb_BloodEntryBagNumber,
|
|
Bb_BloodEntryBagNumberBarcode,
|
|
Bb_BloodEntryTd_BloodTypeID,
|
|
Bb_BloodEntryTd_BloodRhesusID,
|
|
Bb_BloodEntryTd_BloodCategoryID,
|
|
Bb_BloodEntryAftapDate,
|
|
Bb_BloodEntryExpiredDate,
|
|
Bb_BloodEntryEntryDate,
|
|
Bb_BloodEntryEntryTime,
|
|
Bb_BloodEntryBb_BloodSourceID,
|
|
Bb_BloodEntryIsRequest,
|
|
Bb_BloodEntryUserID,
|
|
Bb_BloodEntryLastUpdate,
|
|
Bb_BloodEntryCreated)
|
|
VALUES(
|
|
?,?,?,?,?,?,?,?,?,?,?,?,NOW(),NOW())";
|
|
$qry = $this->db_onedev->query($sql, array($numbering,
|
|
$Bb_BloodEntryBagNumberBarcode,
|
|
$Bb_BloodEntryTd_BloodTypeID,
|
|
$Bb_BloodEntryTd_BloodRhesusID,
|
|
$Bb_BloodEntryTd_BloodCategoryID,
|
|
$Bb_BloodEntryAftapDate,
|
|
$Bb_BloodEntryExpiredDate,
|
|
$Bb_BloodEntryEntryDate,
|
|
$Bb_BloodEntryEntryTime,
|
|
$Bb_BloodEntryBb_BloodSourceID,
|
|
$Bb_BloodEntryIsRequest,
|
|
$userid
|
|
));
|
|
$last_id = 0;
|
|
// echo $this->db_onedev->last_query();
|
|
if($qry){
|
|
$last_id = $this->db_onedev->insert_id();
|
|
}
|
|
else{
|
|
$this->sys_error_db("save bb_bloodentry error", $this->db_onedev->last_query());
|
|
exit;
|
|
}
|
|
$this->db_onedev->trans_complete();
|
|
|
|
$result = array(
|
|
"message" => ''
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|