public function postRegisterUser() { if ($this->rpHash(Input::get('numberReal')) == Input::get('numberRealHash')) { $registration_code = Input::get('registration_code'); if ($registration_code != '') { $count = intval(Input::get('count')); if ($count > 2) { $arr['response'] = "3"; echo json_encode($arr); exit(0); } $dob = date('Y-m-d', strtotime(Input::get('dob'))); $result = DB::table('demographics')->where('registration_code', '=', $registration_code)->where('firstname', '=', Input::get('firstname'))->where('lastname', '=', Input::get('lastname'))->where('DOB', '=', $dob)->first(); if ($result) { $arr['response'] = "1"; $displayname = Input::get('firstname') . " " . Input::get('lastname'); $demographics_relate = DB::table('demographics_relate')->where('pid', '=', $result->pid)->get(); foreach ($demographics_relate as $demographics_relate_row) { $row1 = DB::table('practiceinfo')->where('practice_id', '=', $demographics_relate_row->practice_id)->first(); if ($demographics_relate_row->id != "" && $demographics_relate_row->id != "0") { $arr['response'] = "5"; $row2 = User::where('id', '=', $demographics_relate_row->id)->first(); $data_message['practicename'] = $row1->practice_name; $data_message['username'] = $row2->username; $data_message['url'] = route('home'); $this->send_mail('emails.loginregistration', $data_message, 'Patient Portal Registration Message', Input::get('email'), $demographics_relate_row->practice_id); } else { $data1 = array('username' => Input::get('username'), 'firstname' => Input::get('firstname'), 'lastname' => Input::get('lastname'), 'email' => Input::get('email'), 'group_id' => '100', 'active' => '1', 'displayname' => $displayname, 'practice_id' => $demographics_relate_row->practice_id); $arr['id'] = DB::table('users')->insertGetId($data1); $this->audit('Add'); $data2 = array('id' => $arr['id']); DB::table('demographics_relate')->where('demographics_relate_id', '=', $demographics_relate_row->demographics_relate_id)->update($data2); $this->audit('Update'); $data_message1['practicename'] = $row1->practice_name; $data_message1['username'] = Input::get('username'); $data_message1['url'] = route('home'); $this->send_mail('emails.loginregistrationconfirm', $data_message1, 'Patient Portal Registration Confirmation', Input::get('email'), $demographics_relate_row->practice_id); } } } else { $arr['response'] = "2"; $count++; $arr['count'] = strval($count); } } else { $row3 = Practiceinfo::find(Input::get('practice_id')); $displayname = Session::get('displayname'); $data_message2 = array('firstname' => Input::get('firstname'), 'lastname' => Input::get('lastname'), 'dob' => Input::get('dob'), 'username' => Input::get('username'), 'email' => Input::get('email')); $this->send_mail('emails.loginregistrationrequest', $data_message2, 'New User Request', $row3->email, Input::get('practice_id')); $arr['response'] = "4"; } } else { $count = intval(Input::get('count')); $arr['response'] = "2"; $count++; $arr['count'] = strval($count); } echo json_encode($arr); }
/** * NOSH ChartingSystem Backup and Updating System, to be run as a cron job */ public function backup() { $config_file = __DIR__ . "/../../.env.php"; $config = (require $config_file); $row2 = Practiceinfo::find(1); $dir = $row2->documents_dir; $file = $dir . "noshbackup_" . time() . ".sql"; $command = "mysqldump -u " . $config['mysql_username'] . " -p" . $config['mysql_password'] . " " . $config['mysql_database'] . " > " . $file; system($command); $files = glob($dir . "*.sql"); foreach ($files as $file_row) { $explode = explode("_", $file_row); $time = intval(str_replace(".sql", "", $explode[1])); $month = time() - 604800; if ($time < $month) { unlink($file_row); } } DB::delete('delete from extensions_log where DATE_SUB(CURDATE(), INTERVAL 30 DAY) >= timestamp'); File::cleanDirectory(__DIR__ . "/../../public/temp"); }
protected function getWeightHeightChart($pid) { $query = DB::table('vitals')->select('weight', 'height', 'pedsage')->where('pid', '=', $pid)->where('weight', '!=', '')->where('height', '!=', '')->orderBy('pedsage', 'asc')->get(); if ($query) { $vals = array(); $i = 0; foreach ($query as $row) { $row1 = Practiceinfo::find(Session::get('practice_id')); if ($row1->weight_unit == 'lbs') { $y = $row->weight / 2.20462262185; } else { $y = $row->weight * 1; } if ($row1->height_unit == 'in') { $x = $row->height * 2.54; } else { $x = $row->height * 1; } $vals[$i][] = $x; $vals[$i][] = $y; $i++; } return $vals; } else { return FALSE; } }
public function photoupload() { $result = Practiceinfo::find(Session::get('practice_id')); $directory = $result->documents_dir . Session::get('pid'); foreach (Input::file('file') as $file) { if ($file) { if ($file->getMimeType() != 'image/jpeg' && $file->getMimeType() != 'image/gif' && $file->getMimeType() != 'image/png') { echo "This is not an image file. Try again."; exit(0); } $new_name = str_replace('.' . $file->getClientOriginalExtension(), '', $file->getClientOriginalName()) . '_' . time() . '.' . $file->getClientOriginalExtension(); $file->move($directory, $new_name); $file_path = $directory . "/" . $new_name; $data = array('image_location' => $file_path, 'pid' => Session::get('pid'), 'eid' => Session::get('eid'), 'image_description' => 'Photo uploaded ' . date('F jS, Y'), 'id' => Session::get('user_id'), 'encounter_provider' => Session::get('displayname')); DB::table('image')->insert($data); $this->audit('Add'); } } echo 'Photos uploaded!'; }
}); Route::filter('google', function () { $row = Practiceinfo::find(1); if ($row->google_refresh_token == '' && Session::get('group_id') == '1') { return Redirect::to('googleoauth'); } }); Route::filter('googlecheck', function () { $config_file = __DIR__ . "/../.google"; if (!file_exists($config_file)) { return Redirect::to('google_start'); } }); Route::filter('openid', function () { if (route('home') == 'https://hieofone.com/nosh' || route('home') == 'https://noshchartingsystem.com/nosh' || route('home') == 'https://www.noshchartingsystem.com/nosh' || route('home') == 'http://uma.noshchartingsystem.com/nosh') { $row = Practiceinfo::find(1); if ($row->openidconnect_client_id == '') { return Redirect::to('oidc_register_client'); } } }); Route::filter('version_check', function () { if (!File::exists(__DIR__ . "/../.version")) { return Redirect::to('set_version'); } }); Route::filter('csrf_header', function () { if (Session::token() != Request::header('x-csrf-token')) { Auth::logout(); Session::flush(); header("HTTP/1.1 404 Page Not Found", true, 404);
public function postCheckAdmin() { $practice_id = Session::get('practice_id'); if ($practice_id == '1') { $arr = "OK"; } else { $row = Practiceinfo::find($practice_id); $query = DB::table('users')->join('providers', 'users.id', '=', 'providers.id')->where('users.group_id', '=', '2')->where('users.active', '=', '1')->where('users.practice_id', '=', $practice_id)->get(); $count = count($query); if ($row->provider_limit <= $count) { $arr = "No more providers can be added based on your provider limit for your practice account. Please upgrade your subscription to enable additional providers!"; } else { $arr = "OK"; } } echo $arr; }
public function postVivacareData() { set_time_limit(0); ini_set('memory_limit', '196M'); $practice = Practiceinfo::find(Session::get('practice_id')); $data['response'] = "false"; if ($practice->vivacare != "") { $html = new Htmldom("http://informationrx.com/" . $practice->vivacare); if (isset($html)) { $div = $html->find('[id=nav-topic-dropdown]', 0); $div1 = $html->find('[id=formselectA]', 0); if (isset($div)) { $data['response'] = "true"; foreach ($div->find('select') as $select) { $category = $select->id; foreach ($select->find('option') as $option) { $text = $option->innertext; $link = $option->value; $data['message'][] = array('label' => $text, 'value' => $text, 'link' => $link, 'category' => $category); } } } } } echo json_encode($data); }
public function uma_auth() { $open_id_url = str_replace('/nosh', '/uma-server-webapp/', URL::to('/')); $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first(); $client_id = $practice->uma_client_id; $client_secret = $practice->uma_client_secret; $url = route('uma_auth'); $oidc = new OpenIDConnectClient($open_id_url, $client_id, $client_secret); $oidc->setRedirectURL($url); if ($practice->uma_refresh_token == '') { $oidc->addScope('openid'); $oidc->addScope('email'); $oidc->addScope('profile'); $oidc->addScope('offline_access'); $oidc->addScope('uma_protection'); } else { $oidc->addScope('openid'); $oidc->addScope('email'); $oidc->addScope('profile'); } $oidc->authenticate(true); $firstname = $oidc->requestUserInfo('given_name'); $lastname = $oidc->requestUserInfo('family_name'); $email = $oidc->requestUserInfo('email'); $npi = $oidc->requestUserInfo('npi'); $access_token = $oidc->getAccessToken(); if ($npi != '') { $provider = DB::table('providers')->where('npi', '=', $npi)->first(); if ($provider) { $user = User::where('id', '=', $provider->id)->first(); } else { $user = false; } } else { $user = User::where('uid', '=', $oidc->requestUserInfo('sub'))->first(); //$user = User::where('firstname', '=', $firstname)->where('email', '=', $email)->where('lastname', '=', $lastname)->where('active', '=', '1')->first(); } if ($user) { // Add refresh token, if there is one if ($oidc->getRefreshToken() != '') { $refresh_data['uma_refresh_token'] = $oidc->getRefreshToken(); DB::table('practiceinfo')->where('practice_id', '=', '1')->update($refresh_data); // Register scopes, if none are set yet $uma = DB::table('uma')->first(); if (!$uma) { $resource_set_array[] = array('name' => 'Patient', 'icon' => 'https://noshchartingsystem.com/i-patient.png', 'scopes' => array(URL::to('/') . '/fhir/Patient/1', URL::to('/') . '/fhir/Patient?identifier=1', URL::to('/') . '/fhir/Patient?_id=1', URL::to('/') . '/fhir/Medication', URL::to('/') . '/fhir/Practitioner')); $resource_set_array[] = array('name' => 'Condition', 'icon' => 'https://noshchartingsystem.com/i-condition.png', 'scopes' => array(URL::to('/') . '/fhir/Condition/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Medication List', 'icon' => 'https://noshchartingsystem.com/i-pharmacy.png', 'scopes' => array(URL::to('/') . '/fhir/MedicationStatement/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Allergy', 'icon' => 'https://noshchartingsystem.com/i-allergy.png', 'scopes' => array(URL::to('/') . '/fhir/AllergyIntolerance/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Immunization', 'icon' => 'https://noshchartingsystem.com/i-immunization.png', 'scopes' => array(URL::to('/') . '/fhir/Immunization/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Encounter', 'icon' => 'https://noshchartingsystem.com/i-medical-records.png', 'scopes' => array(URL::to('/') . '/fhir/Encounter/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Family History', 'icon' => 'https://noshchartingsystem.com/i-family-practice.png', 'scopes' => array(URL::to('/') . '/fhir/FamilyHistory/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Binary Files', 'icon' => 'https://noshchartingsystem.com/i-file.png', 'scopes' => array(URL::to('/') . '/fhir/Binary/?subject:Patient=1')); $resource_set_array[] = array('name' => 'Observation', 'icon' => 'https://noshchartingsystem.com/i-cardiology.png', 'scopes' => array(URL::to('/') . '/fhir/Observation/?subject:Patient=1')); $oidc1 = new OpenIDConnectClient($open_id_url, $client_id, $client_secret); $oidc1->refresh($refresh_data['uma_refresh_token'], true); foreach ($resource_set_array as $resource_set_item) { $response = $oidc1->resource_set($resource_set_item['name'], $resource_set_item['icon'], $resource_set_item['scopes']); if (isset($response['resource_set_id'])) { foreach ($resource_set_item['scopes'] as $scope_item) { $response_data1 = array('resource_set_id' => $response['resource_set_id'], 'scope' => $scope_item, 'user_access_policy_uri' => $response['user_access_policy_uri']); DB::table('uma')->insert($response_data1); $this->audit('Add'); } } } } } Auth::login($user); $practice = Practiceinfo::find($user->practice_id); Session::put('user_id', $user->id); Session::put('group_id', $user->group_id); Session::put('practice_id', $user->practice_id); Session::put('version', $practice->version); Session::put('practice_active', $practice->active); Session::put('displayname', $user->displayname); Session::put('documents_dir', $practice->documents_dir); Session::put('rcopia', $practice->rcopia_extension); Session::put('mtm_extension', $practice->mtm_extension); Session::put('patient_centric', $practice->patient_centric); Session::put('uma_auth_access_token', $access_token); setcookie("login_attempts", 0, time() + 900, '/'); return Redirect::intended('/'); } else { $practice_npi = $oidc->requestUserInfo('practice_npi'); $practice_id = false; if ($practice_npi != '') { $practice_npi_array = explode(',', $practice_npi); $practice_npi_array_null = array(); foreach ($practice_npi_array as $practice_npi_item) { $practice_query = DB::table('practiceinfo')->where('npi', '=', $practice_npi_item)->first(); if ($practice_query) { $practice_id = $practice_query->practice_id; } else { $practice_npi_array_null[] = $practice_npi_item; } } } if ($practice_id == false) { if (count($practice_npi_array_null) == 1) { $url = 'http://docnpi.com/api/index.php?ident=' . $practice_npi_array_null[0] . '&is_ident=true&format=aha'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $data1 = curl_exec($ch); curl_close($ch); $html = new Htmldom($data1); $practicename = ''; $address = ''; $street_address1 = ''; $city = ''; $state = ''; $zip = ''; if (isset($html)) { $li = $html->find('li', 0); if (isset($li)) { $nomatch = $li->innertext; if ($nomatch != ' no matching results ') { $name_item = $li->find('span[class=org]', 0); $practicename = $name_item->innertext; $address_item = $li->find('span[class=address]', 0); $address = $address_item->innertext; } } } if ($address != '') { $address_array = explode(',', $address); if (isset($address_array[0])) { $street_address1 = trim($address_array[0]); } if (isset($address_array[1])) { $zip = trim($address_array[1]); } if (isset($address_array[2])) { $city = trim($address_array[2]); } if (isset($address_array[3])) { $state = trim($address_array[3]); } } $practice_data = array('npi' => $practice_npi_array_null[0], 'practice_name' => $practicename, 'street_address1' => $street_address1, 'city' => $city, 'state' => $state, 'zip' => $zip, 'documents_dir' => $practice->documents_dir, 'version' => $practice->version, 'active' => 'Y', 'fax_type' => '', 'vivacare' => '', 'patient_centric' => 'yp', 'smtp_user' => $practice->smtp_user, 'smtp_pass' => $practice->smtp_pass); $practice_id = DB::table('practiceinfo')->insertGetId($practice_data); $this->audit('Add'); } else { Session::put('practice_npi_array', implode(',', $practice_npi_array_null)); Session::put('firstname', $firstname); Session::put('lastname', $lastname); Session::put('username', $oidc->requestUserInfo('sub')); Session::put('middle', $oidc->requestUserInfo('middle_name')); Session::put('displayname', $oidc->requestUserInfo('name')); Session::put('email', $email); Session::put('npi', $npi); Session::put('practice_choose', 'y'); Session::put('uid', $oidc->requestUserInfo('sub')); Session::put('uma_auth_access_token', $access_token); return Redirect::to('practice_choose'); } } $data = array('username' => $oidc->requestUserInfo('sub'), 'firstname' => $firstname, 'middle' => $oidc->requestUserInfo('middle_name'), 'lastname' => $lastname, 'displayname' => $oidc->requestUserInfo('name'), 'email' => $email, 'group_id' => '2', 'active' => '1', 'practice_id' => $practice_id, 'secret_question' => 'Use HIEofOne to reset your password!', 'uid' => $oidc->requestUserInfo('sub')); $id = DB::table('users')->insertGetId($data); $this->audit('Add'); $data1 = array('id' => $id, 'npi' => $npi, 'practice_id' => $practice_id); DB::table('providers')->insert($data1); $this->audit('Add'); $user1 = User::where('id', '=', $id)->first(); Auth::login($user1); $practice1 = Practiceinfo::find($user1->practice_id); Session::put('user_id', $user1->id); Session::put('group_id', $user1->group_id); Session::put('practice_id', $user1->practice_id); Session::put('version', $practice1->version); Session::put('practice_active', $practice1->active); Session::put('displayname', $user1->displayname); Session::put('documents_dir', $practice1->documents_dir); Session::put('rcopia', $practice1->rcopia_extension); Session::put('mtm_extension', $practice1->mtm_extension); Session::put('patient_centric', $practice1->patient_centric); Session::put('uma_auth_access_token', $access_token); setcookie("login_attempts", 0, time() + 900, '/'); return Redirect::intended('/'); } }
public function schedule() { $practice_id = Session::get('practice_id'); $data['practiceinfo'] = Practiceinfo::find($practice_id); 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"); $data['schedule_increment'] = '15'; $this->layout->style = $this->css_assets(); $this->layout->script = $this->js_assets('base'); $this->layout->content .= View::make('schedule_widget', $data)->render(); }
public function postCheckFax() { $result = Practiceinfo::find(Session::get('practice_id')); if ($result->fax_type != "") { echo "Yes"; } else { echo "No"; } }
public function logout() { Auth::logout(); Session::flush(); $practice1 = Practiceinfo::find(1); Session::put('version', $practice1->version); $this->layout->style = $this->css_assets(); $this->layout->script = $this->js_assets('base', true); $this->layout->content = View::make('mobile.logout'); }
public function postGetSalesTax() { $result = Practiceinfo::find(Session::get('practice_id')); echo $result->sales_tax; }
public function postMobileFormAction($table, $action, $row_id, $row_index) { $date_convert_array = array('issue_date_active', 'issue_date_inactive', 'allergies_date_active', 'allergies_date_inactive', 'rxl_date_active', 'imm_date', 'imm_expiration'); $rcopia_tables = array('issues', 'allergies'); $api_tables = array('issues', 'allergies'); $mtm_tables = array('issues'); $ndc_tables = array('allergies'); if ($table == 'issues') { $message = 'Issue '; } if ($table == 'allergies') { $message = 'Allergy '; } if ($table == 'rx_list') { $message = 'Medication '; } if ($table == 'sup_list') { $message = 'Supplement '; } if ($table == 'immunizations') { $message = 'Immunization '; } $arr = array(); $practice = Practiceinfo::find(Session::get('practice_id')); $pid = Session::get('pid'); $data = Input::all(); foreach ($date_convert_array as $key) { if (array_key_exists($key, $data)) { if ($data[$key] !== '') { $data[$key] = date('Y-m-d H:i:s', strtotime($data[$key])); } } } foreach ($rcopia_tables as $rcopia_table) { if ($rcopia_table == $table) { $data['rcopia_sync'] = 'n'; } } foreach ($ndc_tables as $ndc_table) { if ($ndc_table == $table) { if (strpos($data['allergies_med'], ', ') === false) { $ndcid = ''; } else { $med_name = explode(", ", $data['allergies_med'], -1); $ndcid = ""; if ($med_name[0]) { $med_result = DB::table('meds_full_package')->join('meds_full', 'meds_full.PRODUCTNDC', '=', 'meds_full_package.PRODUCTNDC')->select('meds_full_package.NDCPACKAGECODE')->where('meds_full.PROPRIETARYNAME', '=', $med_name[0])->first(); if ($med_result) { $ndcid = $this->ndc_convert($med_result->NDCPACKAGECODE); } } } if ($table == 'allergies') { $data['meds_ndcid'] = $ndcid; } } } if ($action == 'save') { if ($row_id == '0') { $data['pid'] = $pid; $row_id1 = DB::table($table)->insertGetId($data); $this->audit('Add'); foreach ($api_tables as $api_table) { if ($api_table == $table) { $this->api_data('add', $table, $row_index, $row_id1); } } if ($practice->mtm_extension == 'y') { foreach ($mtm_tables as $mtm_table) { if ($mtm_table == $table) { $this->add_mtm_alert($pid, $table); } } } $arr['message'] = $message . 'added!'; } else { DB::table($table)->where($row_index, '=', $row_id)->update($data); $this->audit('Update'); foreach ($api_tables as $api_table) { if ($api_table == $table) { $this->api_data('update', $table, $row_index, $row_id); } } $arr['message'] = $message . 'updated!'; } } if ($action == 'inactivate') { if ($table == 'issues') { $data1 = array('issue_date_inactive' => date('Y-m-d H:i:s', time()), 'rcopia_sync' => 'nd1'); } DB::table($table)->where($row_index, '=', $row_id)->update($data1); $this->audit('Update'); foreach ($api_tables as $api_table) { if ($api_table == $table) { $this->api_data('update', $table, $row_index, $row_id); } } $arr['message'] = $message . 'inactivated!'; } if ($action == 'delete') { if ($practice->rcopia_extension == 'y') { foreach ($rcopia_tables as $rcopia_table) { if ($rcopia_table == $table) { $data2 = array('rcopia_sync' => 'nd'); DB::table($table)->where($row_index, '=', $row_id)->update($data); $this->audit('Update'); while (!$this->check_rcopia_delete($table, $row_id)) { sleep(2); } } } } DB::table($table)->where($row_index, '=', $row_id)->delete(); $this->audit('Delete'); foreach ($api_tables as $api_table) { if ($api_table == $table) { $this->api_data('delete', $table, $row_index, $row_id); } } $arr['message'] = $message . 'deleted!'; } $arr['response'] = 'OK'; echo json_encode($arr); }
public function postResetDatabase() { $db_name = $_ENV['mysql_database']; $db_username = $_ENV['mysql_username']; $db_password = $_ENV['mysql_password']; DB::table('meds_full')->truncate(); $meds_sql_file = __DIR__ . "/../../import/meds_full.sql"; $meds_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $meds_sql_file; system($meds_command); DB::table('meds_full_package')->truncate(); $meds1_sql_file = __DIR__ . "/../../import/meds_full_package.sql"; $meds1_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $meds1_sql_file; system($meds1_command); DB::table('supplements_list')->truncate(); $supplements_file = __DIR__ . "/../../import/supplements_list.sql"; $supplements_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $supplements_file; system($supplements_command); DB::table('icd9')->truncate(); $icd_file = __DIR__ . "/../../import/icd9.sql"; $icd_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $icd_file; system($icd_command); DB::table('cpt')->truncate(); $cpt_file = __DIR__ . "/../../import/cpt.sql"; $cpt_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $cpt_file; system($cpt_command); DB::table('templates')->truncate(); $templates_file = __DIR__ . "/../../import/templates.sql"; $templates_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $templates_file; system($templates_command); DB::table('orderslist1')->truncate(); $orderslist1_file = __DIR__ . "/../../import/orderslist1.sql"; $orderslist1_command = "mysql -u " . $db_username . " -p" . $db_password . " " . $db_name . " < " . $orderslist1_file; system($orderslist1_command); DB::table('addressbook')->truncate(); DB::table('alerts')->truncate(); DB::table('allergies')->truncate(); DB::table('api_queue')->truncate(); DB::table('assessment')->truncate(); DB::table('audit')->truncate(); DB::table('billing')->truncate(); DB::table('billing_core')->truncate(); DB::table('calendar')->truncate(); DB::table('ci_sessions')->truncate(); DB::table('cpt_relate')->truncate(); $practice = Practiceinfo::find('1'); $patients = DB::table('demographics')->get(); foreach ($patients as $patient) { $directory = $practice->documents_dir . $patient->pid; $this->deltree($directory, false); } DB::table('demographics')->truncate(); DB::table('documents')->truncate(); DB::table('encounters')->truncate(); DB::table('era')->truncate(); DB::table('extensions_log')->truncate(); DB::table('forms')->truncate(); DB::table('groups')->truncate(); DB::table('hippa')->truncate(); DB::table('hippa_request')->truncate(); DB::table('hpi')->truncate(); DB::table('image')->truncate(); DB::table('immunizations')->truncate(); DB::table('insurance')->truncate(); DB::table('issues')->truncate(); DB::table('labs')->truncate(); DB::table('messaging')->truncate(); DB::table('mtm')->truncate(); DB::table('orders')->truncate(); DB::table('orderslist')->truncate(); DB::table('other_history')->truncate(); DB::table('pages')->truncate(); DB::table('pe')->truncate(); DB::table('plan')->truncate(); DB::table('procedure')->truncate(); DB::table('procedurelist')->truncate(); DB::table('providers')->truncate(); DB::table('received')->truncate(); $received = $practice->documents_dir . 'received'; $this->deltree($received, true); DB::table('recipients')->truncate(); DB::table('ros')->truncate(); DB::table('rx')->truncate(); DB::table('scans')->truncate(); $scans = $practice->documents_dir . 'scans'; $this->deltree($scans, true); DB::table('schedule')->truncate(); DB::table('sendfax')->truncate(); $sentfax = $practice->documents_dir . 'sentfax'; $sentfax->deltree($sentfax, true); DB::table('sessions')->truncate(); DB::table('supplement_inventory')->truncate(); DB::table('sup_list')->truncate(); DB::table('tags')->truncate(); DB::table('tags_relate')->truncate(); DB::table('tests')->truncate(); DB::table('t_messages')->truncate(); DB::table('users')->truncate(); DB::table('vaccine_inventory')->truncate(); DB::table('vaccine_temp')->truncate(); DB::table('vitals')->truncate(); DB::table('practiceinfo')->truncate(); echo "OK"; }
public function postProviderSchedule() { $start = Input::get('start'); $end = Input::get('end'); $id = Session::get('provider_id'); $events = array(); $query = DB::table('schedule')->where('provider_id', '=', $id)->whereBetween('start', array($start, $end))->get(); if ($query) { foreach ($query as $row) { if ($row->visit_type != '') { $row1 = DB::table('calendar')->select('classname')->where('visit_type', '=', $row->visit_type)->where('practice_id', '=', Session::get('practice_id'))->first(); $classname = $row1->classname; } else { $classname = 'colorblack'; } if ($row->pid == '0') { $pid = ''; } else { $pid = $row->pid; } if ($row->timestamp == '0000-00-00 00:00:00' || $row->user_id == '') { $timestamp = ''; } else { $user_row = User::find($row->user_id); $timestamp = 'Appointment added by ' . $user_row->displayname . ' on ' . $row->timestamp; } $row_start = date('c', $row->start); $row_end = date('c', $row->end); $event = array('id' => $row->appt_id, 'start' => $row_start, 'end' => $row_end, 'visit_type' => $row->visit_type, 'className' => $classname, 'provider_id' => $row->provider_id, 'pid' => $pid, 'timestamp' => $timestamp); if (Session::get('group_id') == '100' || Session::get('group_id') == 'schedule') { if (Session::get('pid') != $pid) { $event['title'] = 'Appointment taken'; $event['reason'] = 'Private'; $event['status'] = 'Private'; $event['notes'] = ''; $event['editable'] = false; } else { $event['title'] = $row->title; $event['reason'] = $row->reason; $event['status'] = $row->status; $event['notes'] = ''; $event['editable'] = true; } } else { $event['title'] = $row->title; $event['reason'] = $row->reason; $event['status'] = $row->status; $event['notes'] = $row->notes; if (Session::get('group_id') == '1') { $event['editable'] = false; } else { $event['editable'] = true; } } $events[] = $event; } } $query2 = DB::table('repeat_schedule')->where('provider_id', '=', $id)->get(); if ($query2) { foreach ($query2 as $row2) { if ($row2->start <= $end || $row2->start == "0") { if ($row2->repeat == "86400") { if ($row2->start <= $start) { $repeat_start = strtotime('this ' . strtolower(date('l', $start)) . ' ' . $row2->repeat_start_time, $start); $repeat_end = strtotime('this ' . strtolower(date('l', $start)) . ' ' . $row2->repeat_end_time, $start); } else { $repeat_start = strtotime('this ' . $row2->repeat_day . ' ' . $row2->repeat_start_time, $start); $repeat_end = strtotime('this ' . $row2->repeat_day . ' ' . $row2->repeat_end_time, $start); } } else { $repeat_start = strtotime('this ' . $row2->repeat_day . ' ' . $row2->repeat_start_time, $start); $repeat_end = strtotime('this ' . $row2->repeat_day . ' ' . $row2->repeat_end_time, $start); } if ($row2->until == '0') { while ($repeat_start <= $end) { $repeat_id = 'R' . $row2->repeat_id; $until = ''; if ($row2->reason == '') { $row2->reason = $row2->title; } $repeat_start1 = date('c', $repeat_start); $repeat_end1 = date('c', $repeat_end); $event1 = array('id' => $repeat_id, 'start' => $repeat_start1, 'end' => $repeat_end1, 'repeat' => $row2->repeat, 'until' => $until, 'className' => 'colorblack', 'provider_id' => $row2->provider_id, 'status' => 'Repeated Event', 'notes' => ''); if (Session::get('group_id') == '100') { $event1['title'] = 'Provider Not Available'; $event1['reason'] = 'Provider Not Available'; $event1['editable'] = false; } else { $event1['title'] = $row2->title; $event1['reason'] = $row2->reason; if (Session::get('group_id') == '1') { $event1['editable'] = false; } else { $event1['editable'] = true; } } $events[] = $event1; $repeat_start = $repeat_start + $row2->repeat; $repeat_end = $repeat_end + $row2->repeat; } } else { while ($repeat_start <= $end) { if ($repeat_start > $row2->until) { break; } else { $repeat_id = 'R' . $row2->repeat_id; $until = date('m/d/Y', $row2->until); if ($row2->reason == '') { $row2->reason = $row2->title; } $repeat_start1 = date('c', $repeat_start); $repeat_end1 = date('c', $repeat_end); $event1 = array('id' => $repeat_id, 'start' => $repeat_start1, 'end' => $repeat_end1, 'repeat' => $row2->repeat, 'until' => $until, 'className' => 'colorblack', 'provider_id' => $row2->provider_id, 'status' => 'Repeated Event', 'notes' => ''); if (Session::get('group_id') == '100') { $event1['title'] = 'Provider Not Available'; $event1['reason'] = 'Provider Not Available'; $event1['editable'] = false; } else { $event1['title'] = $row2->title; $event1['reason'] = $row2->reason; if (Session::get('group_id') == '1') { $event1['editable'] = false; } else { $event1['editable'] = true; } } $events[] = $event1; $repeat_start = $repeat_start + $row2->repeat; $repeat_end = $repeat_end + $row2->repeat; } } } } } } $row3 = Practiceinfo::find(Session::get('practice_id')); $compminTime = strtotime($row3->minTime); $compmaxTime = strtotime($row3->maxTime); if ($row3->sun_o != '') { $comp1o = strtotime($row3->sun_o); $comp1c = strtotime($row3->sun_c); if ($comp1o > $compminTime) { $events = $this->add_closed1('sunday', $row3->minTime, $row3->sun_o, $events, $start, $end); } if ($comp1c < $compmaxTime) { $events = $this->add_closed2('sunday', $row3->maxTime, $row3->sun_c, $events, $start, $end); } } else { $events = $this->add_closed3('sunday', $row3->minTime, $row3->maxTime, $events, $start, $end); } if ($row3->mon_o != '') { $comp2o = strtotime($row3->mon_o); $comp2c = strtotime($row3->mon_c); if ($comp2o > $compminTime) { $events = $this->add_closed1('monday', $row3->minTime, $row3->mon_o, $events, $start, $end); } if ($comp2c < $compmaxTime) { $events = $this->add_closed2('monday', $row3->maxTime, $row3->mon_c, $events, $start, $end); } } else { $events = $this->add_closed3('monday', $row3->minTime, $row3->maxTime, $events, $start, $end); } if ($row3->tue_o != '') { $comp3o = strtotime($row3->tue_o); $comp3c = strtotime($row3->tue_c); if ($comp3o > $compminTime) { $events = $this->add_closed1('tuesday', $row3->minTime, $row3->tue_o, $events, $start, $end); } if ($comp3c < $compmaxTime) { $events = $this->add_closed2('tuesday', $row3->maxTime, $row3->tue_c, $events, $start, $end); } } else { $events = $this->add_closed3('tuesday', $row3->minTime, $row3->maxTime, $events, $start, $end); } if ($row3->wed_o != '') { $comp4o = strtotime($row3->wed_o); $comp4c = strtotime($row3->wed_c); if ($comp4o > $compminTime) { $events = $this->add_closed1('wednesday', $row3->minTime, $row3->wed_o, $events, $start, $end); } if ($comp4c < $compmaxTime) { $events = $this->add_closed2('wednesday', $row3->maxTime, $row3->wed_c, $events, $start, $end); } } else { $events = $this->add_closed3('wednesday', $row3->minTime, $row3->maxTime, $events, $start, $end); } if ($row3->thu_o != '') { $comp5o = strtotime($row3->thu_o); $comp5c = strtotime($row3->thu_c); if ($comp5o > $compminTime) { $events = $this->add_closed1('thursday', $row3->minTime, $row3->thu_o, $events, $start, $end); } if ($comp5c < $compmaxTime) { $events = $this->add_closed2('thursday', $row3->maxTime, $row3->thu_c, $events, $start, $end); } } else { $events = $this->add_closed3('thursday', $row3->minTime, $row3->maxTime, $events, $start, $end); } if ($row3->fri_o != '') { $comp6o = strtotime($row3->fri_o); $comp6c = strtotime($row3->fri_c); if ($comp6o > $compminTime) { $events = $this->add_closed1('friday', $row3->minTime, $row3->fri_o, $events, $start, $end); } if ($comp6c < $compmaxTime) { $events = $this->add_closed2('friday', $row3->maxTime, $row3->fri_c, $events, $start, $end); } } else { $events = $this->add_closed3('friday', $row3->minTime, $row3->maxTime, $events, $start, $end); } if ($row3->sat_o != '') { $comp7o = strtotime($row3->sat_o); $comp7c = strtotime($row3->sat_c); if ($comp7o > $compminTime) { $events = $this->add_closed1('saturday', $row3->minTime, $row3->sat_o, $events, $start, $end); } if ($comp7c < $compmaxTime) { $events = $this->add_closed2('saturday', $row3->maxTime, $row3->sat_c, $events, $start, $end); } } else { $events = $this->add_closed3('saturday', $row3->minTime, $row3->maxTime, $events, $start, $end); } echo json_encode($events); }
public function action() { $errors = new MessageBag(); if ($old = Input::old("errors")) { $errors = $old; } $data = array("errors" => $errors); if (Input::server("REQUEST_METHOD") == "POST") { $default_practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first(); if ($default_practice->patient_centric == 'y') { $validator_array = array("username" => "required", "password" => "required"); } else { $validator_array = array("username" => "required", "password" => "required", "practice_id" => "required"); } $validator = Validator::make(Input::all(), $validator_array); if ($validator->passes()) { $username = Input::get('username'); $password = Input::get('password'); if ($default_practice->patient_centric == 'y') { $credentials = array("username" => $username, "password" => $password, "active" => '1'); $user = User::where('username', '=', $username)->where('active', '=', '1')->first(); } else { $practice_id = Input::get('practice_id'); $credentials = array("username" => $username, "password" => $password, "active" => '1', "practice_id" => $practice_id); $user = User::where('username', '=', $username)->where('active', '=', '1')->where('practice_id', '=', $practice_id)->first(); } if (Auth::attempt($credentials)) { $practice = Practiceinfo::find($user->practice_id); Session::put('user_id', $user->id); Session::put('group_id', $user->group_id); Session::put('practice_id', $user->practice_id); Session::put('version', $practice->version); Session::put('practice_active', $practice->active); Session::put('displayname', $user->displayname); Session::put('documents_dir', $practice->documents_dir); Session::put('rcopia', $practice->rcopia_extension); Session::put('mtm_extension', $practice->mtm_extension); Session::put('patient_centric', $practice->patient_centric); setcookie("login_attempts", 0, time() + 900, '/'); if ($practice->patient_centric == 'n') { return Redirect::intended('mobile'); } else { if ($user->group_id != '100' && $user->group_id != '1') { $pid = DB::table('demographics')->first(); $this->setpatient($pid->pid); return Redirect::intended('chart'); } else { return Redirect::intended('mobile'); } } } } $attempts = $_COOKIE['login_attempts'] + 1; setcookie("login_attempts", $attempts, time() + 900, '/'); $data["errors"] = new MessageBag(array("password" => "Username and/or password invalid.")); $data["username"] = Input::get("username"); return Redirect::to("login_mobile")->withInput($data); } else { $practice1 = Practiceinfo::find(1); Session::put('version', $practice1->version); $practice_id = Session::get('practice_id'); if ($practice_id == FALSE) { $data['practice_id'] = '1'; } else { $data['practice_id'] = $practice_id; } $data['patient_centric'] = $practice1->patient_centric; $practices = Practiceinfo::all(); $practices_array = array(); if ($practices) { foreach ($practices as $practice_row) { $practices_array[$practice_row->practice_id] = $practice_row->practice_name; } } $data['practices'] = Form::select('practice_id', $practices_array, null, array('id' => 'practice_id')); if (array_key_exists('login_attempts', $_COOKIE) && $_COOKIE['login_attempts'] >= 5) { $data['attempts'] = "You have reached the number of limits to login. Wait 15 minutes then try again."; $this->layout->style = HTML::style('css/mobile.css'); $this->layout->script = $this->js_assets('base', true); //$this->layout->script .= HTML::script('/js/login.js'); $this->layout->content = View::make('mobile.login', $data); } else { if (!array_key_exists('login_attempts', $_COOKIE)) { setcookie("login_attempts", 0, time() + 900, '/'); } $this->layout->style = HTML::style('css/mobile.css'); $this->layout->script = $this->js_assets('base', true); //$this->layout->script .= HTML::script('/js/login.js'); $this->layout->content = View::make('mobile.login', $data); } } }
public function uma_auth() { $open_id_url = str_replace('/nosh', '/uma-server-webapp/', URL::to('/')); $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first(); $client_id = $practice->uma_client_id; $client_secret = $practice->uma_client_secret; $url = route('uma_auth'); $oidc = new OpenIDConnectClient($open_id_url, $client_id, $client_secret); $oidc->setRedirectURL($url); $oidc->authenticate(true, 'user'); $firstname = $oidc->requestUserInfo('given_name'); $lastname = $oidc->requestUserInfo('family_name'); $email = $oidc->requestUserInfo('email'); $npi = $oidc->requestUserInfo('npi'); $access_token = $oidc->getAccessToken(); if ($npi != '') { $provider = DB::table('providers')->where('npi', '=', $npi)->first(); if ($provider) { $user = User::where('id', '=', $provider->id)->first(); } else { $user = false; } } else { $user = User::where('uid', '=', $oidc->requestUserInfo('sub'))->first(); //$user = User::where('firstname', '=', $firstname)->where('email', '=', $email)->where('lastname', '=', $lastname)->where('active', '=', '1')->first(); } if ($user) { Auth::login($user); $practice = Practiceinfo::find($user->practice_id); Session::put('user_id', $user->id); Session::put('group_id', $user->group_id); Session::put('practice_id', $user->practice_id); Session::put('version', $practice->version); Session::put('practice_active', $practice->active); Session::put('displayname', $user->displayname); Session::put('documents_dir', $practice->documents_dir); Session::put('rcopia', $practice->rcopia_extension); Session::put('mtm_extension', $practice->mtm_extension); Session::put('patient_centric', $practice->patient_centric); Session::put('uma_auth_access_token', $access_token); setcookie("login_attempts", 0, time() + 900, '/'); return Redirect::intended('/'); } else { $practice_npi = $oidc->requestUserInfo('practice_npi'); $practice_id = false; if ($practice_npi != '') { $practice_npi_array = explode(',', $practice_npi); $practice_npi_array_null = array(); foreach ($practice_npi_array as $practice_npi_item) { $practice_query = DB::table('practiceinfo')->where('npi', '=', $practice_npi_item)->first(); if ($practice_query) { $practice_id = $practice_query->practice_id; } else { $practice_npi_array_null[] = $practice_npi_item; } } } if ($practice_id == false) { if (count($practice_npi_array_null) == 1) { $url = 'http://docnpi.com/api/index.php?ident=' . $practice_npi_array_null[0] . '&is_ident=true&format=aha'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $data1 = curl_exec($ch); curl_close($ch); $html = new Htmldom($data1); $practicename = ''; $address = ''; $street_address1 = ''; $city = ''; $state = ''; $zip = ''; if (isset($html)) { $li = $html->find('li', 0); if (isset($li)) { $nomatch = $li->innertext; if ($nomatch != ' no matching results ') { $name_item = $li->find('span[class=org]', 0); $practicename = $name_item->innertext; $address_item = $li->find('span[class=address]', 0); $address = $address_item->innertext; } } } if ($address != '') { $address_array = explode(',', $address); if (isset($address_array[0])) { $street_address1 = trim($address_array[0]); } if (isset($address_array[1])) { $zip = trim($address_array[1]); } if (isset($address_array[2])) { $city = trim($address_array[2]); } if (isset($address_array[3])) { $state = trim($address_array[3]); } } $practice_data = array('npi' => $practice_npi_array_null[0], 'practice_name' => $practicename, 'street_address1' => $street_address1, 'city' => $city, 'state' => $state, 'zip' => $zip, 'documents_dir' => $practice->documents_dir, 'version' => $practice->version, 'active' => 'Y', 'fax_type' => '', 'vivacare' => '', 'patient_centric' => 'yp', 'smtp_user' => $practice->smtp_user, 'smtp_pass' => $practice->smtp_pass); $practice_id = DB::table('practiceinfo')->insertGetId($practice_data); $this->audit('Add'); } else { Session::put('practice_npi_array', implode(',', $practice_npi_array_null)); Session::put('firstname', $firstname); Session::put('lastname', $lastname); Session::put('username', $oidc->requestUserInfo('sub')); Session::put('middle', $oidc->requestUserInfo('middle_name')); Session::put('displayname', $oidc->requestUserInfo('name')); Session::put('email', $email); Session::put('npi', $npi); Session::put('practice_choose', 'y'); Session::put('uid', $oidc->requestUserInfo('sub')); Session::put('uma_auth_access_token', $access_token); return Redirect::to('practice_choose'); } } $data = array('username' => $oidc->requestUserInfo('sub'), 'firstname' => $firstname, 'middle' => $oidc->requestUserInfo('middle_name'), 'lastname' => $lastname, 'displayname' => $oidc->requestUserInfo('name'), 'email' => $email, 'group_id' => '2', 'active' => '1', 'practice_id' => $practice_id, 'secret_question' => 'Use HIEofOne to reset your password!', 'uid' => $oidc->requestUserInfo('sub')); $id = DB::table('users')->insertGetId($data); $this->audit('Add'); $data1 = array('id' => $id, 'npi' => $npi, 'practice_id' => $practice_id); DB::table('providers')->insert($data1); $this->audit('Add'); $user1 = User::where('id', '=', $id)->first(); Auth::login($user1); $practice1 = Practiceinfo::find($user1->practice_id); Session::put('user_id', $user1->id); Session::put('group_id', $user1->group_id); Session::put('practice_id', $user1->practice_id); Session::put('version', $practice1->version); Session::put('practice_active', $practice1->active); Session::put('displayname', $user1->displayname); Session::put('documents_dir', $practice1->documents_dir); Session::put('rcopia', $practice1->rcopia_extension); Session::put('mtm_extension', $practice1->mtm_extension); Session::put('patient_centric', $practice1->patient_centric); Session::put('uma_auth_access_token', $access_token); setcookie("login_attempts", 0, time() + 900, '/'); return Redirect::intended('/'); } }
public function getLoadtemplate() { $row = Encounters::find(Session::get('eid')); $data['encounter'] = $row; $gender = Session::get('gender'); $result = Practiceinfo::find(Session::get('practice_id')); if ($result->mtm_extension == 'y') { $data['mtm'] = '<button type="button" id="hpi_mtm" class="nosh_button">MTM</button>'; } else { $data['mtm'] = ''; } $age = Session::get('agealldays'); if ($age <= 365.25) { $data['birth'] = '<button type="button" id="hpi_birth_hx_template" class="nosh_button">Birth History</button>'; } else { $data['birth'] = ''; } if ($age <= 6574.5) { $data['wcc'] = '<button type="button" id="hpi_wcc" class="nosh_button">Well Child Check</button>'; $data['cpe'] = ''; $data['preg'] = ''; } else { $data['wcc'] = ''; $data['cpe'] = '<button type="button" id="hpi_cpe" class="nosh_button">Complete Physical</button>'; if ($gender == 'male') { $data['preg'] = ''; } else { $data['preg'] = '<button type="button" id="hpi_preg" class="nosh_button">Pregnancy Status</button>'; } } if ($row->encounter_template == 'standardmedical' || $row->encounter_template == 'standardmedical1') { $data['ros'] = View::make('encounters.ros')->render(); $data['oh'] = View::make('encounters.oh')->render(); $data1['practiceInfo'] = $result; $data['vitals'] = View::make('encounters.vitals', $data1)->render(); $data['pe'] = View::make('encounters.pe')->render(); $data['labs'] = View::make('encounters.labs')->render(); $data['results'] = View::make('encounters.results')->render(); $data['proc'] = View::make('encounters.proc')->render(); $data['assessment'] = View::make('encounters.assessment')->render(); $data2['mtm'] = $result->mtm_extension; $data['orders'] = View::make('encounters.orders', $data2)->render(); } if ($row->encounter_template == 'clinicalsupport') { $data['oh'] = View::make('encounters.oh')->render(); $data['labs'] = View::make('encounters.labs')->render(); $data['proc'] = View::make('encounters.proc')->render(); $data['assessment'] = View::make('encounters.assessment')->render(); $data2['mtm'] = $result->mtm_extension; $data['orders'] = View::make('encounters.orders', $data2)->render(); } if ($row->encounter_template == 'standardpsych' || $row->encounter_template == 'standardpsych1') { $data['ros'] = View::make('encounters.ros')->render(); $data['oh'] = View::make('encounters.oh')->render(); $data1['practiceInfo'] = $result; $data['vitals'] = View::make('encounters.vitals', $data1)->render(); $data['pe'] = View::make('encounters.pe')->render(); $data['assessment'] = View::make('encounters.assessment')->render(); $data2['mtm'] = $result->mtm_extension; $data['orders'] = View::make('encounters.orders', $data2)->render(); } if ($row->encounter_template == 'standardmtm') { $data2['mtm'] = $result->mtm_extension; $data['oh'] = View::make('encounters.oh')->render(); $data1['practiceInfo'] = $result; $data['vitals'] = View::make('encounters.vitals', $data1)->render(); $data['results'] = View::make('encounters.results')->render(); $data['assessment'] = View::make('encounters.assessment')->render(); $data['orders'] = View::make('encounters.orders', $data2)->render(); $data['medications'] = View::make('encounters.mtm_medications')->render(); } return View::make('encounters.' . $row->encounter_template, $data); }
public function postSendMessage() { $message_id = Input::get('message_id'); $from = Session::get('user_id'); $t_messages_id = Input::get('t_messages_id'); if (Input::get('patient_name') == '') { $subject = Input::get('subject'); } else { $subject = Input::get('subject') . ' [RE: ' . Input::get('patient_name') . ']'; } $mailbox = array(); $messages_to = ""; $i = 0; foreach (Input::get('message_to') as $key => $to_row) { $to_pos = strpos($to_row, "("); $to_pos = $to_pos + 1; $to_id = substr($to_row, $to_pos); $mailbox[] = str_replace(")", "", $to_id); if ($i > 0) { $messages_to .= ";" . $to_row; } else { $messages_to .= $to_row; } $i++; } $messages_cc = ""; if (Input::get('cc') != '') { $j = 0; foreach (Input::get('cc') as $key1 => $cc_row) { $cc_pos = strpos($cc_row, "("); $cc_pos = $cc_pos + 1; $cc_id = substr($cc_row, $cc_pos); $mailbox[] = str_replace(")", "", $cc_id); if ($j > 0) { $messages_cc .= ";" . $cc_row; } else { $messages_cc .= $cc_row; } $j++; } } foreach ($mailbox as $mailbox_row) { if ($mailbox_row != '') { $data = array('pid' => Input::get('pid'), 'patient_name' => Input::get('patient_name'), 'message_to' => $messages_to, 'cc' => $messages_cc, 'message_from' => $from, 'subject' => $subject, 'body' => Input::get('body'), 't_messages_id' => $t_messages_id, 'status' => 'Sent', 'mailbox' => $mailbox_row, 'practice_id' => Session::get('practice_id')); DB::table('messaging')->insert($data); $this->audit('Add'); $user_row = User::find($mailbox_row); if ($user_row->group_id === '100') { $practice = Practiceinfo::find(Session::get('practice_id')); $data_message['patient_portal'] = $practice->patient_portal; $this->send_mail('emails.newmessage', $data_message, 'New Message in your Patient Portal', $user_row->email, Session::get('practice_id')); } } } $data1a = array('pid' => Input::get('pid'), 'patient_name' => Input::get('patient_name'), 'message_to' => $messages_to, 'cc' => $messages_cc, 'message_from' => $from, 'subject' => $subject, 'body' => Input::get('body'), 'status' => 'Sent', 'mailbox' => '0', 'practice_id' => Session::get('practice_id')); if ($message_id != '') { DB::table('messaging')->where('message_id', '=', $message_id)->update($data1a); $this->audit('Update'); } else { $message_id = DB::table('messaging')->insertGetId($data1a); $this->audit('Add'); } if ($t_messages_id != '' || $t_messages_id != '0') { $row = User::find($from); $displayname = $row->displayname . ' (' . $row->id . ')'; $row1 = Messaging::find($message_id); $date = explode(" ", $row1->date); $message1 = Input::get('body'); $message = 'On ' . $row1->date . ', ' . $displayname . ' wrote:' . "\n---------------------------------\n" . $message1; $data1 = array('t_messages_message' => $message, 't_messages_to' => ''); DB::table('t_messages')->where('t_messages_id', '=', $t_messages_id)->update($data1); $this->audit('Update'); } echo 'Message sent!'; }
public function get_scans($practice_id) { $result = Practiceinfo::find($practice_id); Config::set('app.timezone', $result->timezone); $dir = $result->documents_dir . 'scans/' . $practice_id; if (!file_exists($dir)) { mkdir($dir, 0777); } $files = scandir($dir); $count = count($files); $j = 0; for ($i = 2; $i < $count; $i++) { $line = $files[$i]; $filePath = $dir . "/" . $line; $check = DB::table('scans')->where('fileName', '=', $line)->first(); if (!$check) { $date = fileatime($filePath); $fileDateTime = date('Y-m-d H:i:s', $date); $pdftext = file_get_contents($filePath); $filePages = preg_match_all("/\\/Page\\W/", $pdftext, $dummy); $data = array('fileName' => $line, 'filePath' => $filePath, 'fileDateTime' => $fileDateTime, 'filePages' => $filePages, 'practice_id' => $practice_id); DB::table('scans')->insert($data); $this->audit('Add'); $j++; } } return $j; }
public function main() { $row = Practiceinfo::find(Session::get('practice_id')); if (isset($row->default_pos_id)) { $data['default_pos'] = $row->default_pos_id; } else { $data['default_pos'] = ''; } $data['encounter_template'] = $row->encounter_template; if ($row->weekends == '1') { $data['weekends'] = 'true'; } else { $data['weekends'] = 'false'; } $data['minTime'] = ltrim($row->minTime, "0"); $data['maxTime'] = ltrim($row->maxTime, "0"); if (!Session::get('encounter_active')) { Session::put('encounter_active', 'n'); } 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 ($row->fax_type != "") { $data1['fax'] = true; } else { $data1['fax'] = false; } $patient = DB::table('demographics_relate')->where('pid', '=', Session::get('pid'))->where('practice_id', '=', Session::get('practice_id'))->whereNotNull('id')->first(); if ($patient) { $data2['portal_active'] = true; } else { $data2['portal_active'] = false; } $patient1 = DB::table('demographics_relate')->where('pid', '=', Session::get('pid'))->where('practice_id', '=', Session::get('practice_id'))->whereNotNull('url')->first(); if ($patient1) { $data['url'] = 'Connected'; } else { $data['url'] = 'Not Connected'; } $this->layout->style = $this->css_assets(); $this->layout->script = $this->js_assets('chart'); $this->layout->search = View::make('search', $this->getSearchData())->render(); $this->layout->menu = View::make('menu', $this->getMenuData())->render(); $this->layout->content = View::make('chart', $data)->render(); $this->layout->modules = View::make('demographics')->render(); $this->layout->modules .= View::make('options')->render(); $this->layout->modules .= View::make('issues')->render(); $this->layout->modules .= View::make('medications')->render(); $this->layout->modules .= View::make('allergies')->render(); $this->layout->modules .= View::make('supplements')->render(); $this->layout->modules .= View::make('immunizations')->render(); $this->layout->modules .= View::make('print')->render(); $this->layout->modules .= View::make('billing')->render(); $this->layout->modules .= View::make('documents')->render(); $this->layout->modules .= View::make('t_messages')->render(); $this->layout->modules .= View::make('encounters')->render(); $this->layout->modules .= View::make('alerts', $data2)->render(); $this->layout->modules .= View::make('lab')->render(); $this->layout->modules .= View::make('rad')->render(); $this->layout->modules .= View::make('cp')->render(); $this->layout->modules .= View::make('ref')->render(); $this->layout->modules .= View::make('messaging', $data1)->render(); $this->layout->modules .= View::make('schedule')->render(); $this->layout->modules .= View::make('financial')->render(); $this->layout->modules .= View::make('office')->render(); $this->layout->modules .= View::make('graph')->render(); $this->layout->modules .= View::make('image')->render(); if ($row->mtm_extension == 'y') { $this->layout->content .= View::make('mtm')->render(); $this->layout->script .= HTML::script('/js/mtm.js'); } }