Example #1
0
 public function updateMedicalAnswer($question_id, $answer)
 {
     $question = MedicalQuestion::findOrFail($question_id);
     if (MedicalQuestionAnswer::where('patient_id', $this->id)->where('question_id', $question_id)->count() == 0) {
         $stored_answer = new MedicalQuestionAnswer();
         $stored_answer->question_id = $question_id;
         $stored_answer->patient_id = $this->id;
         $stored_answer->answer = $answer;
         $stored_answer->save();
         $this->addHistoryItem("Medical Question Answer Added", "An answer to the medical question \"" . $question->name . "\" was added for this patient to <strong>" . ($answer == 1 ? 'Yes' : 'No') . "</strong>.", Auth::user()->id, 16);
     } else {
         $stored_answer = MedicalQuestionAnswer::where('patient_id', $this->id)->where('question_id', $question_id)->first();
         if ($stored_answer->answer != $answer) {
             $stored_answer->answer = $answer;
             $stored_answer->save();
             $this->addHistoryItem("Medical Question Answer Updated", "An answer to the medical question \"" . $question->name . "\" was updated for this patient to <strong>" . ($answer == 1 ? 'Yes' : 'No') . "</strong>.", Auth::user()->id, 15);
         }
     }
 }
Example #2
0
 public function showMedical($id)
 {
     $patient = Patient::findOrFail($id);
     $questions = MedicalQuestion::where('active', 1)->orderBy('order', 'desc')->get();
     $stored_answers = MedicalQuestionAnswer::where('patient_id', $patient->id)->get();
     $answers = array();
     foreach ($stored_answers as $a) {
         $answers[$a->question_id] = $a->answer;
     }
     view()->share('show_patient_nav', true);
     $vars = array('current_nav' => 2, "patient" => $patient, "questions" => $questions, "answers" => $answers);
     return view('backend.page.patient-medical')->with($vars);
 }