public function find_medical_examination_results_lookup_id($id)
 {
     $medical_examination_results_lookup_id = medical_examination_results_lookup::where('id', '=', $id)->first()['attributes']['id'];
     return $medical_examination_results_lookup_id;
 }
Exemple #2
0
 public function getReport_benefiters_vs_clinical_conditions()
 {
     $results = array();
     // get all clinical conditions from lookup
     $clinical_conditions_lookup = medical_examination_results_lookup::get();
     // count benefiters regarding their medical condition
     foreach ($clinical_conditions_lookup as $condition) {
         // first we will make a benefiters id list with the current clinical condition.
         $medical_examination_results_with_same_clinical_condition = medical_examination_results::where('results_lookup_id', $condition['id'])->get();
         // then make an array with all benefiter_id with the current clinical condition.
         $benefiters_with_same_clinical_condition = array();
         foreach ($medical_examination_results_with_same_clinical_condition as $med_exam_same_clinical) {
             array_push($benefiters_with_same_clinical_condition, medical_visits::find($med_exam_same_clinical['medical_visit_id'])['benefiter_id']);
         }
         // then find the duplicities in the above array and count the result.
         $current_clinical_condition_counter = count(array_count_values($benefiters_with_same_clinical_condition));
         // pass all necessary for amchart.js results to another array.
         $clinical_conditions_result = ['clinical_condition_name' => $condition['description'], 'clinical_condition_count' => $current_clinical_condition_counter];
         array_push($results, $clinical_conditions_result);
     }
     // return array with medical condition => number of benefiters with this medical condition
     return $results;
 }