public function logoutInactiveUsers() { $now = time(); $foo = $now - $_SESSION['inactive']['time']; $users = array(); $this->db->setSQL("SELECT id, uid FROM users_sessions WHERE last_request < {$foo} AND logout IS NULL"); foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $user) { $id = $user['id']; $users[] = array('uid' => $user['uid']); $this->db->setSQL("UPDATE users_sessions SET logout = '{$now}' WHERE id = '{$id}'"); $this->db->execOnly(); } return $users; }
protected function addEncounterHistoryEvent($msg) { $data['eid'] = $this->eid; //$data['pid'] = $_SESSION['patient']['pid']; $data['date'] = date('Y-m-d H:i:s'); $data['user'] = $this->user->getCurrentUserTitleLastName(); $data['event'] = $msg; $this->db->setSQL($this->db->sqlBind($data, 'encounter_history', 'I')); $this->db->execOnly(); }
public function removeAllowBlank($table) { $this->db->setSQL("Select id, options FROM {$table}"); foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $row) { $options = json_decode($row['options'], true); if (isset($options['allowBlank'])) { unset($options['allowBlank']); $id = $row['id']; $data['options'] = json_encode($options); $this->db->setSQL($this->db->sqlBind($data, $table, 'U', "id='{$id}'")); $this->db->execOnly(); } } }
public function addPatientLabsResult(stdClass $params) { $lab['pid'] = isset($params->pid) ? $params->pid : $_SESSION['patient']['pid']; $lab['uid'] = $_SESSION['user']['id']; $lab['document_id'] = $params->document_id; $lab['date'] = date('Y-m-d H:i:s'); $lab['parent_id'] = $params->parent_id; $this->db->setSQL($this->db->sqlBind($lab, 'patient_labs', 'I')); $this->db->execLog(); $patient_lab_id = $this->db->lastInsertId; foreach ($this->laboratories->getLabObservationFieldsByParentId($params->parent_id) as $result) { $foo = array(); $foo['patient_lab_id'] = $patient_lab_id; $foo['observation_loinc'] = $result->loinc_number; $foo['observation_value'] = null; $foo['unit'] = $result->default_unit; $this->db->setSQL($this->db->sqlBind($foo, 'patient_labs_results', 'I')); $this->db->execOnly(); } return $params; }
public function createNewEmergency() { $patient = $this->patient->createNewPatientOnlyName('EMER'); if ($patient['success']) { $this->pid = $patient['patient']['pid']; /** * send new patient to the emergency pool area */ $params = new stdClass(); $params->pid = $this->pid; $params->priority = $this->priority; $params->sendTo = 3; $this->poolArea->sendPatientToPoolArea($params); /** * create new encounter */ $params = new stdClass(); $params->pid = $this->pid; $params->brief_description = '***EMERGENCY***'; $params->visit_category = 'Emergency'; $params->priority = $this->priority; $params->service_date = Time::getLocalTime(); $encounter = $this->encounter->createEncounter($params); $this->eid = $encounter['encounter']->eid; /** * log the emergency */ $this->logEmergency(); /* * update patient first name to EMERGENCY- encounter id */ $data['fname'] = 'EMER-' . $this->emergencyId; $this->db->setSQL($this->db->sqlBind($data, 'patient_demographics', 'U', array('pid' => $this->pid))); $this->db->execOnly(); return array('success' => true, 'emergency' => array('pid' => $this->pid, 'eid' => $this->eid, 'name' => 'EMER-' . $this->emergencyId, 'priority' => $params->priority)); } else { return array('success' => false, 'error' => $patient['error']); } }
// } //} $filename = 'cdt.txt'; $handle = fopen($filename, 'r'); $string = fread($handle, filesize($filename)); //preg_match("/(\w*?) (.*\n)/", $string, $matches, PREG_OFFSET_CAPTURE); // //print '<pre>'; //print_r($matches); // //$html = "<b>bold text</b><a href=howdy.html>click me</a>"; preg_match_all("/(.*?) (.*)\n/", $string, $matches, PREG_SET_ORDER); foreach ($matches as $val) { $data = array('code' => $val[1], 'text' => $val[2]); $db->setSQL($db->sqlBind($data, 'cdt_codes', 'I')); $db->execOnly(); } // print_r($res); //foreach($res as $num => $val){ // echo '<pre>'; // if(is_odd($num)){ // foreach($res[$num] as $item => $inside){ // //$surgeries=($inside); // $data['surgeries'] = $inside; // // print $db->sqlBind($data, 'table_example', 'I'); // echo '<br>'; //// $sql= "INSERT INTO surgeries (type, surgery, type_num) VALUES('".$tittle."','".$surgeries."','".$type_num."')"; //// //// mysql_query($sql); //// echo $sql . "\n";
$prow['prefix'] = $data['phone_prefix']; $prow['number'] = $data['phone_number']; $prow['type'] = 2; $prow['foreign_id'] = $new_id; $frow['country_code'] = $data['fax_country_code']; $frow['area_code'] = $data['fax_area_code']; $frow['prefix'] = $data['fax_prefix']; $frow['number'] = $data['fax_number']; $frow['type'] = 5; $frow['foreign_id'] = $new_id; // ************************************************************************************* // Lets Insert the address for the new pharmacy or insurance // ************************************************************************************* $sql = $mitos_db->sqlBind($arow, "addresses", "I"); $mitos_db->setSQL($sql); $mitos_db->execOnly(); // ************************************************************************************* // Lets Insert the phone number for the new pharmacy or insurance // ************************************************************************************* $sql = $mitos_db->sqlBind($prow, "phone_numbers", "I"); $mitos_db->setSQL($sql); $mitos_db->execOnly(); // ************************************************************************************* // Lets Insert the Fax number for the new pharmacy or insurance // ************************************************************************************* $sql = $mitos_db->sqlBind($frow, "phone_numbers", "I"); $mitos_db->setSQL($sql); $mitos_db->execOnly(); if ($ret[2]) { echo '{ success: false, errors: { reason: "' . $ret[2] . '" }}'; } else {
// Remember, this file is called via the Framework Store, this is the AJAX thing. //-------------------------------------------------------------------------------------------------------------------------- session_name("MitosEHR"); session_start(); session_cache_limiter('private'); include_once "../../../classes/dbHelper.php"; include_once "../../../classes/I18n.class.php"; require_once "../../../classes/dataExchange.class.php"; //****************************************************************************** // Reset session count 10 secs = 1 Flop //****************************************************************************** $_SESSION['site']['flops'] = 0; // Count records variable $count = 0; $mitos_db = new dbHelper(); // ************************************************************************************* // Flag the message to delete // ************************************************************************************* $data = json_decode($_POST['row']); $delete_id = $data[0]->id; // ************************************************************************************* // Finally build the Delete SQL Statement and inject it to the SQL Database // ************************************************************************************* $sql = "DELETE FROM facility WHERE id='" . $delete_id . "'"; $mitos_db->setSQL($sql); $ret = $mitos_db->execOnly(); if ($ret == "") { echo '{ success: false, errors: { reason: "' . $ret[2] . '" }}'; } else { echo "{ success: true }"; }
{ if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir . "/" . $object) == "dir") { RemoveReclusiveDir($dir . "/" . $object); } else { unlink($dir . "/" . $object); } } } reset($objects); rmdir($dir); } return true; } //print '<h1>SQL Clean Up!</h1>'; foreach ($tables as $table) { $db->setSQL("TRUNCATE TABLE {$table}"); $err = $db->execOnly(); $msg = isset($err[1]) ? 'FAIL!' : 'PASS!'; //print 'Empty `' . $table . '` ' . $msg . '<br>'; } //print '<h1>Patient Directories Clean Up!</h1>'; $path = '../sites/' . $_SESSION['site']['dir'] . '/patients/'; $patientsDir = getDirectoryList($path); foreach ($patientsDir as $dir) { RemoveReclusiveDir($path . $dir); } print 'Factory Reset Complete!';