/** * Method to get only the Self Contact witch is the Patient Contact information * @param $pid * @return mixed */ public function getSelfContact($pid) { return $this->Contacts->sql('SELECT *, combo_lists_options.option_name as relationship_name FROM patient_contacts LEFT JOIN combo_lists_options ON relationship = option_value WHERE combo_lists_options.list_id=134 AND patient_contacts.relationship="SEL" AND patient_contacts.pid = ' . $pid)->all(); }
public function getProviderCredentializations($params) { $this->getProviderCredentializationModel(); $this->pc->setOrFilterProperties(array('provider_id')); if (isset($params->fullList)) { $sql = "SELECT `ic`.`id` as insurance_company_id, `ic`.`name` as insurance_company_name,\n\t\t\t\t\t(SELECT id FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider1) as id,\n\t\t\t\t\t:provider2 as 'provider_id',\n\t\t\t\t\t(SELECT start_date FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider3) as start_date,\n\t\t\t\t\t(SELECT end_date FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider4) as end_date,\n\t\t\t\t\t(SELECT credentialization_notes FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider5) as credentialization_notes,\n\t\t\t\t\t(SELECT create_uid FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider6) as create_uid,\n\t\t\t\t\t(SELECT create_date FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider7) as create_date,\n\t\t\t\t\t(SELECT update_uid FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider8) as update_uid,\n\t\t\t\t\t(SELECT update_date FROM provider_credentializations as pc WHERE pc.insurance_company_id = ic.id and pc.provider_id = :provider9) as update_date\n\t\t\t\t FROM `insurance_companies` as ic"; $params = array(':provider1' => $params->providerId, ':provider2' => $params->providerId, ':provider3' => $params->providerId, ':provider4' => $params->providerId, ':provider5' => $params->providerId, ':provider6' => $params->providerId, ':provider7' => $params->providerId, ':provider8' => $params->providerId, ':provider9' => $params->providerId); return $this->pc->sql($sql)->all($params); } return $this->pc->load($params)->all(); }
public function query($params) { $sql = "SELECT *, 'CPT4' as code_type FROM cpt_codes WHERE isRadiology = '1'"; if (isset($params->onlyActive) && $params->onlyActive) { $sql .= " AND active = '1' "; } if (isset($params->isRadiology) && $params->isRadiology) { $sql .= " AND isRadiology = '1' "; } $this->c->reset(); $sql .= ' AND (code LIKE ' . $this->c->where($params->query . '%') . ' OR code_text LIKE ' . $this->c->where('%' . $params->query . '%') . ' OR code_text_short LIKE ' . $this->c->where('%' . $params->query . '%') . ' OR code_text_medium LIKE ' . $this->c->where('%' . $params->query . '%') . ')'; $records = $this->c->sql($sql)->all(); return array('total' => count($records), 'data' => array_slice($records, $params->start, $params->limit)); }
/** * @param $parentId * @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($parentId) { $this->setModels(); $items = []; $records = $this->ff->sql("Select * FROM `forms_fields` WHERE `parentId` = '{$parentId}' ORDER BY `x_index` ASC, `id` ASC")->all(); foreach ($records 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['x_index']); array_push($items, $item); } return $items; }
/** * @param $params * @param $tree * @return mixed */ public function getFacilityConfigs($params, $tree = true) { $this->setFacilityConfigModel(); $records = []; $facilities = $this->getFacilities(['active' => 1]); foreach ($facilities as $facility) { $facility = (object) $facility; $sql = "SELECT f.*, d.title as `text`, false AS `leaf`, true AS `expanded`, false AS `expandable`, true AS `loaded`\n\t\t\t\t\t FROM `facility_structures` AS f\n\t\t\t\tLEFT JOIN `departments` AS d ON f.foreign_id = d.id\n\t\t\t\t WHERE f.foreign_type = 'D' AND f.parentId = 'f{$facility->id}'"; $departments = $this->c->sql($sql)->all(); $departmentsRecords = []; foreach ($departments as $i => $department) { $department = (object) $department; $sql = "SELECT f.*, s.title as `text`, true AS `leaf`, true AS `expanded`, true AS `loaded`\n\t\t\t\t\t FROM `facility_structures` AS f\n\t\t\t\tLEFT JOIN `specialties` AS s ON f.foreign_id = s.id\n\t\t\t\t WHERE f.foreign_type = 'S' AND f.parentId = '{$department->id}'"; $specialties = $this->c->sql($sql)->all(); if ($tree) { $department->children = $specialties; $departmentsRecords[] = $department; } else { foreach ($specialties as $specialty) { $department->specialties[$specialty['foreign_id']] = $specialty; } $departmentsRecords[$department->foreign_id] = $department; } } if ($tree) { $records[] = ['id' => 'f' . $facility->id, 'text' => $facility->name, 'leaf' => false, 'expanded' => true, 'expandable' => false, 'children' => $departmentsRecords]; } else { $facility->departments = $departmentsRecords; $records[$facility->id] = $facility; } } return $records; }
public function searchAllergiesData($params) { if (!isset($params->query)) { return array(); } $this->setAdminAllergyModel(); $sql = "SELECT * FROM `allergies` WHERE `allergy` LIKE '%{$params->query}%' GROUP BY `allergy_code`\tLIMIT 100"; $records = $this->d->sql($sql)->all(); return array('total' => count($records), 'data' => array_slice($records, $params->start, $params->limit)); }
public function getUsersByAcl($acl) { $acls = explode('&', $acl); foreach ($acls as &$acl) { $acl = '`ap`.`perm_key` = \'' . $acl . '\''; } $count = count($acls); $where = implode(' OR ', $acls); $sql = "SELECT `u`.*, `ar`.`role_name` AS role FROM users AS u\n \tLEFT JOIN `acl_roles` AS ar ON `ar`.`id` = `u`.`role_id`\n \t\t\t\t\tWHERE `u`.`id` IN (\n\t\t\t\t\t SELECT `up`.`id` FROM `users` AS up\n\t\t\t\t\t LEFT JOIN `acl_role_perms` AS arp ON `arp`.`role_id` = `up`.`role_id`\n\t\t\t\t\t LEFT JOIN `acl_permissions` AS ap ON `ap`.`id` = `arp`.`perm_id`\n \t\t\t\t\t\tWHERE `arp`.`value` = 1 AND ( {$where} )\n\t\t\t\t\t \tGROUP BY `up`.`id`\n\t\t\t\t\t HAVING COUNT(`up`.`id`) = {$count}\n\t\t\t\t\t) AND (\n\t\t active = 1\n\t )"; $records = $this->u->sql($sql)->all(); return ['total' => count($records), 'data' => $records]; }
public function getActiveFacilities() { if ($this->F == null) { $this->F = MatchaModel::setSenchaModel('App.model.administration.Facility'); } $sql = 'SELECT id AS option_value, `name` AS option_name FROM `facility` WHERE active = \'1\' ORDER BY `name`'; $records = $this->F->sql($sql)->all(); foreach ($records as $i => $record) { $records[$i]['option_value'] = intval($record['option_value']); } return $records; }
/** * @param $params * @param $includeDateOfBirth * * @return mixed */ public function getPossibleDuplicatesByDemographic($params, $includeDateOfBirth = false) { $this->setPatientModel(); $sql = "SELECT *\n\t\t\t\t FROM `patient`\n \t\t\t\t WHERE `fname` SOUNDS LIKE '{$params->fname}'\n \t\t\t\t AND `lname` SOUNDS LIKE '{$params->lname}'\n \t\t\t\t AND `sex` = '{$params->sex}'"; if ($includeDateOfBirth) { $sql = " AND `DOB` = '{$params->DOB}'"; } if (isset($params->pid) && $params->pid != 0) { $sql .= " AND `pid` != '{$params->pid}'"; } $results = $this->p->sql($sql)->all(); return ['total' => count($results), 'data' => $results]; }
/** * @param $params * @param $includeDateOfBirth * * @return mixed */ public function getPossibleDuplicatesByDemographic($params, $includeDateOfBirth = false) { $this->setPatientModel(); $sql = "SELECT *\n\t\t\t\t FROM `patient`\n \t\t\t\t WHERE `fname` SOUNDS LIKE '{$params->fname}'\n \t\t\t\t AND `lname` SOUNDS LIKE '{$params->lname}'\n \t\t\t\t AND `sex` = '{$params->sex}'"; $this->patientContacts = new PatientContacts(); if ($includeDateOfBirth) { $sql = " AND `DOB` = '{$params->DOB}'"; } if (isset($params->pid) && $params->pid != 0) { $sql .= " AND `pid` != '{$params->pid}'"; } $results = $this->p->sql($sql)->all(); foreach ($results as $index => $record) { $contact = $this->patientContacts->getSelfContact($record['pid']); $results[$index]['name'] = Person::fullname($record['fname'], $record['mname'], $record['lname']); if (isset($contact)) { $results[$index]['fulladdress'] = Person::fulladdress(isset($contact['street_mailing_address']) ? $contact['street_mailing_address'] : '', null, isset($contact['city']) ? $contact['city'] : '', isset($contact['state']) ? $contact['state'] : '', isset($contact['zip']) ? $contact['zip'] : ''); $results[$index]['phones'] = isset($contact['phone_local_number']) ? $contact['phone_use_code'] . '-' . $contact['phone_area_code'] . '-' . $contact['phone_local_number'] : ''; } } return ['total' => count($results), 'data' => $results]; }
public function userLiveSearch($params) { $acls = isset($params->acl) ? explode('&', $params->acl) : false; if ($acls === false) { $params->query = $params->query . '%'; $this->u->sql('SELECT `u`.*, `ar`.`role_name` AS role FROM users as u LEFT JOIN `acl_roles` AS ar ON `ar`.`id` = `u`.`role_id` WHERE `u`.`fname` LIKE ? OR `u`.`lname` LIKE ? OR `u`.`username` LIKE ?'); $records = $this->u->all([$params->query, $params->query, $params->query]); } else { foreach ($acls as &$acl) { $acl = '`ap`.`perm_key` = \'' . $acl . '\''; } $count = count($acls); $where = implode(' OR ', $acls); $sql = "SELECT `u`.*, `ar`.`role_name` AS role FROM users AS u\n \tLEFT JOIN `acl_roles` AS ar ON `ar`.`id` = `u`.`role_id`\n \t\t\t\t\tWHERE `u`.`id` IN (\n\t\t\t\t\t SELECT `up`.`id` FROM `users` AS up\n\t\t\t\t\t LEFT JOIN `acl_role_perms` AS arp ON `arp`.`role_id` = `up`.`role_id`\n\t\t\t\t\t LEFT JOIN `acl_permissions` AS ap ON `ap`.`id` = `arp`.`perm_id`\n \t\t\t\t\t\tWHERE `arp`.`value` = 1 AND ( {$where} )\n\t\t\t\t\t \tGROUP BY `up`.`id`\n\t\t\t\t\t HAVING COUNT(`up`.`id`) = {$count}\n\t\t\t\t\t) AND (\n\t\t fname LIKE ? OR lname LIKE ? OR username LIKE ?\n\t )"; $this->u->sql($sql); $params->query = $params->query . '%'; $records = $this->u->all([$params->query, $params->query, $params->query]); } return ['total' => count($records), 'data' => array_slice($records, $params->start, $params->limit)]; }
public function getPatientCurrentZoneInfoByPid($pid) { $this->setPpModel(); $zone = $this->pp->sql("SELECT id AS patientZoneId,\n\t\t\t\t\t\t\t\t zone_id AS zoneId,\n\t\t\t\t\t\t\t\t time_in AS zoneTimeIn\n\t\t FROM patient_zone\n\t\t WHERE pid = '{$pid}' AND time_out IS NULL\n\t\t ORDER BY id DESC")->one(); return $zone; }
/** * Method to get the contacts by type. * @param $pid * @return mixed */ public function getContactByType($pid, $type) { return $this->Contacts->sql("SELECT *,\n combo_lists_options.option_name as relationship_name\n FROM patient_contacts\n LEFT JOIN combo_lists_options\n ON relationship = option_value\n WHERE combo_lists_options.list_id=134\n AND patient_contacts.relationship='{$type}'\n AND patient_contacts.active=1\n AND patient_contacts.pid = {$pid}")->one(); }
public function getEncounterServicesByEIDandPID($params) { return $this->s->sql("SELECT *,\n CLO.option_name as financial_name,\n CLO.code_type as code_type\n FROM\n encounter_services as ES\n LEFT JOIN\n combo_lists_options as CLO\n ON\n (ES.financial_class = CLO.option_value) AND (CLO.list_id=135)\n WHERE\n ES.eid=" . $params->filter[0]->value . " AND\n ES.pid=" . $params->filter[1]->value)->all(); }