3320 lines
151 KiB
PHP
3320 lines
151 KiB
PHP
<?php
|
|
defined("BASEPATH") or exit("No direct script access allowed");
|
|
class Etlfisik
|
|
{
|
|
function __construct()
|
|
{
|
|
$CI = &get_instance();
|
|
$this->db_smartone = $CI->load->database("default", true);
|
|
$this->db_onedev = $CI->load->database("default", true);
|
|
}
|
|
|
|
function clean_mysqli_connection($dbc)
|
|
{
|
|
while (mysqli_more_results($dbc)) {
|
|
if (mysqli_next_result($dbc)) {
|
|
$result = mysqli_use_result($dbc);
|
|
|
|
if (get_class($result) == 'mysqli_stmt') {
|
|
mysqli_stmt_free_result($result);
|
|
} else {
|
|
unset($result);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function generate_kelainan_by_order($orderID,$userID){
|
|
$this->generate_kelainan_nonlab($orderID,$userID);
|
|
$this->generate_kelainan_lab($orderID,$userID);
|
|
//$this->generate_kelainan_lab($orderID,$userID);
|
|
$this->generate_all_fisik($orderID,$userID);
|
|
$sql = "SELECT *
|
|
FROM t_orderheader
|
|
JOIN so_resultentry ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID AND So_ResultEntryNonlab_TemplateID = 27 AND
|
|
So_ResultEntryIsActive = 'Y'
|
|
WHERE
|
|
T_OrderHeaderID = ? AND T_OrderHeaderIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,array($orderID));
|
|
$rst_fisik = $query->result_array();
|
|
$soReID = 0;
|
|
if(count($rst_fisik)> 0){
|
|
$soReID = $rst_fisik[0]['So_ResultEntryID'];
|
|
}
|
|
|
|
$this->generate_summaries($orderID,$soReID,$userID,$debugID=0);
|
|
|
|
$sql = " SELECT 'lab' as type,
|
|
T_KelainanLabID,
|
|
Mcu_KelainanName,
|
|
fn_get_translate_word_separator_comma(Mcu_KelainanName,2) as Mcu_KelainanNameEng,
|
|
Mcu_FitnessCategoryID,
|
|
Mcu_FitnessCategoryName,
|
|
Mcu_FitnessCategoryEng,
|
|
Mcu_FitnessCategoryLevel,
|
|
Nat_TestName
|
|
FROM t_kelainan_lab
|
|
JOIN mcu_summarylab ON T_KelainanLabMcu_SummaryLabID = Mcu_SummaryLabID
|
|
JOIN mcu_kelainan ON Mcu_summaryLabMcu_KelainanID = Mcu_KelainanID
|
|
JOIN mcu_fitness_category ON Mcu_SummaryLabMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
|
JOIN nat_test ON Mcu_SummaryLabNat_TestID = Nat_TestID
|
|
WHERE
|
|
T_KelainanLabT_OrderHeaderID = ? AND
|
|
T_KelainanLabIsActive= 'Y'
|
|
UNION
|
|
SELECT 'nonlab' as type,
|
|
T_KelainanNonLabID,
|
|
Mcu_KelainanName,
|
|
fn_get_translate_word_separator_comma(Mcu_KelainanName,2) as Mcu_KelainanNameEng,
|
|
Mcu_FitnessCategoryID,
|
|
Mcu_FitnessCategoryName,
|
|
Mcu_FitnessCategoryEng,
|
|
Mcu_FitnessCategoryLevel,
|
|
Nat_TestName
|
|
FROM t_kelainan_nonlab
|
|
JOIN mcu_summarynonlab ON T_KelainanNonLabMcu_SummaryNonlabID = Mcu_SummaryNonlabID
|
|
JOIN mcu_kelainan ON Mcu_SummaryNonlabMcu_KelainanID = Mcu_KelainanID
|
|
JOIN mcu_fitness_category ON Mcu_SummaryNonlabMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
|
JOIN nat_test ON Mcu_SummaryNonlabNat_TestID = Nat_TestID
|
|
WHERE
|
|
T_KelainanNonLabT_OrderHeaderID = ? AND
|
|
T_KelainanNonLabIsActive= 'Y'
|
|
UNION
|
|
SELECT 'fisik' as type,
|
|
T_KelainanFiskID,
|
|
Mcu_KelainanName,
|
|
fn_get_translate_word_separator_comma(Mcu_KelainanName,2) as Mcu_KelainanNameEng,
|
|
Mcu_FitnessCategoryID,
|
|
Mcu_FitnessCategoryName,
|
|
Mcu_FitnessCategoryEng,
|
|
Mcu_FitnessCategoryLevel,
|
|
GROUP_CONCAT(CONCAT(Mcu_FisikValueLabel,'|',Mcu_FisikValueSegment,'|',Mcu_FisikValueCategory)) as Nat_TestName
|
|
FROM t_kelainan_fisik
|
|
JOIN mcu_fisiksummary ON T_KelainanFiskMcu_FisikSummaryID = Mcu_FisikSummaryID
|
|
JOIN mcu_kelainan ON Mcu_FisikSummaryMcu_KelainanID = Mcu_KelainanID
|
|
JOIN mcu_fitness_category ON Mcu_FisikSummaryMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
|
JOIN mcu_fisiksummarydetail ON Mcu_FisikSummaryDetailMcu_FisikSummaryID = Mcu_FisikSummaryID AND
|
|
Mcu_FisikSummaryDetailIsActive = 'Y'
|
|
JOIN mcu_fisikvalue ON Mcu_FisikValueT_OrderHeaderID = T_KelainanFiskT_OrderHeaderID AND
|
|
Mcu_FisikSummaryDetailCode = Mcu_FisikValueCode AND Mcu_FisikValueIsActive = 'Y'
|
|
WHERE
|
|
T_KelainanFiskT_OrderHeaderID = ? AND
|
|
T_KelainanFiskIsActive = 'Y'
|
|
GROUP BY T_KelainanFiskID";
|
|
$query = $this->db_onedev->query($sql,array($orderID,$orderID,$orderID));
|
|
//echo $this->db_onedev->last_query();
|
|
$rtn = $query->result_array();
|
|
$status = array("id"=>"1","name" => "BAIK", "name_eng" => "FIT FOR WORK" ,"level" => "1");
|
|
if(count($rtn) > 0){
|
|
$max = 0;
|
|
foreach ($rtn as $key => $value) {
|
|
if(intval($value['Mcu_FitnessCategoryLevel']) > $max){
|
|
$max = intval($value['Mcu_FitnessCategoryLevel']);
|
|
$status = array("id"=> $value['Mcu_FitnessCategoryID'],"name" => $value['Mcu_FitnessCategoryName'], "name_eng" => $value['Mcu_FitnessCategoryEng'] ,"level" => $value['Mcu_FitnessCategoryLevel']);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
$resposne = array("status" => $status,"data" => $rtn);
|
|
|
|
return $resposne;
|
|
}
|
|
|
|
function generate_kelainan_nonlab($orderID,$userID){
|
|
$sql = "SELECT So_ResultEntryID, T_OrderHeaderID, T_TestNat_TestID, Mcu_SummaryNonlabID, Mcu_SummaryNonlabMcu_KelainanID, Mcu_SummaryNonlabID
|
|
FROM so_resultentry_category_result
|
|
JOIN so_resultentry ON So_ResultEntryCategoryResultSo_ResultEntryID = So_ResultEntryID AND
|
|
So_ResultEntryStatus <> 'NEW' AND So_ResultEntryIsActive = 'Y'
|
|
JOIN t_orderheader ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderIsActive = 'Y' AND
|
|
T_OrderHeaderID = ?
|
|
JOIN t_orderdetail ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND T_OrderDetailIsActive = 'Y'
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN mcu_summarynonlab ON Mcu_SummaryNonlabNat_TestID = T_TestNat_TestID AND
|
|
Mcu_SummaryNonlabIsActive = 'Y' AND So_ResultEntryCategoryNonlabConclusionDetailID IN (Mcu_SummaryNonlabConclusionDetailIDs)
|
|
WHERE
|
|
So_ResultEntryCategoryResultIsActive = 'Y'";
|
|
|
|
$qry = $this->db_onedev->query($sql,array($orderID));
|
|
if (!$qry) {
|
|
echo $this->db_onedev->last_query();
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error get order | " . $this->db_onedev->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
$sql = "UPDATE t_kelainan_nonlab SET
|
|
T_KelainanNonLabIsActive = 'N'
|
|
WHERE
|
|
T_KelainanNonLabT_OrderHeaderID = ? AND
|
|
T_KelainanNonLabIsActive = 'Y'
|
|
";
|
|
$qry = $this->db_onedev->query($sql,array($orderID));
|
|
|
|
foreach ($rows as $key => $value) {
|
|
|
|
|
|
$sql = "INSERT INTO t_kelainan_nonlab (
|
|
T_KelainanNonLabSo_ResultEntryID,
|
|
T_KelainanNonLabT_OrderHeaderID,
|
|
T_KelainanNonLabNat_TestID,
|
|
T_KelainanNonLabMcu_SummaryNonlabID,
|
|
T_KelainanNonLabCreatedUserID,
|
|
T_KelainanLabNonCreated
|
|
) VALUES(?,?,?,?,?,NOW())";
|
|
$qry = $this->db_onedev->query($sql,[
|
|
$value['So_ResultEntryID'],
|
|
$value['T_OrderHeaderID'],
|
|
$value['T_TestNat_TestID'],
|
|
$value['Mcu_SummaryNonlabID'],
|
|
$userID
|
|
]);
|
|
}
|
|
|
|
}
|
|
|
|
function generate_kelainan_lab($orderid)
|
|
{
|
|
$sql = "SELECT
|
|
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
|
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
|
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
|
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
|
T_OrderDetailMaxValueInclusive,
|
|
T_OrderDetailNormalValueNote,
|
|
Mcu_SummaryLabID,
|
|
Mcu_SummaryLabValue,
|
|
Mcu_SummaryLabNat_MethodeID,
|
|
Mcu_SummaryLabWithMethode,
|
|
Mcu_SummaryLabType,
|
|
Mcu_SummaryLabIsNormalValue,
|
|
Mcu_SummaryLabIsRange,
|
|
Mcu_SummaryLabMinInclusive,
|
|
Mcu_SummaryLabMinValue,
|
|
Mcu_SummaryLabMaxInclusive,
|
|
Mcu_SummaryLabMaxValue,
|
|
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
|
Nat_TestID,
|
|
Nat_TestCode,
|
|
mcu_kelainangroup.*
|
|
from t_orderdetail
|
|
join t_orderheader on T_OrderHeaderID = {$orderid}
|
|
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
and T_OrderDetailIsActive = 'Y'
|
|
JOIN m_patient
|
|
ON T_OrderHeaderM_PatientID = M_PatientID
|
|
join t_test
|
|
on T_OrderDetailT_TestID = T_TestID
|
|
join nat_test ON T_TestNat_TestID = Nat_TestID
|
|
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
|
AND (Mcu_SummaryLabGender = 'A' OR (Mcu_SummaryLabGender <> 'A' AND Mcu_SummaryLabGender = CASE
|
|
WHEN LOWER(M_PatientGender) = 'male' THEN 'M'
|
|
WHEN LOWER(M_PatientGender) = 'female' THEN 'F'
|
|
else ''
|
|
END))
|
|
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
|
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
|
//echo $sql;
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
echo $this->db_onedev->last_query();
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error get order | " . $this->db_onedev->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
$results = [];
|
|
|
|
|
|
|
|
foreach ($rows as $r) {
|
|
$result_value = $r['T_OrderDetailResult'];
|
|
|
|
$value_comparison = 0;
|
|
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
|
$kelainan = [];
|
|
$notavailable = [];
|
|
if (trim($result_value) == 'NA') {
|
|
$notavailable = $r;
|
|
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
|
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
|
$value_comparison = $r['T_OrderDetailMinValue'];
|
|
}
|
|
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
|
$value_comparison = $r['T_OrderDetailMaxValue'];
|
|
}
|
|
if ($r['Mcu_SummaryLabType'] == '!=') {
|
|
$result_value = strtolower(trim($result_value));
|
|
$value_comparison = strtolower(trim($r['T_OrderDetailNormalValueNote']));
|
|
}
|
|
|
|
|
|
|
|
//echo "Y";
|
|
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else if ($r['Mcu_SummaryLabIsRange'] == 'Y') {
|
|
// Mcu_SummaryLabIsNormalValue,
|
|
// Mcu_SummaryLabIsRange,
|
|
// Mcu_SummaryLabMinInclusive,
|
|
// Mcu_SummaryLabMinValue,
|
|
// Mcu_SummaryLabMaxInclusive,
|
|
// Mcu_SummaryLabMaxValue,
|
|
$isWithinMin = $r['Mcu_SummaryLabMinInclusive'] === 'Y' ? floatval($result_value) >= floatval($r['Mcu_SummaryLabMinValue']) : floatval($result_value) > floatval($r['Mcu_SummaryLabMinValue']);
|
|
$isWithinMax = $r['Mcu_SummaryLabMaxInclusive'] === 'Y' ? floatval($result_value) <= floatval($r['Mcu_SummaryLabMaxValue']) : floatval($result_value) < floatval($r['Mcu_SummaryLabMaxValue']);
|
|
|
|
if ($isWithinMax && $isWithinMin) {
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
$value_comparison = $r['Mcu_SummaryLabValue'];
|
|
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
|
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($results) > 0) {
|
|
$sql = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabIsActive = 'N'
|
|
WHERE
|
|
T_KelainanLabT_OrderHeaderID = {$orderid}";
|
|
$this->db_onedev->query($sql);
|
|
|
|
foreach ($results as $v_result) {
|
|
$sql_kel_lab = "SELECT *
|
|
FROM t_kelainan_lab
|
|
WHERE T_KelainanLabT_OrderDetailID = ?
|
|
GROUP BY T_KelainanLabT_OrderDetailID";
|
|
$qry_kel_lab = $this->db_onedev->query($sql_kel_lab, array($v_result['orderdetailID']));
|
|
if ($qry_kel_lab) {
|
|
$rows_kel = $qry_kel_lab->result_array();
|
|
} else {
|
|
$this->sys_error_db("select kelainan lab", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows_kel) > 0) {
|
|
|
|
// print_r($v_result['orderdetailID']);
|
|
// exit;
|
|
|
|
$sql_update_kel = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabT_OrderDetailID = {$v_result['orderdetailID']},
|
|
T_KelainanLabT_OrderHeaderID = {$v_result['orderheaderID']},
|
|
T_KelainanLabNat_TestID = {$v_result['nat_testID']},
|
|
T_KelainanLabMcu_SummaryLabID = {$v_result['mcu_summarylabID']},
|
|
T_KelainanLabCreatedUserID = 1,
|
|
T_KelainanLabIsActive = 'Y',
|
|
T_KelainanLabCreated = NOW()
|
|
WHERE T_KelainanLabID = {$rows_kel[0]['T_KelainanLabID']}";
|
|
$qry_update_kel = $this->db_onedev->query($sql_update_kel);
|
|
if (!$qry_update_kel) {
|
|
echo $this->db_onedev->last_query();
|
|
//$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db('error', 'Error update lab: ' . $this->db_onedev);
|
|
exit;
|
|
}
|
|
} else {
|
|
// print_r('insert');
|
|
// exit;
|
|
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
|
T_KelainanLabT_OrderDetailID,
|
|
T_KelainanLabT_OrderHeaderID,
|
|
T_KelainanLabNat_TestID,
|
|
T_KelainanLabMcu_SummaryLabID,
|
|
T_KelainanLabCreatedUserID,
|
|
T_KelainanLabCreated)
|
|
VALUES(
|
|
'{$v_result['orderdetailID']}',
|
|
'{$v_result['orderheaderID']}',
|
|
'{$v_result['nat_testID']}',
|
|
'{$v_result['mcu_summarylabID']}',
|
|
1,
|
|
NOW())";
|
|
$qry_insert_lab = $this->db_onedev->query($sql_insert_lab);
|
|
|
|
if (!$qry_insert_lab) {
|
|
//$this->db_onedev->trans_rollback();
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function generate_kelainan_lab_x($orderid)
|
|
{
|
|
$sql = "SELECT
|
|
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
|
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
|
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
|
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
|
T_OrderDetailMaxValueInclusive,
|
|
Mcu_SummaryLabID,
|
|
Mcu_SummaryLabValue,
|
|
Mcu_SummaryLabNat_MethodeID,
|
|
Mcu_SummaryLabWithMethode,
|
|
Mcu_SummaryLabType,
|
|
Mcu_SummaryLabIsNormalValue,
|
|
Mcu_SummaryLabIsRange,
|
|
Mcu_SummaryLabMinInclusive,
|
|
Mcu_SummaryLabMinValue,
|
|
Mcu_SummaryLabMaxInclusive,
|
|
Mcu_SummaryLabMaxValue,
|
|
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
|
Nat_TestID,
|
|
Nat_TestCode,
|
|
mcu_kelainangroup.*
|
|
from t_orderdetail
|
|
join t_orderheader on T_OrderHeaderID = {$orderid}
|
|
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
and T_OrderDetailIsActive = 'Y'
|
|
JOIN m_patient
|
|
ON T_OrderHeaderM_PatientID = M_PatientID
|
|
join t_test
|
|
on T_OrderDetailT_TestID = T_TestID
|
|
join nat_test ON T_TestNat_TestID = Nat_TestID
|
|
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
|
AND (Mcu_SummaryLabGender = 'A' OR (Mcu_SummaryLabGender <> 'A' AND Mcu_SummaryLabGender = CASE
|
|
WHEN LOWER(M_PatientGender) = 'male' THEN 'M'
|
|
WHEN LOWER(M_PatientGender) = 'female' THEN 'F'
|
|
else ''
|
|
END))
|
|
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
|
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
|
//echo $sql;
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
echo $this->db_onedev->last_query();
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error get order | " . $this->db_onedev->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
$results = [];
|
|
|
|
|
|
|
|
foreach ($rows as $r) {
|
|
$result_value = $r['T_OrderDetailResult'];
|
|
|
|
$value_comparison = 0;
|
|
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
|
$kelainan = [];
|
|
$notavailable = [];
|
|
if (trim($result_value) == 'NA') {
|
|
$notavailable = $r;
|
|
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
|
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
|
$value_comparison = $r['T_OrderDetailMinValue'];
|
|
}
|
|
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
|
$value_comparison = $r['T_OrderDetailMaxValue'];
|
|
}
|
|
//echo "Y";
|
|
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else if ($r['Mcu_SummaryLabIsRange'] == 'Y') {
|
|
// Mcu_SummaryLabIsNormalValue,
|
|
// Mcu_SummaryLabIsRange,
|
|
// Mcu_SummaryLabMinInclusive,
|
|
// Mcu_SummaryLabMinValue,
|
|
// Mcu_SummaryLabMaxInclusive,
|
|
// Mcu_SummaryLabMaxValue,
|
|
$isWithinMin = $r['Mcu_SummaryLabMinInclusive'] === 'Y' ? floatval($result_value) >= floatval($r['Mcu_SummaryLabMinValue']) : floatval($result_value) > floatval($r['Mcu_SummaryLabMinValue']);
|
|
$isWithinMax = $r['Mcu_SummaryLabMaxInclusive'] === 'Y' ? floatval($result_value) <= floatval($r['Mcu_SummaryLabMaxValue']) : floatval($result_value) < floatval($r['Mcu_SummaryLabMaxValue']);
|
|
|
|
if ($isWithinMax && $isWithinMin) {
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
$value_comparison = $r['Mcu_SummaryLabValue'];
|
|
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
|
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($results) > 0) {
|
|
$sql = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabIsActive = 'N'
|
|
WHERE
|
|
T_KelainanLabT_OrderHeaderID = {$orderid}";
|
|
$this->db_onedev->query($sql);
|
|
|
|
foreach ($results as $v_result) {
|
|
$sql_kel_lab = "SELECT *
|
|
FROM t_kelainan_lab
|
|
WHERE T_KelainanLabT_OrderDetailID = ?
|
|
GROUP BY T_KelainanLabT_OrderDetailID";
|
|
$qry_kel_lab = $this->db_onedev->query($sql_kel_lab, array($v_result['orderdetailID']));
|
|
if ($qry_kel_lab) {
|
|
$rows_kel = $qry_kel_lab->result_array();
|
|
} else {
|
|
$this->sys_error_db("select kelainan lab", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows_kel) > 0) {
|
|
|
|
// print_r($v_result['orderdetailID']);
|
|
// exit;
|
|
|
|
$sql_update_kel = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabT_OrderDetailID = {$v_result['orderdetailID']},
|
|
T_KelainanLabT_OrderHeaderID = {$v_result['orderheaderID']},
|
|
T_KelainanLabNat_TestID = {$v_result['nat_testID']},
|
|
T_KelainanLabMcu_SummaryLabID = {$v_result['mcu_summarylabID']},
|
|
T_KelainanLabCreatedUserID = 1,
|
|
T_KelainanLabIsActive = 'Y',
|
|
T_KelainanLabCreated = NOW()
|
|
WHERE T_KelainanLabID = {$rows_kel[0]['T_KelainanLabID']}";
|
|
$qry_update_kel = $this->db_onedev->query($sql_update_kel);
|
|
if (!$qry_update_kel) {
|
|
echo $this->db_onedev->last_query();
|
|
//$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db('error', 'Error update lab: ' . $this->db_onedev);
|
|
exit;
|
|
}
|
|
} else {
|
|
// print_r('insert');
|
|
// exit;
|
|
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
|
T_KelainanLabT_OrderDetailID,
|
|
T_KelainanLabT_OrderHeaderID,
|
|
T_KelainanLabNat_TestID,
|
|
T_KelainanLabMcu_SummaryLabID,
|
|
T_KelainanLabCreatedUserID,
|
|
T_KelainanLabCreated)
|
|
VALUES(
|
|
'{$v_result['orderdetailID']}',
|
|
'{$v_result['orderheaderID']}',
|
|
'{$v_result['nat_testID']}',
|
|
'{$v_result['mcu_summarylabID']}',
|
|
1,
|
|
NOW())";
|
|
$qry_insert_lab = $this->db_onedev->query($sql_insert_lab);
|
|
|
|
if (!$qry_insert_lab) {
|
|
//$this->db_onedev->trans_rollback();
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function dynamic_comparison($varleft, $op, $varright)
|
|
{
|
|
|
|
switch ($op) {
|
|
case "=":
|
|
return $varleft == $varright;
|
|
case "!=":
|
|
return $varleft != $varright;
|
|
case ">=":
|
|
return $varleft >= $varright;
|
|
case "<=":
|
|
return $varleft <= $varright;
|
|
case ">":
|
|
return $varleft > $varright;
|
|
case "<":
|
|
return $varleft < $varright;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function generate_kelainan_lab_old($orderid)
|
|
{
|
|
$sql = "select
|
|
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
|
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
|
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
|
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
|
T_OrderDetailMaxValueInclusive,
|
|
Mcu_SummaryLabID,
|
|
Mcu_SummaryLabValue,
|
|
Mcu_SummaryLabNat_MethodeID,
|
|
Mcu_SummaryLabWithMethode,
|
|
Mcu_SummaryLabType,
|
|
Mcu_SummaryLabIsNormalValue,
|
|
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
|
Nat_TestID,
|
|
Nat_TestCode,
|
|
mcu_kelainangroup.*
|
|
from t_orderdetail
|
|
join t_orderheader on T_OrderHeaderID = {$orderid}
|
|
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
and T_OrderDetailIsActive = 'Y'
|
|
join t_test
|
|
on T_OrderDetailT_TestID = T_TestID
|
|
join nat_test ON T_TestNat_TestID = Nat_TestID
|
|
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
|
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
|
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
|
//echo $sql;
|
|
$qry = $this->db_onedev->query($sql);
|
|
if (!$qry) {
|
|
echo $this->db_onedev->last_query();
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Error get order | " . $this->db_onedev->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
$results = [];
|
|
|
|
|
|
|
|
foreach ($rows as $r) {
|
|
$result_value = $r['T_OrderDetailResult'];
|
|
|
|
$value_comparison = 0;
|
|
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
|
$kelainan = [];
|
|
$notavailable = [];
|
|
if (trim($result_value) == 'NA') {
|
|
$notavailable = $r;
|
|
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
|
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
|
$value_comparison = $r['T_OrderDetailMinValue'];
|
|
}
|
|
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
|
$value_comparison = $r['T_OrderDetailMaxValue'];
|
|
}
|
|
//echo "Y";
|
|
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
$value_comparison = $r['Mcu_SummaryLabValue'];
|
|
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
|
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
} else {
|
|
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
|
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
|
$kelainan = $r;
|
|
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($results) > 0) {
|
|
$sql = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabIsActive = 'N'
|
|
WHERE
|
|
T_KelainanLabT_OrderHeaderID = {$orderid}";
|
|
$this->db_onedev->query($sql);
|
|
|
|
foreach ($results as $v_result) {
|
|
$sql_kel_lab = "SELECT *
|
|
FROM t_kelainan_lab
|
|
WHERE T_KelainanLabT_OrderDetailID = ?
|
|
GROUP BY T_KelainanLabT_OrderDetailID";
|
|
$qry_kel_lab = $this->db_onedev->query($sql_kel_lab, array($v_result['orderdetailID']));
|
|
if ($qry_kel_lab) {
|
|
$rows_kel = $qry_kel_lab->result_array();
|
|
} else {
|
|
$this->sys_error_db("select kelainan lab", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
if (count($rows_kel) > 0) {
|
|
|
|
$sql_update_kel = "UPDATE t_kelainan_lab
|
|
SET T_KelainanLabT_OrderDetailID = {$v_result['orderdetailID']},
|
|
T_KelainanLabT_OrderHeaderID = {$v_result['orderheaderID']},
|
|
T_KelainanLabNat_TestID = {$v_result['nat_testID']},
|
|
T_KelainanLabMcu_SummaryLabID = {$v_result['mcu_summarylabID']},
|
|
T_KelainanLabCreatedUserID = 1,
|
|
T_KelainanLabIsActive = 'Y',
|
|
T_KelainanLabCreated = NOW()
|
|
WHERE T_KelainanLabID = {$rows_kel[0]['T_KelainanLabID']}";
|
|
$qry_update_kel = $this->db_onedev->query($sql_update_kel);
|
|
if (!$qry_update_kel) {
|
|
echo $this->db_onedev->last_query();
|
|
//$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db('error', 'Error update lab: ' . $this->db_onedev);
|
|
exit;
|
|
}
|
|
} else {
|
|
// print_r('insert');
|
|
// exit;
|
|
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
|
T_KelainanLabT_OrderDetailID,
|
|
T_KelainanLabT_OrderHeaderID,
|
|
T_KelainanLabNat_TestID,
|
|
T_KelainanLabMcu_SummaryLabID,
|
|
T_KelainanLabCreatedUserID,
|
|
T_KelainanLabCreated)
|
|
VALUES(
|
|
'{$v_result['orderdetailID']}',
|
|
'{$v_result['orderheaderID']}',
|
|
'{$v_result['nat_testID']}',
|
|
'{$v_result['mcu_summarylabID']}',
|
|
1,
|
|
NOW())";
|
|
$qry_insert_lab = $this->db_onedev->query($sql_insert_lab);
|
|
|
|
if (!$qry_insert_lab) {
|
|
//$this->db_onedev->trans_rollback();
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function insert_data_etl($data,$userid){
|
|
if($data){
|
|
|
|
/*$sql = "UPDATE mcu_fisikvalue SET
|
|
Mcu_FisikValueIsActive = 'N',
|
|
Mcu_FisikValueLastUpdated = NOW() ,
|
|
Mcu_FisikValueLastUpdatedUserID = ?
|
|
WHERE
|
|
Mcu_FisikValueT_OrderHeaderID = ? AND
|
|
Mcu_FisikValueCode = ? AND
|
|
Mcu_FisikValueIsActive = 'Y'";
|
|
$qry = $this->db_smartone->query($sql,array($userid,$data['order_id'],$data['code']));
|
|
if (! $qry) {
|
|
return false;
|
|
}*/
|
|
|
|
$sql = "SELECT COUNT(*) as xcount, Mcu_FisikValueID as id
|
|
FROM mcu_fisikvalue
|
|
WHERE
|
|
Mcu_FisikValueT_OrderHeaderID = ? AND
|
|
Mcu_FisikValueCode = ?
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql,array($data['order_id'],$data['code']));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
|
|
//echo $this->db_smartone->last_query();
|
|
//print_r($data);
|
|
//echo $data['code'];
|
|
/*if($data['code'] == 'bmi_classification_asia_pacific'){
|
|
echo $this->db_smartone->last_query();
|
|
}*/
|
|
|
|
$exist_dt = $qry->row_array();
|
|
/*if($data['code'] == 'bmi_classification_asia_pacific'){
|
|
print_r($exist_dt);
|
|
}*/
|
|
|
|
if($exist_dt['xcount'] > 0){
|
|
$sql = "UPDATE mcu_fisikvalue SET
|
|
Mcu_FisikValueIsActive = 'Y',
|
|
Mcu_FisikValueLastUpdated = NOW() ,
|
|
Mcu_FisikValueLastUpdatedUserID = ?,
|
|
Mcu_FisikValueLabel = ?,
|
|
Mcu_FisikValueNote = ?,
|
|
Mcu_FisikValueSegment = ?,
|
|
Mcu_FisikValueCategory = ?
|
|
WHERE
|
|
Mcu_FisikValueID = ?
|
|
";
|
|
$qry = $this->db_smartone->query($sql,array($userid,$data['label'],$data['note'],$data['segment'],$data['category'],$exist_dt['id']));
|
|
}else{
|
|
$sql = "INSERT INTO mcu_fisikvalue (
|
|
`Mcu_FisikValueT_OrderHeaderID`,
|
|
`Mcu_FisikValueCode`,
|
|
`Mcu_FisikValueLabel`,
|
|
`Mcu_FisikValueNote`,
|
|
`Mcu_FisikValueSegment`,
|
|
`Mcu_FisikValueCategory`,
|
|
`Mcu_FisikValueCreated`,
|
|
`Mcu_FisikValueCreatedUserID`
|
|
) VALUES(?,?,?,?,?,?,NOW(),?)";
|
|
$qry = $this->db_smartone->query($sql,array(
|
|
$data['order_id'],
|
|
$data['code'],
|
|
$data['label'],
|
|
$data['note'],
|
|
$data['segment'],
|
|
$data['category'],
|
|
$userid
|
|
));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function generate_all_fisik($orderID,$userid){
|
|
$this->status_gizi($orderID,$userid);
|
|
$this->persepsi_warna($orderID,$userid);
|
|
$this->visus($orderID,$userid);
|
|
|
|
$sql = "SELECT *
|
|
FROM so_resultentry
|
|
WHERE
|
|
So_ResultEntryNonlab_TemplateID = 27 AND
|
|
So_ResultEntryT_OrderHeaderID = ? AND
|
|
So_ResultEntryIsActive = 'Y'
|
|
LIMIT 1";
|
|
$qry = $this->db_smartone->query($sql,array($orderID));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
//echo $this->db_smartone->last_query();
|
|
$results = $qry->result_array();
|
|
if(count($results) > 0){
|
|
$soReID = $results[0]['So_ResultEntryID'];
|
|
|
|
$this->keluhan($soReID,$userid);
|
|
$this->riwayat_penyakit($soReID,$userid);
|
|
$this->penyakit_keluarga($soReID,$userid);
|
|
$this->kebiasaan_hidup($soReID,$userid);
|
|
$this->fisik_konsumsiobatteratur($soReID,$userid);
|
|
$this->imunasi($soReID,$userid);
|
|
$this->vital_sign($soReID,$userid);
|
|
$this->keadaan_umum($soReID,$userid);
|
|
$this->kepala_wajah($soReID,$userid);
|
|
$this->mata($soReID,$userid);
|
|
$this->lapang_pandang($soReID,$userid);
|
|
$this->telinga($soReID,$userid);
|
|
$this->hidung($soReID,$userid);
|
|
$this->gigi($soReID,$userid);
|
|
$this->mulut($soReID,$userid);
|
|
$this->leher($soReID,$userid);
|
|
$this->thorax($soReID,$userid);
|
|
$this->paru($soReID,$userid);
|
|
$this->jantung($soReID,$userid);
|
|
$this->perut($soReID,$userid);
|
|
$this->sistem_integumen($soReID,$userid);
|
|
$this->genitourinaria($soReID,$userid);
|
|
$this->anggota_gerak($soReID,$userid);
|
|
$this->sistem_persyarafan($soReID,$userid);
|
|
$this->smell_test($soReID,$userid);
|
|
$this->low_back_pain_screening_test($soReID,$userid);
|
|
$this->loop_k3($soReID,$userid);
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
function visus($orderID,$userid) {
|
|
$ret_array = [];
|
|
|
|
$sql = " SELECT * , T_SamplingAdditionalFisikVisusID as visus_id
|
|
FROM t_samplingso_additional_fisik_visus
|
|
WHERE
|
|
T_SamplingAdditionalFisikVisusT_OrderHeaderID = ? AND
|
|
T_SamplingAdditionalFisikVisusIsActive = 'Y'
|
|
LIMIT 1";
|
|
$qry = $this->db_smartone->query($sql,array($orderID));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
|
|
$row_result = $qry->row_array();
|
|
//echo $this->db_smartone->last_query();
|
|
|
|
|
|
if($row_result && intval($row_result['visus_id']) > 0){
|
|
|
|
|
|
|
|
$visus = array();
|
|
$visus_kiri = "";
|
|
$visus_kanan = "";
|
|
$visus_kesimpulan = "";
|
|
$normal = array("20/20", "20/25","6/6","6/7.5","6/7,5");
|
|
$miopia_od = false;
|
|
$miopia_os = false;
|
|
$miopia_od_value = '';
|
|
$miopia_os_value = '';
|
|
$astigmatismus_od = false;
|
|
$astigmatismus_os = false;
|
|
$astigmatismus_od_value = '';
|
|
$astigmatismus_os_value = '';
|
|
$presbiopia_ods = false;
|
|
$presbiopia_ods_value = '';
|
|
$x_od = false;
|
|
$x_os = false;
|
|
$x_od_value = "";
|
|
$x_os_value = "";
|
|
$od_visus = "20/20";
|
|
$os_visus = "20/20";
|
|
if($row_result['T_SamplingAdditionalFisikVisusTKODV'] == '6/7,5' || $row_result['T_SamplingAdditionalFisikVisusTKODV'] == '6/6' || $row_result['T_SamplingAdditionalFisikVisusTKODV'] == '6/7.5')
|
|
$od_visus = $row_result['T_SamplingAdditionalFisikVisusTKODV'] ;
|
|
|
|
if($row_result['T_SamplingAdditionalFisikVisusTKOSV'] == '6/7,5' || $row_result['T_SamplingAdditionalFisikVisusTKOSV'] == '6/6' || $row_result['T_SamplingAdditionalFisikVisusTKOSV'] == '6/7.5')
|
|
$os_visus = $row_result['T_SamplingAdditionalFisikVisusTKOSV'] ;
|
|
|
|
|
|
|
|
if((strtolower($row_result['T_SamplingAdditionalFisikVisusTKODV']) != "normal" && $row_result['T_SamplingAdditionalFisikVisusTKODV'] != "" && $row_result['T_SamplingAdditionalFisikVisusTKODV'] != "-") && ($row_result['T_SamplingAdditionalFisikVisusTKOSV'] != "" && $row_result['T_SamplingAdditionalFisikVisusTKOSV'] != "-" && strtolower($row_result['T_SamplingAdditionalFisikVisusTKODV']) != "normal" && strtolower($row_result['T_SamplingAdditionalFisikVisusTKOSV']) != "normal")){
|
|
$visus[] = array(
|
|
"xx1" => "Tanpa Kacamata",
|
|
"xx2" => "OD : ",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusTKODV']
|
|
);
|
|
|
|
$visus[] = array(
|
|
"xx1" => "Tanpa Kacamata",
|
|
"xx2" => "OS",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusTKOSV']
|
|
);
|
|
|
|
|
|
$rst['kelainan'] = "Kelainan refraksi (tanpa kacamata)";
|
|
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKODV'], $normal)){
|
|
$value_koreksi_od = "";
|
|
$od_sph = $row_result['T_SamplingAdditionalFisikVisusODSPH'];
|
|
if($od_sph != "" && $od_sph != "-" && $od_sph != "--" && $od_sph != "/-" && $od_sph != "/" && $od_sph != "-/" && strtolower(trim($od_sph)) != 'plano'){
|
|
if ($visus_kanan != "") $visus_kanan .= ", ";
|
|
$visus_kanan .= $od_sph." (Miopia)";
|
|
|
|
$miopia_od = true;
|
|
$miopia_od_value = $od_sph;
|
|
}
|
|
|
|
|
|
$od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL'];
|
|
|
|
//$od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL'];
|
|
if($od_cyl != "" && $od_cyl != "-" && $od_cyl != "--" && $od_cyl != "/-" && $od_cyl != "/" && $od_cyl != "-/"){
|
|
if ($visus_kanan != "") $visus_kanan .= ", ";
|
|
$visus_kanan .= "Cyl ".$od_cyl;
|
|
|
|
$astigmatismus_od = true;
|
|
$astigmatismus_od_value = $od_cyl;
|
|
}
|
|
|
|
|
|
$od_x = $row_result['T_SamplingAdditionalFisikVisusODX'];
|
|
//echo $od_x;
|
|
if($od_x != "" && $od_x != "-" && $od_x != "--" && $od_x != "/-" && $od_x != "/" && $od_x != "-/"){
|
|
$visus_kanan .= " axis ".$od_x." (Astigmatismus)";
|
|
$x_od = true;
|
|
$x_od = $od_x;
|
|
}else{
|
|
if($od_cyl != "" && $od_cyl != "-" && $od_cyl != "--" && $od_cyl != "/-" && $od_cyl != "/" && $od_cyl != "-/")
|
|
$visus_kanan .= " (Astigmatismus)";
|
|
}
|
|
//$value_koreksi_od .= "X (".$od_x.") ";
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKOSV'], $normal)){
|
|
$value_koreksi_os = "";
|
|
$os_sph = $row_result['T_SamplingAdditionalFisikVisusOSSPH'];
|
|
if(strtolower(trim($os_sph)) != "tidak terkoreksi" && strtolower(trim($os_sph)) != "tidak dapat dinilai" && $os_sph != "" && $os_sph != "-" && $os_sph != "--" && $os_sph != "/-" && $os_sph != "/" && $os_sph != "-/" && strtolower(trim($os_sph)) != 'plano'){
|
|
if ($visus_kiri != "") $visus_kiri .= ", ";
|
|
$visus_kiri .= $os_sph." (Miopia)";
|
|
|
|
$miopia_os = true;
|
|
$miopia_os_value = $os_sph;
|
|
}
|
|
|
|
$os_cyl = $row_result['T_SamplingAdditionalFisikVisusOSCYL'];
|
|
|
|
if(strtolower(trim($os_cyl)) != "tidak terkoreksi" && strtolower(trim($os_cyl)) != "tidak dapat dinilai" && $os_cyl != "" && $os_cyl != "-" && $os_cyl != "--" && $os_cyl != "/-" && $os_cyl != "/" && $os_cyl != "-/"){
|
|
if ($visus_kiri != "") $visus_kiri .= ", ";
|
|
$visus_kiri .= "Cyl ".$os_cyl;
|
|
|
|
$astigmatismus_os = true;
|
|
$astigmatismus_os_value = $os_cyl;
|
|
}
|
|
|
|
|
|
$os_x = $row_result['T_SamplingAdditionalFisikVisusOSX'];
|
|
|
|
if(strtolower(trim($os_x)) != "tidak terkoreksi" && strtolower(trim($os_x)) != "tidak dapat dinilai" && $os_x != "" && $os_x != "-" && $os_x != "--" && $os_x != "/-" && $os_x != "/" && $os_x != "-/"){
|
|
//if ($visus_kiri != "") $visus_kiri .= ", ";
|
|
$visus_kiri .= " axis ".$os_x." (Astigmatismus)";
|
|
$x_os = true;
|
|
$x_os = $os_x;
|
|
}else{
|
|
if($os_cyl != "" && $os_cyl != "-")
|
|
$visus_kiri .= " (Astigmatismus)";
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if((strtolower($row_result['T_SamplingAdditionalFisikVisusDKODV']) != "normal" && $row_result['T_SamplingAdditionalFisikVisusDKODV'] != "" && $row_result['T_SamplingAdditionalFisikVisusDKODV'] != "-") && ($row_result['T_SamplingAdditionalFisikVisusDKOSV'] != "" && $row_result['T_SamplingAdditionalFisikVisusDKOSV'] != "-" && strtolower($row_result['T_SamplingAdditionalFisikVisusDKODV']) != "normal" && strtolower($row_result['T_SamplingAdditionalFisikVisusDKOSV']) != "normal")){
|
|
$visus[] = array(
|
|
"xx1" => "Dengan Kacamata",
|
|
"xx2" => "OD : ",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusDKODV']
|
|
);
|
|
|
|
$visus[] = array(
|
|
"xx1" => "Dengan Kacamata",
|
|
"xx2" => "OS",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusDKOSV']
|
|
);
|
|
|
|
$rst['kelainan'] = "Kelainan refraksi (dengan kacamata)";
|
|
$od_visus = $row_result['T_SamplingAdditionalFisikVisusDKODV'] ;
|
|
$os_visus = $row_result['T_SamplingAdditionalFisikVisusDKOSV'] ;
|
|
|
|
|
|
$value_koreksi_od = "";
|
|
$od_sph = $row_result['T_SamplingAdditionalFisikVisusODSPH'];
|
|
if(strtolower(trim($od_sph)) != "tidak terkoreksi" && strtolower(trim($od_sph)) != "tidak dapat dinilai" && $od_sph != "" && $od_sph != "-" && $od_sph != "--" && $od_sph != "/-" && $od_sph != "/" && $od_sph != "-/" && strtolower(trim($od_sph)) != 'plano'){
|
|
if ($visus_kanan != "") $visus_kanan .= ", ";
|
|
$visus_kanan .= $od_sph." (Miopia)";
|
|
|
|
$miopia_od = true;
|
|
$miopia_od_value = $od_sph;
|
|
}
|
|
|
|
$od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL'];
|
|
|
|
if(strtolower(trim($od_cyl)) != "tidak terkoreksi" && strtolower(trim($od_cyl)) != "tidak dapat dinilai" && $od_cyl != "" && $od_cyl != "-" && $od_cyl != "--" && $od_cyl != "/-" && $od_cyl != "/" && $od_cyl != "-/"){
|
|
if ($visus_kanan != "") $visus_kanan .= ", ";
|
|
$visus_kanan .= "Cyl ".$od_cyl;
|
|
|
|
$astigmatismus_od = true;
|
|
$astigmatismus_od_value = $od_cyl;
|
|
}
|
|
|
|
$od_x = $row_result['T_SamplingAdditionalFisikVisusODX'];
|
|
if(strtolower(trim($od_x)) != "tidak terkoreksi" && strtolower(trim($od_x)) != "tidak dapat dinilai" && $od_x != "" && $od_x != "-" && $od_x != "--" && $od_x != "/-" && $od_x != "/" && $od_x != "-/"){
|
|
//if ($visus_kanan != "") $visus_kanan .= ", ";
|
|
$visus_kanan .= " axis ".$od_x." (Astigmatismus)";
|
|
$x_od = true;
|
|
$x_od = $od_x;
|
|
}else{
|
|
if($od_cyl != "" && $od_cyl != "-" && $od_cyl != "--" && $od_cyl != "/-" && $od_cyl != "/" && $od_cyl != "-/")
|
|
$visus_kanan .= " (Astigmatismus)";
|
|
}
|
|
//$value_koreksi_od .= "X (".$od_x.") ";
|
|
|
|
|
|
|
|
|
|
|
|
$value_koreksi_os = "";
|
|
$os_sph = $row_result['T_SamplingAdditionalFisikVisusOSSPH'];
|
|
if(strtolower(trim($os_sph)) != "tidak terkoreksi" && strtolower(trim($os_sph)) != "tidak dapat dinilai" && $os_sph != "" && $os_sph != "-" && $os_sph != "--" && $os_sph != "/-" && $os_sph != "/" && $os_sph != "-/" && strtolower(trim($os_sph)) != 'plano'){
|
|
if ($visus_kiri != "") $visus_kiri .= ", ";
|
|
$visus_kiri .= $os_sph." (Miopia)";
|
|
|
|
$miopia_os = true;
|
|
$miopia_os_value = $os_sph;
|
|
}
|
|
|
|
$os_cyl = $row_result['T_SamplingAdditionalFisikVisusOSCYL'];
|
|
|
|
if(strtolower(trim($os_cyl)) != "tidak terkoreksi" && strtolower(trim($os_cyl)) != "tidak dapat dinilai" && $os_cyl != "" && $os_cyl != "-" && $os_cyl != "--" && $os_cyl != "/-" && $os_cyl != "/" && $os_cyl != "-/"){
|
|
if ($visus_kiri != "") $visus_kiri .= ", ";
|
|
$visus_kiri .= "Cyl ".$os_cyl;
|
|
|
|
$astigmatismus_os = true;
|
|
$astigmatismus_os_value = $os_cyl;
|
|
}
|
|
|
|
$os_x = $row_result['T_SamplingAdditionalFisikVisusOSX'];
|
|
|
|
if(strtolower(trim($os_x)) != "tidak terkoreksi" && strtolower(trim($os_x)) != "tidak dapat dinilai" && $os_x != "" && $os_x != "-" && $os_x != "--" && $os_x != "/-" && $os_x != "/" && $os_x != "-/"){
|
|
$visus_kiri .= " axis ".$os_x." (Astigmatismus)";
|
|
$x_os = true;
|
|
$x_os = $os_x;
|
|
}else{
|
|
if($os_cyl != "" && $os_cyl != "-" && $os_cyl != "--" && $os_cyl != "/-" && $os_cyl != "/" && $os_cyl != "-/")
|
|
$visus_kiri .= " (Astigmatismus)";
|
|
}
|
|
//$value_koreksi_os .= "X (".$os_x.") ";
|
|
|
|
|
|
}
|
|
|
|
if(($row_result['T_SamplingAdditionalFisikVisusTKODV'] != "" && $row_result['T_SamplingAdditionalFisikVisusTKODV'] != "-") && ($row_result['T_SamplingAdditionalFisikVisusTKOSV'] != "" && $row_result['T_SamplingAdditionalFisikVisusTKOSV'] != "-")){
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKODV'], $normal) && $visus_kanan == ''){
|
|
$visus_kanan = "Miopia";
|
|
$miopia_od = true;
|
|
$miopia_od_value = "";
|
|
}
|
|
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKOSV'], $normal) && $visus_kiri == ''){
|
|
$visus_kiri = "Miopia";
|
|
$miopia_os = true;
|
|
$miopia_os_value = "";
|
|
}
|
|
}
|
|
|
|
if(($row_result['T_SamplingAdditionalFisikVisusDKODV'] != "" && $row_result['T_SamplingAdditionalFisikVisusDKODV'] != "-") && ($row_result['T_SamplingAdditionalFisikVisusDKOSV'] != "" && $row_result['T_SamplingAdditionalFisikVisusDKOSV'] != "-")){
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusDKODV'], $normal) && $visus_kanan == ''){
|
|
$visus_kanan = "Miopia";
|
|
$miopia_od = true;
|
|
$miopia_od_value = "";
|
|
}
|
|
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusDKOSV'], $normal) && $visus_kiri == ''){
|
|
$visus_kiri = "Miopia";
|
|
$miopia_os = true;
|
|
$miopia_os_value = "";
|
|
}
|
|
}
|
|
|
|
$od_add = $row_result['T_SamplingAdditionalFisikVisusADD'];
|
|
if($od_add != "" && $od_add != "-" && $od_add != "--" && $od_add != "/-" && $od_add != "/" && $od_add != "-/"){
|
|
if ($visus_kanan != "") $visus_kanan .= ", ";
|
|
$visus_kanan .= $od_add." (Presbiopia)";
|
|
|
|
if ($visus_kiri != "") $visus_kiri .= ", ";
|
|
$visus_kiri .= $od_add." (Presbiopia)";
|
|
|
|
|
|
$presbiopia_ods = true;
|
|
$presbiopia_ods_value = $od_add;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
$data_insert = array(
|
|
'code' => 'visus',
|
|
'label' => 'visus',
|
|
'note' => $rst['kelainan'],
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus','visus');
|
|
|
|
if($miopia_od){
|
|
$data_insert = array(
|
|
'code' => 'visus_miopia_od',
|
|
'label' => 'visus Miopia OD',
|
|
'note' => $miopia_od_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_miopia_od','visus Miopia OD');
|
|
}
|
|
if($miopia_os){
|
|
$data_insert = array(
|
|
'code' => 'visus_miopia_os',
|
|
'label' => 'visus Miopia OS',
|
|
'note' => $miopia_os_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_miopia_os','visus Miopia OS');
|
|
}
|
|
if($miopia_od){
|
|
$in_value = ["20/30","20/40"];
|
|
$exp_value_od = explode("/",$od_visus);
|
|
if(isset($exp_value_od[1]) && intval($exp_value_od[1]) < 50){
|
|
$data_insert = array(
|
|
'code' => 'visus_miopia_od_30_40',
|
|
'label' => 'visus Miopia OD 20/30 20/40',
|
|
'note' => $miopia_od_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_miopia_od_30_40','visus Miopia OD 20/30 20/40');
|
|
}
|
|
if(isset($exp_value_od[1]) && intval($exp_value_od[1]) > 50){
|
|
$data_insert = array(
|
|
'code' => 'visus_miopia_od_over_50',
|
|
'label' => 'visus Miopia OD > 20/50',
|
|
'note' => $miopia_od_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_miopia_ods_over_50','visus Miopia ODS > 20/50');
|
|
}
|
|
}
|
|
|
|
if($miopia_os){
|
|
|
|
$in_value = ["20/30","20/40"];
|
|
$exp_value_os = explode("/",$os_visus);
|
|
//print_r($exp_value_os);
|
|
if(isset($exp_value_os[1]) && intval($exp_value_os[1]) < 50){
|
|
$data_insert = array(
|
|
'code' => 'visus_miopia_os_30_40',
|
|
'label' => 'visus Miopia OS 20/30 20/40',
|
|
'note' => $miopia_os_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_miopia_od_30_40','visus Miopia OD 20/30 20/40');
|
|
}
|
|
if(isset($exp_value_os[1]) && intval($exp_value_os[1]) > 50){
|
|
$data_insert = array(
|
|
'code' => 'visus_miopia_os_over_50',
|
|
'label' => 'visus Miopia OS > 20/50',
|
|
'note' => $miopia_os_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_miopia_ods_over_50','visus Miopia ODS > 20/50');
|
|
}
|
|
}
|
|
|
|
if($astigmatismus_od){
|
|
$data_insert = array(
|
|
'code' => 'visus_astigmatismus_od',
|
|
'label' => 'visus Astigmatismus OD',
|
|
'note' => $astigmatismus_od_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_astigmatismus_od','visus Astigmatismus OD');
|
|
}
|
|
if($astigmatismus_os){
|
|
$data_insert = array(
|
|
'code' => 'visus_astigmatismus_os',
|
|
'label' => 'visus Astigmatismus OS',
|
|
'note' => $astigmatismus_os_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_astigmatismus_os','visus Astigmatismus OS');
|
|
}
|
|
if($astigmatismus_od && $astigmatismus_os){
|
|
$data_insert = array(
|
|
'code' => 'visus_astigmatismus_ods',
|
|
'label' => 'visus Astigmatismus ODS',
|
|
'note' => $astigmatismus_os_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_astigmatismus_ods','visus Astigmatismus ODS');
|
|
}
|
|
if($x_od){
|
|
$data_insert = array(
|
|
'code' => 'visus_x_od',
|
|
'label' => 'visus X OD',
|
|
'note' => $x_od_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_x_od','visus X OD');
|
|
}
|
|
if($x_os){
|
|
$data_insert = array(
|
|
'code' => 'visus_x_os',
|
|
'label' => 'visus X OS',
|
|
'note' => $x_od_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_x_os','visus X OS');
|
|
}
|
|
if($presbiopia_ods){
|
|
$data_insert = array(
|
|
'code' => 'visus_presbiopia_ods',
|
|
'label' => 'visus Presbiopia ODS',
|
|
'note' => $presbiopia_ods_value,
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('visus_presbiopia_ods','visus Presbiopia ODS');
|
|
}
|
|
}
|
|
|
|
function visus_old($orderID,$userid) {
|
|
$sql = " SELECT * , T_SamplingAdditionalFisikVisusID as visus_id
|
|
FROM t_samplingso_additional_fisik_visus
|
|
WHERE
|
|
T_SamplingAdditionalFisikVisusT_OrderHeaderID = ? LIMIT 1";
|
|
$qry = $this->db_smartone->query($sql,array($orderID));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
|
|
$row_result = $qry->row_array();
|
|
|
|
|
|
$visus = array();
|
|
$visus_kiri = "";
|
|
$visus_kanan = "";
|
|
$visus_kesimpulan = "";
|
|
$normal = array("20/20", "20/25");
|
|
$rst['kelainan'] = "Normal";
|
|
$miopia_od = false;
|
|
$miopia_os = false;
|
|
$miopia_od_value = '';
|
|
$miopia_os_value = '';
|
|
$astigmatismus_od = false;
|
|
$astigmatismus_os = false;
|
|
$astigmatismus_od_value = '';
|
|
$astigmatismus_os_value = '';
|
|
$presbiopia_od = false;
|
|
$presbiopia_os = false;
|
|
$presbiopia_od_value = '';
|
|
$presbiopia_os_value = '';
|
|
|
|
if($row_result){
|
|
if(($row_result['T_SamplingAdditionalFisikVisusTKODV'] != "" && $row_result['T_SamplingAdditionalFisikVisusTKODV'] != "-") && ($row_result['T_SamplingAdditionalFisikVisusTKOSV'] != "" && $row_result['T_SamplingAdditionalFisikVisusTKOSV'] != "-")){
|
|
$visus[] = array(
|
|
"xx1" => "Tanpa Kacamata",
|
|
"xx2" => "OD : ",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusTKODV']
|
|
);
|
|
|
|
$visus[] = array(
|
|
"xx1" => "Tanpa Kacamata",
|
|
"xx2" => "OS",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusTKOSV']
|
|
);
|
|
|
|
$rst['kelainan'] = "Kelainan refraksi (tanpa kacamata)";
|
|
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKODV'], $normal)){
|
|
$value_koreksi_od = "";
|
|
$od_sph = $row_result['T_SamplingAdditionalFisikVisusODSPH'];
|
|
if($od_sph != "" && $od_sph != "-" && $od_sph != "--" && $od_sph != "/-" && $od_sph != "/" && $od_sph != "-/" && strtolower(trim($od_sph)) != 'plano'){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Miopia OD";
|
|
|
|
$miopia_od = true;
|
|
$miopia_od_value = $od_sph;
|
|
}
|
|
|
|
$od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL'];
|
|
if($od_cyl != "" && $od_cyl != "-" && $od_cyl != "--" && $od_cyl != "/-" && $od_cyl != "/" && $od_cyl != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Astigmatismus OD";
|
|
|
|
$astigmatismus_od = true;
|
|
$astigmatismus_od_value = $od_cyl;
|
|
}
|
|
|
|
|
|
$od_x = $row_result['T_SamplingAdditionalFisikVisusODX'];
|
|
if($od_x != "" && $od_x != "-" && $od_x != "--" && $od_x != "/-" && $od_x != "/" && $od_x != "-/")
|
|
$value_koreksi_od .= "X (".$od_x.") ";
|
|
|
|
$od_add = $row_result['T_SamplingAdditionalFisikVisusADD'];
|
|
if($od_add != "" && $od_add != "-" && $od_add != "--" && $od_add != "/-" && $od_add != "/" && $od_add != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Presbiopia OD";
|
|
|
|
$presbiopia_od = true;
|
|
|
|
$presbiopia_od_value = "";
|
|
$presbiopia_os_value = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKOSV'], $normal)){
|
|
$value_koreksi_os = "";
|
|
$os_sph = $row_result['T_SamplingAdditionalFisikVisusOSSPH'];
|
|
if(strtolower(trim($os_sph)) != "tidak terkoreksi" && strtolower(trim($os_sph)) != "tidak dapat dinilai" && $os_sph != "" && $os_sph != "-" && $os_sph != "--" && $os_sph != "/-" && $os_sph != "/" && $os_sph != "-/" && strtolower(trim($os_sph)) != 'plano'){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Miopia OS";
|
|
}
|
|
|
|
|
|
$os_cyl = $row_result['T_SamplingAdditionalFisikVisusOSCYL'];
|
|
if(strtolower(trim($os_cyl)) != "tidak terkoreksi" && strtolower(trim($os_cyl)) != "tidak dapat dinilai" && $os_cyl != "" && $os_cyl != "-" && $os_cyl != "--" && $os_cyl != "/-" && $os_cyl != "/" && $os_cyl != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Astigmatismus OS";
|
|
}
|
|
|
|
|
|
$os_x = $row_result['T_SamplingAdditionalFisikVisusOSX'];
|
|
if(strtolower(trim($os_x)) != "tidak terkoreksi" && strtolower(trim($os_x)) != "tidak dapat dinilai" && $os_x != "" && $os_x != "-" && $os_x != "--" && $os_x != "/-" && $os_x != "/" && $os_x != "-/")
|
|
$value_koreksi_os .= "X (".$os_x.") ";
|
|
|
|
$od_add = $row_result['T_SamplingAdditionalFisikVisusADD'];
|
|
if($od_add != "" && $od_add != "-" && $od_add != "--" && $od_add != "/-" && $od_add != "/" && $od_add != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Presbiopia OS";
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if(($row_result['T_SamplingAdditionalFisikVisusDKODV'] != "" && $row_result['T_SamplingAdditionalFisikVisusDKODV'] != "-") && ($row_result['T_SamplingAdditionalFisikVisusDKOSV'] != "" && $row_result['T_SamplingAdditionalFisikVisusDKOSV'] != "-")){
|
|
$visus[] = array(
|
|
"xx1" => "Dengan Kacamata",
|
|
"xx2" => "OD : ",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusDKODV']
|
|
);
|
|
|
|
$visus[] = array(
|
|
"xx1" => "Dengan Kacamata",
|
|
"xx2" => "OS",
|
|
"xx3" => $row_result['T_SamplingAdditionalFisikVisusDKOSV']
|
|
);
|
|
|
|
$rst['kelainan'] = "Kelainan refraksi (dengan kacamata)";
|
|
|
|
|
|
$value_koreksi_od = "";
|
|
$od_sph = $row_result['T_SamplingAdditionalFisikVisusODSPH'];
|
|
if(strtolower(trim($od_sph)) != "tidak terkoreksi" && strtolower(trim($od_sph)) != "tidak dapat dinilai" && $od_sph != "" && $od_sph != "-" && $od_sph != "--" && $od_sph != "/-" && $od_sph != "/" && $od_sph != "-/" && strtolower(trim($od_sph)) != 'plano'){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Miopia OD";
|
|
}
|
|
|
|
|
|
$od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL'];
|
|
if(strtolower(trim($od_cyl)) != "tidak terkoreksi" && strtolower(trim($od_cyl)) != "tidak dapat dinilai" && $od_cyl != "" && $od_cyl != "-" && $od_cyl != "--" && $od_cyl != "/-" && $od_cyl != "/" && $od_cyl != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Astigmatismus OD";
|
|
}
|
|
|
|
|
|
$od_x = $row_result['T_SamplingAdditionalFisikVisusODX'];
|
|
if(strtolower(trim($od_x)) != "tidak terkoreksi" && strtolower(trim($od_x)) != "tidak dapat dinilai" && $od_x != "" && $od_x != "-" && $od_x != "--" && $od_x != "/-" && $od_x != "/" && $od_x != "-/")
|
|
$value_koreksi_od .= "X (".$od_x.") ";
|
|
|
|
$od_add = $row_result['T_SamplingAdditionalFisikVisusADD'];
|
|
if($od_add != "" && $od_add != "-" && $od_add != "--" && $od_add != "/-" && $od_add != "/" && $od_add != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Presbiopia OD";
|
|
}
|
|
|
|
|
|
|
|
|
|
$value_koreksi_os = "";
|
|
$os_sph = $row_result['T_SamplingAdditionalFisikVisusOSSPH'];
|
|
if(strtolower(trim($os_sph)) != "tidak terkoreksi" && strtolower(trim($os_sph)) != "tidak dapat dinilai" && $os_sph != "" && $os_sph != "-" && $os_sph != "--" && $os_sph != "/-" && $os_sph != "/" && $os_sph != "-/" && strtolower(trim($os_sph)) != 'plano'){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Miopia OS";
|
|
}
|
|
|
|
$os_cyl = $row_result['T_SamplingAdditionalFisikVisusOSCYL'];
|
|
if(strtolower(trim($os_cyl)) != "tidak terkoreksi" && strtolower(trim($os_cyl)) != "tidak dapat dinilai" && $os_cyl != "" && $os_cyl != "-" && $os_cyl != "--" && $os_cyl != "/-" && $os_cyl != "/" && $os_cyl != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Astigmatismus OS";
|
|
}
|
|
|
|
$os_x = $row_result['T_SamplingAdditionalFisikVisusOSX'];
|
|
if(strtolower(trim($os_x)) != "tidak terkoreksi" && strtolower(trim($os_x)) != "tidak dapat dinilai" && $os_x != "" && $os_x != "-" && $os_x != "--" && $os_x != "/-" && $os_x != "/" && $os_x != "-/")
|
|
$value_koreksi_os .= "X (".$os_x.") ";
|
|
|
|
$od_add = $row_result['T_SamplingAdditionalFisikVisusADD'];
|
|
if($od_add != "" && $od_add != "-" && $od_add != "--" && $od_add != "/-" && $od_add != "/" && $od_add != "-/"){
|
|
if ($visus_kesimpulan != "") $visus_kesimpulan .= ", ";
|
|
$visus_kesimpulan .= "Presbiopia OS";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$rst['kesimpulan'] = $visus_kesimpulan;
|
|
|
|
$data_insert = array(
|
|
'code' => 'visus',
|
|
'label' => 'visus',
|
|
'note' => $rst['kelainan'],
|
|
'segment' => 'visus',
|
|
'category' => 'mata',
|
|
'order_id' => $orderID
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
}
|
|
}
|
|
|
|
function insert_code($code,$label){
|
|
/*$sql = "INSERT INTO fisik_template_code(
|
|
FisikTemplateCodeName,
|
|
FisikTemplateCodeLabel,
|
|
FisikTemplateCodeCreated,
|
|
FisikTemplateCodeCreatedUserID
|
|
)
|
|
VALUES(
|
|
?,?,NOW(),555
|
|
)";
|
|
$qry = $this->db_smartone->query($sql,array($code,$label));
|
|
if (! $qry) {
|
|
return false;
|
|
}*/
|
|
}
|
|
|
|
function status_gizi($id,$userid) {
|
|
$sql = "SELECT *
|
|
FROM t_samplingso_additional_fisik_bbtb
|
|
WHERE
|
|
T_SamplingAdditionalFisikBBTBT_OrderHeaderID = ? AND
|
|
T_SamplingAdditionalFisikBBTBIsActive = 'Y'
|
|
LIMIT 1";
|
|
$qry = $this->db_smartone->query($sql,array($id));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
//echo $this->db_smartone->last_query();
|
|
$row_results = $qry->result_array();
|
|
//print_r($row_result);
|
|
if(count($row_results) > 0){
|
|
$row_result = $row_results[0];
|
|
$status_gizi = array();
|
|
$bb = $row_result["T_SamplingAdditionalFisikBBTBValueBB"];
|
|
$tb = $row_result["T_SamplingAdditionalFisikBBTBValueTB"];
|
|
$standart_bmi = $row_result["T_SamplingAdditionalFisikBBTBStandart"];
|
|
$get_bmi = $this->hitung_bmi($bb,$tb,$standart_bmi);
|
|
$bmi = $get_bmi['bmi'];
|
|
|
|
$classification = $get_bmi['class'];
|
|
//echo $classification;
|
|
|
|
$data_insert_tb = array(
|
|
'code' => 'tb',
|
|
'label' => $tb,
|
|
'note' => $tb,
|
|
'segment' => 'status_gizi',
|
|
'category' => '',
|
|
'order_id' => $id
|
|
);
|
|
$this->insert_data_etl($data_insert_tb,$userid);
|
|
//$this->insert_code('tb',$tb);
|
|
|
|
$data_insert_bb = array(
|
|
'code' => 'bb',
|
|
'label' => $bb,
|
|
'note' => $bb,
|
|
'segment' => 'status_gizi',
|
|
'category' => '',
|
|
'order_id' => $id
|
|
);
|
|
$this->insert_data_etl($data_insert_bb,$userid);
|
|
//$this->insert_code('bb',$bb);
|
|
|
|
$data_insert_bmi = array(
|
|
'code' => 'bmi',
|
|
'label' => $bmi,
|
|
'note' => $bmi,
|
|
'segment' => 'status_gizi',
|
|
'category' => $standart_bmi,
|
|
'order_id' => $id
|
|
);
|
|
$this->insert_data_etl($data_insert_bmi,$userid);
|
|
//$this->insert_code('bmi',$bmi);
|
|
|
|
$data_insert_bmi_class = array(
|
|
'code' => 'bmi_classification_'.$standart_bmi,
|
|
'label' => $classification,
|
|
'note' => $classification,
|
|
'segment' => 'status_gizi',
|
|
'category' => $standart_bmi,
|
|
'order_id' => $id
|
|
);
|
|
//print_r($data_insert_bmi_class);
|
|
$this->insert_data_etl($data_insert_bmi_class,$userid);
|
|
//$this->insert_code('bmi_classification_'.$standart_bmi,$classification);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
function persepsi_warna($id,$userid) {
|
|
$sql = "SELECT IFNULL(T_SamplingAdditionalFisikBWPWValue,'Z') as result,
|
|
IFNULL(T_SamplingAdditionalFisikBWPWVAngka,'') as angka
|
|
FROM t_samplingso_additional_fisik_bw
|
|
WHERE
|
|
T_SamplingAdditionalFisikBWT_OrderHeaderID = ? AND
|
|
T_SamplingAdditionalFisikBWIsActive = 'Y'
|
|
LIMIT 1";
|
|
$qry = $this->db_smartone->query($sql,array($id));
|
|
if (! $qry) {
|
|
return false;
|
|
}
|
|
|
|
|
|
$row_results = $qry->result_array();
|
|
if(count($row_results) > 0){
|
|
$row_result = $row_results[0];
|
|
$hasil = 'Bahan belum';
|
|
if($row_result['result'] == 'BW'){
|
|
$hasil = 'Red Green Deficiency';
|
|
}
|
|
if($row_result['result'] == 'N'){
|
|
$hasil = 'Normal';
|
|
}
|
|
if($row_result['result'] == 'X'){
|
|
$hasil = 'Tidak dilakukan';
|
|
}
|
|
$data_insert_bw = array(
|
|
'code' => 'bw',
|
|
'label' => $row_result['result'],
|
|
'note' => $hasil,
|
|
'segment' => 'mata',
|
|
'category' => '',
|
|
'order_id' => $id
|
|
);
|
|
$this->insert_data_etl($data_insert_bw,$userid);
|
|
//$this->insert_code('bw',$row_result['result']);
|
|
|
|
$data_insert_bwv = array(
|
|
'code' => 'bw_value',
|
|
'label' => $row_result['angka'],
|
|
'note' => $row_result['angka'],
|
|
'segment' => 'mata',
|
|
'category' => '',
|
|
'order_id' => $id
|
|
);
|
|
$this->insert_data_etl($data_insert_bwv,$userid);
|
|
//$this->insert_code('bw_value',$row_result['angka']);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function hitung_bmi($bb,$tb,$standart_bmi){
|
|
$tb = $tb/100;
|
|
$bmi = '';
|
|
$classs = "";
|
|
$bmi_valuex= 0;
|
|
if(intval($bb) != 0 && intval($tb) != 0){
|
|
$bmi = $bb / ($tb * $tb);
|
|
$bmi_valuex = number_format($bmi,2);
|
|
|
|
if($standart_bmi === 'asia_pacific'){
|
|
if($bmi_valuex < 18.5)
|
|
$classs = 'Underweight';
|
|
|
|
if($bmi_valuex >= 18.5 && $bmi_valuex < 23)
|
|
$classs = 'Normal';
|
|
|
|
if($bmi_valuex >= 23 && $bmi_valuex < 25)
|
|
$classs = 'Overweight';
|
|
|
|
if($bmi_valuex >= 25 && $bmi_valuex < 30)
|
|
$classs = 'Obese I';
|
|
|
|
if($bmi_valuex >= 30)
|
|
$classs = 'Obese II';
|
|
}
|
|
|
|
if($standart_bmi === 'who'){
|
|
if($bmi_valuex < 18.5)
|
|
$classs = 'Underweight';
|
|
|
|
if($bmi_valuex >= 18.5 && $bmi_valuex < 25){
|
|
$classs = 'Normal';
|
|
}
|
|
|
|
if($bmi_valuex >= 25 && $bmi_valuex < 30){
|
|
$classs = 'Overweight';
|
|
}
|
|
|
|
if($bmi_valuex >= 30)
|
|
$classs = 'Obese';
|
|
}
|
|
|
|
if($standart_bmi === 'kemenkes'){
|
|
if($bmi_valuex < 18.5)
|
|
$classs = 'Underweight';
|
|
|
|
if($bmi_valuex >= 18.5 && $bmi_valuex < 25.1)
|
|
$classs = 'Normal';
|
|
|
|
if($bmi_valuex >= 25.1 && $bmi_valuex < 27)
|
|
$classs = 'Overweight';
|
|
|
|
if($bmi_valuex >= 27)
|
|
$classs = 'Obese';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return array(
|
|
'bmi' => $bmi_valuex,
|
|
'class' => $classs
|
|
);
|
|
}
|
|
|
|
function keluhan($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'fisik_keluhan'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'fisik_keluhan',
|
|
'category' => ''
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']);
|
|
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function riwayat_penyakit($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'fisik_penyakit'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['segment_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$value['segment_name']);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function penyakit_keluarga($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'fisik_penyakitkeluarga'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
$results = [];
|
|
$options = $value['options'];
|
|
foreach ($options as $ko => $vo) {
|
|
if($vo['selected'] == '1')
|
|
$results[] = $vo['label'];
|
|
}
|
|
|
|
if(count($results) > 0){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => join(", ",$results),
|
|
'segment' => $value['table_name'],
|
|
'category' => $value['table_name'],
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']);
|
|
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
|
|
function kebiasaan_hidup($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'fisik_kebiasaanhidup'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['segment_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$value['segment_name']);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function fisik_konsumsiobatteratur($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'fisik_konsumsiobatteratur'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['table_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']);
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
|
|
function imunasi($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'fisik_riwayatimunisasi'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['segment_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$value['segment_name']);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function vital_sign($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
( FisikTemplateTableName = 'tanda_vital' OR FisikTemplateTableName = 'tanda_vital_td' )
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['id_code'] == 'tanda_vital_5'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'].'_1',
|
|
'label' => $value['label_x'],
|
|
'note' => $value['value_x'],
|
|
'segment' => 'tekanan_darah',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'].'_1',$value['label_x']);
|
|
$rst[] = $data_insert;
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'].'_2',
|
|
'label' => $value['label_y'],
|
|
'note' => $value['value_y'],
|
|
'segment' => 'tekanan_darah',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'].'_2',$value['label_y']);
|
|
$rst[] = $data_insert;
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => 'tekanan_darah_conclusion',
|
|
'label' => $value['standart'],
|
|
'note' => $value['value'],
|
|
'segment' => 'tekanan_darah',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code('tekanan_darah_conclusion',$value['label_y']);
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($value['id_code'] == 'tanda_vital_6'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['chx_y'] == '1'?$value['label_y']:$value['label_x'],
|
|
'note' => $value['value'],
|
|
'segment' => 'suhu',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'],'Suhu');
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($value['id_code'] == 'tanda_vital_1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'denyut_nadi',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'],$value['label']);
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($value['id_code'] == 'tanda_vital_2'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['chx_y'] == '1'?$value['label_y']:$value['label_x'],
|
|
'note' => $value['value'],
|
|
'segment' => 'ritme_denyut_nadi',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'],'Denyut Nadi');
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($value['id_code'] == 'tanda_vital_3'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'laju_pernafasan',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'],$value['label']);
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($value['id_code'] == 'tanda_vital_4'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['chx_y'] == '1'?$value['label_y']:$value['label_x'],
|
|
'note' => $value['value'],
|
|
'segment' => 'pola_nafas',
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
//$this->insert_code($value['id_code'],'Pola Nafas');
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
|
|
function keadaan_umum($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'keadaan_umum'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx_x'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code']+'_x',
|
|
'label' => $value['label_x'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['table_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
}
|
|
if($value['chx_y'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'].'_y',
|
|
'label' => $value['label_y'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['table_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
}
|
|
|
|
////$this->insert_code($value['id_code'],'Keadaan Umum');
|
|
$rst[] = $data_insert;
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function kepala_wajah($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'kepala_wajah'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1' && $value['is_normal'] == 'N'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $value['table_name'],
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | '.$value['table_name']);
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function mata($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'mata'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'mata',
|
|
'category' => 'mata'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | Mata");
|
|
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function lapang_pandang($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'lapang_pandang'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
$value_data = $details[0];
|
|
|
|
if($value_data['chx_x'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => 'lapang_pandang_x',
|
|
'label' => $value_data['label_x'],
|
|
'note' => $value_data['value'],
|
|
'segment' => 'lapang_pandang',
|
|
'category' => 'lapang_pandang'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($value_data['chx_y'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => 'lapang_pandang_y',
|
|
'label' => $value_data['label_y'],
|
|
'note' => $value_data['value'],
|
|
'segment' => 'lapang_pandang',
|
|
'category' => 'lapang_pandang'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code('lapang_pandang_x','Lapang Pandang Tidak Normal');
|
|
//$this->insert_code('lapang_pandang_y','Lapang Pandang Normal');
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function telinga($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'telinga'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'telinga',
|
|
'category' => 'telinga'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Telinga');
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function hidung($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'hidung'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'hidung',
|
|
'category' => 'hidung'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Hidung');
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function gigi($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'gigi'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'gigi',
|
|
'category' => 'gigi'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Gigi');
|
|
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function mulut($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'mukosa_rongga_mulut'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
$segment = strtolower(str_replace(" ","_",$value['segment_name']));
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function leher($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'leher'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'leher',
|
|
'category' => 'leher'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Leher');
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function thorax($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'thorax'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'thorax',
|
|
'category' => 'thorax'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Thorax');
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function paru($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'paru'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'paru',
|
|
'category' => 'paru'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Paru');
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function jantung($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'jantung'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
$segment = strtolower(str_replace(" ","_",str_replace("/","",$value['segment_name'])));
|
|
if($value['chx'] == '1'){
|
|
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function perut($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'perut'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
if($v['name'] != 'Hernia' && $v['name'] != 'Pengukuran'){
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
$segment = strtolower(str_replace(" ","_",$v['name']));
|
|
if($value['chx'] == '1'){
|
|
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
|
|
if($v['name'] == 'Hernia'){
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['id_code'] == 'perut_13'){
|
|
if($value['chx'] == '1'){
|
|
$segment = strtolower(str_replace(" ","_",$v['name']));
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Hernia '.$segment);
|
|
}
|
|
|
|
if($value['id_code'] == 'perut_14'){
|
|
$segment = strtolower(str_replace(" ","_",$v['name']));
|
|
if($value['chx'] == '1'){
|
|
$child_details = $value['details'];
|
|
foreach ($child_details as $kx => $vx) {
|
|
if($vx['id_code'] == 'perut_14_1'){
|
|
if($vx['chx_value'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $vx['id_code'],
|
|
'label' => $vx['label'],
|
|
'note' => '',
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | Hernia '.$segment);
|
|
}
|
|
|
|
if($vx['id_code'] != 'perut_14_1'){
|
|
if($vx['chx_a_value'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $vx['id_code'].'_'.$vx['chx_a_label'],
|
|
'label' => $vx['label'],
|
|
'note' => $vx['chx_a_label'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
|
|
if($vx['chx_b_value'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $vx['id_code'].'_'.$vx['chx_b_label'],
|
|
'label' => $vx['label'],
|
|
'note' => $vx['chx_b_label'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($vx['id_code'].'_'.$vx['chx_a_label'],$value['label'].' | Hernia '.$segment);
|
|
//$this->insert_code($vx['id_code'].'_'.$vx['chx_b_label'],$value['label'].' | Hernia '.$segment);
|
|
}
|
|
|
|
}
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if($v['name'] == 'Hernia'){
|
|
$details = $v['details'];
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function sistem_integumen($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'sistem_integumen'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
$segment = strtolower(str_replace(" ","_",$value['segment_name']));
|
|
if($value['chx'] == '1'){
|
|
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function genitourinaria($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'genitourinaria'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => 'genitourinaria',
|
|
'category' => 'genitourinaria'
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' Genitourinaria');
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function anggota_gerak($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'anggota_gerak'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$segment = strtolower(str_replace(" ","_",str_replace("/","",$value['segment_name'])));
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function sistem_persyarafan($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'sistem_persyarafan'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$segment = strtolower(str_replace(" ","_",str_replace("&","",$value['segment_name'])));
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function smell_test($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'smell_test'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$segment = strtolower(str_replace(" ","_",$value['segment_name']));
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function low_back_pain_screening_test($id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
FisikTemplateTableName = 'low_back_pain_screening_test'
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id));
|
|
//echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$header_details = $valdata['details'];
|
|
//print_r($header_details);
|
|
foreach ($header_details as $k => $v) {
|
|
$details = $v['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$segment = strtolower(str_replace(" ","_",$value['segment_name']));
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => $value['value'],
|
|
'segment' => $segment,
|
|
'category' => $value['table_name']
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label']." | ".$segment);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function k3($type,$id,$userid){
|
|
$rst = [];
|
|
$sql = "SELECT *
|
|
FROM fisik_template
|
|
JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND
|
|
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
|
So_ResultEntryFisikUmumIsActive = 'Y'
|
|
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
|
WHERE
|
|
FisikTemplateIsActive = 'Y' AND
|
|
`FisikTemplateType` = 'k3' AND
|
|
FisikTemplateTableName = ?
|
|
ORDER BY FisikTemplateCode ASC
|
|
LIMIT 1
|
|
";
|
|
$qry = $this->db_smartone->query($sql, array($id,$type));
|
|
// echo $this->db_smartone->last_query();
|
|
$datas = $qry->result_array();
|
|
if($datas && count($datas) > 0){
|
|
$order_header_id = $datas[0]['So_ResultEntryT_OrderHeaderID'];
|
|
$valdata = json_decode($datas[0]['So_ResultEntryFisikUmumDetails'], true);
|
|
$details = $valdata['details'];
|
|
foreach ($details as $key => $value) {
|
|
if($value['chx'] == '1'){
|
|
$data_insert = array(
|
|
'order_id' => $order_header_id,
|
|
'code' => $value['id_code'],
|
|
'label' => $value['label'],
|
|
'note' => '',
|
|
'segment' => $type,
|
|
'category' => $type
|
|
);
|
|
$this->insert_data_etl($data_insert,$userid);
|
|
$rst[] = $data_insert;
|
|
}
|
|
//$this->insert_code($value['id_code'],$value['label'].' | '.$type);
|
|
}
|
|
}
|
|
|
|
return $rst;
|
|
}
|
|
|
|
function loop_k3($id,$userid){
|
|
$rspn = [];
|
|
$arr = ['faktor_fisik','faktor_kimia','faktor_biologi','faktor_ergonomi','faktor_psikologi'];
|
|
foreach ($arr as $key => $value) {
|
|
$rtn = $this->k3($value,$id,$userid);
|
|
if(count($rtn) > 0)
|
|
$rspn[] = $rtn;
|
|
}
|
|
return $rspn;
|
|
}
|
|
|
|
function generate_summaries($orderID,$soReID,$userID,$debugID=0){
|
|
$sql = "UPDATE t_kelainan_fisik SET
|
|
T_KelainanFiskIsActive = 'N',
|
|
T_KelainanFiskDeletedUserID = ? ,
|
|
T_KelainanFiskDeleted = NOW()
|
|
WHERE
|
|
T_KelainanFiskT_OrderHeaderID = ? AND
|
|
T_KelainanFiskIsActive = 'Y'";
|
|
$query = $this->db_smartone->query($sql,[
|
|
$userID,
|
|
$orderID
|
|
]);
|
|
$kelainanrst = [];
|
|
$sql = "SELECT *
|
|
FROM mcu_fisiksummary
|
|
JOIN mcu_kelainan ON Mcu_kelainanID = Mcu_FisikSummaryMcu_KelainanID
|
|
WHERE Mcu_FisikSummaryIsActive = 'Y'";
|
|
$query = $this->db_smartone->query($sql);
|
|
$rumus_summaries = $query->result_array();
|
|
//print_r($rumus_summaries);
|
|
|
|
foreach ($rumus_summaries as $key => $value) {
|
|
//echo $value['Mcu_KelainanName'];
|
|
$results = [];
|
|
$sql = "SELECT *
|
|
FROM mcu_fisiksummarydetail
|
|
WHERE
|
|
Mcu_FisikSummaryDetailMcu_FisikSummaryID = ? AND
|
|
Mcu_FisikSummaryDetailIsActive = 'Y'";
|
|
|
|
$query = $this->db_smartone->query($sql,[$value['Mcu_FisikSummaryID']]);
|
|
$details = $query->result_array();
|
|
foreach ($details as $k => $v) {
|
|
if($v['Mcu_FisikSummaryDetailType'] == 'VK'){
|
|
$sql = "SELECT *
|
|
FROM mcu_fisikvalue
|
|
WHERE
|
|
Mcu_FisikValueT_OrderHeaderID = ? AND
|
|
Mcu_FisikValueIsActive = 'Y' AND
|
|
Mcu_FisikValueCode = ? AND
|
|
Mcu_FisikValueNote = ?";
|
|
$query = $this->db_smartone->query($sql,[$orderID,$v['Mcu_FisikSummaryDetailCode'],$value['Mcu_KelainanName']]);
|
|
/*if($value['Mcu_FisikSummaryID'] == 2){
|
|
echo $this->db_smartone->last_query();
|
|
}*/
|
|
$exist_rows = $query->result_array();
|
|
$return_x = false;
|
|
if(count($exist_rows) > 0){
|
|
$return_x = true;
|
|
}
|
|
$results[] = $return_x;
|
|
}
|
|
|
|
if($v['Mcu_FisikSummaryDetailType'] == 'V'){
|
|
$sql = "SELECT *
|
|
FROM mcu_fisikvalue
|
|
JOIN mcu_fisiksummarydetail
|
|
ON Mcu_FisikSummaryDetailIsActive = 'Y'
|
|
AND Mcu_FisikSummaryDetailCode = Mcu_FisikValueCode
|
|
AND Mcu_FisikValueCode = ?
|
|
AND Mcu_FisikSummaryDetailType = 'V'
|
|
JOIN mcu_fisiksummary
|
|
ON Mcu_FisikSummaryDetailMcu_FisikSummaryID = Mcu_FisikSummaryID
|
|
AND Mcu_FisikSummaryMcu_KelainanID = ?
|
|
WHERE Mcu_FisikValueT_OrderHeaderID = ?
|
|
AND Mcu_FisikValueIsActive = 'Y'
|
|
AND Mcu_FisikSummaryDetailValue REGEXP CONCAT('(^|, )', TRIM(Mcu_FisikValueNote), '(,|$)')";
|
|
$query = $this->db_smartone->query($sql,[$v['Mcu_FisikSummaryDetailCode'],$value['Mcu_KelainanID'],$orderID]);
|
|
if($value['Mcu_FisikSummaryID'] == $debugID){
|
|
echo $this->db_smartone->last_query();
|
|
}
|
|
$exist_rows = $query->result_array();
|
|
$return_x = false;
|
|
if(count($exist_rows) > 0){
|
|
$return_x = true;
|
|
}
|
|
$results[] = $return_x;
|
|
}
|
|
|
|
if($v['Mcu_FisikSummaryDetailType'] == 'C'){
|
|
$sql = "SELECT *
|
|
FROM mcu_fisikvalue
|
|
WHERE
|
|
Mcu_FisikValueT_OrderHeaderID = ? AND
|
|
Mcu_FisikValueIsActive = 'Y' AND
|
|
Mcu_FisikValueCode = ?";
|
|
$query = $this->db_smartone->query($sql,[$orderID,$v['Mcu_FisikSummaryDetailCode']]);
|
|
if($value['Mcu_FisikSummaryID'] == $debugID){
|
|
echo $this->db_smartone->last_query();
|
|
}
|
|
|
|
$exist_rows = $query->result_array();
|
|
$return_x = false;
|
|
if(count($exist_rows) > 0){
|
|
$return_x = true;
|
|
}
|
|
$results[] = $return_x;
|
|
}
|
|
}
|
|
//if($value['Mcu_FisikSummaryID'] == 2)
|
|
//print_r($results);
|
|
|
|
$is_kelainan = false;
|
|
if($value['Mcu_FisikSummaryType'] == "AND"){
|
|
if(!in_array(false,$results))
|
|
$is_kelainan = true;
|
|
|
|
//if($value['Mcu_FisikSummaryID'] == $debugID){
|
|
// echo "AND";
|
|
// print_r($results);
|
|
//}
|
|
|
|
}
|
|
if($value['Mcu_FisikSummaryType'] == "OR"){
|
|
if(in_array(true,$results))
|
|
$is_kelainan = true;
|
|
|
|
//if($value['Mcu_FisikSummaryID'] == $debugID){
|
|
// echo "OR";
|
|
// print_r($results);
|
|
//}
|
|
}
|
|
|
|
//if($value['Mcu_FisikSummaryMcu_KelainanID'] == 27)
|
|
// echo $this->db_smartone->last_query();
|
|
if($is_kelainan){
|
|
|
|
//if($value['Mcu_FisikSummaryID'] == 2){
|
|
// echo "IHIR";
|
|
//}
|
|
$sql = "INSERT INTO t_kelainan_fisik(
|
|
T_KelainanFiskSo_ResultEntryID,
|
|
T_KelainanFiskT_OrderHeaderID,
|
|
T_KelainanFiskMcu_KelainanID,
|
|
T_KelainanFiskMcu_FisikSummaryID,
|
|
T_KelainanFiskCreatedUserID,
|
|
T_KelainanFiskCreated
|
|
) VALUES(?,?,?,?,?,NOW())";
|
|
$query = $this->db_smartone->query($sql,[
|
|
$soReID,
|
|
$orderID,
|
|
$value['Mcu_FisikSummaryMcu_KelainanID'],
|
|
$value['Mcu_FisikSummaryID'],
|
|
$userID
|
|
]);
|
|
$kelainanrst[] = array(
|
|
'id' => $value['Mcu_FisikSummaryMcu_KelainanID'],
|
|
'name' => $value['Mcu_KelainanName']
|
|
);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
function translate_word($word,$langid=1){
|
|
if($langid == 1){
|
|
return $word;
|
|
}
|
|
else{
|
|
$sql = "SELECT * FROM translate_word WHERE Translate_WordIsActive = 'Y' AND Translate_WordFrom = '{$word}'";
|
|
//echo $sql;
|
|
$qry = $this->db_smartone->query($sql);
|
|
if (! $qry) {
|
|
return $word;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
if(count($rows) > 0){
|
|
return $rows[0]["Translate_WordTo"];
|
|
}else{
|
|
return $word;
|
|
}
|
|
}
|
|
}
|
|
|
|
function translate_multiline_text($text, $langid = 1) {
|
|
// Split the text into lines
|
|
$lines = explode("\n", $text);
|
|
|
|
// Translate each line
|
|
$translated_lines = array_map(function($line) use ($langid) {
|
|
// Remove the leading "- " and translate the rest
|
|
$trimmed_line = ltrim($line, "- ");
|
|
return "- " . $this->translate_sentence($trimmed_line, $langid);
|
|
}, $lines);
|
|
|
|
// Join the translated lines back into a multiline string
|
|
return implode("\n", $translated_lines);
|
|
}
|
|
|
|
function translate_sentence($sentence, $langid = 1) {
|
|
// Split the sentence into words
|
|
$words = preg_split('/[\s-]+/', $sentence);
|
|
|
|
// Translate each word
|
|
$translated_words = array_map(function($word) use ($langid) {
|
|
return $this->translate_word($word, $langid);
|
|
}, $words);
|
|
|
|
// Join the translated words back into a sentence
|
|
return implode(' ', $translated_words);
|
|
}
|
|
|
|
}
|