/** * Set the hash for the user mails * * @return bool */ protected function setUserMailHash() { $ds = CSQLDataSource::get("std"); $mails = $ds->loadList("SELECT m.user_mail_id, m.account_class, m.account_id, m.from, m.to, m.subject, c.content FROM user_mail as m, content_html as c WHERE m.account_class IS NOT NULL AND m.account_id IS NOT NULL AND m.text_html_id = c.content_id ORDER BY m.user_mail_id DESC;"); if (count($mails)) { $values = array(); foreach ($mails as $_mail) { $data = "==FROM==\n" . $_mail['from'] . "\n==TO==\n" . $_mail['to'] . "\n==SUBJECT==\n" . $_mail['subject'] . "\n==CONTENT==\n" . $_mail['content']; $hash = CMbSecurity::hash(CMbSecurity::SHA256, $data); $values[] = '(' . $_mail['user_mail_id'] . ', ' . $_mail['account_id'] . ', \'' . $_mail['account_class'] . "', '{$hash}')"; } $mails = $ds->loadList("SELECT m.user_mail_id, m.account_class, m.account_id, m.from, m.to, m.subject, c.content FROM user_mail AS m, content_any AS c WHERE m.account_class IS NOT NULL AND m.account_id IS NOT NULL AND m.text_html_id IS NULL AND m.text_plain_id = c.content_id ORDER BY m.user_mail_id DESC;"); foreach ($mails as $_mail) { $data = "==FROM==\n" . $_mail['from'] . "\n==TO==\n" . $_mail['to'] . "\n==SUBJECT==\n" . $_mail['subject'] . "\n==CONTENT==\n" . $_mail['content']; $hash = CMbSecurity::hash(CMbSecurity::SHA256, $data); $values[] = '(' . $_mail['user_mail_id'] . ', ' . $_mail['account_id'] . ', \'' . $_mail['account_class'] . "', '{$hash}')"; } $query = "INSERT INTO `user_mail` (`user_mail_id`, `account_id`, `account_class`, `hash`) VALUES " . implode(', ', $values) . " ON DUPLICATE KEY UPDATE `hash` = VALUES(`hash`);"; $ds->query($query); if ($msg = $ds->error()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); return false; } } return true; }
/** * @see parent::open() */ function open() { if (self::$ds = CSQLDataSource::get("std")) { return true; } return false; }
/** * Change prat usernames to prat ids * * @return bool */ protected function swapPratIds() { $ds = CSQLDataSource::get("std"); CApp::setTimeLimit(1800); $user = new CUser(); // Changement des chirurgiens $query = "SELECT id_chir\r\n FROM plagesop\r\n GROUP BY id_chir"; $listPlages = $ds->loadList($query); foreach ($listPlages as $plage) { $where["user_username"] = "******" . $plage["id_chir"] . "'"; $user->loadObject($where); if ($user->user_id) { $query = "UPDATE plagesop\r\n SET chir_id = '{$user->user_id}'\r\n WHERE id_chir = '{$user->user_username}'"; $ds->exec($query); $ds->error(); } } //Changement des anesthésistes $query = "SELECT id_anesth\r\n FROM plagesop\r\n GROUP BY id_anesth"; $listPlages = $ds->loadList($query); foreach ($listPlages as $plage) { $where["user_username"] = "******" . $plage["id_anesth"] . "'"; $user->loadObject($where); if ($user->user_id) { $query = "UPDATE plagesop\r\n SET anesth_id = '{$user->user_id}'\r\n WHERE id_anesth = '{$user->user_username}'"; $ds->exec($query); $ds->error(); } } return true; }
/** * Get a hash from the primary key * * @param string $id The primary key value * * @return array The hash */ protected function getHash($id) { $id = $this->getDS()->escape($id); $sep = "|"; $key = $this->_key; $key_multi = strpos($key, $sep) !== false; $values_multi = ""; if (!$key_multi) { $where = "{$key} = '{$id}'"; } else { $cols = array_combine(explode($sep, $key), explode($sep, $id)); $values_multi = implode("|", $cols); $where = array(); foreach ($cols as $_col => $_value) { $where[] = "{$_col} = '{$_value}'"; } $where = implode(" AND ", $where); } $query = $this->getSelectQuery($where); $hash = $this->_ds->loadHash($query); if ($hash && $key_multi) { $hash[$key] = $values_multi; } if ($hash == false) { return $hash; } return $hash; }
/** * Get full database structure * * @param string $dsn Datasource name * @param bool $count Count each table entries * * @return mixed * @throws Exception */ static function getDatabaseStructure($dsn, $count = false) { $databases = CImportTools::getAllDatabaseInfo(); if (!isset($databases[$dsn])) { throw new Exception("DSN not found : {$dsn}"); } $db_info = $databases[$dsn]; $ds = CSQLDataSource::get($dsn); // Description file $description = new DOMDocument(); $description->load($db_info["description_file"]); $description->_xpath = new DOMXPath($description); $db_info["description"] = $description; // Tables $table_names = $ds->loadTables(); $tables = array(); foreach ($table_names as $_table_name) { $_table_info = CImportTools::getTableInfo($ds, $_table_name); if ($count) { $_table_info["count"] = $ds->loadResult("SELECT COUNT(*) FROM {$_table_name}"); } $tables[$_table_name] = $_table_info; } $db_info["tables"] = $tables; return $db_info; }
/** * Tells if the "user_authentication" table exists * * @return bool */ static function authReady() { static $ready = null; if ($ready === null) { $ds = CSQLDataSource::get("std"); $ready = $ds->loadTable("user_authentication") != null; } return $ready; }
/** * Récupération des statistiques du nombre de consultations par mois * selon plusieurs filtres * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * * @return array */ function graphConsultations($debut = null, $fin = null, $prat_id = 0) { if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $rectif = CMbDT::transform("+0 DAY", $debut, "%d") - 1; $debutact = CMbDT::date("-{$rectif} DAYS", $debut); $rectif = CMbDT::transform("+0 DAY", $fin, "%d") - 1; $finact = CMbDT::date("-{$rectif} DAYS", $fin); $finact = CMbDT::date("+ 1 MONTH", $finact); $finact = CMbDT::date("-1 DAY", $finact); $pratSel = new CMediusers(); $pratSel->load($prat_id); $ticks = array(); $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false)); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, "%m/%Y")); $serie_total['data'][] = array(count($serie_total['data']), 0); } $ds = CSQLDataSource::get("std"); $total = 0; $series = array(); $query = "SELECT COUNT(consultation.consultation_id) AS total,\r\n DATE_FORMAT(plageconsult.date, '%m/%Y') AS mois,\r\n DATE_FORMAT(plageconsult.date, '%Y%m') AS orderitem\r\n FROM consultation\r\n INNER JOIN plageconsult\r\n ON consultation.plageconsult_id = plageconsult.plageconsult_id\r\n INNER JOIN users_mediboard\r\n ON plageconsult.chir_id = users_mediboard.user_id\r\n WHERE plageconsult.date BETWEEN '{$debutact}' AND '{$finact}'\r\n AND consultation.annule = '0'"; if ($prat_id) { $query .= "\nAND plageconsult.chir_id = '{$prat_id}'"; } $query .= "\nGROUP BY mois ORDER BY orderitem"; $serie = array('data' => array()); $result = $ds->loadlist($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["mois"]) { $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; break; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; // Set up the title for the graph $title = "Nombre de consultations"; $subtitle = "- {$total} consultations -"; if ($prat_id) { $subtitle .= " Dr {$pratSel->_view} -"; } $options = CFlotrGraph::merge("bars", array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('ticks' => $ticks), 'bars' => array('stacked' => true, 'barWidth' => 0.8))); return array('series' => $series, 'options' => $options); }
/** * Check HL7v2 tables presence * * @return bool */ protected function checkHL7v2Tables() { $dshl7 = CSQLDataSource::get("hl7v2", true); if (!$dshl7 || !$dshl7->loadTable("table_entry")) { CAppUI::setMsg("CHL7v2Tables-missing", UI_MSG_ERROR); return false; } return true; }
function CDoRepasAddEdit() { global $m; $this->CDoObjectAddEdit("CRepas", "repas_id"); $this->redirect = "m={$m}&tab=vw_planning_repas"; // Synchronisation Offline $this->synchro = CValue::post("_syncroOffline", false); $this->synchroConfirm = CValue::post("_synchroConfirm", null); $this->synchroDatetime = CValue::post("_synchroDatetime", null); $this->ds = CSQLDataSource::get("std"); }
/** * Search an ICR by it's code * * @param string $code The code to find * * @return mixed|null */ static function searchICR($code) { $ds = CSQLDataSource::get("ccamV2"); $query = $ds->prepare("SELECT * FROM ccam_ICR WHERE code = %", $code); $result = $ds->exec($query); if ($ds->numRows($result)) { $row = $ds->fetchArray($result); return $row['ICR']; } return null; }
/** * Get the patient merge by date * * @param Date $before before date * @param Date $now now date * * @return array */ static function getPatientMergeByDate($before, $now) { $where = array("date >= '{$before} 00:00:00'", "date <= '{$now} 23:59:59'", "type = 'merge'", "object_class = 'CPatient'"); $ds = CSQLDataSource::get("std"); $ds->exec("SET SESSION group_concat_max_len = 100000;"); $request = new CRequest(); $request->addSelect("DATE(date) AS 'date', COUNT(*) AS 'total', GROUP_CONCAT( object_id SEPARATOR '-') as ids"); $request->addTable("user_log"); $request->addWhere($where); $request->addGroup("DATE(date)"); return $ds->loadList($request->makeSelect()); }
static function insert($value) { $ds = CSQLDataSource::get("std"); if (!$ds) { throw new Exception("No datasource available"); } $query = "INSERT INTO `error_log_data` (`value`, `value_hash`)\n VALUES (?1, ?2)\n ON DUPLICATE KEY UPDATE `error_log_data_id` = LAST_INSERT_ID(`error_log_data_id`)"; $query = $ds->prepare($query, $value, md5($value)); if (!@$ds->exec($query)) { throw new Exception("Exec failed"); } return $ds->insertId(); }
/** * Delete content and update exchange * * @param CContentTabular $content_tabular Content tabular * @param int $type_content_id Content ID * @param date $date_max Date max * @param int $max Max exchange * * @return int */ function deleteContentAndUpdateExchange(CContentTabular $content_tabular, $type_content_id, $date_max, $max) { $ds = $content_tabular->_spec->ds; // Récupère les content Tabulé $query = "SELECT cx.content_id\r\n FROM content_tabular AS cx, exchange_hl7v2 AS ec\r\n WHERE ec.`date_production` < '{$date_max}'\r\n AND ec.{$type_content_id} = cx.content_id\r\n LIMIT {$max};"; $ids = CMbArray::pluck($ds->loadList($query), "content_id"); // Suppression du contenu Tabulé $query = "DELETE FROM content_tabular\r\n WHERE content_id " . CSQLDataSource::prepareIn($ids); $ds->exec($query); // Mise à jour des échanges $query = "UPDATE exchange_hl7v2\r\n SET `{$type_content_id}` = NULL \r\n WHERE `{$type_content_id}` " . CSQLDataSource::prepareIn($ids); $ds->exec($query); $count = $ds->affectedRows(); return $count; }
/** * Removes a module * Warning, it actually breaks module dependency * * @return boolean Job done */ function remove() { if ($this->mod_type == "core") { CAppUI::setMsg("Impossible de supprimer le module '%s'", UI_MSG_ERROR, $this->mod_name); return false; } $success = true; foreach ($this->tables as $table) { $query = "DROP TABLE `{$table}`"; if (!$this->ds->exec($query)) { $success = false; CAppUI::setMsg("Failed to remove table '%s'", UI_MSG_ERROR, $table); } } return $success; }
/** * Build an SQL query to replace a template string * Will check over content_html table to specify update query * * @param string $search text to search * @param string $replace text to replace * @param bool $force_content_table Update content_html or compte_rendu table [optional] * * @return string The sql query */ static function replaceTemplateQuery($search, $replace, $force_content_table = false) { static $_compte_rendu = null; static $_compte_rendu_content_id = null; $search = htmlentities($search); $replace = htmlentities($replace); $ds = CSQLDataSource::get("std"); if ($_compte_rendu === null || $_compte_rendu_content_id === null) { $_compte_rendu = $ds->loadTable("compte_rendu") != null; $_compte_rendu_content_id = $_compte_rendu && $ds->loadField("compte_rendu", "content_id"); } // Content specific table if ($force_content_table || $_compte_rendu && $_compte_rendu_content_id) { return "UPDATE compte_rendu AS cr, content_html AS ch\r\n SET ch.content = REPLACE(`content`, '{$search}', '{$replace}')\r\n WHERE cr.object_id IS NULL\r\n AND cr.content_id = ch.content_id"; } // Single table return "UPDATE `compte_rendu` \r\n SET `source` = REPLACE(`source`, '{$search}', '{$replace}') \r\n WHERE `object_id` IS NULL"; }
/** * count list of Op not linked to a plage * * @param date $start date de début * @param date|null $end date de fin * @param array $chir_ids chir targeted * * @return int number of HP found */ static function countForDates($start, $end = null, $chir_ids = array()) { $d_start = $start; $d_end = $end ? $end : $start; $op = new COperation(); $ljoin = array(); $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id"; $where = array(); if (count($chir_ids)) { $where["chir_id"] = CSQLDataSource::prepareIn($chir_ids); } $where["operations.plageop_id"] = "IS NULL"; $where["operations.date"] = "BETWEEN '{$d_start}' AND '{$d_end}'"; $where["operations.annulee"] = "= '0'"; $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; /** @var COperation[] $listHorsPlage */ return $op->countList($where, null, $ljoin); }
static function loadAllFor($libelles) { $libelles = array_map("strtoupper", $libelles); // Initialisation du tableau $colors_by_libelle = array(); foreach ($libelles as $_libelle) { $color = new self(); $color->libelle = $_libelle; $colors_by_libelle[$_libelle] = $color; } $color = new self(); $where = array(); $libelles = array_map("addslashes", $libelles); $where["libelle"] = CSQLDataSource::prepareIn($libelles); foreach ($color->loadList($where) as $_color) { $colors_by_libelle[$_color->libelle] = $_color; } return $colors_by_libelle; }
/** * Fonction de construction du cache d'info des durées * d'hospi et d'interv * * @param string $tableName Nom de la table de cache * @param string $tableFields Champs de la table de cache * @param array $queryFields Liste des champs du select * @param string $querySelect Chaine contenant les éléments SELECT à utiliser * @param array $queryWhere Chaine contenant les éléments WHERE à utiliser * * @return void */ function buildPartialTables($tableName, $tableFields, $queryFields, $querySelect, $queryWhere) { $ds = CSQLDataSource::get("std"); $joinedFields = join(", ", $queryFields); // Intervale de temps $intervalle = CValue::get("intervalle"); switch ($intervalle) { case "month": $deb = CMbDT::date("-1 month"); break; case "6month": $deb = CMbDT::date("-6 month"); break; case "year": $deb = CMbDT::date("-1 year"); break; default: $deb = CMbDT::date("-10 year"); } $fin = CMbDT::date(); // Suppression si existe $drop = "DROP TABLE IF EXISTS `{$tableName}`"; $ds->exec($drop); // Création de la table partielle $create = "CREATE TABLE `{$tableName}` (" . "\n`chir_id` int(11) unsigned NOT NULL default '0'," . "{$tableFields}" . "\n`ccam` varchar(255) NOT NULL default ''," . "\nKEY `chir_id` (`chir_id`)," . "\nKEY `ccam` (`ccam`)" . "\n) /*! ENGINE=MyISAM */;"; $ds->exec($create); // Remplissage de la table partielle $query = "INSERT INTO `{$tableName}` ({$joinedFields}, `chir_id`, `ccam`)\r\n SELECT {$querySelect}\r\n operations.chir_id,\r\n operations.codes_ccam AS ccam\r\n FROM operations\r\n LEFT JOIN users\r\n ON operations.chir_id = users.user_id\r\n LEFT JOIN plagesop\r\n ON operations.plageop_id = plagesop.plageop_id\r\n WHERE operations.annulee = '0'\r\n {$queryWhere}\r\n AND operations.date BETWEEN '{$deb}' AND '{$fin}'\r\n GROUP BY operations.chir_id, ccam\r\n ORDER BY ccam;"; $ds->exec($query); CAppUI::stepAjax("Nombre de valeurs pour la table '{$tableName}': " . $ds->affectedRows(), UI_MSG_OK); // Insert dans la table principale si vide if (!$ds->loadResult("SELECT COUNT(*) FROM temps_op")) { $query = "INSERT INTO temps_op ({$joinedFields}, `chir_id`, `ccam`)\r\n SELECT {$joinedFields}, `chir_id`, `ccam`\r\n FROM {$tableName}"; $ds->exec($query); } else { $query = "UPDATE temps_op, {$tableName} SET "; foreach ($queryFields as $queryField) { $query .= "\ntemps_op.{$queryField} = {$tableName}.{$queryField}, "; } $query .= "temps_op.chir_id = {$tableName}.chir_id" . "\nWHERE temps_op.chir_id = {$tableName}.chir_id" . "\nAND temps_op.ccam = {$tableName}.ccam"; $ds->exec($query); } }
/** * Parse le fichier et remplit la table correspondante * * @param string $file File path * @param string $table Table name * * @return void */ function addFileIntoDB($file, $table) { $reussi = 0; $echoue = 0; $ds = CSQLDataSource::get("cdarr"); $handle = fopen($file, "r"); // Ne pas utiliser fgetcsv, qui refuse de prendre en compte les caractères en majusucules accentués (et d'autres caractères spéciaux) while ($line = fgets($handle)) { $line = str_replace("'", "\\'", $line); $datas = explode("|", $line); $query = "INSERT INTO {$table} VALUES('" . implode("','", $datas) . "')"; $ds->exec($query); if ($msg = $ds->error()) { $echoue++; } else { $reussi++; } } fclose($handle); CAppUI::stepAjax("ssr-import-cdarr-report", UI_MSG_OK, $file, $table, $reussi, $echoue); }
function addFileIntoDB($file, $table) { $reussi = 0; $echoue = 0; $ds = CSQLDataSource::get("ccamV2"); $handle = fopen($file, "r"); $values = array(); $batch = 50; // Ne pas utiliser fgetcsv, qui refuse de prendre en compte les caractères en majusucules accentués (et d'autres caractères spéciaux) while ($line = fgets($handle)) { $line = str_replace("'", "\\'", $line); $values[] = explode("|", $line); if (count($values) == $batch) { insertValues($ds, $table, $values, $echoue, $reussi); $values = array(); } } if (count($values)) { insertValues($ds, $table, $values, $echoue, $reussi); } CAppUI::stepAjax("Import du fichier {$file} dans la table {$table} : {$reussi} lignes ajoutée(s), {$echoue} échouée(s)", UI_MSG_OK); fclose($handle); }
* $Id$ * * @package Mediboard * @subpackage dPfacturation * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $out = fopen('php://output', 'w'); header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="ExportCompta.xls"'); $facture_class = CValue::get("facture_class", 'CFactureEtablissement'); $factures_id = CValue::get("factures", array()); $factures_id = explode("|", $factures_id); $where = array(); $where["facture_id"] = CSQLDataSource::prepareIn(array_values($factures_id)); $facture = new $facture_class(); $factures = $facture->loadList($where); // Ligne d'entête $fields = array(); $fields[] = "Date"; $fields[] = "Facture"; $fields[] = "Patient"; $fields[] = "Montant"; fputcsv($out, $fields, ';'); foreach ($factures as $_facture) { /* @var CFactureEtablissement $_facture*/ $_facture->loadRefPatient(); $_facture->loadRefsObjects(); $_facture->loadRefsReglements(); $fields = array();
$fin = CValue::get("fin", CMbDT::date()); $prat_id = CValue::get("prat_id", 0); $service_id = CValue::get("service_id", 0); $pratSel = new CMediusers(); $pratSel->load($prat_id); $service = new CSalle(); $service->load($service_id); $datax = array(); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $datax[] = CMbDT::transform("+0 DAY", $i, "%m/%Y"); } $sql = "SELECT * FROM service WHERE"; if ($service_id) { $sql .= "\nAND id = '{$service_id}'"; } $ds = CSQLDataSource::get("std"); $services = $ds->loadlist($sql); $opbysalle = array(); foreach ($services as $service) { $id = $service["service_id"]; $opbysalle[$id]["nom"] = $salle["nom"]; $sql = "SELECT COUNT(sejour.sejour_id) AS total," . "\nDATE_FORMAT(sejour.entree_prevue, '%m/%Y') AS mois," . "\nDATE_FORMAT(sejour.entre_prevue, '%Y%m') AS orderitem," . "\nservice.nom AS nom" . "\nFROM sejour, affectation, services, chambre, lit" . "\nWHERE sejour.annule = '0'" . "\nAND sejour.entree_prevue BETWEEN '{$debut}' AND '{$fin}'"; if ($prat_id) { $sql .= "\nAND sejour.praticien_id = '{$prat_id}'"; } $sql .= "\nAND service.service_id = chambre.service_id" . "\nAND chambre.chambre_id = lit.chambre_id" . "\nAND lit.affectation_id = affectation.affectation_id" . "\nAND affectation.sejour_id = sejour.sejour_id" . "\nAND service.service_id = '{$id}'" . "\nGROUP BY mois" . "\nORDER BY orderitem"; $result = $ds->loadlist($sql); foreach ($datax as $x) { $f = true; foreach ($result as $totaux) { if ($x == $totaux["mois"]) {
$quotas = $function->quotas; } $listPrat = CConsultation::loadPraticiens(PERM_EDIT, $user->function_id, null, true); $listAllPrat = CConsultation::loadPraticiens(null, null, null, true); $where = array(); $where["date"] = $ds->prepare("BETWEEN %1 AND %2", "{$plage->date}", "{$plage->date}"); $where[] = "libelle != 'automatique' OR libelle IS NULL"; $where["chir_id"] = " = '{$user->_id}'"; if ($display_nb_consult == "cab" || $display_nb_consult == "etab") { $where["chir_id"] = CSQLDataSource::prepareIn(array_keys($listPrat)); /** @var CPlageconsult[] $plages_func */ $plages_func = $plage->loadList($where); $utilisation_func = utilisation_rdv($plages_func, $listPlace, $plage); } if ($display_nb_consult == "etab") { $where["chir_id"] = CSQLDataSource::prepareIn(array_keys($listAllPrat)); /** @var CPlageconsult[] $plages_etab */ $plages_etab = $plage->loadList($where); $utilisation_etab = utilisation_rdv($plages_etab, $listPlace, $plage); } // next consult $next_plage = $plage->getNextPlage(); // previous consult $previous_plage = $plage->getPreviousPlage(); } // user's function available $mediuser = new CMediusers(); $mediusers = $mediuser->loadProfessionnelDeSanteByPref(PERM_READ, $function_id); // Vérifier le droit d'écriture sur la plage sélectionnée $plage->canDo(); // Création du template
/** * dPbloc * * @category Bloc * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $date = CValue::get("date"); $bloc_id = CValue::get("bloc_id"); $bloc = new CBlocOperatoire(); $bloc->load($bloc_id); $in_salles = CSQLDataSource::prepareIn($bloc->loadBackIds("salles")); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $where[] = "operations.salle_id {$in_salles} OR plagesop.salle_id {$in_salles}"; $where[] = "operations.date = '{$date}'"; $where["labo"] = "= 1"; $order = "entree_salle, time_operation"; $operation = new COperation(); /** @var COperation[] $operations */ $operations = $operation->loadList($where, $order, null, null, $ljoin); CMbObject::massLoadFwdRef($operations, "plageop_id"); $chirs = CMbObject::massLoadFwdRef($operations, "chir_id"); CMbObject::massLoadFwdRef($chirs, "function_id"); $sejours = CMbObject::massLoadFwdRef($operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($operations as $_operation) { $_operation->loadRefPatient();
$whereFavoris["function_id"] = " IS NULL"; $whereFavoris["group_id"] = " IS NULL"; $whereFavoris["user_id"] = "= '{$user->_id}'"; $tab_favoris_user = $favoris->loadList($whereFavoris); unset($whereFavoris["user_id"]); $function_id = $user->loadRefFunction()->_id; $whereFavoris["function_id"] = " = '{$function_id}'"; $tab_favoris_function = $favoris->loadList($whereFavoris); unset($whereFavoris["function_id"]); $group_id = $user->loadRefFunction()->group_id; $whereFavoris["group_id"] = " = '{$group_id}'"; $tab_favoris_group = $favoris->loadList($whereFavoris); $tab_favoris = $tab_favoris_user + $tab_favoris_function + $tab_favoris_group; } // récupération des favoris sans cibles avec search_auto à "oui" $whereFavorisSansCibles["contextes"] = CSQLDataSource::prepareIn(array("generique", $contexte)); $whereFavorisSansCibles["function_id"] = " IS NULL"; $whereFavorisSansCibles["group_id"] = " IS NULL"; $whereFavorisSansCibles["user_id"] = "= '{$user->_id}'"; $whereFavorisSansCibles["search_auto"] = " LIKE '1'"; $tab_favoris_user_sans_cibles = $favoris_sans_cibles->loadList($whereFavorisSansCibles); unset($whereFavorisSansCibles["user_id"]); $function_id = $user->loadRefFunction()->_id; $whereFavoris["function_id"] = " = '{$function_id}'"; $tab_favoris_function_sans_cibles = $favoris_sans_cibles->loadList($whereFavorisSansCibles); unset($whereFavorisSansCibles["function_id"]); $group_id = $user->loadRefFunction()->group_id; $whereFavorisSansCibles["group_id"] = " = '{$group_id}'"; $tab_favoris_group_sans_cibles = $favoris->loadList($whereFavorisSansCibles); $tab_favoris += $tab_favoris_user_sans_cibles + $tab_favoris_function_sans_cibles + $tab_favoris_group_sans_cibles; }
<?php /** * $Id: httpreq_do_add_insee.php 19219 2013-05-21 12:26:07Z phenxdesign $ * * @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 19219 $ */ CCanDo::checkAdmin(); $sourcePath = "modules/dPpatients/INSEE/insee.tar.gz"; $targetDir = "tmp/insee"; $targetPath = "tmp/insee/insee.sql"; // Extract the SQL dump if (null == ($nbFiles = CMbPath::extract($sourcePath, $targetDir))) { CAppUI::stepAjax("Erreur, impossible d'extraire l'archive", UI_MSG_ERROR); } CAppUI::stepAjax("Extraction de {$nbFiles} fichier(s)", UI_MSG_OK); $ds = CSQLDataSource::get("INSEE"); if (null == ($lineCount = $ds->queryDump($targetPath, true))) { $msg = $ds->error(); CAppUI::stepAjax("Erreur de requête SQL: {$msg}", UI_MSG_ERROR); } CAppUI::stepAjax("import effectué avec succès de {$lineCount} lignes", UI_MSG_OK);
$where = array(); // Filtre sur les dates $where["reglement.date"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max} 23:59:59'"; // Filtre sur les modes de paiement if ($filter->_mode_reglement) { $where["reglement.mode"] = "= '{$filter->_mode_reglement}'"; } // Filtre sur les praticiens $chir_id = CValue::getOrSession("chir"); $listPrat = CConsultation::loadPraticiensCompta($chir_id); // Chargement des règlements via les factures $ljoin["facture_cabinet"] = "reglement.object_id = facture_cabinet.facture_id"; if (!$all_group_compta) { $where["facture_cabinet.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; } $where["facture_cabinet.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat)); $where["reglement.object_class"] = " = 'CFactureCabinet'"; $reglement = new CReglement(); /** @var CReglement[] $reglements */ $reglements = $reglement->loadList($where, " facture_cabinet.facture_id, reglement.date", null, null, $ljoin); $reglement = new CReglement(); // Calcul du récapitulatif // Initialisation du tableau de reglements $recapReglement["total"] = array("nb_consultations" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "secteur1" => "0", "secteur2" => "0", "secteur3" => "0", "du_tva" => "0"); foreach (array_merge($reglement->_specs["mode"]->_list, array("")) as $_mode) { $recapReglement[$_mode] = array("du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0"); } $listReglements = array(); $listConsults = array(); $factures = CStoredObject::massLoadFwdRef($reglements, "object_id"); $patients = CStoredObject::massLoadFwdRef($factures, "patient_id");
* @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 19285 $ */ CCanDo::checkRead(); $user = CMediusers::get(); // Chargement des fontions $function = new CFunctions(); $listFunctions = $function->loadListWithPerms(PERM_EDIT); // Chargement du pack demandé $pack = new CPackExamensLabo(); $pack->load(CValue::getOrSession("pack_examens_labo_id")); if ($pack->_id && $pack->getPerm(PERM_EDIT)) { $pack->loadRefs(); } else { $pack = new CPackExamensLabo(); } //Chargement de tous les packs $where = array("function_id IS NULL OR function_id " . CSQLDataSource::prepareIn(array_keys($listFunctions))); $where["obsolete"] = " = '0'"; $order = "libelle"; $listPacks = $pack->loadList($where, $order); foreach ($listPacks as $key => $curr_pack) { $listPacks[$key]->loadRefs(); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("listFunctions", $listFunctions); $smarty->assign("listPacks", $listPacks); $smarty->assign("pack", $pack); $smarty->display("vw_edit_packs.tpl");
function countMatchingPatients() { $ds = CSQLDataSource::get("std"); $res = $ds->query("SELECT COUNT(*) AS total,\r\n CONVERT( GROUP_CONCAT(`patient_id` SEPARATOR '|') USING latin1 ) AS ids ,\r\n LOWER( CONCAT_WS( '-',\r\n REPLACE( REPLACE( REPLACE( REPLACE( `nom` , '\\\\', '' ) , \"'\", '' ) , '-', '' ) , ' ', '' ) ,\r\n REPLACE( REPLACE( REPLACE( REPLACE( `prenom` , '\\\\', '' ) , \"'\", '' ) , '-', '' ) , ' ', '' ) ,\r\n `naissance`\r\n , QUOTE( REPLACE( REPLACE( REPLACE( REPLACE( `nom_jeune_fille` , '\\\\', '' ) , \"'\", '' ) , '-', '' ) , ' ', '' ) )\r\n , QUOTE( REPLACE( REPLACE( REPLACE( REPLACE( `prenom_2` , '\\\\', '' ) , \"'\", '' ) , '-', '' ) , ' ', '' ) )\r\n , QUOTE( REPLACE( REPLACE( REPLACE( REPLACE( `prenom_3` , '\\\\', '' ) , \"'\", '' ) , '-', '' ) , ' ', '' ) )\r\n , QUOTE( REPLACE( REPLACE( REPLACE( REPLACE( `prenom_4` , '\\\\', '' ) , \"'\", '' ) , '-', '' ) , ' ', '' ) )\r\n )) AS hash\r\n FROM `patients`\r\n GROUP BY hash\r\n HAVING total > 1"); return intval($ds->numRows($res)); }
static function loadValuesFromDB() { global $dPconfig; $ds = CSQLDataSource::get("std"); $request = "SELECT * FROM config_db WHERE config_db.key " . CSQLDataSource::prepareNotIn(self::$forbidden_values); $configs = $ds->loadList($request); foreach ($configs as $_value) { CMbConfig::loadConf(explode(" ", $_value['key']), $_value['value'], $dPconfig); } // Réinclusion du config_overload if (is_file(__DIR__ . "/config_overload.php")) { include __DIR__ . "/config_overload.php"; } }