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

class Datapasienall extends CI_Controller
{



    public function index()
    {
        $this->load->view('dashboardpasienall/tampildata');
    }
    public function frame1()
    {
        $this->load->view('dashboardpasienall/frame1');
    }
    public function frame2()
    {
        $this->load->view('dashboardpasienall/frame2');
    }
    public function frame3()
    {
        $this->load->view('dashboardpasienall/frame3');
    }
    public function frame4()
    {
        $this->load->view('dashboardpasienall/frame4');
    }
    public function frame41()
    {
        $this->load->view('dashboardpasienall/frame5');
    }

    public function judulrajal()
    {
        $this->load->view('dashboardpasienall/judulrajal');
    }
    public function judulinap()
    {
        $this->load->view('dashboardpasienall/judulinap');
    }
    public function judul()
    {
        $this->load->view('dashboardpasienall/judul');
    }


    public function totalmonitoringrajal()
    {
        $tanggal_awal = date('d/m/Y');
        $data = array("TANGGAL_AWAL" => $tanggal_awal);
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => 'http://103.255.241.146/api/d_reg_online/tampil_pasien_smf_sum',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => http_build_query($data),
        ));

        $response = curl_exec($curl);


        if ($response === false) {
            echo "<tr><td colspan='3'>Error: " . curl_error($curl) . "</td></tr>";
            curl_close($curl);
            return;
        }

        curl_close($curl);

        $json2 = json_decode($response);


        if ($json2 && isset($json2->response)) {
            foreach ($json2->response as $b) {
                echo "<tr>";
                echo "<td width='20%' style='color: #fff; padding: 8px;'><center><strong>{$b->daftar}</strong></center></td>";
                echo "<td width='20%' style='color: #fff; padding: 8px;'><center><strong>{$b->terlayani}</strong></center></td>";
                echo "<td width='10%' style='color: #fff; padding: 8px;'><center><strong>{$b->batal}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='3'>No data available</td></tr>";
        }
    }

    public function monitoringrajal()
    {
        $tanggal_awal = date('d/m/Y');
        $data["TANGGAL_AWAL"] = $tanggal_awal;
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/d_reg_online/tampil_pasien_smf',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $data,
        ));

        $response = curl_exec($curl);
        curl_close($curl);

        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='30%' style='color: #fff; padding: 8px;'><strong>{$a->nm_ruang}</strong></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->daftar}</strong></center></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->terlayani}</strong></center></td>";
                echo "<td width='5%'style='color: #fff; padding: 8px;'><center><strong>{$a->batal}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='4'>No data available</td></tr>";
        }
    }

    public function totalmonitoringranap()
    {
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/d_reg_online/tampil_pasien_inap_sum',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
        ));

        $response = curl_exec($curl);



        if ($response === false) {
            echo "<tr><td colspan='3'>Error: " . curl_error($curl) . "</td></tr>";
            curl_close($curl);
            return;
        }

        curl_close($curl);

        $json2 = json_decode($response);


        if ($json2 && isset($json2->response)) {
            foreach ($json2->response as $b) {
                echo "<tr>";
                echo "<td width='20%' style='color: #000; font-size:20px; padding: 8px;'><center><strong>TOTAL</strong></center></td>";
                echo "<td width='20%' style='color: #fff; padding: 8px;'><center><strong>{$b->jumlah}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='3'>No data available</td></tr>";
        }
    }

    public function monitoringranap()
    {
        $tanggal_awal = date('d/m/Y');
        $data["TANGGAL_AWAL"] = $tanggal_awal;
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/d_reg_online/tampil_pasien_inap',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $data,
        ));

        $response = curl_exec($curl);
        curl_close($curl);

        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='30%' style='color: #fff; padding: 8px;'><strong>{$a->nm_kelas}</strong></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->qty}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='2'>No data available</td></tr>";
        }
    }

    public function datapenjamininap()
    {
        $tanggal_awal = date('d/m/Y');
        $tanggal_akhir = date('d/m/Y');

        $datai["TANGGAL_AWAL"]    = $tanggal_awal;
        $data["TANGGAL_PERIKSA"]    = $tanggal_awal;
        $datai["TANGGAL_AKHIR"]    = $tanggal_akhir;

        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/service_rs/inap_penjamin',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $datai
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->penjamin}</strong></center></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->qty}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='2'>No data available</td></tr>";
        }
    }


    public function totalmonitoringigd()
    {
        $tanggal_awal = date('d/m/Y');
        $tanggal_akhir = date('d/m/Y');

        $datai["TANGGAL_AWAL"]    = $tanggal_awal;
        $data["TANGGAL_PERIKSA"]    = $tanggal_awal;
        $datai["TANGGAL_AKHIR"]    = $tanggal_akhir;

        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/service_rs/tampil_igd_sum',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $datai,
        ));

        $response = curl_exec($curl);



        if ($response === false) {
            echo "<tr><td colspan='3'>Error: " . curl_error($curl) . "</td></tr>";
            curl_close($curl);
            return;
        }

        curl_close($curl);

        $json2 = json_decode($response);


        if ($json2 && isset($json2->response)) {
            foreach ($json2->response as $b) {
                echo "<tr>";
                echo "<td width='20%' style='color: #000; font-size:20px; padding: 8px;'><center><strong>TOTAL</strong></center></td>";
                echo "<td width='20%' style='color: #fff; padding: 8px;'><center><strong>{$b->total_igd}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='3'>No data available</td></tr>";
        }
    }

    public function monitoringigd()
    {
        $tanggal_awal = date('d/m/Y');
        $tanggal_akhir = date('d/m/Y');

        $datai["TANGGAL_AWAL"]    = $tanggal_awal;
        $data["TANGGAL_PERIKSA"]    = $tanggal_awal;
        $datai["TANGGAL_AKHIR"]    = $tanggal_akhir;

        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/service_rs/tampil_igd',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $datai
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='30%' style='color: #fff; padding: 8px;'><strong>{$a->nm_jenis_pasien}</strong></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->dilayani}</strong></center></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->batal}</strong></center></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->total}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='2'>No data available</td></tr>";
        }
    }

    public function datapasienlamabaru()
    {
        $tanggal_awal = date('d/m/Y');
        $tanggal_akhir = date('d/m/Y');

        $datai["TANGGAL_AWAL"]    = $tanggal_awal;
        $data["TANGGAL_PERIKSA"]    = $tanggal_awal;
        $datai["TANGGAL_AKHIR"]    = $tanggal_akhir;

        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/service_rs/tampil_igd_lama_baru',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $datai
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='30%' style='color: #fff; padding: 8px;'><strong>{$a->nm_pendaftaran}</strong></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->dilayani}</strong></center></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->batal}</strong></center></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->total}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='2'>No data available</td></tr>";
        }
    }

    public function datapasienikbstotal()
    {
        $tanggal_awal = date('d/m/Y');
        $tanggal_akhir = date('d/m/Y');

        $datai["TANGGAL_AWAL"]    = $tanggal_awal;
        $data["TANGGAL_PERIKSA"]    = $tanggal_awal;
        $datai["TANGGAL_AKHIR"]    = $tanggal_akhir;

        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/service_rs/tampil_ikbs_total',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $datai
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='30%' style='color: #fff; padding: 8px;'><strong>{$a->nm_ruang_op}</strong></td>";
                echo "<td width='10%'style='color: #fff; padding: 8px;'><center><strong>{$a->qty}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='2'>No data available</td></tr>";
        }
    }

    public function datapasienicutotal()
    {
        $tanggal_awal = date('d/m/Y');
        $tanggal_akhir = date('d/m/Y');

        $datai["TANGGAL_AWAL"]    = $tanggal_awal;
        $data["TANGGAL_PERIKSA"]    = $tanggal_awal;
        $datai["TANGGAL_AKHIR"]    = $tanggal_akhir;

        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/service_rs/tampil_total_icu',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $datai
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        $json1 = json_decode($response);

        if ($json1 && isset($json1->response)) {
            foreach ($json1->response as $a) {
                echo "<tr>";
                echo "<td width='20%' style='color: #000; font-size:20px; padding: 8px;'><center><strong>Jumlah</strong></center></td>";
                echo "<td width='30%' style='color: #fff; padding: 8px;'><center><strong>{$a->count}</strong></center></td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='2'>No data available</td></tr>";
        }
    }
}
