<?php

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

class Fever_OPD_Summ_model extends CI_Model {
    public function fetch_patients() {
        return $this->db->where('deleted_DT',NULL)->or_where('(deleted_DT IS NOT NULL AND deactive_cronjob_flag = 0)')->order_by('id', 'desc')->get('mst_guard')->result();
    }
    
    public function fetch_opds() {
        return $this->db->where('Deleted_DT',NULL)->get('tbl_opd_center')->result();
    }

   
//    public function update($id) {
//        $data = array("name" => $_POST['name'],
//            "address" => $_POST['address'],
//            "email" => $_POST['emailid'],
//            "contact" => $_POST['contact'],
//            "city" => $_POST['city'],
//            "Longitude" => $_POST['longitude'],
//            "Latitude" => $_POST['latitude'],
//            "Modify_SI" => $this->session->userdata('id'),
//            "Modify_BY" => $this->session->userdata('username'),
//            "Modify_DT" => date('Y-m-d H:i:s'));
//        $c = $this->db->where('id', $id)->update('mst_office', $data);
//    }
   
    public function summary_delete($id) {

        $data = array(
            "Deleted_SI" => $this->session->userdata('id'),
            "Deleted_BY" => $this->session->userdata('username'),
            "Deleted_DT" => date('Y-m-d H:i:s'));
        $c = $this->db->where('fev_opd_sm_id', $id)->update('tbl_fever_opd_summary', $data);
    }

    
    
    public function insert_fev_opd_sumary() {
        $data = array(
            "opd_name" => $_POST['fev_opd_name'],
            "report_dt" => $_POST['report_dt'],
            "total_opd_male_att" => $_POST['total_opd_male_att'],
            "total_opd_female_att" => $_POST['total_opd_female_att'],
            "covid19_supect_mild" => $_POST['covid19_supect_mild'],
            "covid19_supect_moderate" => $_POST['covid19_supect_moderate'],
            "covid19_supect_severe" => $_POST['covid19_supect_severe'],
            "refer_to_ccc" => $_POST['refer_to_ccc'],
            "refer_to_dchc" => $_POST['refer_to_dchc'],
            "refer_to_facility_quart" => $_POST['refer_to_facility_quart'],
            "treatment_by_mo" => $_POST['treatment_by_mo'],
            "no_admitted_patients" => $_POST['no_of_patients_admitted'],
            
            "Inserted_SI" => $this->session->userdata('id'),
            "Inserted_BY" => $this->session->userdata('name'),
            "Inserted_DT" => date('Y-m-d H:i:s')
        );
        $this->db->insert('tbl_fever_opd_summary', $data);
    }

    public function opd_summary_data() {
        $this->db->select('*');
        $this->db->from('tbl_fever_opd_summary');
        $this->db->where('Deleted_DT', NULL);
        $this->db->order_by('fev_opd_sm_id', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    
}
