HOME


sh-3ll 1.0
DIR:/home/medisavehealth/www/application/models/report/
Upload File :
Current File : //home/medisavehealth/www/application/models/report/RetestReportModel.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class RetestReportModel extends CI_Model{



	public function dailyTestReport($date,$company_id){
		$this->db->select("a.`test_id`, a.`test_date`,a.`employee_id`, a.`test_type`, a.`result`, a.`specimen`, a.`confirmed_case`, a.`self_isolation_recomanded`, a.`rt_pcr`,a.`retest`, a.`client_id`,CONCAT(b.firstname,' ',b.lastname) as name ,b.firstname, b.lastname, b.`gender`, b.`date_of_birth`, b.`address`, b.`contact_no`, b.`email`,a.retest_date");
	    $this->db->join('hcs_employee as b', 'a.employee_id = b.employee_id');
	    $this->db->where('a.company_id = b.company_id');
	    $this->db->where('a.company_id',$company_id);
	    $this->db->where('a.retest','Yes');
	    $this->db->where("a.retest_date",$date);
	    $this->db->from('hcs_test as a');

	    $query=$this->db->get();
		if($query->num_rows() >0){
			$result=$query->result_array();
			return $result;
		}
		else{
			return false;
		}

	}

	public function dateRangeTestReport($start_date,$end_date,$company_id){
		
		$new_start_date=date("Y-m-d",strtotime(str_replace('/','-',$start_date)));
		$new_end_date=date("Y-m-d",strtotime(str_replace('/','-',$end_date)));

		$this->db->select("a.`test_id`, a.`employee_id`, a.`test_type`,a.test_date, STR_TO_DATE(a.`retest_date`,'%d/%m/%Y') as retest_date_new,a.`result`, a.`specimen`, a.`confirmed_case`, a.`self_isolation_recomanded`, a.`rt_pcr`,a.`retest`, a.`client_id`,CONCAT(b.firstname,' ',b.lastname) as name ,b.firstname, b.lastname, b.`gender`, b.`date_of_birth`, b.`address`, b.`contact_no`, b.`email`,a.retest_date");
	    $this->db->join('hcs_employee as b', 'a.employee_id = b.employee_id');
	    $this->db->where('a.retest','Yes');
	    $this->db->where("DATE_FORMAT(STR_TO_DATE(a.`retest_date`,'%d/%m/%Y'),'%Y-%m-%d') >= ", $new_start_date);
	    $this->db->where("DATE_FORMAT(STR_TO_DATE(a.`retest_date`,'%d/%m/%Y'),'%Y-%m-%d') <= ", $new_end_date);
	    $this->db->where('a.company_id = b.company_id');
	    $this->db->where('a.company_id',$company_id);
	    $this->db->order_by("retest_date_new", "ASC");
	    $this->db->from('hcs_test as a');

	    $query=$this->db->get();
		if($query->num_rows() >0){
			$result=$query->result_array();
			return $result;
		}
		else{
			return false;
		}
	}


	public function monthlyTestReport($month,$year,$company_id){
		$this->db->select("a.`test_id`, a.`employee_id`, a.`test_type`,a.test_date, STR_TO_DATE(a.`retest_date`,'%d/%m/%Y') as retest_date_new,a.`result`, a.`specimen`, a.`confirmed_case`, a.`self_isolation_recomanded`, a.`rt_pcr`,a.`retest`, a.`client_id`,CONCAT(b.firstname,' ',b.lastname) as name ,b.firstname, b.lastname, b.`gender`, b.`date_of_birth`, b.`address`, b.`contact_no`, b.`email`,a.retest_date");
		$this->db->where('a.retest','Yes');
	    $this->db->join('hcs_employee as b', 'a.employee_id = b.employee_id');
	    $this->db->where("month(STR_TO_DATE(a.`retest_date`,'%d/%m/%Y'))", $month);
	    $this->db->where("year(STR_TO_DATE(a.`retest_date`,'%d/%m/%Y'))", $year);
	    $this->db->where('a.company_id = b.company_id');
	    $this->db->where('a.company_id',$company_id);
	    $this->db->order_by("retest_date_new", "ASC");
	    $this->db->from('hcs_test as a');

	    $query=$this->db->get();
		if($query->num_rows() >0){
			$result=$query->result_array();
			return $result;
		}
		else{
			return false;
		}
	}

	public function yearlyTestReport($year,$company_id){
		$this->db->select("a.`test_id`, a.`employee_id`, a.`test_type`,a.test_date, STR_TO_DATE(a.`retest_date`,'%d/%m/%Y') as retest_date_new,a.`result`, a.`specimen`, a.`confirmed_case`, a.`self_isolation_recomanded`, a.`rt_pcr`,a.`retest`, a.`client_id`,CONCAT(b.firstname,' ',b.lastname) as name ,b.firstname, b.lastname, b.`gender`, b.`date_of_birth`, b.`address`, b.`contact_no`, b.`email`,a.retest_date");
	    $this->db->join('hcs_employee as b', 'a.employee_id = b.employee_id');
	     $this->db->where('a.retest','Yes');
	    $this->db->where("year(STR_TO_DATE(a.`retest_date`,'%d/%m/%Y'))", $year);
	    $this->db->where('a.company_id = b.company_id');
	    $this->db->where('a.company_id',$company_id);
	    $this->db->order_by("retest_date_new", "ASC");
	    $this->db->from('hcs_test as a');

	    $query=$this->db->get();
		if($query->num_rows() >0){
			$result=$query->result_array();
			return $result;
		}
		else{
			return false;
		}
	}

}