public function analyze() { $year = $this->input->post('year'); $epiweek = $this->input->post('epiweek'); $data['duplicates'] = Surveillance::getDuplicates($year, $epiweek); $data['quality_view'] = "data_duplication_v"; $data['total_diseases'] = Disease::getTotal(); $data['epiweek'] = $epiweek; $data['year'] = $year; $data['small_title'] = "Districts with duplicates in " . $year . " Epiweek " . $epiweek; $this->base_params($data); }
public function get_list() { $year = $this->input->post('year'); $epiweek = $this->input->post('epiweek'); $data['reports'] = Surveillance::getReports($year, $epiweek); $data['quality_view'] = "district_reports_listing_v"; $data['total_diseases'] = Disease::getTotal(); $data['epiweek'] = $epiweek; $data['year'] = $year; $data['small_title'] = "List of all District Reports in " . $year . " Epiweek " . $epiweek; $this->base_params($data); }
public function save() { $i = 0; $valid = $this->_validate_submission(); if ($valid == false) { $this->add(); } else { $editing = false; $diseases = Disease::getAllObjects(); $weekending = $this->input->post("week_ending"); $reporting_year = $this->input->post("reporting_year"); $epiweek = $this->input->post("epiweek"); $facility = $this->input->post("facility"); $reportingfacilities = $this->input->post("reporting_facilities"); $expectedfacilities = $this->input->post("expected_facilities"); $lmcase = $this->input->post("lmcase"); $lfcase = $this->input->post("lfcase"); $lmdeath = $this->input->post("lmdeath"); $lfdeath = $this->input->post("lfdeath"); $gmcase = $this->input->post("gmcase"); $gfcase = $this->input->post("gfcase"); $gmdeath = $this->input->post("gmdeath"); $gfdeath = $this->input->post("gfdeath"); $sickness = $this->input->post("disease"); $reported_by = $this->input->post("reported_by"); $designation = $this->input->post("designation"); $lab_id = $this->input->post("lab_id"); $surveillance_ids = $this->input->post("surveillance_ids"); $data_exists = Surveillance::getFacilityData($epiweek, $reporting_year, $facility); if ($lab_id > 0) { $editing = true; } if ($data_exists->id && $editing == false) { $data = array(); $data['duplicate_facility'] = Facilities::getFacility($facility); $data['duplicate_epiweek'] = $epiweek; $data['duplicate_reporting_year'] = $reporting_year; $data['existing_data'] = true; $this->add($data); return; } $total_diseases = Disease::getTotal(); $timestamp = date('d/m/Y'); $i = 0; foreach ($diseases as $disease) { if ($editing == true) { $surveillance = Surveillance::getSurveillance($surveillance_ids[$i]); } else { $surveillance = new Surveillance(); } $surveillance->Week_Ending = $weekending; $surveillance->Epiweek = $epiweek; $surveillance->Facility = $facility; $surveillance->Submitted = $reportingfacilities; $surveillance->Expected = $expectedfacilities; $surveillance->Lmcase = $lmcase[$i]; $surveillance->Lfcase = $lfcase[$i]; $surveillance->Lmdeath = $lmdeath[$i]; $surveillance->Lfdeath = $lfdeath[$i]; if (isset($gmcase[$i])) { $surveillance->Gmcase = $gmcase[$i]; $surveillance->Gfcase = $gfcase[$i]; $surveillance->Gmdeath = $gmdeath[$i]; $surveillance->Gfdeath = $gfdeath[$i]; } $surveillance->Disease = $disease; $surveillance->Reporting_Year = $reporting_year; $surveillance->Created_By = $this->session->userdata('user_id'); $surveillance->Date_Created = date("Y-m-d"); $surveillance->Reported_By = $reported_by; $surveillance->Designation = $designation; $surveillance->Total_Diseases = $total_diseases; $surveillance->Date_Reported = $timestamp; $surveillance->save(); $i++; } //end foreach //Lab Data if ($editing == true) { $labdata = Lab_Weekly::getLabObject($lab_id); } else { $labdata = new Lab_Weekly(); } $totaltestedlessfive = $this->input->post("total_tested_less_than_five"); $totaltestedgreaterfive = $this->input->post("total_tested_greater_than_five"); $totalpositivelessfive = $this->input->post("total_positive_less_than_five"); $totalpositivegreaterfive = $this->input->post("total_positive_greater_than_five"); $remarks = $this->input->post("remarks"); $labdata->Epiweek = $epiweek; $labdata->Week_Ending = $weekending; $labdata->Facility = $facility; $labdata->Malaria_Below_5 = $totaltestedlessfive; $labdata->Malaria_Above_5 = $totaltestedgreaterfive; $labdata->Positive_Below_5 = $totalpositivelessfive; $labdata->Positive_Above_5 = $totalpositivegreaterfive; $labdata->Remarks = $remarks; $labdata->Reporting_Year = $reporting_year; $labdata->Date_Created = date("Y-m-d"); $labdata->save(); if ($editing) { $data['success_message'] = "You have successfully edited data for " . $labdata->Facility->Name; $this->add($data); } if (!$editing) { $data['success_message'] = "You have successfully added weekly data for " . $labdata->Facility->Name; $this->add($data); } //redirect("weekly_facility/add"); } }
public function getDuplicates($year, $epiweek) { $total_diseases = Disease::getTotal(); $query = Doctrine_Query::create()->select("District, Reporting_Year, Week_Ending, Epiweek, count(id) as Records")->from("surveillance")->where("epiweek = '{$epiweek}' and Reporting_Year = '{$year}'")->groupBy("District")->having("Records > '{$total_diseases}'"); $result = $query->execute(); return $result; }