Initial import
This commit is contained in:
1141
application/controllers/corporate/Uploader.php
Normal file
1141
application/controllers/corporate/Uploader.php
Normal file
File diff suppressed because it is too large
Load Diff
907
application/controllers/corporate/Uploader_dbg.php
Normal file
907
application/controllers/corporate/Uploader_dbg.php
Normal file
@@ -0,0 +1,907 @@
|
||||
<?php
|
||||
class Uploader_dbg extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
$raw = file_get_contents("php://input");
|
||||
return json_decode($raw, true);
|
||||
}
|
||||
function get_company($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyID, M_CompanyOldID, M_BranchID M_CompanyM_BranchID, M_CompanyName, M_CompanyNumber,
|
||||
M_CompanyIDParent, M_CompanyM_CompanyTypeID, M_CompanyM_CompanyBusinessID,
|
||||
M_CompanyM_ProvinceID, M_CompanyM_CityID, M_CompanyM_DistrictID, M_CompanyM_KelurahanID,
|
||||
M_CompanyAddress, M_CompanyPhone, M_CompanyFax, M_CompanyEmail, M_CompanyPIC,
|
||||
M_CompanyM_StaffID, M_CompanyNat_CompanyLevelID, M_CompanyNat_HierarchyID,
|
||||
M_CompanyIsLabFrom, M_CompanyIsLabTo, M_CompanyIsDefault, M_CompanyM_DoctorID,
|
||||
M_CompanyCreated, M_CompanyLastUpdated, M_CompanyIsActive, M_CompanyAddressLocation,
|
||||
M_CompanyHp, M_CompanyPrivateRequest
|
||||
from m_company
|
||||
join m_branch on M_CompanyID = ?
|
||||
and M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$qry = $this->db->query($sql, [$companyID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $rows,
|
||||
])
|
||||
);
|
||||
}
|
||||
function update_upload_mou()
|
||||
{
|
||||
$param = $this->get_param();
|
||||
$uploadID = $param["uploadID"];
|
||||
$status = $param["status"];
|
||||
$sql = "update corp_upload set Corp_UploadStatus = ?
|
||||
, Corp_UploadRetry = Corp_UploadRetry+1
|
||||
, Corp_UploadSentDate = now()
|
||||
where Corp_UploadID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$status, $uploadID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"message" => "",
|
||||
])
|
||||
);
|
||||
}
|
||||
function get_upload_mou()
|
||||
{
|
||||
//Hardcode 1st
|
||||
//2277,2278,2279,2613
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$sql = "select Corp_UploadID, Corp_UploadM_MouID M_MouID,
|
||||
M_MouM_CompanyID
|
||||
from corp_upload
|
||||
join m_mou on Corp_UploadM_MouID = M_MouID
|
||||
where
|
||||
Corp_UploadStatus <> 'Y'
|
||||
and
|
||||
Corp_UploadIsActive = 'Y'
|
||||
and Corp_UploadRetry < 5
|
||||
limit 0,10
|
||||
";
|
||||
$resp = $this->get_rows($sql);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz($resp["message"]);
|
||||
}
|
||||
$result = [];
|
||||
foreach ($resp["data"] as $idx => $r) {
|
||||
$result[] = $r;
|
||||
}
|
||||
$data = json_encode(["status" => "OK", "data" => $result]);
|
||||
$this->reply_gz($data);
|
||||
}
|
||||
function mou_order($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
// get order | pasien
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderDate,T_OrderHeaderLabNumber,T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderLastUpdated, max(ifnull(T_OrderDetailValDate,'1971-01-01 00:01:01')) LastValidationDate,
|
||||
max(ifnull(T_OrderDetailVerDate,'1971-01-01 00:01:01')) LastVerifDate,
|
||||
$branchID M_BranchID, '$branchCode' M_BranchCode, T_OrderHeaderM_PatientID,
|
||||
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.patient_fullname')) FullName,
|
||||
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.M_PatientName')) M_PatientName,
|
||||
T_OrderHeaderM_CompanyID M_CompanyID, M_CompanyNumber,
|
||||
T_OrderHeaderM_MouID M_MouID,
|
||||
M_PatientNIK, M_PatientJabatan, M_PatientKedudukan, M_PatientLocation, M_PatientJob
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderheaderaddon on
|
||||
T_OrderHeaderM_MouID = ?
|
||||
and T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
-- and T_OrderHeaderAddOnValidationDone = 'Y'
|
||||
join m_company on M_CompanyID = T_OrderHeaderM_CompanyID
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join t_orderdetail
|
||||
on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
group by T_OrderHeaderID";
|
||||
$resp = $this->get_rows($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz(
|
||||
"Err Get Order for MOU ID : $mouID | " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
$orders = $resp["data"];
|
||||
echo $this->reply_gz(
|
||||
json_encode(["status" => "OK", "data" => $orders])
|
||||
);
|
||||
}
|
||||
|
||||
//Get Detail Mou
|
||||
function mou_detail($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$sql = "select $branchID Corp_M_BranchID , '$branchCode' Corp_M_BranchCode,
|
||||
M_MouID, M_MouName, M_MouNote , M_CompanyNumber M_MouM_CompanyNumber,
|
||||
M_MouM_CompanyID , M_MouRefNumber ,
|
||||
M_MouNumber , M_MouStartDate , M_MouEndDate , M_MouBase,
|
||||
M_MouM_OmzetTypeID , M_MouIsReleased , M_MouReleaseDate ,
|
||||
M_MouReleaseUserID , M_MouCreated , M_MouLastUpdated ,
|
||||
M_MouIsActive, M_MouUserID
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where M_MouID = ?";
|
||||
$resp = $this->get_row($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz($resp["message"]);
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
$this->error_reply_gz("Mou ID $mouID not found.");
|
||||
}
|
||||
$result = $resp["data"];
|
||||
$this->reply_gz(
|
||||
json_encode(["status" => "OK", "data" => $resp["data"]])
|
||||
);
|
||||
}
|
||||
function reply_gz($resp)
|
||||
{
|
||||
echo gzcompress($resp);
|
||||
exit();
|
||||
}
|
||||
function get_branch()
|
||||
{
|
||||
$sql =
|
||||
"select M_BranchID,M_BranchCode from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault ='Y'";
|
||||
$resp = $this->get_row($sql);
|
||||
if ($resp["status"] != 1) {
|
||||
echo json_encode($resp);
|
||||
exit();
|
||||
}
|
||||
return [$resp["data"]["M_BranchID"], $resp["data"]["M_BranchCode"]];
|
||||
}
|
||||
function log($msg)
|
||||
{
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $msg\n";
|
||||
}
|
||||
function error_reply_gz($msg)
|
||||
{
|
||||
echo gzcompress(json_encode(["status" => "ERR", "message" => $msg]));
|
||||
}
|
||||
function reply($resp, $type = 1)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
}
|
||||
function error_reply($msg)
|
||||
{
|
||||
echo json_encode(["status" => "ERR", "message" => $msg]);
|
||||
}
|
||||
function get_mou_param($mouID)
|
||||
{
|
||||
$sql = "select M_MouM_CompanyID, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouID = ?";
|
||||
$resp = $this->get_row($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Mou Param from $mouID : " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return [0, "1971-01-01", "1971-01-01"];
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return [
|
||||
$r["M_MouM_CompanyID"],
|
||||
$r["M_MouStartDate"],
|
||||
$r["M_MouEndDate"],
|
||||
];
|
||||
}
|
||||
function getCompanyNumber($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyNumber from m_company where M_CompanyID = ?";
|
||||
$resp = $this->get_row($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Company from $companyID: " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return "";
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return $r["M_CompanyNumber"];
|
||||
}
|
||||
//
|
||||
function do_global($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$arr_sp = ["sp_rpt_nl_001_v2", "sp_rpt_nl_002_v2", "sp_rpt_nl_003_v2"];
|
||||
list($companyID, $startDate, $endDate) = $this->get_mou_param($mouID);
|
||||
$companyNumber = $this->getCompanyNumber($companyID);
|
||||
|
||||
$result = [];
|
||||
for ($idx = 0; $idx < 3; $idx++) {
|
||||
$sp = $arr_sp[$idx];
|
||||
$key = str_replace("sp_", "", $sp);
|
||||
$key = str_replace("_v2", "", $key);
|
||||
|
||||
$sql = "call {$sp}(?,?,?,?,'admin')";
|
||||
$resp = $this->get_sp($sql, [
|
||||
$startDate,
|
||||
$endDate,
|
||||
$companyID,
|
||||
$mouID,
|
||||
]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
||||
exit();
|
||||
}
|
||||
$xresult = [];
|
||||
foreach ($resp["data"] as $r) {
|
||||
$r["M_CompanyNumber"] = $companyNumber;
|
||||
$r["M_BranchID"] = $branchID;
|
||||
$r["M_BranchCode"] = $branchCode;
|
||||
$xresult[] = $r;
|
||||
}
|
||||
$result[$key] = $xresult;
|
||||
}
|
||||
echo $this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"branchID" => $branchID,
|
||||
"branchCode" => $branchCode,
|
||||
"companyID" => $companyID,
|
||||
"result" => $result,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function get_resume_id($headerID)
|
||||
{
|
||||
$sql = "select Mcu_ResumeID from mcu_resume
|
||||
where Mcu_ResumeT_OrderHeaderID = ?
|
||||
and Mcu_ResumeIsActive = 'Y'
|
||||
order by Mcu_ResumeID desc
|
||||
limit 0,1";
|
||||
$resp = $this->get_row($sql, [$headerID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
||||
$resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $resp["data"]["Mcu_ResumeID"];
|
||||
}
|
||||
function json_get_so_id($headerID, $so = "")
|
||||
{
|
||||
echo json_encode($this->get_so_result_entry_id($headerID, $so));
|
||||
}
|
||||
function get_so_result_entry_id($headerID, $so = "")
|
||||
{
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 4
|
||||
and T_TestIsNonLab = 'FISIK UMUM'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
|
||||
|
||||
if ($so == "audio") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'AUDIOMETRY'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "ecg") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'ELECTROMEDIS'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "treadmill") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'TREADMILL'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "elmd") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "usg") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 3
|
||||
and T_TestNat_SubGroupID = 22
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "manthoux") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 1
|
||||
and T_TestNat_SubGroupID = 10
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
}
|
||||
$resp = $this->get_row($sql, [$headerID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
||||
$resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $resp["data"]["So_ResultEntryID"];
|
||||
}
|
||||
|
||||
// Hasil lab per individu
|
||||
// Hasil Non Lab per individu
|
||||
// Hasil Resume Individu
|
||||
// by T_OrderHeaderID
|
||||
function get_report($uploadID)
|
||||
{
|
||||
$sql = "select Corp_ReportCode
|
||||
from
|
||||
corp_report
|
||||
join corp_uploaderdetail on
|
||||
Corp_UploaderDetailCorp_ReportID = Corp_ReportID
|
||||
and Corp_UploaderDetailCorp_UploadID = ?";
|
||||
$qry = $this->db->query($sql, [$uploadID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" =>
|
||||
"Error get Reports : " . $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [];
|
||||
//pasti ikut
|
||||
$result[] = "sp_rpt_t_hasil_sampling";
|
||||
$result[] = "sp_rpt_t_hasil_sampling_eng";
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
foreach ($rows as $r) {
|
||||
$rpt_code = $r["Corp_ReportCode"];
|
||||
switch ($rpt_code) {
|
||||
case "001":
|
||||
if (!in_array("sp_rpt_t_hasil2", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil2";
|
||||
}
|
||||
break;
|
||||
case "002":
|
||||
if (!in_array("sp_rpt_t_hasil_eng", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_eng";
|
||||
}
|
||||
break;
|
||||
case "003":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_xray", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_xray";
|
||||
}
|
||||
break;
|
||||
case "004":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd";
|
||||
}
|
||||
break;
|
||||
case "005":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "006":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "007":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "008":
|
||||
case "009":
|
||||
if (!in_array("riw", $result)) {
|
||||
$result[] = "sp_dummy_fisik";
|
||||
}
|
||||
break;
|
||||
|
||||
case "010": //audio
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd-audio", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-audio";
|
||||
}
|
||||
break;
|
||||
case "011": //ecg
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd-ecg", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-ecg";
|
||||
}
|
||||
break;
|
||||
case "012": //treadmill
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (
|
||||
!in_array("sp_rpt_t_hasil_so_elmd-treadmill", $result)
|
||||
) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-treadmill";
|
||||
}
|
||||
break;
|
||||
case "013": //pajanan
|
||||
if (!in_array("sp_dummy_pajanan", $result)) {
|
||||
$result[] = "sp_dummy_pajanan";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function individu($headerID, $uploadID)
|
||||
{
|
||||
$arr_sp = $this->get_report($uploadID);
|
||||
$result = [];
|
||||
foreach ($arr_sp as $sp) {
|
||||
$key = str_replace("sp_", "", $sp);
|
||||
$sql = "call {$sp}(?,'admin')";
|
||||
|
||||
if ($sp == "sp_rpt_mcu_resume_cp_r") {
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resumeID = $this->get_resume_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resumeID]);
|
||||
} elseif ($sp == "sp_rpt_mcu_resume_cp_r_eng") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resumeID = $this->get_resume_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resumeID]);
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_bdm") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"elmd"
|
||||
);
|
||||
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-audio") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"audio"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-ecg") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"ecg"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-treadmill") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"treadmill"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_dummy_pajanan") {
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"faktor_biologi",
|
||||
"faktor_ergonomi",
|
||||
"faktor_fisik",
|
||||
"faktor_kimia",
|
||||
"faktor_psikologi",
|
||||
];
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"pajanan"
|
||||
);
|
||||
$new_data = ["pajanan" => []];
|
||||
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["pajanan"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"k3"
|
||||
);
|
||||
}
|
||||
}
|
||||
$resp = ["data" => $new_data, "status" => 0];
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_layanan") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"layanan"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"manthoux"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux_sampling") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"manthoux"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_usg") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"usg"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_xray") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_dummy_fisik") {
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"keluhan_saat_ini_new",
|
||||
"riwayat_phobia",
|
||||
"riwayat_obat",
|
||||
"riwayat_penyakit",
|
||||
"riwayat_hidup",
|
||||
"riwayat_keluarga",
|
||||
"tanda_vital",
|
||||
"status_gizi",
|
||||
"keadaan_umum",
|
||||
"mulut",
|
||||
"gigi",
|
||||
"visus",
|
||||
"kepala_wajah",
|
||||
"mata",
|
||||
"telinga",
|
||||
"thorax",
|
||||
"paru",
|
||||
"jantung",
|
||||
"integumen",
|
||||
"sistem",
|
||||
"anggota",
|
||||
"genitourinaria",
|
||||
"perut",
|
||||
"leher",
|
||||
"hidung",
|
||||
"persepsi_warna",
|
||||
];
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data = ["fisik" => [], "riwayat" => []];
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["fisik"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data["riwayat"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"riwayat"
|
||||
);
|
||||
}
|
||||
}
|
||||
$resp = ["data" => $new_data, "status" => 0];
|
||||
} else {
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
}
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
||||
exit();
|
||||
}
|
||||
$result[$key] = $resp["data"];
|
||||
}
|
||||
echo $this->reply_gz(
|
||||
json_encode(["status" => "OK", "result" => $result])
|
||||
);
|
||||
}
|
||||
function get_fisik($param, $result_entry_id, $type, $lang_id = 1)
|
||||
{
|
||||
$url = "http://localhost/one-api/v1/report/fisik/$param/$result_entry_id/$lang_id/$type";
|
||||
$resp = $this->get($url);
|
||||
return json_decode($resp, true);
|
||||
}
|
||||
function get($url, $timeout = 60, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode(["status" => "ERR", "message" => $err_msg]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function get_sp($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
return $resp;
|
||||
}
|
||||
function get_mou($companyID)
|
||||
{
|
||||
$sql = "select M_MouID,M_MouName, M_MouNumber
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y' and M_MouM_CompanyID = ?";
|
||||
$resp = $this->get_rows($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply("Error Get MOU by Company $companyID");
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $resp["data"],
|
||||
]);
|
||||
}
|
||||
function step_debug($rows)
|
||||
{
|
||||
print_r($rows);
|
||||
exit();
|
||||
}
|
||||
function get_rows($sql, $param = false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return [
|
||||
"status" => -1,
|
||||
"message" =>
|
||||
$this->db->last_query() .
|
||||
"|" .
|
||||
$this->db->error()["message"],
|
||||
];
|
||||
}
|
||||
return ["status" => 0, "data" => $qry->result_array()];
|
||||
}
|
||||
function get_row($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
if ($resp["status"] == -1) {
|
||||
return $resp;
|
||||
}
|
||||
if (count($resp["data"]) == 0) {
|
||||
return ["status" => 0, "message" => "Not found."];
|
||||
}
|
||||
return ["status" => 1, "data" => $resp["data"][0]];
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user