Ejemplo n.º 1
0
 public function dashboard()
 {
     $user_id = Session::get('user_id');
     $practice_id = Session::get('practice_id');
     $data['practiceinfo'] = Practiceinfo::find($practice_id);
     $result = User::find($user_id);
     $data['displayname'] = $result->displayname;
     $displayname = $result->displayname;
     $fax_query = Received::where('practice_id', '=', $practice_id)->count();
     $from = $displayname . ' (' . $user_id . ')';
     if (Session::get('group_id') == '2') {
         $data['number_messages'] = Messaging::where('mailbox', '=', $user_id)->count();
         $data['number_documents'] = Scans::where('practice_id', '=', $practice_id)->count() + $fax_query;
         $data['number_appts'] = $this->getNumberAppts($user_id);
         $query1 = DB::table('t_messages')->join('demographics', 't_messages.pid', '=', 'demographics.pid')->where('t_messages.t_messages_from', '=', $from)->where('t_messages.t_messages_signed', '=', 'No')->count();
         $query2 = DB::table('encounters')->join('demographics', 'encounters.pid', '=', 'demographics.pid')->where('encounters.encounter_provider', '=', $displayname)->where('encounters.encounter_signed', '=', 'No')->count();
         $data['number_drafts'] = $query1 + $query2;
         $data['number_reminders'] = DB::table('alerts')->join('demographics', 'alerts.pid', '=', 'demographics.pid')->where('alerts.alert_provider', '=', $user_id)->where('alerts.alert_date_complete', '=', '0000-00-00 00:00:00')->where('alerts.alert_reason_not_complete', '=', '')->where(function ($query_array) {
             $query_array->where('alerts.alert', '=', 'Laboratory results pending')->orWhere('alerts.alert', '=', 'Radiology results pending')->orWhere('alerts.alert', '=', 'Cardiopulmonary results pending')->orWhere('alerts.alert', '=', 'Referral pending')->orWhere('alerts.alert', '=', 'Reminder')->orWhere('alerts.alert', '=', 'REMINDER');
         })->count();
         $data['number_bills'] = Encounters::where('bill_submitted', '=', 'No')->where('user_id', '=', $user_id)->count();
         $data['number_tests'] = Tests::whereNull('pid')->where('practice_id', '=', $practice_id)->count();
         if ($data['practiceinfo']->mtm_extension == 'y') {
             $mtm_users_array = explode(",", $data['practiceinfo']->mtm_alert_users);
             if (in_array($user_id, $mtm_users_array)) {
                 $data['mtm_alerts'] = Alerts::where('alert_date_complete', '=', '0000-00-00 00:00:00')->where('alert_reason_not_complete', '=', '')->where('alert', '=', 'Medication Therapy Management')->where('practice_id', '=', $practice_id)->count();
                 $data['mtm_alerts_status'] = "y";
             } else {
                 $data['mtm_alerts_status'] = "n";
             }
         } else {
             $data['mtm_alerts_status'] = "n";
         }
         $data['vaccine_supplement_alert'] = $this->vaccine_supplement_alert($practice_id);
     }
     if (Session::get('group_id') == '3') {
         $data['number_messages'] = Messaging::where('mailbox', '=', $user_id)->count();
         $data['number_documents'] = Scans::where('practice_id', '=', $practice_id)->count() + $fax_query;
         $data['number_drafts'] = DB::table('t_messages')->join('demographics', 't_messages.pid', '=', 'demographics.pid')->where('t_messages.t_messages_from', '=', $from)->where('t_messages.t_messages_signed', '=', 'No')->count();
         $data['number_reminders'] = DB::table('alerts')->join('demographics', 'alerts.pid', '=', 'demographics.pid')->where('alerts.alert_provider', '=', $user_id)->where('alerts.alert_date_complete', '=', '0000-00-00 00:00:00')->where('alerts.alert_reason_not_complete', '=', '')->where(function ($query_array) {
             $query_array->where('alerts.alert', '=', 'Laboratory results pending')->orWhere('alerts.alert', '=', 'Radiology results pending')->orWhere('alerts.alert', '=', 'Cardiopulmonary results pending')->orWhere('alerts.alert', '=', 'Referral pending')->orWhere('alerts.alert', '=', 'Reminder')->orWhere('alerts.alert', '=', 'REMINDER');
         })->count();
         $data['number_bills'] = Encounters::where('bill_submitted', '=', 'No')->where('practice_id', '=', $practice_id)->count();
         $data['number_tests'] = Tests::whereNull('pid')->where('practice_id', '=', $practice_id)->count();
         $data['vaccine_supplement_alert'] = $this->vaccine_supplement_alert($practice_id);
     }
     if (Session::get('group_id') == '4') {
         $data['number_messages'] = Messaging::where('mailbox', '=', $user_id)->count();
         $data['number_bills'] = Encounters::where('bill_submitted', '=', 'No')->where('practice_id', '=', $practice_id)->count();
         $data['number_documents'] = Scans::where('practice_id', '=', $practice_id)->count() + $fax_query;
     }
     if (Session::get('group_id') == '100') {
         $row = Demographics_relate::where('id', '=', $user_id)->first();
         Session::put('pid', $row->pid);
     }
     if (Session::get('group_id') == '1') {
         if ($practice_id == '1') {
             $data['saas_admin'] = 'y';
         } else {
             $data['saas_admin'] = 'n';
         }
         if (Session::get('patient_centric') != 'y') {
             $users = DB::table('users')->where('group_id', '=', '2')->where('practice_id', '=', Session::get('practice_id'))->first();
             if ($users) {
                 $data['users_needed'] = 'n';
             } else {
                 $data['users_needed'] = 'y';
             }
         } else {
             $data['users_needed'] = 'n';
         }
         if (Session::get('patient_centric') != 'y') {
             $schedule = DB::table('practiceinfo')->where('practice_id', '=', Session::get('practice_id'))->whereNull('minTime')->first();
             if ($schedule) {
                 $data['schedule_needed'] = 'y';
             } else {
                 $data['schedule_needed'] = 'n';
             }
         } else {
             $data['schedule_needed'] = 'n';
         }
     }
     if ($data['practiceinfo']->weekends == '1') {
         $data['weekends'] = 'true';
     } else {
         $data['weekends'] = 'false';
     }
     $data['minTime'] = ltrim($data['practiceinfo']->minTime, "0");
     $data['maxTime'] = ltrim($data['practiceinfo']->maxTime, "0");
     if (Session::get('group_id') == '2') {
         $provider = Providers::find(Session::get('user_id'));
         $data['schedule_increment'] = $provider->schedule_increment;
     } else {
         $data['schedule_increment'] = '15';
     }
     if (!Session::get('encounter_active')) {
         Session::put('encounter_active', 'n');
     }
     if ($data['practiceinfo']->fax_type != "") {
         $data1['fax'] = true;
     } else {
         $data1['fax'] = false;
     }
     $this->layout->style = $this->css_assets();
     $this->layout->script = $this->js_assets('home');
     $this->layout->content = '';
     if (Session::get('group_id') == '1') {
         $this->layout->content .= View::make('search', $this->getSearchData())->render();
         $this->layout->content .= View::make('dashboard', $data)->render();
         $this->layout->content .= View::make('setup')->render();
         $this->layout->content .= View::make('users')->render();
         $this->layout->content .= View::make('extensions', $data)->render();
         $this->layout->content .= View::make('schedule_admin')->render();
         $this->layout->content .= View::make('update')->render();
         $this->layout->content .= View::make('logs')->render();
         $this->layout->content .= View::make('schedule')->render();
     }
     if (Session::get('group_id') == '2' || Session::get('group_id') == '3' || Session::get('group_id') == '4') {
         $this->layout->content .= View::make('search', $this->getSearchData())->render();
         $this->layout->content .= View::make('dashboard', $data)->render();
         $this->layout->content .= View::make('demographics')->render();
         $this->layout->content .= View::make('options')->render();
         $this->layout->content .= View::make('messaging', $data1)->render();
         $this->layout->content .= View::make('schedule')->render();
         $this->layout->content .= View::make('billing')->render();
         $this->layout->content .= View::make('financial')->render();
         $this->layout->content .= View::make('office')->render();
         if (Session::get('patient_centric') == 'yp' && Session::get('group_id') == '2') {
             $this->layout->content .= View::make('setup')->render();
         }
     }
     if (Session::get('group_id') == '100') {
         $this->layout->content .= View::make('dashboard', $data)->render();
         $this->layout->content .= View::make('demographics')->render();
         $this->layout->content .= View::make('messaging', $data1)->render();
         $this->layout->content .= View::make('schedule')->render();
         $this->layout->content .= View::make('issues')->render();
         $this->layout->content .= View::make('encounters')->render();
         $this->layout->content .= View::make('t_messages')->render();
         $this->layout->content .= View::make('medications')->render();
         $this->layout->content .= View::make('supplements')->render();
         $this->layout->content .= View::make('allergies')->render();
         $this->layout->content .= View::make('immunizations')->render();
         $this->layout->content .= View::make('documents')->render();
         $this->layout->content .= View::make('forms')->render();
         $this->layout->content .= View::make('graph')->render();
     }
 }
 public function postDemographicsList()
 {
     $practice_id = Session::get('practice_id');
     $pid = Session::get('pid');
     $row = Demographics::find($pid);
     $row_relate = Demographics_relate::where('pid', '=', $pid)->where('practice_id', '=', $practice_id)->first();
     $result = '';
     if ($row) {
         $result .= '<p class="tips"><strong>Address:</strong><br>' . $row->address . '<br>' . $row->city . ', ' . $row->state . ' ' . $row->zip . '</p>';
         $result .= '<p class="tips"><strong>Phone Numbers:</strong><br>Home: ' . $row->phone_home . '<br>Work: ' . $row->phone_work . '<br>Cell: ' . $row->phone_cell . '<br>Email: ' . $row->email . '</p>';
         $result .= '<p class="tips"><strong>Emergency Contact:</strong><br>Contact: ' . $row->emergency_contact . ', ' . $row->emergency_phone . '</p>';
         $gender = Session::get('gender');
         if ($gender == 'female') {
             if ($row->pregnant != 'no') {
                 $pregnant = 'Yes';
             } else {
                 $pregnant = 'No';
             }
             $result .= '<p class="tips"><strong>Other:</strong><br>Sexually Active: ' . ucfirst($row->sexuallyactive) . '<br>Tobacco Use: ' . ucfirst($row->tobacco) . '<br>Pregnant: ' . $pregnant . '</p>';
         } else {
             $result .= '<p class="tips"><strong>Other:</strong><br>Sexually Active: ' . ucfirst($row->sexuallyactive) . '<br>Tobacco Use: ' . ucfirst($row->tobacco) . '</p>';
         }
         $result .= '<p class="tips">Active since ' . $row->date . '</p>';
         if ($row_relate->id != '') {
             $result .= '<p class="tips">Online account is active.</p>';
         } else {
             $result .= '<p class="tips">No online account.</p>';
         }
         $schedule1 = Schedule::where('pid', '=', $pid)->where('status', '=', 'LMC')->get();
         $schedule2 = Schedule::where('pid', '=', $pid)->where('status', '=', 'DNKA')->get();
         $result .= '<p class="tips"><strong># Last minute cancellations: ' . count($schedule1) . '</strong></p>';
         $result .= '<p class="tips"><strong># Did not keep appointments: ' . count($schedule2) . '</strong></p>';
         $result .= '<p class="tips"><strong>Billing Notes:</strong><br>' . nl2br($row->billing_notes) . '</p>';
         $query1 = Insurance::where('pid', '=', $pid)->where('insurance_plan_active', '=', 'Yes')->get();
         if ($query1) {
             $result .= '<p class="tips"><strong>Active Insurance:</strong>';
             foreach ($query1 as $row1) {
                 $result .= '<br>' . $row1->insurance_plan_name . '; ID: ' . $row1->insurance_id_num . '; Group: ' . $row1->insurance_group;
                 if ($row1->insurance_copay != '') {
                     $result .= '; Copay: ' . $row1->insurance_copay;
                 }
                 if ($row1->insurance_deductible != '') {
                     $result .= '; Deductible: ' . $row1->insurance_deductible;
                 }
                 if ($row1->insurance_comments != '') {
                     $result .= '; Comments: ' . $row1->insurance_comments;
                 }
             }
             $result .= '</p>';
         }
         $result .= '<p class="tips"><strong>Credit Card on File: ';
         if ($row->creditcard_number != '') {
             $result .= 'Yes';
         } else {
             $result .= 'No';
         }
         $result .= '</strong></p>';
     } else {
         $result .= 'None available.';
     }
     echo $result;
 }
 public function postPrintEntireCcda()
 {
     if (Session::get('group_id') != '1') {
         Auth::logout();
         Session::flush();
         header("HTTP/1.1 404 Page Not Found", true, 404);
         exit("You cannot do this.");
     } else {
         $track = __DIR__ . '/../../public/temp/track';
         File::put($track, '0');
         ini_set('memory_limit', '196M');
         ini_set('max_execution_time', 300);
         $practice_id = Session::get('practice_id');
         $query = Demographics_relate::where('practice_id', '=', $practice_id)->get();
         $zip_file_name = 'ccda_' . $practice_id . '.zip';
         $zip_file = __DIR__ . '/../../public/temp/' . $zip_file_name;
         if (file_exists($zip_file)) {
             unlink($zip_file);
         }
         $zip = new ZipArchive();
         if ($zip->open($zip_file, ZipArchive::CREATE) !== TRUE) {
             exit("Cannot open <{$zip_file}>\n");
         }
         $files_array = array();
         $i = 0;
         $count = count($query);
         foreach ($query as $row) {
             $filename = 'ccda_' . $row->pid . "_" . time() . ".xml";
             $file = __DIR__ . '/../../public/temp/' . $filename;
             $query1 = DB::table('demographics')->where('pid', '=', $row->pid)->first();
             if ($query1) {
                 $ccda = $this->generate_ccda('', $row->pid);
                 File::put($file, $ccda);
                 $files_array[$i]['file'] = $file;
                 $files_array[$i]['filename'] = $filename;
                 $i++;
                 $percent = round($i / $count * 100);
                 File::put($track, $percent);
             }
         }
         foreach ($files_array as $ccda1) {
             $zip->addFile($ccda1['file'], $ccda1['filename']);
         }
         $zip->close();
         while (!file_exists($zip_file)) {
             sleep(2);
         }
         echo link_to_asset('temp/' . $zip_file_name, 'Download File', $attributes = array(), $secure = null);
     }
 }