Beispiel #1
0
 /**
  * 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;
 }
 /**
  * Launches module upgrade process
  *
  * @param string $oldRevision  Revision before upgrade
  * @param bool   $core_upgrade True if it's a core module upgrade
  *
  * @return string|null New revision, null on error
  */
 function upgrade($oldRevision, $core_upgrade = false)
 {
     /*if (array_key_exists($this->mod_version, $this->queries)) {
         CAppUI::setMsg("Latest revision '%s' should not have upgrade queries", UI_MSG_ERROR, $this->mod_version);
         return;
       }*/
     if (!array_key_exists($oldRevision, $this->queries) && !array_key_exists($oldRevision, $this->config_moves) && !array_key_exists($oldRevision, $this->functions)) {
         CAppUI::setMsg("No queries, functions or config moves for '%s' setup at revision '%s'", UI_MSG_WARNING, $this->mod_name, $oldRevision);
         return null;
     }
     // Point to the current revision
     reset($this->revisions);
     while ($oldRevision != ($currRevision = current($this->revisions))) {
         next($this->revisions);
     }
     $depFailed = false;
     do {
         // Check for dependencies
         foreach ($this->dependencies[$currRevision] as $dependency) {
             $module = @CModule::getInstalled($dependency->module);
             if (!$module || $module->mod_version < $dependency->revision) {
                 $depFailed = true;
                 CAppUI::setMsg("Failed module depency for '%s' at revision '%s'", UI_MSG_WARNING, $dependency->module, $dependency->revision);
             }
         }
         if ($depFailed) {
             return $currRevision;
         }
         // Set Time Limit
         if ($this->timeLimit[$currRevision]) {
             CApp::setTimeLimit($this->timeLimit[$currRevision]);
         }
         // Query upgrading
         foreach ($this->queries[$currRevision] as $_query) {
             list($query, $ignore_errors, $dsn) = $_query;
             $ds = $dsn ? CSQLDataSource::get($dsn) : $this->ds;
             if (!$ds->exec($query)) {
                 if ($ignore_errors) {
                     CAppUI::setMsg("Errors ignored for revision '%s'", UI_MSG_OK, $currRevision);
                     continue;
                 }
                 CAppUI::setMsg("Error in queries for revision '%s': see logs", UI_MSG_ERROR, $currRevision);
                 return $currRevision;
             }
         }
         // Callback upgrading
         foreach ($this->functions[$currRevision] as $function) {
             if (!call_user_func($function)) {
                 $function_name = get_class($function[0]) . "->" . $function[1];
                 CAppUI::setMsg("Error in function '%s' call back for revision '%s': see logs", UI_MSG_ERROR, $function_name, $currRevision);
                 return $currRevision;
             }
         }
         // Preferences
         foreach ($this->preferences[$currRevision] as $_pref) {
             list($_name, $_default, $_restricted) = $_pref;
             // Former pure SQL system
             // Cannot check against module version or fresh install will generate errors
             if (self::isOldPrefSystem($core_upgrade)) {
                 $query = "SELECT * FROM `user_preferences` WHERE `pref_user` = '0' AND `pref_name` = '{$_name}'";
                 $result = $this->ds->exec($query);
                 if (!$this->ds->numRows($result)) {
                     $query = "INSERT INTO `user_preferences` (`pref_user` , `pref_name` , `pref_value`)\n              VALUES ('0', '{$_name}', '{$_default}');";
                     $this->ds->exec($query);
                 }
             } else {
                 $pref = new CPreferences();
                 $where = array();
                 $where["user_id"] = " IS NULL";
                 $where["key"] = " = '{$_name}'";
                 if (!$pref->loadObject($where)) {
                     $pref->key = $_name;
                     $pref->value = $_default;
                     $pref->restricted = $_restricted ? "1" : "0";
                     $pref->store();
                 }
             }
         }
         // Config moves
         if (count($this->config_moves[$currRevision])) {
             foreach ($this->config_moves[$currRevision] as $config) {
                 CAppUI::setConf($config[1], CAppUI::conf($config[0]));
             }
         }
     } while ($currRevision = next($this->revisions));
     return $this->mod_version;
 }
Beispiel #3
0
<?php

/**
 * $Id: import_medecin.php 19280 2013-05-24 16:04:46Z rhum1 $
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19280 $
 */
global $m;
CApp::setTimeLimit(150);
if (!class_exists("DOMDocument")) {
    trigger_error("sorry, DOMDocument is needed");
    return;
}
if (null == ($pass = CValue::get("pass"))) {
    CAppUI::stepAjax("Fonctionnalité désactivée car trop instable.", UI_MSG_WARNING);
    return;
}
if (md5($pass) != "aa450aff6d0f4974711ff4c5536ed4cb") {
    CAppUI::stepAjax("Mot de passe incorrect.\nAttention, fonctionnalité à utiliser avec une extrême prudence", UI_MSG_ERROR);
}
// Chrono start
$chrono = new Chronometer();
$chrono->start();
$segment = CValue::get("segment", 1000);
$step = CValue::get("step", 1);
$from = $step > 1 ? 100 + $segment * ($step - 2) : 0;
$to = $step > 1 ? 100 + ($step - 1) * $segment : 100;
<?php

/**
 * $Id: offline_prescriptions_multipart.php 27852 2015-04-03 09:55:15Z alexis_granger $
 *
 * @package    Mediboard
 * @subpackage Soins
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 27852 $
 */
ob_clean();
CApp::setMemoryLimit("1024M");
CApp::setTimeLimit(240);
$service_id = CValue::get("service_id");
$date = CValue::get("date", CMbDT::date());
$service = new CService();
$service->load($service_id);
$datetime_min = "{$date} 00:00:00";
$datetime_max = "{$date} 23:59:59";
$datetime_avg = "{$date} " . CMbDT::time();
$sejour = new CSejour();
$where = array();
$ljoin = array();
$ljoin["affectation"] = "sejour.sejour_id = affectation.sejour_id";
$where["sejour.entree"] = "<= '{$datetime_max}'";
$where["sejour.sortie"] = " >= '{$datetime_min}'";
$where["affectation.entree"] = "<= '{$datetime_max}'";
$where["affectation.sortie"] = ">= '{$datetime_min}'";
$where["affectation.service_id"] = " = '{$service_id}'";
/** @var CSejour[] $sejours */
Beispiel #5
0
 /**
  * Add a group_id to all the ex_objects
  *
  * @return bool
  */
 protected function addExObjectGroupId()
 {
     CApp::setTimeLimit(1800);
     $ds = $this->ds;
     // Changement des ExClasses
     $query = "SELECT ex_class_id, host_class FROM ex_class";
     $list_ex_class = $ds->loadHashAssoc($query);
     foreach ($list_ex_class as $key => $hash) {
         $query = "ALTER TABLE `ex_object_{$key}`\r\n      ADD `group_id` INT (11) UNSIGNED NOT NULL AFTER `ex_object_id`";
         $ds->exec($query);
         $field_class = null;
         $field_id = null;
         switch ($hash["host_class"]) {
             default:
             case "CMbObject":
                 break;
             case "CPrescriptionLineElement":
             case "CPrescriptionLineMedicament":
             case "COperation":
             case "CConsultation":
             case "CConsultAnesth":
             case "CAdministration":
                 $field_class = "reference_class";
                 $field_id = "reference_id";
                 break;
             case "CSejour":
                 $field_class = "object_class";
                 $field_id = "object_id";
         }
         if ($field_class && $field_id) {
             $query = "UPDATE `ex_object_{$key}`\r\n            LEFT JOIN `sejour` ON `ex_object_{$key}`.`{$field_id}`    = `sejour`.`sejour_id` AND\r\n                  `ex_object_{$key}`.`{$field_class}` = 'CSejour'\r\n            SET `ex_object_{$key}`.`group_id` = `sejour`.`group_id`";
             $ds->exec($query);
         }
     }
     return true;
 }
 * @package    Mediboard
 * @subpackage dPpatients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GPLv2
 * @version    $Revision: 4983 $
 */
CCanDo::checkAdmin();
ini_set("auto_detect_line_endings", true);
global $dPconfig;
$dPconfig["object_handlers"] = array();
CAppUI::stepAjax("Désactivation du gestionnaire", UI_MSG_OK);
$start = CValue::post("start");
$count = CValue::post("count");
$callback = CValue::post("callback");
$date = CMbDT::date();
CApp::setTimeLimit(600);
CApp::setMemoryLimit("512M");
CMbObject::$useObjectCache = false;
$file_import = fopen(CAppUI::conf("root_dir") . "/tmp/rapport_import_patient_{$date}.txt", "a");
importFile(CAppUI::conf("dPpatients imports pat_csv_path"), $start, $count, $file_import);
fclose($file_import);
$start += $count;
file_put_contents(CAppUI::conf("root_dir") . "/tmp/import_patient.txt", "{$start};{$count}");
if ($callback) {
    CAppUI::js("{$callback}({$start},{$count})");
}
echo "<tr><td colspan=\"2\">MEMORY: " . memory_get_peak_usage(true) / (1024 * 1024) . " MB" . "</td>";
CMbObject::$useObjectCache = true;
CApp::rip();
/**
 * import the patient file
<?php

/**
 * dPccam
 *
 * @category Ccam
 * @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::checkAdmin();
CApp::setTimeLimit(360);
$sourcePath = "modules/dPccam/base/ccam.tar.gz";
$targetDir = "tmp/ccam";
$targetTables = "tmp/ccam/tables.sql";
$targetBaseDatas = "tmp/ccam/basedata.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("ccamV2");
// Création des tables
if (null == ($lineCount = $ds->queryDump($targetTables, true))) {
    $msg = $ds->error();
    CAppUI::stepAjax("Import des tables - erreur de requête SQL: {$msg}", UI_MSG_ERROR);
}
CAppUI::stepAjax("Création de {$lineCount} tables", UI_MSG_OK);
// Ajout des données de base
// Bornes
if ($export_id_min = $sip_config["export_id_min"]) {
    $where[] = $patient->_spec->key . " >= '{$export_id_min}'";
}
if ($export_id_max = $sip_config["export_id_max"]) {
    $where[] = $patient->_spec->key . " <= '{$export_id_max}'";
}
// Comptage
$count = $patient->countList($where);
$max = $sip_config["export_segment"];
$max = min($max, $count);
CAppUI::stepAjax("Export de {$max} sur {$count} objets de type 'CPatient' à partir de l'ID '{$idMin}'", UI_MSG_OK);
// Time limit
$seconds = max($max / 20, 120);
CAppUI::stepAjax("Limite de temps du script positionné à '{$seconds}' secondes", UI_MSG_OK);
CApp::setTimeLimit($seconds);
// Export réel
$errors = 0;
$patients = $patient->loadList($where, $patient->_spec->key, "0, {$max}");
$echange = 0;
foreach ($patients as $patient) {
    $patient->loadIPP();
    $patient->loadRefsSejours();
    $patient->_ref_last_log->type = "create";
    $receiver = new CDestinataireHprim();
    $receiver->load(CAppUI::conf("sip export_dest"));
    $receiver->loadConfigValues();
    if (!$patient->_IPP) {
        $IPP = new CIdSante400();
        //Paramétrage de l'id 400
        $IPP->object_class = "CPatient";
/**
 * Catalogue import
 */
function importCatalogue($cat, $parent_id = null)
{
    global $remote_name;
    CApp::setTimeLimit(180);
    // On rend toutes les analyses du catalogue obsoletes
    $idAnalyse = new CIdSante400();
    $idAnalyse->tag = $remote_name;
    $idAnalyse->object_class = "CExamenLabo";
    $idAnalyses = $idAnalyse->loadMatchingList();
    foreach ($idAnalyses as $_id_analyse) {
        $examenLabo = new CExamenLabo();
        $examenLabo->identifiant = $_id_analyse->id400;
        $examenLabo->loadMatchingObject();
        if ($examenLabo->_id) {
            $examenLabo->obsolete = 1;
            $examenLabo->store();
        }
    }
    $idCatalogue = new CIdSante400();
    $idCatalogue->tag = $remote_name;
    $idCatalogue->object_class = "CCatalogueLabo";
    $idCatalogues = $idCatalogue->loadMatchingList();
    foreach ($idCatalogues as $_id_catalogue) {
        $catalogueLabo = new CCatalogueLabo();
        $catalogueLabo->identifiant = $_id_catalogue->id400;
        $catalogueLabo->loadMatchingObject();
        if ($catalogueLabo->_id) {
            $catalogueLabo->obsolete = 1;
            $catalogueLabo->store();
        }
    }
    $compteur["analyses"] = 0;
    $compteur["chapitres"] = 0;
    $compteur["sousChapitre"] = 0;
    $catalogues = array();
    // Creation du catalogue global LABO
    $catal = new CCatalogueLabo();
    $catalogue = new CCatalogueLabo();
    $catal->identifiant = substr(hash('md5', $remote_name), 0, 4);
    // libelle modifié par hash
    $catal->libelle = $remote_name;
    $catal->pere_id = $parent_id;
    // creation de son id400
    $idCat = new CIdSante400();
    $idCat->tag = $remote_name;
    $idCat->id400 = $remote_name;
    $catal->obsolete = 0;
    $idCat->bindObject($catal);
    //CAppUI::stepAjax("Catalogue '$catal->libelle' importé", UI_MSG_OK);
    $path = $remote_name;
    // on met a jour $catalogues
    $catalogues[$path] = $catal;
    //Parcours des analyses
    foreach ($cat->analyse as $_analyse) {
        $chapitre = (string) $_analyse->chapitre;
        $path = "{$remote_name}/{$chapitre}/";
        if (!$chapitre) {
            $path = $remote_name;
        }
        $catChapitre = new CCatalogueLabo();
        // si le catalogue n'existe pas deja
        if (!array_key_exists($path, $catalogues)) {
            // creation du catalogue
            $catChapitre->identifiant = substr(hash('md5', $chapitre), 0, 4);
            // libelle modifié par hash;
            $catChapitre->libelle = $chapitre;
            $catChapitre->pere_id = $catal->_id;
            $catChapitre->decodeUtfStrings();
            //creation de l'id400
            $idCatChapitre = new CIdSante400();
            $idCatChapitre->tag = $remote_name;
            $idCatChapitre->id400 = substr(hash('md5', $chapitre), 0, 4);
            $catChapitre->obsolete = 0;
            $idCatChapitre->bindObject($catChapitre);
            //CAppUI::stepAjax("Catalogue '$catChapitre->libelle' importé", UI_MSG_OK);
            $compteur["chapitres"]++;
            // on met a jour $catalogues
            $catalogues[$path] = $catChapitre;
        }
        $catChapitre = $catalogues[$path];
        $catalogue = $catChapitre;
        // si il y a un sous chapitre a creer==> le pere du sous chapitre est $catalogue->_id;
        $sschapitre = (string) $_analyse->sschapitre;
        if ($sschapitre) {
            // modification du path
            $path .= $sschapitre;
            $catssChapitre = new CCatalogueLabo();
            if (!array_key_exists($path, $catalogues)) {
                // creation du catalogue
                $catssChapitre->identifiant = substr(hash('md5', $sschapitre), 0, 4);
                // libelle modifié par hash;
                $catssChapitre->libelle = $sschapitre;
                $catssChapitre->pere_id = $catChapitre->_id;
                $catssChapitre->decodeUtfStrings();
                //creation de l'id400
                $idCatssChapitre = new CIdSante400();
                $idCatssChapitre->tag = $remote_name;
                $idCatssChapitre->id400 = substr(hash('md5', $sschapitre), 0, 4);
                $catssChapitre->obsolete = 0;
                $idCatssChapitre->bindObject($catssChapitre);
                //CAppUI::stepAjax("Sous Catalogue '$catssChapitre->libelle' importé", UI_MSG_OK);
                $compteur["sousChapitre"]++;
                //on met à jour les catalogues
                $catalogues[$path] = $catssChapitre;
            }
            $catssChapitre = $catalogues[$path];
            $catalogue = $catssChapitre;
        }
        // Code de l'analyse
        $catAtt = $_analyse->attributes();
        $code = $catAtt["code"];
        $idAnalyse = new CIdSante400();
        $idAnalyse->tag = $remote_name;
        $idAnalyse->id400 = (string) $code;
        $analyse = new CExamenLabo();
        $analyse->identifiant = (string) $code;
        $analyse->libelle = (string) $_analyse->libelle;
        $analyse->decodeUtfStrings();
        $analyse->technique = (string) $_analyse->technique;
        $analyse->duree_execution = (string) $_analyse->delaitechnique;
        $materiel = utf8_decode((string) $_analyse->materiel);
        $materiel = trim($materiel);
        switch ($materiel) {
            case "SANG VEINEUX":
                $analyse->type_prelevement = "sang";
                break;
            case "URINE":
                $analyse->type_prelevement = "urine";
                break;
            case "BIOPSIE":
                $analyse->type_prelevement = "biopsie";
                break;
        }
        //$analyse->applicabilite = (string) $_analyse->applicablesexe;
        $analyse->execution_lun = (string) $_analyse->joursrealisation->lundi;
        $analyse->execution_mar = (string) $_analyse->joursrealisation->mardi;
        $analyse->execution_mer = (string) $_analyse->joursrealisation->mercredi;
        $analyse->execution_jeu = (string) $_analyse->joursrealisation->jeudi;
        $analyse->execution_ven = (string) $_analyse->joursrealisation->vendredi;
        $analyse->execution_sam = (string) $_analyse->joursrealisation->samedi;
        $analyse->execution_dim = (string) $_analyse->joursrealisation->dimanche;
        $analyse->catalogue_labo_id = $catalogue->_id;
        $analyse->type = "num";
        $analyse->obsolete = 0;
        $idAnalyse->bindObject($analyse);
        //CAppUI::stepAjax("Analyse '$analyse->identifiant' importée", UI_MSG_OK);
        $compteur["analyses"]++;
    }
    // fin du foreach
    CAppUI::stepAjax("Analyses Importées: " . $compteur["analyses"] . ", Chapitres Importés: " . $compteur["chapitres"] . ", Sous chapitres Importés: " . $compteur["sousChapitre"], UI_MSG_OK);
}
<?php

/**
 * $Id$
 *
 * @category Files
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkEdit();
CApp::setTimeLimit(300);
$show = CValue::get("show", 50);
// Search files without documents
$files = glob(CFile::$directory . "/*/*/*/*");
$filesCount = 0;
$filesWithoutDocCount = 0;
$filesWithoutDocTruncated = array();
$filesWithBadDocCount = 0;
$filesWithBadDocTruncated = array();
foreach ($files as $filePath) {
    $filesCount++;
    $fileName = basename($filePath);
    $fileObjectId = basename(dirname($filePath));
    $fileObjectClass = basename(dirname(dirname(dirname($filePath))));
    $where = array("file_real_filename" => "= '{$fileName}'");
    $doc = new CFile();
    $doc->loadObject($where);
    if (!$doc->file_id) {
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Stock
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$ratio = (double) CValue::get("ratio", 2);
CApp::setMemoryLimit('512M');
CApp::setTimeLimit(120);
$sql = new CRequest();
$sql->addTable("product_order_item");
$sql->addSelect("\r\n  product_order_item.order_item_id,\r\n  product_order_item.reference_id, \r\n  product_reference.price AS RP, \r\n  product_order_item.unit_price AS OP, \r\n  product_order_item.quantity AS OQ, \r\n  product_order.order_id, \r\n  product_order.order_number, \r\n  product_order.date_ordered");
$sql->addLJoin(array("product_reference" => "product_reference.reference_id = product_order_item.reference_id", "product_order" => "product_order.order_id = product_order_item.order_id"));
$sql->addWhere("\r\n  product_order.cancelled = '0' \r\n  AND (product_reference.cancelled = '0' OR product_reference.cancelled IS NULL)\r\n  AND product_reference.price != product_order_item.unit_price\r\n  AND (\r\n    product_order_item.unit_price > product_reference.price*{$ratio} OR \r\n    product_reference.price > product_order_item.unit_price*{$ratio}\r\n  )");
$sql->addOrder("product_reference.code");
$changes = $this->_spec->ds->loadList($sql->makeSelect());
$changes_struct = array();
$references = array();
$references_cahpp = array();
foreach ($changes as $_change) {
    if (!isset($references[$_change["reference_id"]])) {
        $_reference = new CProductReference();
        $_reference->load($_change["reference_id"]);
        $references[$_reference->_id] = $_reference;
        $article = new CCAHPPArticle();
<?php

/**
 * $Id$
 *
 * @category System
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
CApp::setTimeLimit(0);
CApp::setMemoryLimit("1024M");
$dry_run = CValue::get("dry_run", false);
$table = CValue::get("table");
switch ($table) {
    case "access_log":
        CAccessLog::aggregate(10, 60, 1440, $dry_run);
        break;
    case "access_log_archive":
        CAccessLogArchive::aggregate(10, 60, 1440, $dry_run);
        break;
    case "datasource_log":
        CDataSourceLog::aggregate(10, 60, 1440, $dry_run);
        break;
    case "datasource_log_archive":
        CDataSourceLogArchive::aggregate(10, 60, 1440, $dry_run);
        break;
    default:
Beispiel #13
0
<?php

/* $Id: repas_offline.php 27413 2015-03-04 08:06:56Z mytto $ */
/**
* @package Mediboard
* @subpackage dPrepas
* @version $Revision: 27413 $
* @author Sébastien Fillonneau
*/
CCanDo::checkRead();
global $uistyle, $messages, $version;
CApp::setTimeLimit(90);
$indexFile = CValue::post("indexFile", 0);
$style = CValue::post("style", 0);
$image = CValue::post("image", 0);
$javascript = CValue::post("javascript", 0);
$lib = CValue::post("lib", 0);
$typeArch = CValue::post("typeArch", "zip");
// Création du fichier Zip
if (file_exists("tmp/mediboard_repas.zip")) {
    unlink("tmp/mediboard_repas.zip");
}
if (file_exists("tmp/mediboard_repas.tar.gz")) {
    unlink("tmp/mediboard_repas.tar.gz");
}
if ($typeArch == "zip") {
    $zipFile = new ZipArchive();
    $zipFile->open("tmp/mediboard_repas.zip", ZIPARCHIVE::CREATE);
} elseif ($typeArch == "tar") {
    $zipFile = new Archive_Tar("tmp/mediboard_repas.tar.gz", true);
} else {
Beispiel #14
0
 function __construct()
 {
     parent::__construct();
     $this->mod_name = "dPcabinet";
     $this->makeRevision("all");
     $query = "CREATE TABLE consultation (\r\n                    consultation_id bigint(20) NOT NULL auto_increment,\r\n                    plageconsult_id bigint(20) NOT NULL default '0',\r\n                    patient_id bigint(20) NOT NULL default '0',\r\n                    heure time NOT NULL default '00:00:00',\r\n                    duree time NOT NULL default '00:00:00',\r\n                    motif text,\r\n                    secteur1 smallint(6) NOT NULL default '0',\r\n                    secteur2 smallint(6) NOT NULL default '0',\r\n                    rques text,\r\n                    PRIMARY KEY  (consultation_id),\r\n                    KEY plageconsult_id (plageconsult_id,patient_id)\r\n                    ) /*! ENGINE=MyISAM */ COMMENT='Table des consultations';";
     $this->addQuery($query);
     $query = "CREATE TABLE plageconsult (\r\n                    plageconsult_id bigint(20) NOT NULL auto_increment,\r\n                    chir_id bigint(20) NOT NULL default '0',\r\n                    date date NOT NULL default '0000-00-00',\r\n                    debut time NOT NULL default '00:00:00',\r\n                    fin time NOT NULL default '00:00:00',\r\n                    PRIMARY KEY  (plageconsult_id),\r\n                    KEY chir_id (chir_id)\r\n                    ) /*! ENGINE=MyISAM */ COMMENT='Table des plages de consultation des médecins';";
     $this->addQuery($query);
     $this->makeRevision("0.1");
     $query = "ALTER TABLE plageconsult ADD freq TIME DEFAULT '00:15:00' NOT NULL AFTER date ;";
     $this->addQuery($query);
     $this->makeRevision("0.2");
     $query = "ALTER TABLE consultation ADD compte_rendu TEXT DEFAULT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.21");
     $query = "ALTER TABLE consultation CHANGE duree duree TINYINT DEFAULT '1' NOT NULL ";
     $this->addQuery($query);
     $query = "UPDATE consultation SET duree='1' ";
     $this->addQuery($query);
     $this->makeRevision("0.22");
     $query = "ALTER TABLE `consultation`\r\n                ADD `chrono` TINYINT DEFAULT '16' NOT NULL,\r\n                ADD `annule` TINYINT DEFAULT '0' NOT NULL,\r\n                ADD `paye` TINYINT DEFAULT '0' NOT NULL,\r\n                ADD `cr_valide` TINYINT DEFAULT '0' NOT NULL,\r\n                ADD `examen` TEXT,\r\n                ADD `traitement` TEXT";
     $this->addQuery($query);
     $this->makeRevision("0.23");
     $query = "ALTER TABLE `consultation` ADD `premiere` TINYINT NOT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.24");
     $query = "CREATE TABLE `tarifs` (\r\n                `tarif_id` BIGINT NOT NULL AUTO_INCREMENT ,\r\n                `chir_id` BIGINT DEFAULT '0' NOT NULL ,\r\n                `function_id` BIGINT DEFAULT '0' NOT NULL ,\r\n                `description` VARCHAR( 50 ) ,\r\n                `valeur` TINYINT,\r\n                PRIMARY KEY ( `tarif_id` ) ,\r\n                INDEX ( `chir_id`),\r\n                INDEX ( `function_id` )\r\n                ) /*! ENGINE=MyISAM */ COMMENT = 'table des tarifs de consultation';";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` ADD `tarif` TINYINT,\r\n              ADD `type_tarif` ENUM( 'cheque', 'CB', 'especes', 'tiers', 'autre' ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.25");
     $query = "ALTER TABLE `tarifs` CHANGE `valeur` `secteur1` FLOAT( 6 ) DEFAULT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs` ADD `secteur2` FLOAT( 6 ) NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` CHANGE `secteur1` `secteur1` FLOAT( 6 ) DEFAULT '0' NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` CHANGE `secteur2` `secteur2` FLOAT( 6 ) DEFAULT '0' NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` CHANGE `tarif` `tarif` VARCHAR( 50 ) DEFAULT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `plageconsult` ADD `libelle` VARCHAR( 50 ) DEFAULT NULL AFTER `chir_id` ;";
     $this->addQuery($query);
     $this->makeRevision("0.26");
     $query = "ALTER TABLE `consultation`\r\n                ADD `ordonnance` TEXT DEFAULT NULL,\r\n                ADD `or_valide` TINYINT DEFAULT '0' NOT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.27");
     $query = "ALTER TABLE `consultation`\r\n                ADD `courrier1` TEXT DEFAULT NULL,\r\n                ADD `c1_valide` TINYINT DEFAULT '0' NOT NULL";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation`\r\n                ADD `courrier2` TEXT DEFAULT NULL,\r\n                ADD `c2_valide` TINYINT DEFAULT '0' NOT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.28");
     $query = "ALTER TABLE `consultation` ADD `date_paiement` DATE AFTER `paye` ;";
     $this->addQuery($query);
     $query = "UPDATE consultation, plageconsult\r\n                SET consultation.date_paiement = plageconsult.date\r\n                WHERE consultation.plageconsult_id = plageconsult.plageconsult_id\r\n                AND consultation.paye = 1";
     $this->addQuery($query);
     $this->makeRevision("0.29");
     $query = "CREATE TABLE `consultation_anesth` (\r\n          `consultation_anesth_id` BIGINT NOT NULL AUTO_INCREMENT ,\r\n          `consultation_id` BIGINT DEFAULT '0' NOT NULL ,\r\n          `operation_id` BIGINT DEFAULT '0' NOT NULL ,\r\n          `poid` FLOAT,\r\n          `taille` FLOAT,\r\n          `groupe` ENUM( '0', 'A', 'B', 'AB' ) ,\r\n          `rhesus` ENUM( '+', '-' ) ,\r\n          `antecedents` TEXT,\r\n          `traitements` TEXT,\r\n          `tabac` ENUM( '-', '+', '++' ) ,\r\n          `oenolisme` ENUM( '-', '+', '++' ) ,\r\n          `transfusions` ENUM( '-', '+' ) ,\r\n          `tasys` TINYINT,\r\n          `tadias` TINYINT,\r\n          `listCim10` TEXT,\r\n          `intubation` ENUM( 'dents', 'bouche', 'cou' ) ,\r\n          `biologie` ENUM( 'NF', 'COAG', 'IONO' ) ,\r\n          `commande_sang` ENUM( 'clinique', 'CTS', 'autologue' ) ,\r\n          `ASA` TINYINT,\r\n          PRIMARY KEY ( `consultation_anesth_id` ) ,\r\n          INDEX ( `consultation_id`) ,\r\n          INDEX ( `operation_id` )\r\n          ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     // CR passage des champs à enregistrements supprimé car regressifs
     // $this->makeRevision("0.30");
     $this->makeRevision("0.31");
     $query = "CREATE TABLE `examaudio` (\r\n                `examaudio_id` INT NOT NULL AUTO_INCREMENT ,\r\n                `consultation_id` INT NOT NULL ,\r\n                `gauche_aerien` VARCHAR( 64 ) ,\r\n                `gauche_osseux` VARCHAR( 64 ) ,\r\n                `droite_aerien` VARCHAR( 64 ) ,\r\n                `droite_osseux` VARCHAR( 64 ) ,\r\n                PRIMARY KEY ( `examaudio_id` ) ,\r\n                INDEX ( `consultation_id` )) /*! ENGINE=MyISAM */";
     $this->addQuery($query);
     $this->makeRevision("0.32");
     $query = "ALTER TABLE `examaudio` ADD UNIQUE (`consultation_id`)";
     $this->addQuery($query);
     $this->makeRevision("0.33");
     $query = "ALTER TABLE `examaudio`\r\n                ADD `remarques` TEXT AFTER `consultation_id`,\r\n                ADD `gauche_conlat` VARCHAR( 64 ) ,\r\n                ADD `gauche_ipslat` VARCHAR( 64 ) ,\r\n                ADD `gauche_pasrep` VARCHAR( 64 ) ,\r\n                ADD `gauche_vocale` VARCHAR( 64 ) ,\r\n                ADD `gauche_tympan` VARCHAR( 64 ) ,\r\n                ADD `droite_conlat` VARCHAR( 64 ) ,\r\n                ADD `droite_ipslat` VARCHAR( 64 ) ,\r\n                ADD `droite_pasrep` VARCHAR( 64 ) ,\r\n                ADD `droite_vocale` VARCHAR( 64 ) ,\r\n                ADD `droite_tympan` VARCHAR( 64 )";
     $this->addQuery($query);
     $this->makeRevision("0.34");
     $query = "ALTER TABLE `consultation_anesth`\r\n                CHANGE `groupe` `groupe` ENUM( '?', '0', 'A', 'B', 'AB' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `rhesus` `rhesus` ENUM( '?', '+', '-' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `tabac` `tabac` ENUM( '?', '-', '+', '++' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `oenolisme` `oenolisme` ENUM( '?', '-', '+', '++' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `transfusions` `transfusions` ENUM( '?', '-', '+' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `intubation` `intubation` ENUM( '?', 'dents', 'bouche', 'cou' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `biologie` `biologie` ENUM( '?', 'NF', 'COAG', 'IONO' ) DEFAULT '?' NOT NULL ,\r\n                CHANGE `commande_sang` `commande_sang` ENUM( '?', 'clinique', 'CTS', 'autologue' ) DEFAULT '?' NOT NULL ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth`\r\n                CHANGE `tasys` `tasys` INT( 5 ) DEFAULT NULL ,\r\n                CHANGE `tadias` `tadias` INT( 5 ) DEFAULT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.35");
     $query = "ALTER TABLE `consultation` ADD `arrivee` DATETIME AFTER `type_tarif` ;";
     $this->addQuery($query);
     $this->makeRevision("0.36");
     $query = "ALTER TABLE `consultation_anesth`\r\n                CHANGE `groupe` `groupe` ENUM( '?', 'O', 'A', 'B', 'AB' ) DEFAULT '?' NOT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.37");
     $this->makeRevision("0.38");
     $this->makeRevision("0.39");
     $query = "ALTER TABLE `consultation_anesth`\r\n              ADD `mallampati` ENUM( 'classe1', 'classe2', 'classe3', 'classe4' ),\r\n              ADD `bouche` ENUM( 'm20', 'm35', 'p35' ),\r\n              ADD `distThyro` ENUM( 'm65', 'p65' ),\r\n              ADD `etatBucco` VARCHAR(50),\r\n              ADD `conclusion` VARCHAR(50),\r\n              ADD `position` ENUM( 'DD', 'DV', 'DL', 'GP', 'AS', 'TO' );";
     $this->addQuery($query);
     $this->makeRevision("0.40");
     $this->makeRevision("0.41");
     $this->makeRevision("0.42");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `consultation` DROP INDEX `plageconsult_id`  ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` ADD INDEX ( `plageconsult_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` ADD INDEX ( `patient_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs` DROP INDEX `chir_id` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs` ADD INDEX ( `chir_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs` ADD INDEX ( `function_id` ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.43");
     $query = "ALTER TABLE `consultation_anesth`" . "CHANGE `position` `position` ENUM( 'DD', 'DV', 'DL', 'GP', 'AS', 'TO', 'GYN');";
     $this->addQuery($query);
     $query = "CREATE TABLE `techniques_anesth` (\r\n               `technique_id` INT NOT NULL AUTO_INCREMENT ,\r\n               `consultAnesth_id` INT NOT NULL ,\r\n               `technique` TEXT NOT NULL ,\r\n               PRIMARY KEY ( `technique_id` )) /*! ENGINE=MyISAM */";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `rai` float default NULL,\r\n                ADD `hb` float default NULL,\r\n                ADD `tp` float default NULL,\r\n                ADD `tca` time NOT NULL default '00:00:00',\r\n                ADD `creatinine` float default NULL,\r\n                ADD `na` float default NULL,\r\n                ADD `k` float default NULL,\r\n                ADD `tsivy` time NOT NULL default '00:00:00',\r\n                ADD `plaquettes` INT(7) default NULL,\r\n                ADD `ht` float default NULL,\r\n                ADD `ecbu` ENUM( '?', 'NEG', 'POS' ) DEFAULT '?' NOT NULL,\r\n                ADD `ecbu_detail` TEXT,\r\n                ADD `pouls` INT(4) default NULL,\r\n                ADD `spo2` float default NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` CHANGE `operation_id` `operation_id` BIGINT( 20 ) NULL DEFAULT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth`\r\n                CHANGE `etatBucco` `etatBucco` TEXT DEFAULT NULL ,\r\n                CHANGE `conclusion` `conclusion` TEXT DEFAULT NULL ";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth`\r\n                CHANGE `tabac` `tabac` TEXT DEFAULT NULL ,\r\n                CHANGE `oenolisme` `oenolisme` TEXT DEFAULT NULL ";
     $this->addQuery($query);
     $query = "CREATE TABLE `exams_comp` (\r\n               `exam_id` INT NOT NULL AUTO_INCREMENT ,\r\n               `consult_id` INT NOT NULL ,\r\n               `examen` TEXT NOT NULL ,\r\n               `fait` tinyint(1) NOT NULL default 0,\r\n               PRIMARY KEY ( `exam_id` )) /*! ENGINE=MyISAM */";
     $this->addQuery($query);
     $this->makeRevision("0.44");
     $this->addDependency("mediusers", "0.1");
     $this->addMethod("consultAnesth");
     $this->makeRevision("0.45");
     $query = "ALTER TABLE `exams_comp` CHANGE `consult_id` `consultation_id` INT NOT NULL ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `techniques_anesth` CHANGE `consultAnesth_id` `consultation_anesth_id` INT NOT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.46");
     $query = "ALTER TABLE `consultation_anesth` CHANGE `tca` `tca` TINYINT(2) NULL ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `tca_temoin` TINYINT(2) NULL AFTER `tca`,\r\n                ADD `ht_final` FLOAT DEFAULT NULL AFTER `ht`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` DROP `transfusions`";
     $this->addQuery($query);
     $this->makeRevision("0.47");
     $query = "ALTER TABLE `consultation_anesth` CHANGE `rhesus` `rhesus` ENUM( '?', '+', '-', 'POS', 'NEG') DEFAULT '?' NOT NULL ;";
     $this->addQuery($query);
     $query = "UPDATE `consultation_anesth` SET `rhesus`='POS' WHERE `rhesus`='+';";
     $this->addQuery($query);
     $query = "UPDATE `consultation_anesth` SET `rhesus`='NEG' WHERE `rhesus`='-';";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` CHANGE `rhesus` `rhesus` ENUM( '?', 'POS', 'NEG') DEFAULT '?' NOT NULL ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` CHANGE `rai` `rai` ENUM( '?', 'POS', 'NEG') DEFAULT '?' NOT NULL ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` DROP `ecbu_detail`";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `premedication` TEXT,\r\n                ADD `prepa_preop` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("0.48");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `consultation_anesth` \r\n                CHANGE `consultation_anesth_id` `consultation_anesth_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `consultation_id` `consultation_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `operation_id` `operation_id` int(11) unsigned NULL,\r\n                CHANGE `poid` `poid` float unsigned NULL,\r\n                CHANGE `rhesus` `rhesus` enum('?','NEG','POS') NOT NULL DEFAULT '?',\r\n                CHANGE `rai` `rai` enum('?','NEG','POS') NOT NULL DEFAULT '?',\r\n                CHANGE `tasys` `tasys` int(5) unsigned zerofill NULL,\r\n                CHANGE `tadias` `tadias` int(5) unsigned zerofill NULL,\r\n                CHANGE `plaquettes` `plaquettes` int(7) unsigned zerofill NULL,\r\n                CHANGE `pouls` `pouls` mediumint(4) unsigned zerofill NULL,\r\n                CHANGE `ASA` `ASA` enum('1','2','3','4','5') NULL,\r\n                CHANGE `tca` `tca` tinyint(2) unsigned zerofill NULL,\r\n                CHANGE `tca_temoin` `tca_temoin` tinyint(2) unsigned zerofill NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` \r\n                DROP `listCim10`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` \r\n                CHANGE `consultation_id` `consultation_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `plageconsult_id` `plageconsult_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `patient_id` `patient_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `duree` `duree` tinyint(1) unsigned zerofill NOT NULL DEFAULT '1',\r\n                CHANGE `annule` `annule` enum('0','1') NOT NULL DEFAULT '0',\r\n                CHANGE `chrono` `chrono` enum('16','32','48','64') NOT NULL DEFAULT '16',\r\n                CHANGE `paye` `paye` enum('0','1') NOT NULL DEFAULT '0',\r\n                CHANGE `premiere` `premiere` enum('0','1') NOT NULL DEFAULT '0',\r\n                CHANGE `tarif` `tarif` varchar(255) NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` \r\n                DROP `compte_rendu`,\r\n                DROP `cr_valide`,\r\n                DROP `ordonnance`,\r\n                DROP `or_valide`,\r\n                DROP `courrier1`,\r\n                DROP `c1_valide`,\r\n                DROP `courrier2`,\r\n                DROP `c2_valide`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `examaudio` \r\n                CHANGE `examaudio_id` `examaudio_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `consultation_id` `consultation_id` int(11) unsigned NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `exams_comp` \r\n                CHANGE `exam_id` `exam_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `consultation_id` `consultation_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `fait` `fait` tinyint(4) NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `plageconsult` \r\n                CHANGE `plageconsult_id` `plageconsult_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `chir_id` `chir_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `libelle` `libelle` varchar(255) NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs` \r\n                CHANGE `tarif_id` `tarif_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `chir_id` `chir_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `function_id` `function_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `description` `description` varchar(255) NOT NULL,\r\n                CHANGE `secteur1` `secteur1` float NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `techniques_anesth` \r\n                CHANGE `technique_id` `technique_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `consultation_anesth_id` `consultation_anesth_id` int(11) unsigned NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.49");
     $query = "ALTER TABLE `consultation_anesth` \r\n                CHANGE `tasys` `tasys` TINYINT(4) NULL,\r\n                CHANGE `tadias` `tadias` TINYINT(4) NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.50");
     $query = "ALTER TABLE `consultation` CHANGE `patient_id` `patient_id` int(11) unsigned NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.51");
     $query = "UPDATE `consultation` SET `annule` = '0' WHERE (`annule` = '' OR `annule` IS NULL );";
     $this->addQuery($query);
     $this->makeRevision("0.52");
     $query = "UPDATE `consultation` SET `patient_id` = NULL WHERE (`patient_id` = 0 );";
     $this->addQuery($query);
     $this->makeRevision("0.53");
     $query = "CREATE TABLE `exampossum` (\r\n                    `exampossum_id` int(11) unsigned NOT NULL auto_increment,\r\n                    `consultation_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                    `age` enum('inf60','61','sup71') NULL,\r\n                    `ouverture_yeux` enum('spontane','bruit','douleur','jamais') NULL,\r\n                    `rep_verbale` enum('oriente','confuse','inapproprie','incomprehensible','aucune') NULL,\r\n                    `rep_motrice` enum('obeit','oriente','evitement','decortication','decerebration','rien') NULL,\r\n                    `signes_respiratoires` enum('aucun','dyspnee_effort','bpco_leger','dyspnee_inval','bpco_modere','dyspnee_repos','fibrose') NULL,\r\n                    `uree` enum('inf7.5','7.6','10.1','sup15.1') NULL,\r\n                    `freq_cardiaque` enum('inf39','40','50','81','101','sup121') NULL,\r\n                    `signes_cardiaques` enum('aucun','diuretique','antiangineux','oedemes','cardio_modere','turgescence','cardio') NULL,\r\n                    `hb` enum('inf9.9','10','11.5','13','16.1','17.1','sup18.1') NULL,\r\n                    `leucocytes` enum('inf3000','3100','4000','10100','sup20100') NULL,\r\n                    `ecg` enum('normal','fa','autre','sup5','anomalie') NULL,\r\n                    `kaliemie` enum('inf2.8','2.9','3.2','3.5','5.1','5.4','sup6.0') NULL,\r\n                    `natremie` enum('inf125','126','131','sup136') NULL,\r\n                    `pression_arterielle` enum('inf89','90','100','110','131','sup171') NULL,\r\n                    `gravite` enum('min','moy','maj','maj+') NULL,\r\n                    `nb_interv` enum('1','2','sup2') NULL,\r\n                    `pertes_sanguines` enum('inf100','101','501','sup1000') NULL,\r\n                    `contam_peritoneale` enum('aucune','mineure','purulente','diffusion') NULL,\r\n                    `cancer` enum('absense','tumeur','ganglion','metastases') NULL,\r\n                    `circonstances_interv` enum('reglee','urg','prgm','sansdelai') NULL,\r\n                    PRIMARY KEY  (`exampossum_id`),\r\n                    KEY `consultation_id` (`consultation_id`)\r\n                    ) /*! ENGINE=MyISAM */ COMMENT='Table pour le calcul possum';";
     $this->addQuery($query);
     $this->makeRevision("0.54");
     $query = "CREATE TABLE `examnyha` (\r\n                    `examnyha_id` int(11) unsigned NOT NULL auto_increment,\r\n                    `consultation_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                    `q1` enum('0','1') NULL,\r\n                    `q2a` enum('0','1') NULL,\r\n                    `q2b` enum('0','1') NULL,\r\n                    `q3a` enum('0','1') NULL,\r\n                    `q3b` enum('0','1') NULL,\r\n                    `hesitation` enum('0','1') NOT NULL DEFAULT '0',\r\n                    PRIMARY KEY  (`examnyha_id`),\r\n                    KEY `consultation_id` (`consultation_id`)\r\n                    ) /*! ENGINE=MyISAM */ COMMENT='Table pour la classe NYHA';";
     $this->addQuery($query);
     $this->makeRevision("0.55");
     $query = "ALTER TABLE `consultation_anesth` ADD `listCim10` TEXT DEFAULT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.56");
     $this->addDependency("dPplanningOp", "0.63");
     $this->addMethod("cleanOperationIdError");
     $this->makeRevision("0.57");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `consultation`\r\n                ADD INDEX ( `heure` ),\r\n                ADD INDEX ( `annule` ),\r\n                ADD INDEX ( `paye` ),\r\n                ADD INDEX ( `date_paiement` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `plageconsult`\r\n                ADD INDEX ( `date` ),\r\n                ADD INDEX ( `debut` ),\r\n                ADD INDEX ( `fin` )";
     $this->addQuery($query);
     $this->makeRevision("0.58");
     $this->setTimeLimit(1800);
     $this->addDependency("dPpatients", "0.41");
     $query = "INSERT INTO antecedent\r\n            SELECT '', consultation_anesth.consultation_anesth_id, antecedent.type,\r\n              antecedent.date, antecedent.rques, 'CConsultAnesth'\r\n            FROM antecedent, consultation_anesth, consultation\r\n            WHERE antecedent.object_class = 'CPatient'\r\n              AND antecedent.object_id = consultation.patient_id\r\n              AND consultation.consultation_id = consultation_anesth.consultation_id";
     $this->addQuery($query);
     $query = "INSERT INTO traitement\r\n            SELECT '', consultation_anesth.consultation_anesth_id, traitement.debut,\r\n              traitement.fin, traitement.traitement, 'CConsultAnesth'\r\n            FROM traitement, consultation_anesth, consultation\r\n            WHERE traitement.object_class = 'CPatient'\r\n              AND traitement.object_id = consultation.patient_id\r\n              AND consultation.consultation_id = consultation_anesth.consultation_id";
     $this->addQuery($query);
     $query = "UPDATE consultation_anesth, consultation, patients\r\n            SET consultation_anesth.listCim10 = patients.listCim10\r\n            WHERE consultation_anesth.consultation_id = consultation.consultation_id\r\n              AND consultation.patient_id = patients.patient_id";
     $this->addQuery($query);
     $this->makeRevision("0.59");
     $query = "ALTER TABLE `exams_comp` ADD `realisation` ENUM( 'avant', 'pendant' ) NOT NULL DEFAULT 'avant' AFTER `consultation_id`;";
     $this->addQuery($query);
     $this->makeRevision("0.60");
     $query = "CREATE TABLE `addiction` (\r\n            `addiction_id` int(11) unsigned NOT NULL auto_increment,\r\n            `object_id` int(11) unsigned NOT NULL default '0',\r\n            `object_class` enum('CConsultAnesth') NOT NULL default 'CConsultAnesth',\r\n            `type` enum('tabac', 'oenolisme', 'cannabis') NOT NULL default 'tabac',\r\n            `addiction` text,\r\n            PRIMARY KEY  (`addiction_id`)\r\n            ) /*! ENGINE=MyISAM */ COMMENT = 'Addictions pour le dossier anesthésie';";
     $this->addQuery($query);
     $this->makeRevision("0.61");
     $this->addPrefQuery("DefaultPeriod", "month");
     $this->makeRevision("0.62");
     $query = "ALTER TABLE `tarifs`\r\n                CHANGE `chir_id` `chir_id` int(11) unsigned NULL DEFAULT NULL,\r\n                CHANGE `function_id` `function_id` int(11) unsigned NULL DEFAULT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `tarifs` SET function_id = NULL WHERE function_id='0';";
     $this->addQuery($query);
     $query = "UPDATE `tarifs` SET chir_id = NULL WHERE chir_id='0';";
     $this->addQuery($query);
     $query = "DELETE FROM `consultation_anesth` WHERE `consultation_id`= '0'";
     $this->addQuery($query);
     $query = "UPDATE `consultation_anesth` SET operation_id = NULL WHERE operation_id='0';";
     $this->addQuery($query);
     $query = "DELETE FROM `exams_comp` WHERE `consultation_id`= '0'";
     $this->addQuery($query);
     $this->makeRevision("0.63");
     $this->addPrefQuery("simpleCabinet", "0");
     $this->makeRevision("0.64");
     $this->addPrefQuery("GestionFSE", "0");
     $this->makeRevision("0.65");
     $this->addPrefQuery("DossierCabinet", "dPcabinet");
     $this->makeRevision("0.66");
     $query = "UPDATE `consultation` SET  `rques` = NULL  WHERE `rques` = 'NULL'";
     $this->addQuery($query);
     $query = "UPDATE `consultation` SET  `motif` = NULL  WHERE `motif` = 'NULL'";
     $this->addQuery($query);
     $query = "UPDATE `consultation` SET  `traitement` = NULL  WHERE `traitement` = 'NULL'";
     $this->addQuery($query);
     $query = "UPDATE `consultation` SET  `examen` = NULL  WHERE `examen` = 'NULL'";
     $this->addQuery($query);
     $this->makeRevision("0.67");
     $query = "ALTER TABLE `consultation` ADD `codes_ccam` VARCHAR(255);";
     $this->addQuery($query);
     $this->makeRevision("0.68");
     $this->addPrefQuery("ccam", "0");
     $this->makeRevision("0.69");
     $query = "ALTER TABLE `tarifs` ADD `codes_ccam` VARCHAR(255);";
     $this->addQuery($query);
     $this->makeRevision("0.70");
     $query = "UPDATE `consultation_anesth` SET  `plaquettes` = `plaquettes`/1000";
     $this->addQuery($query);
     $this->makeRevision("0.71");
     $query = "ALTER TABLE `consultation_anesth` " . "CHANGE `plaquettes` `plaquettes` int(4) unsigned zerofill NULL";
     $this->addQuery($query);
     $this->makeRevision("0.72");
     $query = "CREATE TABLE `banque` (\r\n             `banque_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, \r\n             `nom` VARCHAR(255) NOT NULL, \r\n             `description` VARCHAR(255), \r\n              PRIMARY KEY (`banque_id`)) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.73");
     $query = "ALTER TABLE `consultation` ADD `banque_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.74");
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'AXA Banque', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque accord', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'LCL', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Populaire', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Natexis', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'La banque Postale', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'BNP Paribas', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Caisse d\\'epargne', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Ixis', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Océor', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Palatine', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Crédit Foncier', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Compagnie 1818', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Caisse des dépôts', 'Caisse des dépôts et consignations') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Crédit Agricole', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'HSBC', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Crédit coopératif', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Crédit Mutuel', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'CIC', 'Crédit Industriel et Commercial') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Dexia', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Société générale', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Groupama Banque', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Crédit du Nord', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Courtois', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Tarneaud', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Kolb', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Laydernier', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Nuger', '') ;";
     $this->addQuery($query);
     $query = " INSERT INTO `banque` ( `banque_id` , `nom` , `description` ) VALUES ( '' , 'Banque Rhône-Alpes', '') ;";
     $this->addQuery($query);
     $this->makeRevision("0.75");
     $query = "CREATE TABLE `consultation_cat` (\r\n            `categorie_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, \r\n            `function_id` INT(11) UNSIGNED NOT NULL, \r\n            `nom_categorie` VARCHAR(255) NOT NULL, \r\n            `nom_icone` VARCHAR(255) NOT NULL, \r\n             PRIMARY KEY (`categorie_id`)) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.76");
     $query = "ALTER TABLE `consultation`\r\n      ADD `categorie_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.77");
     // Tranfert des addictions tabac vers la consultation d'anesthésie
     $query = "INSERT INTO `addiction` ( `addiction_id` , `object_id` , `object_class` , `type` , `addiction` )\r\n      SELECT null,`consultation_anesth_id`, 'CConsultAnesth', 'tabac', `tabac` \r\n      FROM `consultation_anesth` \r\n      WHERE `tabac` IS NOT NULL\r\n      AND `tabac` <> ''";
     $this->addQuery($query);
     // Tranfert des addictions tabac vers le dossier patient
     $query = "INSERT INTO `addiction` ( `addiction_id` , `object_id` , `object_class` , `type` , `addiction` )\r\n      SELECT null,`patient_id`, 'CPatient', 'tabac', `tabac`\r\n      FROM `consultation_anesth`, `consultation`\r\n      WHERE `tabac` IS NOT NULL\r\n      AND `tabac` <> ''\r\n      AND `consultation`.`consultation_id` = `consultation_anesth`.`consultation_id`";
     $this->addQuery($query);
     // Tranfert des addictions oenolisme vers la consultation d'anesthésie
     $query = "INSERT INTO `addiction` ( `addiction_id` , `object_id` , `object_class` , `type` , `addiction` )\r\n      SELECT null,`consultation_anesth_id`, 'CConsultAnesth', 'oenolisme', `oenolisme` \r\n      FROM `consultation_anesth` \r\n      WHERE `oenolisme` IS NOT NULL\r\n      AND `oenolisme` <> ''";
     $this->addQuery($query);
     // Tranfert des addictions oenolisme vers le dossier patient
     $query = "INSERT INTO `addiction` ( `addiction_id` , `object_id` , `object_class` , `type` , `addiction` )\r\n      SELECT null,`patient_id`, 'CPatient', 'oenolisme', `oenolisme`\r\n      FROM `consultation_anesth`, `consultation`\r\n      WHERE `oenolisme` IS NOT NULL\r\n      AND `oenolisme` <> ''\r\n      AND `consultation`.`consultation_id` = `consultation_anesth`.`consultation_id`";
     $this->addQuery($query);
     $this->makeRevision("0.78");
     $query = "ALTER TABLE `consultation` ADD `adresse` enum('0','1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("0.79");
     // Ne pas supprimer le champs listCim10 de la consultAnesth afin d'avoir fait l'import dans dPpatient
     $this->addDependency("dPpatients", "0.51");
     $query = "ALTER TABLE `consultation_anesth`\r\n                DROP `listCim10`;";
     $this->addQuery($query);
     $this->makeRevision("0.80");
     $query = "CREATE TABLE `acte_ngap` (\r\n            `acte_ngap_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, \r\n            `code` VARCHAR(3) NOT NULL, \r\n            `quantite` INT(11) NOT NULL, \r\n            `coefficient` FLOAT NOT NULL, \r\n            `consultation_id` INT(11) UNSIGNED NOT NULL, \r\n            PRIMARY KEY (`acte_ngap_id`)) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.81");
     $query = "ALTER TABLE `tarifs` ADD `codes_ngap` VARCHAR(255);";
     $this->addQuery($query);
     $this->makeRevision("0.82");
     $query = "ALTER TABLE `acte_ngap`\r\n            ADD `montant_depassement` FLOAT, \r\n            ADD `montant_base` FLOAT;";
     $this->addQuery($query);
     $this->makeRevision("0.83");
     $query = "ALTER TABLE `consultation`\r\n            ADD `valide` ENUM('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET `valide` = '1'\r\n             WHERE `tarif` IS NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.84");
     $query = "ALTER TABLE `consultation`\r\n            CHANGE `type_tarif` `mode_reglement` ENUM( 'cheque', 'CB', 'especes', 'tiers', 'autre' ),\r\n            CHANGE `paye` `patient_regle` ENUM('0','1');";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation`\r\n            ADD `total_amc` FLOAT,\r\n            ADD `total_amo` FLOAT,\r\n            ADD `total_assure` FLOAT,\r\n            ADD `facture_acquittee` ENUM('0','1'), \r\n            ADD `a_regler` FLOAT DEFAULT '0.0';";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET `a_regler` = `secteur1` + `secteur2`\r\n            WHERE `mode_reglement` <> 'tiers'\r\n            OR `mode_reglement` IS NULL;";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET `patient_regle` = '1'\r\n            WHERE `mode_reglement` = 'tiers';";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET `facture_acquittee` = '1'\r\n            WHERE `a_regler` = `secteur1` + `secteur2`\r\n            AND `patient_regle` = '1';";
     $this->addQuery($query);
     $this->makeRevision("0.85");
     $query = "ALTER TABLE `consultation`\r\n            ADD `sejour_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.86");
     $this->setTimeLimit(300);
     $query = "UPDATE `consultation`\r\n            SET `patient_regle` = '1'\r\n            WHERE ROUND(`a_regler`,2) = ROUND(0,2);";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET `facture_acquittee` = '1'\r\n            WHERE ROUND(`a_regler`,2) = ROUND(`secteur1` + `secteur2`, 2)\r\n            AND `patient_regle` = '1'\r\n            AND (`facture_acquittee` <> '1'\r\n                  OR `facture_acquittee` IS NULL);";
     $this->addQuery($query);
     $query = "UPDATE `consultation`, `plageconsult`\r\n            SET `date_paiement` = `plageconsult`.`date`  \r\n            WHERE `patient_regle` = '1'\r\n            AND `date_paiement` IS NULL\r\n            AND `consultation`.`plageconsult_id` = `plageconsult`.`plageconsult_id`;";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET date_paiement = NULL\r\n            WHERE date_paiement IS NOT NULL\r\n            AND patient_regle <> '1';";
     $this->addQuery($query);
     $this->makeRevision("0.87");
     $query = "ALTER TABLE `consultation` \r\n            CHANGE `date_paiement` `date_reglement` DATE,\r\n            DROP `patient_regle`;";
     $this->addQuery($query);
     $this->makeRevision("0.88");
     $query = "ALTER TABLE `acte_ngap`\r\n            CHANGE `consultation_id` `object_id` INT(11) UNSIGNED NOT NULL, \r\n            ADD `object_class` ENUM('COperation','CSejour','CConsultation') NOT NULL default 'CConsultation';";
     $this->addQuery($query);
     $this->makeRevision("0.89");
     $query = "UPDATE `consultation`\r\n            SET `date_reglement` = NULL, `facture_acquittee` = NULL\r\n            WHERE `a_regler` = '0'\r\n            AND (`mode_reglement` IS NULL OR `mode_reglement` = '');";
     $this->addQuery($query);
     $this->makeRevision("0.90");
     $query = "ALTER TABLE `consultation` \r\n            CHANGE `facture_acquittee` `reglement_AM` ENUM('0','1');";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET `reglement_AM` = '1'\r\n            WHERE ROUND(`a_regler`,2) = ROUND(`secteur1` + `secteur2`, 2)\r\n            AND `valide` = '1';";
     $this->addQuery($query);
     $this->makeRevision("0.91");
     $query = "DELETE FROM `user_preferences` \r\n      WHERE `key` = 'ccam_consultation'";
     $this->addQuery($query);
     $query = "UPDATE `user_preferences`\r\n      SET `key` = 'ccam_consultation'\r\n      WHERE `key` = 'ccam'";
     $this->addQuery($query);
     $this->makeRevision("0.92");
     $query = "ALTER TABLE `acte_ngap` \r\n            ADD `demi` ENUM('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.93");
     $query = "CREATE TABLE `examigs` (\r\n           `examigs_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, \r\n           `consultation_id` INT(11) UNSIGNED NOT NULL, \r\n           `age` ENUM('0','7','12','15','16','18'), \r\n           `FC` ENUM('11','2','0','4','7'), \r\n           `TA` ENUM('13','5','0','2'), \r\n           `temperature` ENUM('0','3'), \r\n           `PAO2_FIO2` ENUM('11','9','6'), \r\n           `diurese` ENUM('12','4','0'), \r\n           `uree` ENUM('0','6','10'), \r\n           `globules_blancs` ENUM('12','0','3'), \r\n           `kaliemie` ENUM('3a','0','3b'), \r\n           `natremie` ENUM('5','0','1'), \r\n           `HCO3` ENUM('6','3','0'), \r\n           `billirubine` ENUM('0','4','9'), \r\n           `glascow` ENUM('26','13','7','5','0'), \r\n           `maladies_chroniques` ENUM('9','10','17'), \r\n           `admission` ENUM('0','6','8'), \r\n           `scoreIGS` INT(11), \r\n             PRIMARY KEY (`examigs_id`)) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.94");
     CApp::setTimeLimit(180);
     // Ajout de du_tiers
     $query = "ALTER TABLE `consultation`\r\n            ADD `du_tiers` FLOAT DEFAULT 0.0";
     $this->addQuery($query);
     // Calcul de du_tiers
     $query = "UPDATE `consultation`\r\n            SET `du_tiers` = ROUND(`secteur1` + `secteur2` - `a_regler`, 2);";
     $this->addQuery($query);
     // mode_reglement à NULL quand mode_reglement = tiers
     $query = "UPDATE `consultation`\r\n            SET `mode_reglement` = ''\r\n            WHERE `mode_reglement` = 'tiers';";
     $this->addQuery($query);
     // Modification de l'enum de mode_reglement
     $query = "ALTER TABLE `consultation`\r\n            CHANGE `mode_reglement` `mode_reglement` ENUM('cheque','CB','especes','virement','autre');";
     $this->addQuery($query);
     // date_reglement => patient_date_reglement
     $query = "ALTER TABLE `consultation` \r\n            CHANGE `date_reglement` `patient_date_reglement` DATE;";
     $this->addQuery($query);
     // mode_reglement => patient_mode_reglement
     $query = "ALTER TABLE `consultation` \r\n            CHANGE `mode_reglement` `patient_mode_reglement` ENUM('cheque','CB','especes','virement','autre');";
     $this->addQuery($query);
     // a_regler => du_patient
     $query = "ALTER TABLE `consultation`\r\n            CHANGE `a_regler` `du_patient` FLOAT DEFAULT '0.0';";
     $this->addQuery($query);
     // Creation d'un tiers_mode_reglement
     $query = "ALTER TABLE `consultation`\r\n            ADD `tiers_mode_reglement` ENUM('cheque','CB','especes','virement','autre');";
     $this->addQuery($query);
     // Creation d'un tiers_date_reglement
     $query = "ALTER TABLE `consultation`\r\n            ADD `tiers_date_reglement` DATE;";
     $this->addQuery($query);
     // On considere que toutes les anciennes consultations ont reglement_AM à 1
     $query = "UPDATE `consultation`, `plageconsult`\r\n            SET `reglement_AM` = '1'  \r\n            WHERE `consultation`.`plageconsult_id` = `plageconsult`.`plageconsult_id`\r\n            AND `plageconsult`.`date` < '2007-12-01';";
     $this->addQuery($query);
     // On met à jour reglement_AM (reglement_AM à 0 si pas de du_tiers)
     $query = "UPDATE `consultation`\r\n            SET `reglement_AM` = '0'\r\n            WHERE ROUND(`du_tiers`,2)  = ROUND(0,2);";
     $this->addQuery($query);
     // Mise à jour des reglements AM à 1
     $query = "UPDATE `consultation`, `plageconsult`\r\n            SET `tiers_mode_reglement` = 'virement',\r\n                `tiers_date_reglement` = `plageconsult`.`date`\r\n            WHERE `consultation`.`plageconsult_id` = `plageconsult`.`plageconsult_id`\r\n            AND `consultation`.`reglement_AM` = '1';";
     $this->addQuery($query);
     // Suppression du champ reglement_AM
     $query = "ALTER TABLE `consultation`\r\n            DROP `reglement_AM`;";
     $this->addQuery($query);
     $this->makeRevision("0.95");
     $query = "UPDATE consultation\r\n            SET patient_date_reglement = NULL, patient_mode_reglement = NULL\r\n            WHERE du_patient = 0;";
     $this->addQuery($query);
     $this->makeRevision("0.96");
     $query = "UPDATE consultation \r\n            SET valide = '0' \r\n            WHERE valide = '';";
     $this->addQuery($query);
     $this->makeRevision("0.97");
     $query = "ALTER TABLE `consultation`\r\n            ADD `accident_travail` ENUM('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.98");
     $this->addPrefQuery("view_traitement", "1");
     $this->makeRevision("0.99");
     // Table temporaire contenant les consultation_id des accident_travail à 1
     $query = "CREATE TEMPORARY TABLE tbl_accident_travail (\r\n             consultation_id INT( 11 )\r\n            ) AS \r\n              SELECT consultation_id\r\n              FROM `consultation`\r\n              WHERE accident_travail = '1';";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation`\r\n            CHANGE `accident_travail` `accident_travail` DATE DEFAULT NULL";
     $this->addQuery($query);
     $query = "UPDATE `consultation`, `plageconsult`, `tbl_accident_travail`\r\n            SET `consultation`.`accident_travail` = `plageconsult`.`date`\r\n            WHERE `consultation`.`plageconsult_id` = `plageconsult`.`plageconsult_id`\r\n            AND `consultation`.`consultation_id` = `tbl_accident_travail`.`consultation_id`;";
     $this->addQuery($query);
     $query = "UPDATE `consultation`\r\n            SET accident_travail = NULL\r\n            WHERE accident_travail = '0000-00-00';";
     $this->addQuery($query);
     $this->makeRevision("1.00");
     $this->addPrefQuery("autoCloseConsult", "0");
     $this->makeRevision("1.01");
     $query = "ALTER TABLE `acte_ngap` \r\n            ADD `complement` ENUM('N','F','U');";
     $this->addQuery($query);
     $this->makeRevision("1.02");
     $query = "ALTER TABLE `consultation_anesth`\r\n            ADD `sejour_id` INT(11) UNSIGNED AFTER `operation_id`";
     $this->addQuery($query);
     $this->makeRevision("1.03");
     $query = "ALTER TABLE `consultation_anesth` \r\n      ADD `examenCardio` TEXT NULL AFTER `etatBucco` ,\r\n      ADD `examenPulmo` TEXT NULL AFTER `examenCardio` ;";
     $this->addQuery($query);
     $this->makeRevision("1.04");
     $query = "CREATE TABLE `reglement` (\r\n      `reglement_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,\r\n      `consultation_id` INT( 11 ) UNSIGNED NOT NULL ,\r\n      `banque_id` INT( 11 ) UNSIGNED ,\r\n      `date` DATETIME NOT NULL ,\r\n      `montant` FLOAT NOT NULL ,\r\n      `emetteur` ENUM( 'patient', 'tiers' ) ,\r\n      `mode` ENUM( 'cheque', 'CB', 'especes', 'virement', 'autre' ) ,\r\n      PRIMARY KEY ( `reglement_id` )\r\n      ) /*! ENGINE=MyISAM */ ;";
     $this->addQuery($query);
     // On crée les règlements des patients
     $query = "INSERT INTO `reglement` (\r\n      `emetteur`,\r\n      `consultation_id`, \r\n      `banque_id`, \r\n      `date`, \r\n      `montant`,\r\n      `mode`)\r\n      \r\n      SELECT \r\n        'patient',\r\n        `consultation_id`, \r\n        `banque_id`, \r\n        `patient_date_reglement`, \r\n        `du_patient`, \r\n        `patient_mode_reglement`\r\n      FROM \r\n        `consultation`\r\n      WHERE \r\n        `patient_date_reglement` IS NOT NULL;";
     $this->addQuery($query);
     // On crée les règlements des tiers
     $query = "INSERT INTO `reglement` (\r\n      `emetteur`,\r\n      `consultation_id`, \r\n      `date`, \r\n      `montant`,\r\n      `mode`)\r\n      \r\n      SELECT \r\n        'tiers',\r\n        `consultation_id`, \r\n        `tiers_date_reglement`, \r\n        `du_tiers`, \r\n        `tiers_mode_reglement`\r\n      FROM \r\n        `consultation`\r\n      WHERE \r\n        `tiers_date_reglement` IS NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.05");
     $query = "ALTER TABLE `acte_ngap` \r\n      ADD `executant_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n      ADD INDEX (`executant_id`)";
     $this->addQuery($query);
     // COperation : executant_id = operations -> chir_id
     // CSejour : executant_id = sejour -> praticien_id
     // CConsultation : executant_id = consultation -> plageconsult -> chir_id
     $query = "UPDATE `acte_ngap` \r\n       SET `acte_ngap`.`executant_id` = \r\n        (SELECT `chir_id` \r\n         FROM `operations` \r\n         WHERE `operations`.`operation_id` = `acte_ngap`.`object_id`\r\n         LIMIT 1)\r\n       WHERE \r\n        `acte_ngap`.`object_class` = 'COperation' AND \r\n        `acte_ngap`.`executant_id` = 0";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap` \r\n       SET `acte_ngap`.`executant_id` = \r\n        (SELECT `praticien_id` \r\n         FROM `sejour` \r\n         WHERE `sejour`.`sejour_id` = `acte_ngap`.`object_id`\r\n         LIMIT 1)\r\n       WHERE \r\n        `acte_ngap`.`object_class` = 'CSejour' AND \r\n        `acte_ngap`.`executant_id` = 0";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap` \r\n       SET `acte_ngap`.`executant_id` = \r\n        (SELECT `plageconsult`.`chir_id` \r\n         FROM `plageconsult`, `consultation`\r\n         WHERE \r\n           `consultation`.`consultation_id` = `acte_ngap`.`object_id` AND\r\n           `plageconsult`.`plageconsult_id` = `consultation`.`plageconsult_id`\r\n         LIMIT 1)\r\n       WHERE \r\n        `acte_ngap`.`object_class` = 'CConsultation' AND \r\n        `acte_ngap`.`executant_id` = 0";
     $this->addQuery($query);
     $this->makeRevision("1.07");
     $this->addPrefQuery("resumeCompta", "1");
     $this->makeRevision("1.08");
     $this->addPrefQuery("VitaleVisionDir", "");
     $this->addPrefQuery("VitaleVision", "0");
     $this->makeRevision("1.09");
     $query = "UPDATE `consultation` \r\n      SET du_tiers = ROUND(secteur1 + secteur2 - du_patient, 2)\r\n      WHERE ROUND(secteur1 + secteur2 - du_tiers - du_patient, 2) != 0\r\n      AND ABS(ROUND(secteur1 + secteur2 - du_tiers - du_patient, 2)) > 1\r\n      AND valide = '1'";
     $this->addQuery($query);
     $this->makeRevision("1.10");
     $this->addPrefQuery("showDatesAntecedents", "1");
     $this->makeRevision("1.11");
     $query = "ALTER TABLE `consultation_anesth` \r\n              ADD `chir_id` INT (11) UNSIGNED AFTER `sejour_id`,\r\n              ADD `date_interv` DATE AFTER `chir_id`,\r\n              ADD `libelle_interv` VARCHAR (255) AFTER `date_interv`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` \r\n              ADD INDEX (`sejour_id`),\r\n              ADD INDEX (`chir_id`),\r\n              ADD INDEX (`date_interv`);";
     $this->addQuery($query);
     $this->makeRevision("1.12");
     $query = "ALTER TABLE `consultation`\r\n              ADD `histoire_maladie` TEXT AFTER `traitement`,\r\n              ADD `conclusion` TEXT AFTER `histoire_maladie`";
     $this->addQuery($query);
     $this->makeRevision("1.13");
     $query = "ALTER TABLE `consultation` \r\n            ADD `concerne_ALD` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.14");
     $query = "ALTER TABLE `consultation_anesth` \r\n            ADD `date_analyse` DATE;";
     $this->addQuery($query);
     $this->makeRevision("1.15");
     $query = "ALTER TABLE `consultation` \r\n              ADD `facture` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.16");
     $this->addPrefQuery("dPcabinet_show_program", "1");
     $this->makeRevision("1.17");
     $query = "ALTER TABLE `acte_ngap` \r\n              ADD INDEX (`object_id`),\r\n              ADD INDEX (`object_class`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` \r\n              ADD INDEX (`sejour_id`),\r\n              ADD INDEX (`tiers_date_reglement`),\r\n              ADD INDEX (`arrivee`),\r\n              ADD INDEX (`categorie_id`),\r\n              ADD INDEX (`accident_travail`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_anesth` \r\n              ADD INDEX (`date_analyse`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation_cat` \r\n              ADD INDEX (`function_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `examigs` \r\n              ADD INDEX (`consultation_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `exams_comp` \r\n              ADD INDEX (`consultation_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `reglement` \r\n              ADD INDEX (`consultation_id`),\r\n              ADD INDEX (`banque_id`),\r\n              ADD INDEX (`date`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `techniques_anesth` \r\n              ADD INDEX (`consultation_anesth_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.18");
     $this->addPrefQuery("pratOnlyForConsult", "1");
     $this->makeRevision("1.19");
     $query = "ALTER TABLE `consultation_anesth` \r\n      DROP `intubation`";
     $this->addQuery($query);
     $this->makeRevision("1.20");
     $query = "UPDATE plageconsult SET fin = '23:59:59' WHERE fin = '00:00:00'";
     $this->addquery($query);
     $this->makeRevision("1.21");
     $query = "ALTER TABLE `consultation_anesth`\r\n              DROP `biologie`,\r\n              DROP `commande_sang`;";
     $this->addquery($query);
     $this->makeRevision("1.22");
     $query = "ALTER TABLE `consultation_anesth`\r\n              ADD `groupe_ok` ENUM ('0','1') NOT NULL DEFAULT '0' AFTER `groupe`,\r\n              ADD `fibrinogene` FLOAT AFTER `creatinine`,\r\n              ADD `result_ecg` TEXT AFTER `ht_final`,\r\n              ADD `result_rp` TEXT AFTER `result_ecg`;";
     $this->addquery($query);
     $this->makeRevision("1.23");
     $query = "ALTER TABLE `consultation`\r\n              ADD `adresse_par_prat_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.24");
     $query = "ALTER TABLE `consultation` ADD `si_desistement` ENUM ('0','1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("1.25");
     $query = "ALTER TABLE `plageconsult` ADD `locked` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.26");
     $this->addPrefQuery("AFFCONSULT", "0");
     $this->addPrefQuery("MODCONSULT", "0");
     $this->makeRevision("1.27");
     $query = "ALTER TABLE `acte_ngap` ADD `lettre_cle` ENUM ('0','1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap` \r\n       SET `acte_ngap`.`lettre_cle` = '1'\r\n       WHERE \r\n        `acte_ngap`.`code` IN ('C','K','KA','KC','KCC','KE','KFA','KFB','KFD','ORT','PRO','PRA'\r\n                               'SCM','V','Z','ZN','LC','LCM','LFA','LFB','LFD','LK','LKC','LKE'\r\n                               'LRA','LRO','LV','LZ','LZM','LZN','CS','VS','LCC','LCS','LVS',\r\n                               'AMI','AIS','DI')";
     $this->addQuery($query);
     $this->makeRevision("1.28");
     $query = "ALTER TABLE `consultation` CHANGE `accident_travail` `date_at` DATE DEFAULT NULL";
     $this->addQuery($query);
     $this->makeRevision("1.29");
     $query = "ALTER TABLE `consultation`\r\n      ADD `fin_at` DATETIME DEFAULT NULL,\r\n      ADD `pec_at` ENUM ('soins', 'arret') DEFAULT NULL,\r\n      ADD `reprise_at` DATETIME DEFAULT NULL";
     $this->addQuery($query);
     $this->makeRevision("1.30");
     $query = "ALTER TABLE `plageconsult`\r\n      ADD `remplacant_id` BIGINT DEFAULT '0' NOT NULL,\r\n      ADD `desistee` ENUM ('0', '1') NOT NULL DEFAULT '0',\r\n      ADD `remplacant_ok` ENUM ('0', '1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("1.33");
     $query = "ALTER TABLE `plageconsult`\r\n     CHANGE `remplacant_id` `remplacant_id` BIGINT DEFAULT NULL";
     $this->addQuery($query);
     $this->makeRevision("1.34");
     $query = "ALTER TABLE `plageconsult`\r\n     CHANGE `remplacant_id` `remplacant_id` INT(11) UNSIGNED";
     $this->addQuery($query);
     $query = "UPDATE `plageconsult`\r\n     SET `remplacant_id`=NULL WHERE `remplacant_id` = '0'";
     $this->addQuery($query);
     $this->makeRevision("1.35");
     $this->addPrefQuery("displayDocsConsult", "1");
     $this->addPrefQuery("displayPremedConsult", "1");
     $this->addPrefQuery("displayResultsConsult", "1");
     $this->makeRevision("1.36");
     $query = "UPDATE `consultation`\r\n      SET chrono = '16'\r\n      WHERE annule = '1'";
     $this->addQuery($query);
     $this->makeRevision("1.37");
     $query = "ALTER TABLE `consultation_anesth`\r\n              ADD `apfel_femme` ENUM ('0','1') DEFAULT '0',\r\n              ADD `apfel_non_fumeur` ENUM ('0','1') DEFAULT '0',\r\n              ADD `apfel_atcd_nvp` ENUM ('0','1') DEFAULT '0',\r\n              ADD `apfel_morphine` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.38");
     $query = "ALTER TABLE `consultation_anesth` \r\n      ADD `examenAutre` TEXT NULL AFTER `examenPulmo` ,\r\n      ADD `examenDigest` TEXT NULL AFTER `examenPulmo` ;";
     $this->addQuery($query);
     $this->makeRevision("1.39");
     $query = "ALTER TABLE `consultation` \r\n      ADD `type` ENUM ('classique','entree') DEFAULT 'classique'";
     $this->addQuery($query);
     $this->makeRevision("1.40");
     $query = "ALTER TABLE `tarifs` ADD `codes_tarmed` VARCHAR(255);";
     $this->addQuery($query);
     $this->makeRevision("1.41");
     $query = "ALTER TABLE `consultation` \r\n      ADD `grossesse_id` INT (11) UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.42");
     $query = "ALTER TABLE `consultation`\r\n      CHANGE `type` `type` ENUM ('classique','entree','chimio') DEFAULT 'classique';";
     $this->addQuery($query);
     $this->makeRevision("1.43");
     $this->addPrefQuery("choosePatientAfterDate", "0");
     $this->makeRevision("1.44");
     $query = "ALTER TABLE `consultation` \r\n      ADD `remise`  VARCHAR(10) NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.45");
     $query = "ALTER TABLE `consultation_cat` \r\n      CHANGE `function_id` `function_id` INT (11) UNSIGNED NOT NULL,\r\n      ADD `duree` TINYINT (4) UNSIGNED NOT NULL DEFAULT '1',\r\n      ADD `commentaire` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.46");
     $query = "ALTER TABLE `consultation`\r\n      ADD `at_sans_arret` ENUM ('0','1') DEFAULT '0',\r\n      ADD `arret_maladie` ENUM ('0','1') DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("1.47");
     $query = "ALTER TABLE `consultation` \r\n      DROP `remise`;";
     $this->addQuery($query);
     $this->makeRevision("1.48");
     $this->addPrefQuery("viewFunctionPrats", "0");
     $this->makeRevision("1.49");
     $query = "CREATE TABLE `factureconsult` (\r\n         `factureconsult_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n         `patient_id` int(11) unsigned NOT NULL,\r\n         `rabais` FLOAT DEFAULT '0' NOT NULL,\r\n         `ouverture` date NOT NULL,\r\n         `cloture` date,\r\n         `du_patient` float NOT NULL DEFAULT '0.0',\r\n         `du_tiers` float NOT NULL DEFAULT '0.0',\r\n         PRIMARY KEY (`factureconsult_id`),\r\n         INDEX (`patient_id`) )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE factureconsult \r\n              ADD INDEX (`ouverture`), \r\n              ADD INDEX (`cloture`);";
     $this->addQuery($query);
     $this->makeRevision("1.50");
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `type_facture` enum ('maladie','accident') NOT NULL default 'maladie';";
     $this->addQuery($query);
     $query = "ALTER TABLE `reglement`\r\n      CHANGE `consultation_id` `object_id` INT(11) UNSIGNED ,\r\n      ADD `object_class`  ENUM ('CConsultation','CFactureConsult') NOT NULL default 'CConsultation';";
     $this->addQuery($query);
     $this->makeRevision("1.51");
     $query = "ALTER TABLE `consultation` \r\n              ADD `factureconsult_id` INT(11) UNSIGNED NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.52");
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `patient_date_reglement` DATE,\r\n              ADD `tiers_date_reglement` DATE;";
     $this->addQuery($query);
     $query = "ALTER TABLE `factureconsult`\r\n      CHANGE `rabais` `remise` FLOAT DEFAULT '0' NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.53");
     $this->addPrefQuery("viewWeeklyConsultCalendar", "0");
     $this->makeRevision("1.54");
     $query = "ALTER TABLE `consultation` \r\n              ADD INDEX (`grossesse_id`),\r\n              ADD INDEX (`factureconsult_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.55");
     $query = "ALTER TABLE `factureconsult` \r\n              CHANGE `remise` `remise` DECIMAL (10,2) DEFAULT  '0';";
     $this->addQuery($query);
     $this->makeRevision("1.56");
     $query = "ALTER TABLE `tarifs` ADD `codes_caisse` VARCHAR(255);";
     $this->addQuery($query);
     $this->makeRevision("1.57");
     $query = "ALTER TABLE `reglement` \r\n              CHANGE `mode` `mode` ENUM( 'cheque', 'CB', 'especes', 'virement', 'BVR', 'autre' ),\r\n              ADD `num_bvr` VARCHAR(50);";
     $this->addQuery($query);
     $this->makeRevision("1.58");
     $query = "ALTER TABLE `plageconsult`\r\n              ADD `color` VARCHAR(6) NOT NULL DEFAULT 'DDDDDD' ;";
     $this->addQuery($query);
     $this->makeRevision("1.59");
     $query = "ALTER TABLE `factureconsult`\r\n              ADD `npq`  ENUM('0','1') DEFAULT '0',\r\n              ADD `cession_creance` ENUM('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.60");
     $query = "ALTER TABLE `examigs` \r\n              ADD `sejour_id` INT (11) UNSIGNED NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `examigs` ADD INDEX (`sejour_id`);";
     $this->addQuery($query);
     $query = "UPDATE `examigs`\r\n              SET examigs.sejour_id = (SELECT sejour.sejour_id\r\n                               FROM sejour\r\n                               LEFT JOIN consultation_anesth ON sejour.sejour_id = consultation_anesth.sejour_id\r\n                               WHERE consultation_anesth.consultation_id = examigs.consultation_id);";
     $this->addQuery($query);
     $query = "UPDATE `examigs`\r\n              SET sejour_id = (SELECT sejour.sejour_id\r\n                               FROM sejour\r\n                               LEFT JOIN operations ON operations.sejour_id = sejour.sejour_id\r\n                               LEFT JOIN consultation_anesth ON operations.operation_id = consultation_anesth.operation_id\r\n                               WHERE consultation_anesth.consultation_id = examigs.consultation_id)\r\n              WHERE examigs.sejour_id = '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `examigs` DROP `consultation_id`;";
     $this->addQuery($query);
     $this->makeRevision("1.61");
     $query = "UPDATE `plageconsult`\r\n              SET color = 'DDDDDD'\r\n              WHERE color = 'DDD'";
     $this->addQuery($query);
     $this->makeRevision("1.62");
     $query = "ALTER TABLE `consultation`\r\n              ADD `derniere` ENUM ('0','1') DEFAULT '0' AFTER `premiere`;";
     $this->addQuery($query);
     $this->makeRevision("1.63");
     $query = "ALTER TABLE `factureconsult`\r\n              ADD `facture`  ENUM('-1','0','1') DEFAULT '0',\r\n              ADD `assurance`  INT(11) UNSIGNED NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.64");
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `praticien_id` INT (11) UNSIGNED AFTER `patient_id`,\r\n              CHANGE `npq` `npq` ENUM ('0','1') NOT NULL DEFAULT '0',\r\n              CHANGE `cession_creance` `cession_creance` ENUM ('0','1') NOT NULL DEFAULT '0',\r\n              CHANGE `facture` `facture` ENUM ('-1','0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `factureconsult` \r\n              ADD INDEX (`praticien_id`),\r\n              ADD INDEX (`ouverture`),\r\n              ADD INDEX (`cloture`),\r\n              ADD INDEX (`patient_date_reglement`),\r\n              ADD INDEX (`tiers_date_reglement`),\r\n              ADD INDEX (`assurance`);";
     $this->addQuery($query);
     $query = "UPDATE `factureconsult`\r\n              SET `factureconsult`.praticien_id = (SELECT plageconsult.chir_id\r\n                               FROM  plageconsult , consultation\r\n                               WHERE consultation.factureconsult_id = `factureconsult`.factureconsult_id\r\n                               AND plageconsult.plageconsult_id = consultation.plageconsult_id\r\n                               LIMIT 1)\r\n              WHERE factureconsult.praticien_id IS NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.65");
     $query = "ALTER TABLE `factureconsult`\r\n              ADD `ref_accident` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.66");
     $query = "ALTER TABLE `consultation`\r\n      ADD `brancardage` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.67");
     $query = "ALTER TABLE `consultation_anesth`\r\n      ADD `intub_difficile` ENUM ('0','1');";
     $this->addQuery($query);
     $this->makeRevision("1.68");
     $query = "ALTER TABLE `examigs` CHANGE `diurese` `diurese` ENUM('11','12','4','0');";
     $this->addQuery($query);
     $this->makeRevision("1.69");
     $query = "ALTER TABLE `examigs` \r\n      ADD `date` DATETIME AFTER examigs_id";
     $this->addQuery($query);
     $this->makeRevision("1.70");
     $query = "ALTER TABLE `plageconsult` \r\n                ADD `pct_retrocession` INT (11) DEFAULT '70';";
     $this->addQuery($query);
     $query = "ALTER TABLE `plageconsult` \r\n                ADD INDEX (`remplacant_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.71");
     $query = "ALTER TABLE `plageconsult` \r\n                CHANGE `pct_retrocession` `pct_retrocession` FLOAT DEFAULT '70';";
     $this->addQuery($query);
     $this->makeRevision("1.72");
     $query = "ALTER TABLE `examigs` \r\n                CHANGE `glascow` `glasgow` ENUM('26','13','7','5','0');";
     $this->addQuery($query);
     $this->makeRevision("1.73");
     $this->addPrefQuery("empty_form_atcd", "0");
     $this->makeRevision("1.74");
     $this->addPrefQuery("new_semainier", "0");
     $this->makeRevision("1.75");
     $query = "UPDATE consultation, factureconsult\r\n                SET consultation.patient_date_reglement = factureconsult.patient_date_reglement\r\n                WHERE consultation.factureconsult_id = factureconsult.factureconsult_id";
     $this->addQuery($query);
     $this->makeRevision("1.76");
     $query = "ALTER TABLE `reglement` \r\n                ADD `reference` VARCHAR (255)";
     $this->addQuery($query);
     $this->makeRevision("1.77");
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `statut_pro` ENUM ('chomeur','salarie','independant','non_travailleur','sans_emploi','etudiant');";
     $this->addQuery($query);
     $this->makeRevision("1.78");
     $query = "ALTER TABLE `plageconsult` \r\n              ADD `pour_compte_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `plageconsult` \r\n              ADD INDEX (`pour_compte_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.79");
     $query = "ALTER TABLE `factureconsult` \r\n              CHANGE `assurance` `assurance_base` INT (11) UNSIGNED,\r\n              ADD `assurance_complementaire` INT (11) UNSIGNED,\r\n              CHANGE `statut_pro` `statut_pro` ENUM ('chomeur','etudiant','non_travailleur','independant','salarie','sans_emploi');";
     $this->addQuery($query);
     $query = "ALTER TABLE `factureconsult` \r\n              ADD INDEX (`assurance_base`),\r\n              ADD INDEX (`assurance_complementaire`);";
     $this->addQuery($query);
     $this->makeRevision("1.80");
     $query = "ALTER TABLE `factureconsult` DROP INDEX `assurance`";
     $this->addQuery($query);
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `send_assur_base` ENUM ('0','1') DEFAULT '0',\r\n              ADD `send_assur_compl` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.81");
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `num_reference` VARCHAR (27);";
     $this->addQuery($query);
     $this->makeRevision("1.82");
     $this->addPrefQuery("order_mode_grille", "");
     $this->makeRevision("1.83");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `facturable` ENUM ('0','1') NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("1.84");
     $query = "ALTER TABLE `factureconsult` \r\n              CHANGE `assurance_base` `assurance_maladie` INT (11) UNSIGNED,\r\n              CHANGE `assurance_complementaire` `assurance_accident` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.85");
     $this->addDependency("dPplanningOp", "1.70");
     $query = "ALTER TABLE `consultation_anesth` \r\n              DROP `position`,\r\n              DROP `ASA`;";
     $this->addQuery($query);
     $this->makeRevision("1.86");
     $query = "ALTER TABLE `factureconsult` \r\n              ADD `envoi_xml` ENUM ('0','1') DEFAULT '1',\r\n              CHANGE `factureconsult_id` `facture_id` INT (11) UNSIGNED NOT NULL auto_increment,\r\n              ADD `rques_assurance_maladie` TEXT,\r\n              ADD `rques_assurance_accident` TEXT;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation` \r\n              CHANGE `factureconsult_id` `facture_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `reglement` \r\n              CHANGE `object_class` `object_class` ENUM ('CConsultation','CFactureConsult','CFactureCabinet','CFactureEtablissement') NOT NULL DEFAULT 'CConsultation';";
     $this->addQuery($query);
     $query = "RENAME TABLE `factureconsult` TO `facture_cabinet`;";
     $this->addQuery($query);
     $query = "UPDATE reglement\r\n                SET reglement.object_class = 'CFactureCabinet'\r\n                WHERE reglement.object_class = 'CFactureConsult';";
     $this->addQuery($query);
     $query = "ALTER TABLE `reglement` \r\n              CHANGE `object_class` `object_class` ENUM ('CConsultation','CFactureCabinet','CFactureEtablissement') NOT NULL DEFAULT 'CConsultation';";
     $this->addQuery($query);
     $this->makeRevision("1.87");
     $query = "UPDATE user_log\r\n                SET user_log.object_class = 'CFactureCabinet'\r\n                WHERE user_log.object_class = 'CFactureConsult';";
     $this->addQuery($query);
     $this->makeRevision("1.88");
     $query = "UPDATE id_sante400\r\n                SET id_sante400.object_class = 'CFactureCabinet'\r\n                WHERE id_sante400.object_class = 'CFactureConsult';";
     $this->addQuery($query);
     $this->makeRevision("1.89");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `lieu` ENUM('C', 'D') DEFAULT 'C' NOT NULL,\r\n                ADD `exoneration` ENUM('N', '13', '15', '17', '19') DEFAULT 'N' NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.90");
     $query = "ALTER TABLE `consultation`\r\n                ADD `num_at` INT (11) AFTER `date_at`,\r\n                ADD `cle_at` INT (11) AFTER `num_at`";
     $this->addQuery($query);
     $this->makeRevision("1.91");
     $query = "ALTER TABLE `consultation`\r\n                ADD `type_assurance` ENUM('classique','at','maternite','smg');";
     $this->addQuery($query);
     $this->makeRevision("1.92");
     $query = "ALTER TABLE `facture_cabinet` \r\n              ADD `consultation_id` INT (11);";
     $this->addQuery($query);
     $query = "INSERT INTO `facture_cabinet` (`patient_id` ,`praticien_id`,`ouverture`,`cloture`,`du_patient`,`du_tiers`,`patient_date_reglement`,`tiers_date_reglement`, `consultation_id`)\r\n        SELECT c.patient_id, p.chir_id, p.date, p.date, c.du_patient, c.du_tiers,\r\n          c.patient_date_reglement, c.tiers_date_reglement, c.consultation_id\r\n        FROM consultation c, plageconsult p\r\n        WHERE c.facture_id IS NULL\r\n        AND c.plageconsult_id = p.plageconsult_id\r\n        AND c.valide = '1'\r\n        GROUP BY c.consultation_id;";
     $this->addQuery($query);
     $query = "UPDATE consultation c, facture_cabinet f\r\n          SET c.facture_id = f.facture_id\r\n          WHERE c.consultation_id = f.consultation_id;";
     $this->addQuery($query);
     $query = "UPDATE reglement r, consultation c, facture_cabinet f\r\n          SET r.object_id = f.facture_id,\r\n              r.object_class = 'CFactureCabinet'\r\n          WHERE r.object_id = c.consultation_id\r\n          AND r.object_class = 'CConsultation'\r\n          AND f.consultation_id = c.consultation_id;";
     $this->addQuery($query);
     $query = "ALTER TABLE `facture_cabinet` \r\n              DROP `consultation_id`;";
     $this->addQuery($query);
     $this->makeRevision("1.93");
     $query = "ALTER TABLE `reglement` \r\n              CHANGE `object_class` `object_class` ENUM ('CFactureCabinet','CFactureEtablissement') NOT NULL DEFAULT 'CFactureCabinet';";
     $this->addQuery($query);
     $this->makeRevision("1.94");
     $query = "ALTER TABLE `acte_ngap`\r\n              ADD `ald` ENUM ('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.95");
     $this->addPrefQuery("create_dossier_anesth", "1");
     $this->makeRevision("1.96");
     $this->addDependency("dPfacturation", "0.21");
     $this->makeRevision("1.97");
     $query = "UPDATE plageconsult p\r\n              SET p.remplacant_id = NULL\r\n              WHERE p.chir_id = p.remplacant_id;";
     $this->addQuery($query);
     $query = "UPDATE plageconsult p\r\n              SET p.pour_compte_id = NULL\r\n              WHERE p.chir_id = p.pour_compte_id;";
     $this->addQuery($query);
     $this->makeRevision("1.98");
     $query = "ALTER TABLE `tarifs` \r\n                ADD `group_id` INT (11) UNSIGNED";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs` \r\n                    ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.99");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `numero_dent` TINYINT (4) UNSIGNED,\r\n                ADD `comment` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("2.00");
     $query = "ALTER TABLE `facture_cabinet` \r\n                CHANGE `statut_pro` `statut_pro` ENUM ('chomeur','etudiant','non_travailleur','independant','invalide','militaire','retraite','salarie_fr','salarie_sw','sans_emploi');";
     $this->addQuery($query);
     $this->makeRevision("2.01");
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `plus_de_55_ans` ENUM ('0','1') DEFAULT '0' AFTER `intub_difficile`,\r\n                ADD `imc_sup_26` ENUM ('0','1') DEFAULT '0' AFTER `plus_de_55_ans`,\r\n                ADD `edentation` ENUM ('0','1') DEFAULT '0' AFTER `imc_sup_26`,\r\n                ADD `ronflements` ENUM ('0','1') DEFAULT '0' AFTER `edentation`,\r\n                ADD `barbe` ENUM ('0','1') DEFAULT '0' AFTER `ronflements`;";
     $this->addQuery($query);
     $this->makeRevision("2.02");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `execution` DATETIME NOT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap`\r\n                INNER JOIN `consultation` ON (`acte_ngap`.`object_id` = `consultation`.`consultation_id`)\r\n                INNER JOIN `plageconsult` ON (`consultation`.`plageconsult_id` = `plageconsult`.`plageconsult_id`)\r\n                SET `acte_ngap`.`execution` = CONCAT(`plageconsult`.`date`, ' ', `consultation`.`heure`)\r\n                WHERE `acte_ngap`.`object_class` = 'CConsultation';";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap`\r\n                INNER JOIN `operations` ON (`acte_ngap`.`object_id` = `operations`.`operation_id`)\r\n                INNER JOIN `plagesop` ON (`operations`.`plageop_id` = `plagesop`.`plageop_id`)\r\n                SET `acte_ngap`.`execution` = CONCAT(`plagesop`.`date`, ' ', `operations`.`time_operation`)\r\n                WHERE `acte_ngap`.`object_class` = 'COperation'\r\n                AND `operations`.`date` IS NULL;";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap`\r\n                INNER JOIN `operations` ON (`acte_ngap`.`object_id` = `operations`.`operation_id`)\r\n                SET `acte_ngap`.`execution` = CONCAT(`operations`.`date`, ' ', `operations`.`time_operation`)\r\n                WHERE `acte_ngap`.`object_class` = 'COperation'\r\n                AND `operations`.`date` IS NOT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `acte_ngap`\r\n                INNER JOIN `sejour` ON (`acte_ngap`.`object_id` = `sejour`.`sejour_id`)\r\n                SET `acte_ngap`.`execution` = `sejour`.`entree`\r\n                WHERE `acte_ngap`.`object_class` = 'CSejour';";
     $this->addQuery($query);
     $this->makeRevision("2.03");
     $query = "UPDATE `plageconsult`\r\n                SET `plageconsult`.`freq` = '00:15:00'\r\n                WHERE `plageconsult`.`freq` < '00:05:00';";
     $this->addQuery($query);
     $this->makeRevision("2.04");
     $this->addPrefQuery("showIntervPlanning", "0");
     $this->makeRevision("2.05");
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `annule` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.06");
     $query = "ALTER TABLE `plageconsult`\r\n      ADD `pour_tiers` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.07");
     $query = "ALTER TABLE `reglement`\r\n                ADD `tireur` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("2.08");
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `definitive` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.09");
     $this->addPrefQuery("NbConsultMultiple", 4);
     $this->makeRevision("2.10");
     $query = "ALTER TABLE `facture_cabinet`\r\n                CHANGE `type_facture` `type_facture` ENUM ('maladie','accident','esthetique') NOT NULL DEFAULT 'maladie';";
     $this->addQuery($query);
     $this->makeRevision("2.11");
     $query = "ALTER TABLE `reglement`\r\n                ADD `debiteur_id` INT (11) UNSIGNED,\r\n                ADD `debiteur_desc` VARCHAR (255);";
     $this->addQuery($query);
     $query = "ALTER TABLE `reglement`\r\n                ADD INDEX (`debiteur_id`);";
     $this->addQuery($query);
     $this->makeRevision("2.12");
     $query = "ALTER TABLE `consultation_anesth`\r\n              ADD `result_autre` TEXT AFTER `result_rp`;";
     $this->addQuery($query);
     $this->addPrefQuery("viewAutreResult", "0");
     $this->makeRevision("2.13");
     $this->addPrefQuery("use_acte_date_now", "0");
     $this->makeRevision("2.14");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `num_facture` INT (11) UNSIGNED NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `numero` INT (11) UNSIGNED NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("2.15");
     $query = "ALTER TABLE `consultation`\r\n                ADD `secteur3` FLOAT( 6 ) DEFAULT '0' NOT NULL,\r\n                ADD `du_tva` FLOAT( 6 ) DEFAULT '0' NOT NULL,\r\n                ADD `taux_tva` ENUM ('0', '19.6');";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs`\r\n                ADD `secteur3` FLOAT( 6 ) DEFAULT '0' NOT NULL,\r\n                ADD `taux_tva` ENUM ('0', '19.6');";
     $this->addQuery($query);
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `du_tva` DECIMAL (10,2) DEFAULT '0',\r\n                ADD `taux_tva` ENUM ('0', '19.6') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.16");
     $this->addPrefQuery("multi_popups_resume", "1");
     $this->makeRevision("2.17");
     $this->addPrefQuery("allow_plage_holiday", "1");
     $this->makeRevision("2.18");
     $query = "ALTER TABLE `reglement`\r\n                ADD `lock` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.19");
     // On supprime les champs inutiles des consultations
     $query = 'ALTER TABLE `consultation`
   DROP `tiers_mode_reglement`,
   DROP `patient_mode_reglement`,
   DROP `banque_id`;';
     $this->addQuery($query);
     // On supprime le champ facture_id de consult
     // !Ne pas décommenter!
     /*$query = "ALTER TABLE `consultation` DROP `facture_id`;";
       $this->addQuery($query);*/
     $this->makeRevision("2.20");
     // On supprime les champs inutiles des consultations anesth
     $query = "ALTER TABLE `consultation_anesth`\r\n      DROP `poid`,\r\n      DROP `taille`,\r\n      DROP `tasys`,\r\n      DROP `tadias`,\r\n      DROP `pouls`,\r\n      DROP `spo2`;";
     $this->addQuery($query);
     // On supprime les champs inutiles des consultations anesth
     // !Ne pas décommenter!
     /*$query = "ALTER TABLE `consultation_anesth`
         DROP `groupe`,
         DROP `groupe_ok`,
         DROP `rhesus`;";
       $this->addQuery($query);*/
     $this->makeRevision("2.21");
     $this->addPrefQuery("new_consultation", "0");
     $this->makeRevision("2.22");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD INDEX (`execution`);";
     $this->addQuery($query);
     $this->makeRevision("2.23");
     $this->addPrefQuery("today_ref_consult_multiple", "1");
     $this->makeRevision("2.24");
     $query = "ALTER TABLE `facture_cabinet`\r\n                CHANGE `taux_tva` `taux_tva` FLOAT DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `tarifs`\r\n                CHANGE `taux_tva` `taux_tva` FLOAT DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation`\r\n                CHANGE `taux_tva` `taux_tva` FLOAT DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.25");
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `group_id` INT (11) UNSIGNED NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD INDEX (`group_id`);";
     $this->addQuery($query);
     //Facture de cabinet de consultation
     $query = "UPDATE facture_cabinet, users_mediboard, functions_mediboard\r\n          SET facture_cabinet.group_id = functions_mediboard.group_id\r\n          WHERE facture_cabinet.praticien_id = users_mediboard.user_id\r\n          AND functions_mediboard.function_id = users_mediboard.function_id";
     $this->addQuery($query);
     $this->makeRevision("2.26");
     $query = "ALTER TABLE `acte_ngap`\r\n                MODIFY `code` VARCHAR(5) NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("2.27");
     $query = "ALTER TABLE `consultation`\r\n      CHANGE `duree` `duree` INT (4) UNSIGNED NOT NULL DEFAULT '1'";
     $this->addQuery($query);
     $this->makeRevision("2.28");
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `major_pct` INT (11),\r\n                ADD `major_coef` FLOAT,\r\n                ADD `minor_pct` INT (11),\r\n                ADD `minor_coef` FLOAT,\r\n                ADD `numero_forfait_technique` INT (11) UNSIGNED,\r\n                ADD `numero_agrement` BIGINT (20) UNSIGNED,\r\n                ADD `rapport_exoneration` ENUM ('4','7','C','R');";
     $this->addQuery($query);
     $this->makeRevision("2.29");
     $this->addDefaultConfig("dPcabinet CPrescription view_prescription");
     $this->makeRevision('2.30');
     $query = "ALTER TABLE `examigs`\r\n                ADD `simplified_igs` INT(11);";
     $this->addQuery($query);
     $this->makeRevision('2.31');
     $query = "UPDATE consultation_anesth, operations\r\n          SET consultation_anesth.sejour_id = operations.sejour_id\r\n          WHERE consultation_anesth.sejour_id IS NULL\r\n          AND consultation_anesth.operation_id IS NOT NULL\r\n          AND operations.operation_id = consultation_anesth.operation_id";
     $this->addQuery($query);
     $this->makeRevision("2.32");
     $query = "ALTER TABLE `consultation`\r\n      ADD `element_prescription_id` INT (11) UNSIGNED";
     $this->addQuery($query);
     if (CModule::getActive("dPprescription")) {
         $query = "UPDATE `consultation`, `sejour_task`, `prescription_line_element`\r\n        SET `consultation`.`element_prescription_id` = `prescription_line_element`.`element_prescription_id`\r\n        WHERE `sejour_task`.`consult_id` = `consultation`.`consultation_id`\r\n        AND   `sejour_task`.`prescription_line_element_id` = `prescription_line_element`.`prescription_line_element_id`";
         $this->addQuery($query);
     }
     $this->makeRevision('2.33');
     $query = "ALTER TABLE `consultation`\r\n                ADD `org_at` INT(9) UNSIGNED ZEROFILL,\r\n                ADD `feuille_at` ENUM('0', '1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision('2.34');
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `gratuit` ENUM('0', '1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision('2.35');
     // check for old preferences
     $this->addMethod("prefForConsultPratType");
     $this->makeRevision('2.36');
     $query = "ALTER TABLE `consultation`\r\n                ADD `exec_tarif` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `consultation`\r\n                ADD INDEX (`exec_tarif`);";
     $this->addQuery($query);
     $this->makeRevision("2.37");
     $query = "UPDATE `consultation` SET `annule` = '0' WHERE (`annule` = '' OR `annule` IS NULL );";
     $this->addQuery($query);
     $this->makeRevision('2.38');
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `passage_uscpo` ENUM ('0','1'),\r\n                ADD `duree_uscpo` INT (11) UNSIGNED DEFAULT '0',\r\n                ADD `type_anesth` INT (11) UNSIGNED NULL,\r\n                ADD `position` ENUM ('DD','DV','DL','GP','AS','TO','GYN'),\r\n                ADD `ASA` ENUM ('1','2','3','4','5','6'),\r\n                ADD `rques` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("2.39");
     $this->addDefaultConfig("dPcabinet CPrescription view_prescription_externe", "dPcabinet CPrescription view_prescription");
     $this->makeRevision("2.40");
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `piercing` ENUM ('0','1') DEFAULT '0' AFTER `ronflements`;";
     $this->addQuery($query);
     $this->makeRevision("2.41");
     $this->addPrefQuery("take_consult_for_dieteticien", "0");
     $this->makeRevision("2.42");
     $this->addPrefQuery("height_calendar", "2000");
     $this->makeRevision("2.43");
     $this->addPrefQuery("dPcabinet_displayFirstTab", "AntTrait");
     $this->makeRevision("2.44");
     $query = "ALTER TABLE `consultation`\r\n      ADD `consult_related_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("2.45");
     $this->addPrefQuery("show_replication_duplicate", "0");
     $this->makeRevision("2.46");
     $query = "ALTER TABLE `consultation_anesth`\r\n              ADD `mob_cervicale` ENUM( 'm80', '80m100', 'p100' );";
     $this->addQuery($query);
     $this->makeRevision('2.47');
     $query = "ALTER TABLE `acte_ngap`\r\n                CHANGE `object_class` `object_class` ENUM('COperation','CSejour','CConsultation', 'CDevisCodage') NOT NULL default 'CConsultation';";
     $this->addQuery($query);
     $this->makeRevision('2.48');
     $query = "ALTER TABLE `acte_ngap`\r\n                ADD `prescripteur_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision('2.49');
     $query = "ALTER TABLE `banque`\r\n                ADD `departement` VARCHAR (255),\r\n                ADD `boite_postale` VARCHAR (255),\r\n                ADD `adresse` TEXT,\r\n                ADD `cp` VARCHAR (5),\r\n                ADD `ville` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision('2.50');
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `date_cas` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD INDEX (`date_cas`);";
     $this->addQuery($query);
     $this->makeRevision("2.51");
     $this->addPrefQuery("show_plage_holiday", "1");
     $this->makeRevision("2.52");
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD `request_date` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `facture_cabinet`\r\n                ADD INDEX (`request_date`);";
     $this->addQuery($query);
     $this->makeRevision("2.53");
     $query = "ALTER TABLE `consultation`\r\n                ADD `motif_annulation` ENUM ('not_arrived','by_patient')";
     $this->addQuery($query);
     $this->makeRevision("2.54");
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `result_com` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("2.55");
     $query = "ALTER TABLE `facture_cabinet`\r\n                CHANGE `statut_pro` `statut_pro` ENUM ('chomeur','etudiant','non_travailleur','independant','invalide','militaire','retraite','salarie_fr','salarie_sw','sans_emploi','enfant','enceinte');";
     $this->addQuery($query);
     $this->makeRevision("2.56");
     $query = "ALTER TABLE `consultation` ADD INDEX `consult_related_id` (`consult_related_id`)";
     $this->addQuery($query, true);
     $this->makeRevision("2.57");
     $query = "ALTER TABLE `consultation_anesth`\r\n                ADD `strategie_antibio` TEXT;";
     $this->addQuery($query, true);
     $this->mod_version = '2.58';
 }
Beispiel #15
0
 function __construct()
 {
     parent::__construct();
     $this->mod_name = "dPpatients";
     $this->makeRevision("all");
     $query = "CREATE TABLE `patients` (\r\n                `patient_id` INT(11) NOT NULL AUTO_INCREMENT,\r\n                `nom` VARCHAR(50) NOT NULL DEFAULT '',\r\n                `prenom` VARCHAR(50) NOT NULL DEFAULT '',\r\n                `naissance` DATE NOT NULL DEFAULT '0000-00-00',\r\n                `sexe` ENUM('m','f') NOT NULL DEFAULT 'm',\r\n                `adresse` VARCHAR(50) NOT NULL DEFAULT '',\r\n                `ville` VARCHAR(50) NOT NULL DEFAULT '',\r\n                `cp` VARCHAR(5) NOT NULL DEFAULT '',\r\n                `tel` VARCHAR(10) NOT NULL DEFAULT '',\r\n                `medecin_traitant` INT(11) NOT NULL DEFAULT '0',\r\n                `incapable_majeur` ENUM('o','n') NOT NULL DEFAULT 'n',\r\n                `ATNC` ENUM('o','n') NOT NULL DEFAULT 'n',\r\n                `matricule` VARCHAR(15) NOT NULL DEFAULT '',\r\n                `SHS` VARCHAR(10) NOT NULL DEFAULT '',\r\n                PRIMARY KEY  (`patient_id`),\r\n                UNIQUE KEY `patient_id` (`patient_id`),\r\n                KEY `matricule` (`matricule`,`SHS`),\r\n                KEY `nom` (`nom`,`prenom`)\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.1");
     $query = "ALTER TABLE patients\r\n                ADD tel2 VARCHAR( 10 ) AFTER tel ,\r\n                ADD medecin1 INT( 11 ) AFTER medecin_traitant ,\r\n                ADD medecin2 INT( 11 ) AFTER medecin1 ,\r\n                ADD medecin3 INT( 11 ) AFTER medecin2 ,\r\n                ADD rques TEXT;";
     $this->addQuery($query);
     $query = "CREATE TABLE medecin (\r\n                medecin_id INT(11) NOT NULL AUTO_INCREMENT,\r\n                nom VARCHAR(50) NOT NULL DEFAULT '',\r\n                prenom VARCHAR(50) NOT NULL DEFAULT '',\r\n                tel VARCHAR(10) DEFAULT NULL,\r\n                fax VARCHAR(10) DEFAULT NULL,\r\n                email VARCHAR(50) DEFAULT NULL,\r\n                adresse VARCHAR(50) DEFAULT NULL,\r\n                ville VARCHAR(50) DEFAULT NULL,\r\n                cp VARCHAR(5) DEFAULT NULL,\r\n                PRIMARY KEY  (`medecin_id`)\r\n              )/*! ENGINE=MyISAM */ COMMENT='Table des medecins correspondants';";
     $this->addQuery($query);
     $this->makeRevision("0.2");
     $query = "ALTER TABLE medecin\r\n                ADD specialite TEXT AFTER prenom ;";
     $this->addQuery($query);
     $this->makeRevision("0.21");
     $query = "ALTER TABLE medecin\r\n                ADD disciplines TEXT AFTER prenom ;";
     $this->addQuery($query);
     $this->makeRevision("0.22");
     $query = "ALTER TABLE `medecin`\r\n                CHANGE `adresse` `adresse` TEXT DEFAULT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.23");
     $query = "ALTER TABLE `medecin`\r\n                ADD INDEX ( `nom` ),\r\n                ADD INDEX ( `prenom` ),\r\n                ADD INDEX ( `cp` ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.24");
     $query = "ALTER TABLE `patients`\r\n                ADD `nom_jeune_fille` VARCHAR( 50 ) NOT NULL AFTER `nom` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                CHANGE `sexe` `sexe` ENUM( 'm', 'f', 'j' ) DEFAULT 'm' NOT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.25");
     $query = "ALTER TABLE `patients` CHANGE `adresse` `adresse` TEXT NOT NULL ";
     $this->addQuery($query);
     $this->makeRevision("0.26");
     $query = "CREATE TABLE `antecedent` (\r\n                `antecedent_id` BIGINT NOT NULL AUTO_INCREMENT ,\r\n                `patient_id` BIGINT NOT NULL ,\r\n                `type` ENUM( 'trans', 'obst', 'chir', 'med' ) DEFAULT 'med' NOT NULL ,\r\n                `date` DATE,\r\n                `rques` TEXT,\r\n                PRIMARY KEY ( `antecedent_id` ) ,\r\n                INDEX ( `patient_id` )\r\n              ) /*! ENGINE=MyISAM */ COMMENT = 'antecedents des patients';";
     $this->addQuery($query);
     $this->makeRevision("0.27");
     $query = "ALTER TABLE `antecedent`\r\n                CHANGE `type` `type` ENUM( 'trans', 'obst', 'chir', 'med', 'fam' ) DEFAULT 'med' NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD `listCim10` TEXT DEFAULT NULL ;";
     $this->addQuery($query);
     $query = "CREATE TABLE `traitement` (\r\n                `traitement_id` BIGINT NOT NULL AUTO_INCREMENT ,\r\n                `patient_id` BIGINT NOT NULL ,\r\n                `debut` DATE DEFAULT '0000-00-00' NOT NULL ,\r\n                `fin` DATE,\r\n                `traitement` TEXT,\r\n                PRIMARY KEY ( `traitement_id` ) ,\r\n                INDEX ( `patient_id` )\r\n              ) /*! ENGINE=MyISAM */ COMMENT = 'traitements des patients';";
     $this->addQuery($query);
     $this->makeRevision("0.28");
     $query = "ALTER TABLE `patients`\r\n                CHANGE `SHS` `regime_sante` VARCHAR( 40 );";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD `SHS` VARCHAR( 8 ) AFTER `matricule`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD INDEX ( `SHS` );";
     $this->addQuery($query);
     $this->makeRevision("0.29");
     $query = "ALTER TABLE `patients` DROP INDEX `patient_id` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` DROP INDEX `nom` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `nom` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `prenom` ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.30");
     $query = "ALTER TABLE `antecedent` CHANGE `type` `type`\r\n                ENUM( 'trans', 'obst', 'chir', 'med', 'fam', 'alle' ) NOT NULL DEFAULT 'med';";
     $this->addQuery($query);
     $this->makeRevision("0.31");
     $query = "ALTER TABLE `patients` ADD `cmu` date NULL AFTER `matricule` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD `ald` text AFTER `rques` ;";
     $this->addQuery($query);
     $this->makeRevision("0.32");
     $query = "UPDATE `medecin` SET `tel` = NULL WHERE `tel`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `fax` = NULL WHERE `fax`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `email` = NULL WHERE `email`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `specialite` = NULL WHERE `specialite`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `disciplines` = NULL WHERE `disciplines`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `adresse` = NULL WHERE `adresse`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `ville` = NULL WHERE `ville`='NULL' ;";
     $this->addQuery($query);
     $query = "UPDATE `medecin` SET `cp` = NULL WHERE `cp` LIKE 'NULL%' ;";
     $this->addQuery($query);
     $this->makeRevision("0.33");
     $query = "ALTER TABLE `medecin` ADD `jeunefille` VARCHAR( 50 ) AFTER `prenom` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `medecin` ADD `complementaires` TEXT AFTER `disciplines` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `medecin` ADD `orientations` TEXT AFTER `disciplines` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `medecin` DROP `specialite` ;";
     $this->addQuery($query);
     $this->makeRevision("0.34");
     $query = "ALTER TABLE `patients`\r\n                ADD `pays` VARCHAR( 50 ),\r\n                ADD `nationalite` ENUM( 'local', 'etranger' ) NOT NULL DEFAULT 'local',\r\n                ADD `lieu_naissance` VARCHAR( 50 ),\r\n                ADD `profession` VARCHAR( 50 ),\r\n                ADD `employeur_nom` VARCHAR( 50 ),\r\n                ADD `employeur_adresse` TEXT,\r\n                ADD `employeur_cp` VARCHAR( 5 ),\r\n                ADD `employeur_ville` VARCHAR( 50 ),\r\n                ADD `employeur_tel` VARCHAR( 10 ),\r\n                ADD `employeur_urssaf` VARCHAR( 11 ),\r\n                ADD `prevenir_nom` VARCHAR( 50 ),\r\n                ADD `prevenir_prenom` VARCHAR( 50 ),\r\n                ADD `prevenir_adresse` TEXT,\r\n                ADD `prevenir_cp` VARCHAR( 5 ),\r\n                ADD `prevenir_ville` VARCHAR( 50 ),\r\n                ADD `prevenir_tel` VARCHAR( 10 ),\r\n                ADD `prevenir_parente` ENUM( 'conjoint', 'enfant', 'ascendant', 'colateral', 'divers' ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.35");
     $query = "ALTER TABLE `antecedent` CHANGE `type` `type`\r\n                ENUM( 'med', 'alle', 'trans', 'obst', 'chir', 'fam', 'anesth' ) NOT NULL DEFAULT 'med';";
     $this->addQuery($query);
     $this->makeRevision("0.36");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `antecedent`\r\n                CHANGE `antecedent_id` `antecedent_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `patient_id` `patient_id` int(11) unsigned NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `medecin`\r\n                CHANGE `medecin_id` `medecin_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `nom` `nom` varchar(255) NOT NULL,\r\n                CHANGE `prenom` `prenom` varchar(255) NOT NULL,\r\n                CHANGE `jeunefille` `jeunefille` varchar(255) NULL,\r\n                CHANGE `ville` `ville` varchar(255) NULL,\r\n                CHANGE `cp` `cp` int(5) unsigned zerofill NULL,\r\n                CHANGE `tel` `tel` bigint(10) unsigned zerofill NULL,\r\n                CHANGE `fax` `fax` bigint(10) unsigned zerofill NULL,\r\n                CHANGE `email` `email` varchar(255) NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                CHANGE `patient_id` `patient_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `nom` `nom` varchar(255) NOT NULL,\r\n                CHANGE `nom_jeune_fille` `nom_jeune_fille` varchar(255) NULL,\r\n                CHANGE `prenom` `prenom` varchar(255) NOT NULL,\r\n                CHANGE `ville` `ville` varchar(255) NOT NULL,\r\n                CHANGE `medecin_traitant` `medecin_traitant` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `medecin1` `medecin1` int(11) unsigned NULL,\r\n                CHANGE `medecin2` `medecin2` int(11) unsigned NULL,\r\n                CHANGE `medecin3` `medecin3` int(11) unsigned NULL,\r\n                CHANGE `regime_sante` `regime_sante` varchar(255) NULL,\r\n                CHANGE `pays` `pays` varchar(255) NULL,\r\n                CHANGE `cp` `cp` int(5) unsigned zerofill NULL,\r\n                CHANGE `tel` `tel` bigint(10) unsigned zerofill NULL,\r\n                CHANGE `tel2` `tel2` bigint(10) unsigned zerofill NULL,\r\n                CHANGE `SHS` `SHS` int(8) unsigned zerofill NULL,\r\n                CHANGE `employeur_cp` `employeur_cp` int(5) unsigned zerofill NULL,\r\n                CHANGE `employeur_tel` `employeur_tel` bigint(10) unsigned zerofill NULL,\r\n                CHANGE `employeur_urssaf` `employeur_urssaf` bigint(11) unsigned zerofill NULL,\r\n                CHANGE `prevenir_cp` `prevenir_cp` int(5) unsigned zerofill NULL,\r\n                CHANGE `prevenir_tel` `prevenir_tel` bigint(10) unsigned zerofill NULL,\r\n                CHANGE `lieu_naissance` `lieu_naissance` varchar(255) NULL,\r\n                CHANGE `profession` `profession` varchar(255) NULL,\r\n                CHANGE `employeur_nom` `employeur_nom` varchar(255) NULL,\r\n                CHANGE `employeur_ville` `employeur_ville` varchar(255) NULL,\r\n                CHANGE `prevenir_nom` `prevenir_nom` varchar(255) NULL,\r\n                CHANGE `prevenir_prenom` `prevenir_prenom` varchar(255) NULL,\r\n                CHANGE `prevenir_ville` `prevenir_ville` varchar(255) NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n                CHANGE `traitement_id` `traitement_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `patient_id` `patient_id` int(11) unsigned NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                CHANGE `ATNC` `ATNC` enum('o','n','0','1') NOT NULL DEFAULT 'n',\r\n                CHANGE `incapable_majeur` `incapable_majeur` enum('o','n','0','1') NOT NULL DEFAULT 'n';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `ATNC`='0' WHERE `ATNC`='n';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `ATNC`='1' WHERE `ATNC`='o';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `incapable_majeur`='0' WHERE `incapable_majeur`='n';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `incapable_majeur`='1' WHERE `incapable_majeur`='o';";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                CHANGE `ATNC` `ATNC` enum('0','1') NOT NULL DEFAULT '0',\r\n                CHANGE `incapable_majeur` `incapable_majeur` enum('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.37");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `patients`\r\n                ADD `nom_soundex2`    VARCHAR(255) DEFAULT NULL AFTER `nom_jeune_fille`,\r\n                ADD `prenom_soundex2` VARCHAR(255) DEFAULT NULL AFTER `nom_soundex2`,\r\n                ADD `nomjf_soundex2`  VARCHAR(255) DEFAULT NULL AFTER `prenom_soundex2`;";
     $this->addQuery($query);
     $this->addMethod("createSoundex");
     $this->makeRevision("0.38");
     $query = "ALTER TABLE `patients` ADD `rang_beneficiaire` enum('1','2','11','12','13') NULL AFTER `ald`;";
     $this->addQuery($query);
     $this->makeRevision("0.39");
     $query = "ALTER TABLE `traitement` CHANGE `debut` `debut` date NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.40");
     $query = "ALTER TABLE `antecedent`\r\n                CHANGE `patient_id` `object_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                ADD `object_class` enum('CPatient','CConsultAnesth') NOT NULL DEFAULT 'CPatient';";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n                CHANGE `patient_id` `object_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                ADD `object_class` enum('CPatient','CConsultAnesth') NOT NULL DEFAULT 'CPatient';";
     $this->addQuery($query);
     $this->makeRevision("0.41");
     $query = "ALTER TABLE `patients` CHANGE `medecin_traitant` `medecin_traitant` int(11) unsigned NULL DEFAULT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `medecin_traitant` = NULL WHERE `medecin_traitant`='0';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `medecin1` = NULL WHERE `medecin1`='0';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `medecin2` = NULL WHERE `medecin2`='0';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `medecin3` = NULL WHERE `medecin3`='0';";
     $this->addQuery($query);
     $this->makeRevision("0.42");
     $this->addDependency("dPcabinet", "0.60");
     $query = "ALTER TABLE `addiction`\r\n                CHANGE `object_class` `object_class` enum('CPatient','CConsultAnesth') NOT NULL DEFAULT 'CPatient';";
     $this->addQuery($query);
     $this->makeRevision("0.43");
     $query = "ALTER TABLE `antecedent`\r\n                CHANGE `type` `type` enum('med','alle','trans','obst','chir','fam','anesth','gyn') NOT NULL DEFAULT 'med';";
     $this->addQuery($query);
     $this->makeRevision("0.44");
     $query = "ALTER TABLE `patients`\r\n                ADD `assure_nom` VARCHAR(255),\r\n                ADD `assure_nom_jeune_fille` VARCHAR(255),\r\n                ADD `assure_prenom` VARCHAR(255),\r\n                ADD `assure_naissance` DATE,\r\n                ADD `assure_sexe` ENUM('m','f','j'),\r\n                ADD `assure_adresse` TEXT,\r\n                ADD `assure_ville` VARCHAR(255),\r\n                ADD `assure_cp` INT(5) UNSIGNED ZEROFILL,\r\n                ADD `assure_tel` BIGINT(10) UNSIGNED ZEROFILL,\r\n                ADD `assure_tel2` BIGINT(10) UNSIGNED ZEROFILL,\r\n                ADD `assure_pays` VARCHAR(255),\r\n                ADD `assure_nationalite` ENUM('local','etranger') NOT NULL,\r\n                ADD `assure_lieu_naissance` VARCHAR(255),\r\n                ADD `assure_profession` VARCHAR(255),\r\n                ADD `assure_rques` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("0.45");
     $query = "ALTER TABLE `patients`\r\n                CHANGE `rang_beneficiaire` `rang_beneficiaire` ENUM('01','02','11','12','13');";
     $this->addQuery($query);
     $this->makeRevision("0.46");
     $query = "ALTER TABLE `patients`\r\n                ADD `assure_matricule` VARCHAR(15);";
     $this->addQuery($query);
     $this->makeRevision("0.47");
     $query = "ALTER TABLE `patients`\r\n                ADD `rang_naissance` ENUM('1','2','3','4','5','6');";
     $this->addQuery($query);
     $this->makeRevision("0.48");
     $query = "ALTER TABLE `patients`\r\n                ADD `code_regime` TINYINT(2) UNSIGNED ZEROFILL,\r\n                ADD `caisse_gest` MEDIUMINT(3) UNSIGNED ZEROFILL,\r\n                ADD `centre_gest` MEDIUMINT(4) UNSIGNED ZEROFILL,\r\n                ADD `fin_validite_vitale` DATE;";
     $this->addQuery($query);
     $this->makeRevision("0.49");
     $query = "ALTER TABLE `patients`\r\n                CHANGE `rang_beneficiaire` `rang_beneficiaire` ENUM('01','02','09','11','12','13','14','15','16','31');";
     $this->addQuery($query);
     // Creation de la table dossier medical
     $this->makeRevision("0.50");
     CApp::setTimeLimit(60);
     $this->addDependency("dPcabinet", "0.78");
     $query = "CREATE TABLE `dossier_medical` (\r\n                `dossier_medical_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n                `listCim10` TEXT,\r\n                `object_id` INT(11) UNSIGNED NOT NULL,\r\n                `object_class` VARCHAR(25) NOT NULL,\r\n                PRIMARY KEY (`dossier_medical_id`)\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     // Insertion des patients dans la table dossier_medical
     $query = "INSERT INTO `dossier_medical`\r\n                SELECT '', patients.listCim10, patients.patient_id, 'CPatient'\r\n                FROM `patients`;";
     $this->addQuery($query);
     // Insertion des sejours dans la table dossier_medical
     $query = "INSERT INTO `dossier_medical`\r\n                SELECT '', GROUP_CONCAT(consultation_anesth.listCim10 SEPARATOR '|'), sejour.sejour_id, 'CSejour'\r\n                FROM `consultation_anesth`, `operations`,`sejour`\r\n                WHERE consultation_anesth.operation_id = operations.operation_id\r\n                AND operations.sejour_id = sejour.sejour_id\r\n                GROUP BY sejour.sejour_id;";
     $this->addQuery($query);
     // Suppression des '|' en debut de liste
     $query = "UPDATE `dossier_medical` SET `listCim10` = TRIM(LEADING '|' FROM listCim10)\r\n                WHERE listCim10 LIKE '|%'";
     $this->addquery($query);
     // Ajout du champ dossier_medical_id aux tables addiction/antecedent/traitement
     $query = "ALTER TABLE `addiction`\r\n                ADD `dossier_medical_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `addiction`\r\n                ADD INDEX ( `dossier_medical_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `antecedent`\r\n                ADD `dossier_medical_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `antecedent`\r\n                ADD INDEX ( `dossier_medical_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n                ADD `dossier_medical_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n                ADD INDEX ( `dossier_medical_id` ) ;";
     $this->addQuery($query);
     // Mise a jour du champ dossier_medical_id dans le cas du Patient
     // Table addiction
     $query = "ALTER TABLE `addiction` ADD INDEX ( `object_id` ) ;";
     $this->addQuery($query);
     $query = "UPDATE `addiction`, `dossier_medical` SET addiction.dossier_medical_id = dossier_medical.dossier_medical_id\r\n                WHERE dossier_medical.object_class = 'CPatient'\r\n                AND dossier_medical.object_id = addiction.object_id\r\n                AND addiction.object_class = 'CPatient'";
     $this->addQuery($query);
     // Table antecedent
     $query = "UPDATE `antecedent`, `dossier_medical` SET antecedent.dossier_medical_id = dossier_medical.dossier_medical_id\r\n                WHERE dossier_medical.object_class = 'CPatient'\r\n                AND dossier_medical.object_id = antecedent.object_id\r\n                AND antecedent.object_class = 'CPatient'";
     $this->addQuery($query);
     // Table Traitement
     $query = "UPDATE `traitement`, `dossier_medical` SET traitement.dossier_medical_id = dossier_medical.dossier_medical_id\r\n                WHERE dossier_medical.object_class = 'CPatient'\r\n                AND dossier_medical.object_id = traitement.object_id\r\n                AND traitement.object_class = 'CPatient'";
     $this->addQuery($query);
     // Mise a jour du champs dossier_medical_id dans le cas du Sejour
     // Table addiction
     $query = "UPDATE `addiction`, `dossier_medical`, `consultation_anesth`, `sejour`, `operations`\r\n            SET addiction.dossier_medical_id = dossier_medical.dossier_medical_id\r\n            WHERE addiction.object_id = consultation_anesth.consultation_anesth_id\r\n            AND addiction.object_class = 'CConsultAnesth'\r\n            AND consultation_anesth.operation_id = operations.operation_id\r\n            AND operations.sejour_id = sejour.sejour_id\r\n            AND dossier_medical.object_class = 'CSejour'\r\n            AND dossier_medical.object_id = sejour.sejour_id;";
     $this->addQuery($query);
     // Table antecedent
     $query = "UPDATE `antecedent`, `dossier_medical`, `consultation_anesth`, `sejour`, `operations`\r\n            SET antecedent.dossier_medical_id = dossier_medical.dossier_medical_id\r\n            WHERE antecedent.object_id = consultation_anesth.consultation_anesth_id\r\n            AND antecedent.object_class = 'CConsultAnesth'\r\n            AND consultation_anesth.operation_id = operations.operation_id\r\n            AND operations.sejour_id = sejour.sejour_id\r\n            AND dossier_medical.object_class = 'CSejour'\r\n            AND dossier_medical.object_id = sejour.sejour_id;";
     $this->addQuery($query);
     // Table traitement
     $query = "UPDATE `traitement`, `dossier_medical`, `consultation_anesth`, `sejour`, `operations`\r\n            SET traitement.dossier_medical_id = dossier_medical.dossier_medical_id\r\n            WHERE traitement.object_id = consultation_anesth.consultation_anesth_id\r\n            AND traitement.object_class = 'CConsultAnesth'\r\n            AND consultation_anesth.operation_id = operations.operation_id\r\n            AND operations.sejour_id = sejour.sejour_id\r\n            AND dossier_medical.object_class = 'CSejour'\r\n            AND dossier_medical.object_id = sejour.sejour_id;";
     $this->addQuery($query);
     // Mise a jour du champ examen de la consultation dans le cas d'antecendent sans operation_id
     $query = "CREATE TEMPORARY TABLE ligneAntecedent (\r\n             consultation_id INT( 11 ) ,\r\n             ligne_antecedent TEXT\r\n            ) AS\r\n              SELECT consultation_anesth.consultation_id,\r\n                CONCAT_WS(' - ', antecedent.type, antecedent.date, antecedent.rques ) AS ligne_antecedent\r\n              FROM `antecedent`, `consultation_anesth`\r\n              WHERE antecedent.object_id = consultation_anesth.consultation_anesth_id\r\n              AND antecedent.dossier_medical_id IS NULL;";
     $this->addQuery($query);
     $query = "CREATE TEMPORARY TABLE blocAntecedent (\r\n             consultation_id INT( 11 ) ,\r\n             bloc_antecedent TEXT\r\n            ) AS\r\n              SELECT consultation_id, GROUP_CONCAT(ligne_antecedent SEPARATOR '\n') AS bloc_antecedent\r\n              FROM `ligneAntecedent`\r\n              GROUP BY consultation_id;";
     $this->addQuery($query);
     $query = "UPDATE `consultation`, `blocAntecedent`\r\n            SET consultation.examen = CONCAT_WS('\n', consultation.examen, blocAntecedent.bloc_antecedent)\r\n            WHERE consultation.consultation_id = blocAntecedent.consultation_id;";
     $this->addQuery($query);
     // Mise a jour du champ examen de la consultation dans le cas d'une addiction sans operation_id
     $query = "CREATE TEMPORARY TABLE ligneAddiction (\r\n             consultation_id INT( 11 ) ,\r\n             ligne_addiction TEXT\r\n            ) AS\r\n              SELECT consultation_anesth.consultation_id, CONCAT_WS(' - ', addiction.type, addiction.addiction ) AS ligne_addiction\r\n              FROM `addiction`, `consultation_anesth`\r\n              WHERE addiction.object_id = consultation_anesth.consultation_anesth_id\r\n              AND addiction.dossier_medical_id IS NULL;";
     $this->addQuery($query);
     $query = "CREATE TEMPORARY TABLE blocAddiction (\r\n             consultation_id INT( 11 ) ,\r\n             bloc_addiction TEXT\r\n            ) AS\r\n              SELECT consultation_id, GROUP_CONCAT(ligne_addiction SEPARATOR '\n') AS bloc_addiction\r\n              FROM `ligneAddiction`\r\n              GROUP BY consultation_id;";
     $this->addQuery($query);
     $query = "UPDATE `consultation`, `blocAddiction`\r\n            SET consultation.examen = CONCAT_WS('\n', consultation.examen, blocAddiction.bloc_addiction)\r\n            WHERE consultation.consultation_id = blocAddiction.consultation_id;";
     $this->addQuery($query);
     // Mise a jour du champ examen de la consultation dans le cas d'un traitement sans operation_id
     $query = "CREATE TEMPORARY TABLE ligneTraitement (\r\n             consultation_id INT( 11 ) ,\r\n             ligne_traitement TEXT\r\n            ) AS\r\n              SELECT consultation_anesth.consultation_id,\r\n                CONCAT_WS(' - ', traitement.debut, traitement.fin, traitement.traitement ) AS ligne_traitement\r\n              FROM `traitement`, `consultation_anesth`\r\n              WHERE traitement.object_id = consultation_anesth.consultation_anesth_id\r\n              AND traitement.dossier_medical_id IS NULL;";
     $this->addQuery($query);
     $query = "CREATE TEMPORARY TABLE blocTraitement (\r\n             consultation_id INT( 11 ) ,\r\n             bloc_traitement TEXT\r\n            ) AS\r\n              SELECT consultation_id, GROUP_CONCAT(ligne_traitement SEPARATOR '\n') AS bloc_traitement\r\n              FROM `ligneTraitement`\r\n              GROUP BY consultation_id;";
     $this->addQuery($query);
     $query = "UPDATE `consultation`, `blocTraitement`\r\n            SET consultation.examen = CONCAT_WS('\n', consultation.examen, blocTraitement.bloc_traitement)\r\n            WHERE consultation.consultation_id = blocTraitement.consultation_id;";
     $this->addQuery($query);
     $query = "ALTER TABLE `addiction`\r\n            DROP `object_id`,\r\n            DROP `object_class`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `antecedent`\r\n            DROP `object_id`,\r\n            DROP `object_class`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n            DROP `object_id`,\r\n            DROP `object_class`;";
     $this->addQuery($query);
     $this->makeRevision("0.51");
     $query = "ALTER TABLE `patients`\r\n            DROP `listCim10`;";
     $this->addQuery($query);
     $this->makeRevision("0.52");
     $query = "ALTER TABLE `patients`\r\n           CHANGE `naissance` `naissance` CHAR( 10 ) NULL DEFAULT NULL ";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n           CHANGE `assure_naissance` `assure_naissance` CHAR( 10 ) NULL DEFAULT NULL ";
     $this->addQuery($query);
     $this->makeRevision("0.53");
     $query = "ALTER TABLE `dossier_medical` CHANGE `listCim10` `codes_cim` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("0.54");
     $query = "ALTER TABLE `patients` ADD INDEX ( `nom_soundex2` );";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `prenom_soundex2` );";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `naissance` );";
     $this->addQuery($query);
     $this->makeRevision("0.55");
     $query = "ALTER TABLE `patients` ADD INDEX ( `nom_jeune_fille` );";
     $this->addQuery($query);
     $this->makeRevision("0.56");
     $query = "ALTER TABLE `dossier_medical` ADD INDEX ( `object_id` );";
     $this->addQuery($query);
     $query = "ALTER TABLE `dossier_medical` ADD INDEX ( `object_class` );";
     $this->addQuery($query);
     $this->makeRevision("0.57");
     $query = "ALTER TABLE `antecedent`\r\n            CHANGE `type` `type`\r\n            ENUM('med','alle','trans','obst',\r\n              'chir','fam','anesth','gyn','cardio',\r\n              'pulm','stomato','plast','ophtalmo',\r\n              'digestif','gastro','stomie','uro',\r\n              'ortho','traumato','amput','neurochir',\r\n              'greffe','thrombo','cutane','hemato',\r\n              'rhumato','neuropsy','infect','endocrino',\r\n              'carcino')\r\n            NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.58");
     $query = "ALTER TABLE `patients` ADD INDEX ( `medecin_traitant` );";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `medecin1` );";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `medecin2` );";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD INDEX ( `medecin3` );";
     $this->addQuery($query);
     $this->makeRevision("0.59");
     $query = "ALTER TABLE `patients` CHANGE `ald` `notes_amo` TEXT DEFAULT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.60");
     $query = "ALTER TABLE `patients`\r\n            ADD `ald` ENUM('0','1'),\r\n            ADD `code_exo` ENUM('0','5','9') DEFAULT '0',\r\n            ADD `deb_amo` DATE,\r\n            ADD `fin_amo` DATE;";
     $this->addQuery($query);
     $this->makeRevision("0.61");
     $query = "UPDATE `patients`\r\n            SET `fin_amo` = `cmu`";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n            CHANGE `cmu` `cmu` ENUM('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $query = "UPDATE `patients`\r\n            SET `cmu` = '1'\r\n            WHERE `fin_amo` IS NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.62");
     $query = "ALTER TABLE `antecedent`\r\n            CHANGE `type` `type`\r\n            ENUM('med','alle','trans','obst',\r\n              'chir','fam','anesth','gyn','cardio',\r\n              'pulm','stomato','plast','ophtalmo',\r\n              'digestif','gastro','stomie','uro',\r\n              'ortho','traumato','amput','neurochir',\r\n              'greffe','thrombo','cutane','hemato',\r\n              'rhumato','neuropsy','infect','endocrino',\r\n              'carcino','orl');";
     $this->addQuery($query);
     $query = "ALTER TABLE `addiction`\r\n            CHANGE `type` `type`\r\n            ENUM('tabac', 'oenolisme', 'cannabis');";
     $this->addQuery($query);
     $this->makeRevision("0.63");
     $query = "CREATE TABLE `etat_dent` (\r\n            `etat_dent_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n            `dossier_medical_id` INT NOT NULL ,\r\n            `dent` TINYINT UNSIGNED NOT NULL ,\r\n            `etat` ENUM('bridge', 'pivot', 'mobile', 'appareil') NULL\r\n            ) /*! ENGINE=MyISAM */ ;";
     $this->addQuery($query);
     $this->makeRevision("0.64");
     $this->addDependency("dPsante400", "0.1");
     $query = "INSERT INTO `id_sante400` (id_sante400_id, object_class, object_id, tag, last_update, id400)\r\n            SELECT NULL, 'CPatient', `patient_id`, 'SHS group:1', NOW(), `SHS`\r\n            FROM `patients`\r\n            WHERE `SHS` IS NOT NULL\r\n            AND `SHS` != 0";
     $this->addQuery($query);
     $this->makeRevision("0.65");
     $query = "ALTER TABLE `patients` DROP `SHS`";
     $this->addQuery($query);
     $this->makeRevision("0.66");
     $this->addDependency("dPcabinet", "0.30");
     $query = "CREATE TABLE `constantes_medicales` (\r\n      `constantes_medicales_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `patient_id` INT (11) UNSIGNED NOT NULL,\r\n      `datetime` DATETIME NOT NULL,\r\n      `context_class` VARCHAR (255),\r\n      `context_id` INT (11) UNSIGNED,\r\n      `poids` FLOAT UNSIGNED,\r\n      `taille` FLOAT,\r\n      `ta` VARCHAR (10),\r\n      `pouls` INT (11) UNSIGNED,\r\n      `spo2` FLOAT\r\n    ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `constantes_medicales`\r\n      ADD INDEX (`patient_id`),\r\n      ADD INDEX (`datetime`),\r\n      ADD INDEX (`context_id`);";
     $this->addQuery($query);
     $query = "INSERT INTO `constantes_medicales` (\r\n        `context_class`,\r\n        `context_id`,\r\n        `patient_id`,\r\n        `datetime`,\r\n        `poids`,\r\n        `taille`,\r\n        `ta`,\r\n        `pouls`,\r\n        `spo2`\r\n      )\r\n      SELECT\r\n        'CConsultation',\r\n        `consultation`.`consultation_id`,\r\n        `consultation`.`patient_id`,\r\n        CONCAT(`plageconsult`.`date`, ' ', `consultation`.`heure`),\r\n        `consultation_anesth`.`poid`,\r\n        `consultation_anesth`.`taille`,\r\n        IF(`consultation_anesth`.`tasys`, CONCAT(`consultation_anesth`.`tasys`, '|', `consultation_anesth`.`tadias`), NULL),\r\n        `consultation_anesth`.`pouls`,\r\n        `consultation_anesth`.`spo2`\r\n      FROM\r\n        `consultation_anesth`, `consultation`, `plageconsult`\r\n      WHERE\r\n        `consultation`.`consultation_id` = `consultation_anesth`.`consultation_id` AND\r\n        `plageconsult`.`plageconsult_id` = `consultation`.`plageconsult_id`";
     $this->addQuery($query);
     $repl = array("Patient - poids", "Patient - taille", "Patient - Pouls", "Patient - IMC", "Patient - TA");
     $find = array("Anesthésie - poids", "Anesthésie - taille", "Anesthésie - Pouls", "Anesthésie - IMC", "Anesthésie - TA");
     $count = count($repl);
     for ($i = 0; $i < $count; $i++) {
         $query = CSetupdPcompteRendu::renameTemplateFieldQuery($find[$i], $repl[$i]);
         $this->addQuery($query);
     }
     $this->makeRevision("0.67");
     $query = 'ALTER TABLE `constantes_medicales` ADD `temperature` FLOAT';
     $this->addQuery($query);
     $this->makeRevision("0.68");
     $query = "ALTER TABLE `patients`\r\n            ADD `code_sit` MEDIUMINT (4) UNSIGNED ZEROFILL,\r\n            ADD `regime_am` ENUM ('0','1');";
     $this->addQuery($query);
     $this->makeRevision("0.69");
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Patient - antécédents", "Patient - Antécédents -- tous"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Patient - traitements", "Patient - Traitements"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Patient - addictions", "Patient - Addictions -- toutes"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Patient - diagnostics", "Patient - Diagnotics"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Sejour - antécédents", "Sejour - Antécédents -- tous"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Sejour - traitements", "Sejour - Traitements"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Sejour - addictions", "Sejour - Addictions -- toutes"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Sejour - diagnostics", "Sejour - Diagnotics"));
     $this->makeRevision("0.70");
     $query = "ALTER TABLE `patients` ADD `email` VARCHAR (255) AFTER tel2;";
     $this->addQuery($query);
     $this->makeRevision("0.71");
     $query = "CREATE TABLE `correspondant` (\r\n      `correspondant_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `medecin_id` INT (11) UNSIGNED NOT NULL,\r\n      `patient_id` INT (11) UNSIGNED NOT NULL,\r\n      KEY (`medecin_id`),\r\n      KEY (`patient_id`)\r\n      ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.72");
     $query = "ALTER TABLE `antecedent`\r\n            CHANGE `type` `type`\r\n            ENUM('med','alle','trans','obst',\r\n              'chir','fam','anesth','gyn',\r\n              'cardio','pulm','stomato','plast','ophtalmo',\r\n              'digestif','gastro','stomie','uro',\r\n              'ortho','traumato','amput','neurochir',\r\n              'greffe','thrombo','cutane','hemato',\r\n              'rhumato','neuropsy','infect','endocrino',\r\n              'carcino','orl','addiction','habitus');";
     $this->addQuery($query);
     // If there is a type
     $query = "INSERT INTO `antecedent` (`type`, `rques`, `dossier_medical_id`)\r\n            SELECT 'addiction', CONCAT(UPPER(LEFT(`type`, 1)), LOWER(SUBSTRING(`type`, 2)), ': ', `addiction`), `dossier_medical_id`\r\n            FROM `addiction`\r\n            WHERE `type` IS NOT NULL AND `type` <> '0'";
     $this->addQuery($query);
     // If there is no type
     $query = "INSERT INTO `antecedent` (`type`, `rques`, `dossier_medical_id`)\r\n            SELECT 'addiction', `addiction`, `dossier_medical_id`\r\n            FROM `addiction`\r\n            WHERE `type` IS NULL OR `type` = '0'";
     $this->addQuery($query);
     // If there is a type
     // @todo : A vérifier
     /*$query = "UPDATE `aide_saisie` SET
                 `class` = 'CAntecedent',
                 `field` = 'rques',
                 `name` = CONCAT(UPPER(LEFT(`depend_value`, 1)), LOWER(SUBSTRING(`depend_value`, 2)), ': ', `name`),
                 `text` = CONCAT(UPPER(LEFT(`depend_value`, 1)), LOWER(SUBSTRING(`depend_value`, 2)), ': ', `text`),
                 `depend_value` = 'addiction'
               WHERE
                 `class` = 'CAddiction'
                  AND `depend_value` IS NOT NULL";
       $this->addQuery($query);*/
     // If there is no type
     /*$query = "UPDATE `aide_saisie` SET
                 `class` = 'CAntecedent',
                 `field` = 'rques',
                 `depend_value` = 'addiction'
               WHERE
                 `class` = 'CAddiction'
                  AND `depend_value` IS NULL";
       $this->addQuery($query);*/
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Sejour - Addictions -- toutes", "Sejour - Antécédents - Addictions"));
     $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Patient - Addictions -- toutes", "Patient - Antécédents - Addictions"));
     $addiction_types = array('tabac', 'oenolisme', 'cannabis');
     foreach ($addiction_types as $type) {
         $typeTrad = CAppUI::tr("CAddiction.type.{$type}");
         $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Sejour - Addictions - {$typeTrad}", "Sejour - Antécédents - Addictions"));
         $this->addQuery(CSetupdPcompteRendu::renameTemplateFieldQuery("Patient - Addictions - {$typeTrad}", "Patient - Antécédents - Addictions"));
     }
     /*$query = "DROP TABLE `addiction`";
       $this->addQuery($query);*/
     $this->makeRevision("0.73");
     $query = "ALTER TABLE `constantes_medicales`\r\n            ADD `score_sensibilite` FLOAT,\r\n            ADD `score_motricite` FLOAT,\r\n            ADD `EVA` FLOAT,\r\n            ADD `score_sedation` FLOAT,\r\n            ADD `frequence_respiratoire` FLOAT;";
     $this->addQuery($query);
     $this->makeRevision("0.74");
     for ($i = 1; $i <= 3; $i++) {
         $query = "INSERT INTO `correspondant` (`medecin_id`, `patient_id`)\r\n              SELECT `medecin{$i}`, `patient_id`\r\n              FROM `patients`\r\n              WHERE `medecin{$i}` IS NOT NULL";
         $this->addQuery($query);
     }
     $query = "ALTER TABLE `patients`\r\n            DROP `medecin1`,\r\n            DROP `medecin2`,\r\n            DROP `medecin3`";
     $this->addQuery($query);
     $this->makeRevision("0.75");
     $query = "UPDATE `constantes_medicales` SET `poids` = NULL WHERE `poids` = 0";
     $this->addQuery($query);
     $query = "UPDATE `constantes_medicales` SET `taille` = NULL WHERE `taille` = 0";
     $this->addQuery($query);
     $query = "DELETE FROM `constantes_medicales` WHERE\r\n            `poids` IS NULL AND\r\n            `taille` IS NULL AND\r\n            `ta` IS NULL AND\r\n            `pouls` IS NULL AND\r\n            `spo2` IS NULL AND\r\n            `temperature` IS NULL AND\r\n            `score_sensibilite` IS NULL AND\r\n            `score_motricite` IS NULL AND\r\n            `EVA` IS NULL AND\r\n            `score_sedation` IS NULL AND\r\n            `frequence_respiratoire` IS NULL";
     $this->addQuery($query);
     $this->makeRevision("0.76");
     $query = "ALTER TABLE `medecin` ADD `type` ENUM ('medecin','kine','sagefemme','infirmier') NOT NULL DEFAULT 'medecin';";
     $this->addQuery($query);
     $this->makeRevision("0.77");
     $query = "ALTER TABLE `antecedent` ADD `annule` ENUM('0','1') DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("0.78");
     $query = "ALTER TABLE `medecin` ADD `portable` BIGINT(10) UNSIGNED ZEROFILL NULL";
     $this->addQuery($query);
     $this->makeRevision("0.79");
     $query = "ALTER TABLE `antecedent`\r\n            ADD `appareil` ENUM ('cardiovasculaire','endocrinien','neuro_psychiatrique','uro_nephrologique','digestif','pulmonaire');";
     $this->addQuery($query);
     $this->makeRevision("0.80");
     $query = "ALTER TABLE patients\r\n            ADD pays_insee INT(11) AFTER pays ,\r\n            ADD prenom_2 VARCHAR(50) AFTER prenom ,\r\n            ADD prenom_3 VARCHAR(50) AFTER prenom_2 ,\r\n            ADD prenom_4 VARCHAR(50) AFTER prenom_3 ,\r\n            ADD cp_naissance VARCHAR(5) AFTER lieu_naissance ,\r\n            ADD pays_naissance_insee INT(11) AFTER cp_naissance,\r\n            ADD assure_pays_insee INT(11) AFTER assure_pays ,\r\n            ADD assure_prenom_2 VARCHAR(50) AFTER assure_prenom ,\r\n            ADD assure_prenom_3 VARCHAR(50) AFTER assure_prenom_2 ,\r\n            ADD assure_prenom_4 VARCHAR(50) AFTER assure_prenom_3 ,\r\n            ADD assure_cp_naissance VARCHAR(5) AFTER assure_lieu_naissance,\r\n            ADD assure_pays_naissance_insee INT(11) AFTER assure_cp_naissance;";
     $this->addQuery($query);
     $this->makeRevision("0.81");
     $query = "ALTER TABLE `patients`\r\n            CHANGE `prenom_2` `prenom_2` VARCHAR (255),\r\n            CHANGE `prenom_3` `prenom_3` VARCHAR (255),\r\n            CHANGE `prenom_4` `prenom_4` VARCHAR (255),\r\n            CHANGE `sexe` `sexe` ENUM ('m','f','j'),\r\n            CHANGE `adresse` `adresse` TEXT,\r\n            CHANGE `ville` `ville` VARCHAR (255),\r\n            CHANGE `incapable_majeur` `incapable_majeur` ENUM ('0','1'),\r\n            CHANGE `ATNC` `ATNC` ENUM ('0','1'),\r\n            CHANGE `matricule` `matricule` VARCHAR (15),\r\n            CHANGE `assure_prenom_2` `assure_prenom_2` VARCHAR (255),\r\n            CHANGE `assure_prenom_3` `assure_prenom_3` VARCHAR (255),\r\n            CHANGE `assure_prenom_4` `assure_prenom_4` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("0.82");
     $query = "ALTER TABLE `antecedent`\r\n            CHANGE `appareil` `appareil`\r\n            ENUM('cardiovasculaire','digestif','endocrinien',\r\n              'neuro_psychiatrique','pulmonaire',\r\n              'uro_nephrologique','orl','gyneco_obstetrique',\r\n              'orthopedique');";
     $this->addQuery($query);
     $this->makeRevision("0.83");
     $query = "ALTER TABLE `patients`\r\n            CHANGE `pays_insee` `pays_insee` INT(3) UNSIGNED ZEROFILL,\r\n            CHANGE `pays_naissance_insee` `pays_naissance_insee` INT(3) UNSIGNED ZEROFILL,\r\n            CHANGE `assure_pays_insee` `assure_pays_insee` INT(3) UNSIGNED ZEROFILL,\r\n            CHANGE `assure_pays_naissance_insee` `assure_pays_naissance_insee` INT(3) UNSIGNED ZEROFILL;";
     $this->addQuery($query);
     $this->makeRevision("0.84");
     $query = "ALTER TABLE `patients`\r\n        ADD `libelle_exo` TEXT AFTER `rques`,\r\n        ADD `medecin_traitant_declare` ENUM('0', '1') AFTER `email`";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n        CHANGE `code_exo` `code_exo` ENUM('0', '4', '5', '9') NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("0.85");
     $query = "ALTER TABLE `patients`\r\n            ADD `civilite` ENUM ('m','mme','melle','enf','dr','pr','me','vve') AFTER `sexe`,\r\n            ADD `assure_civilite` ENUM ('m','mme','melle','enf','dr','pr','me','vve') AFTER `assure_sexe`";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `civilite` = 'm' WHERE `sexe` = 'm'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `civilite` = 'mme' WHERE `sexe` = 'f'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `civilite` = 'melle' WHERE `sexe` = 'j'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `civilite` = 'enf' WHERE `naissance` >= " . (date('Y') - 15);
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `assure_civilite` = 'm' WHERE `assure_sexe` = 'm'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `assure_civilite` = 'mme' WHERE `assure_sexe` = 'f'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `assure_civilite` = 'melle' WHERE `assure_sexe` = 'j'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `assure_civilite` = 'enf' WHERE `assure_naissance` >= " . (date('Y') - 15);
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `sexe` = 'f' WHERE `sexe` = 'j'";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n            CHANGE `sexe` `sexe` ENUM ('m','f'),\r\n            CHANGE `assure_sexe` `assure_sexe` ENUM ('m','f')";
     $this->addQuery($query);
     $this->makeRevision("0.86");
     $this->makeRevision("0.87");
     $query = "ALTER TABLE `medecin`\r\n            ADD `adeli` INT (9) UNSIGNED ZEROFILL;";
     $this->addQuery($query);
     $this->makeRevision("0.88");
     $query = "ALTER TABLE `constantes_medicales`\r\n      ADD `glycemie` FLOAT UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("0.89");
     $query = "ALTER TABLE `medecin`\r\n      CHANGE `type` `type` ENUM ('medecin','kine','sagefemme','infirmier','dentiste','autre')";
     $this->addQuery($query);
     $this->makeRevision("0.90");
     $query = "ALTER TABLE `medecin`\r\n      CHANGE `type` `type` ENUM ('medecin','kine','sagefemme','infirmier','dentiste','podologue','autre');";
     $this->addQuery($query);
     $this->makeRevision("0.91");
     $query = "ALTER TABLE `patients`\r\n      ADD `notes_amc` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("0.92");
     $query = "ALTER TABLE `antecedent`\r\n                ADD INDEX (`date`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `etat_dent`\r\n                ADD INDEX (`dossier_medical_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n                ADD INDEX (`debut`),\r\n                ADD INDEX (`fin`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD INDEX (`deb_amo`),\r\n                ADD INDEX (`fin_amo`),\r\n                ADD INDEX (`fin_validite_vitale`);";
     $this->addQuery($query);
     $this->makeRevision("0.93");
     $query = "ALTER TABLE `antecedent`\r\n              CHANGE `type` `type` VARCHAR (80),\r\n              CHANGE `appareil` `appareil` VARCHAR (80);";
     $this->addQuery($query);
     $this->makeRevision("0.94");
     $query = "ALTER TABLE `dossier_medical`\r\n              ADD `risque_thrombo_patient` ENUM ('faible','modere','eleve','majeur','NR') DEFAULT 'NR',\r\n              ADD `risque_MCJ_patient` ENUM ('sans','avec','suspect','atteint','NR') DEFAULT 'NR',\r\n              ADD `risque_thrombo_chirurgie` ENUM ('faible','modere','eleve','NR') DEFAULT 'NR',\r\n              ADD `risque_antibioprophylaxie` ENUM ('oui','non','NR') DEFAULT 'NR',\r\n              ADD `risque_prophylaxie` ENUM ('oui','non','NR') DEFAULT 'NR',\r\n              ADD `risque_MCJ_chirurgie` ENUM ('sans','avec','NR') DEFAULT 'NR';";
     $this->addQuery($query);
     $this->makeRevision("0.95");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `redon` FLOAT UNSIGNED,\r\n              ADD `diurese` FLOAT UNSIGNED,\r\n              ADD `injection` VARCHAR (10);";
     $this->addQuery($query);
     $this->makeRevision("0.96");
     $query = "ALTER TABLE `patients`\r\n              ADD `code_gestion` MEDIUMINT (4) UNSIGNED ZEROFILL,\r\n              ADD `mutuelle_types_contrat` TEXT";
     $this->addQuery($query);
     $this->makeRevision("0.97");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `patients` ADD `code_gestion2` MEDIUMINT (2) UNSIGNED ZEROFILL";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` CHANGE `code_gestion` `centre_carte` MEDIUMINT (4) UNSIGNED ZEROFILL";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` CHANGE `code_gestion2` `code_gestion` MEDIUMINT (2) UNSIGNED ZEROFILL";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients` ADD `qual_beneficiaire` ENUM ('0','1','2','3','4','5','6','7','8','9')";
     $this->addQuery($query);
     foreach (CPatient::$rangToQualBenef as $from => $to) {
         $query = "UPDATE `patients` SET `qual_beneficiaire` = '{$to}' WHERE `rang_beneficiaire` = '{$from}'";
         $this->addQuery($query);
     }
     $this->makeRevision("0.98");
     $query = "ALTER TABLE `patients` CHANGE `code_gestion` `code_gestion` CHAR (2)";
     $this->addQuery($query);
     $this->makeRevision("0.99");
     $query = "ALTER TABLE `patients`\r\n             CHANGE `civilite` `civilite` ENUM ('m','mme','melle','mlle','enf','dr','pr','me','vve') DEFAULT 'm',\r\n             CHANGE `assure_civilite` `assure_civilite` ENUM ('m','mme','melle','mlle','enf','dr','pr','me','vve') DEFAULT 'm';";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `civilite` = 'mlle' WHERE `civilite` = 'melle'";
     $this->addQuery($query);
     $query = "UPDATE `patients` SET `assure_civilite` = 'mlle' WHERE `assure_civilite` = 'melle'";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n             CHANGE `civilite` `civilite` ENUM ('m','mme','mlle','enf','dr','pr','me','vve') DEFAULT 'm',\r\n             CHANGE `assure_civilite` `assure_civilite` ENUM ('m','mme','mlle','enf','dr','pr','me','vve') DEFAULT 'm';";
     $this->addQuery($query);
     $this->makeRevision("1.0");
     $query = "ALTER TABLE `constantes_medicales` ADD `ta_droit` VARCHAR (10) AFTER `ta`";
     $this->addQuery($query);
     $this->makeRevision("1.01");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `redon_2` FLOAT UNSIGNED AFTER `redon`,\r\n              ADD `redon_3` FLOAT UNSIGNED AFTER `redon_2`";
     $this->addQuery($query);
     $this->makeRevision("1.02");
     $query = "ALTER TABLE `patients`\r\n      ADD `confiance_nom` VARCHAR( 50 ) AFTER `prevenir_parente`,\r\n      ADD `confiance_prenom` VARCHAR( 50 ) AFTER `confiance_nom`,\r\n      ADD `confiance_adresse` TEXT AFTER `confiance_prenom`,\r\n      ADD `confiance_cp` VARCHAR( 5 ) AFTER `confiance_adresse`,\r\n      ADD `confiance_ville` VARCHAR( 50 ) AFTER `confiance_cp`,\r\n      ADD `confiance_tel` VARCHAR( 10 ) AFTER `confiance_ville`,\r\n      ADD `confiance_parente` ENUM( 'conjoint', 'enfant', 'ascendant', 'colateral', 'divers' ) AFTER `confiance_tel`;";
     $this->addQuery($query);
     $this->makeRevision("1.03");
     $query = "ALTER TABLE `patients` ADD `tel_autre` VARCHAR (20) AFTER `tel2`";
     $this->addQuery($query);
     $this->makeRevision("1.04");
     $this->addPrefQuery("vCardExport", "0");
     $this->makeRevision("1.05");
     $query = "ALTER TABLE `patients` ADD `vip` ENUM ('0','1') NOT NULL DEFAULT '0' AFTER `email`";
     $this->addQuery($query);
     $this->makeRevision("1.06");
     $query = "ALTER TABLE `patients` ADD `date_lecture_vitale` DATETIME";
     $this->addQuery($query);
     $this->makeRevision("1.07");
     $query = "ALTER TABLE `patients`\r\n      DROP `nationalite`,\r\n      DROP `assure_nationalite`;";
     $this->addQuery($query);
     $this->makeRevision("1.08");
     $query = "ALTER TABLE `medecin`\r\n      CHANGE `type` `type` ENUM ('medecin','kine','sagefemme',\r\n        'infirmier','dentiste','podologue', 'pharmacie',\r\n        'maison_medicale', 'autre');";
     $this->addQuery($query);
     $this->makeRevision("1.09");
     $query = "ALTER TABLE `groups_config`\r\n      ADD `dPpatients_CPatient_nom_jeune_fille_mandatory` ENUM ('0', '1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("1.10");
     $query = "ALTER TABLE `constantes_medicales`\r\n      CHANGE `ta` `ta_gauche` VARCHAR (10),\r\n      ADD `ta` VARCHAR(10) AFTER `taille`,\r\n      ADD PVC FLOAT UNSIGNED,\r\n      ADD perimetre_abdo FLOAT UNSIGNED,\r\n      ADD perimetre_cuisse FLOAT UNSIGNED,\r\n      ADD perimetre_cou FLOAT UNSIGNED,\r\n      ADD perimetre_thoracique FLOAT UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.11");
     $query = "UPDATE constantes_medicales\r\n              SET ta_gauche = ta, ta = NULL\r\n              WHERE ta IS NOT NULL AND ta_gauche IS NULL";
     $this->addQuery($query);
     $this->makeRevision("1.12");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `diurese_miction` FLOAT UNSIGNED AFTER `diurese`;";
     $this->addQuery($query);
     $this->makeRevision("1.13");
     $query = "ALTER TABLE `patients`\r\n      ADD `deces` DATE AFTER `naissance`;";
     $this->addQuery($query);
     $this->makeRevision("1.14");
     $query = "ALTER TABLE `medecin`\r\n      CHANGE `prenom` `prenom` varchar(255);";
     $this->addQuery($query);
     $this->makeRevision("1.15");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `comment` TEXT";
     $this->addQuery($query);
     $this->makeRevision("1.16");
     $query = "ALTER TABLE `patients`\r\n      ADD INDEX ( `nomjf_soundex2` );";
     $this->addQuery($query);
     $this->makeRevision("1.17");
     $query = "ALTER TABLE `patients`\r\n      ADD `INS` CHAR(22) AFTER `matricule`";
     $this->addQuery($query);
     $this->makeRevision("1.18");
     $query = "ALTER TABLE `patients`\r\n      CHANGE `INS` `INSC` CHAR(22),\r\n      ADD `INSC_date` DATETIME AFTER `INSC`";
     $this->addQuery($query);
     $this->makeRevision("1.19");
     $query = "ALTER TABLE `medecin`\r\n               ADD `rpps` BIGINT (11) UNSIGNED ZEROFILL;";
     $this->addQuery($query);
     $this->makeRevision("1.20");
     $query = "CREATE TABLE `correspondant_patient` (\r\n      `correspondant_patient_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `patient_id` INT (11) UNSIGNED NOT NULL,\r\n      `relation` ENUM ('confiance','prevenir','employeur'),\r\n      `nom` VARCHAR (255),\r\n      `prenom` VARCHAR (255),\r\n      `adresse` TEXT,\r\n      `cp` INT (5) UNSIGNED ZEROFILL,\r\n      `ville` VARCHAR (255),\r\n      `tel` BIGINT (10) UNSIGNED ZEROFILL,\r\n      `urssaf` BIGINT (11) UNSIGNED ZEROFILL,\r\n      `parente` ENUM ('conjoint','enfant','ascendant','colateral','divers'),\r\n      `email` VARCHAR (255),\r\n      `remarques` TEXT\r\n      ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `correspondant_patient`\r\n              ADD INDEX (`patient_id`);";
     $this->addQuery($query);
     $query = "INSERT INTO correspondant_patient (patient_id, relation, nom, adresse, cp, ville, tel, urssaf)\r\n      SELECT patient_id, 'employeur',\r\n        employeur_nom, employeur_adresse,\r\n        employeur_cp, employeur_ville,\r\n        employeur_tel, employeur_urssaf\r\n      FROM patients";
     $this->addQuery($query);
     $query = "INSERT INTO correspondant_patient (patient_id, relation, nom, prenom, adresse, cp, ville, tel, parente)\r\n      SELECT patient_id, 'prevenir',\r\n        prevenir_nom, prevenir_prenom,\r\n        prevenir_adresse, prevenir_cp,\r\n        prevenir_ville, prevenir_tel, prevenir_parente\r\n      FROM patients";
     $this->addQuery($query);
     $query = "INSERT INTO correspondant_patient (patient_id, relation, nom, prenom, adresse, cp, ville, tel, parente)\r\n      SELECT patient_id, 'confiance',\r\n        confiance_nom, confiance_prenom,\r\n        confiance_adresse, confiance_cp,\r\n        confiance_ville, confiance_tel, confiance_parente\r\n      FROM patients";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n      DROP `employeur_nom`,\r\n      DROP `employeur_adresse`,\r\n      DROP `employeur_cp`,\r\n      DROP `employeur_ville`,\r\n      DROP `employeur_tel`,\r\n      DROP `employeur_urssaf`,\r\n      DROP `prevenir_nom`,\r\n      DROP `prevenir_prenom`,\r\n      DROP `prevenir_adresse`,\r\n      DROP `prevenir_cp`,\r\n      DROP `prevenir_ville`,\r\n      DROP `prevenir_tel`,\r\n      DROP `prevenir_parente`,\r\n      DROP `confiance_nom`,\r\n      DROP `confiance_prenom`,\r\n      DROP `confiance_adresse`,\r\n      DROP `confiance_cp`,\r\n      DROP `confiance_ville`,\r\n      DROP `confiance_tel`,\r\n      DROP `confiance_parente`";
     $this->addQuery($query);
     $this->makeRevision("1.21");
     $query = "CREATE TABLE `devenir_dentaire` (\r\n      `devenir_dentaire_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `patient_id` INT (11) UNSIGNED NOT NULL\r\n      ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `devenir_dentaire`\r\n      ADD INDEX (`patient_id`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `acte_dentaire` (\r\n      `acte_dentaire_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `devenir_dentaire_id` INT (11) UNSIGNED NOT NULL,\r\n      `code` VARCHAR (10) NOT NULL,\r\n      `commentaire` TEXT\r\n      ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `acte_dentaire`\r\n      ADD INDEX (`devenir_dentaire_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.22");
     $query = "DELETE FROM `correspondant_patient`\r\n      WHERE `nom` IS NULL\r\n      AND `prenom` IS NULL\r\n      AND `adresse` IS NULL\r\n      AND `cp` IS NULL\r\n      AND `ville` IS NULL\r\n      AND `tel` IS NULL\r\n      AND `urssaf` IS NULL\r\n      AND `parente` IS NULL\r\n      AND `email` IS NULL\r\n      AND `remarques` IS NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.23");
     $query = "ALTER TABLE `constantes_medicales`\r\n      ADD `redon_4` FLOAT UNSIGNED AFTER `redon_3`,\r\n      ADD `sng` FLOAT UNSIGNED,\r\n      ADD `lame_1` FLOAT UNSIGNED,\r\n      ADD `lame_2` FLOAT UNSIGNED,\r\n      ADD `lame_3` FLOAT UNSIGNED,\r\n      ADD `drain_1` FLOAT UNSIGNED,\r\n      ADD `drain_2` FLOAT UNSIGNED,\r\n      ADD `drain_3` FLOAT UNSIGNED,\r\n      ADD `drain_thoracique_1` FLOAT UNSIGNED,\r\n      ADD `drain_thoracique_2` FLOAT UNSIGNED,\r\n      ADD `drain_pleural_1` FLOAT UNSIGNED,\r\n      ADD `drain_pleural_2` FLOAT UNSIGNED,\r\n      ADD `drain_mediastinal` FLOAT UNSIGNED,\r\n      ADD `sonde_ureterale_1` FLOAT UNSIGNED,\r\n      ADD `sonde_ureterale_2` FLOAT UNSIGNED,\r\n      ADD `sonde_vesicale` FLOAT UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.24");
     $query = "CREATE TABLE `config_constantes_medicales` (\r\n              `service_id` INT (11) UNSIGNED,\r\n              `group_id` INT (11) UNSIGNED,\r\n              `config_constantes_medicales_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `important_constantes` TEXT,\r\n              `diuere_24_reset_hour` TINYINT (4) UNSIGNED,\r\n              `redon_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `sng_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `lame_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `drain_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `drain_thoracique_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `drain_pleural_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `drain_mediastinal_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `sonde_ureterale_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `sonde_vesicale_cumul_reset_hour` TINYINT (4) UNSIGNED,\r\n              `show_cat_tabs` ENUM ('0','1')\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `config_constantes_medicales`\r\n              ADD INDEX (`service_id`),\r\n              ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $conf = CAppUI::conf("dPpatients CConstantesMedicales");
     $query = $this->ds->prepare("INSERT INTO `config_constantes_medicales` (\r\n         `important_constantes` ,\r\n         `diuere_24_reset_hour` ,\r\n         `redon_cumul_reset_hour` ,\r\n         `sng_cumul_reset_hour` ,\r\n         `lame_cumul_reset_hour` ,\r\n         `drain_cumul_reset_hour` ,\r\n         `drain_thoracique_cumul_reset_hour` ,\r\n         `drain_pleural_cumul_reset_hour` ,\r\n         `drain_mediastinal_cumul_reset_hour` ,\r\n         `sonde_ureterale_cumul_reset_hour` ,\r\n         `sonde_vesicale_cumul_reset_hour` ,\r\n         `show_cat_tabs`\r\n       )\r\n       VALUES (\r\n         ?1 , ?2 , ?3 , ?4 , ?5 , ?6 , ?7 , ?8 , ?9 , ?10 , ?11 , '0'\r\n       );", CValue::read($conf, "important_constantes"), CValue::read($conf, "diuere_24_reset_hour"), CValue::read($conf, "redon_cumul_reset_hour"), CValue::read($conf, "sng_cumul_reset_hour"), CValue::read($conf, "lame_cumul_reset_hour"), CValue::read($conf, "drain_cumul_reset_hour"), CValue::read($conf, "drain_thoracique_cumul_reset_hour"), CValue::read($conf, "drain_pleural_cumul_reset_hour"), CValue::read($conf, "drain_mediastinal_cumul_reset_hour"), CValue::read($conf, "sonde_ureterale_cumul_reset_hour"), CValue::read($conf, "sonde_vesicale_cumul_reset_hour"));
     $this->addQuery($query);
     $this->makeRevision("1.25");
     $query = "ALTER TABLE `devenir_dentaire`\r\n              ADD `etudiant_id` INT (11) UNSIGNED,\r\n              ADD INDEX (`etudiant_id`),\r\n              ADD `description` TEXT NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `acte_dentaire`\r\n              ADD `ICR` INT (11) UNSIGNED,\r\n              ADD `consult_id` INT (11) UNSIGNED,\r\n              ADD INDEX (`consult_id`),\r\n              ADD `rank` INT (11) UNSIGNED NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.26");
     $query = "ALTER TABLE `correspondant_patient`\r\n              CHANGE `relation` `relation` ENUM ('assurance','autre','confiance','employeur','inconnu','prevenir'),\r\n              ADD `relation_autre` VARCHAR (255),\r\n              CHANGE `parente` `parente` ENUM ('ami','ascendant','autre','beau_fils',\r\n                'colateral','collegue','compagnon','conjoint','directeur','divers',\r\n                'employeur','employe','enfant','enfant_adoptif','entraineur','epoux',\r\n                'frere','grand_parent','mere','pere','petits_enfants','proche',\r\n                'proprietaire','soeur','tuteur'),\r\n              ADD `parente_autre` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("1.27");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `catheter_suspubien` FLOAT UNSIGNED,\r\n              ADD `entree_lavage` FLOAT UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.28");
     $query = "ALTER TABLE `config_constantes_medicales`\r\n              ADD `show_enable_all_button` ENUM ('0','1');";
     $this->addQuery($query);
     $query = "UPDATE `config_constantes_medicales`\r\n              SET `show_enable_all_button` = '1' WHERE `group_id` IS NULL AND `service_id` IS NULL";
     $this->addQuery($query);
     $this->makeRevision("1.29");
     $query = "ALTER TABLE `patients`\r\n                ADD `csp` TINYINT (2) UNSIGNED ZEROFILL;";
     $this->addQuery($query);
     $this->makeRevision("1.30");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `sonde_nephro_2` FLOAT UNSIGNED AFTER `sonde_ureterale_2`,\r\n              ADD `sonde_nephro_1` FLOAT UNSIGNED AFTER `sonde_ureterale_2`";
     $this->addQuery($query);
     $query = "ALTER TABLE `config_constantes_medicales`\r\n              ADD `sonde_nephro_cumul_reset_hour` TINYINT (4) UNSIGNED AFTER `sonde_ureterale_cumul_reset_hour`;";
     $this->addQuery($query);
     $query = "UPDATE `config_constantes_medicales`\r\n              SET `sonde_nephro_cumul_reset_hour` = '8' WHERE `group_id` IS NULL AND `service_id` IS NULL";
     $this->addQuery($query);
     $this->makeRevision("1.31");
     $query = "ALTER TABLE `constantes_medicales`\r\n      ADD `perimetre_cranien` FLOAT UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.32");
     $query = "ALTER TABLE `patients`\r\n       ADD `tutelle` ENUM ('aucune','tutelle','curatelle') DEFAULT 'aucune';";
     $this->addQuery($query);
     $this->makeRevision("1.33");
     $query = "CREATE TABLE `observation_result_set` (\r\n              `observation_result_set_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `patient_id` INT (11) UNSIGNED NOT NULL,\r\n              `datetime` DATETIME NOT NULL,\r\n              `context_class` CHAR (80) NOT NULL,\r\n              `context_id` INT (11) UNSIGNED\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result_set`\r\n              ADD INDEX (`patient_id`),\r\n              ADD INDEX (`datetime`),\r\n              ADD INDEX (`context_id`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `observation_value_type` (\r\n              `observation_value_type_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `datatype` ENUM ('NM','ST','TX') NOT NULL,\r\n              `code` CHAR (40) NOT NULL,\r\n              `label` CHAR (255),\r\n              `coding_system` CHAR (40) NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_value_type`\r\n              ADD INDEX (`datatype`),\r\n              ADD INDEX (`code`),\r\n              ADD INDEX (`coding_system`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `observation_value_unit` (\r\n              `observation_value_unit_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `code` CHAR (40) NOT NULL,\r\n              `label` CHAR (255),\r\n              `coding_system` CHAR (40) NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_value_unit`\r\n              ADD INDEX (`code`),\r\n              ADD INDEX (`coding_system`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `observation_result` (\r\n              `observation_result_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `observation_result_set_id` INT (11) UNSIGNED NOT NULL,\r\n              `value_type_id` INT (11) UNSIGNED NOT NULL,\r\n              `unit_id` INT (11) UNSIGNED NOT NULL,\r\n              `value` CHAR (255) NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result`\r\n              ADD INDEX (`observation_result_set_id`),\r\n              ADD INDEX (`value_type_id`),\r\n              ADD INDEX (`unit_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.34");
     $query = "ALTER TABLE `observation_result`\r\n              ADD `method` VARCHAR (255)";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result`\r\n              ADD INDEX (`method`)";
     $this->addQuery($query);
     $query = "ALTER TABLE `etat_dent`\r\n              CHANGE `etat` `etat` ENUM ('bridge','pivot','mobile','appareil','defaut');";
     $this->addQuery($query);
     $this->makeRevision("1.35");
     $query = "ALTER TABLE `observation_value_type`\r\n              CHANGE `code` `code` VARCHAR (40) NOT NULL,\r\n              CHANGE `label` `label` VARCHAR (255) NOT NULL,\r\n              CHANGE `coding_system` `coding_system` VARCHAR (40) NOT NULL,\r\n              ADD `desc` VARCHAR (255);";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_value_unit`\r\n              CHANGE `code` `code` VARCHAR (40) NOT NULL,\r\n              CHANGE `label` `label` VARCHAR (255) NOT NULL,\r\n              CHANGE `coding_system` `coding_system` VARCHAR (40) NOT NULL,\r\n              ADD `desc` VARCHAR (255);";
     $this->addQuery($query);
     // Ajout des unités et paramètres standards dans les nouvelles constantes
     $mdil_params = array("0002-4182" => array("HR", "Rythme cardiaque"), "0002-4b60" => array("Tcore", "Température corporelle"), "0002-4bb8" => array("SpO2", "SpO2"), "0002-5900" => array("HC", "Périmètre cranien"), "0002-f093" => array("Weight", "Poids"), "0002-f094" => array("Height", "Taille"), "0401-0adc" => array("Crea", "Créatinine"), "0401-0bc8" => array("Age", "Age"));
     $values = array();
     foreach ($mdil_params as $_code => $_labels) {
         list($_label, $_desc) = $_labels;
         $values[] = "('MDIL', '{$_code}', '{$_label}', '{$_desc}', 'NM')";
     }
     $query = "INSERT INTO `observation_value_type` (`coding_system`, `code`, `label`, `desc`, `datatype`) VALUES " . implode("\n, ", $values);
     $this->addQuery($query);
     $mdil_units = array("0004-0220" => array("%", "%"), "0004-0500" => array("m", "m"), "0004-0511" => array("cm", "cm"), "0004-0512" => array("mm", "mm"), "0004-0652" => array("ml", "ml"), "0004-06c3" => array("kg", "kg"), "0004-0aa0" => array("bpm", "bpm"), "0004-0ae0" => array("rpm", "rpm"), "0004-0f20" => array("mmHg", "mmHg"));
     $values = array();
     foreach ($mdil_units as $_code => $_labels) {
         list($_label, $_desc) = $_labels;
         $values[] = "('MDIL', '{$_code}', '{$_label}', '{$_desc}')";
     }
     $query = "INSERT INTO `observation_value_unit` (`coding_system`, `code`, `label`, `desc`) VALUES " . implode("\n, ", $values);
     $this->addQuery($query);
     $this->makeRevision("1.36");
     $mdil_units = array("0004-1140" => array("°F", "°F"), "0004-17a0" => array("°C", "°C"));
     $values = array();
     foreach ($mdil_units as $_code => $_labels) {
         list($_label, $_desc) = $_labels;
         $values[] = "('MDIL', '{$_code}', '{$_label}', '{$_desc}')";
     }
     $query = "INSERT INTO `observation_value_unit` (`coding_system`, `code`, `label`, `desc`) VALUES " . implode("\n, ", $values);
     $this->addQuery($query);
     $this->makeRevision("1.37");
     $query = "ALTER TABLE `observation_result`\r\n                ADD `status` ENUM ('C','D','F','I','N','O','P','R','S','U','W','X') DEFAULT 'F';";
     $this->addQuery($query);
     $this->makeRevision("1.38");
     $query = "CREATE TABLE `supervision_graph` (\r\n              `supervision_graph_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `owner_class` ENUM ('CGroups') NOT NULL,\r\n              `owner_id` INT (11) UNSIGNED NOT NULL,\r\n              `title` VARCHAR (255) NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph`\r\n              ADD INDEX (`owner_id`),\r\n              ADD INDEX (`owner_class`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `supervision_graph_axis` (\r\n              `supervision_graph_axis_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `supervision_graph_id` INT (11) UNSIGNED NOT NULL,\r\n              `title` VARCHAR (255) NOT NULL,\r\n              `limit_low` FLOAT,\r\n              `limit_high` FLOAT,\r\n              `display` ENUM ('points','lines','bars'),\r\n              `show_points` ENUM ('0','1') NOT NULL DEFAULT '0',\r\n              `symbol` ENUM ('circle','square','diamond','cross','triangle') NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_axis`\r\n              ADD INDEX (`supervision_graph_id`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `supervision_graph_series` (\r\n              `supervision_graph_series_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `supervision_graph_axis_id` INT (11) UNSIGNED NOT NULL,\r\n              `title` VARCHAR (255),\r\n              `value_type_id` INT (11) UNSIGNED NOT NULL,\r\n              `value_unit_id` INT (11) UNSIGNED NOT NULL,\r\n              `color` CHAR (6) NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_series`\r\n              ADD INDEX (`supervision_graph_axis_id`),\r\n              ADD INDEX (`value_type_id`),\r\n              ADD INDEX (`value_unit_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result`\r\n              CHANGE `value` `value` VARCHAR (255) NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result_set`\r\n              CHANGE `context_class` `context_class` VARCHAR (80) NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.39");
     $query = "ALTER TABLE `supervision_graph`\r\n              ADD `disabled` ENUM ('0','1') NOT NULL DEFAULT '1',\r\n              ADD INDEX (`disabled`);";
     $this->addQuery($query);
     $this->makeRevision("1.40");
     $query = "ALTER TABLE `correspondant_patient`\r\n              ADD `fax` BIGINT (10) UNSIGNED ZEROFILL,\r\n              ADD `mob` BIGINT (10) UNSIGNED ZEROFILL";
     $this->addQuery($query);
     $this->makeRevision("1.41");
     $query = "ALTER TABLE `medecin`\r\n      CHANGE `cp` `cp` VARCHAR(8) DEFAULT ''";
     $this->addQuery($query);
     $this->makeRevision("1.42");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `bricker` FLOAT UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.43");
     $query = "ALTER TABLE `patients`\r\n              CHANGE `cp` `cp` VARCHAR (5),\r\n              CHANGE `assure_cp` `assure_cp` VARCHAR (5)";
     $this->addQuery($query);
     $this->makeRevision("1.44");
     $query = "ALTER TABLE `antecedent`\r\n            CHANGE `type` `type`\r\n            ENUM('med','alle','trans','obst',\r\n              'chir','fam','anesth','gyn','cardio',\r\n              'pulm','stomato','plast','ophtalmo',\r\n              'digestif','gastro','stomie','uro','ortho',\r\n              'traumato','amput','neurochir','greffe','thrombo',\r\n              'cutane','hemato','rhumato','neuropsy',\r\n              'infect','endocrino','carcino','orl',\r\n              'addiction','habitus', 'deficience');";
     $this->addQuery($query);
     $this->makeRevision("1.45");
     $query = "ALTER TABLE `patients`\r\n              CHANGE `tel` `tel` VARCHAR (20),\r\n              CHANGE `tel2` `tel2` VARCHAR (20),\r\n              CHANGE `tel_autre` `tel_autre` VARCHAR (40),\r\n              CHANGE `assure_tel` `assure_tel` VARCHAR (20),\r\n              CHANGE `assure_tel2` `assure_tel2` VARCHAR (20)";
     $this->addQuery($query);
     $query = "ALTER TABLE `correspondant_patient`\r\n              CHANGE `tel` `tel` VARCHAR (20),\r\n              CHANGE `mob` `mob` VARCHAR (20),\r\n              CHANGE `fax` `fax` VARCHAR (20);";
     $this->addQuery($query);
     $this->makeRevision("1.46");
     $query = "ALTER TABLE `etat_dent`\r\n              CHANGE `etat` `etat` ENUM ('bridge','pivot','mobile','appareil','implant','defaut');";
     $this->addQuery($query);
     $this->makeRevision("1.47");
     $query = "ALTER TABLE `medecin`\r\n              CHANGE `tel` `tel` VARCHAR (20),\r\n              CHANGE `fax` `fax` VARCHAR (20),\r\n              CHANGE `portable` `portable` VARCHAR (20);";
     $this->addQuery($query);
     $this->makeRevision("1.48");
     $query = "ALTER TABLE `patients`\r\n                ADD `patient_link_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.49");
     $query = "ALTER TABLE `traitement`\r\n              ADD `annule` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.50");
     $query = "ALTER TABLE `antecedent`\r\n              CHANGE `type` `type` VARCHAR (80);";
     $this->addQuery($query);
     $this->makeRevision("1.51");
     $query = "ALTER TABLE `correspondant_patient`\r\n      ADD `nom_jeune_fille` VARCHAR (255),\r\n      ADD `naissance` DATE;";
     $this->addQuery($query);
     $this->makeRevision("1.52");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `douleur_en` FLOAT UNSIGNED,\r\n              ADD `douleur_doloplus` TINYINT (4) UNSIGNED,\r\n              ADD `douleur_algoplus` TINYINT (4) UNSIGNED,\r\n              ADD `ecpa_avant` TINYINT (4) UNSIGNED,\r\n              ADD `ecpa_apres` TINYINT (4) UNSIGNED,\r\n              ADD `vision_oeil_droit` TINYINT (4) UNSIGNED,\r\n              ADD `vision_oeil_gauche` TINYINT (4) UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.53");
     $query = "ALTER TABLE `correspondant_patient`\r\n                 ADD `ean` VARCHAR (30);";
     $this->addQuery($query);
     $this->makeRevision("1.54");
     $query = "ALTER TABLE `correspondant_patient`\r\n              ADD `date_debut` DATE,\r\n              ADD `date_fin` DATE,\r\n              ADD `num_assure` VARCHAR (30),\r\n              ADD `employeur` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `correspondant_patient`\r\n              ADD INDEX (`naissance`),\r\n              ADD INDEX (`date_debut`),\r\n              ADD INDEX (`date_fin`),\r\n              ADD INDEX (`employeur`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n              ADD `avs` VARCHAR (15),\r\n              ADD `assure_avs` VARCHAR (15);";
     $this->addQuery($query);
     $this->makeRevision("1.55");
     $query = "ALTER TABLE `constantes_medicales` ADD `creatininemie` FLOAT UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.56");
     $query = "ALTER TABLE `constantes_medicales` ADD `glasgow` FLOAT UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.57");
     $query = "ALTER TABLE `constantes_medicales`\r\n              ADD `drain_thoracique_flow` FLOAT UNSIGNED AFTER `drain_thoracique_2`,\r\n              ADD `drain_shirley` FLOAT UNSIGNED AFTER `drain_mediastinal`";
     $this->addQuery($query);
     $this->makeRevision("1.58");
     $query = "CREATE TABLE `correspondant_modele` (\r\n      `correspondant_modele_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `group_id` INT (11) UNSIGNED,\r\n      `relation` ENUM ('assurance','autre','confiance','employeur','inconnu','prevenir'),\r\n      `relation_autre` VARCHAR (255),\r\n      `nom` VARCHAR (255),\r\n      `nom_jeune_fille` VARCHAR (255),\r\n      `prenom` VARCHAR (255),\r\n      `naissance` CHAR (10),\r\n      `adresse` TEXT,\r\n      `cp` INT (5) UNSIGNED ZEROFILL,\r\n      `ville` VARCHAR (255),\r\n      `tel` VARCHAR (20),\r\n      `mob` VARCHAR (20),\r\n      `fax` VARCHAR (20),\r\n      `urssaf` BIGINT (11) UNSIGNED ZEROFILL,\r\n      `parente` ENUM ('ami','ascendant','autre','beau_fils','colateral','collegue',\r\n        'compagnon','conjoint','directeur','divers','employeur','employe','enfant',\r\n        'enfant_adoptif','entraineur','epoux','frere','grand_parent','mere','pere',\r\n        'petits_enfants','proche','proprietaire','soeur','tuteur'),\r\n      `parente_autre` VARCHAR (255),\r\n      `email` VARCHAR (255),\r\n      `remarques` TEXT,\r\n      `ean` VARCHAR (30),\r\n      `num_assure` VARCHAR (30),\r\n      `employeur` INT (11) UNSIGNED\r\n     ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `correspondant_modele`\r\n                ADD INDEX (`group_id`),\r\n                ADD INDEX (`employeur`);";
     $this->addQuery($query);
     $this->makeRevision("1.59");
     $query = "ALTER TABLE `correspondant_patient`\r\n                CHANGE `patient_id` `patient_id` INT (11) UNSIGNED,\r\n                ADD `ean_id` VARCHAR (20)";
     $this->addQuery($query);
     $this->makeRevision("1.60");
     $query = "DROP TABLE `correspondant_modele`";
     $this->addQuery($query);
     $this->makeRevision("1.61");
     $query = "ALTER TABLE `patients`\r\n                CHANGE `avs` `avs` VARCHAR (16);";
     $this->addQuery($query);
     $this->makeRevision("1.62");
     $query = "ALTER TABLE `correspondant_patient`\r\n                CHANGE `cp` `cp` VARCHAR (5)";
     $this->addQuery($query);
     $this->makeRevision("1.63");
     $query = "ALTER TABLE `correspondant_patient`\r\n    ADD `assure_id` VARCHAR (25) AFTER ean";
     $this->addQuery($query);
     $this->makeRevision("1.64");
     $query = "ALTER TABLE `supervision_graph_axis`\r\n                CHANGE `display` `display` ENUM ('points','lines','bars','stack','bandwidth');";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_series`\r\n                ADD `integer_values` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $query = "CREATE TABLE `supervision_graph_pack` (\r\n                `supervision_graph_pack_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `owner_class` ENUM ('CGroups') NOT NULL,\r\n                `owner_id` INT (11) UNSIGNED NOT NULL,\r\n                `title` VARCHAR (255) NOT NULL,\r\n                `disabled` ENUM ('0','1') NOT NULL DEFAULT '1'\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_pack`\r\n                ADD INDEX `owner` (`owner_class`, `owner_id`)";
     $this->addQuery($query);
     $query = "CREATE TABLE `supervision_graph_to_pack` (\r\n                `supervision_graph_to_pack_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `graph_class` ENUM ('CSupervisionGraph','CSupervisionTimedData'),\r\n                `graph_id` INT (11) UNSIGNED NOT NULL,\r\n                `pack_id` INT (11) UNSIGNED NOT NULL,\r\n                `rank` INT (11) NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_to_pack`\r\n                ADD INDEX (`graph_id`),\r\n                ADD INDEX (`pack_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph`\r\n                ADD `height` INT (11) UNSIGNED NOT NULL DEFAULT 200;";
     $this->addQuery($query);
     $query = "CREATE TABLE `supervision_timed_data` (\r\n                `supervision_timed_data_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `owner_class` ENUM ('CGroups') NOT NULL,\r\n                `owner_id` INT (11) UNSIGNED NOT NULL,\r\n                `title` VARCHAR (255) NOT NULL,\r\n                `disabled` ENUM ('0','1') NOT NULL DEFAULT '1',\r\n                `period` ENUM ('1','5','10','15','20','30','60') NOT NULL\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_timed_data`\r\n                ADD INDEX (`owner_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.65");
     $query = "ALTER TABLE  `constantes_medicales`\r\n                DROP INDEX `context_id`,\r\n                ADD  INDEX `patient_id_datetime` (`patient_id`, `datetime`),\r\n                ADD  INDEX `context_class` (`context_class`),\r\n                ADD  INDEX `context` (`context_class`, `context_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.66");
     $query = "ALTER TABLE `patients`\r\n              DROP `assure_avs`;";
     $this->addQuery($query);
     $this->makeRevision("1.68");
     $query = "ALTER TABLE `medecin`\r\n                ADD `email_apicrypt` VARCHAR (50),\r\n                ADD `last_ldap_checkout` DATE;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD `province` VARCHAR (40) AFTER adresse;";
     $this->addQuery($query);
     $this->makeRevision("1.69");
     $this->addMethod("moveConstantesConfigsFromOldTable");
     // TODO: "DROP TABLE config_constantes_medicales"
     $this->makeRevision("1.70");
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `hauteur_uterine` FLOAT UNSIGNED AFTER `perimetre_thoracique`,\r\n                ADD `peak_flow` FLOAT UNSIGNED AFTER `vision_oeil_gauche`;";
     $this->addQuery($query);
     $this->makeRevision("1.71");
     $query = "ALTER TABLE `dossier_medical` \r\n                ADD `facteurs_risque` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.72");
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `hemoglobine_rapide` FLOAT AFTER `glycemie`,\r\n                ADD `gaz` INT (11) UNSIGNED AFTER `injection`,\r\n                ADD `selles` INT (11) UNSIGNED AFTER `gaz`";
     $this->addQuery($query);
     $this->makeRevision("1.73");
     $query = "ALTER TABLE `patients`\r\n                ADD `situation_famille` ENUM ('S','M','G','P','D','W','A')";
     $this->addQuery($query);
     $this->makeRevision("1.74");
     $query = "ALTER TABLE `patients`\r\n                ADD `is_smg` ENUM ('0','1') DEFAULT '0' AFTER `cmu`";
     $this->addQuery($query);
     $this->makeRevision("1.75");
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `cetonemie` FLOAT UNSIGNED AFTER `glycemie`";
     $this->addQuery($query);
     $this->makeRevision("1.76");
     $query = "ALTER TABLE `constantes_medicales`\r\n      ADD `redon_5` FLOAT UNSIGNED AFTER `redon_4`;";
     $this->addQuery($query);
     $this->makeRevision("1.77");
     $query = "ALTER TABLE `constantes_medicales` \r\n                ADD `douleur_evs` TINYINT (4) UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("1.78");
     $this->addMethod("addConstantesRank");
     $this->makeRevision("1.79");
     $query = "UPDATE `patients` SET `INSC` = NULL, `INSC_date` = null;";
     $this->addQuery($query);
     $this->makeRevision("1.80");
     $query = "ALTER TABLE `correspondant_patient` \r\n                ADD `ean_base` VARCHAR (30),\r\n                ADD `type_pec` ENUM ('TG','TP','TS');";
     $this->addQuery($query);
     $this->makeRevision("1.81");
     $query = "ALTER TABLE `constantes_medicales` \r\n                ADD `ta_couche` VARCHAR (10),\r\n                ADD `ta_assis` VARCHAR (10),\r\n                ADD `ta_debout` VARCHAR (10),\r\n                ADD `redon_6` FLOAT UNSIGNED,\r\n                ADD `redon_7` FLOAT UNSIGNED,\r\n                ADD `redon_8` FLOAT UNSIGNED,\r\n                ADD `redon_accordeon_1` FLOAT UNSIGNED,\r\n                ADD `redon_accordeon_2` FLOAT UNSIGNED,\r\n                ADD `drain_thoracique_3` FLOAT UNSIGNED,\r\n                ADD `drain_thoracique_4` FLOAT UNSIGNED,\r\n                ADD `drain_dve` FLOAT UNSIGNED,\r\n                ADD `drain_kher` FLOAT UNSIGNED,\r\n                ADD `drain_crins` FLOAT UNSIGNED,\r\n                ADD `drain_sinus` FLOAT UNSIGNED,\r\n                ADD `drain_orifice_1` FLOAT UNSIGNED,\r\n                ADD `drain_orifice_2` FLOAT UNSIGNED,\r\n                ADD `drain_orifice_3` FLOAT UNSIGNED,\r\n                ADD `drain_orifice_4` FLOAT UNSIGNED,\r\n                ADD `drain_ileostomie` FLOAT UNSIGNED,\r\n                ADD `drain_colostomie` FLOAT UNSIGNED,\r\n                ADD `drain_gastrostomie` FLOAT UNSIGNED,\r\n                ADD `drain_jejunostomie` FLOAT UNSIGNED,\r\n                ADD `sonde_rectale` FLOAT UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.82");
     $query = "INSERT INTO `configuration` (`feature`, `value`, `object_id`, `object_class`)\r\n                SELECT REPLACE(`feature`, ' selection ', ' selection_cabinet '), `value`, `object_id`, `object_class`\r\n                FROM `configuration`\r\n                WHERE `feature` LIKE 'dPpatients CConstantesMedicales selection %'\r\n                AND (\r\n                  `object_class` = 'CGroups' OR `object_class` IS NULL AND `object_id` IS NULL\r\n                )";
     $this->addQuery($query);
     $this->makeRevision("1.83");
     $query = "ALTER TABLE `correspondant_patient`\r\n                CHANGE `relation` `relation` ENUM ('assurance','autre','confiance','employeur','inconnu','prevenir') DEFAULT 'prevenir',\r\n                ADD `surnom` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("1.84");
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `ph_sanguin` FLOAT UNSIGNED,\r\n                ADD `lactates` FLOAT UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.85");
     $query = "CREATE TABLE `supervision_timed_picture` (\r\n                `supervision_timed_picture_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `owner_class` ENUM ('CGroups') NOT NULL,\r\n                `owner_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `title` VARCHAR (255) NOT NULL,\r\n                `disabled` ENUM ('0','1') NOT NULL DEFAULT '1',\r\n                `value_type_id` INT (11) UNSIGNED NOT NULL\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_timed_picture`\r\n                ADD INDEX `owner` (`owner_class`, `owner_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_to_pack`\r\n                CHANGE `graph_class` `graph_class` VARCHAR (80);";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result`\r\n                CHANGE `unit_id` `unit_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_timed_data`\r\n                CHANGE `period` `period` ENUM ('1','5','10','15','20','30','60'),\r\n                ADD `value_type_id` INT (11) UNSIGNED NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_timed_data`\r\n                ADD INDEX (`value_type_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_result`\r\n                ADD `file_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `observation_value_type`\r\n                CHANGE `datatype` `datatype` ENUM ('NM','ST','TX','FILE') NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.86");
     $mdil_params = array("0002-4a15" => array("ABPs", "ABP (systolic)"), "0002-4a16" => array("ABPd", "ABP (diastolic)"), "0002-4a17" => array("ABPm", "ABP (mean)"));
     $values = array();
     foreach ($mdil_params as $_code => $_labels) {
         list($_label, $_desc) = $_labels;
         $values[] = "('MDIL', '{$_code}', '{$_label}', '{$_desc}', 'NM')";
     }
     $query = "INSERT INTO `observation_value_type` (`coding_system`, `code`, `label`, `desc`, `datatype`) VALUES " . implode("\n, ", $values);
     $this->addQuery($query);
     $this->makeRevision("1.87");
     $query = "CREATE TABLE `supervision_graph_value_label` (\r\n                `supervision_graph_value_label_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `supervision_graph_axis_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `value` INT (11) NOT NULL,\r\n                `title` VARCHAR (255) NOT NULL\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_value_label`\r\n                ADD INDEX (`supervision_graph_axis_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_graph_series`\r\n                CHANGE `value_unit_id` `value_unit_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.88");
     $query = "ALTER TABLE `observation_result`\r\n                ADD `label_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.89");
     $query = "ALTER TABLE `dossier_medical`\r\n                ADD `absence_traitement` ENUM ('0','1');";
     $this->addQuery($query);
     $this->makeRevision("1.90");
     $this->addMethod('modifyConstantsRanksConfigs');
     $this->makeRevision('1.91');
     $query = 'ALTER TABLE `constantes_medicales`
             ADD `hemo_glycquee` FLOAT UNSIGNED,
             ADD `saturation_air` FLOAT UNSIGNED,
             ADD `clair_creatinine` FLOAT UNSIGNED;';
     $this->addQuery($query);
     $this->makeRevision("1.92");
     $query = "CREATE TABLE `ins_patient` (\r\n                `ins_patient_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `patient_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `ins` VARCHAR (255) NOT NULL,\r\n                `type` ENUM ('A','C') NOT NULL,\r\n                `date` DATETIME NOT NULL,\r\n                `provider` VARCHAR (255) NOT NULL\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("1.93");
     $query = "ALTER TABLE `ins_patient`\r\n                ADD INDEX (`patient_id`),\r\n                ADD INDEX (`date`);";
     $this->addQuery($query);
     $this->makeRevision("1.94");
     $query = "ALTER TABLE `patients`\r\n                DROP `INSC`,\r\n                DROP `INSC_DATE`";
     $this->addQuery($query);
     $this->makeRevision("1.95");
     $query = "ALTER TABLE `dossier_medical`\r\n                ADD `groupe_sanguin` ENUM ('?','O','A','B','AB') DEFAULT '?',\r\n                ADD `rhesus` ENUM ('?','NEG','POS') DEFAULT '?',\r\n                ADD `groupe_ok` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision('1.96');
     $this->addDependency("dPcabinet", "1.23");
     //Création des dossiers médicaux manquants correspondant aux consultations d'anesthésie
     $query = "INSERT INTO `dossier_medical` (`object_class`, `object_id`)\r\n                SELECT 'CPatient', c.patient_id\r\n                FROM `consultation_anesth` ca, `consultation` c\r\n                WHERE ca.consultation_id = c.consultation_id\r\n                AND c.patient_id IS NOT NULL\r\n                AND ( (ca.rhesus != '?' AND ca.rhesus != '')\r\n                      OR ca.groupe_ok = '1'\r\n                      OR (ca.groupe != '?' AND ca.groupe != '') )\r\n                AND NOT EXISTS (\r\n                  SELECT * FROM dossier_medical AS d\r\n                  WHERE c.patient_id = d.object_id\r\n                  AND d.object_class = 'CPatient'\r\n                );";
     $this->addQuery($query);
     //Mise à jour des rhésus dans les dossiers médicaux
     $query = "UPDATE `dossier_medical` d, `consultation_anesth` ca, `consultation` c\r\n                SET d.rhesus = ca.rhesus\r\n                WHERE d.object_class = 'CPatient'\r\n                AND ca.consultation_id = c.consultation_id\r\n                AND c.patient_id = d.object_id\r\n                AND c.patient_id IS NOT NULL\r\n                AND ca.rhesus != '?'\r\n                AND ca.rhesus != ''\r\n                AND d.rhesus = '?';";
     $this->addQuery($query);
     //Mise à jour du groupe_ok dans les dossiers médicaux
     $query = "UPDATE `dossier_medical` d, `consultation_anesth` ca, `consultation` c\r\n                SET d.groupe_ok = ca.groupe_ok\r\n                WHERE d.object_class = 'CPatient'\r\n                AND ca.consultation_id = c.consultation_id\r\n                AND c.patient_id = d.object_id\r\n                AND c.patient_id IS NOT NULL\r\n                AND ca.groupe_ok = '1'\r\n                AND d.groupe_ok = '0';";
     $this->addQuery($query);
     //Mise à jour du groupe sanguin dans les dossiers médicaux
     $query = "UPDATE `dossier_medical` d, `consultation_anesth` ca, `consultation` c\r\n                SET d.groupe_sanguin = ca.groupe\r\n                WHERE d.object_class = 'CPatient'\r\n                AND ca.consultation_id = c.consultation_id\r\n                AND c.patient_id = d.object_id\r\n                AND c.patient_id IS NOT NULL\r\n                AND ca.groupe != '?'\r\n                AND ca.groupe != ''\r\n                AND d.groupe_sanguin = '?';";
     $this->addQuery($query);
     // Preference pour ranger les antecedents par date
     $this->makeRevision("1.97");
     $this->addPrefQuery("sort_atc_by_date", "0");
     $this->addQuery($query);
     // Index manquants dans la table Patient
     $this->makeRevision('1.98');
     $query = "ALTER TABLE `patients`\r\n      ADD INDEX (`deces`),\r\n      ADD INDEX (`ville`),\r\n      ADD INDEX (`profession`),\r\n      ADD INDEX (`patient_link_id`),\r\n      ADD INDEX (`assure_profession`),\r\n      ADD INDEX (`date_lecture_vitale`);";
     $this->addQuery($query);
     $this->makeRevision("1.99");
     $query = "ALTER TABLE `patients`\r\n    ADD `allow_sms_notification` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.00");
     //Default's value
     $query = "INSERT INTO configuration (feature, value)\r\n                SELECT 'dPpatients CPatient nom_jeune_fille_mandatory',\r\n                       dPpatients_CPatient_nom_jeune_fille_mandatory\r\n                FROM groups_config\r\n                WHERE object_id IS NULL;";
     $this->addQuery($query);
     $this->makeRevision("2.01");
     $query = "INSERT INTO configuration (feature, value, object_id, object_class)\r\n                SELECT 'dPpatients CPatient nom_jeune_fille_mandatory',\r\n                       dPpatients_CPatient_nom_jeune_fille_mandatory,\r\n                       object_id, 'CGroups'\r\n                FROM groups_config\r\n                WHERE object_id IS NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("2.02");
     $this->makeRevision("2.03");
     $query = "ALTER TABLE `correspondant_patient`\r\n                CHANGE `nom` `nom` VARCHAR (255) NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD `function_id` INT (11) UNSIGNED AFTER `patient_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD INDEX (`function_id`);";
     $this->addQuery($query);
     $this->makeRevision("2.04");
     $query = "ALTER TABLE `medecin`\r\n                ADD `function_id` INT (11) UNSIGNED AFTER `medecin_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `medecin`\r\n                ADD INDEX (`function_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `correspondant_patient`\r\n                ADD `function_id` INT (11) UNSIGNED AFTER `correspondant_patient_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `correspondant_patient`\r\n                ADD INDEX (`function_id`);";
     $this->addQuery($query);
     $this->makeRevision("2.05");
     $query = "ALTER TABLE `medecin`\r\n                ADD `sexe` VARCHAR (2) NOT NULL DEFAULT 'u' AFTER `jeunefille` ";
     $this->addQuery($query);
     $this->makeRevision("2.06");
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `alat` INT (3),\r\n                ADD `asat` INT (3),\r\n                ADD `broadman` INT (2),\r\n                ADD `cpk` INT (3),\r\n                ADD `hdlc` FLOAT,\r\n                ADD `ipsc` FLOAT,\r\n                ADD `gammagt` INT (3),\r\n                ADD `ldlc` FLOAT,\r\n                ADD `plaquettes` INT (4),\r\n                ADD `potassium` FLOAT,\r\n                ADD `sodium` FLOAT,\r\n                ADD `triglycerides` FLOAT;";
     $this->addQuery($query);
     $this->makeRevision("2.07");
     $query = "ALTER TABLE `constantes_medicales`\r\n      ADD `user_id` INT (11) UNSIGNED AFTER `constantes_medicales_id`";
     $this->addQuery($query);
     $this->makeRevision("2.08");
     $query = "ALTER TABLE `patients`\r\n                ADD `allow_sisra_send` ENUM ('0','1') DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("2.09");
     $query = "ALTER TABLE `correspondant_patient`\r\n                ADD `sex` VARCHAR (2) NOT NULL DEFAULT 'u' AFTER `prenom` ";
     $this->addQuery($query);
     $this->makeRevision("2.10");
     $this->addMethod("updateDeathDate");
     $this->makeRevision("2.11");
     $this->addPrefQuery('update_patient_from_vitale_behavior', 'choice');
     $this->makeRevision("2.12");
     $this->addDefaultConfig("dPpatients CPatient allow_anonymous_patient", 'dPplanningOp CSejour create_anonymous_pat');
     $this->addDefaultConfig("dPpatients CPatient anonymous_sexe", 'dPplanningOp CSejour anonymous_sexe');
     $this->addDefaultConfig("dPpatients CPatient anonymous_naissance", 'dPplanningOp CSejour anonymous_naissance');
     $this->makeRevision("2.13");
     $query = "CREATE TABLE `patient_state` (\r\n                `patient_state_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `patient_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `mediuser_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `state` ENUM ('PROV','VALI','DPOT','ANOM', 'CACH') NOT NULL,\r\n                `datetime` DATETIME NOT NULL,\r\n                `reason` TEXT\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patient_state`\r\n                ADD INDEX (`patient_id`),\r\n                ADD INDEX (`datetime`),\r\n                ADD INDEX (`mediuser_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `patients`\r\n                ADD `status` ENUM ('PROV','VALI','DPOT','ANOM','CACH'),\r\n                ADD INDEX (`status`);";
     $this->addQuery($query);
     $this->makeRevision("2.14");
     $query = "CREATE TABLE `patient_link` (\r\n                `patient_link_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `patient_id1` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `patient_id2` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `type` ENUM ('DPOT') DEFAULT 'DPOT',\r\n                `reason` TEXT\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `patient_link`\r\n                ADD INDEX (`patient_id1`),\r\n                ADD INDEX (`patient_id2`);";
     $this->addQuery($query);
     //cas où des doublons ont été saisie
     $query = "INSERT INTO `patient_link`(`patient_id1`, `patient_id2`)\r\n                SELECT `patient_id`, `patient_link_id` FROM `patients` WHERE `patient_link_id` IS NOT NULL";
     $this->addQuery($query);
     $this->makeRevision("2.15");
     $this->addFunctionalPermQuery("allowed_identity_status", "0");
     $this->makeRevision("2.16");
     $query = "UPDATE `user_preferences` SET `key` = 'LogicielLectureVitale', `value` = 'none'\r\n                WHERE `key` = 'VitaleVision' AND `value` = '0';";
     $this->addQuery($query);
     $query = "UPDATE `user_preferences` SET `key` = 'LogicielLectureVitale', `value` = 'vitaleVision'\r\n                WHERE `key` = 'VitaleVision' AND `value` = '1';";
     $this->addQuery($query);
     $this->makeRevision("2.17");
     $this->addFunctionalPermQuery("allowed_modify_identity_status", "0");
     $this->makeRevision("2.18");
     $this->addPrefQuery("new_date_naissance_selector", "0");
     $this->makeRevision("2.19");
     $query = "ALTER TABLE `etat_dent`\r\n                CHANGE `etat` `etat` ENUM ('bridge','pivot','mobile','appareil','implant','defaut','absence','app-partiel');";
     $this->addQuery($query);
     $this->makeRevision('2.20');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `sens_membre_inf_d` FLOAT,\r\n                ADD `sens_membre_inf_g` FLOAT,\r\n                ADD `tonus_d` FLOAT,\r\n                ADD `tonus_g` FLOAT,\r\n                ADD `motricite_d` FLOAT,\r\n                ADD `motricite_g` FLOAT;";
     $this->addQuery($query);
     $this->makeRevision('2.21');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `perimetre_brachial` FLOAT UNSIGNED AFTER `perimetre_abdo`;";
     $this->addQuery($query);
     $this->makeRevision('2.22');
     $this->addDefaultConfig("dPpatients identitovigilance merge_only_admin", "dPpatients CPatient merge_only_admin");
     $this->addDefaultConfig("dPpatients identitovigilance show_patient_link", "dPpatients CPatient show_patient_link");
     $this->addDefaultConfig("dPpatients CTraitement enabled", "dPpatients CTraitement enabled");
     $this->makeRevision('2.23');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `creation_date` DATETIME AFTER `user_id`;";
     $this->addQuery($query);
     $this->makeRevision("2.24");
     $query = "ALTER TABLE `supervision_graph`\r\n                ADD `automatic_protocol` ENUM ('Kheops-Concentrator');";
     $this->addQuery($query);
     $query = "CREATE TABLE `supervision_instant_data` (\r\n                `supervision_instant_data_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `value_type_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `value_unit_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `size` TINYINT (4) UNSIGNED NOT NULL DEFAULT '0',\r\n                `color` VARCHAR (6),\r\n                `owner_class` ENUM ('CGroups') NOT NULL,\r\n                `owner_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `title` VARCHAR (255) NOT NULL,\r\n                `disabled` ENUM ('0','1') NOT NULL DEFAULT '1',\r\n                INDEX (`value_type_id`),\r\n                INDEX (`value_unit_id`),\r\n                INDEX `owner` (`owner_class`, `owner_id`)\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision('2.25');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `echelle_confort` INT(2);";
     $this->addQuery($query);
     $this->makeRevision('2.26');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `pres_artere_invasive` INT(3);";
     $this->addQuery($query);
     $this->makeRevision('2.27');
     $query = "ALTER TABLE `patients`\r\n              ADD `ame` ENUM('0','1') DEFAULT '0' AFTER `cmu`;";
     $this->addQuery($query);
     $this->makeRevision('2.28');
     $query = "ALTER TABLE `patient_state`\r\n                CHANGE `state` `state` ENUM ('PROV','VALI','DPOT','ANOM','CACH','DOUB','DESA','DOUA','COLP','COLV','FILI','HOMD',\r\n                'HOMA','USUR','IDRA','RECD','IDVER') NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision('2.29');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD perimetre_hanches FLOAT UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision('2.30');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `capnometrie` INT(3) UNSIGNED,\r\n                ADD `sortie_lavage` INT(3) UNSIGNED,\r\n                ADD `coloration` INT(1) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision('2.31');
     $this->addPrefQuery('constantes_show_comments_tooltip', '0');
     $this->makeRevision('2.32');
     $query = "ALTER TABLE `constantes_medicales`\r\n                ADD `motricite_inf_d` FLOAT,\r\n                ADD `motricite_inf_g` FLOAT,\r\n                ADD `perimetre_taille` INT(3) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision('2.33');
     $query = "CREATE TABLE `pathologie` (\r\n                `pathologie_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `debut` DATE,\r\n                `fin` DATE,\r\n                `pathologie` TEXT,\r\n                `annule` ENUM ('0','1') DEFAULT '0',\r\n                `dossier_medical_id` INT (11) UNSIGNED NOT NULL DEFAULT '0'\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `pathologie`\r\n                ADD INDEX (`debut`),\r\n                ADD INDEX (`fin`),\r\n                ADD INDEX (`dossier_medical_id`);";
     $this->addQuery($query);
     $this->makeRevision("2.34");
     $query = "ALTER TABLE `supervision_graph_axis`\r\n                ADD `in_doc_template` ENUM ('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_timed_data`\r\n                ADD `in_doc_template` ENUM ('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `supervision_timed_picture`\r\n                ADD `in_doc_template` ENUM ('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision('2.35');
     $query = "ALTER TABLE `antecedent`\r\n                ADD `owner_id` INT (11) UNSIGNED,\r\n                ADD `creation_date` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `traitement`\r\n                ADD `owner_id` INT (11) UNSIGNED,\r\n                ADD `creation_date` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `pathologie`\r\n                ADD `owner_id` INT (11) UNSIGNED NOT NULL,\r\n                ADD `creation_date` DATETIME NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("2.36");
     $query = "ALTER TABLE `constantes_medicales`\r\n            ADD `contraction_uterine` FLOAT,\r\n            ADD `bruit_foetal` FLOAT;";
     $this->addQuery($query);
     $this->makeRevision("2.37");
     $query = "ALTER TABLE `pathologie`\r\n      ADD `indication_id` INT (11),\r\n      ADD `indication_group_id` INT (11);";
     $this->addQuery($query);
     $this->makeRevision("2.38");
     $query = "ALTER TABLE `antecedent`\r\n      ADD `majeur` ENUM ('0','1') DEFAULT '0' AFTER `annule`;";
     $this->addQuery($query);
     $this->makeRevision("2.39");
     $query = "ALTER TABLE `dossier_medical`\r\n                ADD `medecin_traitant_id` INT (11) UNSIGNED AFTER `dossier_medical_id`,\r\n                ADD `derniere_mapa` DATE AFTER `absence_traitement`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `dossier_medical`\r\n                ADD INDEX (`medecin_traitant_id`),\r\n                ADD INDEX (`derniere_mapa`);";
     $this->addQuery($query);
     $this->makeRevision("2.40");
     $query = "CREATE TABLE `salutation` (\r\n                `salutation_id`    INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n                `owner_id`         INT(11) UNSIGNED NOT NULL,\r\n                `object_class`     VARCHAR(255) NOT NULL,\r\n                `object_id`        INT(11) UNSIGNED NOT NULL,\r\n                `starting_formula` VARCHAR(255) NOT NULL,\r\n                `closing_formula`  VARCHAR(255) NOT NULL,\r\n                INDEX (`owner_id`),\r\n                INDEX `object` (`object_class`, `object_id`),\r\n                UNIQUE (`owner_id`, `object_class`, `object_id`)\r\n                )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("2.41");
     $this->addPrefQuery('constantes_show_view_tableau', '0');
     $this->makeRevision("2.42");
     $query = "ALTER TABLE `medecin`\r\n            ADD `titre` ENUM ('m', 'mme', 'dr', 'pr') AFTER `sexe`;";
     $this->addQuery($query);
     $this->makeRevision("2.43");
     $query = "ALTER TABLE `medecin`\r\n      ADD `actif` ENUM ('0','1') DEFAULT '1' AFTER `sexe`;";
     $this->addQuery($query);
     $this->mod_version = '2.44';
     $query = "SHOW TABLES LIKE 'communes_suisse'";
     $this->addDatasource("INSEE", $query);
     if (array_key_exists('INSEE', CAppUI::conf('db'))) {
         $dsn = CSQLDataSource::get('INSEE');
         if ($dsn->fetchRow($dsn->exec('SHOW TABLES LIKE \'communes_france\';'))) {
             $query = "SELECT * FROM `communes_france` WHERE `code_postal` = 71000 AND `commune` = 'MACON';";
             $this->addDatasource("INSEE", $query);
         }
     }
 }
<?php

/**
 * $Id$
 * 
 * @package    Mediboard
 * @subpackage dPccam
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
ini_set("memory_limit", "2048M");
CApp::setTimeLimit(1800);
$nomenclature = CValue::get("nomenclature", "ccam");
$file = isset($_FILES['import']) ? $_FILES['import'] : null;
$results = array();
$i = 0;
if ($file && ($fp = fopen($file['tmp_name'], 'r'))) {
    $cols = fgetcsv($fp, null, ";");
    while ($line = fgetcsv($fp, null, ";")) {
        if (!isset($line[0]) || $line[0] == "") {
            continue;
        }
        $results[$i]["praticien"] = trim($line[0]);
        $results[$i]["tag"] = trim($line[1]);
        if ($nomenclature == "ccam") {
            $results[$i]['chapitres'] = trim($line[2]);
            $results[$i]["code"] = array(trim($line[3]));
            if ($chaps = $results[$i]['chapitres']) {
                $ds = CSQLDataSource::get("ccamV2");