<?php

namespace App\Http\Controllers\BridgingBPJS;

use App\Service\Bpjs\Bridging;
use Illuminate\Http\Request;

class RencanaKontrolController extends BpjsController
{
    protected $bpjs;

    public function __construct()
    {
        parent::__construct();
        $this->bpjs = new Bridging($this->consid, $this->timestamp, $this->signature);
    }

    public function KontrolCariSep($noSep)
    {
        $endpoint = "RencanaKontrol/nosep/" . $noSep;
        $sep = $this->bpjs->getRequest($endpoint);
        return $sep;
    }

    public function KontrolCariSurat($noSurat)
    {
        $endpoint = "RencanaKontrol/noSuratKontrol/" . $noSurat;
        $noSurat = $this->bpjs->getRequest($endpoint);
        return $noSurat;
    }

    public function InsertRencanaKontrol(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "RencanaKontrol/insert";
        $rencana = $this->bpjs->postRequest($endpoint, $data);
        return $rencana;
    }

    public function UpdateRencanaKontrol(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "RencanaKontrol/Update";
        $rencana = $this->bpjs->putRequest($endpoint, $data);
        return $rencana;
    }

    public function DeleteRencanaKontrol(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "RencanaKontrol/Delete";
        $rencana = $this->bpjs->deleteRequest($endpoint, $data);
        return $rencana;
    }

    // --------------------- SPRI --------------------------//
    public function InsertRencanaKontrolSpri(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "RencanaKontrol/InsertSPRI";
        $rencana = $this->bpjs->postRequest($endpoint, $data);
        return $rencana;
    }

    public function UpdateRencanaKontrolSpri(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "RencanaKontrol/UpdateSPRI";
        $rencana = $this->bpjs->putRequest($endpoint, $data);
        return $rencana;
    }

    public function DataNoSuratKontrol($tglAwal, $tglAkhir, $formatFilter)
    {
        $endpoint = "RencanaKontrol/ListRencanaKontrol/tglAwal/" . $tglAwal . "/tglAkhir/" . $tglAkhir . "/filter/" . $formatFilter;
        $noSurat = $this->bpjs->getRequest($endpoint);
        return $noSurat;
    }

    public function DataPoliSpesialistik($jenisKontrol, $nomor, $tgl)
    {
        $endpoint = "RencanaKontrol/ListSpesialistik/JnsKontrol/" . $jenisKontrol . "/nomor/" . $nomor . "/TglRencanaKontrol/" . $tgl;
        $noSurat = $this->bpjs->getRequest($endpoint);
        return $noSurat;
    }

    public function DataDokter($jenisKontrol, $kodePoli, $tgl)
    {
        $endpoint = "RencanaKontrol/JadwalPraktekDokter/JnsKontrol/" . $jenisKontrol . "/KdPoli/" . $kodePoli . "/TglRencanaKontrol/" . $tgl;
        $noSurat = $this->bpjs->getRequest($endpoint);
        return $noSurat;
    }

    public function DataNoSuratKontrolNoKartu($bulan, $tahun, $nokartu, $formatFilter)
    {
        $endpoint = "RencanaKontrol/ListRencanaKontrol/Bulan/" . $bulan . "/Tahun/" . $tahun . "/Nokartu/" . $nokartu . "/filter/" . $formatFilter;
        $noSurat = $this->bpjs->getRequest($endpoint);
        return $noSurat;
    }
}
