Esempio n. 1
0
 /**
  * @param stdClass $params
  * @return array
  * NOTES: Address of who?,
  *  Naming: "getAddressesFromPatient" ???
  */
 public function getAddresses(stdClass $params)
 {
     $this->db->setSQL("SELECT *\n                         FROM users\n                        WHERE users.active = 1 AND ( users.authorized = 1 OR users.username = '' )\n                        LIMIT {$params->start},{$params->limit}");
     $records = $this->db->fetchRecords(PDO::FETCH_ASSOC);
     $total = count($records);
     $rows = array();
     foreach ($records as $row) {
         $row['fullname'] = Person::fullname($row['fname'], $row['mname'], $row['lname']);
         $row['fulladdress'] = Person::fulladdress($row['street'], $row['streetb'], $row['city'], $row['state'], $row['zip']);
         array_push($rows, $row);
     }
     return array('totals' => $total, 'rows' => $rows);
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 /**
  * Function: getPaymentsBySearch
  */
 public function getPaymentsBySearch(stdClass $params)
 {
     // Declare all the variables that we are going to use.
     (array) ($patientPayments = '');
     (int) ($total = 0);
     (string) ($sql = '');
     (string) ($whereClause = '');
     // Look between date the payment was created
     if ($params->datefrom && $params->dateto) {
         $whereClause .= chr(13) . " AND date_created BETWEEN '" . substr($params->datefrom, 0, -9) . " 00:00:00' AND '" . substr($params->dateto, 0, -9) . " 23:00:00'";
     }
     // Look for the Paying Entity
     if ($params->payingEntityCombo) {
         $whereClause .= chr(13) . " AND paying_entity = '" . $params->payingEntityCombo . "'";
     }
     // Look for the Patient
     if ($params->patientSearch) {
         $whereClause .= chr(13) . " AND paying_entity = '" . $params->payingEntityCombo . "'";
     }
     // If the whereClause variable is used go ahead and
     // and add the where command.
     if ($whereClause) {
         $whereClause = 'WHERE ' . $whereClause;
     }
     $sql = "SELECT\n\t\t\t\t\tpatient_demographics.fname,\n\t\t\t\t\tpatient_demographics.mname,\n\t\t\t\t\tpatient_demographics.lname,\n\t\t\t\t\tpatient_demographics.pid,\n\t\t\t\t\tpayments.dtime,\n\t\t\t\t\tpayments.encounter,\n\t\t\t\t\tpayments.user,\n\t\t\t\t\tpayments.method,\n\t\t\t\t\tpayments.source,\n\t\t\t\t\tpayments.amount1,\n\t\t\t\t\tpayments.amount2,\n\t\t\t\t\tpayments.posted1,\n\t\t\t\t\tpayments.posted2\n\t\t\t\tFROM\n\t\t\t\t\tpayments\n\t\t\t\tINNER JOIN\n\t\t\t\t\tpatient_demographics \n\t\t\t\tON\n\t\t\t\t\tpatient_demographics.pid = payments.pid\n\t\t\t\t{$whereClause}";
     $this->db->setSQL($sql);
     // Loop through the results.
     // in here you can do calculations or other stuff.
     foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $row) {
         $patientPayments[] = $row;
     }
     $total = count($patientPayments);
     // Return the results back to ExtJS.
     return array('totals' => $total, 'rows' => $patientPayments);
 }
Esempio n. 4
0
 public function getPatientFutureEventsByPid($pid)
 {
     $date = Time::getLocalTime();
     $tomorrow = date('Y-m-d 0000:00:00', strtotime($date . ' + 1 days'));
     $this->db->setSQL("SELECT * FROM calendar_events WHERE patient_id = '{$pid}' AND start >= '{$tomorrow}'");
     return $this->db->fetchRecords(PDO::FETCH_ASSOC);
 }
Esempio n. 5
0
 public function getTemplatesTypes()
 {
     $this->db->setSQL("SELECT DISTINCT title, body\n                           \t FROM documents_templates\n                           \t WHERE template_type ='documenttemplate'");
     $records = $this->db->fetchRecords(PDO::FETCH_ASSOC);
     $records[] = array('title' => 'Empty');
     return $records;
 }
 /**
  * @param $parent
  * @return array
  *
  * Here we use the parent id to get the child items and it options
  * using basically the same logic of getFields() function and returning
  * an array of child items
  */
 function getChildItems($parent)
 {
     $items = array();
     $this->db->setSQL("Select * FROM forms_fields WHERE parentId = '{$parent}' ORDER BY pos ASC");
     foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $item) {
         $opts = $this->getItemsOptions($item['id']);
         foreach ($opts as $opt => $val) {
             $item[$opt] = $val;
         }
         /**
          * If the item is a combo box lets create a store...
          */
         if ($item['xtype'] == 'combobox') {
             $item = $this->getComboDefaults($item);
             $item['store'] = $this->getStore($item['list_id']);
         }
         if ($item['xtype'] == 'datefield') {
             $item['format'] = 'Y-m-d';
         }
         /**
          * this if what makes this function reclusive this function will keep
          * calling it self
          */
         $item['items'] = $this->getChildItems($item['id']);
         if ($item['items'] == null) {
             unset($item['items']);
         }
         unset($item['id'], $item['form_id'], $item['parentId'], $item['pos']);
         array_push($items, $item);
     }
     return $items;
 }
Esempio n. 7
0
 public function getLabsLiveSearch(stdClass $params)
 {
     $this->db->setSQL("SELECT id,\n\t\t\t\t\t\t\t\t  parent_loinc,\n\t\t\t\t\t\t\t\t  loinc_number,\n\t\t\t\t\t\t\t\t  loinc_name\n\t\t\t\t\t\t\tFROM  labs_panels\n\t\t\t\t\t\t\tWHERE parent_loinc <> loinc_number\n\t\t\t\t\t\t\t  AND loinc_name      LIKE'{$params->query}%'");
     $records = $this->db->fetchRecords(PDO::FETCH_ASSOC);
     $total = count($records);
     $records = array_slice($records, $params->start, $params->limit);
     return array('totals' => $total, 'rows' => $records);
 }
Esempio n. 8
0
 public function getMedicationAttributesByCODE($CODE)
 {
     $this->db->setSQL("\n            SELECT `ATV`, `ATN` FROM rxnsat WHERE `CODE` = '{$CODE}' AND `ATN` = 'DST' AND `SAB` = 'MMSL'\n            UNION\n            SELECT `ATV`, `ATN` FROM rxnsat WHERE `CODE` = '{$CODE}' AND `ATN` = 'DRT' AND `SAB` = 'MMSL'\n            UNION\n            SELECT `ATV`, `ATN` FROM rxnsat WHERE `CODE` = '{$CODE}' AND `ATN` = 'DDF' AND `SAB` = 'MMSL'\n        ");
     $foo = array();
     foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $fo) {
         $foo[$fo['ATN']] = $fo['ATV'];
     }
     return $foo;
 }
Esempio n. 9
0
 private function getPatientsByPoolAreaId($area_id, $in_queue)
 {
     $this->db->setSQL("SELECT pp.*\n\t\t\t\t\t\t\t FROM patient_pools AS pp\n\t\t\t\t\t\t\tWHERE pp.area_id = '{$area_id}'\n\t\t\t\t\t\t\t  AND pp.time_out IS NULL\n\t\t\t\t\t\t\t  AND pp.in_queue = '{$in_queue}'");
     $records = array();
     foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $patient) {
         $patient['name'] = ($patient['eid'] != null ? '*' : '') . $this->patient->getPatientFullNameByPid($patient['pid']);
         $records[] = $patient;
     }
     return $records;
 }
Esempio n. 10
0
 /**
  * @static
  * @return mixed
  */
 public static function setGlobals()
 {
     $conn = new dbHelper();
     $conn->setSQL("SELECT gl_name, gl_value FROM globals");
     foreach ($conn->fetchRecords(PDO::FETCH_ASSOC) as $setting) {
         $_SESSION['global_settings'][$setting['gl_name']] = $setting['gl_value'];
     }
     $_SESSION['global_settings']['timezone_offset'] = -14400;
     $_SESSION['global_settings']['date_time_display_format'] = $_SESSION['global_settings']['date_display_format'] . ' ' . $_SESSION['global_settings']['time_display_format'];
     return $_SESSION['site']['path'];
 }
Esempio n. 11
0
 /**
  * @param stdClass $params
  * @return array
  */
 public function getFacilities(stdClass $params)
 {
     if (isset($params->active)) {
         $wherex = 'active = ' . $params->active;
     } else {
         $wherex = 'active = 1';
     }
     if (isset($params->sort)) {
         $orderx = $params->sort[0]->property . ' ' . $params->sort[0]->direction;
     } else {
         $orderx = 'name';
     }
     $sql = "SELECT * FROM facility WHERE {$wherex} ORDER BY {$orderx} LIMIT {$params->start},{$params->limit}";
     $this->db->setSQL($sql);
     $rows = array();
     foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $row) {
         if (strlen($row['pos_code']) <= 1) {
             $row['pos_code'] = '0' . $row['pos_code'];
         }
         array_push($rows, $row);
     }
     return $rows;
 }
 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();
         }
     }
 }
Esempio n. 13
0
 private function getGraphCurves($type, $sex)
 {
     $this->db->setSQL("SELECT * FROM vector_graphs WHERE type = '{$type}' AND sex = '{$sex}'");
     $records = array();
     foreach ($this->db->fetchRecords(PDO::FETCH_ASSOC) as $row) {
         unset($row['type'], $row['sex'], $row['L'], $row['M'], $row['S']);
         foreach ($row as $key => $val) {
             if ($val == null) {
                 unset($row[$key]);
             }
         }
         $records[] = $row;
     }
     return $records;
 }
Esempio n. 14
0
 /**
  * @internal param $user_id
  * @return array
  */
 public function getUserPerms()
 {
     $this->conn->setSQL("SELECT * FROM acl_user_perms WHERE user_id = '{$this->user_id}' ORDER BY add_date ASC");
     $perms = array();
     foreach ($this->conn->fetchRecords(PDO::FETCH_ASSOC) as $row) {
         $pK = strtolower($row['perm_key']);
         if ($pK == '') {
             continue;
         }
         if ($row['value'] == '1') {
             $hP = true;
         } else {
             $hP = false;
         }
         $perms[$pK] = array('perm' => $pK, 'inheritted' => false, 'value' => $hP, 'Name' => $this->getPermNameByPermKey($row['perm_key']), 'id' => $row['id']);
     }
     return $perms;
 }
Esempio n. 15
0
 private function getFloorPlanZonesByFloorPlanId($floor_plan_id)
 {
     $this->db->setSQL("SELECT * FROM floor_plans_zones WHERE floor_plan_id = '{$floor_plan_id}'");
     return $this->db->fetchRecords(PDO::FETCH_ASSOC);
 }
Esempio n. 16
0
 /**
  * @return array
  */
 public function getCptUsedByClinic()
 {
     $this->db->setSQL("SELECT DISTINCT cpt.code, cpt.code_text, cpt.code_text_medium, cpt.code_text_short\n                             FROM encounter_codes_cpt AS ecc\n                        left JOIN cpt_codes AS cpt ON ecc.code = cpt.code\n                         ORDER BY cpt.code DESC");
     $records = $this->db->fetchRecords(PDO::FETCH_ASSOC);
     return array('totals' => count($records), 'rows' => $records);
 }
Esempio n. 17
0
 public function getPreventiveCareDismissedAlertsByPid(stdClass $params)
 {
     $this->db->setSQL("SELECT pcig.id,\n                                  pcig.preventive_care_id,\n                                  pcig.reason,\n                                  pcig.dismiss,\n                                  pcig.date,\n                                  pcig.observation,\n                                  pcg.description\n                           FROM preventive_care_inactive_patient as pcig\n                           LEFT JOIN preventive_care_guidelines  as pcg on pcig.preventive_care_id = pcg.id\n                           WHERE pcig.pid = '{$params->pid}'\n                           AND  pcig.dismiss = 1");
     return $this->db->fetchRecords();
 }
Esempio n. 18
0
 public function getUserRolesByCurrentUserOrUserId($uid = null)
 {
     $uid = $uid == null ? $_SESSION['user']['id'] : $uid;
     $this->db->setSQL("SELECT * FROM acl_user_roles WHERE user_id = '{$uid}'");
     return $this->db->fetchRecords(PDO::FETCH_ASSOC);
 }
Esempio n. 19
0
 public function getEncounterHCFAOptionsByEid($eid)
 {
     $this->db->setSQL("SELECT * FROM encounter_hcfa_1500_options WHERE eid = '{$eid}'");
     return $this->db->fetchRecords(PDO::FETCH_ASSOC);
 }
Esempio n. 20
0
 public function getPatientDisclosures(stdClass $params)
 {
     $this->db->setSQL("SELECT * FROM patient_disclosures WHERE pid = '{$params->pid}'");
     return $this->db->fetchRecords();
 }