public function findMedicalVisitExaminationResults($med_visit_id)
 {
     $med_visit_exam_results = medical_examination_results::where('medical_visit_id', $med_visit_id)->with('icd10')->orderBy('results_lookup_id')->get();
     return $med_visit_exam_results;
 }
Exemplo n.º 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;
 }