db_smartone = $this->load->database("onedev", true); } function pribadi($id,$langid) { //$id = So_ResultEntryID $sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName, T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo, T_OrderHeaderM_PatientAge, date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB , date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate, M_SexName, (SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID left join m_district on M_KelurahanM_DistrictID = M_DistrictID left join m_city on M_DistrictM_CityID = M_CityID WHERE M_PatientAddressM_PatientID = M_PatientID ORDER BY M_PatientAddressM_PatientID LIMIT 1) AS M_PatientAddressDescription from so_resultentry join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryID = ? join m_patient on M_PatientID = T_OrderHeaderM_PatientID join m_title on M_PatientM_TitleID = M_TitleID left join m_sex on M_PatientM_SexID = M_SexID "; $qry = $this->db_smartone->query($sql,array($id)); if ($qry) { $rows = $qry->result_array(); foreach($rows as $idx => $r ) { $rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid); $rows[$idx]["phobia"] = $this->phobia($id,$langid); } echo json_encode($rows); } else { echo json_encode(array()); } } function phobia($id,$langid) { $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)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0 ) { return ""; } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true); //keluhan saat ini $phobia = ""; foreach($details as $d) { if ($d["title"] == "RIWAYAT POBIA") { if ($d["flag_normal"] == "Y") { $phobia = $d["label_flag_normal"]; break; } 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,$langid) { $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)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0 ) { return ""; } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true); //keluhan saat ini $keluhan_saat_ini = ""; foreach($details as $d) { if ($d["title"] == "KELUHAN SAAT INI") { if ($d["flag_normal"] == "Y") { $keluhan_saat_ini = $d["label_flag_normal"]; break; } 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 riwayat_penyakit($id,$langid) { $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)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0 ) { return ""; } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true); //keluhan saat ini $riwayat_penyakit = array(); foreach($details as $d) { if ($d["title"] == "RIWAYAT PENYAKIT") { if ($d["flag_normal"] == "Y") { $riwayat_penyakit = $d["label_flag_normal"]; break; } else { $prev_group = ""; $chex_group = array(); $tot_baris= 0; $arr_result = array(); foreach($d["details"] as $gp) { $group = $gp["name"]; if ($group == "Allergi" ) continue; $have_detail = false; foreach($gp["details"] as $xd ) { if ($xd["chx"] == 1 ) { $have_detail = true; } } if ($have_detail) { $arr_result[] = array($group, "", "","") ; foreach($gp["details"] as $xd ) { if ($xd["chx"] == 1 ) { $arr_result[] = array($xd["label"], "X", "",$xd["value"]) ; } } } } $tot_baris = ceil( count($arr_result) / 2 ) ; for($i=0; $i < $tot_baris ; $i++) { $left = $arr_result[$i]; $right = array("","","",""); if ( isset($arr_result[$i+$tot_baris]) ) { $right = $arr_result[$i+$tot_baris]; } $riwayat_penyakit[] = array( "c1" => $left[0], "c2" => $left[1], "c3" => $left[2], "c4" => $left[3], "c5" => $right[0], "c6" => $right[1], "c7" => $right[2], "c8" => $right[3], ); } } } } echo json_encode($riwayat_penyakit); //return ($riwayat_penyakit); } //riwayat penyakit keluarga function penyakit_keluarga($id,$langid) { $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)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0 ) { return ""; } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true); //keluhan saat ini $penyakit_keluarga = array(); foreach($details as $d) { if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") { if ($d["flag_normal"] == "Y") { $penyakit_keluarga = $d["label_flag_normal"]; break; } else { $prev_group = ""; $chex_group = array(); $tot_baris= 0; $arr_result = array(); foreach($d["details"] as $gp) { if ($gp["chx"] == 1 ) { $arr_result[] = array($gp["label"], "X", "",$gp["value"]) ; } } $tot_baris = ceil( count($arr_result) / 2 ) ; for($i=0; $i < $tot_baris ; $i++) { $left = $arr_result[$i]; $right = array("","","",""); if ( isset($arr_result[$i+$tot_baris]) ) { $right = $arr_result[$i+$tot_baris]; } $penyakit_keluarga[] = array( "d1" => $left[0], "d2" => $left[1], "d3" => $left[2], "d4" => $left[3], "d5" => $right[0], "d6" => $right[1], "d7" => $right[2], "d8" => $right[3], ); } } } } echo json_encode($penyakit_keluarga); //return ($penyakit_keluarga); } function riwayat_alergi($id,$langid) { $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)); if (! $qry) { return ""; } $rows = $qry->result_array(); if (count($rows) == 0 ) { return ""; } $details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true); //keluhan saat ini $riwayat_alergi = array(); foreach($details as $d) { if ($d["title"] == "RIWAYAT PENYAKIT") { if ($d["flag_normal"] == "Y") { $riwayat_alergi = $d["label_flag_normal"]; break; } else { $prev_group = ""; $chex_group = array(); $tot_baris= 0; $arr_result = array(); foreach($d["details"] as $gp) { $group = $gp["name"]; if ($group != "Allergi" ) continue; foreach($gp["details"] as $xd ) { if ($xd["chx"] == 1 ) { $arr_result = array($xd["label"], "Ya", "",$xd["value"]) ; } else { $arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ; } $riwayat_alergi[] = array( "a1" => $arr_result[0], "a2" => $arr_result[1], "a3" => $arr_result[2], "a4" => $arr_result[3], ); } } } } } echo json_encode($riwayat_alergi); } function riwayat_obat($id,$langid) { $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)); 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 $riwayat_obat = array(); foreach($details as $d) { if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") { if ($d["flag_normal"] == "Y") { $riwayat_obat = $d["label_flag_normal"]; break; } else { foreach($d["details"] as $gp) { if ($gp["chx"] == 1 ) { $arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ; $riwayat_obat[] = array( "o1" => $gp["label"], "o2" => "Ya", "o3" => $gp["value"], ); } } } } } echo json_encode($riwayat_obat); } 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()); } } } ?>