From fc9b4f57619a5c1f6bec0b5848b6e0d74d3c681b Mon Sep 17 00:00:00 2001 From: renaldybrada Date: Fri, 13 Mar 2026 14:36:02 +0700 Subject: [PATCH] add action tindakan --- dataLaporanOperasi.php | 27 +++++++++ index.php | 121 ++++++++++++++++++++++++----------------- 2 files changed, 98 insertions(+), 50 deletions(-) diff --git a/dataLaporanOperasi.php b/dataLaporanOperasi.php index a371fff..ad33594 100644 --- a/dataLaporanOperasi.php +++ b/dataLaporanOperasi.php @@ -18,6 +18,9 @@ switch ($action) { case "searchDokterAnestesi": searchDokterAnestesi($db, $q); break; + case "searchTindakan": + searchTindakan($db, $q); + break; default : echo json_encode([ "error" => "invalid action" @@ -32,6 +35,8 @@ function searchDPJP(PostgresDb $db, string $q) { } $sql_dokter_bedah = $db->query($query); + + $query .= " LIMIT 10"; $arr_dokter_bedah = array(); foreach ($sql_dokter_bedah->fetchAll() as $ds) { @@ -51,6 +56,8 @@ function searchDokterAnestesi(PostgresDb $db, string $q) { $query .= " AND (namadokter ILIKE '%$q%' OR kode_dpjp ILIKE '%$q%')"; } + $query .= " LIMIT 10"; + $sql_dokter_anestesi = $db->query($query); $arr_dokter_anestesi = array(); @@ -64,4 +71,24 @@ function searchDokterAnestesi(PostgresDb $db, string $q) { ]); } +function searchTindakan(PostgresDb $db, string $q) { + $query = "SELECT kode as code, keterangan as str from icd_cm"; + if ($q != '') { + $query .= " where kode ilike '$q%' OR keterangan ilike '%$q%'"; + } + + $query .= " LIMIT 10"; + + $sql_tindakan = $db->query($query); + + $result = array(); + foreach($sql_tindakan->fetchAll() as $t) { + array_push($result, $t); + } + + echo json_encode([ + "message" => "success get tindakan", + "data" => $result + ]); +} ?> \ No newline at end of file diff --git a/index.php b/index.php index 2f9f3cd..3cb47a7 100644 --- a/index.php +++ b/index.php @@ -1,40 +1,5 @@ query( - "SELECT * FROM public.m_dokter WHERE kdsmf LIKE '%BEDAH%'" -); -$arr_dokter_bedah = array(); -foreach ($sql_dokter_bedah->fetchAll() as $ds) { - $arr_dokter_bedah[$ds['kddokter']] = $ds['namadokter']; -} - -// query dokter anestesi -$sql_dokter_anesthesi = $db->query("SELECT * FROM public.m_dokter WHERE kdsmf LIKE '%ANESTHESI%'"); -$arr_dokter_anesthesi = array(); -foreach ($sql_dokter_anesthesi->fetchAll() as $ds) { - $arr_dokter_anesthesi[$ds['kddokter']] = $ds['namadokter']; -} - -$riwayat = [ - [ - "tanggal" => "28/1/2026, 2:27:04 PM", - "operator" => "dr.SYAIFULLAH AMISRAGANI, Sp.OT", - "status" => "Tervalidasi" - ], - [ - "tanggal" => "29/1/2026, 10:13:29 AM", - "operator" => "dr.PRADANA NURHADI,Sp.U", - "status" => "Belum Validasi" - ] -]; - if ($_SERVER['REQUEST_METHOD'] == "POST") { echo "
";
     print_r($_POST);
@@ -161,10 +126,18 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
 
             
-
+
- + + + +
@@ -833,25 +806,73 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { document.getElementById("lama_bius").oninput = () => calc("bius_mulai", "lama_bius", "bius_selesai") /* dynamic tindakan */ + let timerTindakan = null - document.addEventListener("click", e => { + document.addEventListener("input", function(e){ - if (e.target.classList.contains("addTindakan")) { - let row = document.createElement("div") - row.classList.add("row", "my-2", "tindakanRow") - row.innerHTML = ` -
- -
+ if (!e.target.classList.contains("tindakanSearch")) return -
- -
- ` - document.getElementById("tindakanContainer").appendChild(row) + let input = e.target + let row = input.closest(".tindakanRow") + let result = row.querySelector(".tindakanResult") + clearTimeout(timerTindakan) + + let keyword = input.value + + if (keyword.length < 2) { + result.innerHTML = "" + return } + timerTindakan = setTimeout(() => { + + fetch(`http://localhost:8080/dataLaporanOperasi.php?action=searchTindakan&q=${keyword}`) + .then(res => res.json()) + .then(data => { + + result.innerHTML = "" + + data.data.forEach(d => { + + let item = document.createElement("button") + + item.type = "button" + item.className = "list-group-item list-group-item-action" + item.textContent = d.str + + item.onclick = () => { + + input.value = d.str + row.querySelector(".tindakanValue").value = d.code + + result.innerHTML = "" + + } + + result.appendChild(item) + + }) + + }) + + }, 300) + + }) + + document.addEventListener("click", function(e){ + + if (!e.target.classList.contains("addTindakan")) return + + let row = document.querySelector(".tindakanRow") + let clone = row.cloneNode(true) + + clone.querySelector(".tindakanSearch").value = "" + clone.querySelector(".tindakanValue").value = "" + clone.querySelector(".tindakanResult").innerHTML = "" + + row.parentNode.appendChild(clone) + }) /* darah */