Пример #1
0
 /**
  * Method getPerformerByUid()
  * @param $uid
  * @return array|bool
  */
 private function getPerformerByUid($uid)
 {
     $User = new User();
     $user = $User->getUser($uid);
     unset($User);
     if ($user === false) {
         return false;
     }
     $user = (object) $user;
     if ($user->facility_id == 0) {
         return false;
     }
     $Facilities = new Facilities();
     $facility = $Facilities->getFacility(['id' => $user->facility_id]);
     if ($user === false) {
         return false;
     }
     $facility = (object) $facility;
     $performer = ['assignedEntity' => ['id' => ['@attributes' => ['root' => UUID::v4()]]]];
     $performer['assignedEntity']['addr'] = ['@attributes' => ['use' => 'HP'], 'streetAddressLine' => ['@value' => isset($user->street) ? $user->street : ''], 'city' => ['@value' => isset($user->city) ? $user->city : ''], 'state' => ['@value' => isset($user->state) ? $user->state : ''], 'postalCode' => ['@value' => isset($user->postal_code) ? $user->postal_code : ''], 'country' => ['@value' => isset($user->country_code) ? $user->country_code : '']];
     $performer['assignedEntity']['telecom'] = ['@attributes' => ['value' => 'tel:' . (isset($user->phone) ? $user->phone : '')]];
     $performer['assignedEntity']['representedOrganization'] = ['id' => ['@attributes' => ['root' => '2.16.840.1.113883.4.6']]];
     $performer['assignedEntity']['assignedPerson']['name'] = ['name' => ['prefix' => $this->primaryProvider['title'], 'given' => $this->primaryProvider['fname'], 'family' => $this->primaryProvider['lname']]];
     $performer['assignedEntity']['representedOrganization']['name'] = $facility->name;
     $performer['assignedEntity']['representedOrganization']['telecom'] = $this->telecomBuilder($this->facility['phone'], 'WP');
     $performer['assignedEntity']['representedOrganization']['addr'] = $this->addressBuilder('WP', $this->facility['address'] . ' ' . $this->facility['address_cont'], $this->facility['city'], $this->facility['state'], $this->facility['postal_code'], $this->facility['country_code']);
     return $performer;
 }
 public function save_details()
 {
     $district = $this->session->userdata("district_province_id");
     $facility_id = $this->input->post('facility_id');
     //Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one!
     if (strlen($facility_id) > 0) {
         $facility = Facilities::getFacility($facility_id);
         //Retrieve the fridges for this facility
         $fridges = Facility_Fridges::getFacilityFridges($facility_id);
         //Delete all these existing facility-fridge combinations
         foreach ($fridges as $fridge) {
             $fridge->delete();
         }
     } else {
         $facility = new Facilities();
     }
     $facility->facilitycode = $this->input->post('facilitycode');
     $facility->name = $this->input->post('name');
     $facility->facilitytype = $this->input->post('type');
     $facility->district = $district;
     $facility->email = $this->input->post('email');
     $facility->phone = $this->input->post('phone');
     $facility->save();
     $facility_id = $facility->id;
     $fridges = $this->input->post('fridges');
     $counter = 0;
     foreach ($fridges as $fridge) {
         if ($fridge > 0) {
             $facility_fridge = new Facility_Fridges();
             $facility_fridge->Facility = $facility_id;
             $facility_fridge->Fridge = $fridge;
             $facility_fridge->Timestamp = date('U');
             $facility_fridge->save();
             $counter++;
         } else {
             $counter++;
             continue;
         }
     }
     redirect("facility_management/district_list");
 }
 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");
     }
 }