394 lines
12 KiB
PHP
394 lines
12 KiB
PHP
<?php
|
|
class Checkfisikresult extends MY_Controller
|
|
{
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->db_one = $this->load->database("onedev", true);
|
|
$this->load->library("Genresultfisik");
|
|
// Inject koneksi DB onedev ke library (data so_* ada di onedev, bukan "default")
|
|
$this->genresultfisik->db_smartone = $this->db_one;
|
|
}
|
|
|
|
/**
|
|
* Endpoint sederhana untuk mengecek satu fungsi di Genresultfisik.
|
|
*
|
|
* Cara pakai (contoh, via browser / Postman):
|
|
* /v1/su/Checkfisikresult/check?id=123&method=keluhan_saat_ini
|
|
*
|
|
* Param:
|
|
* - id : So_ResultEntryID / OrderID yang akan dicek
|
|
* - method : nama fungsi di Genresultfisik (misal: keluhan_saat_ini, riwayat_penyakit, bodyfatmonitoring, dll)
|
|
* - langid : (opsional) bahasa, default 1
|
|
*/
|
|
|
|
/*
|
|
|
|
|
|
['keluhan_saat_ini' => 'STRING',
|
|
'riwayat_phobia' => 'STRING',
|
|
'bodyfatmonitoring' => 'STRING',
|
|
'riwayat_penyakit' => 'STRING',
|
|
'alergi' => 'STRING',
|
|
'riwayat_penyakit_keluarga' => {'rpk_ayah' => 'STRING', 'rpk_ibu' => 'STRING'},
|
|
'merokok' => 'STRING',
|
|
'alkohol' => 'STRING',
|
|
'olahraga' => 'STRING',
|
|
'riwayat_obat' => 'STRING',
|
|
'riwayat_imunisasi' => 'STRING',
|
|
'tekanan_darah' => {
|
|
"<key_data_sistolik>": "120 mmHg",
|
|
"<key_data_diastolik>": "80 mmHg",
|
|
"standart_tensi": "...",
|
|
"conclusion_tensi": "Prehipertensi"
|
|
}, // assoc — tiap key = key_data dari so_resultentry_fisik_umum
|
|
'laju_pernafasan' => '14 x\/menit',
|
|
'denyut_nadi' => '12 x\/menit',
|
|
'suhu' => 'Afebrile',
|
|
'ritme_denyut_nadi' => 'Reguler',
|
|
'pola_nafas' => 'Normal',
|
|
'status_gizi' => {
|
|
"TB": "169 cm",
|
|
"BB": "50 kg",
|
|
"BodyFat": "20%",
|
|
"BMI": "17.51 Underweight",
|
|
"Standart": "Asia Pacific"
|
|
},
|
|
'lapang_pandang' => 'STRING',
|
|
'keadaan_umum' => [
|
|
{
|
|
"label": "Kesadaran",
|
|
"value": "Normal "
|
|
},
|
|
{
|
|
"label": "Sikap & tingkah laku",
|
|
"value": "Normal "
|
|
},
|
|
{
|
|
"label": "Kontak psikis \/ perhatian",
|
|
"value": "Normal "
|
|
}
|
|
],
|
|
'kepala_wajah' => 'STRING',
|
|
'persepsi_warna' => 'STRING',
|
|
'doctor' => 'STRING',
|
|
'konjuktiva_sklera' => 'STRING',
|
|
'telinga' => 'STRING',
|
|
'visus_left' => 'STRING',
|
|
'visus_right' => 'STRING',
|
|
'hidung' => 'STRING',
|
|
'leher' => 'STRING',
|
|
'thorax' => 'STRING',
|
|
'mulut'=>'STRING',
|
|
'tenggorokan'=>'STRING',
|
|
'paru'=>'STRING',
|
|
'jantung'=>'STRING',
|
|
'anogenital'=>'STRING',
|
|
'pengukuran'=> {
|
|
"lingkar_perut": "120 cm",
|
|
"lingkar_pinggang": "92 cm"
|
|
},
|
|
'tonometri'=> 'STRING',
|
|
'perut'=>'STRING',
|
|
'ginjal'=>'STRING',
|
|
'hernia'=>'STRING',
|
|
'anogenital'=>'STRING',
|
|
'perut':'STRING',
|
|
'kulit'=>'STRING',
|
|
'reflek'=> {
|
|
"Refleks_Fisiologis": "Normal",
|
|
"Refleks_Pathologis": "Laseque Test : Positif, Bragard Test : Negatif, Patrick Test : Positif, Kontra Patrick : Positif, Tinnel Test : Negatif, Phalen Test : Negatif, Tremor Test : Negatif"
|
|
},
|
|
'romberg'=>'STRING',
|
|
'genitourinaria' => 'STRING',
|
|
'anggota_gerak' => 'STRING',
|
|
'sistem_persyarafan' => {
|
|
"Refleks_Fisiologis": "Normal",
|
|
"Refleks_Pathologis": "Negatif",
|
|
"Refleks_Neurologis_Lainnya": "Tidak ada"
|
|
},
|
|
'smell_test' => 'STRING',
|
|
'rectum_urogenital' => 'STRING',
|
|
'faktor_fisik' => 'STRING',
|
|
'faktor_kimia' => 'STRING',
|
|
'faktor_biologi' => 'STRING',
|
|
'faktor_ergonomi' => 'STRING',
|
|
'faktor_psikologi' => 'STRING'
|
|
]
|
|
*/
|
|
public function check()
|
|
{
|
|
$id = $this->input->get("id");
|
|
$method = $this->input->get("method");
|
|
$langid = $this->input->get("langid");
|
|
$type = $this->input->get("type");
|
|
|
|
if ($langid === null || $langid === "") {
|
|
$langid = 1;
|
|
}
|
|
|
|
if (empty($id) || empty($method)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Parameter 'id' dan 'method' wajib diisi",
|
|
]));
|
|
}
|
|
|
|
// Pastikan library ter-load dan method ada
|
|
if (!isset($this->genresultfisik) || !is_object($this->genresultfisik)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Library Genresultfisik tidak tersedia",
|
|
]));
|
|
}
|
|
|
|
if (!method_exists($this->genresultfisik, $method)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Method '{$method}' tidak ditemukan di Genresultfisik",
|
|
]));
|
|
}
|
|
|
|
// Coba panggil fungsi dengan beberapa pola parameter yang umum dipakai di Genresultfisik
|
|
try {
|
|
// Pola paling sering: (id, langid)
|
|
$result = null;
|
|
|
|
// Khusus method visus: dukung parameter type dari query (?type=left/right)
|
|
if ($method === "visus") {
|
|
if ($type === null || $type === "") {
|
|
$type = "fisik";
|
|
}
|
|
|
|
// Signature saat ini: visus($id, $type, $langid = 1)
|
|
$result = $this->genresultfisik->visus($id, $type, $langid);
|
|
}
|
|
else {
|
|
// Coba (id, langid, 'fisik') jika method menerima 3 argumen
|
|
$refMethod = new ReflectionMethod($this->genresultfisik, $method);
|
|
$paramCount = $refMethod->getNumberOfParameters();
|
|
|
|
if ($paramCount === 1) {
|
|
$result = $this->genresultfisik->{$method}($id);
|
|
} elseif ($paramCount === 2) {
|
|
$result = $this->genresultfisik->{$method}($id, $langid);
|
|
} elseif ($paramCount >= 3) {
|
|
// Asumsi umum di file: (id, langid, type)
|
|
$result = $this->genresultfisik->{$method}($id, $langid, "fisik");
|
|
} else {
|
|
// Tidak didukung skenarionya
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Jumlah parameter method '{$method}' tidak didukung untuk auto-check",
|
|
"param_count" => $paramCount,
|
|
]));
|
|
}
|
|
}
|
|
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => true,
|
|
"method" => $method,
|
|
"id" => $id,
|
|
"langid" => $langid,
|
|
"result" => $result,
|
|
]));
|
|
} catch (Throwable $e) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Terjadi error saat eksekusi method",
|
|
"error" => $e->getMessage(),
|
|
]));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Endpoint untuk menjalankan SEMUA fungsi publik di Genresultfisik
|
|
* (kecuali constructor, helper internal tertentu) untuk satu ID.
|
|
*
|
|
* Cara pakai:
|
|
* /v1/su/Checkfisikresult/check_all?id=123&langid=1
|
|
*/
|
|
public function check_all()
|
|
{
|
|
$id = $this->input->get("id");
|
|
$langid = $this->input->get("langid");
|
|
|
|
if ($langid === null || $langid === "") {
|
|
$langid = 1;
|
|
}
|
|
|
|
if (empty($id)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Parameter 'id' wajib diisi",
|
|
]));
|
|
}
|
|
|
|
if (!isset($this->genresultfisik) || !is_object($this->genresultfisik)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Library Genresultfisik tidak tersedia",
|
|
]));
|
|
}
|
|
|
|
$className = get_class($this->genresultfisik);
|
|
$refClass = new ReflectionClass($className);
|
|
$methods = $refClass->getMethods(ReflectionMethod::IS_PUBLIC);
|
|
|
|
// Daftar nama method yang TIDAK akan dieksekusi otomatis
|
|
// (constructor, helper internal, dan method yang memodifikasi data)
|
|
$exclude = [
|
|
"__construct",
|
|
"clean_mysqli_connection",
|
|
"save_result_fisik_umum", // memodifikasi DB — gunakan endpoint check_save
|
|
"update_unvalidated", // memodifikasi DB
|
|
];
|
|
|
|
$results = [];
|
|
|
|
foreach ($methods as $m) {
|
|
$name = $m->getName();
|
|
|
|
// Skip method-method tertentu
|
|
if (in_array($name, $exclude, true)) {
|
|
continue;
|
|
}
|
|
|
|
// Pastikan method milik class Genresultfisik (bukan turunan dari parent / CI)
|
|
if ($m->getDeclaringClass()->getName() !== $className) {
|
|
continue;
|
|
}
|
|
|
|
$paramCount = $m->getNumberOfParameters();
|
|
|
|
try {
|
|
if ($paramCount === 0) {
|
|
// Tidak ada parameter, panggil tanpa argumen
|
|
$result = $this->genresultfisik->{$name}();
|
|
} elseif ($paramCount === 1) {
|
|
$result = $this->genresultfisik->{$name}($id);
|
|
} elseif ($paramCount === 2) {
|
|
$result = $this->genresultfisik->{$name}($id, $langid);
|
|
} elseif ($paramCount >= 3) {
|
|
// Asumsi pola umum: (id, langid, "fisik")
|
|
$result = $this->genresultfisik->{$name}($id, $langid, "fisik");
|
|
} else {
|
|
$results[$name] = [
|
|
"ok" => false,
|
|
"error" => "Jumlah parameter tidak didukung untuk auto-check",
|
|
"param_count" => $paramCount,
|
|
];
|
|
continue;
|
|
}
|
|
|
|
$results[$name] = [
|
|
"ok" => true,
|
|
"param_count" => $paramCount,
|
|
"result" => $result,
|
|
];
|
|
} catch (Throwable $e) {
|
|
$results[$name] = [
|
|
"ok" => false,
|
|
"param_count" => $paramCount,
|
|
"error" => $e->getMessage(),
|
|
];
|
|
}
|
|
}
|
|
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => true,
|
|
"id" => $id,
|
|
"langid" => $langid,
|
|
"results" => $results,
|
|
]));
|
|
}
|
|
|
|
/**
|
|
* Endpoint khusus untuk menguji save_result_fisik_umum termasuk
|
|
* kolom ResultFisikUmumT_OrderHeaderDate yang baru.
|
|
*
|
|
* Cara pakai:
|
|
* /v1/su/Checkfisikresult/check_save?id=123&langid=1
|
|
*
|
|
* Param:
|
|
* - id : OrderHeaderID (So_ResultEntryID / OrderHeaderID)
|
|
* - langid : (opsional) bahasa, default 1
|
|
*/
|
|
public function check_save()
|
|
{
|
|
$id = $this->input->get("id");
|
|
$langid = $this->input->get("langid");
|
|
|
|
if ($langid === null || $langid === "") {
|
|
$langid = 1;
|
|
}
|
|
|
|
if (empty($id)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Parameter 'id' wajib diisi",
|
|
]));
|
|
}
|
|
|
|
if (!isset($this->genresultfisik) || !is_object($this->genresultfisik)) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Library Genresultfisik tidak tersedia",
|
|
]));
|
|
}
|
|
|
|
try {
|
|
$result = $this->genresultfisik->save_result_fisik_umum($id, $langid);
|
|
|
|
// Setelah save, ambil baris yang baru disimpan untuk verifikasi
|
|
$saved_rows = $this->db_one
|
|
->where("ResultFisikUmumOrderHeaderID", $id)
|
|
->order_by("ResultFisikUmumID", "DESC")
|
|
->limit(20)
|
|
->get("result_fisik_umum")
|
|
->result_array();
|
|
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => true,
|
|
"id" => $id,
|
|
"langid" => $langid,
|
|
"save_result" => $result,
|
|
"saved_rows" => $saved_rows,
|
|
]));
|
|
} catch (Throwable $e) {
|
|
return $this->output
|
|
->set_content_type("application/json")
|
|
->set_output(json_encode([
|
|
"success" => false,
|
|
"message" => "Terjadi error saat eksekusi save_result_fisik_umum",
|
|
"error" => $e->getMessage(),
|
|
"trace" => $e->getTraceAsString(),
|
|
]));
|
|
}
|
|
}
|
|
}
|
|
?>
|