149 lines
4.3 KiB
PHP
149 lines
4.3 KiB
PHP
<?php
|
|
class Mgmmcu_nonlab extends MY_Controller
|
|
{
|
|
var $base_url;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->base_url = "/one-api/etl/mgmmcu";
|
|
$this->db->query("use one_etl");
|
|
}
|
|
|
|
function nonlab_kelainan($orderHeaderID, $mgmMcuID = 0)
|
|
{
|
|
$resp = $this->json($orderHeaderID);
|
|
}
|
|
|
|
// helper function
|
|
// post
|
|
// get
|
|
// insert_or_update
|
|
function json($orderHeaderID)
|
|
{
|
|
$url = "http://localhost/one-api/v1/report/fisik03/json/$orderHeaderID";
|
|
$data = file_get_contents($url);
|
|
$dataJson = json_decode($data, true);
|
|
$result = [];
|
|
foreach ($dataJson as $r) {
|
|
$arr = [
|
|
"T_OrderHeaderID" => $orderHeaderID,
|
|
"title" => $r["title"],
|
|
"subtitle" => $r["subtitle"],
|
|
"label_flag_normal" => $r["label_flag_normal"],
|
|
"flag_normal" => $r["flag_normal"],
|
|
"flag_normal" => $r["flag_normal"],
|
|
"show_all" => $r["show_all"],
|
|
"type_form" => $r["type_form"],
|
|
"T_TestName" => $r["T_TestName"],
|
|
"So_ResultEntryFisikUmumType" => $r["So_ResultEntryFisikUmumType"],
|
|
"name" => $r["name"],
|
|
"table_name" => $r["table_name"],
|
|
"segment_name" => $r["segment_name"],
|
|
"id_code" => $r["id_code"],
|
|
"lang_id" => $r["lang_id"],
|
|
"label" => $r["label"],
|
|
"is_normal" => $r["is_normal"],
|
|
"chx" => $r["chx"],
|
|
"value" => $r["value"],
|
|
"kesimpulan" => $r["kesimpulan"],
|
|
"value_x" => $r["value_x"],
|
|
"standart_bmi" => $r["standart_bmi"],
|
|
"standart" => $r["standart"],
|
|
];
|
|
$result[] = $arr;
|
|
}
|
|
header("Content-Type: application/json");
|
|
echo json_encode($result);
|
|
exit;
|
|
return $result;
|
|
}
|
|
|
|
|
|
//tidak jadi di pakai
|
|
function mcu_resume($orderHeaderID)
|
|
{
|
|
$sql = "call one.sp_rpt_r_mcu_resume(?,'')";
|
|
$qry = $this->db->query($sql, [$orderHeaderID]);
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error sp_mcu_resume| " . $this->db->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$arr_test = [];
|
|
$result = [];
|
|
Header("Content-Type: application/json");
|
|
echo json_encode($rows);
|
|
exit;
|
|
foreach ($rows as $r) {
|
|
if ($r["T_TestID"] == "") continue;
|
|
$arr_test[$r["T_TestID"]] = 1;
|
|
}
|
|
$s_test = "0," . implode(",", array_keys($arr_test));
|
|
$sql = "select T_TestID,Nat_TestID,Nat_TestName
|
|
from one.t_test
|
|
join one.nat_test on T_TestID in ($s_test)
|
|
and T_TestNat_TestID = Nat_TestID";
|
|
$qry = $this->db->query($sql);
|
|
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error get nat_test| " . $this->db->error()["message"], "sql" => $this->db->last_query()
|
|
]);
|
|
exit;
|
|
}
|
|
$xrows = $qry->result_array();
|
|
foreach ($xrows as $r) {
|
|
$arr_test[$r["T_TestID"]] = $r;
|
|
}
|
|
foreach ($rows as $r) {
|
|
$nt = $arr_test[$r["T_TestID"]];
|
|
$result[] = [
|
|
"T_OrderHeaderID" => $r["T_OrderHeaderID"],
|
|
"Nat_TestID" => $nt["Nat_TestID"],
|
|
"Nat_TestName" => $nt["Nat_TestName"],
|
|
"Result" => $r["Mcu_ResumeDetailsResult"]
|
|
];
|
|
}
|
|
echo json_encode(["status" => "OK", "data" => $result]);
|
|
}
|
|
|
|
function post($service, $data)
|
|
{
|
|
$xbase_url = $this->base_url;
|
|
$url = $xbase_url . "$service";
|
|
$ch = curl_init($url);
|
|
$payload = json_encode($data);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
$data_rst = json_decode($result);
|
|
return $data_rst;
|
|
}
|
|
function get($service, $debug = "")
|
|
{
|
|
$xbase_url = $this->base_url;
|
|
$url = $xbase_url . "$service";
|
|
$ch = curl_init($url);
|
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
if ($debug != "") {
|
|
echo "url : $url \n";
|
|
print_r($result);
|
|
}
|
|
$data_rst = json_decode($result);
|
|
return $data_rst;
|
|
}
|
|
}
|