Ejemplo n.º 1
0
 protected function encounters_view($eid, $pid, $practice_id, $modal = false, $addendum = false)
 {
     $encounterInfo = Encounters::find($eid);
     $data['patientInfo'] = Demographics::find($pid);
     $data['eid'] = $eid;
     $data['encounter_DOS'] = date('F jS, Y; h:i A', $this->human_to_unix($encounterInfo->encounter_DOS));
     $data['encounter_provider'] = $encounterInfo->encounter_provider;
     $data['date_signed'] = date('F jS, Y; h:i A', $this->human_to_unix($encounterInfo->date_signed));
     $data['age1'] = $encounterInfo->encounter_age;
     $data['dob'] = date('F jS, Y', $this->human_to_unix($data['patientInfo']->DOB));
     $data['age'] = $this->current_age($pid);
     if ($data['patientInfo']->sex == 'm') {
         $data['gender'] = 'Male';
     }
     if ($data['patientInfo']->sex == 'f') {
         $data['gender'] = 'Female';
     }
     if ($data['patientInfo']->sex == 'u') {
         $data['gender'] = 'Undifferentiated';
     }
     $data['encounter_cc'] = nl2br($encounterInfo->encounter_cc);
     $practiceInfo = Practiceinfo::find($practice_id);
     $hpiInfo = Hpi::find($eid);
     if ($hpiInfo) {
         if (!is_null($hpiInfo->hpi) && $hpiInfo->hpi != '') {
             $data['hpi'] = '<br><h4>History of Present Illness:</h4><p class="view">';
             $data['hpi'] .= nl2br($hpiInfo->hpi);
             $data['hpi'] .= '</p>';
         }
         if (!is_null($hpiInfo->situation) && $hpiInfo->situation != '') {
             $data['hpi'] = '<br><h4>Situation:</h4><p class="view">';
             $data['hpi'] .= nl2br($hpiInfo->situation);
             $data['hpi'] .= '</p>';
         }
     } else {
         $data['hpi'] = '';
     }
     $rosInfo = Ros::find($eid);
     if ($rosInfo) {
         $data['ros'] = '<br><h4>Review of Systems:</h4><p class="view">';
         if ($rosInfo->ros_gen != '') {
             $data['ros'] .= '<strong>General: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_gen);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_eye != '') {
             $data['ros'] .= '<strong>Eye: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_eye);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_ent != '') {
             $data['ros'] .= '<strong>Ears, Nose, Throat: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_ent);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_resp != '') {
             $data['ros'] .= '<strong>Respiratory: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_resp);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_cv != '') {
             $data['ros'] .= '<strong>Cardiovascular: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_cv);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_gi != '') {
             $data['ros'] .= '<strong>Gastrointestinal: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_gi);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_gu != '') {
             $data['ros'] .= '<strong>Genitourinary: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_gu);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_mus != '') {
             $data['ros'] .= '<strong>Musculoskeletal: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_mus);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_neuro != '') {
             $data['ros'] .= '<strong>Neurological: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_neuro);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych != '') {
             $data['ros'] .= '<strong>Psychological: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_heme != '') {
             $data['ros'] .= '<strong>Hematological, Lymphatic: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_heme);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_endocrine != '') {
             $data['ros'] .= '<strong>Endocrine: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_endocrine);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_skin != '') {
             $data['ros'] .= '<strong>Skin: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_skin);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_wcc != '') {
             $data['ros'] .= '<strong>Well Child Check: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_wcc);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych1 != '') {
             $data['ros'] .= '<strong>Depression: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych1);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych2 != '') {
             $data['ros'] .= '<strong>Anxiety: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych2);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych3 != '') {
             $data['ros'] .= '<strong>Bipolar: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych3);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych4 != '') {
             $data['ros'] .= '<strong>Mood Disorders: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych4);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych5 != '') {
             $data['ros'] .= '<strong>ADHD: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych5);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych6 != '') {
             $data['ros'] .= '<strong>PTSD: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych6);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych7 != '') {
             $data['ros'] .= '<strong>Substance Related Disorder: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych7);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych8 != '') {
             $data['ros'] .= '<strong>Obsessive Compulsive Disorder: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych8);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych9 != '') {
             $data['ros'] .= '<strong>Social Anxiety Disorder: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych9);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych10 != '') {
             $data['ros'] .= '<strong>Autistic Disorder: </strong>';
             $data['ros'] .= nl2br($rosInfo->ros_psych10);
             $data['ros'] .= '<br /><br />';
         }
         if ($rosInfo->ros_psych11 != '') {
             $data['ros'] .= "<strong>Asperger's Disorder: </strong>";
             $data['ros'] .= nl2br($rosInfo->ros_psych11);
             $data['ros'] .= '<br /><br />';
         }
         $data['ros'] .= '</p>';
     } else {
         $data['ros'] = '';
     }
     $ohInfo = DB::table('other_history')->where('eid', '=', $eid)->first();
     if ($ohInfo) {
         $data['oh'] = '<br><h4>Other Pertinent History:</h4><p class="view">';
         if ($ohInfo->oh_pmh != '') {
             $data['oh'] .= '<strong>Past Medical History: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_pmh);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_psh != '') {
             $data['oh'] .= '<strong>Past Surgical History: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_psh);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_fh != '') {
             $data['oh'] .= '<strong>Family History: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_fh);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_sh != '') {
             $data['oh'] .= '<strong>Social History: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_sh);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_etoh != '') {
             $data['oh'] .= '<strong>Alcohol Use: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_etoh);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_tobacco != '') {
             $data['oh'] .= '<strong>Tobacco Use: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_tobacco);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_drugs != '') {
             $data['oh'] .= '<strong>Illicit Drug Use: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_drugs);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_employment != '') {
             $data['oh'] .= '<strong>Employment: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_employment);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_psychosocial != '') {
             $data['oh'] .= '<strong>Psychosocial: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_psychosocial);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_developmental != '') {
             $data['oh'] .= '<strong>Developmental: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_developmental);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_medtrials != '') {
             $data['oh'] .= '<strong>Past Medication Trials: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_medtrials);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_meds != '') {
             $data['oh'] .= '<strong>Medications: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_meds);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_supplements != '') {
             $data['oh'] .= '<strong>Supplements: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_supplements);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_allergies != '') {
             $data['oh'] .= '<strong>Allergies: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_allergies);
             $data['oh'] .= '<br /><br />';
         }
         if ($ohInfo->oh_results != '') {
             $data['oh'] .= '<strong>Reviewed Results: </strong>';
             $data['oh'] .= nl2br($ohInfo->oh_results);
             $data['oh'] .= '<br /><br />';
         }
         $data['oh'] .= '</p>';
     } else {
         $data['oh'] = '';
     }
     $vitalsInfo1 = Vitals::where('eid', '=', $eid)->get();
     if (count($vitalsInfo1) > 0) {
         foreach ($vitalsInfo1 as $vitalsInfo) {
             $data['vitals'] = '<br><h4>Vital Signs:</h4><p class="view">';
             $data['vitals'] .= '<strong>Date/Time:</strong>';
             $data['vitals'] .= $vitalsInfo->vitals_date . '<br>';
             if ($vitalsInfo->weight != '') {
                 $data['vitals'] .= '<strong>Weight: </strong>';
                 $data['vitals'] .= $vitalsInfo->weight . ' ' . $practiceInfo->weight_unit . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->height != '') {
                 $data['vitals'] .= '<strong>Height: </strong>';
                 $data['vitals'] .= $vitalsInfo->height . ' ' . $practiceInfo->height_unit . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->headcircumference != '') {
                 $data['vitals'] .= '<strong>Head Circumference: </strong>';
                 $data['vitals'] .= $vitalsInfo->headcircumference . ' ' . $practiceInfo->hc_unit . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->BMI != '') {
                 $data['vitals'] .= '<strong>Body Mass Index: </strong>';
                 $data['vitals'] .= $vitalsInfo->BMI . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->temp != '') {
                 $data['vitals'] .= '<strong>Temperature: </strong>';
                 $data['vitals'] .= $vitalsInfo->temp . ' ' . $practiceInfo->temp_unit . ', ' . $vitalsInfo->temp_method . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->bp_systolic != '' && $vitalsInfo->bp_diastolic != '') {
                 $data['vitals'] .= '<strong>Blood Pressure: </strong>';
                 $data['vitals'] .= $vitalsInfo->bp_systolic . '/' . $vitalsInfo->bp_diastolic . ', ' . $vitalsInfo->bp_position . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->pulse != '') {
                 $data['vitals'] .= '<strong>Pulse: </strong>';
                 $data['vitals'] .= $vitalsInfo->pulse . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->respirations != '') {
                 $data['vitals'] .= '<strong>Respirations: </strong>';
                 $data['vitals'] .= $vitalsInfo->respirations . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->o2_sat != '') {
                 $data['vitals'] .= '<strong>Oxygen Saturations: </strong>';
                 $data['vitals'] .= $vitalsInfo->o2_sat . '<br>';
             } else {
                 $data['vitals'] .= '';
             }
             if ($vitalsInfo->vitals_other != '') {
                 $data['vitals'] .= '<strong>Notes: </strong>';
                 $data['vitals'] .= nl2br($vitalsInfo->vitals_other) . '<br>';
             }
             $data['vitals'] .= '</p>';
         }
     } else {
         $data['vitals'] = '';
     }
     $peInfo = Pe::find($eid);
     if ($peInfo) {
         $data['pe'] = '<br><h4>Physical Exam:</h4><p class="view">';
         if ($peInfo->pe_gen1 != '') {
             $data['pe'] .= '<strong>General: </strong>';
             $data['pe'] .= nl2br($peInfo->pe_gen1);
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_eye1 != '' || $peInfo->pe_eye2 != '' || $peInfo->pe_eye3 != '') {
             $data['pe'] .= '<strong>Eye:</strong>';
             if ($peInfo->pe_eye1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_eye1);
             }
             if ($peInfo->pe_eye2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_eye2);
             }
             if ($peInfo->pe_eye3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_eye3);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_ent1 != '' || $peInfo->pe_ent2 != '' || $peInfo->pe_ent3 != '' || $peInfo->pe_ent4 != '' || $peInfo->pe_ent5 != '' || $peInfo->pe_ent6 != '') {
             $data['pe'] .= '<strong>Ears, Nose, Throat:</strong>';
             if ($peInfo->pe_ent1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ent1);
             }
             if ($peInfo->pe_ent2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ent2);
             }
             if ($peInfo->pe_ent3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ent3);
             }
             if ($peInfo->pe_ent4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ent4);
             }
             if ($peInfo->pe_ent5 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ent5);
             }
             if ($peInfo->pe_ent6 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ent6);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_neck1 != '' || $peInfo->pe_neck2 != '') {
             $data['pe'] .= '<strong>Neck:</strong>';
             if ($peInfo->pe_neck1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_neck1);
             }
             if ($peInfo->pe_neck2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_neck2);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_resp1 != '' || $peInfo->pe_resp2 != '' || $peInfo->pe_resp3 != '' || $peInfo->pe_resp4 != '') {
             $data['pe'] .= '<strong>Respiratory:</strong>';
             if ($peInfo->pe_resp1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_resp1);
             }
             if ($peInfo->pe_resp2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_resp2);
             }
             if ($peInfo->pe_resp3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_resp3);
             }
             if ($peInfo->pe_resp4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_resp4);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_cv1 != '' || $peInfo->pe_cv2 != '' || $peInfo->pe_cv3 != '' || $peInfo->pe_cv4 != '' || $peInfo->pe_cv5 != '' || $peInfo->pe_cv6 != '') {
             $data['pe'] .= '<strong>Cardiovascular:</strong>';
             if ($peInfo->pe_cv1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_cv1);
             }
             if ($peInfo->pe_cv2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_cv2);
             }
             if ($peInfo->pe_cv3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_cv3);
             }
             if ($peInfo->pe_cv4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_cv4);
             }
             if ($peInfo->pe_cv5 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_cv5);
             }
             if ($peInfo->pe_cv6 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_cv6);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_ch1 != '' || $peInfo->pe_ch2 != '') {
             $data['pe'] .= '<strong>Chest:</strong>';
             if ($peInfo->pe_ch1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ch1);
             }
             if ($peInfo->pe_ch2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ch2);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_gi1 != '' || $peInfo->pe_gi2 != '' || $peInfo->pe_gi3 != '' || $peInfo->pe_gi4 != '') {
             $data['pe'] .= '<strong>Gastrointestinal:</strong>';
             if ($peInfo->pe_gi1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gi1);
             }
             if ($peInfo->pe_gi2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gi2);
             }
             if ($peInfo->pe_gi3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gi3);
             }
             if ($peInfo->pe_gi4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gi4);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_gu1 != '' || $peInfo->pe_gu2 != '' || $peInfo->pe_gu3 != '' || $peInfo->pe_gu4 != '' || $peInfo->pe_gu5 != '' || $peInfo->pe_gu6 != '' || $peInfo->pe_gu7 != '' || $peInfo->pe_gu8 != '' || $peInfo->pe_gu9 != '') {
             $data['pe'] .= '<strong>Genitourinary:</strong>';
             if ($peInfo->pe_gu1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu1);
             }
             if ($peInfo->pe_gu2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu2);
             }
             if ($peInfo->pe_gu3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu3);
             }
             if ($peInfo->pe_gu4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu4);
             }
             if ($peInfo->pe_gu5 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu5);
             }
             if ($peInfo->pe_gu6 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu6);
             }
             if ($peInfo->pe_gu7 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu7);
             }
             if ($peInfo->pe_gu8 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu8);
             }
             if ($peInfo->pe_gu9 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_gu9);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_lymph1 != '' || $peInfo->pe_lymph2 != '' || $peInfo->pe_lymph3 != '') {
             $data['pe'] .= '<strong>Lymphatic:</strong>';
             if ($peInfo->pe_lymph1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_lymph1);
             }
             if ($peInfo->pe_lymph2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_lymph2);
             }
             if ($peInfo->pe_lymph3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_lymph3);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_ms1 != '' || $peInfo->pe_ms2 != '' || $peInfo->pe_ms3 != '' || $peInfo->pe_ms4 != '' || $peInfo->pe_ms5 != '' || $peInfo->pe_ms6 != '' || $peInfo->pe_ms7 != '' || $peInfo->pe_ms8 != '' || $peInfo->pe_ms9 != '' || $peInfo->pe_ms10 != '' || $peInfo->pe_ms11 != '' || $peInfo->pe_ms12 != '') {
             $data['pe'] .= '<strong>Musculoskeletal:</strong>';
             if ($peInfo->pe_ms1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms1);
             }
             if ($peInfo->pe_ms2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms2);
             }
             if ($peInfo->pe_ms3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms3);
             }
             if ($peInfo->pe_ms4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms4);
             }
             if ($peInfo->pe_ms5 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms5);
             }
             if ($peInfo->pe_ms6 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms6);
             }
             if ($peInfo->pe_ms7 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms7);
             }
             if ($peInfo->pe_ms8 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms8);
             }
             if ($peInfo->pe_ms9 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms9);
             }
             if ($peInfo->pe_ms10 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms10);
             }
             if ($peInfo->pe_ms11 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms11);
             }
             if ($peInfo->pe_ms12 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_ms12);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_skin1 != '' || $peInfo->pe_skin2 != '') {
             $data['pe'] .= '<strong>Skin:</strong>';
             if ($peInfo->pe_skin1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_skin1);
             }
             if ($peInfo->pe_skin2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_skin2);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_neuro1 != '' || $peInfo->pe_neuro2 != '' || $peInfo->pe_neuro3 != '') {
             $data['pe'] .= '<strong>Neurologic:</strong>';
             if ($peInfo->pe_neuro1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_neuro1);
             }
             if ($peInfo->pe_neuro2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_neuro2);
             }
             if ($peInfo->pe_neuro3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_neuro3);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_psych1 != '' || $peInfo->pe_psych2 != '' || $peInfo->pe_psych3 != '' || $peInfo->pe_psych4 != '') {
             $data['pe'] .= '<strong>Psychiatric:</strong>';
             if ($peInfo->pe_psych1 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_psych1);
             }
             if ($peInfo->pe_psych2 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_psych2);
             }
             if ($peInfo->pe_psych3 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_psych3);
             }
             if ($peInfo->pe_psych4 != '') {
                 $data['pe'] .= ' ' . nl2br($peInfo->pe_psych4);
             }
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_constitutional1 != '') {
             $data['pe'] .= '<strong>Constitutional: </strong>';
             $data['pe'] .= nl2br($peInfo->pe_constitutional1);
             $data['pe'] .= '<br /><br />';
         }
         if ($peInfo->pe_mental1 != '') {
             $data['pe'] .= '<strong>Mental Status Examination: </strong>';
             $data['pe'] .= nl2br($peInfo->pe_mental1);
             $data['pe'] .= '<br /><br />';
         }
         $data['pe'] .= '</p>';
     } else {
         $data['pe'] = '';
     }
     $imagesInfo = DB::table('image')->where('eid', '=', $eid)->get();
     $html = '';
     if ($imagesInfo) {
         $data['images'] = '<br><h4>Images:</h4><p class="view">';
         $k = 0;
         foreach ($imagesInfo as $imagesInfo_row) {
             $directory = $practiceInfo->documents_dir . $pid . "/";
             $new_directory = __DIR__ . '/../../public/temp/';
             $new_directory1 = '/temp/';
             $file_path = str_replace($directory, $new_directory, $imagesInfo_row->image_location);
             $file_path1 = str_replace($directory, $new_directory1, $imagesInfo_row->image_location);
             copy($imagesInfo_row->image_location, $file_path);
             if ($k != 0) {
                 $data['images'] .= '<br><br>';
             }
             $data['images'] .= HTML::image($file_path1, 'Image', array('border' => '0'));
             if ($imagesInfo_row->image_description != '') {
                 $data['images'] .= '<br>' . $imagesInfo_row->image_description . '<br>';
             }
             $k++;
         }
     } else {
         $data['images'] = '';
     }
     $labsInfo = Labs::find($eid);
     if ($labsInfo) {
         $data['labs'] = '<br><h4>Laboratory Testing:</h4><p class="view">';
         if ($labsInfo->labs_ua_urobili != '' || $labsInfo->labs_ua_bilirubin != '' || $labsInfo->labs_ua_ketones != '' || $labsInfo->labs_ua_glucose != '' || $labsInfo->labs_ua_protein != '' || $labsInfo->labs_ua_nitrites != '' || $labsInfo->labs_ua_leukocytes != '' || $labsInfo->labs_ua_blood != '' || $labsInfo->labs_ua_ph != '' || $labsInfo->labs_ua_spgr != '' || $labsInfo->labs_ua_color != '' || $labsInfo->labs_ua_clarity != '') {
             $data['labs'] .= '<strong>Dipstick Urinalysis:</strong><br /><table>';
             if ($labsInfo->labs_ua_urobili != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Urobilinogen:</th><td align=\\"left\\">' . $labsInfo->labs_ua_urobili . '</td></tr>';
             }
             if ($labsInfo->labs_ua_bilirubin != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Bilirubin:</th><td align=\\"left\\">' . $labsInfo->labs_ua_bilirubin . '</td></tr>';
             }
             if ($labsInfo->labs_ua_ketones != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Ketones:</th><td align=\\"left\\">' . $labsInfo->labs_ua_ketones . '</td></tr>';
             }
             if ($labsInfo->labs_ua_glucose != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Glucose:</th><td align=\\"left\\">' . $labsInfo->labs_ua_glucose . '</td></tr>';
             }
             if ($labsInfo->labs_ua_protein != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Protein:</th><td align=\\"left\\">' . $labsInfo->labs_ua_protein . '</td></tr>';
             }
             if ($labsInfo['labs_ua_nitrites'] != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Nitrites:</th><td align=\\"left\\">' . $labsInfo->labs_ua_nitrites . '</td></tr>';
             }
             if ($labsInfo->labs_ua_leukocytes != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Leukocytes:</th><td align=\\"left\\">' . $labsInfo->labs_ua_leukocytes . '</td></tr>';
             }
             if ($labsInfo->labs_ua_blood != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Blood:</th><td align=\\"left\\">' . $labsInfo->labs_ua_blood . '</td></tr>';
             }
             if ($labsInfo->labs_ua_ph != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">pH:</th><td align=\\"left\\">' . $labsInfo->labs_ua_ph . '</td></tr>';
             }
             if ($labsInfo->labs_ua_spgr != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Specific gravity:</th><td align=\\"left\\">' . $labsInfo->labs_ua_spgr . '</td></tr>';
             }
             if ($labsInfo->labs_ua_color != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Color:</th><td align=\\"left\\">' . $labsInfo->labs_ua_color . '</td></tr>';
             }
             if ($labsInfo->labs_ua_clarity != '') {
                 $data['labs'] .= '<tr><th align=\\"left\\">Clarity:</th><td align=\\"left\\">' . $labsInfo->labs_ua_clarity . '</td></tr>';
             }
             $data['labs'] .= '</table>';
         }
         if ($labsInfo->labs_upt != '') {
             $data['labs'] .= '<strong>Urine HcG: </strong>';
             $data['labs'] .= $labsInfo->labs_upt;
             $data['labs'] .= '<br /><br />';
         }
         if ($labsInfo->labs_strep != '') {
             $data['labs'] .= '<strong>Rapid Strep: </strong>';
             $data['labs'] .= $labsInfo->labs_strep;
             $data['labs'] .= '<br /><br />';
         }
         if ($labsInfo->labs_mono != '') {
             $data['labs'] .= '<strong>Mono Spot: </strong>';
             $data['labs'] .= $labsInfo->labs_mono;
             $data['labs'] .= '<br>';
         }
         if ($labsInfo->labs_flu != '') {
             $data['labs'] .= '<strong>Rapid Influenza: </strong>';
             $data['labs'] .= $labsInfo->labs_flu;
             $data['labs'] .= '<br /><br />';
         }
         if ($labsInfo->labs_microscope != '') {
             $data['labs'] .= '<strong>Micrscopy: </strong>';
             $data['labs'] .= nl2br($labsInfo->labs_microscope);
             $data['labs'] .= '<br /><br />';
         }
         if ($labsInfo->labs_glucose != '') {
             $data['labs'] .= '<strong>Fingerstick Glucose: </strong>';
             $data['labs'] .= $labsInfo->labs_glucose;
             $data['labs'] .= '<br /><br />';
         }
         if ($labsInfo->labs_other != '') {
             $data['labs'] .= '<strong>Other: </strong>';
             $data['labs'] .= nl2br($labsInfo->labs_other);
             $data['labs'] .= '<br /><br />';
         }
         $data['labs'] .= '</p>';
     } else {
         $data['labs'] = '';
     }
     $procedureInfo = Procedure::find($eid);
     if ($procedureInfo) {
         $data['procedure'] = '<br><h4>Procedures:</h4><p class="view">';
         if ($procedureInfo->proc_type != '') {
             $data['procedure'] .= '<strong>Procedure: </strong>';
             $data['procedure'] .= nl2br($procedureInfo->proc_type);
             $data['procedure'] .= '<br /><br />';
         }
         if ($procedureInfo->proc_description != '') {
             $data['procedure'] .= '<strong>Description of Procedure: </strong>';
             $data['procedure'] .= nl2br($procedureInfo->proc_description);
             $data['procedure'] .= '<br /><br />';
         }
         if ($procedureInfo->proc_complications != '') {
             $data['procedure'] .= '<strong>Complications: </strong>';
             $data['procedure'] .= nl2br($procedureInfo->proc_complications);
             $data['procedure'] .= '<br /><br />';
         }
         if ($procedureInfo->proc_ebl != '') {
             $data['procedure'] .= '<strong>Estimated Blood Loss: </strong>';
             $data['procedure'] .= nl2br($procedureInfo->proc_ebl);
             $data['procedure'] .= '<br /><br />';
         }
         $data['procedure'] .= '</p>';
     } else {
         $data['procedure'] = '';
     }
     $assessmentInfo = Assessment::find($eid);
     if ($assessmentInfo) {
         $data['assessment'] = '<br><h4>Assessment:</h4><p class="view">';
         if ($assessmentInfo->assessment_1 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_1 . '</strong><br />';
             if ($assessmentInfo->assessment_2 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_2 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_2 . '</strong><br />';
             if ($assessmentInfo->assessment_3 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_3 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_3 . '</strong><br />';
             if ($assessmentInfo->assessment_4 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_4 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_4 . '</strong><br />';
             if ($assessmentInfo->assessment_5 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_5 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_5 . '</strong><br />';
             if ($assessmentInfo->assessment_6 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_6 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_6 . '</strong><br />';
             if ($assessmentInfo->assessment_7 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_7 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_7 . '</strong><br />';
             if ($assessmentInfo->assessment_8 == '') {
                 $data['assessment'] .= '<br />';
             }
         }
         if ($assessmentInfo->assessment_8 != '') {
             $data['assessment'] .= '<strong>' . $assessmentInfo->assessment_8 . '</strong><br /><br />';
         }
         if ($assessmentInfo->assessment_other != '') {
             if ($encounterInfo->encounter_template == 'standardmtm') {
                 $data['assessment'] .= '<strong>SOAP Note: </strong>';
             } else {
                 $data['assessment'] .= '<strong>Additional Diagnoses: </strong>';
             }
             $data['assessment'] .= nl2br($assessmentInfo->assessment_other);
             $data['assessment'] .= '<br /><br />';
         }
         if ($assessmentInfo->assessment_ddx != '') {
             if ($encounterInfo->encounter_template == 'standardmtm') {
                 $data['assessment'] .= '<strong>MAP2: </strong>';
             } else {
                 $data['assessment'] .= '<strong>Differential Diagnoses Considered: </strong>';
             }
             $data['assessment'] .= nl2br($assessmentInfo->assessment_ddx);
             $data['assessment'] .= '<br /><br />';
         }
         if ($assessmentInfo->assessment_notes != '') {
             if ($encounterInfo->encounter_template == 'standardmtm') {
                 $data['assessment'] .= '<strong>Pharmacist Note: </strong>';
             } else {
                 $data['assessment'] .= '<strong>Assessment Discussion: </strong>';
             }
             $data['assessment'] .= nl2br($assessmentInfo->assessment_notes);
             $data['assessment'] .= '<br /><br />';
         }
         $data['assessment'] .= '</p>';
     } else {
         $data['assessment'] = '';
     }
     $ordersInfo1 = Orders::where('eid', '=', $eid)->get();
     if (count($ordersInfo1) > 0) {
         $data['orders'] = '<br><h4>Orders:</h4><p class="view">';
         $orders_lab_array = array();
         $orders_radiology_array = array();
         $orders_cp_array = array();
         $orders_referrals_array = array();
         foreach ($ordersInfo1 as $ordersInfo) {
             $address_row1 = Addressbook::find($ordersInfo->address_id);
             if ($address_row1) {
                 $orders_displayname = $address_row1->displayname;
             } else {
                 $orders_displayname = 'Unknown';
             }
             if ($ordersInfo->orders_labs != '') {
                 $orders_lab_array[] = 'Orders sent to ' . $orders_displayname . ': ' . nl2br($ordersInfo->orders_labs) . '<br />';
             }
             if ($ordersInfo->orders_radiology != '') {
                 $orders_radiology_array[] = 'Orders sent to ' . $orders_displayname . ': ' . nl2br($ordersInfo->orders_radiology) . '<br />';
             }
             if ($ordersInfo->orders_cp != '') {
                 $orders_cp_array[] = 'Orders sent to ' . $orders_displayname . ': ' . nl2br($ordersInfo->orders_cp) . '<br />';
             }
             if ($ordersInfo->orders_referrals != '') {
                 $orders_referrals_array[] = 'Referral sent to ' . $orders_displayname . ': ' . nl2br($ordersInfo->orders_referrals) . '<br />';
             }
         }
         if (count($orders_lab_array) > 0) {
             $data['orders'] .= '<strong>Labs: </strong>';
             foreach ($orders_lab_array as $lab_item) {
                 $data['orders'] .= $lab_item;
             }
         }
         if (count($orders_radiology_array) > 0) {
             $data['orders'] .= '<strong>Imaging: </strong>';
             foreach ($orders_radiology_array as $radiology_item) {
                 $data['orders'] .= $radiology_item;
             }
         }
         if (count($orders_cp_array) > 0) {
             $data['orders'] .= '<strong>Cardiopulmonary: </strong>';
             foreach ($orders_cp_array as $cp_item) {
                 $data['orders'] .= $cp_item;
             }
         }
         if (count($orders_referrals_array) > 0) {
             $data['orders'] .= '<strong>Referrals: </strong>';
             foreach ($orders_referrals_array as $referrals_item) {
                 $data['orders'] .= $referrals_item;
             }
         }
         $data['orders'] .= '</p>';
     } else {
         $data['orders'] = '';
     }
     $rxInfo = Rx::find($eid);
     if ($rxInfo) {
         $data['rx'] = '<br><h4>Prescriptions and Immunizations:</h4><p class="view">';
         if ($rxInfo->rx_rx != '') {
             $data['rx'] .= '<strong>Prescriptions Given: </strong>';
             $data['rx'] .= nl2br($rxInfo->rx_rx);
             $data['rx'] .= '<br /><br />';
         }
         if ($rxInfo->rx_supplements != '') {
             $data['rx'] .= '<strong>Supplements Recommended: </strong>';
             $data['rx'] .= nl2br($rxInfo->rx_supplements);
             $data['rx'] .= '<br /><br />';
         }
         if ($rxInfo->rx_immunizations != '') {
             $data['rx'] .= '<strong>Immunizations Given: </strong>';
             $data['rx'] .= 'CDC Vaccine Information Sheets given for each immunization and consent obtained.<br />';
             $data['rx'] .= nl2br($rxInfo->rx_immunizations);
             $data['rx'] .= '<br /><br />';
         }
         $data['rx'] .= '</p>';
     } else {
         $data['rx'] = '';
     }
     $planInfo = Plan::find($eid);
     if ($planInfo) {
         $data['plan'] = '<br><h4>Plan:</h4><p class="view">';
         if ($planInfo->plan != '') {
             $data['plan'] .= '<strong>Recommendations: </strong>';
             $data['plan'] .= nl2br($planInfo->plan);
             $data['plan'] .= '<br /><br />';
         }
         if ($planInfo->followup != '') {
             $data['plan'] .= '<strong>Followup: </strong>';
             $data['plan'] .= nl2br($planInfo->followup);
             $data['plan'] .= '<br /><br />';
         }
         if ($planInfo->goals != '') {
             $data['plan'] .= '<strong>Goals/Measures: </strong>';
             $data['plan'] .= nl2br($planInfo->goals);
             $data['plan'] .= '<br /><br />';
         }
         if ($planInfo->tp != '') {
             $data['plan'] .= '<strong>Treatment Plan Notes: </strong>';
             $data['plan'] .= nl2br($planInfo->tp);
             $data['plan'] .= '<br /><br />';
         }
         if ($planInfo->duration != '') {
             $data['plan'] .= 'Counseling and face-to-face time consists of more than 50 percent of the visit.  Total face-to-face time is ';
             $data['plan'] .= $planInfo->duration . ' minutes.';
             $data['plan'] .= '<br /><br />';
         }
         $data['plan'] .= '</p>';
     } else {
         $data['plan'] = '';
     }
     $billing_query = Billing_core::where('eid', '=', $eid)->get();
     if ($billing_query) {
         $data['billing'] = '<p class="view">';
         $billing_count = 0;
         foreach ($billing_query as $billing_row) {
             if ($billing_count > 0) {
                 $data['billing'] .= ',' . $billing_row->cpt;
             } else {
                 $data['billing'] .= '<strong>CPT Codes: </strong>';
                 $data['billing'] .= $billing_row->cpt;
             }
             $billing_count++;
         }
         if ($encounterInfo->bill_complex != '') {
             $data['billing'] .= '<br><strong>Medical Complexity: </strong>';
             $data['billing'] .= nl2br($encounterInfo->bill_complex);
             $data['billing'] .= '<br /><br />';
         }
         $data['billing'] .= '</p>';
     } else {
         $data['billing'] = '';
     }
     if ($modal == true) {
         if ($encounterInfo->encounter_signed == 'No') {
             $data['status'] = 'Draft';
         } else {
             $data['status'] = 'Signed on ' . date('F jS, Y', $this->human_to_unix($encounterInfo->date_signed)) . '.';
         }
         if ($addendum == true) {
             $data['addendum'] = true;
         } else {
             $data['addendum'] = false;
         }
         return View::make('modal_view', $data);
     } else {
         return View::make('encounter_view', $data);
     }
 }
 public function postBillingOtherSave()
 {
     $id = Input::get('other_billing_id');
     $query = Billing_core::find($id);
     $data = array('eid' => '0', 'pid' => Session::get('pid'), 'dos_f' => Input::get('dos_f'), 'cpt_charge' => Input::get('cpt_charge'), 'reason' => Input::get('reason'), 'unit' => '1', 'payment' => '0', 'practice_id' => Session::get('practice_id'));
     if ($query) {
         DB::table('billing_core')->where('billing_core_id', '=', $id)->update($data);
         $this->audit('Update');
         $result['message'] = 'Miscellaneous Bill Updated';
     } else {
         $id1 = DB::table('billing_core')->insertGetId($data);
         $this->audit('Add');
         $data1 = array('other_billing_id' => $id1);
         DB::table('billing_core')->where('billing_core_id', '=', $id1)->update($data1);
         $this->audit('Update');
         $result['message'] = 'Miscellaneous Bill Added';
     }
     echo json_encode($result);
 }