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

require_once 'vendor/autoload.php';

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


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

			$params = $obj ;
			$postMethod = "application/x-www-form-urlencoded" ;

			$url = 'RencanaKontrol/insert';
			echo $this->HttpRequest("POST",$url,$params,$postMethod) ;		
		}

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

			$params = $obj ;
			$postMethod = "application/x-www-form-urlencoded" ;

			$url = 'RencanaKontrol/Update';
			echo $this->HttpRequest("PUT",$url,$params,$postMethod) ;		
		}

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

			$params = $obj ;
			$postMethod = "application/x-www-form-urlencoded" ;

			$url = 'RencanaKontrol/Delete';
			echo $this->HttpRequest("DELETE",$url,$params,$postMethod) ;			
		}

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

			$params = $obj ;

			$url = 'RencanaKontrol/insertSPRI';
			echo $this->HttpRequest("POST",$url,$params) ;		
		}

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

			$params = $obj ;

			$url = 'RencanaKontrol/UpdateSPRI';
			echo $this->HttpRequest("PUT",$url,$params) ;		
		}

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

			$noSep = $this->GetJsonObject($obj->{'noSep'}) ;	
			$url = 'RencanaKontrol/nosep/'.$noSep;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$noSuratKontrol = $this->GetJsonObject($obj->{'noSuratKontrol'}) ;	
			$url = 'RencanaKontrol/noSuratKontrol/'.$noSuratKontrol;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$bulan = $this->GetJsonObject($obj->{'bulan'}) ;
			$tahun = $this->GetJsonObject($obj->{'tahun'}) ;
			$noKartu = $this->GetJsonObject($obj->{'noKartu'}) ;
			$formatFilter = $this->GetJsonObject($obj->{'formatFilter'}) ;

			$url = 'RencanaKontrol/ListRencanaKontrol/Bulan/'.$bulan.'/Tahun/'.$tahun.'/Nokartu/'.$noKartu.'/filter/'.$formatFilter;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$tanggalAwal = $this->GetJsonObject($obj->{'tanggalAwal'}) ;
			$tanggalAkhir = $this->GetJsonObject($obj->{'tanggalAkhir'}) ;
			$formatFilter = $this->GetJsonObject($obj->{'formatFilter'}) ;

			$url = 'RencanaKontrol/ListRencanaKontrol/tglAwal/'.$tanggalAwal.'/tglAkhir/'.$tanggalAkhir.'/filter/'.$formatFilter;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$jenisKontrol = $this->GetJsonObject($obj->{'jenisKontrol'}) ;
			$nomor = $this->GetJsonObject($obj->{'nomor'}) ;
			$tanggalRencanaKontrol = $this->GetJsonObject($obj->{'tanggalRencanaKontrol'}) ;

			$url = 'RencanaKontrol/ListSpesialistik/JnsKontrol/'.$jenisKontrol.'/nomor/'.$nomor.'/TglRencanaKontrol/'.$tanggalRencanaKontrol;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$jenisKontrol = $this->GetJsonObject($obj->{'jenisKontrol'}) ;
			$kodePoli = $this->GetJsonObject($obj->{'kodePoli'}) ;
			$tanggalRencanaKontrol = $this->GetJsonObject($obj->{'tanggalRencanaKontrol'}) ;

			$url = 'RencanaKontrol/JadwalPraktekDokter/JnsKontrol/'.$jenisKontrol.'/KdPoli/'.$kodePoli.'/TglRencanaKontrol/'.$tanggalRencanaKontrol;
			echo $this->HttpRequest("GET",$url) ;		
		}

        public function HttpRequest($method,$endPoint,$params="",$contentType="application/x-www-form-urlencoded")
		{			
			echo $this->libhttprequest->vclaim($method,$endPoint,$params,$contentType);
			exit();			
		}
		
	
		function GetJsonObject($obj){
			return isset($obj) ? $obj : ""; 
		}
	
	
	
	
	
	
	
	
	

}