function getXMLDocument()
 {
     try {
         $this->conn = Matcha::getConn();
         $filePointer = "../reports/{$this->reportDir}/reportStatement.sql";
         // Important connection parameter, this will allow multiple
         // prepare tags with the same name.
         $this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         if (file_exists($filePointer) && is_readable($filePointer)) {
             // Get the SQL content
             $fileContent = file_get_contents($filePointer);
             $RunSQL = $this->conn->prepare($fileContent);
             // Copy all the request variables into the ExecuteValues
             foreach ($this->request as $field) {
                 $PrepareField[':' . $field['name']] = $field['value'];
             }
             // Also copy all the request variables to Return variable to XML
             foreach ($this->request as $field) {
                 $ReturnFilter[$field['name']] = $field['value'];
             }
             $RunSQL->execute($PrepareField);
             $records = $RunSQL->fetchAll(PDO::FETCH_ASSOC);
             $ExtraAttributes['xml-stylesheet'] = 'type="text/xsl" href="report.xsl"';
             Array2XML::init('1.0', 'UTF-8', true, $ExtraAttributes);
             $xml = Array2XML::createXML('records', array('filters' => $ReturnFilter, 'record' => $records));
             return $xml->saveXML();
         } else {
             throw new Exception('Error: Not SQL Statement file was found or is readable.');
         }
     } catch (Exception $Error) {
         error_log(print_r($Error, true));
         return $Error;
     }
 }
Example #2
0
 function __construct()
 {
     $this->conn = Matcha::getConn();
     $this->patient = new Patient();
     $this->poolArea = new PoolArea();
     $this->diagnosis = new DiagnosisCodes();
     $this->FamilyHistory = new FamilyHistory();
     if (!isset($this->e)) {
         $this->e = MatchaModel::setSenchaModel('App.model.patient.Encounter');
     }
     if (!isset($this->ros)) {
         $this->ros = MatchaModel::setSenchaModel('App.model.patient.ReviewOfSystems');
     }
     if (!isset($this->soap)) {
         $this->soap = MatchaModel::setSenchaModel('App.model.patient.SOAP');
     }
     if (!isset($this->d)) {
         $this->d = MatchaModel::setSenchaModel('App.model.patient.Dictation');
     }
     if (!isset($this->hcfa)) {
         $this->hcfa = MatchaModel::setSenchaModel('App.model.patient.HCFAOptions');
     }
     if (!isset($this->edx)) {
         $this->edx = MatchaModel::setSenchaModel('App.model.patient.EncounterDx');
     }
 }
Example #3
0
 function __construct()
 {
     $this->conn = Matcha::getConn();
     if (!isset($this->s)) {
         $this->s = MatchaModel::setSenchaModel('App.model.patient.EncounterService');
     }
 }
Example #4
0
 /**
  * Creates the MatchaHelper instance
  */
 function __construct()
 {
     $this->db = new MatchaHelper();
     $this->conn = Matcha::getConn();
     if (!isset($this->ff)) {
         $this->ff = MatchaModel::setSenchaModel('App.model.administration.FormField');
     }
 }
Example #5
0
 function __construct()
 {
     $this->conn = Matcha::getConn();
     if (!isset($this->i)) {
         $this->i = MatchaModel::setSenchaModel('App.model.patient.PatientImmunization');
     }
     return;
 }
Example #6
0
 public function logoutSession()
 {
     $id = $_SESSION['session_id'];
     $logout = time();
     $conn = Matcha::getConn();
     $conn->exec("UPDATE `users_sessions` SET `logout` = '{$logout}' WHERE `id` = '{$id}'");
     return true;
 }
Example #7
0
 function __construct()
 {
     parent::__construct();
     $this->conn = \Matcha::getConn();
     $this->user = new \User();
     $this->patient = new \Patient();
     $this->encounter = new \Encounter();
     return;
 }
Example #8
0
 public static function getGeoLocation($ip)
 {
     $conn = Matcha::getConn();
     $sql = 'SELECT * FROM `geo_ip_location` WHERE ? BETWEEN `ip_start_num` AND `ip_end_num`';
     $ip_number = self::isIpV4($ip) ? self::getIpV4Number($ip) : self::getIpV6Number($ip);
     $sth = $conn->prepare($sql);
     $sth->execute([$ip_number]);
     return $sth->fetch(PDO::FETCH_ASSOC);
 }
Example #9
0
 function __construct()
 {
     $this->conn = Matcha::getConn();
     $this->db = new MatchaHelper();
     if (!isset($this->LO)) {
         $this->LO = MatchaModel::setSenchaModel('App.model.administration.LabObservations');
     }
     return;
 }
Example #10
0
 function __construct()
 {
     $this->db = new MatchaHelper();
     $this->conn = Matcha::getConn();
     $this->labs = new Laboratories();
     $this->immu = new Immunizations();
     $this->serv = new Services();
     return;
 }
Example #11
0
 function __construct()
 {
     $this->conn = Matcha::getConn();
     $this->db = new MatchaHelper();
     //	    if($this->LP == null) $this->LO = MatchaModel::setSenchaModel('App.model.administration.LabPanels');
     if ($this->LO == null) {
         $this->LO = MatchaModel::setSenchaModel('App.model.administration.LabObservations');
     }
     return;
 }
Example #12
0
 function getXMLDocument()
 {
     try {
         $filePointer = "../reports/{$this->reportDir}/reportStatement.sql";
         if (file_exists($filePointer) && is_readable($filePointer)) {
             // Important connection parameter, this will allow multiple
             // prepare tags with the same name.
             $this->conn = Matcha::getConn();
             $this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
             // Get the report SQL statement content
             $fileContent = file_get_contents($filePointer);
             // Copy all the request variables into the Prepared Values,
             // also check if it came from the grid form and normal form.
             // This because we need to do a POST-PREPARE the SQL statement
             foreach ($this->request as $field) {
                 $PrepareField[':' . $field['name']]['operator'] = isset($field['operator']) ? $field['operator'] : '=';
                 $PrepareField[':' . $field['name']]['value'] = $field['value'];
             }
             // Copy all the request filter variables to the XML,
             // also check if it came from the grid form and normal form.
             // This because we need to do a POST-PREPARE the SQL statement
             foreach ($this->request as $field) {
                 $ReturnFilter[$field['name']]['operator'] = isset($field['operator']) ? $field['operator'] : '=';
                 $ReturnFilter[$field['name']]['value'] = $field['value'];
             }
             // Prepare all the variable fields in the SQL Statement
             $PreparedSQL = $this->PostPrepare($fileContent, $PrepareField);
             $Queries = explode(';', $PreparedSQL);
             // Run all the SQL Statement separated by `;` in the file
             foreach ($Queries as $Query) {
                 if (strlen(trim($Query)) > 0) {
                     $SQL = $this->conn->prepare($Query);
                     $SQL->execute();
                     $records[] = $SQL->fetchAll(PDO::FETCH_ASSOC);
                 }
             }
             $ExtraAttributes['xml-stylesheet'] = 'type="text/xsl" href="report.xsl"';
             Array2XML::init('1.0', 'UTF-8', true, $ExtraAttributes);
             $xml = Array2XML::createXML('records', array('filters' => $ReturnFilter, 'record' => $records[count($records) - 1]));
             return $xml->saveXML();
         } else {
             throw new Exception('Error: Not SQL Statement file was found or readable.');
         }
     } catch (Exception $Error) {
         error_log(print_r($Error, true));
         return $Error;
     }
 }
Example #13
0
    public function patientLiveSearch(stdClass $params)
    {
        $this->setPatientModel();
        $conn = Matcha::getConn();
        $whereValues = [];
        $where = [];
        $queries = explode(' ', $params->query);
        foreach ($queries as $index => $query) {
            $query = trim($query);
            $where[] = " (pubpid REGEXP :pubpid{$index} OR fname LIKE :fname{$index} OR lname LIKE :lname{$index} OR mname LIKE :mname{$index} OR DOB LIKE :DOB{$index} OR pid LIKE :pid{$index} OR SS LIKE :ss{$index}) ";
            $whereValues[':fname' . $index] = $query . '%';
            $whereValues[':lname' . $index] = $query . '%';
            $whereValues[':mname' . $index] = $query . '%';
            if ($index == 0) {
                if (preg_match('/^(.)-(.*)-(.{2})$/', $query, $matches)) {
                    $whereValues[':pubpid' . $index] = '^' . $matches[1] . '-' . str_pad($matches[2], 15, '0', STR_PAD_LEFT) . '-' . $matches[3] . '$';
                } elseif (preg_match('/^(.)-(.*)$/', $query, $matches)) {
                    $whereValues[':pubpid' . $index] = '^' . $matches[1] . '-' . str_pad($matches[2], 15, '0', STR_PAD_LEFT);
                } elseif (preg_match('/(.*)-(.{2})$/', $query, $matches)) {
                    $whereValues[':pubpid' . $index] = str_pad($matches[1], 15, '0', STR_PAD_LEFT) . '-' . $matches[2];
                } else {
                    $whereValues[':pubpid' . $index] = trim($query, '-') . '-.{2}$';
                }
            } else {
                $whereValues[':pubpid' . $index] = trim($query, '-') . '-.{2}$';
            }
            $whereValues[':DOB' . $index] = $query . '%';
            $whereValues[':pid' . $index] = $query . '%';
            $whereValues[':ss' . $index] = '%' . $query;
        }
        $sth = $conn->prepare('SELECT pid, pubpid, fname, lname, mname, DOB, SS, sex
 								 FROM `patient` WHERE ' . implode(' AND ', $where) . ' LIMIT 300');
        $sth->execute($whereValues);
        $patients = $sth->fetchAll(PDO::FETCH_ASSOC);
        return ['totals' => count($patients), 'rows' => array_slice($patients, $params->start, $params->limit)];
    }
Example #14
0
 function __construct()
 {
     $this->hl7 = new HL7();
     $this->conn = Matcha::getConn();
     $this->p = MatchaModel::setSenchaModel('App.model.patient.Patient');
     $this->e = MatchaModel::setSenchaModel('App.model.patient.Encounter');
     $this->u = MatchaModel::setSenchaModel('App.model.administration.User');
     $this->r = MatchaModel::setSenchaModel('App.model.administration.ReferringProvider');
     $this->m = MatchaModel::setSenchaModel('App.model.administration.HL7Message');
     $this->c = MatchaModel::setSenchaModel('App.model.administration.HL7Client');
     $this->f = MatchaModel::setSenchaModel('App.model.administration.Facility');
 }
Example #15
0
        $records = $recordSet->fetchAll($fetchStyle);
        $err = $recordSet->errorInfo();
        if ($err[2]) {
            return $err;
        }
        return $records;
    }
    /**
     * @brief       Row Count
     * @details     This methods is used to query an statement and return the rows
     * coount using PDO
     *
     * @author      Ernesto J. Rodriguez (Certun) <*****@*****.**>
     * @version     Vega 1.0
     *
     * @note        count($sql) should be use instead of this method.
     *              please refer to @ref Logs::getLogs() to see an example
     *              of how to use count();
     *
     * @return      int The number of rows in a table
     */
    function rowCount()
    {
        $recordSet = self::$__conn->query($this->sql_statement);
        return $recordSet->rowCount();
    }
}
$conn = Matcha::getConn();
if (!isset($conn)) {
    new MatchaHelper();
}
Example #16
0
File: ACL.php Project: igez/gaiaehr
 /**
  * @param {string} $category
  * @param {array} $permissions
  * @param {bool} $install
  */
 public static function updateModulePermissions($category, $permissions, $install)
 {
     self::$conn = Matcha::getConn();
     self::setPermissionModel();
     foreach ($permissions as $permission) {
         $permission = (object) $permission;
         $sth = self::$conn->prepare('SELECT * FROM `acl_permissions` WHERE perm_key = ?');
         $sth->execute([$permission->key]);
         $record = $sth->fetch(PDO::FETCH_ASSOC);
         if ($install && $record === false) {
             $sth = self::$conn->prepare('INSERT INTO `acl_permissions` (`perm_cat`, `perm_name`, `perm_key`, `active`, `seq`) VALUES (?,?,?,?,?)');
             $sth->execute([$category, $permission->title, $permission->key, '1', isset($permission->seq) ? $permission->seq : '0']);
         } elseif ($install) {
             $record = (object) $record;
             $sth = self::$conn->prepare('UPDATE `acl_permissions` SET `perm_cat` = ?, `perm_name` = ?, `perm_key` = ?, `active` = ?, `seq` = ? WHERE id = ?');
             $sth->execute([$category, $permission->title, $permission->key, '1', isset($permission->seq) ? $permission->seq : '0', $record->id]);
         } elseif ($record !== false) {
             $record = (object) $record;
             $sth = self::$conn->prepare('UPDATE `acl_permissions` SET `active` = ?  WHERE id = ?');
             $sth->execute(['0', $record->id]);
         }
     }
 }
Example #17
0
 function __construct()
 {
     $this->conn = \Matcha::getConn();
 }
Example #18
0
 private function getGraphCurves($type, $sex)
 {
     $conn = Matcha::getConn();
     $sth = $conn->prepare("SELECT * FROM vector_graphs WHERE type = :type AND sex = :sex");
     $sth->execute(array(':type' => $type, ':sex' => $sex));
     $records = array();
     foreach ($sth->fetchAll(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;
 }
Example #19
0
 function __construct()
 {
     $this->conn = Matcha::getConn();
     $this->setTables();
 }
Example #20
0
 function __construct()
 {
     $this->hl7 = new HL7();
     $this->conn = Matcha::getConn();
     if (!isset($this->p)) {
         $this->p = MatchaModel::setSenchaModel('App.model.patient.Patient');
     }
     if (!isset($this->PatientContacts)) {
         $this->PatientContacts = MatchaModel::setSenchaModel('App.model.patient.PatientContacts');
     }
     if (!isset($this->EncounterServices)) {
         $this->EncounterServices = MatchaModel::setSenchaModel('App.model.patient.EncounterService');
     }
     if (!isset($this->e)) {
         $this->e = MatchaModel::setSenchaModel('App.model.patient.Encounter');
     }
     if (!isset($this->u)) {
         $this->u = MatchaModel::setSenchaModel('App.model.administration.User');
     }
     if (!isset($this->r)) {
         $this->r = MatchaModel::setSenchaModel('App.model.administration.ReferringProvider');
     }
     if (!isset($this->m)) {
         $this->m = MatchaModel::setSenchaModel('App.model.administration.HL7Message');
     }
     if (!isset($this->c)) {
         $this->c = MatchaModel::setSenchaModel('App.model.administration.HL7Client');
     }
     if (!isset($this->f)) {
         $this->f = MatchaModel::setSenchaModel('App.model.administration.Facility');
     }
 }
Example #21
0
 /**
  * @return bool
  */
 public function isBlocked()
 {
     include_once ROOT . '/dataProvider/GeoIpLocation.php';
     $ip = $_SERVER['REMOTE_ADDR'];
     if ($ip == '::1' || $ip == '127.0.0.1') {
         return false;
     }
     $geo_data = GeoIpLocation::getGeoLocation($ip);
     if ($geo_data === false) {
         $sql = 'SELECT * FROM `ip_access_rules` WHERE active = 1 AND ip = :ip1  OR ip = :ip2 ORDER BY weight DESC LIMIT 1';
         $where = [];
         $where[':ip1'] = '*';
         $where[':ip2'] = $ip;
     } else {
         $sql = 'SELECT * FROM `ip_access_rules` WHERE active = 1 AND ip = :ip1 OR ip = :ip2 OR country_code = :country_code ORDER BY weight DESC LIMIT 1';
         $where = [];
         $where[':ip1'] = '*';
         $where[':ip2'] = $ip;
         $where[':country_code'] = $geo_data['country_code'];
     }
     $conn = Matcha::getConn();
     $sth = $conn->prepare($sql);
     $sth->execute($where);
     $result = $sth->fetch(PDO::FETCH_ASSOC);
     if ($result !== false) {
         $blocked = $result['rule'] == 'BLK';
     } else {
         // if no rule found blocked the IP if not inside local network
         $blocked = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) !== false;
     }
     if ($blocked) {
         $record = new stdClass();
         $record->ip = $ip;
         $record->country_code = $geo_data !== false ? $geo_data['country_code'] : '';
         $record->event = 'Blocked';
         $record->create_date = date('Y-m-d H:i:s');
         $this->l->save($record);
     }
     return $blocked;
 }