1672 lines
53 KiB
PHP
1672 lines
53 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)
|
|
{
|
|
$url = "http://localhost/one-api/etl/mgmmcu_nonlab/json/" . $orderHeaderID;
|
|
$get_content = file_get_contents($url);
|
|
$json = json_decode($get_content, true);
|
|
|
|
$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);
|
|
}
|
|
|
|
function update_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode)
|
|
{
|
|
$sql_update = "UPDATE mgm_header SET
|
|
Mgm_HeaderIsActive = 'N'
|
|
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 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 mgm_detail
|
|
SET Mgm_DetailIsActive = 'N'
|
|
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 = "INSERT INTO mgm_header(
|
|
Mgm_HeaderMgm_McuID,
|
|
Mgm_HeaderT_OrderHeaderID,
|
|
Mgm_HeaderNat_TestCode,
|
|
Mgm_HeaderType,
|
|
Mgm_HeaderIsNormal,
|
|
Mgm_HeaderIsActive,
|
|
Mgm_HeaderCreated,
|
|
Mgm_HeaderLastUpdated) VALUES(?,?,?,'F','Y','Y',NOW(),NOW())";
|
|
$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;
|
|
}
|
|
}
|
|
|
|
function insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID)
|
|
{
|
|
$sql = "INSERT INTO mgm_header(
|
|
Mgm_HeaderMgm_McuID,
|
|
Mgm_HeaderT_OrderHeaderID,
|
|
Mgm_HeaderNat_TestCode,
|
|
Mgm_HeaderType,
|
|
Mgm_HeaderIsNormal,
|
|
Mgm_HeaderIsActive,
|
|
Mgm_HeaderCreated,
|
|
Mgm_HeaderLastUpdated) VALUES(?,?,?,'F','N','Y',NOW(),NOW())";
|
|
$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;
|
|
}
|
|
|
|
$insert_mgm_header_id = $this->db->insert_id();
|
|
|
|
//insert di mgm_detail kelainanid dan kelainangroupid
|
|
$sql_detail = "INSERT INTO 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"],
|
|
"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 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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$this->reply(["status" => "OK", 'message' => 'Proses generate bmi berhasil']);
|
|
} else {
|
|
$this->reply(["status" => "OK", 'message' => 'No bmi']);
|
|
}
|
|
}
|
|
|
|
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"];
|
|
$natTestCode = $j['title'];
|
|
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$this->reply(["status" => "OK", 'message' => 'Proses generate blood presure berhasil']);
|
|
} else {
|
|
$this->reply(["status" => "OK", 'message' => 'No blood presure']);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$this->reply(["status" => "OK", 'message' => 'Proses generate visus jauh berhasil']);
|
|
} else {
|
|
$this->reply(["status" => "OK", 'message' => 'No visus jauh']);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$this->reply(["status" => "OK", 'message' => 'Proses generate persepsi warna berhasil']);
|
|
} else {
|
|
$this->reply(["status" => "OK", 'message' => 'No persepsi warna']);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$this->reply(["status" => "OK", 'message' => 'Proses generate px gigi berhasil']);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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) {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
} else {
|
|
$this->insert_mgm_detail($mgmMcuID, $orderHeaderID, $natTestCode, $mcuKelainanID, $mcuKelainanGroupID);
|
|
}
|
|
}
|
|
|
|
|
|
if ($j["id_code"] == "gigi_2" || $j["id_code"] == "gigi_3" || $j["id_code"] == "gigi_4" || $j["id_code"] == "gigi_5" || || $j["id_code"] == "gigi_6" || || $j["id_code"] == "gigi_7" || || $j["id_code"] == "gigi_8") {
|
|
$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 == 1) {
|
|
$sql = "SELECT Mcu_KelainanID,
|
|
Mcu_KelainanName,
|
|
Mcu_KelainanClasification,
|
|
Mcu_KelainanMcu_KelainanGroupID
|
|
FROM mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
AND Mcu_KelainanName = CONCAT('%',?,'%')";
|
|
// AND Mcu_KelainanClasification = ?
|
|
|
|
$qry = $this->db->query($sql,array($j['label']));
|
|
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);
|
|
} else {
|
|
$this->insert_mgm_header($mgmMcuID, $orderHeaderID, $natTestCode);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
} 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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
} 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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
$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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
if ($j["table_name"] == "perut" && $j["value"] == "Tidak diperiksa") {
|
|
|
|
$natTestCode = $j['title'];
|
|
|
|
$sql_update = "UPDATE mgm_header SET
|
|
Mgm_HeaderIsActive = 'N'
|
|
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 = "INSERT INTO mgm_header(
|
|
Mgm_HeaderMgm_McuID,
|
|
Mgm_HeaderT_OrderHeaderID,
|
|
Mgm_HeaderNat_TestCode,
|
|
Mgm_HeaderType,
|
|
Mgm_HeaderIsNormal,
|
|
Mgm_HeaderIsActive,
|
|
Mgm_HeaderCreated,
|
|
Mgm_HeaderLastUpdated) VALUES(?,?,?,'F','X','Y',NOW(),NOW())";
|
|
$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;
|
|
}
|
|
}
|
|
}
|
|
|
|
$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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
$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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
|
|
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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
$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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
$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 mcu_kelainan
|
|
WHERE Mcu_KelainanIsActive = 'Y'
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
$this->reply(["status" => "OK", 'message' => 'Proses generate lbp berhasil']);
|
|
}
|
|
}
|