create search dokter API + UI
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
require_once "lib/PostgresDb.php";
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$db = new PostgresDb();
|
||||
|
||||
$action = $_GET['action'] ?? '';
|
||||
$q = '';
|
||||
if (isset($_GET['q'])) {
|
||||
$q = $_GET['q'];
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case "searchDPJP":
|
||||
searchDPJP($db, $q);
|
||||
break;
|
||||
case "searchDokterAnestesi":
|
||||
searchDokterAnestesi($db, $q);
|
||||
break;
|
||||
default :
|
||||
echo json_encode([
|
||||
"error" => "invalid action"
|
||||
]);
|
||||
}
|
||||
|
||||
function searchDPJP(PostgresDb $db, string $q) {
|
||||
$query = "SELECT kddokter, namadokter, kdsmf, kode_dpjp FROM public.m_dokter WHERE kdsmf LIKE '%BEDAH%'";
|
||||
|
||||
if ($q != '') {
|
||||
$query .= " AND (namadokter ILIKE '%$q%' OR kode_dpjp ILIKE '%$q%')";
|
||||
}
|
||||
|
||||
$sql_dokter_bedah = $db->query($query);
|
||||
|
||||
$arr_dokter_bedah = array();
|
||||
foreach ($sql_dokter_bedah->fetchAll() as $ds) {
|
||||
array_push($arr_dokter_bedah, $ds);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"message" => "success get dokter",
|
||||
"data" => $arr_dokter_bedah
|
||||
]);
|
||||
}
|
||||
|
||||
function searchDokterAnestesi(PostgresDb $db, string $q) {
|
||||
$query = "SELECT kddokter, namadokter, kdsmf, kode_dpjp FROM public.m_dokter WHERE kdsmf LIKE '%ANESTHESI%'";
|
||||
|
||||
if ($q != '') {
|
||||
$query .= " AND (namadokter ILIKE '%$q%' OR kode_dpjp ILIKE '%$q%')";
|
||||
}
|
||||
|
||||
$sql_dokter_anestesi = $db->query($query);
|
||||
|
||||
$arr_dokter_anestesi = array();
|
||||
foreach ($sql_dokter_anestesi->fetchAll() as $ds) {
|
||||
array_push($arr_dokter_anestesi, $ds);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"message" => "success get dokter",
|
||||
"data" => $arr_dokter_anestesi
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user