<?php
defined('BASEPATH') or exit('No direct script access allowed');

require_once 'vendor/autoload.php';

class Wsbpjsrs extends CI_Controller
{	
   
		public function __construct()
		{
			parent::__construct();
			$this->load->model('data_menu');			
		}

		public function poli()
		{					
			$url = 'ref/poli';

			echo $this->HttpRequest("GET",$url) ;			
		}

		public function dokter()
		{					
			$url = 'ref/dokter';

			echo $this->HttpRequest("GET",$url) ;		
		}

		public function jadwalDokter()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$kodePoliBpjs = $this->GetJsonObject($obj->{'kodePoliBpjs'}) ;
			$tanggal = $this->GetJsonObject($obj->{'tanggal'}) ;	
			
			$url = 'jadwaldokter/kodepoli/'.$kodePoliBpjs.'/tanggal/'.$tanggal;
			echo $this->HttpRequest("GET",$url) ;		
		}

		public function updateJadwalDokter()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);
			$params = $obj ;			
			$url = '/jadwaldokter/updatejadwaldokter';
			echo $this->HttpRequest("POST",$url,$params) ;		
		}

		public function addAntrean()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);
			$params = $obj ;			
			$url = '/antrean/add';
			echo $this->HttpRequest("POST",$url,$params) ;		
		}

		public function updateWaktuAntrean()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);
			$params = $obj ;			
			$url = '/antrean/updatewaktu';
			echo $this->HttpRequest("POST",$url,$params) ;		
		}

		public function batalAntrean()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);
			$params = $obj ;			
			$url = '/antrean/batal';
			echo $this->HttpRequest("POST",$url,$params) ;		
		}

		public function listTaskAntrean()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);
			$params = $obj ;			
			$url = '/antrean/getlisttask';
			echo $this->HttpRequest("POST",$url,$params) ;		
		}


		public function dashboardPerTanggal()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$tanggal = $this->GetJsonObject($obj->{'tanggal'}) ;
			$waktu = $this->GetJsonObject($obj->{'waktu'}) ;	
			
			$url = 'dashboard/waktutunggu/tanggal/'.$tanggal.'/waktu/'.$waktu;
			
			echo $this->HttpRequest("GET",$url) ;		
		}

		public function dashboardPerbulan()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$bulan = $this->GetJsonObject($obj->{'bulan'}) ;
			$tahun = $this->GetJsonObject($obj->{'tahun'}) ;
			$waktu = $this->GetJsonObject($obj->{'waktu'}) ;	
			
			$url = 'dashboard/waktutunggu/bulan/'.$bulan.'/tahun/'.$tahun.'/waktu/'.$waktu;
			
			echo $this->HttpRequest("GET",$url) ;		
		}
		
		public function HttpRequest($method,$endPoint,$params="",$contentType="application/x-www-form-urlencoded")
		{			
			echo $this->libhttprequest->wsbpjs($method,$endPoint,$params,$contentType);
			exit();			
		}
	
		function GetJsonObject($obj){
			return isset($obj) ? $obj : ""; 
		}
	
	

}

?>