function getLayoutLabel($value, $form_id) { // get from layout_options $sql = sqlStatement("SELECT title from layout_options WHERE form_id = ? and field_id = ?", array($form_id, $value)); if (sqlNumRows($sql) > 0) { $result = sqlFetchArray($sql); return xl($result['title']); } // if not found, default to the passed-in value return $value; }
public function test(CqmPatient $patient, $beginDate, $endDate) { // Flow of control loop $return = false; do { // See if BMI has been recorded between >=22kg/m2 and <30kg/m2 6 months before, or simultanious to the encounter $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( form_vitals.pid = form_encounter.pid ) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? AND form_vitals.BMI >= 22 AND form_vitals.BMI < 30 " . "AND DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) " . "AND DATE( form_vitals.date ) <= DATE( form_encounter.date ) " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )"; $res = sqlStatement($query, array($patient->id)); $number = sqlNumRows($res); if ($number >= 1) { $return = true; break; } // See if BMI has been recorded >=30kg/m2 6 months before, or simultanious to the encounter // AND ÒCare goal: follow-up plan BMI managementÓ OR ÒCommunication provider to provider: dietary consultation orderÓ $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( form_vitals.pid = form_encounter.pid ) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? AND form_vitals.BMI >= 30 " . "AND ( DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) ) " . "AND ( DATE( form_vitals.date ) <= DATE( form_encounter.date ) ) " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )"; $res = sqlStatement($query, array($patient->id)); $number = sqlNumRows($res); if ($number >= 1 && (Helper::check(ClinicalType::CARE_GOAL, CareGoal::FOLLOW_UP_PLAN_BMI_MGMT, $patient) || Helper::check(ClinicalType::COMMUNICATION, Communication::DIET_CNSLT, $patient))) { $return = true; break; } // See if BMI has been recorded <22kg/m2 6 months before, or simultanious to the encounter // AND ÒCare goal: follow-up plan BMI managementÓ OR ÒCommunication provider to provider: dietary consultation orderÓ $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( form_vitals.pid = form_encounter.pid ) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? AND form_vitals.BMI < 22 " . "AND ( DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) ) " . "AND ( DATE( form_vitals.date ) <= DATE( form_encounter.date ) ) " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )"; $res = sqlStatement($query, array($patient->id)); $number = sqlNumRows($res); if ($number >= 1 && (Helper::check(ClinicalType::CARE_GOAL, CareGoal::FOLLOW_UP_PLAN_BMI_MGMT, $patient) || Helper::check(ClinicalType::COMMUNICATION, Communication::DIET_CNSLT, $patient))) { $return = true; break; } } while (false); return $return; }
/** * Offsite Portal connection function library. * * Copyright (C) 2013 Z&H Consultancy Services Private Limited <*****@*****.**> * * LICENSE: This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;. * * @package OpenEMR * @author Eldho Chacko <*****@*****.**> * @author Vinish K <*****@*****.**> * @link http://www.open-emr.org */ function portal_connection(){ global $credentials; $password = $GLOBALS['portal_offsite_password']; $randkey = ''; $timminus = date("Y-m-d H:m",(strtotime(date("Y-m-d H:m"))-7200)).":00"; sqlStatement("DELETE FROM audit_details WHERE audit_master_id IN(SELECT id FROM audit_master WHERE type=5 AND created_time<=?)",array($timminus)); sqlStatement("DELETE FROM audit_master WHERE type=5 AND created_time<=?",array($timminus)); do{ $randkey = substr(md5(rand().rand()), 0, 8); $res = sqlStatement("SELECT * FROM audit_details WHERE field_value = ?",array($randkey)); $cnt = sqlNumRows($res); } while($cnt>0); $password = sha1($password.gmdate("Y-m-d H").$randkey); $grpID = sqlInsert("INSERT INTO audit_master SET type=5"); sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?",array($randkey,$grpID)); $credentials = array($GLOBALS['portal_offsite_username'],$password,$randkey); //CALLING WEBSERVICE ON THE PATIENT-PORTAL $client = new SoapClient(null, array( 'location' => $GLOBALS['portal_offsite_address_patient_link']."/webservice/webserver.php", 'uri' => "urn://portal/req" ) ); return $client; }
public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null) { $data = Codes::lookup($this->getOptionId()); $range = new Range(Range::NEG_INF, Range::POS_INF); if (isset($options[self::OPTION_RANGE]) && is_a($options[self::OPTION_RANGE], 'Range')) { $range = $options[self::OPTION_RANGE]; } foreach ($data as $codeType => $codes) { foreach ($codes as $code) { // search through vitals to find the most recent lab result in the date range // if the result value is within range using Range->test(val), return true $sql = "SELECT procedure_result.result, procedure_result.date " . "FROM `procedure_type`, " . "`procedure_order`, " . "`procedure_report`, " . "`procedure_result` " . "WHERE procedure_type.procedure_type_id = procedure_order.procedure_type_id " . "AND procedure_order.procedure_order_id = procedure_report.procedure_order_id " . "AND procedure_report.procedure_report_id = procedure_result.procedure_report_id " . "AND ( procedure_type.standard_code = ? OR procedure_type.procedure_code = ? ) " . "AND procedure_report.date_collected >= ? " . "AND procedure_report.date_collected <= ? " . "AND procedure_order.patient_id = ? "; if ($range->lowerBound != Range::NEG_INF) { $sql .= "AND procedure_result.result >= ? "; } if ($range->upperBound != Range::POS_INF) { $sql .= "AND procedure_result.result < ? "; } $bindings = array($codeType . ':' . $code, $code, $beginDate, $endDate, $patient->id); if ($range->lowerBound != Range::NEG_INF) { $bindings[] = $range->lowerBound; } if ($range->upperBound != Range::POS_INF) { $bindings[] = $range->upperBound; } $result = sqlStatement($sql, $bindings); $number = sqlNumRows($result); if ($number > 0) { return true; } } } return false; }
public function test(CqmPatient $patient, $beginDate, $endDate) { // See if BP has been done within the measurement period (on a day of a specified encounter) $query = "SELECT form_vitals.bps, form_vitals.bpd " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( DATE(form_vitals.date) = DATE(form_encounter.date)) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.pid = ?" . "AND form_vitals.bps IS NOT NULL AND form_vitals.bps between 100 and 140 " . "AND form_vitals.bpd IS NOT NULL AND form_vitals.bpd between 60 and 90 " . "AND form_vitals.date >= ? " . "AND form_vitals.date <= ? " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' OR enc_category_map.rule_enc_id = 'enc_nurs_fac' )"; $res = sqlStatement($query, array($patient->id, $beginDate, $endDate)); $number = sqlNumRows($res); if ($number > 0) { return true; } return false; }
function md5_pass($length = 8) { $randkey = substr(md5(rand() . rand()), 0, $length); $res = sqlStatement("SELECT * FROM audit_master AS am LEFT OUTER JOIN audit_details AS ad ON ad.audit_master_id=am.id WHERE type=5 AND field_value=?", array($randkey)); if (sqlNumRows($res)) { md5_pass(); } else { $grpID = sqlInsert("INSERT INTO audit_master SET type=5"); sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?", array($randkey, $grpID)); return $randkey; } }
function checkIfPatientValidationHookIsActive() { $module_query = sqlStatement("SELECT * FROM modules WHERE mod_name= 'Patientvalidation' and mod_active=1"); if (sqlNumRows($module_query)) { //if you want to check inactive active hook please uncheck the following comment //$s = "<div style='margin-bottom:10px; border:1px solid black;padding: 5px 5px 5px 5px;width:300px;background-color: #79bbff'><center> " . xl("You are using patient validation module") . "</center></div>"; // echo $s; return true; } else return false; }
function lookup_openemr_patient($wp_login) { if (empty($wp_login)) { die(xlt('The patient was not logged in when submitting this form')); } $ptres = sqlStatement("SELECT pid FROM patient_data WHERE cmsportal_login = ?", array($wp_login)); if (sqlNumRows($ptres) < 1) { die(xlt('There is no patient with portal login') . " '{$wp_login}'"); } if (sqlNumRows($ptres) > 1) { die(xlt('There are multiple patients with portal login') . " '{$wp_login}'"); } $ptrow = sqlFetchArray($ptres); return $ptrow['pid']; }
function lookup_pt($wp_login) { if (empty($wp_login)) { return false; } $ptres = sqlStatement("SELECT pid FROM patient_data WHERE cmsportal_login = ?", array($wp_login)); if (sqlNumRows($ptres) < 1) { return false; } if (sqlNumRows($ptres) > 1) { return false; } $ptrow = sqlFetchArray($ptres); return $ptrow['pid']; }
function update_visit_forms(&$menu_list) { $baseURL = "/interface/patient_file/encounter/load_form.php?formname="; $menu_list->children = array(); $lres = sqlStatement("SELECT * FROM list_options " . "WHERE list_id = 'lbfnames' AND activity = 1 ORDER BY seq, title"); if (sqlNumRows($lres)) { while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; // should start with LBF $title = $lrow['title']; $formURL = $baseURL . urlencode($option_id); $formEntry = new stdClass(); $formEntry->label = xl_form_title($title); $formEntry->url = $formURL; $formEntry->requirement = 2; $formEntry->target = 'enc'; array_push($menu_list->children, $formEntry); } } $reg = getRegistered(); if (!empty($reg)) { foreach ($reg as $entry) { $option_id = $entry['directory']; $title = trim($entry['nickname']); if ($option_id == 'fee_sheet') { continue; } if ($option_id == 'newpatient') { continue; } if (empty($title)) { $title = $entry['name']; } $formURL = $baseURL . urlencode($option_id); $formEntry = new stdClass(); $formEntry->label = xl_form_title($title); $formEntry->url = $formURL; $formEntry->requirement = 2; $formEntry->target = 'enc'; array_push($menu_list->children, $formEntry); } } }
function getQRDAStratumInfo($patArr, $begin_date) { $startumArr = array(); if (count($patArr) > 0) { //Age Between 3 and 11 $stratumOneQry = "SELECT FLOOR( DATEDIFF( '" . add_escape_custom($begin_date) . "' , DOB ) /365 ) as pt_age FROM patient_data WHERE pid IN (" . add_escape_custom(implode(",", $patArr)) . ") HAVING (pt_age BETWEEN 1 AND 10) "; $stratumOneRes = sqlStatement($stratumOneQry); $stratumOneRows = sqlNumRows($stratumOneRes); //Age Between 12 and 17 $stratumTwoQry = "SELECT FLOOR( DATEDIFF( '" . add_escape_custom($begin_date) . "' , DOB ) /365 ) as pt_age FROM patient_data WHERE pid IN (" . add_escape_custom(implode(",", $patArr)) . ") HAVING (pt_age BETWEEN 11 AND 16) "; $stratumTwoRes = sqlStatement($stratumTwoQry); $stratumTwoRows = sqlNumRows($stratumTwoRes); $startumArr[1] = $stratumOneRows; $startumArr[2] = $stratumTwoRows; } else { $startumArr[1] = 0; $startumArr[2] = 0; } return $startumArr; }
public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null) { $data = Codes::lookup($this->getOptionId()); $type = $this->getListType(); foreach ($data as $codeType => $codes) { foreach ($codes as $code) { if (exist_lists_item($patient->id, $type, $codeType . '::' . $code, $endDate)) { return true; } } } if ($this->getOptionId() == self::FINDING_BMI_PERC) { // check for any BMI percentile finding // there are a few BMI codes, but it doesn't matter, // because we just want to check for any finding $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? " . "AND DATE( form_vitals.date ) >= ? " . "AND DATE( form_vitals.date ) <= ? "; $res = sqlStatement($query, array($patient->id, $beginDate, $endDate)); $number = sqlNumRows($res); if ($number >= 1) { return true; } } return false; }
if ($to_date) { $query .= "AND fe.date >= '{$from_date} 00:00:00' AND fe.date <= '{$to_date} 23:59:59' "; } else { $query .= "AND fe.date >= '{$from_date} 00:00:00' AND fe.date <= '{$from_date} 23:59:59' "; } if ($provider) { $query .= "AND fe.provider_id = '{$provider}' "; } if ($facility) { $query .= "AND fe.facility_id = '{$facility}' "; } if ($new_patients) { $query .= "AND fe.date = (SELECT MIN(fe2.date) FROM form_encounter AS fe2 WHERE fe2.pid = fe.pid) "; } $res = sqlStatement($query); $numRows = sqlNumRows($res); if ($numRows > 0) { $lastdocname = ""; $doc_encounters = 0; while ($row = sqlFetchArray($res)) { $patient_id = $row['pid']; $docname = ''; if (!empty($row['ulname']) || !empty($row['ufname'])) { $docname = $row['ulname']; if (!empty($row['ufname']) || !empty($row['umname'])) { $docname .= ', ' . $row['ufname'] . ' ' . $row['umname']; } } $errmsg = ""; if ($details) { // Fetch all other forms for this encounter.
} </script> </head> <body class="body_top"> <form action="list_amendments.php" name="list_amendments" id="list_amendments" method="post" onsubmit='return top.restoreSession()'> <span class="title"><?php echo xlt('List'); ?> </span> <?php $query = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC"; $resultSet = sqlStatement($query, array($pid)); if (sqlNumRows($resultSet)) { ?> <table cellspacing="0" cellpadding="0" style="width:100%"> <tr> <td><a href="javascript:checkForAmendments();" class="css_button"><span><?php echo xlt("Print Amendments"); ?> </span></a></td> <td align="right"> <a href="#" class="small" onClick="checkUncheck(1);"><span><?php echo xlt('Check All'); ?> </span></a> | <a href="#" class="small" onClick="checkUncheck(0);"><span><?php echo xlt('Clear All'); ?>
} // If an encounter ID was given, then we must generate a receipt. // if (!empty($_GET['enc'])) { generate_receipt($patient_id, $_GET['enc']); exit; } // Get the unbilled billing table items and product sales for // this patient. $query = "SELECT id, date, code_type, code, modifier, code_text, " . "provider_id, payer_id, units, fee, encounter " . "FROM billing WHERE pid = ? AND activity = 1 AND " . "billed = 0 AND code_type != 'TAX' " . "ORDER BY encounter DESC, id ASC"; $bres = sqlStatement($query, array($patient_id)); $query = "SELECT s.sale_id, s.sale_date, s.prescription_id, s.fee, " . "s.quantity, s.encounter, s.drug_id, d.name, r.provider_id " . "FROM drug_sales AS s " . "LEFT JOIN drugs AS d ON d.drug_id = s.drug_id " . "LEFT OUTER JOIN prescriptions AS r ON r.id = s.prescription_id " . "WHERE s.pid = ? AND s.billed = 0 " . "ORDER BY s.encounter DESC, s.sale_id ASC"; $dres = sqlStatement($query, array($patient_id)); // If there are none, just redisplay the last receipt and exit. // if (sqlNumRows($bres) == 0 && sqlNumRows($dres) == 0) { generate_receipt($patient_id); exit; } // Get the valid practitioners, including those not active. $arr_users = array(); $ures = sqlStatement("SELECT id, username FROM users WHERE " . "( authorized = 1 OR info LIKE '%provider%' ) AND username != ''"); while ($urow = sqlFetchArray($ures)) { $arr_users[$urow['id']] = '1'; } // Now write a data entry form: // List unbilled billing items (cpt, hcpcs, copays) for the patient. // List unbilled product sales for the patient. // Present an editable dollar amount for each line item, a total // which is also the default value of the input payment amount, // and OK and Cancel buttons.
sqlQuery("INSERT INTO list_options (list_id,option_id,title,seq) VALUES ('drug_units',?,?,?)", array($runit['option_id'] + 1, $medArray[$i]['StrengthUOM'], $runit['option_id'] + 1)); $runit['option_id'] = $runit['option_id'] + 1; } } if ($medArray[$i]['DosageFrequencyDescription']) { $qint = sqlStatement("SELECT option_id FROM list_options WHERE list_id='drug_interval' AND title = ?", array($medArray[$i]['DosageFrequencyDescription'])); $rint = sqlFetchArray($qint); if (sqlNumRows($qint) <= 0) { $rint = sqlQuery("SELECT option_id AS option_id FROM list_options WHERE list_id='drug_interval' ORDER BY ABS(option_id) DESC LIMIT 1"); sqlQuery("INSERT INTO list_options (list_id,option_id,title,seq) VALUES ('drug_interval',?,?,?)", array($rint['option_id'] + 1, $medArray[$i]['DosageFrequencyDescription'], $rint['option_id'] + 1)); $rint['option_id'] = $rint['option_id'] + 1; } } $check = sqlStatement("select * from prescriptions where prescriptionguid=? and patient_id=? and prescriptionguid is not null", array($medArray[$i]['PrescriptionGuid'], $medArray[$i]['ExternalPatientID'])); $prescription_id = ''; if (sqlNumRows($check) == 0) { $prescription_id = sqlInsert("insert into prescriptions \n (\n patient_id,provider_id,encounter,date_added,drug,drug_id,drug_info_erx,form,dosage,size,unit,route,`INTERVAL`,refills,note,`DATETIME`,\n `USER`,site,prescriptionguid,erx_source,rxnorm_drugcode\n )\n values\n (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW(),?,?,?,'1',?)", array($medArray[$i]['ExternalPatientID'], $provider['id'], $encounter, substr($medArray[$i]['PrescriptionDate'], 0, 10), $medArray[$i]['DrugName'], $medArray[$i]['DrugID'], $medArray[$i]['DrugInfo'], $rin['option_id'], $medArray[$i]['DosageNumberDescription'], number($medArray[$i]['Strength']), $runit['option_id'], $rroute['option_id'], $rint['option_id'], $medArray[$i]['Refills'], $medArray[$i]['PrescriptionNotes'], $_SESSION['authUserID'], $medArray[$i]['SiteID'], $medArray[$i]['PrescriptionGuid'], $medArray[$i]['rxcui'])); $j++; } else { sqlQuery("update prescriptions set \n provider_id=?, drug=?, drug_id=?, drug_info_erx=?, form=?, dosage=?, size=? ,unit=?, route=?, `INTERVAL`=?, refills=?, note=?, \n `DATETIME`=NOW(),`USER`=?, site=? ,erx_source='1', rxnorm_drugcode=?, active='1'\n WHERE prescriptionguid=? AND patient_id=?\n ", array($provider['id'], $medArray[$i]['DrugName'], $medArray[$i]['DrugID'], $medArray[$i]['DrugInfo'], $rin['option_id'], $medArray[$i]['DosageNumberDescription'], number($medArray[$i]['Strength']), $runit['option_id'], $rroute['option_id'], $rint['option_id'], $medArray[$i]['Refills'], $medArray[$i]['PrescriptionNotes'], $_SESSION['authUserID'], $medArray[$i]['SiteID'], $medArray[$i]['rxcui'], $medArray[$i]['PrescriptionGuid'], $medArray[$i]['ExternalPatientID'])); } $result = sqlFetchArray($check); if ($result['id']) { $prescription_id = $result['id']; } processAmcCall('e_prescribe_amc', true, 'add', $medArray[$i]['ExternalPatientID'], 'prescriptions', $prescription_id); } if ($j != 0) { sqlQuery("update patient_data set soap_import_status=? where pid=?", array('2', $pid)); } if ($xml_response_count == 0) {
/** * Sequential code set "internal" searching function * * Function is basically a wrapper of the code_set_search() function to support * a optimized searching models. The default mode will: * Searches codes first; then if no hits, it will then search the descriptions * (which are separated by each word in the code_set_search() function). * (This function is not meant to be called directly) * * @param string $form_code_type code set key (special keyword is PROD) (Note --ALL-- has been deprecated and should be run through the multiple_code_set_search() function instead) * @param string $search_term search term * @param integer $limit Number of results to return (NULL means return all) * @param array $modes Holds the search modes to process along with the order of processing (default behavior is described in above function comment) * @param boolean $count if true, then will only return the number of entries * @param boolean $active if true, then will only return active entries * @param integer $start Query start limit (for pagination) * @param integer $number Query number returned (for pagination) * @param array $filter_elements Array that contains elements to filter * @param string $is_hit_mode This is a mode that simply returns the name of the mode if results were found * @return recordset/integer/string */ function sequential_code_set_search($form_code_type, $search_term, $limit = NULL, $modes = NULL, $count = false, $active = true, $start = NULL, $number = NULL, $filter_elements = array(), $is_hit_mode = false) { // Set the default behavior that is described in above function comments if (empty($modes)) { $modes = array('code', 'description'); } // Return the Search Results (loop through each mode in order) foreach ($modes as $mode) { $res = code_set_search($form_code_type, $search_term, $count, $active, false, $start, $number, $filter_elements, $limit, $mode); if ($count && $res > 0 || !$count && sqlNumRows($res) > 0) { if ($is_hit_mode) { // just return the mode return $mode; } else { // returns the count number if count is true or returns the data if count is false return $res; } } } }
if ($iter['id'] && $last_encounter_id != $this_encounter_id) { $tmpbpr = $iter['bill_process']; if ($tmpbpr == '0' && $iter['billed']) { $tmpbpr = '2'; } $rhtml .= "<td><input type='checkbox' value='" . attr($tmpbpr) . "' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling * 1) . "'> </td>\n"; $CheckBoxBilling++; } else { $rhtml .= "<td></td>\n"; } if ($last_encounter_id != $this_encounter_id) { $rhtml2 = ""; $rowcnt = 0; $resMoneyGot = sqlStatement("SELECT pay_amount as PatientPay,date(post_time) as date FROM ar_activity where " . "pid = ? and encounter = ? and payer_type=0 and account_code='PCP'", array($iter['enc_pid'], $iter['enc_encounter'])); //new fees screen copay gives account_code='PCP' if (sqlNumRows($resMoneyGot) > 0) { $lcount += 2; $rcount++; } //checks whether a copay exists for the encounter and if exists displays it. while ($rowMoneyGot = sqlFetchArray($resMoneyGot)) { $rowcnt++; $PatientPay = $rowMoneyGot['PatientPay']; $date = $rowMoneyGot['date']; if ($PatientPay > 0) { if ($rhtml) { $rhtml2 .= "<tr bgcolor='{$bgcolor}'>\n"; } $rhtml2 .= "<td width='50'>"; $rhtml2 .= "<span class='text'>" . xlt('COPAY') . ": </span>"; $rhtml2 .= "</td>\n";
/** * Function to check for existance of data for a patient in the rule_patient_data table * * @param string $patient_id pid of selected patient. * @param string $category label in category column * @param string $item label in item column * @param string $complete label in complete column (YES,NO, or blank) * @param string $num_items_comp number items comparison (eq,ne,gt,ge,lt,le) * @param integer $num_items_thres number of items threshold * @param string $intervalType type of interval (ie. year) * @param integer $intervalValue searched for within this many times of the interval type * @param string $dateTarget target date(format Y-m-d H:i:s). * @return boolean true if check passed, otherwise false */ function exist_custom_item($patient_id, $category, $item, $complete, $num_items_comp, $num_items_thres, $intervalType = '', $intervalValue = '', $dateTarget) { // Set the table $table = 'rule_patient_data'; // Collect the correct column label for patient id in the table $patient_id_label = collect_database_label('pid', $table); // Get the interval sql query string $dateSql = sql_interval_string($table, $intervalType, $intervalValue, $dateTarget); // search for number of specific items $sql = sqlStatementCdrEngine("SELECT `result` " . "FROM `" . add_escape_custom($table) . "` " . "WHERE `category`=? " . "AND `item`=? " . "AND `complete`=? " . "AND `" . add_escape_custom($patient_id_label) . "`=? " . $dateSql, array($category, $item, $complete, $patient_id)); // See if number of returned items passes the comparison return itemsNumberCompare($num_items_comp, $num_items_thres, sqlNumRows($sql)); }
xl('Service Location', 'e'); ?> : </span></td> <td><input type='checkbox' name='service_location' value = '1'></td> <td> </td> <td><span class='text'><?php echo htmlspecialchars(xl('Color'), ENT_QUOTES); ?> : </span><span class="mandatory"> *</span></td> <td><input type=entry name=ncolor id=ncolor size=20 value="">[<a href="javascript:void(0);" onClick="pick('pick','newcolor');return false;" NAME="pick" ID="pick"><?php echo htmlspecialchars(xl('Pick'), ENT_QUOTES); ?> </a>]</td> </tr> <?php $disabled = ''; $resPBE = sqlStatement("select * from facility where primary_business_entity='1' and id!='" . $my_fid . "'"); if (sqlNumRows($resPBE) > 0) { $disabled = 'disabled'; } ?> <tr> <td><span class='text'><?php xl('Primary Business Entity', 'e'); ?> : </span></td> <td><input type='checkbox' name='primary_business_entity' id='primary_business_entity' value='1' <?php if ($facility['primary_business_entity'] == 1) { echo 'checked'; } ?> <?php if ($GLOBALS['erx_enable']) {
$sql_select_part_codetype = ""; $sql_where_part_codetype = ""; if (!empty($CodetypeMaster)) { $sql_select_part_codetype = "billing.code_type,"; $sql_where_part_codetype = "and billing.code_type ='{$CodetypeMaster}'"; } $CodeMaster = $RowSearchSub['code']; $ModifierMaster = $RowSearchSub['modifier']; $res = sqlStatement("SELECT fname,lname,mname FROM patient_data\twhere pid ='{$PId}'"); $row = sqlFetchArray($res); $fname = $row['fname']; $lname = $row['lname']; $mname = $row['mname']; $NameDB = $lname . ' ' . $fname . ' ' . $mname; $ResultSearch = sqlStatement("SELECT billing.id,last_level_closed,billing.encounter,form_encounter.`date`,{$sql_select_part_codetype} billing.code,billing.modifier,fee\n\t\t\t\t\t\t FROM billing ,form_encounter\n\t\t\t\t\t\t where billing.encounter=form_encounter.encounter and billing.pid=form_encounter.pid and \n\t\t\t\t\t\t code_type!='ICD9' and code_type!='COPAY' and billing.activity!=0 and \n\t\t\t\t\t\t form_encounter.pid ='{$PId}' and billing.pid ='{$PId}' and billing.encounter ='{$EncounterMaster}'\n {$sql_where_part_codetype}\n\t\t\t\t\t\t and billing.code ='{$CodeMaster}'\n\t\t\t\t\t\t and billing.modifier ='{$ModifierMaster}'\n\t\t\t\t\t\t ORDER BY form_encounter.`date`,form_encounter.encounter,billing.code,billing.modifier"); if (sqlNumRows($ResultSearch) > 0) { if ($CountPatient == 1) { $Table = 'yes'; ?> <table width="1004" border="0" cellpadding="0" cellspacing="0" align="center" id="TableDistributePortion"> <tr class="text" bgcolor="#dddddd"> <td width="25" class="left top" > </td> <td width="144" class="left top" ><?php echo htmlspecialchars(xl('Patient Name'), ENT_QUOTES); ?> </td> <td width="55" class="left top" ><?php echo htmlspecialchars(xl('Post For'), ENT_QUOTES); ?> </td> <td width="70" class="left top" ><?php
</ul> </li> <?php if ($GLOBALS['gbl_nav_visit_forms']) { ?> <li><a class="collapsed_lv2"><span><?php xl('Visit Forms', 'e'); ?> </span></a> <ul> <?php // Generate the items for visit forms, both traditional and LBF. // $lres = sqlStatement("SELECT * FROM list_options " . "WHERE list_id = 'lbfnames' ORDER BY seq, title"); if (sqlNumRows($lres)) { while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; // should start with LBF $title = $lrow['title']; genMiscLink('RBot', 'cod', '2', xl_form_title($title), "patient_file/encounter/load_form.php?formname={$option_id}"); } } include_once "{$srcdir}/registry.inc"; $reg = getRegistered(); if (!empty($reg)) { foreach ($reg as $entry) { $option_id = $entry['directory']; $title = trim($entry['nickname']); if ($option_id == 'fee_sheet') { continue;
<br> <br> <?php $N = 15; $offset = $_REQUEST['offset']; if (!isset($offset)) { $offset = 0; } $disclQry = " SELECT el.id, el.event, el.recipient, el.description, el.date, CONCAT(u.fname, ' ', u.lname) as user_fullname FROM extended_log el " . " LEFT JOIN users u ON u.username = el.user " . " WHERE el.patient_id=? AND el.event IN (SELECT option_id FROM list_options WHERE list_id='disclosure_type') ORDER BY el.date DESC "; $r2 = sqlStatement($disclQry, array($pid)); $totalRecords = sqlNumRows($r2); //echo "select id,event,recipient,description,date from extended_log where patient_id=$pid AND event in (select option_id from list_options where list_id='disclosure_type') order by date desc limit $offset ,$N"; //display all of the disclosures for the day, as well as others that are active from previous dates, up to a certain number, $N $disclInnerQry = " SELECT el.id, el.event, el.recipient, el.description, el.date, CONCAT(u.fname, ' ', u.lname) as user_fullname FROM extended_log el " . " LEFT JOIN users u ON u.username = el.user " . " WHERE patient_id=? AND event IN (SELECT option_id FROM list_options WHERE list_id='disclosure_type') ORDER BY date DESC LIMIT {$offset},{$N}"; $r1 = sqlStatement($disclInnerQry, array($pid)); $n = sqlNumRows($r1); $noOfRecordsLeft = $totalRecords - $offset; if ($n > 0) { ?> <table border='0' class="text"> <tr> <td colspan='5' style="padding: 5px;"><a href="disclosure_full.php" class="" id='Submit' onclick="top.restoreSession()"><span><?php echo xlt('Refresh'); ?> </span></a></td> </tr> </table> <div id='pnotes'> <table border='0' cellpadding="1" width='80%'> <tr class="showborder_head" align='left' height="22"> <th style='width: 120px';> </th>
?> </ul> </li> </ul> </li> <?php } ?> <li><a class="collapsed" id="repimg" ><span><?php xl('Reports', 'e'); ?> </span></a> <ul> <?php $module_query = sqlStatement("SELECT msh.*,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh LEFT OUTER JOIN modules_settings AS ms ON\n obj_name=enabled_hooks AND ms.mod_id=msh.mod_id LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id \n WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='reports' ORDER BY mod_id"); if (sqlNumRows($module_query)) { $jid = 0; $modid = ''; while ($modulerow = sqlFetchArray($module_query)) { $modulePath = ""; $added = ""; if ($modulerow['type'] == 0) { $modulePath = $GLOBALS['customModDir']; $added = ""; } else { $added = "index"; $modulePath = $GLOBALS['zendModDir']; } $relative_link = "modules/" . $modulePath . "/" . $modulerow['mod_relative_link'] . $modulerow['path']; $mod_nick_name = $modulerow['menu_name'] ? $modulerow['menu_name'] : 'NoName'; if ($jid == 0 || $modid != $modulerow['mod_id']) {
public function getPatientElements($patientId, $totalCount, $requestedPrescriptionIds) { $elements = array(); if ($patientId) { $uploadActive = $this->getGlobals()->getUploadActive(); $elements[] = $this->getPatient($patientId); $selectPrescriptionIds = $this->getStore()->selectPrescriptionIdsNotUploadedByPatientId($patientId, $uploadActive, $totalCount); $selectPrescriptionIdsCount = sqlNumRows($selectPrescriptionIds); $prescriptionIds = array(); while ($selectPrescriptionId = sqlFetchArray($selectPrescriptionIds)) { $prescriptionIds[] = $selectPrescriptionId['id']; } if (count($requestedPrescriptionIds) > 0) { $elements = array_merge($elements, $this->getPatientPrescriptions($requestedPrescriptionIds)); } elseif (count($prescriptionIds) > 0) { $elements = array_merge($elements, $this->getPatientPrescriptions($prescriptionIds)); } else { $this->getPatientPrescriptions(array(0)); } if ($selectPrescriptionIdsCount < $totalCount) { $elements = array_merge($elements, $this->getPatientMedication($patientId, $uploadActive, $totalCount - $selectPrescriptionIdsCount)); } } return $elements; }
$row = sqlFetchArray($res); $Payer = $row['name']; //------------------- } elseif ($RowSearch['patient_id'] * 1 > 0) { //------------------- $res = sqlStatement("SELECT fname,lname,mname FROM patient_data\n\t\t\t\t\t\t\t\t\t\t\t\twhere pid ='{$RowSearch['patient_id']}'"); $row = sqlFetchArray($res); $fname = $row['fname']; $lname = $row['lname']; $mname = $row['mname']; $Payer = $lname . ' ' . $fname . ' ' . $mname; //------------------- } //============================================= $CountIndex++; if ($CountIndex == sqlNumRows($ResultSearch)) { $StringClass = ' bottom left top '; } else { $StringClass = ' left top '; } if ($CountIndex % 2 == 1) { $bgcolor = '#ddddff'; } else { $bgcolor = '#ffdddd'; } ?> <tr class="text" bgcolor='<?php echo $bgcolor; ?> '> <td class="<?php
$widgetButtonLabel = ''; $widgetButtonLink = ''; $widgetAuth = false; $widgetButtonClass = ''; $bodyClass = "summary_item small"; $fixedWidth = false; expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); } ?> <?php $res = sqlStatement("select * from prescriptions where patient_id=? and active='1'", array($pid)); ?> <table> <?php if (sqlNumRows($res) == 0) { ?> <tr class=text> <td><?php echo htmlspecialchars(xl('None'), ENT_NOQUOTES); ?> </td> </tr> <?php } while ($row_currentMed = sqlFetchArray($res)) { $runit = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_units'), $row_currentMed['unit']); $rin = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_form'), $row_currentMed['form']); $rroute = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_route'), $row_currentMed['route']); $rint = generate_display_field(array('data_type' => '1', 'list_id' => 'drug_interval'), $row_currentMed['interval']); ?>
$odrstmt = $odrstmt . ",d.ndc_number"; } if ($_POST['lab_results'] == true && strlen($form_lab_results) > 0) { $odrstmt = $odrstmt . ",procedure_result_result"; } if ($type == 'Medical History') { $sqlstmt = "select * from (" . $sqlstmt . " " . $whr_stmt . " " . $odrstmt . ",history_data_date desc) a group by patient_id"; } else { $sqlstmt = $sqlstmt . " " . $whr_stmt . " " . $odrstmt; } $result = sqlStatement($sqlstmt, $sqlBindArray); $row_id = 1.1; //given to each row to identify and toggle $img_id = 1.2; $k = 1.3; if (sqlNumRows($result) > 0) { ?> <br> <div id = "report_results"> <?php while ($row = sqlFetchArray($result)) { ?> <table width=90% align="center" cellpadding="5" cellspacing="0" style="font-family:tahoma;color:black;" border="0"> <tr bgcolor = "#CCCCCC" style="font-size:15px;"> <td><b><?php echo htmlspecialchars(xl('Summary of'), ENT_NOQUOTES); echo " "; ?> <?php echo htmlspecialchars($row['patient_name'], ENT_NOQUOTES); ?>
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Author: Eldho Chacko <*****@*****.**> // Jacob T Paul <*****@*****.**> // // +------------------------------------------------------------------------------+ //SANITIZE ALL ESCAPES $sanitize_all_escapes = true; // //STOP FAKE REGISTER GLOBALS $fake_register_globals = false; // require_once "../../interface/globals.php"; if (trim($_POST['contextname']) != '' && $_POST['action'] == 'add') { $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0 AND cl_list_item_long=?", array($_POST['contextname'])); if (!sqlNumRows($res)) { $id = sqlInsert("INSERT INTO customlists (cl_list_type,cl_list_item_long) VALUES(?,?)", array(2, $_POST['contextname'])); sqlStatement("UPDATE customlists SET cl_list_id=? WHERE cl_list_slno=?", array($id, $id)); } } elseif ($_POST['action'] == 'delete' && $_POST['item'] != '') { sqlStatement("UPDATE customlists SET cl_deleted=1 WHERE cl_list_type=2 AND cl_list_slno=?", array($_POST['item'])); } elseif ($_POST['action'] == 'update' && $_POST['item'] != '') { sqlStatement("UPDATE customlists SET cl_list_item_long=? WHERE cl_deleted=0 AND cl_list_type=2 AND cl_list_slno=?", array($_POST['updatecontextname'], $_POST['item'])); } ?> <html> <head> <link rel="stylesheet" href="<?php echo $css_header; ?> " type="text/css">
public function valid($credentials) { $timminus = date("Y-m-d H:m", strtotime(date("Y-m-d H:m")) - 7200) . ":00"; sqlStatement("DELETE FROM audit_details WHERE audit_master_id IN(SELECT id FROM audit_master WHERE type=5 AND created_time<=?)", array($timminus)); sqlStatement("DELETE FROM audit_master WHERE type=5 AND created_time<=?", array($timminus)); global $pid; $ok = 0; $okE = 0; $okN = 0; $okO = 0; $okP = 0; $tim = strtotime(gmdate("Y-m-d H:m")); $res = sqlStatement("SELECT * FROM audit_details WHERE field_value=?", array($credentials[3])); if (sqlNumRows($res)) { if ($GLOBALS['validated_offsite_portal'] != true) { return false; } } else { $grpID = sqlInsert("INSERT INTO audit_master SET type=5"); sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=? ", array($credentials[3], $grpID)); } if (sha1($GLOBALS['portal_offsite_password'] . date("Y-m-d H", $tim) . $credentials[3]) == $credentials[2]) { $ok = 1; } elseif (sha1($GLOBALS['portal_offsite_password'] . date("Y-m-d H", $tim - 3600) . $credentials[3]) == $credentials[2]) { $ok = 1; } elseif (sha1($GLOBALS['portal_offsite_password'] . date("Y-m-d H", $tim + 3600) . $credentials[3]) == $credentials[2]) { $ok = 1; } if ($credentials[1] == $GLOBALS['portal_offsite_username'] && $ok == 1 && $GLOBALS['portal_offsite_enable'] == 1 || $GLOBALS['validated_offsite_portal'] == true) { $prow = sqlQuery("SELECT * FROM patient_access_offsite WHERE portal_username=?", array($credentials[6])); if ($credentials[4] == 'existingpatient') { if (UserService::validcredential($credentials) === 2) { $okE = 2; } elseif (UserService::validcredential($credentials) == true) { $okE = 1; } else { return false; } } elseif ($credentials[4] == 'oemruser') { if ($credentials[9]) { $prow = sqlQuery("SELECT pid FROM audit_master WHERE id=?", array($credentials[9])); } $okO = 1; } elseif ($credentials[4] == 'newpatient') { if (UserService::validcredential($credentials) === 2) { $okN = 3; } elseif (UserService::validcredential($credentials)) { $okN = 2; } else { $okN = 1; $prow = sqlQuery("SELECT IFNULL(MAX(pid)+1,1) AS pid FROM patient_data"); } } if ($okE == 1 || $okN == 2 || $okN == 1 || $okO == 1) { $pid = $prow['pid']; $GLOBALS['pid'] = $prow['pid']; } elseif ($okE == 2 || $okN == 3) { $arow = sqlQuery("\n\t\t\t\tSELECT \n\t\t\t\t\tad.audit_master_id \n\t\t\t\tFROM\n\t\t\t\t\taudit_details ad \n\t\t\t\t\tJOIN audit_details ad2 \n\t\t\t\t\t\tON ad2.audit_master_id = ad.audit_master_id \n\t\t\t\t\t\tAND ad2.table_name = 'patient_access_offsite' \n\t\t\t\t\t\tAND ad2.field_name = 'portal_pwd' \n\t\t\t\tWHERE ad.table_name = 'patient_access_offsite' \n\t\t\t\t\tAND ad.field_name = 'portal_username' \n\t\t\t\t\tAND ad.field_value = ?\n\t\t\t", array($credentials[6])); $auditmasterid = $arow['audit_master_id']; $GLOBALS['auditmasterid'] = $arow['audit_master_id']; $pid = 0; $GLOBALS['pid'] = 0; } $_GET['site'] = $credentials[0]; if ($okE) { if ($okE == 1) { $portal = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid)); } elseif ($okE == 2) { $portal = sqlQuery("\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tIF(COUNT(*),'yes','no') AS allow_patient_portal\n\t\t\t\t\tFROM\n\t\t\t\t\t\taudit_master am \n\t\t\t\t\t\tJOIN audit_details ad \n\t\t\t\t\t\t\tON ad.audit_master_id = am.id \n\t\t\t\t\t\t\tAND ad.table_name = 'patient_access_offsite' \n\t\t\t\t\t\t\tAND ad.field_name = 'portal_username' \n\t\t\t\t\tWHERE am.approval_status = 1 \n\t\t\t\t\t\tAND ad.field_value = ?\n\t\t\t\t", array($credentials[6])); } if (strtolower($portal['allow_patient_portal']) != 'yes') { return false; } } $GLOBALS['validated_offsite_portal'] = true; if ($okO) { return 'oemruser'; } elseif ($okE == 1) { return 'existingpatient'; } elseif ($okE == 2) { return 'newpatienttoapprove'; } elseif ($okN == 1 || $okN == 2) { return 'newpatient'; } elseif ($okN == 3) { return 'newpatienttoapprove'; } return false; } else { return false; } }