<?php

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class M_saturssa_report_lp extends CI_Model {

    function ketepatanantrianoperasi(){
        if(isset($_POST['tanggal'])) {
            $dateall    = $this->input->post('tanggal');
            $pisah      = explode ("-", $dateall);
            $awal       = date("Y-m-d", strtotime($pisah[0]));
            $akhir      = date("Y-m-d", strtotime($pisah[1]));
        }else{
            $awal       = date("Y-m-d");
            $akhir      = date("Y-m-d");
        }

        $query = $this->load->database('saturssa', TRUE);
        $query->select('dpo.No_rekam_medis as norm, dpo.No_KTP as nik, dpo.Nama_pasien as namapasien, dpo.Jenis_kelamin as jk, dpo.Tanggal_lahir as tgllahir, dpo.Umur as umur, dpo.Tanggal_daftar as tgldaftar, dpo.Tanggal_selesai_operasi as tglselesai, dpo.Kategori_operasi as kodekategorioperasi,
                            dko.Kategori as kategorioperasi
                            ');
        $query->join('daftar_kategori_operasi AS dko',      'dko.id     = dpo.Kategori_operasi', 'left');

        $query->where('dpo.Tanggal_selesai_operasi >=', $awal);
        $query->where('dpo.Tanggal_selesai_operasi <=', $akhir);
        $query->where('dpo.Status_operasi',"2");
        $query->order_by('dpo.Tanggal_daftar', 'ASC');
        return $query->get('data_pasien_operasi AS dpo ')->result();  
    }

}
?>