<?php

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

class Highrisk_model extends CI_Model {


    
    
    public function insertlab() {
        $data = array("Patient_Id" => $_POST['patientid'],
            "Sample_Collection_Flag" => 1,
            "Date_Collection" => $_POST['collected_date'],
            "Lab_Type" => $_POST['lab_type'],
            
            "Lab_Id" => $_POST['lab_id'],
            "Inserted_SI" => $this->session->userdata('id'),
            "Inserted_BY" => $this->session->userdata('name'),
            "Inserted_DT" => date('Y-m-d H:i:s')
        );
        $this->db->insert('lab_tests', $data);
    }

    public function fetch_data() {

        $this->db->select('*');
        $this->db->from('lab_tests');
        $this->db->where('Deleted_DT', NULL);
        $this->db->order_by('LTtest_Id', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }

    public function fetch_positive_patients() {
        return $this->db->where('deleted_DT',NULL)->where('patient_status',  1)->order_by('id', 'desc')->get('mst_guard')->result();
    }
    
    public function fetch_labs() {
        
        return $this->db->where('deleted_DT',NULL)->get('mst_labs')->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);
    }

}
