コード例 #1
0
 function query($query)
 {
     $stid = oci_parse($this->link, $query);
     if (!oci_execute($stid)) {
         mbLog($query);
     }
     if (CSQLDataSource::$trace) {
         $this->_queries[$stid] = $query;
     }
     return $stid;
 }
コード例 #2
0
ファイル: do_multirequest.php プロジェクト: fbone/mediboard4
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
// for now
$data = CValue::post("data");
$data = stripslashes($data);
mbLog(json_decode($data, true));
コード例 #3
0
ファイル: vw_search_auto.php プロジェクト: fbone/mediboard4
    $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;
}
// On effectue la recherche automatique
if (isset($tab_favoris)) {
    try {
        $search = new CSearch();
        $results = $search->searchAuto($tab_favoris, $_ref_object);
    } catch (Exception $e) {
        CAppUI::displayAjaxMsg("search-not-connected", UI_MSG_ERROR);
        mbLog($e->getMessage());
    }
}
// Récupération des rss items pour le marquage pmsi (preuves de recherche PMSI)
$rss_items = array();
$items = array();
if ($contexte == "pmsi" && CModule::getActive("atih")) {
    $rss = new CRSS();
    $rss->sejour_id = $sejour_id;
    $rss->loadMatchingObject();
    $rss_items = $rss->loadRefsSearchItems();
    foreach ($rss_items as $_items) {
        $items[] = $_items->search_class . "-" . $_items->search_id;
    }
}
$smarty = new CSmartyDP();
コード例 #4
0
 /**
  * return an array of objects from an SQL SELECT query
  *
  * @param string $query SQL Query
  *
  * @todo to optimize request, only select object oids in $query
  * @return self[] List of found objects, null if module is not installed
  */
 function loadQueryList($query)
 {
     global $m, $action;
     $ds = $this->_spec->ds;
     // @todo should replace fetchAssoc, instanciation and bind
     // while ($newObject = $ds->fetchObject($res, $this->_class)) {
     $rows = $ds->loadList($query);
     $objects = array();
     foreach ($rows as $_row) {
         /** @var self $newObject */
         $newObject = new $this->_class();
         $newObject->bind($_row, false);
         $newObject->checkConfidential();
         $newObject->updateFormFields();
         $newObject->registerCache();
         // Some external classes do not have primary keys
         if ($newObject->_id) {
             $objects[$newObject->_id] = $newObject;
         } else {
             $objects[] = $newObject;
         }
     }
     if (count($objects) != count($rows)) {
         mbLog($query, "Missing group by in {$m} / {$action} (rows : " . count($rows) . ", objects : " . count($objects) . ")");
     }
     return $objects;
 }
コード例 #5
0
 /**
  * Trace a query chrono
  *
  * @param string $trace Trace label
  *
  * @return void
  */
 static function traceChrono($trace)
 {
     // Allways log slow queries
     $log_step = floor(self::$chrono->latestStep);
     if ($log_step) {
         $query = self::$last_query;
         $values = implode(", ", self::$last_values);
         mbLog("slow '{$trace}' in '{$log_step}' seconds", "CRecordSante400");
         if ($trace != "connection") {
             mbLog("last query was \n {$query} \n with values [{$values}]", "CRecordSante400");
         }
     }
     // Trace to output
     if (self::$verbose) {
         $step = self::$chrono->latestStep * 1000;
         $total = self::$chrono->total * 1000;
         $pace = floor(2 * log10($step));
         $pace = max(0, min(6, $pace));
         $message = "query-pace-{$pace}";
         $type = floor(($pace + 3) / 2);
         CAppUI::stepMessage($type, $message, $trace, $step, $total);
     }
 }
コード例 #6
0
 /**
  * Put logs in buffer and store them.
  * Use direct storage if buffer_life time config is 0
  *
  * @param self[] $logs Log collection to put in buffer
  *
  * @return void
  */
 static function bufferize($logs)
 {
     $class = get_called_class();
     // No buffer use standard unique fast store
     $buffer_lifetime = CAppUI::conf("access_log_buffer_lifetime");
     if (!$buffer_lifetime) {
         if ($msg = static::fastMultiStore($logs)) {
             mbLog("Could not store logs: {$msg}", $class);
             trigger_error($msg, E_USER_WARNING);
         }
         return;
     }
     // Buffer logs into file
     $buffer = CAppUI::getTmpPath("{$class}.buffer");
     foreach ($logs as $_log) {
         file_put_contents($buffer, serialize($_log) . PHP_EOL, FILE_APPEND);
     }
     // Unless lifetime is reached by random, don't unbuffer logs
     if (rand(1, $buffer_lifetime) !== 1) {
         return;
     }
     // Move to temporary buffer to prevent concurrent unbuffering
     $tmpbuffer = tempnam(dirname($buffer), basename($buffer) . ".");
     if (!rename($buffer, $tmpbuffer)) {
         // Keep the log for a while, should not be frequent with buffer lifetime 100+
         mbLog("Probable concurrent logs unbuffering", $class);
         return;
     }
     // Read lines from temporary buffer
     $lines = file($tmpbuffer);
     $buffered_logs = array();
     foreach ($lines as $_line) {
         $buffered_logs[] = unserialize($_line);
     }
     $assembled_logs = static::assembleLogs($buffered_logs);
     if ($msg = static::fastMultiStore($assembled_logs)) {
         trigger_error($msg, E_USER_WARNING);
         return;
     }
     // Remove the useless temporary buffer
     unlink($tmpbuffer);
     $buffered_count = count($buffered_logs);
     $assembled_count = count($assembled_logs);
     mbLog("'{$buffered_count}' logs buffered, '{$assembled_count}' logs assembled", $class);
 }
コード例 #7
0
        $fact->loadRefPatient();
        $fact->loadRefPraticien();
        $fact->loadRefsReglements();
        $fact->isRelancable();
    }
    $journal_pdf->editJournal(false);
    $journal_pdf->type_pdf = "checklist";
    $journal_pdf->definitive = $definitive;
    $journal_pdf->editJournal(false);
    if (!$facture_id) {
        if ($definitive) {
            foreach ($factures as $_facture) {
                if (!$_facture->definitive) {
                    $_facture->definitive = 1;
                    if ($msg = $_facture->store()) {
                        mbLog($msg);
                    }
                }
            }
        }
        unset($_GET["suppressHeaders"]);
    }
}
if ($type_pdf == "relance") {
    $relance = new CRelance();
    $relance->load($relance_id);
    if ($relance->_id) {
        $facture_pdf->factures = array($relance->loadRefFacture());
    }
    $facture_pdf->relance = $relance;
    $facture_pdf->editRelance();
コード例 #8
0
 /**
  * Refresh the data cache
  *
  * @return void
  */
 static function refreshDataCache()
 {
     $mutex = new CMbFileMutex("config-build");
     $mutex->acquire(20);
     // If cache was built by another thread
     if (self::getValuesCacheStatus() === self::STATUS_OK) {
         $mutex->release();
         $hosts_shm = SHM::get("config-values-__HOSTS__");
         $hosts = $hosts_shm["content"];
         $values = array();
         foreach ($hosts as $_host) {
             $_host_value = SHM::get("config-values-{$_host}");
             $values[$_host] = $_host_value["content"];
         }
         self::$values = $values;
         self::$hosts = $hosts;
         self::$dirty = false;
         mbLog("'config-values' already present, skipping regeneration");
         return;
     }
     $t = microtime(true);
     self::buildAllConfig();
     $t1 = microtime(true) - $t;
     $datetime = strftime(CMbDT::ISO_DATETIME);
     foreach (self::$values as $_host => $_configs) {
         SHM::put("config-values-{$_host}", array("date" => $datetime, "content" => $_configs));
     }
     SHM::put("config-values-__HOSTS__", array("date" => $datetime, "content" => array_keys(self::$values)));
     $t2 = microtime(true) - $t - $t1;
     mbLog(sprintf("'config-values' gerenated in %f ms, written in %f ms", $t1 * 1000, $t2 * 1000));
     $mutex->release();
     self::$dirty = false;
 }
コード例 #9
0
ファイル: CCdaTools.class.php プロジェクト: fbone/mediboard4
 /**
  * Valide le CDA
  *
  * @param String $cda                   CDA
  * @param Bool   $schematron_validation Validation par schémtron
  *
  * @throws CMbException
  * @return void
  */
 static function validateCDA($cda, $schematron_validation = true)
 {
     $dom = new CMbXMLDocument("UTF-8");
     $returnErrors = $dom->loadXMLSafe($cda, null, true);
     if ($returnErrors !== true) {
         throw new CMbException("Erreur lors de la conception du document");
     }
     $validateSchematron = null;
     if ($schematron_validation) {
         $returnErrors = $dom->schemaValidate("modules/cda/resources/CDA.xsd", true, false);
         $validateSchematron = self::validateSchematron($cda);
     }
     if ($returnErrors !== true || $validateSchematron) {
         mbLog($returnErrors);
         throw new CMbException("Problème de conformité, vérifiez les informations nécessaires pour le CDA");
     }
 }
コード例 #10
0
ファイル: CReglement.class.php プロジェクト: fbone/mediboard4
 /**
  * Règle les actes ccam lors de l'acquittement
  *
  * @return string|null
  */
 function changeActesCCAM()
 {
     $facture = $this->_ref_facture;
     $actes = array();
     foreach ($facture->loadRefsConsultation() as $consult) {
         /* @var CConsultation $consult*/
         foreach ($consult->loadRefsActesCCAM($facture->numero) as $acte_ccam) {
             $actes[] = $acte_ccam;
         }
     }
     foreach ($facture->loadRefsSejour() as $sejour) {
         /* @var CSejour $sejour*/
         foreach ($sejour->loadRefsOperations() as $op) {
             foreach ($op->loadRefsActesCCAM($facture->numero) as $acte_ccam) {
                 $actes[] = $acte_ccam;
             }
         }
         foreach ($sejour->loadRefsActesCCAM($facture->numero) as $acte_ccam) {
             $actes[] = $acte_ccam;
         }
     }
     $actes_non_regle = array();
     $actes_to_regle = array();
     foreach ($actes as $_acte_ccam) {
         if (!$_acte_ccam->regle && $_acte_ccam->montant_base || !$_acte_ccam->regle_dh && $_acte_ccam->montant_depassement) {
             $actes_non_regle[] = $_acte_ccam;
         } else {
             $actes_to_regle[] = $_acte_ccam;
         }
     }
     //Pour l'acquittement,
     if (!$facture->_du_restant && count($actes_non_regle)) {
         foreach ($actes_non_regle as $_acte_ccam) {
             /* @var CActeCCAM $acte */
             $_acte_ccam->regle = 1;
             $_acte_ccam->regle_dh = 1;
             if ($msg = $_acte_ccam->store()) {
                 mbLog($msg);
             }
         }
     } else {
         if ($facture->_du_restant && count($actes_to_regle)) {
             foreach ($actes_to_regle as $_acte_ccam) {
                 /* @var CActeCCAM $acte */
                 $_acte_ccam->regle = 0;
                 $_acte_ccam->regle_dh = 0;
                 if ($msg = $_acte_ccam->store()) {
                     mbLog($msg);
                 }
             }
         }
     }
 }
コード例 #11
0
        /** @var $_node DOMElement */
        if ($_node->nodeName === "span" && ($_node->getAttribute("class") === "name" || $_node->getAttribute("class") === "field") && $_node->childNodes->length != 1 && $_node->firstChild && ($_node->firstChild->nodeType != XML_TEXT_NODE || !preg_match("/\\[.+\\]/", $_node->nodeValue))) {
            return true;
        }
        if ($_node->childNodes) {
            searchSpan($_node);
        }
    }
    return false;
}
$compte_rendu = new CCompteRendu();
$where = array();
$where["object_id"] = "IS NULL";
$compte_rendus = $compte_rendu->loadList($where, null, "350000");
/** @var  $compte_rendus CCompteRendu[] */
$list = array();
/** @var DOMDocument $xml */
$xml = new DOMDocument('1.0', 'iso-8859-1');
foreach ($compte_rendus as $_compte_rendu) {
    mbLog($_compte_rendu->_id);
    $_compte_rendu->loadContent();
    $content = CMbString::convertHTMLToXMLEntities($_compte_rendu->_source);
    $content = utf8_encode(CHtmlToPDF::cleanWord($content));
    $xml->loadXML("<div>" . $content . "</div>");
    if (searchSpan($xml->documentElement)) {
        $list[] = $_compte_rendu;
    }
}
$smarty = new CSmartyDP();
$smarty->assign("list", $list);
$smarty->display("inc_update_class_fields.tpl");
コード例 #12
0
/**
 * import the patient file
 *
 * @param string   $file        path to the file
 * @param int      $start       start int
 * @param int      $count       number of iterations
 * @param resource $file_import file for report
 *
 * @return null
 */
function importFile($file, $start, $count, $file_import)
{
    $fp = fopen($file, 'r');
    $patient = new CPatient();
    $patient_specs = CModelObjectFieldDescription::getSpecList($patient);
    CModelObjectFieldDescription::addBefore($patient->_specs["_IPP"], $patient_specs);
    /** @var CMbFieldSpec[] $_patient_specs */
    $_patient_specs = CModelObjectFieldDescription::getArray($patient_specs);
    echo count($_patient_specs) . " traits d'import";
    //0 = first line
    if ($start == 0) {
        $start++;
    }
    $line_nb = 0;
    while ($line = fgetcsv($fp, null, ";")) {
        $patient = new CPatient();
        if ($line_nb >= $start && $line_nb < $start + $count) {
            $line_rapport = "ligne {$line_nb} - ";
            //foreach SPECS, first load
            foreach ($_patient_specs as $key => $_specs) {
                $field = $_specs->fieldName;
                $data = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $line[$key]);
                //specific cleanups
                if ($_specs instanceof CPhoneSpec) {
                    $data = preg_replace('/\\D/', '', $data);
                }
                if ($field == "sexe") {
                    $data = strtolower($data);
                }
                if ($field == "deces" && $data == "0000-00-00") {
                    $data = null;
                }
                $patient->{$field} = $data;
            }
            $line_rapport .= "Patient {$patient->nom} {$patient->prenom} ({$patient->naissance})";
            //clone and IPP
            $IPP = $patient->_IPP;
            $patient->_generate_IPP = false;
            $patient_full = new CPatient();
            $patient_full->extendsWith($patient);
            // load by ipp if basic didn't find.
            if (!$patient->_id) {
                $patient->loadFromIPP();
                if ($patient->_id) {
                    $line_rapport .= " (trouvé par IPP)";
                }
            }
            //load patient with basics
            if (!$patient->_id) {
                $patient->_IPP = null;
                $patient->loadMatchingPatient();
                if ($patient->_id) {
                    $line_rapport .= " (trouvé par matching)";
                }
            }
            //update fields if import have more data
            foreach ($patient->getPlainFields() as $field => $value) {
                if (!$patient->{$field}) {
                    $patient->{$field} = $patient_full->{$field};
                }
            }
            // fields created by store, let the store do the job for these
            $patient->civilite = "guess";
            //found
            if ($patient->_id) {
                //check IPP
                $patient->loadIPP();
                //update
                $patient->store();
                if (!$patient->_IPP) {
                    $idex = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP(), $IPP, $patient->_id);
                    $idex->last_update = CMbDT::dateTime();
                    $idex->store();
                    if ($idex->_id) {
                        $line_rapport .= ", IPP créé : {$IPP}";
                    }
                    echo "<tr style=\"color:#c98000\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] déjà existant (MAJ ipp : {$idex->id400})</td></tr>";
                } else {
                    $line_rapport .= " déjà existant";
                    if ($patient->_IPP != $IPP) {
                        mbLog($patient->_view . " [ipp: " . $patient->_IPP . " / ipp_import:" . $IPP);
                        $line_rapport .= " [IPP du fichier: {$IPP} / ipp en base: {$patient->_IPP} ]";
                    }
                    $line_rapport .= " [IPP en base et fichier identiques]";
                    echo "<tr style=\"color:#c98000\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] déjà existant (ipp : {$patient->_IPP})</td></tr>";
                }
            } else {
                $result = $patient->store();
                if (!$result) {
                    $line_rapport .= " créé avec succes";
                    //create IPP
                    $idex = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP(), $IPP, $patient->_id);
                    if ($idex->_id) {
                        $line_rapport .= ", IPP précédente : {$idex->id400}";
                    }
                    $idex->last_update = CMbDT::dateTime();
                    $idex->store();
                    if ($idex->_id) {
                        $line_rapport .= ", IPP enregistrée : {$idex->id400}";
                    }
                    echo "<tr style=\"color:green\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] créé (ipp : {$idex->id400})</td></tr>";
                } else {
                    $patient->repair();
                    $result = $patient->store();
                    $line_rapport .= " réparé et créé";
                    if (!$result) {
                        //create IPP
                        $idex = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP(), $IPP, $patient->_id);
                        if ($idex->_id) {
                            $line_rapport .= ", IPP précédente : {$idex->id400}";
                        }
                        $idex->last_update = CMbDT::dateTime();
                        $idex->store();
                        if ($idex->_id) {
                            $line_rapport .= ", IPP enregistrée : {$idex->id400}";
                        }
                        echo "<tr style=\"color:green\"><td>{$line_nb}</td><td>patient [{$patient->nom} {$patient->prenom}] créé (ipp : {$idex->id400})</td></tr>";
                    } else {
                        $line_rapport .= " non créé : {$result}";
                        mbLog("LINE {$line_nb} : erreur: " . $result);
                        echo "<tr  style=\"color:red\"><td>{$line_nb}</td><td>\n              <div class=\"error\">le patient [{$patient->nom} {$patient->prenom}] n'a pas été créé<br/>\n            erreur: {$result}</div></td></tr>";
                    }
                }
            }
            $line_rapport .= "\n";
            fwrite($file_import, $line_rapport);
        }
        if ($line_nb > $start + $count) {
            break;
        }
        $line_nb++;
    }
}
コード例 #13
0
    CAppUI::displayAjaxMsg("Le serveur de recherche n'est pas connecté", UI_MSG_WARNING);
}
try {
    // récupération des données pour les journaux utilisateurs
    $client_log = new CSearchLog();
    $client_log->createClient();
    $infos_log = $client_log->loadCartoInfos();
} catch (Exception $e) {
    $infos_log = array();
    CAppUI::displayAjaxMsg("Le serveur de recherche de journaux n'est pas connecté", UI_MSG_WARNING);
}
try {
    // récupération des données pour les journaux utilisateurs
    $wrapper = new CSearchFileWrapper(null, null);
    $infos_tika = $wrapper->loadTikaInfos();
} catch (Exception $e) {
    mbLog($e);
    $infos_tika = "";
    CAppUI::displayAjaxMsg("Le serveur d'extraction de fichiers n'est pas connecté", UI_MSG_WARNING);
}
$ds = CSQLDataSource::get("std");
$query = "SELECT MIN(`date`) AS oldest_datetime FROM `search_indexing`";
$result = $ds->exec($query);
$oldest_datetime = $ds->fetchObject($result)->oldest_datetime;
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("infos_index", $infos_index);
$smarty->assign("infos_log", $infos_log);
$smarty->assign("infos_tika", $infos_tika);
$smarty->assign("oldest_datetime", $oldest_datetime);
$smarty->display("vw_cartographie_mapping.tpl");
コード例 #14
0
ファイル: CSearch.class.php プロジェクト: fbone/mediboard4
 /**
  * indexation en bulk avec les données contstruites (avec les fields corrects)
  *
  * @param array $data les data que vous voulez indexer
  *
  * @return bool
  */
 function bulkIndexing($data)
 {
     $data_to_index = $this->constructBulkData($data);
     foreach ($data_to_index as $type_name => $_type) {
         // cas particulier des formulaires
         $typeES = strpos($type_name, 'CExObject') === 0 ? $this->_index->getType("CExObject") : $this->_index->getType($type_name);
         foreach ($_type as $action => $_data) {
             $documents = array();
             foreach ($_data as $_datum) {
                 // cas particulier des formulaires
                 if (strpos($type_name, 'CExObject') === 0) {
                     $_id = $_datum["ex_class_id"] . "_" . $_datum["id"];
                 } else {
                     $_id = $_datum["id"];
                 }
                 $documents[] = new Document($_id, $_datum);
             }
             switch ($action) {
                 case 'create':
                     $typeES->addDocuments($documents);
                     break;
                 case 'store':
                     try {
                         $typeES->updateDocuments($documents);
                     } catch (Exception $e) {
                         try {
                             $typeES->addDocuments($documents);
                         } catch (Exception $e) {
                             mbLog($e->getMessage());
                         }
                     }
                     break;
                 case 'delete':
                     $typeES->deleteDocuments($documents);
                     break;
                 case 'merge':
                     /* supprimer un des deux et faire un update de l'autre.*/
                     break;
                 default:
                     return false;
             }
         }
         // Pour avoir la dernière version de l'index
         $typeES->getIndex()->refresh();
     }
     // Suppression dans la table buffer
     $ids_to_delete = CMbArray::pluck($data, "search_indexing_id");
     $this->deleteDataTemporaryTable($ids_to_delete);
     return true;
 }