public function print_ccr() { $pid = Session::get('pid'); ini_set('memory_limit', '196M'); $user_id = Session::get('user_id'); $row = Demographics::find($pid); $header = strtoupper($row->lastname . ', ' . $row->firstname . '(DOB: ' . date('m/d/Y', $this->human_to_unix($row->DOB)) . ', Gender: ' . ucfirst(Session::get('gender')) . ', ID: ' . $pid . ')'); $html = $this->page_intro('Continuity of Care Record', Session::get('practice_id'))->render(); $html .= $this->page_ccr($pid)->render(); $file_path = __DIR__ . "/../../public/temp/ccr_" . time() . "_" . $user_id . ".pdf"; $this->generate_pdf($html, $file_path, 'footerpdf', $header, '2'); while (!file_exists($file_path)) { sleep(2); } return Response::download($file_path); }
public function get_results() { $dir = '/srv/ftp/shared/import/'; $files = scandir($dir); $count = count($files); $full_count = 0; for ($i = 2; $i < $count; $i++) { $line = $files[$i]; $file = $dir . $line; $hl7 = file_get_contents($file); $hl7_lines = explode("\r", $hl7); $results = array(); $j = 0; $result_last = ''; $from = ''; foreach ($hl7_lines as $line) { $line_section = explode("|", $line); if ($line_section[0] == "MSH") { if (strpos($line_section[3], "LAB") !== FALSE) { $test_type = "Laboratory"; } else { $test_type = "Imaging"; } } if ($line_section[0] == "PID") { $name_section = explode("^", $line_section[5]); $lastname = $name_section[0]; $firstname = $name_section[1]; $year = substr($line_section[7], 0, 4); $month = substr($line_section[7], 4, 2); $day = substr($line_section[7], 6, 2); $dob = $year . "-" . $month . "-" . $day . " 00:00:00"; $sex = strtolower($line_section[8]); } if ($line_section[0] == "ORC") { $provider_section = explode("^", $line_section[12]); $provider_lastname = $provider_section[1]; $provider_firstname = $provider_section[2]; $provider_id = $provider_section[0]; $practice_section = explode("^", $line_section[17]); $practice_lab_id = $practice_section[0]; } if ($line_section[0] == "OBX") { $test_name_section = explode("^", $line_section[3]); $results[$j]['test_name'] = $test_name_section[1]; $results[$j]['test_result'] = $line_section[5]; $results[$j]['test_units'] = $line_section[6]; $results[$j]['test_reference'] = $line_section[7]; $results[$j]['test_flags'] = $line_section[8]; $year1 = substr($line_section[14], 0, 4); $month1 = substr($line_section[14], 4, 2); $day1 = substr($line_section[14], 6, 2); $hour1 = substr($line_section[14], 8, 2); $minute1 = substr($line_section[14], 10, 2); $results[$j]['test_datetime'] = $year1 . "-" . $month1 . "-" . $day1 . " " . $hour1 . ":" . $minute1 . ":00"; $j++; } if ($line_section[0] == "NTE") { if ($line_section[1] == '1') { $result_last = $j - 1; } if ($line_section[2] == "TX") { $from = $line_section[3] . ", Ordering Provider: " . $provider_firstname . ' ' . $provider_lastname; $keys = array_keys($results); foreach ($keys as $key) { $results[$key]['test_from'] = $from; } } else { $results[$result_last]['test_result'] .= "\n" . $line_section[3]; } } } $practice_id = ''; $practice_row_test = Practiceinfo::where('peacehealth_id', '=', $practice_lab_id)->first(); if (!$practice_row_test) { $patient_row = Demographics::where('lastname', '=', $lastname)->where('firstname', '=', $firstname)->where('DOB', '=', $dob)->where('sex', '=', $sex)->first(); if ($patient_row) { $pid = $patient_row->pid; $demo_relate = DB::table('demographics_relate')->where('pid', '=', $pid)->first(); if ($demo_relate) { $practice_id = $demo_relate->practice_id; } } } else { $practice_id = $practice_row_test->practice_id; } if ($practice_id != '') { $practice_row = Practiceinfo::find($practice_id); Config::set('app.timezone', $practice_row->timezone); $provider_row = DB::table('users')->join('providers', 'providers.id', '=', 'users.id')->select('users.lastname', 'users.firstname', 'users.title', 'users.id')->where('providers.peacehealth_id', '=', $provider_id)->first(); if ($provider_row) { $provider_id = $provider_row->id; } else { $provider_id = ''; } $patient_row = Demographics::where('lastname', '=', $lastname)->where('firstname', '=', $firstname)->where('DOB', '=', $dob)->where('sex', '=', $sex)->first(); if ($patient_row) { $pid = $patient_row->pid; $dob_message = date("m/d/Y", strtotime($patient_row->DOB)); $patient_name = $patient_row->lastname . ', ' . $patient_row->firstname . ' (DOB: ' . $dob_message . ') (ID: ' . $pid . ')'; $tests = 'y'; $test_desc = ""; $k = 0; foreach ($results as $results_row) { $test_data = array('pid' => $pid, 'test_name' => $results_row['test_name'], 'test_result' => $results_row['test_result'], 'test_units' => $results_row['test_units'], 'test_reference' => $results_row['test_reference'], 'test_flags' => $results_row['test_flags'], 'test_from' => $from, 'test_datetime' => $results_row['test_datetime'], 'test_type' => $test_type, 'test_provider_id' => $provider_id, 'practice_id' => $practice_id); DB::table('tests')->insert($test_data); $this->audit('Add'); if ($k == 0) { $test_desc .= $results_row['test_name']; } else { $test_desc .= ", " . $results_row['test_name']; } $k++; } $practice_row = Practiceinfo::find($practice_id); $directory = $practice_row->documents_dir . $pid; $file_path = $directory . '/tests_' . time() . '.pdf'; $html = $this->page_intro('Test Results', $practice_id); $html .= $this->page_results($pid, $results, $patient_name); $this->generate_pdf($html, $file_path); $documents_date = date("Y-m-d H:i:s", time()); $test_desc = 'Test results for ' . $patient_name; $pages_data = array('documents_url' => $file_path, 'pid' => $pid, 'documents_type' => $test_type, 'documents_desc' => $test_desc, 'documents_from' => $from, 'documents_date' => $documents_date); $documents_id = DB::table('documents')->insertGetId($pages_data); $this->audit('Add'); } else { $messages_pid = ''; $patient_name = "Unknown patient: " . $lastname . ", " . $firstname . ", DOB: " . $month . "/" . $day . "/" . $year; $tests = 'unk'; foreach ($results as $results_row) { $test_data = array('test_name' => $results_row['test_name'], 'test_result' => $results_row['test_result'], 'test_units' => $results_row['test_units'], 'test_reference' => $results_row['test_reference'], 'test_flags' => $results_row['test_flags'], 'test_unassigned' => $patient_name, 'test_from' => $from, 'test_datetime' => $results_row['test_datetime'], 'test_type' => $test_type, 'test_provider_id' => $provider_id, 'practice_id' => $practice_id); DB::table('tests')->insert($test_data); $this->audit('Add'); } $documents_id = ''; } $subject = "Test results for " . $patient_name; $body = "Test results for " . $patient_name . "\n\n"; foreach ($results as $results_row1) { $body .= $results_row1['test_name'] . ": " . $results_row1['test_result'] . ", Units: " . $results_row1['test_units'] . ", Normal reference range: " . $results_row1['test_reference'] . ", Date: " . $results_row1['test_datetime'] . "\n"; } $body .= "\n" . $from; if ($tests = "unk") { $body .= "\n" . "Patient is unknown to the system. Please reconcile this test result in your dashboard."; } if ($provider_id != '') { $provider_name = $provider_row->firstname . " " . $provider_row->lastname . ", " . $provider_row->title . " (" . $provider_id . ")"; $data_message = array('pid' => $pid, 'message_to' => $provider_name, 'message_from' => $provider_row['id'], 'subject' => $subject, 'body' => $body, 'patient_name' => $patient_name, 'status' => 'Sent', 'mailbox' => $provider_id, 'practice_id' => $practice_id, 'documents_id' => $documents_id); DB::table('messaging')->insert($data_message); $this->audit('Add'); } $file1 = str_replace('/srv/ftp/shared/import/', '', $file); rename($file, $practice_row->documents_dir . $file1); $full_count++; } else { $file1 = str_replace('/srv/ftp/shared/import/', '', $file); rename($file, $practice_row->documents_dir . $file1 . '.error'); } } return $full_count; }
public function postCompileBilling() { $eid = Session::get('eid'); $pid = Session::get('pid'); $practice_id = Session::get('practice_id'); $row = Demographics::find($pid); $encounterInfo = Encounters::find($eid); $dos1 = $this->human_to_unix($encounterInfo->encounter_DOS); $dos = date('mdY', $dos1); $dos2 = date('m/d/Y', $dos1); $pos = $encounterInfo->encounter_location; $assessment_data = Assessment::find($eid); $icd_pointer = ''; if ($assessment_data->assessment_1 != '') { $icd_pointer .= "A"; } if ($assessment_data->assessment_2 != '') { $icd_pointer .= "B"; } if ($assessment_data->assessment_3 != '') { $icd_pointer .= "C"; } if ($assessment_data->assessment_4 != '') { $icd_pointer .= "D"; } $labsInfo = Labs::find($eid); if ($labsInfo) { 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 != '') { $this->compile_procedure_billing('81002', $eid, $pid, $dos2, $icd_pointer, $practice_id); } if ($labsInfo->labs_upt != '') { $this->compile_procedure_billing('81025', $eid, $pid, $dos2, $icd_pointer, $practice_id); } if ($labsInfo->labs_strep != '') { $this->compile_procedure_billing('87880', $eid, $pid, $dos2, $icd_pointer, $practice_id); } if ($labsInfo->labs_mono != '') { $this->compile_procedure_billing('86308', $eid, $pid, $dos2, $icd_pointer, $practice_id); } if ($labsInfo->labs_flu != '') { $this->compile_procedure_billing('87804', $eid, $pid, $dos2, $icd_pointer, $practice_id); } if ($labsInfo->labs_glucose != '') { $this->compile_procedure_billing('82962', $eid, $pid, $dos2, $icd_pointer, $practice_id); } } $result9 = Procedure::find($eid); if ($result9) { $this->compile_procedure_billing($result9->proc_cpt, $eid, $pid, $dos2, $icd_pointer, $practice_id); } $result11 = Immunizations::where('eid', '=', $eid)->get(); if ($result11) { foreach ($result11 as $row11) { $this->compile_procedure_billing($row11->cpt, $eid, $pid, $dos2, $icd_pointer, $practice_id); } } echo 'CPT codes complied from the encounter!'; }
protected function schedule_notification($appt_id) { $row1 = Schedule::find($appt_id); if ($row1->pid != '0') { $row = Demographics::find($row1->pid); $row2 = Practiceinfo::find(Session::get('practice_id')); $row0 = User::find($row1->provider_id); $displayname = $row0->displayname; $to = $row->reminder_to; $phone = $row2->phone; $startdate = date("F j, Y, g:i a", $row1->start); if ($row1->start < time()) { if ($to != '') { $data_message['startdate'] = date("F j, Y, g:i a", $row1->start); $data_message['displayname'] = $row0->displayname; $data_message['phone'] = $row2->phone; $data_message['email'] = $row2->email; $data_message['additional_message'] = $row2->additional_message; if ($row->reminder_method == 'Cellular Phone') { $this->send_mail(array('text' => 'emails.remindertext'), $data_message, 'Appointment Reminder', $to, Session::get('practice_id')); } else { $this->send_mail('emails.reminder', $data_message, 'Appointment Reminder', $to, Session::get('practice_id')); } } } } }
public function postElectronicOrders() { $pid = Session::get('pid'); $orders_id = Input::get('orders_id'); $row = Orders::find($orders_id); $row1 = Addressbook::find($row->address_id); if ($row1->electronic_order == '') { echo "Laboratory provider is not configured for electronic order entry. Please use an alternate method for delivery."; exit(0); } else { $row2 = Demographics::find($pid); $row3 = User::find($row->id); $row4 = Providers::find($row->id); if ($row1->electronic_order == 'PeaceHealth') { $date = date('YmdHi'); $dob = date('Ymd', $this->human_to_unix($row2->DOB)); $order_date = date('YmdHi', $this->human_to_unix($row->orders_pending_date)); $middle = substr($row3->middle, 0, 1); $pname = substr($row3->lastname, 0, 5) . substr($row3->firstname, 0, 1) . substr($row3->middle, 0, 1); $hl7 = "MSH|^~\\&|QDX|" . strtoupper($pname) . "|||" . $date . "00||ORM^O01|R10063131003.1|P|2.3||^" . strtoupper($pname); $hl7 .= "\r"; $hl7 .= "PID|1|" . $pid . "|||" . strtoupper($row2->lastname) . "^" . strtoupper($row2->firstname) . "||" . $dob . "|" . strtoupper($row2->sex) . "|||||||||||"; $hl7 .= "\r"; $hl7 .= "ORC|NW|" . $orders_id . "|||A||^^^" . $order_date . "00||" . $date . "00|||" . strtoupper($row4->peacehealth_id) . "^" . strtoupper($row3->lastname) . "^" . strtoupper($row3->firstname) . "^" . strtoupper($middle) . "^^^" . strtoupper($row3->title) . "||||^|" . strtoupper($row4->peacehealth_id) . "^" . strtoupper($row3->lastname) . "^" . strtoupper($row3->firstname) . "^" . strtoupper($middle) . "^^^" . strtoupper($row3->title) . "||||100^QA-Central Laboratory|QA-Central Laboratory|QA-Central Laboratory^123 International Way^Springfield^OR^97477|1-800-826-3616"; $orders_array = explode("\n", $row->orders_labs); $j = 1; foreach ($orders_array as $orders_row) { if ($orders_row != "") { $orders_row_array = explode(";", $orders_row); $testname = $orders_row_array[0]; $i = 0; foreach ($orders_row_array as $orders_row1) { if (strpos($orders_row1, " Code: ") !== FALSE) { $testcode = str_replace(" Code: ", "", $orders_row1); $i++; } if (strpos($orders_row1, " AOEAnswer: ") !== FALSE) { $aoe_answer = str_replace(" AOEAnswer: ", "", $orders_row1); if (strpos($aoe_answer, "|") !== FALSE) { $aoe_answer_array = explode("|", $aoe_answer); } else { $aoe_answer_array[] = $aoe_answer; } } if (strpos($orders_row1, " AOECode: ") !== FALSE) { $aoe_code = str_replace(" AOECode: ", "", $orders_row1); $aoe_code = str_replace("\r", "", $aoe_code); if (strpos($aoe_code, "|") !== FALSE) { $aoe_code_array = explode("|", $aoe_code); } else { $aoe_code_array[] = $aoe_code; } } } if ($i == 0) { echo "Laboratory order code is missing for the electronic order entry. Be sure you are choosing an order from an Electronic Order Entry list"; exit(0); } $hl7 .= "\r"; $orders_cc = ''; $hl7 .= "OBR|" . $j . "|" . $orders_id . "||" . strtoupper($testcode) . "^" . strtoupper($testname) . "^^|R|" . $order_date . "00|" . $date . "|||||||" . $date . "00|SST^BLD|96666|||||PHL^PeaceHealth Laboratories^123 International Way^Springfield^OR^97477|||||||" . $orders_cc . "|"; $j++; } } if ($row->orders_insurance != 'Bill Client') { $in1_array = explode("\n", $row->orders_insurance); $k = 1; foreach ($in1_array as $in1_row) { $in1_array1 = explode(";", $in1_row); $payor_id = str_replace(" Payor ID: ", "", $in1_array1[1]); if ($payor_id == "Unknown") { $payor_id = 'UNK.'; } $plan_id = str_replace(" ID: ", "", $in1_array1[2]); if (strpos($in1_array1[3], " Group: ") !== FALSE) { $group_id = str_replace(" Group: ", "", $in1_array1[3]); $name_array = explode(", ", $in1_array1[4]); } else { $group_id = ""; $name_array = explode(", ", $in1_array1[3]); } $hl7 .= "\r"; $hl7 .= "IN1|" . $k . "|UNK.|" . strtoupper($payor_id) . "|" . strtoupper($in1_array1[0]) . "||||" . strtoupper($group_id) . "||||||||" . strtoupper($name_array[0]) . "^" . strtoupper($name_array[1]) . "^^^||||||||||||||||||||" . strtoupper($plan_id) . "|||||||||"; $k++; } } if (isset($aoe_answer_array)) { for ($l = 0; $l < count($aoe_answer_array); $l++) { $hl7 .= "\r"; $m = $l + 1; $hl7 .= "OBX|" . $m . "||" . strtoupper($aoe_code_array[$l]) . "||" . strtoupper($aoe_answer_array[$l]) . "||||||P|||" . $date . "00|"; } } $file = "/srv/ftp/shared/export/PHLE_" . time(); file_put_contents($file, $hl7); echo "Electronic order entry sent!"; exit(0); } } }
$data['topage'] = Input::get('topage'); return View::make('pdf.footer', $data); })); Route::get('mtmfooterpdf', array("as" => "mtmfooterpdf", function () { $data['page'] = Input::get('page'); $data['topage'] = Input::get('topage'); return View::make('pdf.mtmfooter', $data); })); Route::get('mtmheaderpdf/{pid}', array("as" => "mtmheaderpdf", function ($pid) { $page = Input::get('page'); if ($page > 1) { $data['show'] = true; } else { $data['show'] = false; } $row = Demographics::find($pid); $date = explode(" ", $row->DOB); $date1 = explode("-", $date[0]); $data['patientDOB'] = $date1[1] . "/" . $date1[2] . "/" . $date1[0]; $data['patientInfo1'] = $row->firstname . ' ' . $row->lastname; return View::make('pdf.mtmheader', $data); })); Route::get('backup', array('as' => 'backup', 'uses' => 'BackupController@backup')); Route::post('backuprestore', array('as' => 'backuprestore', 'uses' => 'BackupController@restore')); Route::get('googleoauth', array('as' => 'googleoauth', 'uses' => 'LoginController@googleoauth')); Route::get('oidc', array('as' => 'oidc', 'uses' => 'LoginController@oidc')); Route::get('oidc_register_client', array('as' => 'oidc_register_client', 'uses' => 'LoginController@oidc_register_client')); Route::get('oidc_check_patient_centric', array('as' => 'oidc_check_patient_centric', 'uses' => 'LoginController@oidc_check_patient_centric')); Route::any('practice_choose', array('as' => 'practice_choose', 'before' => 'force.ssl', 'uses' => 'LoginController@practice_choose')); Route::any('uma_invitation_request', array('as' => 'uma_invitation_request', 'before' => 'force.ssl', 'uses' => 'LoginController@uma_invitation_request')); Route::get('uma_auth', array('as' => 'uma_auth', 'uses' => 'LoginController@uma_auth'));
public function postScanImport() { $pid = Input::get('pid'); $pt = Demographics::find($pid); if ($pt) { $row = Scans::find(Input::get('scans_id')); $directory = Session::get('documents_dir') . $pid; if (Input::get('scan_import_pages') == '') { $filePath = $directory . "/" . $row->fileName . '_' . time() . '.pdf'; if (!copy($row->filePath, $filePath)) { echo "Scan import failed!"; exit(0); } } else { $page_array = explode(",", Input::get('scan_import_pages')); $page = " "; foreach ($page_array as $page_item) { $page .= "A" . $page_item . " "; } $filename = str_replace(".pdf", "", $row['fileName']); $filePath = $directory . "/" . $filename . "_" . time() . "_excerpt.pdf"; $commandpdf2 = 'pdftk A="' . $row['filePath'] . '" cat' . $page . 'output "' . $filePath . '"'; $commandpdf3 = escapeshellcmd($commandpdf2); exec($commandpdf3); } $data = array('documents_url' => $filePath, 'pid' => $pid, 'documents_type' => Input::get('documents_type'), 'documents_desc' => Input::get('documents_desc'), 'documents_from' => Input::get('documents_from'), 'documents_viewed' => Input::get('documents_viewed'), 'documents_date' => date('Y-m-d', strtotime(Input::get('documents_date')))); DB::table('documents')->insert($data); $this->audit('Add'); echo 'Document added!'; } else { echo 'No patient for document to be imported!'; exit(0); } }
public function postGrowthChart($style) { $pid = Session::get('pid'); $displayname = Session::get('displayname'); $demographics = Demographics::find($pid); $gender = Session::get('gender'); $time = time(); $dob = $this->human_to_unix($demographics->DOB); $pedsage = $time - $dob; $datenow = date(DATE_RFC822, $time); $date = date("Y-m-d", $time); $data = array(); $data['patientname'] = $demographics->firstname . ' ' . $demographics->lastname; if ($style == 'bmi-age') { $data['patient'] = $this->getBMIChart($pid); $data['yaxis'] = 'kg/m2'; if ($gender == 'male') { $sex = 'm'; } else { $sex = 'f'; } $array = $this->getSpline($style, $sex); usort($array, array("AjaxCommonController", "cmp")); foreach ($array as $row) { $data['categories'][] = (double) $row['Age']; $data['P5'][] = (double) $row['P5']; $data['P10'][] = (double) $row['P10']; $data['P25'][] = (double) $row['P25']; $data['P50'][] = (double) $row['P50']; $data['P75'][] = (double) $row['P75']; $data['P90'][] = (double) $row['P90']; $data['P95'][] = (double) $row['P95']; } $data['xaxis'] = 'Age (days)'; $data['title'] = 'BMI-for-age percentiles for ' . $demographics->firstname . ' ' . $demographics->lastname . ' as of ' . $datenow; $val = end($data['patient']); $age = round($val[0]); $x = $val[1]; $lms = $this->getLMS($style, $sex, $age); $l = $lms['L']; $m = $lms['M']; $s = $lms['S']; $val1 = $x / $m; if ($lms['L'] != '0') { $val2 = pow($val1, $l); $val2 = $val2 - 1; $val3 = $l * $s; $zscore = $val2 / $val3; } else { $val4 = log($val1); $zscore = $val4 / $s; } $percentile = $this->cdf($zscore) * 100; $percentile = round($percentile); $data['percentile'] = strval($percentile); echo json_encode($data); exit(0); } if ($style == 'weight-age') { $data['patient'] = $this->getWeightChart($pid); $data['yaxis'] = 'kg'; if ($gender == 'male') { $sex = 'm'; } else { $sex = 'f'; } $array = $this->getSpline($style, $sex); usort($array, array("AjaxCommonController", "cmp")); foreach ($array as $row) { $data['categories'][] = (double) $row['Age']; $data['P5'][] = (double) $row['P5']; $data['P10'][] = (double) $row['P10']; $data['P25'][] = (double) $row['P25']; $data['P50'][] = (double) $row['P50']; $data['P75'][] = (double) $row['P75']; $data['P90'][] = (double) $row['P90']; $data['P95'][] = (double) $row['P95']; } $data['xaxis'] = 'Age (days)'; $data['title'] = 'Weight-for-age percentiles for ' . $demographics->firstname . ' ' . $demographics->lastname . ' as of ' . $datenow; $val = end($data['patient']); $age = round($val[0]); $x = $val[1]; $lms = $this->getLMS($style, $sex, $age); $l = $lms['L']; $m = $lms['M']; $s = $lms['S']; $val1 = $x / $m; $data['val1'] = $val1; if ($lms['L'] != '0') { $val2 = pow($val1, $l); $val2 = $val2 - 1; $val3 = $l * $s; $zscore = $val2 / $val3; } else { $val4 = log($val1); $zscore = $val4 / $s; } $percentile = $this->cdf($zscore) * 100; $percentile = round($percentile); $data['percentile'] = strval($percentile); echo json_encode($data); exit(0); } if ($style == 'height-age') { $data['patient'] = $this->getHeightChart($pid); $data['yaxis'] = 'cm'; if ($gender == 'male') { $sex = 'm'; } else { $sex = 'f'; } $array = $this->getSpline($style, $sex); usort($array, array("AjaxCommonController", "cmp")); foreach ($array as $row) { $data['categories'][] = (double) $row['Age']; $data['P5'][] = (double) $row['P5']; $data['P10'][] = (double) $row['P10']; $data['P25'][] = (double) $row['P25']; $data['P50'][] = (double) $row['P50']; $data['P75'][] = (double) $row['P75']; $data['P90'][] = (double) $row['P90']; $data['P95'][] = (double) $row['P95']; } $data['title'] = 'Height-for-age percentiles for ' . $demographics->firstname . ' ' . $demographics->lastname . ' as of ' . $datenow; $val = end($data['patient']); $age = round($val[0]); $x = $val[1]; $lms = $this->getLMS($style, $sex, $age); $l = $lms['L']; $m = $lms['M']; $s = $lms['S']; $val1 = $x / $m; if ($lms['L'] != '0') { $val2 = pow($val1, $l); $val2 = $val2 - 1; $val3 = $l * $s; $zscore = $val2 / $val3; } else { $val4 = log($val1); $zscore = $val4 / $s; } $percentile = $this->cdf($zscore) * 100; $percentile = round($percentile); $data['percentile'] = strval($percentile); echo json_encode($data); exit(0); } if ($style == 'head-age') { $data['patient'] = $this->getHCChart($pid); $data['yaxis'] = 'cm'; if ($gender == 'male') { $sex = 'm'; } else { $sex = 'f'; } $array = $this->getSpline($style, $sex); usort($array, array("AjaxCommonController", "cmp")); foreach ($array as $row) { $data['categories'][] = (double) $row['Age']; $data['P5'][] = (double) $row['P5']; $data['P10'][] = (double) $row['P10']; $data['P25'][] = (double) $row['P25']; $data['P50'][] = (double) $row['P50']; $data['P75'][] = (double) $row['P75']; $data['P90'][] = (double) $row['P90']; $data['P95'][] = (double) $row['P95']; } $data['xaxis'] = 'Age (days)'; $data['title'] = 'Head circumference-for-age percentiles for ' . $demographics->firstname . ' ' . $demographics->lastname . ' as of ' . $datenow; $val = end($data['patient']); $age = round($val[0]); $x = $val[1]; $lms = $this->getLMS($style, $sex, $age); $l = $lms['L']; $m = $lms['M']; $s = $lms['S']; $val1 = $x / $m; if ($lms['L'] != '0') { $val2 = pow($val1, $l); $val2 = $val2 - 1; $val3 = $l * $s; $zscore = $val2 / $val3; } else { $val4 = log($val1); $zscore = $val4 / $s; } $percentile = $this->cdf($zscore) * 100; $percentile = round($percentile); $data['percentile'] = strval($percentile); echo json_encode($data); exit(0); } if ($style == 'weight-height') { $data['patient'] = $this->getWeightHeightChart($pid); $data['yaxis'] = 'kg'; $data['xaxis'] = 'cm'; if ($gender == 'male') { $sex = 'm'; } else { $sex = 'f'; } if ($pedsage <= 63113852) { $array1 = $this->getSpline('weight-length', $sex); usort($array1, array("AjaxCommonController", "cmp1")); $i = 0; foreach ($array1 as $row1) { $data['P5'][$i][] = (double) $row1['Height']; $data['P5'][$i][] = (double) $row1['P5']; $data['P10'][$i][] = (double) $row1['Height']; $data['P10'][$i][] = (double) $row1['P10']; $data['P25'][$i][] = (double) $row1['Height']; $data['P25'][$i][] = (double) $row1['P25']; $data['P50'][$i][] = (double) $row1['Height']; $data['P50'][$i][] = (double) $row1['P50']; $data['P75'][$i][] = (double) $row1['Height']; $data['P75'][$i][] = (double) $row1['P75']; $data['P90'][$i][] = (double) $row1['Height']; $data['P90'][$i][] = (double) $row1['P90']; $data['P95'][$i][] = (double) $row1['Height']; $data['P95'][$i][] = (double) $row1['P95']; $i++; } } else { $array2 = $this->getSpline($style, $sex); usort($array2, array("AjaxCommonController", "cmp2")); $j = 0; foreach ($array2 as $row1) { $data['P5'][$j][] = (double) $row1['Height']; $data['P5'][$j][] = (double) $row1['P5']; $data['P10'][$j][] = (double) $row1['Height']; $data['P10'][$j][] = (double) $row1['P10']; $data['P25'][$j][] = (double) $row1['Height']; $data['P25'][$j][] = (double) $row1['P25']; $data['P50'][$j][] = (double) $row1['Height']; $data['P50'][$j][] = (double) $row1['P50']; $data['P75'][$j][] = (double) $row1['Height']; $data['P75'][$j][] = (double) $row1['P75']; $data['P90'][$j][] = (double) $row1['Height']; $data['P90'][$j][] = (double) $row1['P90']; $data['P95'][$j][] = (double) $row1['Height']; $data['P95'][$j][] = (double) $row1['P95']; $j++; } } $data['title'] = 'Weight-height for ' . $demographics->firstname . ' ' . $demographics->lastname . ' as of ' . $datenow; $val = end($data['patient']); $length = round($val[0]); $data['length'] = $length; $x = $val[1]; if ($pedsage <= 63113852) { $lms = $this->getLMS1('weight-length', $sex, $length); } else { $lms = $this->getLMS2($style, $sex, $length); } $l = $lms['L']; $m = $lms['M']; $s = $lms['S']; $val1 = $x / $m; if ($lms['L'] != '0') { $val2 = pow($val1, $l); $val2 = $val2 - 1; $val3 = $l * $s; $zscore = $val2 / $val3; } else { $val4 = log($val1); $zscore = $val4 / $s; } $percentile = $this->cdf($zscore) * 100; $percentile = round($percentile); $data['percentile'] = strval($percentile); echo json_encode($data); exit(0); } }
public function postFinancialQueryPrint() { $practice_id = Session::get('practice_id'); $query_text1 = DB::table('billing_core')->where('practice_id', '=', $practice_id); $variables_array = Input::get('variables'); $type = Input::get('type'); $i = 0; foreach ($variables_array[0] as $variable) { if ($i == 0) { $query_text1->where($type, '=', $variable); } else { $query_text1->orWhere($type, '=', $variable); } $i++; } $year_array = Input::get('year'); $query_text1->where(function ($query_array1) use($year_array) { $j = 0; foreach ($year_array[0] as $year) { if ($j == 0) { $query_array1->where('dos_f', 'LIKE', "%{$year}%"); } else { $query_array1->orWhere('dos_f', 'LIKE', "%{$year}%"); } $j++; } }); $query_text1->orderBy('dos_f', 'desc'); $query = $query_text1->get(); if ($query) { $records1 = array(); $k = 0; foreach ($query as $records_row) { $query2_row = Demographics::find($records_row->pid); if ($type == 'payment_type') { $type1 = $records_row->payment_type; $amount = $records_row->payment; } else { $type1 = "CPT code: " . $records_row->cpt; $amount = $records_row->cpt_charge; } $records1[$k] = array('billing_core_id' => $records_row->billing_core_id, 'dos_f' => $records_row->dos_f, 'lastname' => $query2_row->lastname, 'firstname' => $query2_row->firstname, 'amount' => $amount, 'type' => $type1); $k++; } $response['id_doc'] = time() . "_" . Session::get('user_id'); $file_path = __DIR__ . "/../../public/temp/financial_query_" . $response['id_doc'] . ".pdf"; $html = $this->page_intro('Financial Query Results', Session::get('practice_id'))->render(); $html .= $this->page_financial_results($records1); $this->generate_pdf($html, $file_path); $response['message'] = "OK"; } else { $response['message'] = "No result."; } echo json_encode($response); }
public function postEditEvent() { $start = strtotime(Input::get('start_date') . " " . Input::get('start_time')); $visit_type = Input::get('visit_type'); if ($visit_type != '') { $row = DB::table('calendar')->select('duration')->where('visit_type', '=', $visit_type)->where('active', '=', 'y')->where('practice_id', '=', Session::get('practice_id'))->first(); $end = $start + $row->duration; } else { $end = strtotime(Input::get('start_date') . " " . Input::get('end')); } if (Session::get('group_id') == '100') { $pid = Session::get('pid'); $row1 = Demographics::find($pid); $title = $row1->lastname . ', ' . $row1->firstname . ' (DOB: ' . date('m/d/Y', strtotime($row1->DOB)) . ') (ID: ' . $pid . ')'; } else { $pid = Input::get('pid'); if ($pid == '') { $title = Input::get('reason'); } else { $title = Input::get('title'); } } $provider_id = Session::get('provider_id'); $reason = Input::get('reason'); $id = Input::get('event_id'); $repeat = Input::get('repeat'); if ($id == '') { if (Session::get('group_id') == '100') { $status = 'Pending'; } else { if (Input::get('pid') == '') { $status = ''; } else { $status = 'Pending'; } } } else { $status = Input::get('status'); } if ($repeat != '') { $repeat_day1 = date('l', $start); $repeat_day = strtolower($repeat_day1); $repeat_start_time = date('h:ia', $start); $repeat_end_time = date('h:ia', $end); if (Input::get('until') != '') { $until = strtotime(Input::get('until')); } else { $until = '0'; } $data1 = array('repeat_day' => $repeat_day, 'repeat_start_time' => $repeat_start_time, 'repeat_end_time' => $repeat_end_time, 'repeat' => $repeat, 'until' => $until, 'title' => $title, 'reason' => $reason, 'provider_id' => $provider_id, 'start' => $start); if ($id == '') { DB::table('schedule')->insert($data1); $this->audit('Add'); } else { $id_check = strpbrk($id, 'N'); if ($id_check == TRUE) { $nid = str_replace('N', '', $id); DB::table('repeat_schedule')->insert($data1); $this->audit('Add'); DB::table('schedule')->where('appt_id', '=', $nid)->delete(); $this->audit('Delete'); } else { $rid = str_replace('R', '', $id); DB::table('repeat_schedule')->where('repeat_id', '=', $rid)->update($data1); $this->audit('Update'); } } } else { $data = array('pid' => $pid, 'start' => $start, 'end' => $end, 'title' => $title, 'visit_type' => $visit_type, 'reason' => $reason, 'status' => $status, 'provider_id' => $provider_id, 'user_id' => Session::get('user_id')); if (Session::get('group_id') != '100') { $data['notes'] = Input::get('notes'); } if ($id == '') { $data['timestamp'] = null; $appt_id = DB::table('schedule')->insertGetId($data); $this->audit('Add'); $this->schedule_notification($appt_id); } else { $id_check1 = strpbrk($id, 'NR'); if ($id_check1 == TRUE) { $nid1 = str_replace('NR', '', $id); DB::table('schedule')->insert($data); $this->audit('Add'); DB::table('repeat_schedule')->where('repeat_id', '=', $nid1)->delete(); $this->audit('Delete'); } else { $notify = DB::table('schedule')->where('appt_id', '=', $id)->first(); DB::table('schedule')->where('appt_id', '=', $id)->update($data); $this->audit('Update'); if ($notify->start != $start && $notify->end != $end) { $this->schedule_notification($id); } } } } }
public function postTestsImport() { if (Session::get('group_id') != '2' && Session::get('group_id') != '3') { Auth::logout(); Session::flush(); header("HTTP/1.1 404 Page Not Found", true, 404); exit("You cannot do this."); } else { $pid = Input::get('pid'); $tests_id_array = json_decode(Input::get('tests_id_array')); $i = 0; $results = array(); foreach ($tests_id_array as $tests_id) { $data = array('pid' => $pid, 'test_unassigned' => ''); DB::table('tests')->where('tests_id', '=', $tests_id)->update($data); $this->audit('Update'); $results[$i] = Tests::find($tests_id)->toArray(); $provider_id = $results[$i]['test_provider_id']; $from = $results[$i]['test_from']; $test_type = $results[$i]['test_type']; $i++; } $patient_row = Demographics::find($pid)->toArray(); $dob_message = date("m/d/Y", strtotime($patient_row['DOB'])); $patient_name = $patient_row['lastname'] . ', ' . $patient_row['firstname'] . ' (DOB: ' . $dob_message . ') (ID: ' . $pid . ')'; $practice_row = Practiceinfo::find(Session::get('practice_id'))->toArray(); $directory = $practice_row['documents_dir'] . $pid; $file_path = $directory . '/tests_' . time() . '.pdf'; $html = $this->page_intro('Test Results', $practice_id); $html .= $this->page_results($pid, $results, $patient_name); $this->generate_pdf($html, $file_path); $documents_date = date("Y-m-d H:i:s", time()); $test_desc = 'Test results for ' . $patient_name; $pages_data = array('documents_url' => $file_path, 'pid' => $pid, 'documents_type' => $test_type, 'documents_desc' => $test_desc, 'documents_from' => $from, 'documents_date' => $documents_date); if (Session::get('group_id') == '2') { $pages_data['documents_viewed'] = Session::get('displayname'); } $documents_id = DB::table('documents')->insertGetId($pages_data); $this->audit('Add'); if (Session::get('group_id') == '3') { $provider_row = User::find($provider_id)->toArray(); $provider_name = $provider_row['firstname'] . " " . $provider_row['lastname'] . ", " . $provider_row['title'] . " (" . $provider_id . ")"; $subject = "Test results for " . $patient_name; $body = "Test results for " . $patient_name . "\n\n"; foreach ($results as $results_row1) { $body .= $results_row1['test_name'] . ": " . $results_row1['test_result'] . ", Units: " . $results_row1['test_units'] . ", Normal reference range: " . $results_row1['test_reference'] . ", Date: " . $results_row1['test_datetime'] . "\n"; } $body .= "\n" . $from; $data_message = array('pid' => $pid, 'message_to' => $provider_name, 'message_from' => Session::get('user_id'), 'subject' => $subject, 'body' => $body, 'patient_name' => $patient_name, 'status' => 'Sent', 'mailbox' => $provider_id, 'practice_id' => $practice_id, 'documents_id' => $documents_id); DB::table('messaging')->insert($data_message); $this->audit('Add'); } echo $i; } }
public function postTestsView($tests_id, $pid) { $row = Tests::find($tests_id); $row1 = Demographics::find($pid); $text = '<strong>Patient:</strong> ' . $row1->firstname . " " . $row1->lastname . '<br><br><strong>Type:</strong> ' . $row->test_type . '<br><br><strong>Date:</strong> ' . date('m/d/Y', $row->test_datetime) . '<br><br><strong>Test</strong> ' . $row->test_name . '<br><br><strong>Result:</strong> ' . $row->test_result . ' ' . $row->test_units . ' (' . $row->test_reference . ')<br><br><strong>From:</strong> ' . $row->test_from; echo $text; }