db_smartone = $this->load->database("onedev", true); } function label_print($id, $start_date, $end_date, $type) { $rst = []; $sql = "SELECT T_OrderHeaderLabNumber,M_PatientDivisi,M_PatientDepartement, CONCAT(T_OrderHeaderLabNumber,' / ',M_PatientName) as baris_1, IF('{$type}' = 'divisi',CONCAT(M_PatientNIP,' / ',M_PatientDivisi),CONCAT(M_PatientNIP,' / ',M_PatientDepartement)) as baris_2, CONCAT(M_PatientNIP,' / ',M_PatientDepartement) as baris_2_departement, M_PatientNIP, DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date, CorporateName FROM t_orderheader JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID JOIN mgm_mcu ON Mgm_McuID = T_OrderHeaderMgm_McuID JOIN corporate ON Mgm_McuCorporateID = CorporateID WHERE T_OrderHeaderIsActive = 'Y' AND T_OrderHeaderMgm_McuID = {$id} AND DATE(T_OrderHeaderDate) BETWEEN '{$start_date}' AND '{$end_date}'"; // echo $sql; $qry = $this->db_smartone->query($sql); if ($qry) { $rows = $qry->result_array(); $count = 1; $loop_arr = []; foreach ($rows as $idx => $r) { $loop_arr[] = $r; if ($count == 2) { $rst[] = $loop_arr; $loop_arr = []; $count = 1; } else { if ($idx < count($rows) - 1) { $count = $count + 1; } else { $rst[] = $loop_arr; $count = $count + 1; } } } echo json_encode($rst); } else { echo json_encode(array()); } } function label_print_nolab($id, $start_date, $end_date, $type, $nolab = "") { $filter = ""; if ($nolab != "") { $filter .= " AND T_OrderHeaderLabNumber = '{$nolab}'"; } $rst = []; $sql = "SELECT T_OrderHeaderLabNumber,M_PatientDivisi,M_PatientDepartement, CONCAT(T_OrderHeaderLabNumber,' / ',M_PatientName) as baris_1, IF('{$type}' = 'divisi',CONCAT(M_PatientNIP,' / ',M_PatientDivisi),CONCAT(M_PatientNIP,' / ',M_PatientDepartement)) as baris_2, CONCAT(M_PatientNIP,' / ',M_PatientDepartement) as baris_2_departement, M_PatientNIP, DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date, CorporateName FROM t_orderheader JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID JOIN mgm_mcu ON Mgm_McuID = T_OrderHeaderMgm_McuID JOIN corporate ON Mgm_McuCorporateID = CorporateID WHERE T_OrderHeaderIsActive = 'Y' AND T_OrderHeaderMgm_McuID = {$id} AND DATE(T_OrderHeaderDate) BETWEEN '{$start_date}' AND '{$end_date}' $filter"; // echo $sql; $qry = $this->db_smartone->query($sql); if ($qry) { $rows = $qry->result_array(); $count = 1; $loop_arr = []; foreach ($rows as $idx => $r) { $loop_arr[] = $r; if ($count == 2) { $rst[] = $loop_arr; $loop_arr = []; $count = 1; } else { if ($idx < count($rows) - 1) { $count = $count + 1; } else { $rst[] = $loop_arr; $count = $count + 1; } } } echo json_encode($rst); } else { echo json_encode(array()); } } function pribadi($id, $type) { //$id = So_ResultEntryID $sql = " select DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y') as T_OrderHeaderDate , T_OrderHeaderLabNumber , concat(M_TitleName ,'. ' , M_PatientName) as M_PatientName, if(M_PatientGender = 'male' , 'Laki-Laki' , 'Perempuan') as Gender, M_PatientNoReg, M_PatientDOB, T_OrderHeaderM_PatientAge, CorporateName, M_PatientAddress, M_PatientHp , M_PatientEmail, M_PatientAddressCity, M_PatientAddressState, CorporateAddress, CorporateEmail , CorporatePhone, CorporateAddressCity, CorporateAddressState, CONCAT(ifnull(pj .M_DoctorPrefix,''),' ',ifnull(pj .M_DoctorPrefix2,''),' ',pj .M_DoctorName,' ',ifnull(pj .M_DoctorSuffix,''),' ',ifnull(pj .M_DoctorSuffix2,'') ) AS M_DoctorName , CONCAT(DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') ,' / ',T_OrderHeaderM_PatientAge) AS Umur, NOW() as tanggalsekarang from so_resultentry join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID left join m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y' left join m_title ON M_PatientM_TitleID = M_TitleID AND M_TitleIsActive = 'Y' left join corporate on T_OrderHeaderCorporateID = CorporateID and CorporateIsActive = 'Y' left join m_doctorpj ON T_OrderHeaderPjM_DoctorID = M_DoctorPjID and M_DoctorPjIsDefaultPJ = 'Y' left join m_doctor pj ON So_ResultEntryM_DoctorID = pj .M_DoctorID AND pj .M_DoctorIsActive = 'Y' where So_ResultEntryID = ? and T_OrderHeaderIsActive = 'Y' and So_ResultEntryNonlab_TemplateName like '%Fisik%' "; $qry = $this->db_smartone->query($sql, array($id)); if ($qry) { $rows = $qry->result_array(); foreach ($rows as $idx => $r) { $rows[$idx]["kesimpulan"] = $this->kesimpulanv4($id, $langid); } echo json_encode($rows); } else { echo json_encode(array()); } } function phobia($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT POBIA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0) { return ""; } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $phobia = ""; //echo $d["title"] ; if ($d["title"] == "RIWAYAT POBIA") { if ($d["flag_normal"] == "Y") { $phobia = $d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $xd) { if ($xd["chx"] == "1") { if ($phobia != "") $phobia .= ", "; $phobia .= $xd["label"]; if ($xd["value"] != "") $phobia .= " (" . $xd["value"] . ")"; } } } } return $phobia; } function keluhan_saat_ini($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'KELUHAN SAAT INI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0) { return ""; } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $keluhan_saat_ini = ""; if ($d["title"] == "KELUHAN SAAT INI") { if ($d["flag_normal"] == "Y") { $keluhan_saat_ini = $d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $xd) { if ($xd["chx"] == "1") { if ($keluhan_saat_ini != "") $keluhan_saat_ini .= ", "; $keluhan_saat_ini .= $xd["label"]; } } } } return $keluhan_saat_ini; } function keluhan_saat_ini_new($id, $langid = 1, $type = "riwayat") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'KELUHAN SAAT INI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return ""; } // echo $this->db_smartone->last_query(); $rows = $qry->result_array(); if (count($rows) == 0) { return ""; } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //print_r($details); //keluhan saat ini $keluhan_saat_ini_new = array(); if ($d["title"] == "KELUHAN SAAT INI") { if ($d["flag_normal"] == "Y") { $keluhan_saat_ini_new = array(); //$d["label_flag_normal"]; } else { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $keluhan_saat_ini_new[] = array( "a1" => $gp["label"], "a2" => $gp["value"], ); } } } } echo json_encode($keluhan_saat_ini_new); } function riwayat_phobia($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT POBIA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $riwayat_phobia = array(); if ($d["title"] == "RIWAYAT POBIA") { if ($d["flag_normal"] == "Y") { $riwayat_phobia = array(); //$d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $riwayat_phobia[] = array( "b1" => $gp["label"], "b2" => $gp["value"], ); } } } } echo json_encode($riwayat_phobia); } function etnis($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'ETNIS' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $etnis = array(); //echo $d["title"]; if ($d["title"] == "ETNIS") { if ($d["flag_normal"] == "Y") { $etnis = array(); //$d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $etnis[] = array( "x1" => $gp["label"], "x2" => $gp["value"], ); } } } } echo json_encode($etnis); } function bodyfatmonitoring($id, $langid = 1, $type = "fisik") { $sql = " SELECT * FROM so_resultentry JOIN t_samplingso_additional_fisik_bbtb ON T_SamplingAdditionalFisikBBTBT_OrderHeaderID = So_ResultEntryT_OrderHeaderID WHERE So_ResultEntryID = ? AND So_ResultEntryIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = $rows[0]["T_SamplingAdditionalFisikBBTBBodyFat"]; //keluhan saat ini $bodyfat = array(); $bodyfat[] = array( "x1" => "Body Fat", "x2" => $d . "%" ); echo json_encode($bodyfat); } function riwayat_penyakit($id, $langid = 1, $type = "riwayat") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT PENYAKIT' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $riwayat_penyakit = array(); if ($d["title"] == "RIWAYAT PENYAKIT") { if ($d["flag_normal"] == "Y") { $riwayat_penyakit = array(); //$d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $gp) { foreach ($gp["details"] as $xd) { if ($xd["chx"] == 1) { $arr_result[] = array($xd["label"], $xd["value"], $xd["segment_name"], $xd["id"]); $riwayat_penyakit[] = array( "c1" => $xd["label"], "c2" => $xd["value"], "c3" => $xd["segment_name"], "c4" => $xd["id"] ); } } } } } echo json_encode($riwayat_penyakit); } function riwayat_keluarga($id, $langid = 1, $type = "riwayat") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT PENYAKIT KELUARGA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $riwayat_keluarga = array(); if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") { if ($d["flag_normal"] == "Y") { $riwayat_keluarga = array(); //$d["label_flag_normal"]; exit; } else { //print_r($d["details"]); foreach ($d["details"] as $gp) { if (true || $gp["chx"] == 1) { //print_r($gp["options"]); $arr_result[] = array($gp["label"], $gp["value"], $gp["id"]); foreach ($gp["options"] as $gpd) { if ($gpd["selected"] == 1) { $riwayat_keluarga[] = array( "d1" => $gp["label"], "d2" => $gpd["label"], "d3" => $gp["id"], ); } } } } } } echo json_encode($riwayat_keluarga); } function riwayat_hidup($id, $langid = 1, $type = "riwayat") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT KEBIASAAN HIDUP' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $riwayat_hidup = array(); if ($d["title"] == "RIWAYAT KEBIASAAN HIDUP") { if ($d["flag_normal"] == "Y") { $riwayat_hidup = array(); //$d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $gp) { foreach ($gp["details"] as $xd) { if ($xd["chx"] == 1) { $arr_result[] = array($xd["segment_name"], $xd["label"], $xd["value"]); if ($xd['id_code'] != 'fisik_kebiasaanhidup_4') { $riwayat_hidup[] = array( "e1" => $xd["segment_name"], "e2" => $xd["label"] . ' ' . $xd["value"], "e3" => $xd["value"], ); } else { $riwayat_hidup[] = array( "e1" => $xd["segment_name"], "e2" => $xd["label"] . ' ' . $xd["value"] . ' ' . $xd['suffix'], "e3" => $xd["value"], ); } } } } } } echo json_encode($riwayat_hidup); } function riwayat_obat($id, $langid = 1, $type = "riwayat") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT KONSUMSI OBAT TERATUR' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $riwayat_obat = array(); if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") { if ($d["flag_normal"] == "Y") { $riwayat_obat = array(); //$d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $riwayat_obat[] = array( "f1" => $gp["label"], "f2" => $gp["value"], ); } } } } echo json_encode($riwayat_obat); } function riwayat_imunisasi($id, $langid = 1, $type = "riwayat") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'RIWAYAT IMUNISASI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $riwayat_imunisasi = array(); if ($d["title"] == "RIWAYAT IMUNISASI") { if ($d["flag_normal"] == "Y") { $riwayat_imunisasi = array(); //$d["label_flag_normal"]; exit; } else { foreach ($d["details"] as $gp) { foreach ($gp["details"] as $xd) { if ($xd["chx"] == 1) { $arr_result[] = array($xd["segment_name"], $xd["label"], $xd["value"]); $riwayat_imunisasi[] = array( "g1" => $xd["segment_name"], "g2" => $xd["label"] . ' ' . $xd["value"], "g3" => $xd["value"], ); } } } } } echo json_encode($riwayat_imunisasi); } //pemeriksaan Fisik function tanda_vital($id, $langid = 1, $type = "fisik") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'TANDA VITAL' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $tanda_vital = array(); if ($d["title"] == "TANDA VITAL") { foreach ($d["details"] as $gp) { if ($gp['id_code'] != 'tanda_vital_5') { $value = $gp["value"] . ' ' . $gp["unit"]; if ($gp["chx_y"] == "1") $value = $gp["label_y"]; if ($gp["chx_x"] == "1") $value = $gp["label_x"] . ' ' . $gp["value"] . ' ' . $gp["unit"]; $tanda_vital[] = array( "aa1" => $gp["label"], "aa2" => $value, "aa3" => ucwords(strtolower($gp["value_x"])), ); } else { $kesimpulan = str_replace("Stadium", "Stage", $gp["value"]); $value = $gp["value_x"] . '/' . $gp["value_y"] . ' ' . $gp["unit"]; $tanda_vital[] = array( "aa1" => $gp["label"], "aa2" => $value, "aa3" => ucwords(strtolower($kesimpulan)), ); } } } echo json_encode($tanda_vital); } function status_gizi($id, $langid = 1, $type = "fisik") { $sql = "SELECT * FROM so_resultentry JOIN t_samplingso_additional_fisik_bbtb ON So_ResultEntryT_OrderHeaderID = T_SamplingAdditionalFisikBBTBT_OrderHeaderID WHERE So_ResultEntryID = $id LIMIT 1"; //echo $sql; $qry = $this->db_smartone->query($sql); if (! $qry) { return json_encode(array()); } //echo $this->db_smartone->last_query(); $row_result = $qry->row_array(); $status_gizi = array(); $bb = $row_result["T_SamplingAdditionalFisikBBTBValueBB"]; $tb = $row_result["T_SamplingAdditionalFisikBBTBValueTB"]; $bodyfat = $row_result["T_SamplingAdditionalFisikBBTBBodyFat"] == -1 ? "Tidak dilakukan" : $row_result["T_SamplingAdditionalFisikBBTBBodyFat"]; $standart_bmi = $row_result["T_SamplingAdditionalFisikBBTBStandart"]; $get_bmi = $this->hitung_bmi($bb, $tb, $standart_bmi); $bmi = $get_bmi['bmi']; $classification = $get_bmi['class']; $standart_text = ucwords(str_replace("_", " ", $standart_bmi)); $status_gizi[] = array( "qq1" => "Tinggi Badan", "qq2" => $tb, "qq3" => "", "qq4" => $standart_text, ); $status_gizi[] = array( "qq1" => "Berat Badan", "qq2" => $bb, "qq3" => "", "qq4" => $standart_text, ); $status_gizi[] = array( "qq1" => "Body Fat", "qq2" => $bodyfat, "qq3" => "", "qq4" => $standart_text, ); $status_gizi[] = array( "qq1" => "BMI (" . $standart_text . ")", "qq2" => $bmi, "qq3" => "", "qq4" => $standart_text, ); $status_gizi[] = array( "qq1" => "Klasifikasi", "qq2" => $classification, "qq3" => "", "qq4" => $standart_text, ); echo json_encode($status_gizi); } function lapang_pandang($id, $langid = 1, $type = "fisik") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'LAPANG PANDANG' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $lapang_pandang = array(); if ($d["title"] == "LAPANG PANDANG") { foreach ($d["details"] as $gp) { if ($gp["chx_y"] == "1") $value = $gp["label_y"]; if ($gp["chx_x"] == "1") $value = $gp["label_x"]; $lapang_pandang[] = array( "aa1" => $gp["label"], "aa2" => $value, "aa3" => "" ); } } echo json_encode($lapang_pandang); } function hitung_bmi($bb, $tb, $standart_bmi) { $tb = $tb / 100; $bmi = ''; $bmi = $bb / ($tb * $tb); $bmi_valuex = number_format($bmi, 2); $classs = "Undefined"; 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 keadaan_umum($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'KEADAAN UMUM' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $keadaan_umum = array(); if ($d["title"] == "KEADAAN UMUM") { foreach ($d["details"] as $gp) { $value = $gp["value"]; if ($gp["chx_x"] == "1") $value = $gp["label_x"]; if ($gp["chx_y"] == "1") $value = $gp["label_y"]; $keadaan_umum[] = array( "rr1" => $gp["label"], "rr2" => $value, "rr3" => $gp["unit"], ); } } echo json_encode($keadaan_umum); } function kepala_wajah($id, $langid = 1, $type = "fisik") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'KEPALA WAJAH' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $kepala_wajah = array(); if ($d["title"] == "KEPALA WAJAH") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $kepala_wajah[] = array( "bb1" => $gp["label"], "bb2" => $gp["value"], ); } } } if (empty($kepala_wajah)) { $kepala_wajah[] = array( "bb1" => "Tidak diperiksa", "bb2" => "", ); } echo json_encode($kepala_wajah); } function mata($id, $langid = 1, $type = "fisik") { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'MATA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $mata = array(); if ($d["title"] == "MATA") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $mata[] = array( "cc1" => $gp["label"], "cc2" => $gp["value"], ); } } } if (empty($mata)) { $mata[] = array( "cc1" => "Tidak diperiksa", "cc2" => "" ); } echo json_encode($mata); } function persepsi_warna($id, $langid = 1, $type = 'fisik') { $sql = "SELECT IFNULL(T_SamplingAdditionalFisikBWPWValue,'') as result, IFNULL(T_SamplingAdditionalFisikBWPWVAngka,'') as angka FROM so_resultentry LEFT JOIN t_samplingso_additional_fisik_bw ON T_SamplingAdditionalFisikBWT_OrderHeaderID = So_ResultEntryT_OrderHeaderID WHERE So_ResultEntryID = ? LIMIT 1 "; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $row_result = $qry->row_array(); //keluhan saat ini $persepsi_warna = array(); if ($row_result['result'] == '') { $persepsi_warna[] = array( "dd1" => 'Tidak diperiksa', "dd2" => '', ); } else { $result = "Normal"; if ($row_result['result'] == 'BW') $result = "Buta Warna (" . $row_result['angka'] . ")"; $persepsi_warna[] = array( "dd1" => $result, "dd2" => "", ); } echo json_encode($persepsi_warna); } function telinga($id, $langid = 1, $type = 'fisik') { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'TELINGA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $telinga = array(); if ($d["title"] == "TELINGA") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $telinga[] = array( "ee1" => $gp["label"], "ee2" => $gp["value"], ); } } } if (empty($telinga)) { $telinga[] = array( "ee1" => 'Tidak diperiksa', "ee2" => '' ); } echo json_encode($telinga); } function visus($id) { $sql = " SELECT * , IFNULL(T_SamplingAdditionalFisikVisusID,0) as visus_id FROM so_resultentry LEFT JOIN t_samplingso_additional_fisik_visus ON T_SamplingAdditionalFisikVisusT_OrderHeaderID = So_ResultEntryT_OrderHeaderID WHERE So_ResultEntryID = ? LIMIT 1"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $row_result = $qry->row_array(); $visus = array(); $visus_kiri = "Normal"; $visus_kanan = "Normal"; $normal = array("20/20", "20/25"); if (intval($row_result['visus_id']) == 0) { $visus[] = array( "xx1" => "Tidak diperiksa", "xx2" => "", "xx3" => "" ); } else { 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'] ); if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKODV'], $normal)) { $value_koreksi_od = ""; $od_sph = $row_result['T_SamplingAdditionalFisikVisusODSPH']; if ($od_sph != "") $value_koreksi_od .= "Sph (" . $od_sph . ") "; $od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL']; if ($od_cyl != "") $value_koreksi_od .= "Cyl (" . $od_cyl . ") "; $od_x = $row_result['T_SamplingAdditionalFisikVisusODX']; if ($od_x != "") $value_koreksi_od .= "X (" . $od_x . ") "; $visus[] = array( "xx1" => "Dengan Koreksi", "xx2" => "OD", "xx3" => $value_koreksi_od ); } if (!in_array($row_result['T_SamplingAdditionalFisikVisusTKOSV'], $normal)) { $value_koreksi_os = ""; $os_sph = $row_result['T_SamplingAdditionalFisikVisusOSSPH']; if ($os_sph != "") $value_koreksi_os .= "Sph (" . $os_sph . ") "; $os_cyl = $row_result['T_SamplingAdditionalFisikVisusOSCYL']; if ($os_cyl != "") $value_koreksi_os .= "Cyl (" . $os_cyl . ") "; $os_x = $row_result['T_SamplingAdditionalFisikVisusOSX']; if ($os_x != "") $value_koreksi_os .= "X (" . $os_x . ") "; $visus[] = array( "xx1" => "Dengan Koreksi", "xx2" => "OS", "xx3" => $value_koreksi_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'] ); if (!in_array($row_result['T_SamplingAdditionalFisikVisusDKODV'], $normal)) { $value_koreksi_od = ""; $od_sph = $row_result['T_SamplingAdditionalFisikVisusODSPH']; if ($od_sph != "") $value_koreksi_od .= "Sph (" . $od_sph . ") "; $od_cyl = $row_result['T_SamplingAdditionalFisikVisusODCYL']; if ($od_cyl != "") $value_koreksi_od .= "Cyl (" . $od_cyl . ") "; $od_x = $row_result['T_SamplingAdditionalFisikVisusODX']; if ($od_x != "") $value_koreksi_od .= "X (" . $od_x . ") "; $od_add = $row_result['T_SamplingAdditionalFisikVisusADD']; if ($od_add != "" && $od_add != "-") $value_koreksi_od .= "Add (" . $od_add . ") "; $visus[] = array( "xx1" => "Dengan Koreksi", "xx2" => "OD", "xx3" => $value_koreksi_od ); } $value_koreksi_os = ""; $os_sph = $row_result['T_SamplingAdditionalFisikVisusOSSPH']; if ($os_sph != "") $value_koreksi_os .= "Sph (" . $os_sph . ") "; $os_cyl = $row_result['T_SamplingAdditionalFisikVisusOSCYL']; if ($os_cyl != "") $value_koreksi_os .= "Cyl (" . $os_cyl . ") "; $os_x = $row_result['T_SamplingAdditionalFisikVisusOSX']; if ($os_x != "") $value_koreksi_os .= "X (" . $os_x . ") "; $od_add = $row_result['T_SamplingAdditionalFisikVisusADD']; if ($od_add != "" && $od_add != "-") $value_koreksi_os .= "Add (" . $od_add . ") "; $visus[] = array( "xx1" => "Dengan Koreksi", "xx2" => "OS", "xx3" => $value_koreksi_os ); } } echo json_encode($visus); } function hidung($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'HIDUNG' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $hidung = array(); if ($d["title"] == "HIDUNG") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $hidung[] = array( "ff1" => $gp["label"], "ff2" => $gp["value"], ); } } } if (empty($hidung)) { $hidung[] = array( "ff1" => 'Tidak diperiksa', "ff2" => '', ); } echo json_encode($hidung); } function gigi($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'GIGI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $hidung = array(); if ($d["title"] == "GIGI") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $gigi[] = array( "ff1" => $gp["label"], "ff2" => $gp["value"], ); } } } if (empty($gigi)) { $gigi[] = array( "ff1" => 'Tidak diperiksa', "ff2" => '', ); } echo json_encode($gigi); } function gigi_x($id) { $kode_gigi = array( "X" => "Berlubang", "C" => "Tambalan", "O" => "Tanggal", "R" => "Sisa akar", "A" => "Gigi Palsu", "K" => "Karang Gigi", "I" => "Impaksi" ); $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'GIGI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id, $langid, $type)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $db = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); $arr_gigi = array(); // $header = array('is_normal'=>'N'); if ($db["title"] != "GIGI") return false; if ($db["title"] == 'GIGI') { //print_r($db); $header = $db['is_normal']; } foreach ($db["details"] as $dx) { foreach ($dx["details"] as $dc) { $dc["value"] = strtoupper($dc["value"]); if ($dc["value"] != "" && isset($kode_gigi[$dc["value"]])) { //$value = $kode_gigi[$dc["value"]]; $value = $dc["value"]; if (! isset($arr_gigi[$value])) $arr_gigi[$value] = array(); $kode = $dc["id_code"]; $pos = substr($kode, -1); if (strpos($kode, "atas")) { if (strpos($kode, "kiri")) { $arr_gigi[$value][] = "└" . $pos; } else { $arr_gigi[$value][] = $pos . "┘"; } } else { if (strpos($kode, "kiri")) { $arr_gigi[$value][] = "┌" . $pos; } else { $arr_gigi[$value][] = $pos . "┐"; } } } } } //print_r($header); $gigi = array(); foreach ($arr_gigi as $v => $g) { $gigi[] = array("header" => $header, "gg1" => join($g, ", "), "gg2" => "", "gg3" => $v); } if (empty($gigi)) { $gigi[] = array("header" => $header); } echo json_encode($gigi); } function gigi_lama($id, $langid, $type) { $sql = "select * from so_resultentry_fisik_umum where So_ResultEntryFisikUmumSo_ResultEntryID= ? and So_ResultEntryFisikUmumM_LangID=? and So_ResultEntryFisikUmumType=?"; $qry = $this->db_smartone->query($sql, array($id, $langid, $type)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $gigi = array(); foreach ($details as $d) { if ($d["title"] == "GIGI") { foreach ($d["details"] as $gp) { foreach ($gp["details"] as $xd) { if ($xd["value"] <> '') { $arr_result[] = array($xd["id_code"], $xd["label"], $xd["value"]); $gigi[] = array( "gg1" => $xd["id_code"], "gg2" => $xd["label"], "gg3" => $xd["value"] ); } } } } } $gigi = array( array("gg1" => "+8, +7, +7, +8", "gg2" => "b", "gg3" => "O") ); echo json_encode($gigi); } function mulut($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'MULUT' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $mulut = array(); if ($d["title"] == "MULUT") { foreach ($d["details"] as $gp) { foreach ($gp["details"] as $xd) { if ($xd["chx"] == 1) { $arr_result[] = array($gp["name"], $xd["label"], $xd["value"]); $mulut[] = array( "hh1" => $gp["name"], "hh2" => $xd["label"], "hh3" => $xd["value"] ); } } } } if (empty($mulut)) { $mulut[] = array( "hh1" => 'Tidak diperiksa', "hh2" => '', "hh3" => '' ); } echo json_encode($mulut); } function leher($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'LEHER' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $leher = array(); if ($d["title"] == "LEHER") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $leher[] = array( "ii1" => $gp["label"], "ii2" => $gp["value"], ); } } } if (empty($leher)) { $leher[] = array( "ii1" => "Tidak diperiksa", "ii2" => "" ); } echo json_encode($leher); } function thorax($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'THORAX / DADA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $thorax = array(); if ($d["title"] == "THORAX / DADA") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $thorax[] = array( "jj1" => $gp["label"], "jj2" => $gp["value"], ); } } } if (empty($thorax)) { $thorax[] = array( "jj1" => "Tidak diperiksa", "jj2" => "" ); } echo json_encode($thorax); } function paru($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'PARU-PARU' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $paru = array(); if ($d["title"] == "PARU-PARU") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $paru[] = array( "kk1" => $gp["label"], "kk2" => $gp["value"], ); } } } if (empty($paru)) { $paru[] = array( "kk1" => "Tidak diperiksa", "kk2" => "" ); } echo json_encode($paru); } function jantung($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'JANTUNG' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $jantung = array(); if ($d["title"] == "JANTUNG") { foreach ($d["details"] as $gp) { foreach ($gp["details"] as $xd) { if ($xd["chx"] == 1) { $arr_result[] = array($gp["name"], $xd["label"], $xd["value"]); $jantung[] = array( "ll1" => $gp["name"], "ll2" => $xd["label"], "ll3" => $xd["value"] ); } } } } if (empty($jantung)) { $jantung[] = array( "ll1" => "Tidak diperiksa", "ll2" => "", "ll3" => "" ); } echo json_encode($jantung); } function perut($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'PERUT / ABDOMEN' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $perut = array(); if ($d["title"] == "PERUT / ABDOMEN") { foreach ($d["details"] as $gp) { if ($gp["name"] != 'Hernia' && $gp["name"] != 'Pengukuran') { foreach ($gp["details"] as $xd) { if ($xd["chx"] == 1) { $arr_result[] = array($gp["name"], $xd["label"], $xd["value"]); $perut[] = array( "mm1" => $gp["name"], "mm2" => $xd["label"], "mm3" => $xd["value"] ); } } } elseif ($gp["name"] == 'Hernia') { //print_r($gp["details"][1]); if ($gp["details"][1]["chx"] == "1") { $hasil = $gp["details"][1]["value"]; $hasil_detail = ""; //print_r($gp["details"][1]); if ($gp["details"][1]["details"][0]["chx_value"] == 1) { if ($hasil_detail != "") $hasil_detail .= ", "; $hasil_detail .= " " . $gp["details"][1]["details"][0]["label"]; } //print_r($gp["details"][1]["details"][1]); if ($gp["details"][1]["details"][1]["chx_a_value"] == 1 || $gp["details"][1]["details"][1]["chx_b_value"] == 1) { $ds_hasil = ""; if ($gp["details"][1]["details"][1]["chx_a_value"] == 1) { if ($ds_hasil != "") $ds_hasil .= ", "; $ds_hasil .= $gp["details"][1]["details"][1]["chx_a_label"]; } if ($gp["details"][1]["details"][1]["chx_b_value"] == 1) { if ($ds_hasil != "") $ds_hasil .= ", "; $ds_hasil .= $gp["details"][1]["details"][1]["chx_b_label"]; } if ($hasil_detail != "") $hasil_detail .= ", "; $hasil_detail .= " " . $gp["details"][1]["details"][1]["label"] . " (" . $ds_hasil . ")"; } if ($gp["details"][1]["details"][2]["chx_a_value"] == 1 || $gp["details"][1]["details"][2]["chx_b_value"] == 1) { $ds_hasil = ""; if ($gp["details"][1]["details"][2]["chx_a_value"] == 1) { if ($ds_hasil != "") $ds_hasil .= ", "; $ds_hasil .= $gp["details"][1]["details"][1]["chx_a_label"]; } if ($gp["details"][1]["details"][2]["chx_b_value"] == 1) { if ($ds_hasil != "") $ds_hasil .= ", "; $ds_hasil .= $gp["details"][1]["details"][2]["chx_b_label"]; } if ($hasil_detail != "") $hasil_detail .= ", "; $hasil_detail .= " " . $gp["details"][1]["details"][2]["label"] . " (" . $ds_hasil . ")"; } $perut[] = array( "mm1" => $gp["name"], "mm2" => $gp["details"][1]["label"], "mm3" => $hasil . $hasil_detail ); } if ($gp["details"][0]["chx"] == "1") { $perut[] = array( "mm1" => $gp["name"], "mm2" => $gp["details"][0]["label"], "mm3" => "" ); } } elseif ($gp["name"] == 'Pengukuran') { $perut[] = array( "mm1" => $gp["name"], "mm2" => $gp["details"][0]["label"] . " : " . $gp["details"][0]["value"] . " " . $gp["details"][0]["unit"], "mm3" => $gp["details"][1]["label"] . " : " . $gp["details"][1]["value"] . " " . $gp["details"][1]["unit"] ); } } } if (empty($perut)) { $perut[] = array( "mm1" => "Tidak diperiksa", "mm2" => "", "mm3" => "" ); } echo json_encode($perut); } function genitourinaria($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'GENITOURINARIA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $genitourinaria = array(); if ($d["title"] == "GENITOURINARIA") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $genitourinaria[] = array( "nn1" => $gp["label"], "nn2" => $gp["value"], ); } } } if (empty($genitourinaria)) { $genitourinaria[] = array( "nn1" => "Tidak diperiksa", "nn2" => "" ); } echo json_encode($genitourinaria); } function anggota($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'ANGGOTA GERAK' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $anggota = array(); if ($d["title"] == "ANGGOTA GERAK") { //WIP //echo "
"; print_r($d["details"]);
         foreach ($d["details"] as $gp) {
            foreach ($gp["details"] as $xd) {
               if ($xd["chx"] == 1) {
                  $arr_result[] = array($gp["name"], $xd["label"], $xd["value"]);
                  $anggota[] = array(
                     "oo1" => $gp["name"],
                     "oo2" => $xd["label"],
                     "oo3" => $xd["value"]
                  );
               }
            }
         }
      }

      if (empty($anggota)) {
         $anggota[] = array(
            "oo1" => "Tidak diperiksa",
            "oo2" => "",
            "oo3" => ""
         );
      }
      echo json_encode($anggota);
   }
   function sistem($id)
   {
      $sql = "SELECT * 
                  FROM so_resultentry_fisik_umum 
                  JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'SISTEM PERSYARAFAN'
                  WHERE
                  So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'";
      $qry = $this->db_smartone->query($sql, array($id));
      if (! $qry) {
         return json_encode(array());
      }
      $rows = $qry->result_array();
      if (count($rows) == 0) {
         return json_encode(array());
      }
      $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
      //keluhan saat ini
      $sistem = array();


      if ($d["title"] == "SISTEM PERSYARAFAN") {

         foreach ($d["details"] as $gp) {
            foreach ($gp["details"] as $xd) {
               if ($xd["chx"] == 1) {
                  $arr_result[] = array($gp["name"], $xd["label"], $xd["value"]);
                  $sistem[] = array(
                     "pp1" => $gp["name"],
                     "pp2" => $xd["label"],
                     "pp3" => $xd["value"]
                  );
               }
            }
         }
      }

      if (empty($sistem)) {
         $sistem[] = array(
            "pp1" => "Tidak diperiksa",
            "pp2" => "",
            "pp3" => ""
         );
      }
      echo json_encode($sistem);
   }


   function smell($id)
   {
      $sql = "SELECT * 
   FROM so_resultentry_fisik_umum 
   JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'SMELL TEST'
   WHERE
   So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'";
      $qry = $this->db_smartone->query($sql, array($id));
      if (! $qry) {
         return json_encode(array());
      }
      $rows = $qry->result_array();
      if (count($rows) == 0) {
         return json_encode(array());
      }
      $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
      //keluhan saat ini
      $smell = array();


      if ($d["title"] == "SMELL TEST") {

         foreach ($d["details"] as $gp) {
            foreach ($gp["details"] as $xd) {
               if ($xd["chx"] == 1) {
                  $arr_result[] = array($gp["name"], $xd["label"], $xd["value"], $d["inspected"]);
                  $smell[] = array(
                     "xx1" => $gp["name"],
                     "xx2" => $xd["label"],
                     "xx3" => $xd["value"],
                     "xx4" => $d["is_inspected"]

                  );
               }
            }
         }
      }

      if (empty($smell)) {
         $smell[] = array(
            "xx1" => "Tidak periksa",
            "xx2" => "",
            "xx3" => ""
         );
      }
      echo json_encode($smell);
   }


   function low($id)
   {
      $sql = "SELECT * 
   FROM so_resultentry_fisik_umum 
   JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'LOW BACK PAIN SCREENING TEST'
   WHERE
   So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'";
      $qry = $this->db_smartone->query($sql, array($id));
      if (! $qry) {
         return json_encode(array());
      }
      $rows = $qry->result_array();
      if (count($rows) == 0) {
         return json_encode(array());
      }
      $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
      //keluhan saat ini
      $low = array();


      if ($d["title"] == "LOW BACK PAIN SCREENING TEST") {

         foreach ($d["details"] as $gp) {
            foreach ($gp["details"] as $xd) {
               if ($xd["chx"] == 1) {
                  $arr_result[] = array($gp["name"], $xd["label"], $xd["value"], $d["is_inspected"]);
                  $low[] = array(
                     "yy1" => $gp["name"],
                     "yy2" => $xd["label"],
                     "yy3" => $xd["value"],
                     "yy4" => $d["is_inspected"]

                  );
               }
            }
         }
      }

      if (empty($low)) {
         $low[] = array(
            "yy1" => "Tidak periksa",
            "yy2" => "",
            "yy3" => ""
         );
      }
      echo json_encode($low);
   }



   function integumen($id)
   {
      $sql = "SELECT * 
                  FROM so_resultentry_fisik_umum 
                  JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'SISTEM INTEGUMEN'
                  WHERE
                  So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'";
      $qry = $this->db_smartone->query($sql, array($id));
      if (! $qry) {
         return json_encode(array());
      }
      $rows = $qry->result_array();
      if (count($rows) == 0) {
         return json_encode(array());
      }
      $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
      //keluhan saat ini
      $integumen = array();


      if ($d["title"] == "SISTEM INTEGUMEN") {

         foreach ($d["details"] as $gp) {
            foreach ($gp["details"] as $xd) {
               if ($xd["chx"] == 1) {
                  $arr_result[] = array($gp["name"], $xd["label"], $xd["value"]);
                  $integumen[] = array(
                     "pp1" => $gp["name"],
                     "pp2" => $xd["label"],
                     "pp3" => $xd["value"]
                  );
               }
            }
         }
      }

      if (empty($integumen)) {
         $integumen[] = array(
            "pp1" => "Tidak periksa",
            "pp2" => "",
            "pp3" => ""
         );
      }
      echo json_encode($integumen);
   }


   //end pemeriksaan fisik

   //saran
   //konsul

   function kesimpulan($id, $langid)
   {
      return "Ini adalah contoh kesimpulan dari pemeriksaan di atas.";
      /*      $sql = "select * from so_resultentry_fisik_umum
         where So_ResultEntryFisikUmumSo_ResultEntryID= ?
         and So_ResultEntryFisikUmumM_LangID=?
         and So_ResultEntryFisikUmumType=?";
      $qry = $this->db_smartone->query($sql,array($id,$langid,$type));
      $kesimpulan = "ada apa denganmu ";

      echo json_encode(array("abc" => $kesimpulan));
*/
   }

   function kesimpulanx($id, $langid)
   {

      $sql = "select * from so_resultentry_fisik_umum
         where So_ResultEntryFisikUmumSo_ResultEntryID= ?
         and So_ResultEntryFisikUmumM_LangID=?
         and So_ResultEntryFisikUmumType='fisik'";
      $qry = $this->db_smartone->query($sql, array($id, $langid));
      $rows = $qry->result_array();
      if (count($rows) == 0) return '';

      $data = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
      echo "
";
      print_r($data);
   }

   function kesimpulanv4($id)
   {
      $this->load->library('kesimpulanfisik');
      $kesimpulan = $this->kesimpulanfisik->kesimpulan($id);
      return $kesimpulan;
   }

   function xkesimpulanv4($id)
   {
      $kesimpulan = "";
      /*$sql = "SELECT *
				FROM so_resultentry_fisik_umum
				WHERE 
					So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
					So_ResultEntryFisikUmumM_LangID = ? AND
					So_ResultEntryFisikUmumType = 'riwayat'
				";
		$qry = $this->db_smartone->query($sql,array($id,$langid));
		$data_rows = $qry->result_array();
		if ( count($data_rows) == 0 ) return '';
		$riwayat_data = json_decode($data_rows[0]["So_ResultEntryFisikUmumDetails"],true);*/
      $sql = "SELECT *
				FROM fisik_template
            JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND So_ResultEntryFisikUmumSo_ResultEntryID = ?
				WHERE 
					FisikTemplateIsActive = 'Y' AND
					FisikTemplateType = 'Riwayat'
            ORDER BY FisikTemplateCode ASC
				";
      $qry = $this->db_smartone->query($sql, array($id));
      // echo $this->db_smartone->last_query();
      $xriwayats = $qry->result_array();
      $riwayat_data = [];
      foreach ($xriwayats as $key => $value) {
         $riwayat_data[] = json_decode($value['So_ResultEntryFisikUmumDetails'], true);
      }
      //print_r($riwayat_data);
      foreach ($riwayat_data as $riwayat_da) {
         //print_r($riwayat_da);
         //echo $riwayat_da["title"];
         if ($riwayat_da["title"] == "KELUHAN SAAT INI") {
            //print_r($riwayat_da["details"]);
            foreach ($riwayat_da["details"] as $riwayat_db) {
               if (($riwayat_db["chx"] == "1" || $riwayat_db["chx"] != false) && $riwayat_db["label"] == 'Gastritis (maag)') {
                  if ($kesimpulan != "") $kesimpulan .= ", ";
                  $kesimpulan .= $riwayat_db["label"] . " " . $riwayat_db["value"];
               }
            }
         }
      }

      $kode_gigi    =    array(
         "X" => "Berlubang",
         "C" => "Tambalan",
         "O" => "Tanggal",
         "R" => "Sisa akar",
         "A" => "Gigi Palsu",
         "K" => "Karang Gigi"
      );

      $sql = "SELECT *
      FROM fisik_template
      JOIN so_resultentry_fisik_umum ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND So_ResultEntryFisikUmumSo_ResultEntryID = ?
      JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
				JOIN t_orderheader ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
				JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
      WHERE 
         FisikTemplateIsActive = 'Y' AND
         FisikTemplateType = 'Fisik'
      ORDER BY FisikTemplateCode ASC
      ";
      $qry = $this->db_smartone->query($sql, array($id));
      // echo $this->db_smartone->last_query();
      $xfisiks = $qry->result_array();
      $fisik_data = [];
      foreach ($xfisiks as $kex => $valux) {
         $fisik_data[] = json_decode($valux['So_ResultEntryFisikUmumDetails'], true);
      }
      //print_r($fisik_data);
      /*$sql = "SELECT so_resultentry_fisik_umum.*, M_SexCode 
				FROM so_resultentry_fisik_umum
				JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
				JOIN t_orderheader ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
				JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
				JOIN m_sex ON M_PatientM_SexID = M_SexID
				WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ?
					AND So_ResultEntryFisikUmumM_LangID = ?
					AND So_ResultEntryFisikUmumType = 'fisik'";
		$qry = $this->db_smartone->query($sql,array($id,$langid));
		$rows = $qry->result_array();
		if ( count($rows) == 0 ) return '';
		$data = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
		*/

      $sexcode = $xfisiks[0]["M_PatientGender"] == 'male' ? 'L' : 'P';
      //echo $xfisiks[0]["M_PatientGender"];
      //echo $sexcode;
      //$data = $fisik_data;
      //echo json_encode($fisik_data);
      // echo $kesimpulan;
      foreach ($fisik_data as $da) {
         //echo $da["title"];
         if ($da["title"] == "TANDA VITAL") {
            foreach ($da["details"] as $db) {
               //print_r($db);
               if ($db["chx_x"] == "1") {
                  if ($kesimpulan != "") $kesimpulan .= ", ";
                  $kesimpulan .= $db["label"] . " " . $db["label_x"];
               }
               if ($db["id_code"] == "tanda_vital_1") {
                  //echo $db["value"];
                  if (intval($db["value"]) > 100) {
                     if ($kesimpulan != "") $kesimpulan .= ", ";
                     $kesimpulan .= "Takhikardi " . " ( " . $db["value"] . " x/menit )";
                  }
                  if (intval($db["value"]) < 60) {
                     if ($kesimpulan != "") $kesimpulan .= ", ";
                     $kesimpulan .= "Bradikardi " . " ( " . $db["value"] . " x/menit )";
                  }
               }
               if ($db["id_code"] == "tanda_vital_3") {
                  if (intval($db["value"]) > 20 || intval($db["value"]) < 16) {
                     if ($kesimpulan != "") $kesimpulan .= ", ";
                     $kesimpulan .= $db["label"] . " ( " . $db["value"] . " x/menit )";
                  }
               }
               if ($db["id_code"] == 'tanda_vital_5' && $db["value_x"] != 'NORMAL' && $db["value_x"] != 'OPTIMAL' && $db['value_x'] != 'HIGH NORMAL') {
                  if ($kesimpulan != "") $kesimpulan .= ", ";
                  $kesimpulan .= $db["label"] . " " . $db["value"] . " " . $db["unit"] . " ( " . ucwords(strtolower($db["value_x"])) . " )";
               }
            }
         } elseif ($da["title"] == "STATUS GIZI") {
            $bmi_value = "";

            //echo json_encode($da['details']);
            foreach ($da["details"] as $db) {

               if ($db["id_code"] == "status_gizi_4") $bmi_value = $db["value"];
               if ($db["chx_x"] == "1") {
                  if ($kesimpulan != "") $kesimpulan .= ", ";
                  $kesimpulan .= $db["label"] . " " . $db["label_x"];
               }
               if (($db["id_code"] == "status_gizi_6" && $db["value"] != "Normal" && $db["value"] != '-')) {
                  //echo $db["value"] ;
                  if ($kesimpulan != "") $kesimpulan .= ", ";
                  $kesimpulan .= $db["value"] . " ( BMI : $bmi_value )";

                  //echo $kesimpulan;
               }
               //echo $kesimpulan;
               if ($db["id_code"] == "status_gizi_3") {
                  if (intval($db["value"]) >= 90 && $sexcode == 'L') {
                     if ($kesimpulan != "") $kesimpulan .= ", ";
                     $kesimpulan .= $db["label"] . " " . " ( " . $db["value"] . " cm )";
                  }
                  if (intval($db["value"]) >= 80 && $sexcode == 'P') {
                     if ($kesimpulan != "") $kesimpulan .= ", ";
                     $kesimpulan .= $db["label"] . " " . " ( " . $db["value"] . " cm )";
                  }
               }
            }
         } elseif ($da["title"] == "KEADAAN UMUM") {
            foreach ($da["details"] as $db) {
               if ($db["chx_x"] == "1") {
                  if ($kesimpulan != "") $kesimpulan .= ", ";
                  $kesimpulan .= $db["label"] . " : ( " . $db["label_x"] . " ) " . $db["value"];
               }
            }
            //echo $kesimpulan;
         } elseif ($da["title"] == "KEPALA WAJAH") {
            //echo json_encode($da["details"]);
            $rst_x = '';
            foreach ($da["details"] as $db) {
               if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") {
                  if ($rst_x != "") $rst_x .= ", ";
                  $rst_x .= $db["label"] . " " . $db["value"];
               }
               if ($db["label"] == "Lain-lain" && $db["chx"] == "1") {
                  if ($rst_x != "") $rst_x .= ", ";
                  $rst_x .= $db["value"];
               }
            }
            //echo $kesimpulan;

            if ($rst_x !== '') {
               if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } //echo $kesimpulan; } elseif ($da["title"] == "MATA") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } //echo $kesimpulan; } elseif ($da["title"] == "PERSEPSI WARNA") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } //echo $kesimpulan; } elseif ($da["title"] == "VISUS JAUH") { $s_rst = ''; foreach ($da["details"] as $db) { $str_data = ""; $r_ods = ''; $xr_ods = array(); $kelainan = ''; foreach ($db['details'] as $dc) { if ($dc['chx'] == '1' && $dc['segment_name'] == 'Tanpa kacamata' && ($dc['value'] != '' && $dc['value'] != '6/6')) { $r_ods .= $dc['label'] . " : " . $dc['value'] . " "; array_push($xr_ods, $dc['value']); } if ($dc['chx'] == '1' && $dc['segment_name'] == 'Dengan kacamata' && $dc['value'] != '') { if ($dc['value'] != '6/6') $r_ods .= $dc['label'] . " : " . $dc['value'] . " "; array_push($r_ods); array_push($xr_ods, $dc['value']); } } //print_r($xr_ods); if (!empty($xr_ods)) { if ($db['name'] == 'Tanpa kacamata') { $kelainan = "Kelainan Refraksi"; $str_data .= $kelainan . " " . $db['name'] . " ( " . $r_ods . ")"; } if ($db['name'] == 'Dengan kacamata') { $all66 = true; foreach ($xr_ods as $xd => $xv) { if ($xv != '6/6') { $all66 = false; } } if ($all66) { $kelainan = "Kelainan Refraksi Terkoreksi"; } else { $kelainan = "Kelainan Refraksi"; } if ($r_ods != '') $str_data .= $kelainan . " " . $db['name'] . " ( " . $r_ods . ")"; else $str_data .= $kelainan . " " . $db['name']; } $s_rst .= $str_data; } //echo $str_data; } if ($s_rst != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $s_rst; } //echo $kesimpulan; } elseif ($da["title"] == "TELINGA") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } } elseif ($da["title"] == "HIDUNG") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } //echo $kesimpulan; } elseif ($da["title"] == "GIGI") { $arr_gigi = array(); foreach ($da["details"] as $db) { foreach ($db["details"] as $dc) { $dc["value"] = strtoupper($dc["value"]); if ($dc["value"] != "" && isset($kode_gigi[$dc["value"]])) { $value = $kode_gigi[$dc["value"]]; if (! isset($arr_gigi[$value])) $arr_gigi[$value] = array(); $kode = $dc["id_code"]; $pos = substr($kode, -1); if (strpos($kode, "atas")) { if (strpos($kode, "kiri")) { $arr_gigi[$value][] = "└" . $pos; } else { $arr_gigi[$value][] = $pos . "┘"; } } else { if (strpos($kode, "kiri")) { $arr_gigi[$value][] = "┌" . $pos; } else { $arr_gigi[$value][] = $pos . "┐"; } } } } } $r_gigi = ""; foreach ($arr_gigi as $v => $g) { if ($r_gigi != "") $r_gigi .= "
"; $r_gigi .= "" . $v . " " . join(",", $g) . ""; } //print_r($arr_gigi); //echo $r_gigi; if ($r_gigi != "") { if ($kesimpulan != "") $kesimpulan .= "
"; if ($kesimpulan != "") $kesimpulan .= "Gigi
"; $kesimpulan .= $r_gigi; } //echo $kesimpulan; } elseif ($da["title"] == "MULUT") { $s_rst = ''; foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["label"] . " " . $dc["label_x"] . " " . $dc["value"]; } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($s_rst != "") $s_rst .= "
"; $s_rst .= "" . $db["name"] . " : " . $s_res . ""; } } if ($s_rst != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= "" . ucwords(strtolower($da["title"])) . "
"; $kesimpulan .= $s_rst; } //echo $kesimpulan; } elseif ($da["title"] == "LEHER") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } } elseif ($da["title"] == "THORAX / DADA") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } //echo $kesimpulan; } elseif ($da["title"] == "PARU-PARU") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } } elseif ($da["title"] == "JANTUNG") { $s_rst = ''; foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= " ( " . $dc["label"] . " : " . $dc["label_x"] . " " . $dc["value"] . " )"; } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($s_rst != "") $s_rst .= "
"; $s_rst .= "" . $db["name"] . " : " . $s_res . ""; } } if ($s_rst != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . "
"; $kesimpulan .= $s_rst; } } elseif ($da["title"] == "PERUT / ABDOMEN") { foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain' && $dc['label'] != 'Tidak Ada') { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["label"] . " " . $dc["value"]; } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $db["name"] . " : " . $s_res; } } //echo $kesimpulan; } elseif ($da["title"] == "GENITOURINARIA") { $rst_x = ''; foreach ($da["details"] as $db) { if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Tidak diperiksa" && $db["label"] != "Lain-lain") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["label"] . " " . $db["value"]; } if ($db["label"] == "Lain-lain" && $db["chx"] == "1") { if ($rst_x != "") $rst_x .= ", "; $rst_x .= $db["value"]; } } if ($rst_x !== '') { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= ucwords(strtolower($da["title"])) . " : " . $rst_x; } } elseif ($da["title"] == "ANGGOTA GERAK") { foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= "( " . $dc["label"] . " ) " . $dc["value"]; /* perubahan 180320 */ } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $db["name"] . " : " . $s_res; } } } elseif ($da["title"] == "SISTEM PERSYARAFAN") { foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= "( " . $dc["label"] . " ) " . $dc["value"]; /* perubahan 180320 */ } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $db["name"] . " : " . $s_res; } } } elseif ($da["title"] == "SMELL TEST") { foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= "( " . $dc["label"] . " ) " . $dc["value"]; /* perubahan 180320 */ } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $db["name"] . " : " . $s_res; } } } elseif ($da["title"] == "LOW BACK PAIN SCREENING TEST") { foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= "( " . $dc["label"] . " ) " . $dc["value"]; /* perubahan 180320 */ } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $db["name"] . " : " . $s_res; } } //echo $kesimpulan; } elseif ($da["title"] == "SISTEM INTEGUMEN") { foreach ($da["details"] as $db) { $s_res = ""; foreach ($db["details"] as $dc) { if ($dc["chx"] == "1" && $dc["is_normal"] == "N" && $dc["label"] != 'Lain-lain') { if ($s_res != "") $s_res .= ", "; $s_res .= "( " . $dc["label"] . " ) " . $dc["value"]; } if ($dc["label"] == 'Lain-lain' && $dc["chx"] == "1") { if ($s_res != "") $s_res .= ", "; $s_res .= $dc["value"]; } } if ($s_res != "") { if ($kesimpulan != "") $kesimpulan .= "
"; $kesimpulan .= $db["name"] . " : " . $s_res; } } //echo $kesimpulan; } } if ($kesimpulan == "") { $kesimpulan = "Tidak ditemukan kelainan."; } else { $kesimpulan = "Pada saat ini didapatkan kelainan berupa :
" . $kesimpulan; } return $kesimpulan; } function kesimpulanv2($id, $langid) { $kode_gigi = array( "X" => "Berlubang", "C" => "Tambalan", "O" => "Tanggal", "R" => "Sisa akar", "A" => "Gigi Palsu", "K" => "Karang Gigi" ); $sql = "select * from so_resultentry_fisik_umum where So_ResultEntryFisikUmumSo_ResultEntryID= ? and So_ResultEntryFisikUmumM_LangID=? and So_ResultEntryFisikUmumType='fisik'"; $qry = $this->db_smartone->query($sql, array($id, $langid)); $rows = $qry->result_array(); if (count($rows) == 0) return ''; $data = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); $kesimpulan = ""; $arr_gigi = array(); foreach ($data as $obj) { if (isset($obj["details"])) { $dd = $obj["details"]; if (isset($dd["details"])) { if (isset($dh["chx_x"])) { if ($dh["chx_x"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["label_x"]; } } elseif (isset($dh["is_normal"])) { if ($dh["is_normal"] == "N" && $dh["chx"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } elseif (isset($dh["chx"])) { if ($dh["chx"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } } else { foreach ($dd as $dh) { if ($obj["type_form"] == "TOOTH") { foreach ($dh["details"] as $xd) { if ($xd["value"] != "") { if (! in_array($arr_gigi, $kode_gigi[$xd["value"]])) { $arr_gigi[] = $kode_gigi[$xd["value"]]; } } } } elseif (isset($dh["chx_x"])) { if ($dh["chx_x"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["label_x"]; } } elseif (isset($dh["is_normal"])) { if ($dh["is_normal"] == "N" && $dh["chx"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } elseif (isset($dh["chx"])) { if ($dh["chx"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } } } } } if ($kesimpulan == "") { $kesimpulan = "Dalam batas normal"; } else { $kesimpulan = "Pada saat ini di dapatkan kelainan berupa : \n$kesimpulan"; } if (count($arr_gigi) > 0) { $kesimpulan .= "\nGigi : " . join($arr_gigi); } else { $kesimpulan .= "\nGigi : normal."; } return $kesimpulan; } function kesimpulanv3($id, $langid) { $kode_gigi = array( "X" => "Berlubang", "C" => "Tambalan", "O" => "Tanggal", "R" => "Sisa akar", "A" => "Gigi Palsu", "K" => "Karang Gigi" ); $sql = "select * from so_resultentry_fisik_umum where So_ResultEntryFisikUmumSo_ResultEntryID= ? and So_ResultEntryFisikUmumM_LangID=? and So_ResultEntryFisikUmumType='fisik'"; $qry = $this->db_smartone->query($sql, array($id, $langid)); $rows = $qry->result_array(); if (count($rows) == 0) return ''; $data = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); $kesimpulan = ""; $arr_gigi = array(); foreach ($data as $obj) { if (isset($obj["details"])) { $dd = $obj["details"]; if (isset($dd["details"])) { if (isset($dh["chx_x"])) { if ($dh["chx_x"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["label_x"]; } } elseif (isset($dh["is_normal"])) { if ($dh["is_normal"] == "N") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } elseif (isset($dh["chx"])) { if ($dh["chx"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } } else { foreach ($dd as $dh) { if ($obj["type_form"] == "TOOTH") { foreach ($dh["details"] as $xd) { if ($xd["value"] != "") { if (! in_array($arr_gigi, $kode_gigi[$xd["value"]])) { $arr_gigi[] = $kode_gigi[$xd["value"]]; } } } } elseif (isset($dh["chx_x"])) { if ($dh["chx_x"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["label_x"]; } } elseif (isset($dh["is_normal"])) { if ($dh["is_normal"] == "N") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } elseif (isset($dh["chx"])) { if ($dh["chx"] == "1") { if ($kesimpulan != "") $kesimpulan .= ", "; $kesimpulan .= $dh["label"] . " " . $dh["value"]; } } } } } } if ($kesimpulan == "") { $kesimpulan = "Dalam batas normal"; } else { $kesimpulan = "Pada saat ini di dapatkan kelainan berupa : \n$kesimpulan"; } if (count($arr_gigi) > 0) { $kesimpulan .= "\nGigi : " . join($arr_gigi); } return $kesimpulan; } function saran($id, $langid) { $sql = "select * from so_resultentry_fisik_umum where So_ResultEntryFisikUmumSo_ResultEntryID= ? and So_ResultEntryFisikUmumM_LangID=? and So_ResultEntryFisikUmumType='saran'"; $qry = $this->db_smartone->query($sql, array($id, $langid)); $saran = ""; $rows = $qry->result_array(); if (count($rows) > 0) { $saran = $rows[0]["So_ResultEntryFisikUmumDetails"]; } echo json_encode(array("saran" => $saran)); } function konsul($id, $langid) { $sql = "select * from so_resultentry_fisik_umum where So_ResultEntryFisikUmumSo_ResultEntryID= ? and So_ResultEntryFisikUmumM_LangID=? and So_ResultEntryFisikUmumType='konsul'"; $qry = $this->db_smartone->query($sql, array($id, $langid)); $rows = $qry->result_array(); if (count($rows) > 0) { $konsul = $rows[0]["So_ResultEntryFisikUmumDetails"]; } echo json_encode(array("konsul" => $konsul)); } //k3 function faktor_fisik($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'FAKTOR FISIK' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $faktor_fisik = array(); if ($d["title"] == "FAKTOR FISIK") { foreach ($d["details"] as $gp) { // if ($gp["chx"] == 1 ) { $arr_result[] = array($gp["label"], $gp["value_sumber"], $gp["value_lama"], $gp["chx"]); $faktor_fisik[] = array( "aaa1" => $gp["label"], "aaa2" => $gp["value_sumber"], "aaa3" => $gp["value_lama"], "aaa4" => $gp["chx"] ); // } } } echo json_encode($faktor_fisik); } function faktor_kimia($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'FAKTOR KIMIA' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $faktor_kimia = array(); if ($d["title"] == "FAKTOR KIMIA") { foreach ($d["details"] as $gp) { // if ($gp["chx"] == 1 ) { $arr_result[] = array($gp["label"], $gp["value_sumber"], $gp["value_lama"], $gp["chx"]); $faktor_kimia[] = array( "bbb1" => $gp["label"], "bbb2" => $gp["value_sumber"], "bbb3" => $gp["value_lama"], "bbb4" => $gp["chx"] ); // } } } echo json_encode($faktor_kimia); } function faktor_biologi($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'FAKTOR BIOLOGI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $faktor_biologi = array(); if ($d["title"] == "FAKTOR BIOLOGI") { foreach ($d["details"] as $gp) { // if ($gp["chx"] == 1 ) { $arr_result[] = array($gp["label"], $gp["value_sumber"], $gp["value_lama"], $gp["chx"]); $faktor_biologi[] = array( "ccc1" => $gp["label"], "ccc2" => $gp["value_sumber"], "ccc3" => $gp["value_lama"], "ccc4" => $gp["chx"] ); // } } } echo json_encode($faktor_biologi); } function faktor_ergonomi($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'FAKTOR ERGONOMI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $faktor_ergonomi = array(); if ($d["title"] == "FAKTOR ERGONOMI") { foreach ($d["details"] as $gp) { // if ($gp["chx"] == 1 ) { $arr_result[] = array($gp["label"], $gp["value_sumber"], $gp["value_lama"], $gp["chx"]); $faktor_ergonomi[] = array( "ddd1" => $gp["label"], "ddd2" => $gp["value_sumber"], "ddd3" => $gp["value_lama"], "ddd4" => $gp["chx"] ); // } } } echo json_encode($faktor_ergonomi); } function faktor_psikologi($id) { $sql = "SELECT * FROM so_resultentry_fisik_umum JOIN fisik_template ON So_ResultEntryFisikUmumFisikTemplateID = FisikTemplateID AND FisikTemplateIsActive = 'Y' AND FisikTemplateTitle = 'FAKTOR PSIKOLOGI' WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ? AND So_ResultEntryFisikUmumIsActive = 'Y'"; $qry = $this->db_smartone->query($sql, array($id)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $d = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $faktor_psikologi = array(); if ($d["title"] == "FAKTOR PSIKOLOGI") { foreach ($d["details"] as $gp) { $arr_result[] = array($gp["label"], $gp["value_sumber"], $gp["value_lama"], $gp["chx"]); $faktor_psikologi[] = array( "eee1" => $gp["label"], "eee2" => $gp["value_sumber"], "eee3" => $gp["value_lama"], "eee4" => $gp["chx"] ); } } echo json_encode($faktor_psikologi); } //k3 function kesimpulanx2($id, $langid, $type) { $sql = "select * from so_resultentry_fisik_umum where So_ResultEntryFisikUmumSo_ResultEntryID= ? and So_ResultEntryFisikUmumM_LangID=? and So_ResultEntryFisikUmumType=?"; $qry = $this->db_smartone->query($sql, array($id, $langid, $type)); if (! $qry) { return json_encode(array()); } $rows = $qry->result_array(); if (count($rows) == 0) { return json_encode(array()); } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true); //keluhan saat ini $kesimpulanx = array("asdasdasdasdasd"); foreach ($details as $d) { if ($d["title"] == "") { foreach ($d["details"] as $gp) { if ($gp["chx"] == 1) { $arr_result[] = array($gp["label"], $gp["value"]); $kesimpulanx[] = array( "nn1" => $gp["label"], "nn2" => $gp["value"] ); } } } } echo json_encode(array("abc" => $kesimpulanx)); } function list() { $sql = "select * from m_religion"; $qry = $this->db_smartone->query($sql); if ($qry) { $rows = $qry->result_array(); echo json_encode($rows); } else { echo json_encode(array()); } } function get($id) { $sql = "select * from m_religion where M_ReligionID=?"; $qry = $this->db_smartone->query($sql, $id); if ($qry) { $rows = $qry->result_array(); echo json_encode($rows); } else { echo json_encode(array()); } } }