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

require_once 'vendor/autoload.php';

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


		public function cariRujukanByNoRujukan()
		{

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$noRujukan = $this->GetJsonObject($obj->{'noRujukan'}) ;
			
			$url = 'Rujukan/'.$noRujukan;
			echo $this->HttpRequest("GET",$url) ;		
		}
		
		public function cariRujukanByNoRujukanRumahSakit()
		{

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

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

		public function cariRujukanByNoKartuOneRecord()
		{

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

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

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

			$noKartu = $this->GetJsonObject($obj->{'noKartu'}) ;
			
			$url = 'Rujukan/List/Peserta/'.$noKartu;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$params = $obj ;

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

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

			$params = $obj ;

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

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

			$params = $obj ;
			//$contentType = 'application/json';
			$url = 'Rujukan/delete';
			echo $this->HttpRequest("DELETE",$url,$params) ;		
		}

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

			$params = $obj ;

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

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

			$params = $obj ;

			$url = 'Rujukan/Khusus/delete';
			echo $this->HttpRequest("DELETE",$url,$params) ;		
		}

		public function listRujukanKhusus()
		{

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$bulan = $this->GetJsonObject($obj->{'bulan'}) ;
			$tahun= $this->GetJsonObject($obj->{'tahun'}) ;	
			
			$url = 'Rujukan/Khusus/List/Bulan/'.$bulan.'/Tahun/'.$tahun;
			echo $this->HttpRequest("GET",$url) ;		
		}


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

			$params = $obj ;

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

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

			$params = $obj ;

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

		public function listSpesialistikRujukan()
		{	

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$kodePpk = $this->GetJsonObject($obj->{'kodePpk'}) ;
			$tanggalRujukan = $this->GetJsonObject($obj->{'tanggalRujukan'}) ;	
			
			$url = 'Rujukan/ListSpesialistik/PPKRujukan/'.$kodePpk.'/TglRujukan/'.$tanggalRujukan;
			echo $this->HttpRequest("GET",$url) ;		
		}


		public function listSarana()
		{	

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$kodePpk = $this->GetJsonObject($obj->{'kodePpk'}) ;
			
			$url = 'Rujukan/ListSarana/PPKRujukan/'.$kodePpk;
			echo $this->HttpRequest("GET",$url) ;		
		}

		public function listRujukanKeluarRs()
		{	

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

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

			$url = 'Rujukan/Keluar/List/tglMulai/'.$tanggalMulai.'/tglAkhir/'.$tanggalAkhir;
			echo $this->HttpRequest("GET",$url) ;		
		}

		public function dataRujukanKeluarRsByNoRujukan()
		{

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

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

		public function dataJumlahSepRujukan()
		{

			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$jenisRujukan = $this->GetJsonObject($obj->{'jenisRujukan'}) ;
			$noRujukan = $this->GetJsonObject($obj->{'noRujukan'}) ;
		
			$url = 'Rujukan/JumlahSEP/'.$jenisRujukan.'/'.$noRujukan ;
			echo $this->HttpRequest("GET",$url) ;		
		}

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

			$nomorRujukan= $this->GetJsonObject($obj->{'nomorRujukan'}) ;
			
			$url = 'Rujukan/'.$nomorRujukan;
			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 : ""; 
		}
	
	
	
	
	
	
	
	
	

}