1806 lines
59 KiB
PHP
1806 lines
59 KiB
PHP
<?php
|
|
|
|
class Fisik extends MY_Controller
|
|
{
|
|
var $db;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// $cek = $this->db->query("select database() as current_db")->result();
|
|
// print_r($cek);
|
|
echo "ETL MCU FISIK";
|
|
}
|
|
function reply($resp)
|
|
{
|
|
echo json_encode($resp);
|
|
}
|
|
|
|
function generate($mgmMcuID, $orderHeaderID)
|
|
{
|
|
// Mcu_OrderStatusFisik
|
|
$sql = "SELECT * FROM one_etl.mcu_order 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();
|
|
$this->sys_error_db("Error cek mcu order riwayat");
|
|
exit;
|
|
}
|
|
$cek = $qry->result_array();
|
|
if (count($cek) > 0) {
|
|
if ($cek[0]['Mcu_OrderStatusFisik'] == 'Y') {
|
|
$this->statusDone($mgmMcuID, $orderHeaderID);
|
|
$this->sys_ok('Already generated');
|
|
exit;
|
|
}
|
|
}
|
|
$url = "http://localhost/one-api/etl/mgmmcu_nonlab/json/" . $orderHeaderID;
|
|
$get_content = file_get_contents($url);
|
|
$json = json_decode($get_content, true);
|
|
header("Content-Type: text/plain");
|
|
$this->db->trans_begin();
|
|
$this->generate_bmi($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_blood_presure($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_visus_mata($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_persepsi_warna($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_px_gigi($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_tht($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_jantung($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_perut($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_anggota_gerak($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_pesyarafan($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_smell_test($mgmMcuID, $orderHeaderID, $json);
|
|
$this->generate_lbp($mgmMcuID, $orderHeaderID, $json);
|
|
|
|
$sql = "UPDATE one_etl.mcu_order SET
|
|
Mcu_OrderStatusFisik = 'Y',
|
|
Mcu_OrderStatusFisikDateTime = NOW(),
|
|
Mcu_OrderLastUpdated = NOW()
|
|
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();
|
|
}
|
|
$this->statusDone($mgmMcuID, $orderHeaderID);
|
|
$this->db->trans_commit();
|
|
echo json_encode(["status" => "OK", "message" => ""]);
|
|
}
|
|
|
|
function update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode)
|
|
{
|
|
$sql_update = "UPDATE one_etl.mgm_header SET
|
|
Mgm_HeaderIsActive = 'N',
|
|
Mgm_HeaderLastUpdated = NOW()
|
|
WHERE Mgm_HeaderMgm_McuID = ? AND
|
|
Mgm_HeaderT_OrderHeaderID = ? AND Mgm_HeaderNat_TestCode = ?";
|
|
$qry_update = $this->db->query($sql_update, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry_update) {
|
|
// $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_detail($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_update_detail = "UPDATE one_etl.mgm_detail
|
|
SET Mgm_DetailIsActive = 'N',
|
|
Mgm_DetailLastUpdated = NOW()
|
|
WHERE Mgm_DetailMgm_HeaderID = ?";
|
|
$qry_update_detail = $this->db->query($sql_update_detail, 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)
|
|
{
|
|
$sql = "SELECT T_OrderHeaderM_PatientAge,
|
|
M_SexCode, IFNULL(M_PatientKedudukan, '') M_PatientKedudukan
|
|
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;
|
|
$kedudukan = $row->M_PatientKedudukan;
|
|
|
|
$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,
|
|
Mgm_HeaderM_PatientLocation) VALUES(?,?,?,?,?,'F','Y','Y',NOW(),NOW(), ?)";
|
|
$qry = $this->db->query($sql, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode,
|
|
$patient_age,
|
|
$sex_code,
|
|
$kedudukan
|
|
));
|
|
$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;
|
|
}
|
|
}
|
|
|
|
function insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, $debug = "")
|
|
{
|
|
$sql = "SELECT T_OrderHeaderM_PatientAge,
|
|
M_SexCode , IFNULL(M_PatientKedudukan, '') M_PatientKedudukan
|
|
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;
|
|
$kedudukan = $row->M_PatientKedudukan;
|
|
|
|
$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,
|
|
Mgm_HeaderM_PatientLocation) VALUES(?,?,?,?,?,'F','Y','Y',NOW(),NOW(), ?)";
|
|
$qry = $this->db->query($sql, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode,
|
|
$patient_age,
|
|
$sex_code,
|
|
$kedudukan
|
|
));
|
|
$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;
|
|
}
|
|
|
|
$insert_mgm_header_id = $this->db->insert_id();
|
|
|
|
//insert di mgm_detail kelainanid dan kelainangroupid
|
|
|
|
$sql_detail = "INSERT INTO one_etl.mgm_detail(
|
|
Mgm_DetailMgm_HeaderID,
|
|
Mgm_DetailMcu_KelainanID,
|
|
Mgm_DetailMcu_KelainanGroupID,
|
|
Mgm_DetailIsActive,
|
|
Mgm_DetailCreated,
|
|
Mgm_DetailLastUpdated) VALUES(?,?,?,'Y',NOW(),NOW())";
|
|
$qry_detail = $this->db->query($sql_detail, array(
|
|
$insert_mgm_header_id,
|
|
$mcuKelainanID,
|
|
$mcuKelainanGroupID
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry_detail) {
|
|
// $this->db->trans_rollback();
|
|
|
|
$error = array(
|
|
|
|
"message" => $this->db->error()["message"],
|
|
"debug" => $debug,
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function generate_bmi($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
// cari ada bmi atau tidak
|
|
// jika sudah ada isActive di N kan dulu
|
|
// update mgm_detail join mgm_header set Mgm_DetailIsActive = 'N' where ...
|
|
// update mgm_header set Mgm_HeaderIsActive = 'N' where ...
|
|
$have_bmi = false;
|
|
$mcuKelainanID = 0;
|
|
$natTestCode = '';
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "status_gizi_6") {
|
|
// print_r($j);
|
|
// exit;
|
|
$have_bmi = true;
|
|
$std = $j["standart_bmi"];
|
|
$kelainan = $j["value"];
|
|
$natTestCode = $j['title'];
|
|
//dicari Mcu_KelainanID dan Mcu_KelainanMcu_KelainanGroupID di one_etl.mcu_kelainan based on
|
|
//Mcu_KelainanName dan Mcu_KelainanClasification
|
|
// di simpan di Mcu_KelainanID
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 1
|
|
AND Mcu_KelainanName = ? AND Mcu_KelainanClasification = ?";
|
|
$qry = $this->db->query($sql, array($kelainan, $std));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($have_bmi) {
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
//dianggap normal
|
|
//hanya insert di mgm_header
|
|
//NatTestCode == Status Gizi
|
|
//isNormal Y
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
//insert di mgm header
|
|
//NatTestCode == Status Gizi
|
|
//isNormal N
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, "bmi");
|
|
}
|
|
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate bmi berhasil']);
|
|
}
|
|
// $this->db->trans_commit();
|
|
}
|
|
|
|
function generate_blood_presure($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_esc = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "tanda_vital_5") {
|
|
$have_esc = true;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["value_x"];
|
|
$natTestCode = $j['title'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 2
|
|
AND Mcu_KelainanName = ? AND Mcu_KelainanClasification = ?";
|
|
$qry = $this->db->query($sql, array($kelainan, $std));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($have_esc) {
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, "blood presure");
|
|
}
|
|
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate blood presure berhasil']);
|
|
}
|
|
// $this->db->trans_commit();
|
|
}
|
|
|
|
function generate_visus_mata($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_visus_mata = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if (
|
|
$j["id_code"] == "visus_jauh_1" ||
|
|
$j["id_code"] == "visus_jauh_2" ||
|
|
$j["id_code"] == "visus_jauh_3" ||
|
|
$j["id_code"] == "visus_jauh_4"
|
|
) {
|
|
// print_r($j);
|
|
// exit;
|
|
$have_visus_mata = true;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["kesimpulan"];
|
|
$natTestCode = $j['title'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 3
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($have_visus_mata) {
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, "visus mata");
|
|
}
|
|
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate visus jauh berhasil']);
|
|
}
|
|
// $this->db->trans_commit();
|
|
}
|
|
|
|
function generate_persepsi_warna($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_persepsi_warna = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "persepsi_warna_1") {
|
|
// print_r($j);
|
|
// exit;
|
|
$have_persepsi_warna = true;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 4
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($have_persepsi_warna) {
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'warna');
|
|
}
|
|
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate persepsi warna berhasil']);
|
|
}
|
|
// $this->db->trans_commit();
|
|
}
|
|
|
|
function generate_px_gigi($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_px_gigi = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "gigi_atas_ketiga_kanan_8") {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
// $natTestCode = $j['title'];
|
|
|
|
$str = $j["value"];
|
|
|
|
// Mencocokkan pola dengan menggunakan ekspresi reguler
|
|
preg_match_all('/Berlubang|Tambalan|Tanggal|Sisa akar|Gigi Palsu|Karang Gigi|Impaksi/', $str, $matches);
|
|
|
|
// Menyimpan hasil cocok ke dalam array
|
|
$hasil_array = $matches[0];
|
|
|
|
|
|
foreach ($hasil_array as $key => $value) {
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 5
|
|
AND Mcu_KelainanName LIKE ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array("%$value%"));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$natTestCode = '';
|
|
if ($value == 'Berlubang') {
|
|
$natTestCode = 'GIGI BERLUBANG';
|
|
} else if ($value == 'Tambalan') {
|
|
$natTestCode = 'GIGI TAMBALAN';
|
|
} else if ($value == 'Tanggal') {
|
|
$natTestCode = 'GIGI TANGGAL';
|
|
} else if ($value == 'Sisa akar') {
|
|
$natTestCode = 'SISA AKAR';
|
|
} else if ($value == 'Gigi Palsu') {
|
|
$natTestCode = 'GIGI PALSU';
|
|
} else if ($value == 'Karang gigi') {
|
|
$natTestCode = 'KARANG GIGI';
|
|
} else if ($value == 'Impaksi') {
|
|
$natTestCode = 'IMPAKSI';
|
|
} else {
|
|
$natTestCode = 'GIGI';
|
|
}
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
$mcuKelainanID = $row['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $row['Mcu_KelainanMcu_KelainanGroupID'];
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if (count($mcuKelainanID) == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'gigi');
|
|
}
|
|
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate px gigi berhasil']);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
// $this->db->trans_commit();
|
|
}
|
|
|
|
function generate_tht($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_tht = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "mukosa_rongga_mulut_3") {
|
|
// print_r($j);
|
|
// exit;
|
|
$have_tht = true;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 6
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($chx == 1 || $j['is_normal'] == 'Y') {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'tht1');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "hidung_1") {
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($chx == 0) {
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 6
|
|
AND Mcu_KelainanName = 'Hidung'";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'tht2');
|
|
} else {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "telinga_1") {
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($chx == 0) {
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 6
|
|
AND Mcu_KelainanName = 'Telinga'";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'tht3');
|
|
} else {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate tht berhasil']);
|
|
}
|
|
|
|
function generate_jantung($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_jantung = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "jantung_2" && $j['chx'] == 1) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 7
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'jantung');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "jantung_4" && $j['chx'] == 1) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 7
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'jantung2');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "jantung_6" && $j['chx'] == 1) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 7
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'jantung3');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "jantung_8" && $j['chx'] == 1) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 7
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'jantung4');
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate jantung berhasil']);
|
|
}
|
|
|
|
function generate_perut($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_perut = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "perut_1" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 8
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'perut');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "perut_6" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 8
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'perut2');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "perut_8" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 8
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'perut3');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "perut_11" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 8
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'perut4');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "perut_13" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 8
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'perut5');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "perut_17" && $j['chx'] == 1) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 8
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'perut6');
|
|
}
|
|
}
|
|
|
|
if ($j["table_name"] == "perut" && $j["value"] == "Tidak diperiksa") {
|
|
|
|
$natTestCode = $j['title'];
|
|
|
|
$sql_update = "UPDATE one_etl.mgm_header SET
|
|
Mgm_HeaderIsActive = 'N',
|
|
Mgm_HeaderLastUpdated = NOW()
|
|
WHERE Mgm_HeaderMgm_McuID = ? AND
|
|
Mgm_HeaderT_OrderHeaderID = ? AND Mgm_HeaderNat_TestCode = ?";
|
|
$qry_update = $this->db->query($sql_update, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode
|
|
));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry_update) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT T_OrderHeaderM_PatientAge,
|
|
M_SexCode , IFNULL(M_PatientKedudukan, '') M_PatientKedudukan
|
|
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;
|
|
$kedudukan = $row->M_PatientKedudukan;
|
|
|
|
$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,
|
|
Mgm_HeaderM_PatientLocation) VALUES(?,?,?,?,?,'F','Y','Y',NOW(),NOW(), ?)";
|
|
$qry = $this->db->query($sql, array(
|
|
$mgmMcuID,
|
|
$orderHeaderID,
|
|
$natTestCode,
|
|
$patient_age,
|
|
$sex_code,
|
|
$kedudukan
|
|
));
|
|
$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;
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate perut/abdomen berhasil']);
|
|
}
|
|
|
|
function generate_anggota_gerak($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_anggota_gerak = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "anggota_gerak_1" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 9
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'gerak');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "anggota_gerak_8" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 9
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'gerak2');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "anggota_gerak_16" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 9
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'gerak3');
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate anggota gerak berhasil']);
|
|
}
|
|
|
|
function generate_pesyarafan($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_pesyarafan = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "sistem_persyarafan_1" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 10
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'persyarafan');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "sistem_persyarafan_4" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 10
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'persyarafan2ssss');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "sistem_persyarafan_6" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 10
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'Persyarafan3');
|
|
}
|
|
}
|
|
|
|
if ($j["id_code"] == "sistem_persyarafan_8" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 10
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'persyarafan4');
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate pesyarafan berhasil']);
|
|
}
|
|
|
|
function generate_smell_test($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_smell_test = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if ($j["id_code"] == "smell_test_1" && $j['chx'] == 0) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 11
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'smell');
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate smell test berhasil']);
|
|
}
|
|
|
|
function generate_lbp($mgmMcuID, $orderHeaderID, $json)
|
|
{
|
|
// $this->db->trans_begin();
|
|
|
|
$have_lib = false;
|
|
$natTestCode = '';
|
|
$mcuKelainanID = 0;
|
|
$mcuKelainanGroupID = 0;
|
|
foreach ($json as $j) {
|
|
if (
|
|
($j["id_code"] == "low_back_pain_screening_test_2" ||
|
|
$j["id_code"] == "low_back_pain_screening_test_4" ||
|
|
$j["id_code"] == "low_back_pain_screening_test_6" ||
|
|
$j["id_code"] == "low_back_pain_screening_test_8") && $j['chx'] == 1
|
|
) {
|
|
// print_r($j);
|
|
// exit;
|
|
$std = $j["standart"];
|
|
$kelainan = $j["label"];
|
|
$natTestCode = $j['title'];
|
|
$chx = $j['chx'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM one_etl.mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanMcu_KelainanGroupID = 12
|
|
AND Mcu_KelainanName = ?";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql, array($kelainan));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("select mcu_kelainan", $this->db);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows) > 0) {
|
|
$mcuKelainanID = $rows[0]['Mcu_KelainanID'];
|
|
$mcuKelainanGroupID = $rows[0]['Mcu_KelainanMcu_KelainanGroupID'];
|
|
}
|
|
|
|
// update mgm header
|
|
$this->update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
// update mgm detail
|
|
$this->update_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
|
|
if ($mcuKelainanID == 0) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID, 'ibp');
|
|
}
|
|
}
|
|
}
|
|
|
|
// $this->db->trans_commit();
|
|
// $this->reply(["status" => "OK", 'message' => 'Proses generate lbp berhasil']);
|
|
}
|
|
function statusDone($Mgm_McuID, $orderHeaderID)
|
|
{
|
|
$sql = "SELECT
|
|
Mcu_OrderStatusLab,
|
|
Mcu_OrderStatusNonLab,
|
|
Mcu_OrderStatusFisik,
|
|
Mcu_OrderStatusRiwayat,
|
|
Mcu_OrderStatusFitness
|
|
FROM one_etl.mcu_order
|
|
WHERE Mcu_OrderT_OrderHeaderID = ?
|
|
AND Mcu_OrderMgm_McuID = ?";
|
|
$qry = $this->db->query($sql, array(
|
|
$orderHeaderID,
|
|
$Mgm_McuID
|
|
));
|
|
if (!$qry) {
|
|
$this->sys_error_db("Update status done", $this->db);
|
|
exit;
|
|
}
|
|
$cek = $qry->result_array();
|
|
if (count($cek) > 0) {
|
|
$data = $cek[0];
|
|
if (
|
|
$data['Mcu_OrderStatusLab'] == 'Y'
|
|
&& $data['Mcu_OrderStatusNonLab'] == 'Y'
|
|
&& $data['Mcu_OrderStatusFisik'] == 'Y'
|
|
&& $data['Mcu_OrderStatusRiwayat'] == 'Y'
|
|
&& $data['Mcu_OrderStatusFitness'] == 'Y'
|
|
) {
|
|
$sql = "UPDATE one_etl.mcu_order
|
|
SET Mcu_OrderStatus = 'Y',
|
|
Mcu_OrderLastUpdated = NOW()
|
|
WHERE Mcu_OrderT_OrderHeaderID = ?
|
|
AND Mcu_OrderMgm_McuID = ?";
|
|
$qry = $this->db->query($sql, array(
|
|
$orderHeaderID,
|
|
$Mgm_McuID
|
|
));
|
|
if (!$qry) {
|
|
$this->sys_error_db("Update status done", $this->db);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|