Browse Source

Upload files to ''

master
angsagd 3 years ago
parent
commit
1fda8b70de
5 changed files with 329 additions and 0 deletions
  1. +11
    -0
      dokter.php
  2. +241
    -0
      index.html
  3. +11
    -0
      jadwal.php
  4. +56
    -0
      library.php
  5. +10
    -0
      poliklinik.php

+ 11
- 0
dokter.php View File

@ -0,0 +1,11 @@
<?php
require_once 'library.php';
$dokter = [];
if(isset($_GET['param'])) {
$id_poliklinik = addslashes($_GET['param']);
$dokter = get_all("dokter", "nama", true, "id_poliklinik='$id_poliklinik'");
}
if($dokter) resp_success($dokter);
else resp_failed();

+ 241
- 0
index.html View File

@ -0,0 +1,241 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Service</title>
<style>
body {
margin: 0;
padding: 0;
}
p {
font-family: sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: serif;
}
h2:hover {
text-decoration: underline;
}
h3, h4 {
margin-bottom: 5px;
}
#container {
margin: auto;
width: 700px;
}
.kode {
font-family: monospace;
font-size: larger;
padding: 0px 5px;
background-color: #eee;
}
.kode-box {
font-family: monospace;
font-size: larger;
padding: 10px;
background-color: #eee;
border: 1px dotted #999;
}
.keterangan {
background-color: #ccc;
border: 1px solid #999;
padding: 10px 20px;
list-style: none;
}
ul.keterangan li {
margin: 5px 0px;
}
.keterangan .parameter {
display: inline-block;
width: 150px;
}
.keterangan .nilai {
font-family: monospace;
font-size: large;
}
</style>
</head>
<body>
<div id="container">
<h1>Dokumentasi Web Service</h1>
<div id="umum" class="bagian">
<h2>Konstruksi Umum</h2>
<p>
Semua request service dilakukan melalui <br><span class="kode">{BASE_URL}</span> :
<span class="kode">http://mangusada.bakpasir.web.id/</span><br>Method yang digunakan
adalah <span class="kode">GET</span> atau <span class="kode">POST</span> tergantung
jenis request.
</p>
<p>
Response service adalah data dalam format JSON, berupa JSON object dengan property pertama
adalah <span class="kode">status</span>. Property <span class="kode">status</span>
menunjukkan status berhasil atau tidaknya request mendapatkan data. Jika berhasil
mendapatkan data, maka <span class="kode">status</span> akan bernilai <span class="kode">1</span>
diikuti dengan property <span class="kode">data</span> yang berisi data hasil request.
Namun jika gagal, maka <span class="kode">status</span> akan bernilai <span class="kode">0</span>.
</p>
<h4>Response berhasil</h4>
<div class="kode-box">
{"status":1, "data": ... }
</div>
<h4>Response gagal</h4>
<div class="kode-box">
{"status":0}
</div>
</div>
<div id="dokter" class="bagian">
<h2>Informasi Daftar Dokter</h2>
<ul class="keterangan">
<li>
<span class="parameter">Method</span>:
<span class="nilai">GET</span>
</li>
<li>
<span class="parameter">URL</span>:
<span class="nilai">{BASE_URL}/dokter/{id_poliklinik}</span>
</li>
<li>
<span class="parameter">Content-Type</span>:
<span class="nilai">application/json</span>
</li>
</ul>
<h4>Contoh:</h4>
<div class="kode-box">
http://mangusada.bakpasir.web.id/dokter/2
</div>
<h4>Hasil:</h4>
<div class="kode-box">
{"status":1, "data":[{"id":"5", "nama":"dr. Budiman", ... }, ... ]}
</div>
</div>
<div id="jadwal" class="bagian">
<h2>Informasi Jadwal Dokter</h2>
<ul class="keterangan">
<li>
<span class="parameter">Method</span>:
<span class="nilai">GET</span>
</li>
<li>
<span class="parameter">URL</span>:
<span class="nilai">{BASE_URL}/jadwal/{id_dokter}</span>
</li>
<li>
<span class="parameter">Content-Type</span>:
<span class="nilai">application/json</span>
</li>
</ul>
<h4>Contoh:</h4>
<div class="kode-box">
http://mangusada.bakpasir.web.id/jadwal/5
</div>
<h4>Hasil:</h4>
<div class="kode-box">
{"status":1, "data":[{"id":"6", "id_dokter":"5", "hari":"2", "mulai":"17:00:00", ... }, ... ]}
</div>
</div>
<div id="jaminan" class="bagian">
<h2>Informasi Daftar Jaminan</h2>
<ul class="keterangan">
<li>
<span class="parameter">Method</span>:
<span class="nilai">GET</span>
</li>
<li>
<span class="parameter">URL</span>:
<span class="nilai">{BASE_URL}/jaminan</span>
</li>
<li>
<span class="parameter">Content-Type</span>:
<span class="nilai">application/json</span>
</li>
</ul>
<h4>Contoh:</h4>
<div class="kode-box">
http://mangusada.bakpasir.web.id/jaminan
</div>
<h4>Hasil:</h4>
<div class="kode-box">
{"status":1, "data":[{"id":"4", "nama":"BPJS", ... }, ... ]}
</div>
</div>
<div id="pasien" class="bagian">
<h2>Informasi Data Pasien</h2>
<ul class="keterangan">
<li>
<span class="parameter">Method</span>:
<span class="nilai">GET</span>
</li>
<li>
<span class="parameter">URL</span>:
<span class="nilai">{BASE_URL}/pasien/{no_rekam_medis}</span>
</li>
<li>
<span class="parameter">Content-Type</span>:
<span class="nilai">application/json</span>
</li>
</ul>
<h4>Contoh:</h4>
<div class="kode-box">
http://mangusada.bakpasir.web.id/pasien/510303200000023
</div>
<h4>Hasil:</h4>
<div class="kode-box">
{"status":1, "data":{"id":"7", "rm":"510303200000023", "nik":"5102044311820002", "nama":"Ni Nyoman Mariawati", ... }}
</div>
</div>
<div id="poliklinik" class="bagian">
<h2>Informasi Daftar Poliklinik</h2>
<h3>Semua Poliklinik</h3>
<ul class="keterangan">
<li>
<span class="parameter">Method</span>:
<span class="nilai">GET</span>
</li>
<li>
<span class="parameter">URL</span>:
<span class="nilai">{BASE_URL}/poliklinik</span>
</li>
<li>
<span class="parameter">Content-Type</span>:
<span class="nilai">application/json</span>
</li>
</ul>
<h4>Contoh:</h4>
<div class="kode-box">
http://mangusada.bakpasir.web.id/poliklinik
</div>
<h4>Hasil:</h4>
<div class="kode-box">
{"status":1, "data":[{"id":"4", "nama":"Klinik Anak", "type":"2"}, ... ]}
</div>
<h3>Poliklinik Menurut Type</h3>
<ul class="keterangan">
<li>
<span class="parameter">Method</span>:
<span class="nilai">GET</span>
</li>
<li>
<span class="parameter">URL</span>:
<span class="nilai">{BASE_URL}/poliklinik/{type}</span>
</li>
<li>
<span class="parameter">Content-Type</span>:
<span class="nilai">application/json</span>
</li>
</ul>
<h4>Contoh:</h4>
<div class="kode-box">
http://mangusada.bakpasir.web.id/poliklinik/2
</div>
<h4>Hasil:</h4>
<div class="kode-box">
{"status":1, "data":[{"id":"4", "nama":"Klinik Anak", "type":"2"}, ... ]}
</div>
</div>
<div id="pendaftaran">
<h2>Melakukan Pendaftaran</h2>
</div>
</div>
</body>
</html>

+ 11
- 0
jadwal.php View File

@ -0,0 +1,11 @@
<?php
require_once 'library.php';
$jadwal =[];
if(isset($_GET['param'])) {
$id_dokter = addslashes($_GET['param']);
$jadwal = get_all("jadwal", "hari", true, "id_dokter='$id_dokter'");
}
if($jadwal) resp_success($jadwal);
else resp_failed();

+ 56
- 0
library.php View File

@ -0,0 +1,56 @@
<?php
session_start();
define(DBHOST, '127.0.0.1');
define(DBUSER, 'mangusada');
define(DBPASS, 'mangusada');
define(DBNAME, 'mangusadaws');
if(!$link = @mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME))
die(mysqli_connect_error());
function db_query($sql) {
global $link;
if(!$result=@mysqli_query($link, $sql))
die(mysqli_error($link));
return $result;
}
function get_all($table, $sort_by=false, $ascending=true, $where=false) {
$sql = "SELECT * FROM $table";
if($where) $sql .= " WHERE $where";
if($sort_by) {
$sql .= " ORDER BY $sort_by";
if($ascending) $sql .= " ASC";
else $sql .= " DESC";
}
$result = db_query($sql);
$return = [];
while($row=mysqli_fetch_assoc($result)) $return[] = $row;
return $return;
}
function get_one($table, $where) {
$sql = "SELECT * FROM $table WHERE $where";
$result = db_query($sql);
if($row=mysqli_fetch_assoc($result)) return $row;
else return [];
}
function resp_success($array) {
resp_header();
echo json_encode(['status'=>1, 'data'=>$array]);
}
function resp_failed() {
resp_header();
echo json_encode(['status'=>0]);
}
function resp_header()
{
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json; charset=UTF-8');
}

+ 10
- 0
poliklinik.php View File

@ -0,0 +1,10 @@
<?php
require_once 'library.php';
if(isset($_GET['param'])) {
$type = addslashes($_GET['param']);
$poliklinik = get_all("poliklinik", "type, nama", true, "type='$type'");
} else $poliklinik = get_all("poliklinik", "type, nama");
if($poliklinik) resp_success($poliklinik);
else resp_failed();

Loading…
Cancel
Save