public function postCopyEncounter() { $eid = Input::get('copy_encounter_from'); $encounter = Encounters::find(Session::get('eid')); if ($encounter->encounter_template == 'standardmedical') { $table_array1 = array("hpi", "ros", "vitals", "pe", "labs", "procedure", "rx", "assessment", "plan"); $table_array2 = array("other_history"); } if ($encounter->encounter_template == 'clinicalsupport') { $table_array1 = array("hpi", "labs", "procedure", "rx", "assessment", "plan"); $table_array2 = array("other_history"); } if ($encounter->encounter_template == 'standardpsych' || $encounter->encounter_template == 'standardpsych1') { $table_array1 = array("hpi", "ros", "vitals", "pe", "rx", "assessment", "plan"); $table_array2 = array("other_history"); } foreach ($table_array1 as $table1) { $table_query1 = DB::table($table1)->where('eid', '=', $eid)->first(); if ($table_query1) { $data2 = (array) $table_query1; unset($data2['eid']); $data2['eid'] = Session::get('eid'); $query1 = DB::table($table1)->where('eid', '=', Session::get('eid'))->first(); if ($query1) { DB::table($table1)->where('eid', '=', Session::get('eid'))->update($data2); $this->audit('Update'); } else { DB::table($table1)->insert($data2); $this->audit('Add'); } } } $table_query2 = DB::table('other_history')->where('eid', '=', $eid)->get(); if ($table_query2) { foreach ($table_query2 as $table_row) { $data3 = (array) $table_row; unset($data3['eid']); unset($data3['oh_id']); $data3['eid'] = Session::get('eid'); $query2 = DB::table('other_history')->where('eid', '=', Session::get('eid'))->first(); if ($query2) { $data3[$primary] = $query2->oh_id; DB::table('other_history')->where('oh_id', '=', $query2->oh_id)->update($data3); $this->audit('Update'); } else { DB::table('other_history')->insert($data3); $this->audit('Add'); } } } echo "Copied previous encounter elements to new encounter."; }
public function postPreviousEncounters() { $encounter = Encounters::find(Session::get('eid')); $query = DB::table('encounters')->where('pid', '=', Session::get('pid'))->where('addendum', '=', 'n')->where('practice_id', '=', Session::get('practice_id'))->orderBy('encounter_DOS', 'asc')->where('eid', '!=', Session::get('eid')); if ($encounter->encounter_template == 'standardpsych' || $encounter->encounter_template == 'standardpsych1') { $query->where(function ($query_array1) { $query_array1->where('encounter_template', '=', 'standardpsych')->orWhere('encounter_template', '=', 'standardpsych1'); }); } else { $query->where('encounter_template', '=', $encounter->encounter_template); } $result = $query->get(); $data = array(); if ($result) { foreach ($result as $row) { $key = $row->eid; $value = date('Y-m-d', $this->human_to_unix($row->encounter_DOS)) . ' (Chief complaint: ' . $row->encounter_cc . ')'; $data[$key] = $value; } } echo json_encode($data); }
public function dashboard() { $practice = DB::table('practiceinfo')->where('practice_id', '=', Session::get('practice_id'))->first(); $user_id = Session::get('user_id'); $result = User::find($user_id); $practice_id = Session::get('practice_id'); $fax_query = Received::where('practice_id', '=', $practice_id)->count(); $displayname = $result->displayname; $from = $displayname . ' (' . $user_id . ')'; $data['header'] = $this->mobile_header_build(Session::get('displayname')); if (Session::get('group_id') == '2') { $data1['number_messages'] = Messaging::where('mailbox', '=', $user_id)->count(); $data1['number_documents'] = Scans::where('practice_id', '=', $practice_id)->count() + $fax_query; $data1['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(); $data1['number_drafts'] = $query1 + $query2; $data1['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(); $data1['number_bills'] = Encounters::where('bill_submitted', '=', 'No')->where('user_id', '=', $user_id)->count(); $data1['number_tests'] = Tests::whereNull('pid')->where('practice_id', '=', $practice_id)->count(); } $data['content'] = View::make('mobile.home_content', $data1)->render(); $data['form'] = ''; $left_panel_array = array(array('Schedule', 'mobile_schedule'), array('Inbox', 'mobile_inbox')); if (Session::get('group_id') != '100') { $left_panel_array[] = array('Drafts', 'mobile_drafts'); $left_panel_array[] = array('Alerts', 'mobile_alerts'); if (Session::get('patient_centric') == 'n') { $left_panel_array[] = array('Scans', 'mobile_scan'); if ($practice->fax_type != "") { $left_panel_array[] = array('Faxes', 'mobile_fax'); } } } $data['left_panel'] = $this->mobile_menu_build($left_panel_array, "left_panel_list", 'mobile_click_home'); $data['right_panel'] = ''; $this->layout->style = HTML::style('css/mobile.css'); $this->layout->style .= HTML::style('css/toastr.min.css'); $this->layout->script = $this->js_assets('base', true); $this->layout->content = View::make('mobile.home', $data); }
protected function page_invoice1($eid) { $pid = Session::get('pid'); $assessmentInfo = Assessment::find($eid); if ($assessmentInfo) { $data['assessment'] = ''; if ($assessmentInfo->assessment_1 != '') { $data['assessment'] .= $assessmentInfo->assessment_1 . '<br />'; if ($assessmentInfo->assessment_2 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_2 != '') { $data['assessment'] .= $assessmentInfo->assessment_2 . '<br />'; if ($assessmentInfo->assessment_3 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_3 != '') { $data['assessment'] .= $assessmentInfo->assessment_3 . '<br />'; if ($assessmentInfo->assessment_4 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_4 != '') { $data['assessment'] .= $assessmentInfo->assessment_4 . '<br />'; if ($assessmentInfo->assessment_5 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_5 != '') { $data['assessment'] .= $assessmentInfo->assessment_5 . '<br />'; if ($assessmentInfo->assessment_6 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_6 != '') { $data['assessment'] .= $assessmentInfo->assessment_6 . '<br />'; if ($assessmentInfo->assessment_7 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_7 != '') { $data['assessment'] .= $assessmentInfo->assessment_7 . '<br />'; if ($assessmentInfo->assessment_8 == '') { $data['assessment'] .= '<br />'; } } if ($assessmentInfo->assessment_8 != '') { $data['assessment'] .= $assessmentInfo->assessment_8 . '<br /><br />'; } } else { $data['assessment'] = ''; } $result1 = DB::table('billing_core')->where('eid', '=', $eid)->orderBy('cpt_charge', 'desc')->get(); if ($result1) { $charge = 0; $payment = 0; $data['text'] = '<table class="pure-table"><tr><th style="width:14%">PROCEDURE</th><th style="width:14%">UNITS</th><th style="width:50%">DESCRIPTION</th><th style="width:22%">CHARGE PER UNIT</th></tr>'; foreach ($result1 as $key1 => $value1) { $cpt_charge1[$key1] = $value1->cpt_charge; } array_multisort($cpt_charge1, SORT_DESC, $result1); foreach ($result1 as $result1a) { if ($result1a->cpt) { $query2 = DB::table('cpt_relate')->where('cpt', '=', $result1a->cpt)->first(); if ($query2) { $result2 = DB::table('cpt_relate')->where('cpt', '=', $result1a->cpt)->first(); } else { $result2 = DB::table('cpt')->where('cpt', '=', $result1a->cpt)->first(); } $data['text'] .= '<tr><td>' . $result1a->cpt . '</td><td>' . $result1a->unit . '</td><td>' . $result2->cpt_description . '</td><td>$' . $result1a->cpt_charge . '</td></tr>'; $charge += $result1a->cpt_charge * $result1a->unit; } else { $data['text'] .= '<tr><td>Date of Payment:</td><td>' . $result1a->dos_f . '</td><td>' . $result1a->payment_type . '</td><td">$(' . $result1a->payment . ')</td></tr>'; $payment = $payment + $result1a->payment; } } $balance = $charge - $payment; $charge = number_format($charge, 2, '.', ','); $payment = number_format($payment, 2, '.', ','); $balance = number_format($balance, 2, '.', ','); $data['text'] .= '<tr><td></td><td></td><td><strong>Total Charges:</strong></td><td><strong>$' . $charge . '</strong></td></tr><tr><td></td><td></td><td><strong>Total Payments:</strong></td><td><strong>$' . $payment . '</strong></td></tr><tr><td></td><td></td><td></td><td><hr/></td></tr><tr><td></td><td></td><td><strong>Remaining Balance:</strong></td><td><strong>$' . $balance . '</strong></td></tr></table>'; } else { $data['text'] = 'No procedures.'; } $row = Demographics::find($pid); $practice = Practiceinfo::find(Session::get('practice_id')); $data['practiceName'] = $practice->practice_name; $data['practiceInfo1'] = $practice->street_address1; if ($practice->street_address2 != '') { $data['practiceInfo1'] .= ', ' . $practice->street_address2; } $data['practiceInfo2'] = $practice->city . ', ' . $practice->state . ' ' . $practice->zip; $data['practiceInfo3'] = 'Phone: ' . $practice->phone . ', Fax: ' . $practice->fax; $data['disclaimer'] = '<br>Please send a check payable to ' . $practice->practice_name . ' and mail it to:'; $data['disclaimer'] .= '<br>' . $practice->billing_street_address1; if ($practice->billing_street_address2 != '') { $data['text'] .= ', ' . $practice->billing_street_address2; } $data['disclaimer'] .= '<br>' . $practice->billing_city . ', ' . $practice->billing_state . ' ' . $practice->billing_zip; $data['patientInfo1'] = $row->firstname . ' ' . $row->lastname; $data['patientInfo2'] = $row->address; $data['patientInfo3'] = $row->city . ', ' . $row->state . ' ' . $row->zip; $data['patientInfo'] = $row; $data['dob'] = date('m/d/Y', $this->human_to_unix($row->DOB)); $encounterInfo = Encounters::find($eid); $data['encounter_DOS'] = date('F jS, Y', $this->human_to_unix($encounterInfo->encounter_DOS)); $data['encounter_provider'] = $encounterInfo->encounter_provider; $query1 = DB::table('insurance')->where('pid', '=', $pid)->where('insurance_plan_active', '=', 'Yes')->get(); $data['insuranceInfo'] = ''; if ($query1) { foreach ($query1 as $row1) { $data['insuranceInfo'] .= $row1->insurance_plan_name . '; ID: ' . $row1->insurance_id_num . '; Group: ' . $row1->insurance_group . '; ' . $row1->insurance_insu_lastname . ', ' . $row1->insurance_insu_firstname . '<br><br>'; } } $data['title'] = "INVOICE"; $data['date'] = date('F jS, Y', time()); $result = DB::table('demographics_notes')->where('pid', '=', Session::get('pid'))->where('practice_id', '=', Session::get('practice_id'))->first(); if (is_null($result->billing_notes) || $result->billing_notes == '') { $billing_notes = 'Invoice for encounter (Date of Service: ' . $data['encounter_DOS'] . ') printed on ' . $data['date'] . '.'; } else { $billing_notes = $result->billing_notes . "\n" . 'Invoice for encounter (Date of Service: ' . $data['encounter_DOS'] . ') printed on ' . $data['date'] . '.'; } $billing_notes_data = array('billing_notes' => $billing_notes); DB::table('demographics_notes')->where('pid', '=', Session::get('pid'))->where('practice_id', '=', Session::get('practice_id'))->update($billing_notes_data); $this->audit('Update'); return View::make('pdf.invoice_page', $data); }
public function postGetPrevention($eid) { $pid = Session::get('pid'); $row = Demographics::find($pid); $dob1 = $this->human_to_unix($row->DOB); $encounterInfo = Encounters::find($eid); $dos1 = $this->human_to_unix($encounterInfo->encounter_DOS); $agediff = $dos1 - $dob1; if ($agediff < 31556926) { $data['prevent_established1'] = '99391'; $data['prevent_new1'] = '99381'; } if ($agediff >= 31556926 && $agediff < 157784630) { $data['prevent_established1'] = '99392'; $data['prevent_new1'] = '99382'; } if ($agediff >= 157784630 && $agediff < 378683112) { $data['prevent_established1'] = '99393'; $data['prevent_new1'] = '99383'; } if ($agediff >= 378683112 && $agediff < 568024668) { $data['prevent_established1'] = '99394'; $data['prevent_new1'] = '99384'; } if ($agediff >= 568024668 && $agediff < 1262277040) { $data['prevent_established1'] = '99395'; $data['prevent_new1'] = '99385'; } if ($agediff >= 1262277040 && $agediff < 2051200190) { $data['prevent_established1'] = '99396'; $data['prevent_new1'] = '99386'; } if ($agediff >= 2051200190) { $data['prevent_established1'] = '99397'; $data['prevent_new1'] = '99387'; } echo json_encode($data); }
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 postTagQuery($pid) { $practice_id = Session::get('practice_id'); $query_text = DB::table('tags_relate'); $tags = Input::get('tags_array'); foreach ($tags[0] as $tag) { $query_text->where('tags_id', '=', $tag); } if ($pid != '0') { $query_text->where('pid', '=', $pid); } $page = Input::get('page'); $limit = Input::get('rows'); $sidx = Input::get('sidx'); $sord = Input::get('sord'); $sord = strtolower($sord); $query = $query_text->get(); if ($query) { $count = count($query); $total_pages = ceil($count / $limit); } else { $count = 0; $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } $start = $limit * $page - $limit; if ($start < 0) { $start = 0; } $query1 = $query_text->orderBy($sidx, $sord)->skip($start)->take($limit)->get(); $response['page'] = $page; $response['total'] = $total_pages; $response['records'] = $count; if ($query1) { $records1 = array(); $i = 0; foreach ($query1 as $row) { $records1[$i]['index'] = $i; $records1[$i]['pid'] = $row->pid; $row1 = Demographics::find($row->pid); $records1[$i]['lastname'] = $row1->lastname; $records1[$i]['firstname'] = $row1->firstname; if ($row->eid != '') { $row2 = Encounters::find($row->eid); $records1[$i]['doc_date'] = $row2->encounter_date; $records1[$i]['doctype'] = 'Encounter'; $records1[$i]['doctype_index'] = 'eid'; $records1[$i]['doc_id'] = $row->eid; } if ($row->t_messages_id != '') { $row3 = T_messages::find($row->t_messages_id); $records1[$i]['doc_date'] = $row3->t_messages_date; $records1[$i]['doctype'] = 'Telephone Message'; $records1[$i]['doctype_index'] = 't_messages_id'; $records1[$i]['doc_id'] = $row->t_messages_id; } if ($row->message_id != '') { $row4 = Messaging::find($row->message_id); $records1[$i]['doc_date'] = $row4->date; $records1[$i]['doctype'] = 'Message'; $records1[$i]['doctype_index'] = 'message_id'; $records1[$i]['doc_id'] = $row->message_id; } if ($row->documents_id != '') { $row5 = Documents::find($row->documents_id); $records1[$i]['doc_date'] = $row5->documents_date; $records1[$i]['doctype'] = 'Documents'; $records1[$i]['doctype_index'] = 'documents_id'; $records1[$i]['doc_id'] = $row->documents_id; } if ($row->hippa_id != '') { $row6 = Hippa::find($row->hippa_id); $records1[$i]['doc_date'] = $row6->hippa_date_release; $records1[$i]['doctype'] = 'Records Release'; $records1[$i]['doctype_index'] = 'hippa_id'; $records1[$i]['doc_id'] = $row->hippa_id; } if ($row->appt_id != '') { $row7 = Schedule::find($row->appt_id); $records1[$i]['doc_date'] = $row7->timestamp; $records1[$i]['doctype'] = 'Appointment'; $records1[$i]['doctype_index'] = 'appt_id'; $records1[$i]['doc_id'] = $row->appt_id; } if ($row->tests_id != '') { $row8 = Tests::find($row->tests_id); $records1[$i]['doc_date'] = $row8->test_datetime; $records1[$i]['doctype'] = 'Test Results'; $records1[$i]['doctype_index'] = 'tests_id'; $records1[$i]['doc_id'] = $row->tests_id; } if ($row->mtm_id != '') { $row9 = Mtm::find($row->mtm_id); $records1[$i]['doc_date'] = $row9->mtm_date_completed; $records1[$i]['doctype'] = 'Medication Therapy Management'; $records1[$i]['doctype_index'] = 'mtm_id'; $records1[$i]['doc_id'] = $row->mtm_id; } $i++; } $response['rows'] = $records1; } else { $response['rows'] = ''; } echo json_encode($response); }