744 lines
25 KiB
Plaintext
744 lines
25 KiB
Plaintext
<?php
|
|
class Riwayat extends MY_Controller
|
|
{
|
|
var $db;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
echo "ETL MCU RIWAYAT";
|
|
}
|
|
function reply($resp)
|
|
{
|
|
echo json_encode($resp);
|
|
}
|
|
|
|
function generate($mgmMcuID, $orderHeaderID)
|
|
{
|
|
$url = "http://localhost/one-api/etl/mgmmcu_nonlab/json/" . $orderHeaderID;
|
|
$get_content = file_get_contents($url);
|
|
$json = json_decode($get_content, true);
|
|
|
|
$this->generate_etnis($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_keluhan_saat_ini($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_riwayat_pobia($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_riwayat_penyakit($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_riwayat_penyakit_keluarga($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_kebiasaan_hidup($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_konsumsi_obat($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_imunisasi($mgmMcuID, $orderHeaderID, $json);
|
|
$sql = "UPDATE one_etl.mcu_order SET Mcu_OrderStatus = 'W' WHERE Mcu_OrderMgm_McuID = ? AND Mcu_OrderT_OrderHeaderID = ?";
|
|
$qry = $this->db->query($sql, [$mgmMcuID, $orderHeaderID]);
|
|
if (!$qry) {
|
|
echo "Error :" . $this->db->error()["message"];
|
|
echo $this->db->last_query();
|
|
}
|
|
echo json_encode(["status" => "OK", "message" => ""]);
|
|
}
|
|
|
|
function update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode)
|
|
{
|
|
$sql = "UPDATE one_etl.mgm_header SET
|
|
Mgm_HeaderIsActive = 'N'
|
|
WHERE Mgm_HeaderMgm_McuID = ? AND
|
|
Mgm_HeaderT_OrderHeaderID = ? AND Mgm_HeaderNat_TestCode = ?";
|
|
$qry = $this->db->query($sql, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
function update_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode)
|
|
{
|
|
$sql_select_header = "SELECT Mgm_HeaderID
|
|
FROM one_etl.mgm_header
|
|
WHERE Mgm_HeaderMgm_McuID = ? AND Mgm_HeaderT_OrderHeaderID = ?
|
|
AND Mgm_HeaderNat_TestCode = ? AND Mgm_HeaderIsActive = 'N'
|
|
ORDER BY Mgm_HeaderID DESC";
|
|
$qry_select_header = $this->db->query($sql_select_header, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode
|
|
));
|
|
if ($qry_select_header) {
|
|
$rows = $qry_select_header->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mgm_header", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mgmHeaderID = $rows[0]["Mgm_HeaderID"];
|
|
|
|
$sql_upate_riwayat = "UPDATE one_etl.mgm_riwayat
|
|
SET Mgm_RiwayatIsActive = 'N'
|
|
WHERE Mgm_RiwayatMgm_HeaderID = ?";
|
|
$qry_update_detail = $this->db->query($sql_upate_riwayat, array(
|
|
$mgmHeaderID
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry_update_detail) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
function insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode)
|
|
{
|
|
$query = "SELECT COUNT(*) as exist FROM one_etl.mgm_header WHERE Mgm_HeaderIsActive = 'Y'
|
|
AND Mgm_HeaderMgm_McuID = '{$mgmMcuID}'
|
|
AND Mgm_HeaderT_OrderHeaderID = '{$orderHeaderID}'
|
|
AND Mgm_HeaderNat_TestCode = '{$natTestCode}'
|
|
AND Mgm_HeaderType = 'R'";
|
|
$exist_name = $this->db->query($query)->row()->exist;
|
|
if ($exist_name == 0) {
|
|
$sql = "SELECT T_OrderHeaderM_PatientAge,
|
|
M_SexCode
|
|
FROM t_orderheader
|
|
join m_patient on
|
|
T_OrderHeaderID = ?
|
|
and T_OrderHeaderM_PatientID = M_PatientID
|
|
join m_sex on M_PatientM_SexID = M_SexID";
|
|
$qry = $this->db->query($sql, [$orderHeaderID]);
|
|
if (!$qry) {
|
|
echo json_encode(["status" => "ERR", "message" => $this->db->error()]);
|
|
exit;
|
|
}
|
|
$row = $qry->row();
|
|
$patient_age = $row->T_OrderHeaderM_PatientAge;
|
|
$sex_code = $row->M_SexCode;
|
|
|
|
$sql = "INSERT INTO one_etl.mgm_header(
|
|
Mgm_HeaderMgm_McuID,
|
|
Mgm_HeaderT_OrderHeaderID,
|
|
Mgm_HeaderNat_TestCode,
|
|
Mgm_HeaderT_OrderHeaderM_PatientAge,
|
|
Mgm_HeaderM_SexCode,
|
|
Mgm_HeaderType,
|
|
Mgm_HeaderIsNormal,
|
|
Mgm_HeaderIsActive,
|
|
Mgm_HeaderCreated,
|
|
Mgm_HeaderLastUpdated) VALUES(?,?,?,?,?,'R','Y','Y',NOW(),NOW())";
|
|
$qry = $this->db->query($sql, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode,
|
|
$patient_age,
|
|
$sex_code
|
|
));
|
|
|
|
$last_qry = $this->db->last_query();
|
|
//echo $last_qry;
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
function insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID)
|
|
{
|
|
$query = "SELECT COUNT(*) as exist FROM one_etl.mgm_header WHERE Mgm_HeaderIsActive = 'Y'
|
|
AND Mgm_HeaderMgm_McuID = '{$mgmMcuID}'
|
|
AND Mgm_HeaderT_OrderHeaderID = '{$orderHeaderID}'
|
|
AND Mgm_HeaderNat_TestCode = '{$natTestCode}'
|
|
AND Mgm_HeaderType = 'R'";
|
|
$exist_name = $this->db->query($query)->row()->exist;
|
|
if ($exist_name == 0) {
|
|
$sql = "SELECT T_OrderHeaderM_PatientAge,
|
|
M_SexCode
|
|
FROM t_orderheader
|
|
join m_patient on
|
|
T_OrderHeaderID = ?
|
|
and T_OrderHeaderM_PatientID = M_PatientID
|
|
join m_sex on M_PatientM_SexID = M_SexID";
|
|
$qry = $this->db->query($sql, [$orderHeaderID]);
|
|
if (!$qry) {
|
|
echo json_encode(["status" => "ERR", "message" => $this->db->error()]);
|
|
exit;
|
|
}
|
|
$row = $qry->row();
|
|
$patient_age = $row->T_OrderHeaderM_PatientAge;
|
|
$sex_code = $row->M_SexCode;
|
|
|
|
$sql = "INSERT INTO one_etl.mgm_header(
|
|
Mgm_HeaderMgm_McuID,
|
|
Mgm_HeaderT_OrderHeaderID,
|
|
Mgm_HeaderNat_TestCode,
|
|
Mgm_HeaderT_OrderHeaderM_PatientAge,
|
|
Mgm_HeaderM_SexCode,
|
|
Mgm_HeaderType,
|
|
Mgm_HeaderIsNormal,
|
|
Mgm_HeaderIsActive,
|
|
Mgm_HeaderCreated,
|
|
Mgm_HeaderLastUpdated) VALUES(?,?,?,?,?,'R','Y','Y',NOW(),NOW())";
|
|
$qry = $this->db->query($sql, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode,
|
|
$patient_age,
|
|
$sex_code
|
|
));
|
|
|
|
$last_qry = $this->db->last_query();
|
|
//echo $last_qry;
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$insert_mgm_header_id = $this->db->insert_id();
|
|
} else {
|
|
$query = "SELECT Mgm_HeaderID FROM one_etl.mgm_header WHERE Mgm_HeaderIsActive = 'Y'
|
|
AND Mgm_HeaderMgm_McuID = '{$mgmMcuID}'
|
|
AND Mgm_HeaderT_OrderHeaderID = '{$orderHeaderID}'
|
|
AND Mgm_HeaderNat_TestCode = '{$natTestCode}'";
|
|
$insert_mgm_header_id = $this->db->query($query)->row()->Mgm_HeaderID;
|
|
}
|
|
$query = "SELECT COUNT(*) as exist FROM one_etl.mgm_riwayat WHERE Mgm_RiwayatIsActive = 'Y'
|
|
AND Mgm_RiwayatMgm_HeaderID = '{$insert_mgm_header_id}'
|
|
AND Mgm_RiwayatMcu_RiwayatID = '{$mcuRiwayatID}'
|
|
AND Mgm_RiwayatMcu_RiwayatGroupID = '{$mcuRiwayatGroupID}'";
|
|
$exist_riwayat = $this->db->query($query)->row()->exist;
|
|
if ($exist_riwayat == 0) {
|
|
// insert di mgm_riwayat
|
|
$sql_riwayat = "INSERT INTO one_etl.mgm_riwayat(
|
|
Mgm_RiwayatMgm_HeaderID,
|
|
Mgm_RiwayatMcu_RiwayatID,
|
|
Mgm_RiwayatMcu_RiwayatGroupID,
|
|
Mgm_RiwayatCreated,
|
|
Mgm_RiwayatLastUpdated) VALUES(?,?,?,NOW(),NOW())";
|
|
$qry_riwayat = $this->db->query($sql_riwayat, array(
|
|
$insert_mgm_header_id,
|
|
$mcuRiwayatID,
|
|
$mcuRiwayatGroupID,
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry_riwayat) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
function generate_etnis($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_etnis = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "ETNIS";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if (
|
|
$value["title"] == "ETNIS" && $value["chx"] == 1
|
|
) {
|
|
$have_etnis = true;
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($riwayat));
|
|
// echo $this->db->last_query();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat etnis", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate etnis berhasil']);
|
|
}
|
|
|
|
function generate_keluhan_saat_ini($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_keluhan_today = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "KELUHAN SAAT INI";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
|
|
if ($value["title"] == "KELUHAN SAAT INI" && $value["chx"] == 1) {
|
|
$have_keluhan_today = true;
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($riwayat));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat keluhan saat ini", $this->db);
|
|
exit;
|
|
}
|
|
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate keluhan saat ini berhasil']);
|
|
}
|
|
|
|
function generate_riwayat_pobia($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$riwayat_pobia = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "RIWAYAT POBIA";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if ($value["title"] == "RIWAYAT POBIA" && $value["chx"] == 1) {
|
|
// print_r($value);
|
|
// exit;
|
|
$riwayat_pobia = true;
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$riwayat = $value["label"];
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($riwayat));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat riwayat pobia", $this->db);
|
|
exit;
|
|
}
|
|
|
|
// print_r($rows);
|
|
// exit;
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate riwayat pobia berhasil']);
|
|
}
|
|
|
|
function generate_riwayat_penyakit($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_riwayat_penyakit = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "RIWAYAT PENYAKIT";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if ($value["title"] == "RIWAYAT PENYAKIT" && $value["chx"] == 1) {
|
|
$have_riwayat_penyakit = true;
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$segment_name = $value["segment_name"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatSegmentName = ?
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($segment_name, $riwayat));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat penyakit", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate riwayat penyakit berhasil']);
|
|
}
|
|
|
|
function generate_riwayat_penyakit_keluarga($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_riwayat_penyakit_keluarga = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "RIWAYAT PENYAKIT KELUARGA";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if ($value["title"] == "RIWAYAT PENYAKIT KELUARGA" && $value["chx"] == 1) {
|
|
// print_r($value);
|
|
// exit;
|
|
|
|
$have_riwayat_penyakit_keluarga = true;
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($riwayat));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat penyakit keluarga", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate riwayat penyakit keluarga berhasil']);
|
|
}
|
|
function generate_kebiasaan_hidup($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_kebiasaan_hidup = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "RIWAYAT KEBIASAAN HIDUP";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if ($value["title"] == "RIWAYAT KEBIASAAN HIDUP" && $value["chx"] == 1) {
|
|
$have_kebiasaan_hidup = true;
|
|
$segment = $value["segment_name"];
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatSegmentName = ?
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($segment, $riwayat));
|
|
// echo $this->db->last_query();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat kebiasaan hidup", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
// update mgm header
|
|
// $this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
// $this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate kebiasaan hidup berhasil']);
|
|
}
|
|
function generate_konsumsi_obat($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_kebiasaan_hidup = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "RIWAYAT KONSUMSI OBAT TERATUR";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if ($value["title"] == "RIWAYAT KONSUMSI OBAT TERATUR" && $value["chx"] == 1) {
|
|
$have_kebiasaan_hidup = true;
|
|
$segment = '';
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($riwayat));
|
|
// echo $this->db->last_query();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat obat", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
// update mgm header
|
|
// $this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
// $this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate kebiasaan hidup berhasil']);
|
|
}
|
|
function generate_imunisasi($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_kebiasaan_hidup = false;
|
|
$mcuRiwayatID = 0;
|
|
$mcuRiwayatGroupID = 0;
|
|
$natTestCode = "";
|
|
|
|
$title = "RIWAYAT IMUNISASI";
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $title);
|
|
|
|
foreach ($json as $key => $value) {
|
|
if ($value["title"] == "RIWAYAT IMUNISASI" && $value["chx"] == 1) {
|
|
$have_kebiasaan_hidup = true;
|
|
$segment = $value["segment_name"];
|
|
$riwayat = $value["label"];
|
|
if ($riwayat == "") {
|
|
print_r($value);
|
|
};
|
|
$natTestCode = $value["title"];
|
|
$sql = "SELECT Mcu_RiwayatID,
|
|
Mcu_RiwayatName,
|
|
Mcu_RiwayatMcu_RiwayatGroupID
|
|
FROM one_etl.mcu_riwayat
|
|
WHERE Mcu_RiwayatIsActive = 'Y'
|
|
AND Mcu_RiwayatSegmentName = ?
|
|
AND Mcu_RiwayatName = ?";
|
|
$qry = $this->db->query($sql, array($segment, $riwayat));
|
|
// echo $this->db->last_query();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu riwayat imunisasi", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuRiwayatID = $rows[0]["Mcu_RiwayatID"];
|
|
$mcuRiwayatGroupID = $rows[0]["Mcu_RiwayatMcu_RiwayatGroupID"];
|
|
}
|
|
|
|
// update mgm header
|
|
// $this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
// $this->update_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuRiwayatID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_riwayat($mgmMcuID, $orderHeaderID, $natTestCode, $mcuRiwayatID, $mcuRiwayatGroupID);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate kebiasaan hidup berhasil']);
|
|
}
|
|
}
|