Exemplo n.º 1
0
 /**
  * @see parent::__construct
  */
 function __construct()
 {
     parent::__construct();
     $this->mod_name = "dPplanningOp";
     $this->makeRevision("all");
     $query = "CREATE TABLE operations (\r\n      operation_id BIGINT(20) UNSIGNED NOT NULL auto_increment,\r\n      pat_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',\r\n      chir_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',\r\n      plageop_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',\r\n      CIM10_code VARCHAR(5) DEFAULT NULL,\r\n      CCAM_code VARCHAR(7) DEFAULT NULL,\r\n      cote ENUM('droit','gauche','bilatéral','total') NOT NULL DEFAULT 'total',\r\n      temp_operation TIME NOT NULL DEFAULT '00:00:00',\r\n      time_operation TIME NOT NULL DEFAULT '00:00:00',\r\n      examen TEXT,\r\n      materiel TEXT,\r\n      commande_mat ENUM('o', 'n') NOT NULL DEFAULT 'n',\r\n      info ENUM('o','n') NOT NULL DEFAULT 'n',\r\n      date_anesth date NOT NULL DEFAULT '0000-00-00',\r\n      time_anesth TIME NOT NULL DEFAULT '00:00:00',\r\n      type_anesth tinyint(4) DEFAULT NULL,\r\n      date_adm date NOT NULL DEFAULT '0000-00-00',\r\n      time_adm TIME NOT NULL DEFAULT '00:00:00',\r\n      duree_hospi tinyint(4) UNSIGNED NOT NULL DEFAULT '0',\r\n      type_adm ENUM('comp','ambu','exte') DEFAULT 'comp',\r\n      chambre ENUM('o','n') NOT NULL DEFAULT 'o',\r\n      ATNC ENUM('o','n') NOT NULL DEFAULT 'n',\r\n      rques TEXT,\r\n      rank tinyint(4) NOT NULL DEFAULT '0',\r\n      admis ENUM('n','o') NOT NULL DEFAULT 'n',\r\n      PRIMARY KEY  (operation_id),\r\n      UNIQUE KEY operation_id (operation_id)\r\n    ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.1");
     $query = "ALTER TABLE operations\r\n      ADD entree_bloc TIME AFTER temp_operation ,\r\n      ADD sortie_bloc TIME AFTER entree_bloc ,\r\n      ADD saisie ENUM( 'n', 'o' ) DEFAULT 'n' NOT NULL ,\r\n      CHANGE plageop_id plageop_id BIGINT( 20 ) UNSIGNED";
     $this->addQuery($query);
     $this->makeRevision("0.2");
     $query = "ALTER TABLE `operations`\r\n      ADD `convalescence` TEXT AFTER `materiel` ;";
     $this->addQuery($query);
     $this->makeRevision("0.21");
     $query = "ALTER TABLE `operations`\r\n      ADD `depassement` INT( 4 );";
     $this->addQuery($query);
     $this->makeRevision("0.22");
     $query = "ALTER TABLE `operations`\r\n      ADD `CCAM_code2` VARCHAR( 7 ) AFTER `CCAM_code`,\r\n      ADD INDEX ( `CCAM_code2` ),\r\n      ADD INDEX ( `CCAM_code` ),\r\n      ADD INDEX ( `pat_id` ),\r\n      ADD INDEX ( `chir_id` ),\r\n      ADD INDEX ( `plageop_id` );";
     $this->addQuery($query);
     $this->makeRevision("0.23");
     $query = "ALTER TABLE `operations`\r\n      ADD `modifiee` TINYINT DEFAULT '0' NOT NULL AFTER `saisie`,\r\n      ADD `annulee` TINYINT DEFAULT '0' NOT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.24");
     $query = "ALTER TABLE `operations`\r\n      ADD `compte_rendu` TEXT,\r\n      ADD `cr_valide` TINYINT( 4 ) DEFAULT '0' NOT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.25");
     $query = "ALTER TABLE `operations`\r\n      ADD `pathologie` VARCHAR( 8 ) DEFAULT NULL,\r\n      ADD `septique` TINYINT DEFAULT '0' NOT NULL ;";
     $this->addQuery($query);
     $this->makeRevision("0.26");
     $query = "ALTER TABLE `operations`\r\n      ADD `libelle` TEXT DEFAULT NULL AFTER `CCAM_code2`;";
     $this->addQuery($query);
     // CR passage des champs à enregistrements supprimé car regressif
     //    $this->makeRevision("0.27");
     $this->makeRevision("0.28");
     $query = "ALTER TABLE `operations`\r\n      ADD `codes_ccam` VARCHAR( 160 ) AFTER `CIM10_code`";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `codes_ccam` )";
     $this->addQuery($query);
     $this->makeRevision("0.29");
     $query = "UPDATE `operations`\r\n      SET `codes_ccam` = CONCAT_WS('|', `CCAM_code`, `CCAM_code2`)";
     $this->addQuery($query);
     $this->makeRevision("0.30");
     $query = "ALTER TABLE `operations`\r\n      ADD `pose_garrot` TIME AFTER `entree_bloc` ,\r\n      ADD `debut_op` TIME AFTER `pose_garrot` ,\r\n      ADD `fin_op` TIME AFTER `debut_op` ,\r\n      ADD `retrait_garrot` TIME AFTER `fin_op` ;";
     $this->addQuery($query);
     $this->makeRevision("0.31");
     $query = "ALTER TABLE `operations`\r\n      ADD `salle_id` BIGINT AFTER `plageop_id` ,\r\n      ADD `date` DATE AFTER `salle_id`;";
     $this->addQuery($query);
     $this->makeRevision("0.32");
     $query = "ALTER TABLE `operations`\r\n      ADD `venue_SHS` VARCHAR( 8 ) AFTER `chambre`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `venue_SHS` );";
     $this->addQuery($query);
     $this->makeRevision("0.33");
     $query = "ALTER TABLE `operations`\r\n      ADD `code_uf` VARCHAR( 3 ) AFTER `venue_SHS`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD `libelle_uf` VARCHAR( 40 ) AFTER `code_uf`;";
     $this->addQuery($query);
     $this->makeRevision("0.34");
     $query = "ALTER TABLE `operations`\r\n      ADD `entree_reveil` TIME AFTER `sortie_bloc` ,\r\n      ADD `sortie_reveil` TIME AFTER `entree_reveil` ;";
     $this->addQuery($query);
     $this->makeRevision("0.35");
     $query = "ALTER TABLE `operations`\r\n      ADD `entree_adm` DATETIME AFTER `admis`;";
     $this->addQuery($query);
     $query = "UPDATE `operations` SET\r\n      `entree_adm` = ADDTIME(date_adm, time_adm)\r\n      WHERE `admis` = 'o'";
     $this->addQuery($query);
     $this->makeRevision("0.36");
     $this->addDependency("dPbloc", "0.15");
     // Réparation des opérations avec `duree_hospi` = '255'
     $query = "UPDATE `operations`, `plagesop` SET\r\n      `operations`.`date_adm` = `plagesop`.`date`,\r\n      `operations`.`duree_hospi` = '1'\r\n      WHERE `operations`.`duree_hospi` = '255'\r\n      AND `operations`.`plageop_id` = `plagesop`.`plageop_id`";
     $this->addQuery($query);
     // Création de la table
     $query = "CREATE TABLE `sejour` (\r\n      `sejour_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,\r\n      `patient_id` INT UNSIGNED NOT NULL ,\r\n      `praticien_id` INT UNSIGNED NOT NULL ,\r\n      `entree_prevue` DATETIME NOT NULL ,\r\n      `sortie_prevue` DATETIME NOT NULL ,\r\n      `entree_reelle` DATETIME,\r\n      `sortie_reelle` DATETIME,\r\n      `chambre_seule` ENUM('o','n') NOT NULL DEFAULT 'o',\r\n      PRIMARY KEY ( `sejour_id` )\r\n    ) /*! ENGINE=MyISAM */";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `patient_id` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `praticien_id` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `entree_prevue` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `sortie_prevue` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `entree_reelle` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `sortie_reelle` )";
     $this->addQuery($query);
     // Migration de l'ancienne table
     $query = "ALTER TABLE `sejour`\r\n      ADD `tmp_operation_id` INT UNSIGNED NOT NULL AFTER `sejour_id`";
     $this->addQuery($query);
     $query = "INSERT INTO `sejour` (\r\n        `sejour_id` ,\r\n        `tmp_operation_id` ,\r\n        `patient_id` ,\r\n        `praticien_id` ,\r\n        `entree_prevue` ,\r\n        `sortie_prevue` ,\r\n        `entree_reelle` ,\r\n        `sortie_reelle` ,\r\n        `chambre_seule`\r\n      )\r\n      SELECT\r\n        '',\r\n        `operation_id`,\r\n        `pat_id`,\r\n        `chir_id`,\r\n        ADDTIME(`date_adm`, `time_adm`),\r\n        ADDDATE(ADDTIME(`date_adm`, `time_adm`), `duree_hospi`),\r\n        `entree_adm` ,\r\n        NULL ,\r\n        `chambre`\r\n      FROM `operations`\r\n      WHERE `operations`.`pat_id` != 0";
     $this->addQuery($query);
     // Ajout d'une référence vers les sejour
     $query = "ALTER TABLE `operations`\r\n      ADD `sejour_id` INT UNSIGNED NOT NULL AFTER `operation_id`";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `sejour_id` )";
     $this->addQuery($query);
     $query = "UPDATE `operations`, `sejour`\r\n      SET `operations`.`sejour_id` = `sejour`.`sejour_id`\r\n      WHERE `sejour`.`tmp_operation_id` = `operations`.`operation_id`";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      DROP `tmp_operation_id` ";
     $this->addQuery($query);
     $this->makeRevision("0.37");
     // Migration de nouvelles propriétés
     $query = "ALTER TABLE `sejour`\r\n      ADD `type` ENUM( 'comp', 'ambu', 'exte' ) DEFAULT 'comp' NOT NULL AFTER `praticien_id` ,\r\n      ADD `annule` TINYINT DEFAULT '0' NOT NULL AFTER `type` ,\r\n      ADD `venue_SHS` VARCHAR( 8 ) AFTER `annule` ,\r\n      ADD `saisi_SHS` ENUM( 'o', 'n' ) DEFAULT 'n' NOT NULL AFTER `venue_SHS` ,\r\n      ADD `modif_SHS` TINYINT DEFAULT '0' NOT NULL AFTER `saisi_SHS`";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `type` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `annule` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `venue_SHS` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `saisi_SHS` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `modif_SHS` )";
     $this->addQuery($query);
     $query = "UPDATE `sejour`, `operations` SET\r\n      `sejour`.`type` = `operations`.`type_adm`,\r\n      `sejour`.`annule` = `operations`.`annulee`,\r\n      `sejour`.`venue_SHS` = `operations`.`venue_SHS`,\r\n      `sejour`.`saisi_SHS` = `operations`.`saisie`,\r\n      `sejour`.`modif_SHS` = `operations`.`modifiee`\r\n      WHERE `operations`.`sejour_id` = `sejour`.`sejour_id`";
     $this->addQuery($query);
     $this->makeRevision("0.38");
     $query = "UPDATE `sejour`, `operations` SET\r\n      `sejour`.`entree_reelle` = NULL\r\n      WHERE `operations`.`sejour_id` = `sejour`.`sejour_id`\r\n      AND `operations`.`admis` = 'n'";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      CHANGE `date_anesth` `date_anesth` DATE";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `date_anesth` = NULL\r\n      WHERE `date_anesth` = '0000-00-00'";
     $this->addQuery($query);
     $this->makeRevision("0.39");
     $query = "ALTER TABLE sejour\r\n      ADD rques TEXT;";
     $this->addQuery($query);
     $this->makeRevision("0.40");
     $query = "ALTER TABLE operations\r\n      ADD pause TIME NOT NULL DEFAULT '00:00:00' AFTER temp_operation";
     $this->addQuery($query);
     $this->makeRevision("0.41");
     $query = "ALTER TABLE `sejour`\r\n      ADD `pathologie` VARCHAR( 8 ) DEFAULT NULL,\r\n      ADD `septique` TINYINT DEFAULT '0' NOT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `sejour`, `operations` SET\r\n      `sejour`.`pathologie` = `operations`.`pathologie`,\r\n      `sejour`.`septique` = `operations`.`septique`\r\n      WHERE `operations`.`sejour_id` = `sejour`.`sejour_id`";
     $this->addQuery($query);
     $this->makeRevision("0.42");
     $query = "ALTER TABLE `sejour`\r\n      ADD `code_uf` VARCHAR( 8 ) DEFAULT NULL AFTER venue_SHS,\r\n      ADD `libelle_uf` TINYINT DEFAULT '0' NOT NULL AFTER code_uf;";
     $this->addQuery($query);
     $query = "UPDATE `sejour`, `operations` SET\r\n      `sejour`.`code_uf` = `operations`.`code_uf`,\r\n      `sejour`.`libelle_uf` = `operations`.`libelle_uf`\r\n      WHERE `operations`.`sejour_id` = `sejour`.`sejour_id`";
     $this->addQuery($query);
     $this->makeRevision("0.43");
     $query = "ALTER TABLE `sejour`\r\n      ADD `convalescence` TEXT DEFAULT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `sejour`, `operations` SET\r\n      `sejour`.`convalescence` = `operations`.`convalescence`\r\n      WHERE `operations`.`sejour_id` = `sejour`.`sejour_id`";
     $this->addQuery($query);
     $this->makeRevision("0.44");
     $query = "ALTER TABLE `sejour`\r\n      DROP `code_uf`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      DROP `libelle_uf`;";
     $this->addQuery($query);
     $query = " ALTER TABLE `sejour`\r\n      ADD `modalite_hospitalisation` ENUM( 'office', 'libre', 'tiers' ) NOT NULL DEFAULT 'libre' AFTER `type`;";
     $this->addQuery($query);
     $this->makeRevision("0.45");
     $query = "ALTER TABLE `operations`\r\n      DROP `entree_adm`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      DROP `admis`;";
     $this->addQuery($query);
     $this->makeRevision("0.46");
     $query = "ALTER TABLE `sejour`\r\n      ADD `DP`  VARCHAR(5) DEFAULT NULL AFTER `rques`;";
     $this->addQuery($query);
     $query = "UPDATE `sejour`, `operations` SET\r\n      `sejour`.`DP` = `operations`.`CIM10_code`\r\n      WHERE `operations`.`sejour_id` = `sejour`.`sejour_id`";
     $this->addQuery($query);
     $this->makeRevision("0.47");
     $query = "CREATE TABLE protocole (\r\n      protocole_id INT UNSIGNED NOT NULL auto_increment,\r\n      chir_id INT UNSIGNED NOT NULL DEFAULT '0',\r\n      type ENUM('comp','ambu','exte') DEFAULT 'comp',\r\n      DP VARCHAR(5) DEFAULT NULL,\r\n      convalescence TEXT DEFAULT NULL,\r\n      rques_sejour TEXT DEFAULT NULL,\r\n      pathologie VARCHAR(8) DEFAULT NULL,\r\n      septique TINYINT DEFAULT '0' NOT NULL,\r\n      codes_ccam VARCHAR(160) DEFAULT NULL,\r\n      libelle TEXT DEFAULT NULL,\r\n      temp_operation TIME NOT NULL DEFAULT '00:00:00',\r\n      examen TEXT DEFAULT NULL,\r\n      materiel TEXT DEFAULT NULL,\r\n      duree_hospi TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\r\n      rques_operation TEXT DEFAULT NULL,\r\n      depassement TINYINT DEFAULT NULL,\r\n      PRIMARY KEY  (protocole_id)\r\n    ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD INDEX (`chir_id`)";
     $this->addQuery($query);
     $query = "INSERT INTO `protocole` (\r\n        `protocole_id`, `chir_id`,\r\n        `type`,\r\n        `DP`,\r\n        `convalescence`,\r\n        `rques_sejour`,\r\n        `pathologie`,\r\n        `septique`,\r\n        `codes_ccam`,\r\n        `libelle`,\r\n        `temp_operation`,\r\n        `examen`,\r\n        `materiel`,\r\n        `duree_hospi`,\r\n        `rques_operation`,\r\n        `depassement`\r\n      )\r\n      SELECT\r\n        '',\r\n        `operations`.`chir_id`,\r\n        `operations`.`type_adm`,\r\n        `operations`.`CIM10_code`,\r\n        `operations`.`convalescence`,\r\n        '',\r\n        '',\r\n        '',\r\n        `operations`.`codes_ccam`,\r\n        `operations`.`libelle`,\r\n        `operations`.`temp_operation`,\r\n        `operations`.`examen`,\r\n        `operations`.`materiel`,\r\n        `operations`.`duree_hospi`,\r\n        `operations`.`rques`,\r\n        `operations`.`depassement`\r\n       FROM `operations`\r\n       WHERE `operations`.`pat_id` = 0";
     $this->addQuery($query);
     $query = "DELETE FROM `operations`\r\n      WHERE `pat_id` = 0";
     $this->addQuery($query);
     $this->makeRevision("0.48");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `modalite_hospitalisation` `modalite` ENUM( 'office', 'libre', 'tiers' ) DEFAULT 'libre' NOT NULL";
     $this->addQuery($query);
     $this->makeRevision("0.49");
     $query = "UPDATE `operations`\r\n      SET `date` = NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.50");
     $query = "ALTER TABLE `operations`\r\n      ADD `anesth_id` INT UNSIGNED DEFAULT NULL AFTER `chir_id`";
     $this->addQuery($query);
     $this->makeRevision("0.51");
     $this->addDependency("dPetablissement", "0.1");
     $query = "ALTER TABLE `sejour`\r\n      ADD `group_id` INT UNSIGNED NOT NULL DEFAULT 1 AFTER `praticien_id`";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX ( `group_id` ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.52");
     $query = "ALTER TABLE `operations`\r\n      DROP INDEX `operation_id` ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `anesth_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      DROP `pat_id`,\r\n      DROP `CCAM_code`,\r\n      DROP `CCAM_code2`,\r\n      DROP `compte_rendu`,\r\n      DROP `cr_valide`,\r\n      DROP `date_adm`,\r\n      DROP `time_adm`,\r\n      DROP `chambre`,\r\n      DROP `type_adm`,\r\n      DROP `venue_SHS`,\r\n      DROP `saisie`,\r\n      DROP `modifiee`,\r\n      DROP `CIM10_code`,\r\n      DROP `convalescence`,\r\n      DROP `pathologie`,\r\n      DROP `septique` ;";
     $this->addQuery($query);
     $this->makeRevision("0.53");
     $query = "CREATE TABLE `type_anesth` (\r\n      `type_anesth_id` INT UNSIGNED NOT NULL auto_increment,\r\n      `name` VARCHAR(50) DEFAULT NULL,\r\n      PRIMARY KEY  (type_anesth_id)\r\n    ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('1', 'Non définie');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('2', 'Rachi');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('3', 'Rachi + bloc');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('4', 'Anesthésie loco-régionale');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('5', 'Anesthésie locale');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('6', 'Neurolept');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('7', 'Anesthésie générale');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('8', 'Anesthesie generale + bloc');";
     $this->addQuery($query);
     $query = "INSERT INTO `type_anesth`\r\n      VALUES ('9', 'Anesthesie peribulbaire');";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `type_anesth`=`type_anesth`+1;";
     $this->addQuery($query);
     $this->makeRevision("0.54");
     $query = "ALTER TABLE `operations`\r\n      ADD `induction` TIME AFTER `sortie_reveil`";
     $this->addQuery($query);
     $this->makeEmptyRevision("0.55");
     $this->makeEmptyRevision("0.56");
     $query = "ALTER TABLE `operations`\r\n      CHANGE `operation_id` `operation_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n      CHANGE `sejour_id` `sejour_id` int(11) UNSIGNED NOT NULL DEFAULT '0',\r\n      CHANGE `chir_id` `chir_id` int(11) UNSIGNED NOT NULL DEFAULT '0',\r\n      CHANGE `anesth_id` `anesth_id` int(11) UNSIGNED NULL,\r\n      CHANGE `plageop_id` `plageop_id` int(11) UNSIGNED NULL,\r\n      CHANGE `code_uf` `code_uf` VARCHAR(3) NULL,\r\n      CHANGE `libelle_uf` `libelle_uf` VARCHAR(35) NULL,\r\n      CHANGE `salle_id` `salle_id` int(11) UNSIGNED NULL,\r\n      CHANGE `codes_ccam` `codes_ccam` VARCHAR(255) NULL,\r\n      CHANGE `libelle` `libelle` VARCHAR(255) NULL,\r\n      CHANGE `type_anesth` `type_anesth` int(11) UNSIGNED NULL,\r\n      CHANGE `rank` `rank` tinyint NOT NULL DEFAULT '0',\r\n      CHANGE `annulee` `annulee` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `depassement` `depassement` float NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations` DROP `duree_hospi`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      CHANGE `protocole_id` `protocole_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 `pathologie` `pathologie` VARCHAR(3) NULL,\r\n      CHANGE `codes_ccam` `codes_ccam` VARCHAR(255) NULL,\r\n      CHANGE `libelle` `libelle` VARCHAR(255) NULL,\r\n      CHANGE `duree_hospi` `duree_hospi` mediumint NOT NULL DEFAULT '0',\r\n      CHANGE `septique` `septique` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `depassement` `depassement` float NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `sejour_id` `sejour_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n      CHANGE `patient_id` `patient_id` int(11) UNSIGNED NOT NULL DEFAULT '0',\r\n      CHANGE `praticien_id` `praticien_id` int(11) UNSIGNED NOT NULL DEFAULT '0',\r\n      CHANGE `group_id` `group_id` int(11) UNSIGNED NOT NULL DEFAULT '1',\r\n      CHANGE `venue_SHS` `venue_SHS` int(8) UNSIGNED zerofill NULL,\r\n      CHANGE `annule` `annule` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `modif_SHS` `modif_SHS` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `septique` `septique` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `pathologie` `pathologie` VARCHAR(3) NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `type_anesth`\r\n      CHANGE `type_anesth_id` `type_anesth_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n      CHANGE `name` `name` VARCHAR(255) NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `saisi_SHS` `saisi_SHS` ENUM('o','n','0','1') NOT NULL DEFAULT 'n',\r\n      CHANGE `chambre_seule` `chambre_seule` ENUM('o','n','0','1') NOT NULL DEFAULT 'o';";
     $this->addQuery($query);
     $query = "UPDATE `sejour`\r\n      SET `saisi_SHS`='0'\r\n      WHERE `saisi_SHS`='n';";
     $this->addQuery($query);
     $query = "UPDATE `sejour`\r\n      SET `saisi_SHS`='1'\r\n      WHERE `saisi_SHS`='o';";
     $this->addQuery($query);
     $query = "UPDATE `sejour`\r\n      SET `chambre_seule`='0'\r\n      WHERE `chambre_seule`='n';";
     $this->addQuery($query);
     $query = "UPDATE `sejour`\r\n      SET `chambre_seule`='1'\r\n      WHERE `chambre_seule`='o';";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `saisi_SHS` `saisi_SHS` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `chambre_seule` `chambre_seule` ENUM('0','1') NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      CHANGE `ATNC` `ATNC` ENUM('o','n','0','1') NOT NULL DEFAULT 'n',\r\n      CHANGE `commande_mat` `commande_mat` ENUM('o','n','0','1') NOT NULL DEFAULT 'n',\r\n      CHANGE `info` `info` ENUM('o','n','0','1') NOT NULL DEFAULT 'n';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `ATNC`='0'\r\n      WHERE `ATNC`='n';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `ATNC`='1'\r\n      WHERE `ATNC`='o';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `info`='0'\r\n      WHERE `info`='n';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `info`='1'\r\n      WHERE `info`='o';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `commande_mat`='0'\r\n      WHERE `commande_mat`='n';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `commande_mat`='1'\r\n      WHERE `commande_mat`='o';";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      CHANGE `ATNC` `ATNC` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `commande_mat` `commande_mat` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `info` `info` ENUM('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.57");
     $query = "ALTER TABLE `operations`\r\n      DROP `date_anesth`,\r\n      DROP `time_anesth`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      CHANGE `entree_bloc` `entree_salle` TIME NULL,\r\n      CHANGE `sortie_bloc` `sortie_salle` TIME NULL,\r\n      ADD `entree_bloc` TIME NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.58");
     $query = "ALTER TABLE `sejour`\r\n      ADD `ATNC` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `hormone_croissance` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `lit_accompagnant`   ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `isolement`          ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `television`         ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `repas_diabete`      ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `repas_sans_sel`     ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `repas_sans_residu`  ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `type` `type` ENUM('comp','ambu','exte','seances','ssr','psy') NOT NULL DEFAULT 'comp';";
     $this->addQuery($query);
     $query = "UPDATE sejour SET ATNC = '1' WHERE sejour_id IN (SELECT sejour_id FROM `operations` WHERE ATNC = '1');";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations` DROP `ATNC`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole` CHANGE `type` `type` ENUM('comp','ambu','exte','seances','ssr','psy') NOT NULL DEFAULT 'comp';";
     $this->addQuery($query);
     $this->makeRevision("0.59");
     $query = "UPDATE `operations` SET annulee = 0 WHERE annulee = ''";
     $this->addQuery($query);
     $query = "UPDATE `sejour` SET annule = 0 WHERE annule = ''";
     $this->addQuery($query);
     $this->makeRevision("0.60");
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `salle_id` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `date` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `time_operation` )";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX ( `annulee` )";
     $this->addQuery($query);
     $this->makeRevision("0.61");
     $query = "ALTER TABLE `operations`\r\n      CHANGE `induction` `induction_debut` TIME";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD `induction_fin` TIME AFTER `induction_debut`";
     $this->addQuery($query);
     $this->makeRevision("0.62");
     $query = "ALTER TABLE `operations`\r\n      ADD `anapath` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      ADD `labo` ENUM('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.63");
     $query = "UPDATE `operations`\r\n      SET `anesth_id` = NULL WHERE `anesth_id` = '0';";
     $this->addQuery($query);
     $this->makeRevision("0.64");
     $query = "ALTER TABLE `operations`\r\n      ADD `forfait` FLOAT NULL AFTER `depassement`,\r\n      ADD `fournitures` FLOAT NULL AFTER `forfait`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD `forfait` FLOAT NULL AFTER `depassement`,\r\n      ADD `fournitures` FLOAT NULL AFTER `forfait`;";
     $this->addQuery($query);
     $this->makeRevision("0.65");
     $query = "ALTER TABLE `sejour`\r\n      ADD `codes_ccam` VARCHAR(255);";
     $this->addQuery($query);
     $this->makeRevision("0.66");
     $this->addPrefQuery("mode", "1");
     $this->makeRevision("0.67");
     $query = "UPDATE `user_preferences`\r\n      SET `key` = 'mode_dhe' WHERE `key` = 'mode';";
     $this->addQuery($query, true);
     $this->makeRevision("0.68");
     $query = "ALTER TABLE `sejour`\r\n      ADD `mode_sortie` ENUM( 'normal', 'transfert', 'deces' );";
     $this->addQuery($query);
     $this->makeRevision("0.69");
     $query = "ALTER TABLE `sejour`\r\n      ADD `prestation_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.70");
     $query = "ALTER TABLE `sejour`\r\n      ADD `facturable` ENUM('0','1') NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("0.71");
     $query = "ALTER TABLE `sejour`\r\n      ADD `reanimation` ENUM('0','1') NOT NULL DEFAULT '1' AFTER `chambre_seule`;";
     $this->addQuery($query);
     $this->makeRevision("0.72");
     $query = "ALTER TABLE `sejour`\r\n      ADD `zt` ENUM('0','1') NOT NULL DEFAULT '1' AFTER `reanimation`;";
     $this->addQuery($query);
     $this->makeRevision("0.73");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `reanimation` `reanimation` ENUM('0','1') NOT NULL DEFAULT '0',\r\n      CHANGE `zt` `zt` ENUM('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "UPDATE `sejour` SET `sejour`.`reanimation` = 0, `sejour`.`zt` = 0;";
     $this->addQuery($query);
     $this->makeRevision("0.74");
     $query = "ALTER TABLE `operations`\r\n      CHANGE `cote` `cote` ENUM('droit','gauche','bilatéral','total','inconnu') NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.75");
     $query = "ALTER TABLE `sejour`\r\n      ADD `etablissement_transfert_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.76");
     $query = "ALTER TABLE `operations`\r\n      ADD `horaire_voulu` TIME;";
     $this->addQuery($query);
     $this->makeRevision("0.77");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `type` `type` ENUM('comp','ambu','exte','seances','ssr','psy','urg') NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.78");
     $query = "ALTER TABLE `type_anesth`\r\n      ADD `ext_doc` ENUM('1','2','3','4','5','6');";
     $this->addQuery($query);
     $this->makeRevision("0.79");
     $query = "ALTER TABLE `sejour`\r\n      ADD `DR` VARCHAR(5),\r\n      CHANGE `pathologie` `pathologie` CHAR(3)";
     $this->addQuery($query);
     $this->makeRevision("0.80");
     $query = "UPDATE operations, plagesop\r\n      SET operations.salle_id = plagesop.salle_id\r\n      WHERE operations.salle_id IS NULL\r\n      AND operations.plageop_id = plagesop.plageop_id;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      CHANGE `salle_id` `salle_id` INT( 11 ) UNSIGNED NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.81");
     $query = "ALTER TABLE `operations`\r\n      CHANGE `salle_id` `salle_id` INT( 11 ) UNSIGNED DEFAULT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET salle_id = NULL WHERE salle_id = 0;";
     $this->addQuery($query);
     $this->makeRevision("0.82");
     $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 , 'CSejour', `sejour_id` , 'SHS group:1', NOW( ) , `venue_SHS`\r\n      FROM `sejour`\r\n      WHERE `venue_SHS` IS NOT NULL\r\n      AND `venue_SHS` != 0";
     $this->addQuery($query);
     $this->makeRevision("0.83");
     $query = "ALTER TABLE `sejour`\r\n      DROP `venue_SHS`";
     $this->addQuery($query);
     $this->makeRevision("0.84");
     $query = "ALTER TABLE `sejour`\r\n      ADD `repas_sans_porc` ENUM('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.85");
     $query = "ALTER TABLE `protocole`\r\n      ADD `protocole_prescription_chir_id` INT (11) UNSIGNED,\r\n      ADD `protocole_prescription_anesth_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD INDEX (`protocole_prescription_chir_id`),\r\n      ADD INDEX (`protocole_prescription_anesth_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.86");
     $query = "ALTER TABLE `operations` ADD `depassement_anesth` FLOAT NULL AFTER `fournitures`;";
     $this->addQuery($query);
     $this->makeRevision("0.87");
     $this->addDependency("dPcompteRendu", "0.1");
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("Opération - CCAM - code", "Opération - CCAM1 - code");
     $this->addQuery($query);
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("Opération - CCAM - description", "Opération - CCAM1 - description");
     $this->addQuery($query);
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("Opération - CCAM complet", "Opération - CCAM - codes");
     $this->addQuery($query);
     $this->makeRevision("0.88");
     $query = "ALTER TABLE `operations`\r\n        CHANGE `anapath` `anapath` ENUM ('1','0','?') DEFAULT '?',\r\n        CHANGE `labo` `labo` ENUM ('1','0','?') DEFAULT '?';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `anapath` = '?'\r\n      WHERE `anapath` = '0'";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `labo` = '?'\r\n      WHERE `labo` = '0'";
     $this->addQuery($query);
     $this->makeRevision("0.89");
     $query = "ALTER TABLE `protocole`\r\n      ADD `for_sejour` ENUM ('0','1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("0.90");
     $query = "ALTER TABLE `sejour`\r\n    ADD `adresse_par_prat_id` INT (11),\r\n    ADD `adresse_par_etab_id` INT (11),\r\n    ADD `libelle` VARCHAR (255)";
     $this->addQuery($query);
     $this->makeRevision("0.91");
     $query = "ALTER TABLE `protocole`\r\n      ADD `libelle_sejour` VARCHAR (255)";
     $this->addQuery($query);
     $this->makeRevision("0.92");
     $query = "ALTER TABLE `operations`\r\n      ADD `cote_admission` ENUM ('droit','gauche') AFTER `horaire_voulu`,\r\n      ADD `cote_consult_anesth` ENUM ('droit','gauche') AFTER `cote_admission`,\r\n      ADD `cote_hospi` ENUM ('droit','gauche') AFTER `cote_consult_anesth`,\r\n      ADD `cote_bloc` ENUM ('droit','gauche') AFTER `cote_hospi`;";
     $this->addQuery($query);
     $this->makeRevision("0.93");
     $query = "ALTER TABLE `operations`\r\n      ADD `prothese` ENUM ('1','0','?')  DEFAULT '?' AFTER `labo`,\r\n      ADD `date_visite_anesth` DATETIME,\r\n      ADD `prat_visite_anesth_id` INT (11) UNSIGNED,\r\n      ADD `rques_visite_anesth` TEXT,\r\n      ADD `autorisation_anesth` ENUM ('0','1');";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX (`date_visite_anesth`),\r\n      ADD INDEX (`prat_visite_anesth_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.94");
     $this->addPrefQuery("dPplanningOp_listeCompacte", "1");
     $this->makeRevision("0.95");
     $query = "ALTER TABLE `sejour`\r\n      ADD `service_id` INT (11) UNSIGNED AFTER `zt`,\r\n      ADD INDEX (`etablissement_transfert_id`),\r\n      ADD INDEX (`service_id`),\r\n      ADD INDEX (`prestation_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.96");
     $query = "ALTER TABLE `protocole`\r\n      ADD `service_id_sejour` INT (11) UNSIGNED,\r\n      ADD INDEX (`temp_operation`),\r\n      ADD INDEX (`service_id_sejour`);";
     $this->addQuery($query);
     $this->makeRevision("0.97");
     $query = "ALTER TABLE `sejour`\r\n      ADD `etablissement_entree_transfert_id` INT (11) UNSIGNED,\r\n      ADD INDEX (`etablissement_entree_transfert_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.98");
     $query = "ALTER TABLE `sejour`\r\n      ADD `facture` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.99");
     $query = "ALTER TABLE `operations`\r\n      ADD `facture` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.00");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `type` `type` ENUM ('comp','ambu','exte','seances','ssr','psy','urg','consult') NOT NULL;";
     $this->addQuery($query);
     $this->makeEmptyRevision("1.01");
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX (`type_anesth`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX (`adresse_par_prat_id`),\r\n      ADD INDEX (`adresse_par_etab_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.02");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `chambre_seule` `chambre_seule` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.03");
     $query = "UPDATE sejour\r\n      SET sortie_prevue = entree_reelle\r\n      WHERE entree_reelle IS NOT NULL\r\n      AND sortie_prevue < entree_reelle";
     $this->addQuery($query);
     $this->makeRevision("1.04");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `mode_sortie` `mode_sortie` ENUM ('normal','transfert','mutation','deces') DEFAULT 'normal',\r\n      ADD `service_mutation_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX (`service_mutation_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.05");
     $query = "ALTER TABLE `sejour`\r\n      ADD `entree` DATETIME AFTER `sortie_reelle`,\r\n      ADD `sortie` DATETIME AFTER `entree`";
     $this->addQuery($query);
     $query = "UPDATE `sejour` SET\r\n      `sejour`.`entree` = IF(`sejour`.`entree_reelle`,`sejour`.`entree_reelle`,`sejour`.`entree_prevue`),\r\n      `sejour`.`sortie` = IF(`sejour`.`sortie_reelle`,`sejour`.`sortie_reelle`,`sejour`.`sortie_prevue`)";
     $this->addQuery($query);
     $this->makeRevision("1.06");
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX (`entree`),\r\n      ADD INDEX (`sortie`);";
     $this->addQuery($query);
     $this->makeRevision("1.07");
     $query = "ALTER TABLE `sejour`\r\n      ADD `service_entree_mutation_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.08");
     $query = "ALTER TABLE `sejour`\r\n      ADD `forfait_se` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.09");
     $query = "ALTER TABLE `sejour`\r\n      ADD `recuse` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.10");
     $query = "ALTER TABLE `protocole`\r\n      CHANGE `service_id_sejour` `service_id` INT (11) UNSIGNED  NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD INDEX (`service_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.11");
     $query = "ALTER TABLE `protocole`\r\n      CHANGE `service_id` `service_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "UPDATE `protocole`\r\n      SET service_id = NULL\r\n      WHERE service_id = '0'";
     $this->addQuery($query);
     $this->makeRevision("1.12");
     $query = "CREATE TABLE `color_libelle_sejour` (\r\n      `color_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `libelle` VARCHAR (255) NOT NULL,\r\n      `color` CHAR (6) NOT NULL DEFAULT 'ffffff'\r\n    ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("1.13");
     $query = "ALTER TABLE `operations`\r\n      ADD `debut_prepa_preop` TIME,\r\n      ADD `fin_prepa_preop` TIME";
     $this->addQuery($query);
     $this->makeRevision("1.14");
     $query = "CREATE TABLE `interv_hors_plages` (\r\n      `interv_hors_plage_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY\r\n    ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("1.15");
     $query = "ALTER TABLE sejour\r\n      ADD commentaires_sortie TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.16");
     $query = "ALTER TABLE `protocole`\r\n              CHANGE `protocole_prescription_chir_id` `protocole_prescription_chir_id` VARCHAR (255),\r\n              CHANGE `protocole_prescription_anesth_id` `protocole_prescription_anesth_id` VARCHAR (255);";
     $this->addQuery($query);
     $query = "UPDATE `protocole`\r\n              SET protocole_prescription_chir_id = CONCAT('CPrescription-', protocole_prescription_chir_id)\r\n              WHERE protocole_prescription_chir_id IS NOT NULL;";
     $this->addQuery($query);
     $query = "UPDATE `protocole`\r\n              SET protocole_prescription_anesth_id = CONCAT('CPrescription-', protocole_prescription_anesth_id)\r\n              WHERE protocole_prescription_anesth_id IS NOT NULL;";
     $this->addQuery($query);
     $this->makeRevision("1.17");
     $query = "ALTER table `protocole`\r\n              ADD `protocole_prescription_chir_class` ENUM ('CPrescription', 'CPrescriptionProtocolePack') AFTER `protocole_prescription_chir_id`,\r\n              ADD `protocole_prescription_anesth_class` ENUM ('CPrescription', 'CPrescriptionProtocolePack') AFTER `protocole_prescription_anesth_id`;";
     $this->addQuery($query);
     $query = "UPDATE `protocole`\r\n              SET protocole_prescription_chir_class = SUBSTRING_INDEX(protocole_prescription_chir_id, '-', 1),\r\n              protocole_prescription_chir_id = SUBSTRING(protocole_prescription_chir_id, LENGTH(SUBSTRING_INDEX(protocole_prescription_chir_id,'-',1))+2),\r\n              protocole_prescription_anesth_class = SUBSTRING_INDEX(protocole_prescription_anesth_id, '-', 1),\r\n              protocole_prescription_anesth_id = SUBSTRING(protocole_prescription_anesth_id, LENGTH(SUBSTRING_INDEX(protocole_prescription_anesth_id,'-',1))+2);";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n              CHANGE protocole_prescription_chir_id protocole_prescription_chir_id INT(11),\r\n              CHANGE protocole_prescription_anesth_id protocole_prescription_anesth_id INT(11)";
     $this->makeRevision("1.18");
     $query = "ALTER TABLE `sejour`\r\n              ADD `consult_accomp` ENUM ('oui','non','nc') DEFAULT 'nc';";
     $this->addQuery($query);
     $this->makeRevision("1.19");
     $query = "ALTER TABLE `groups_config`\r\n      ADD `dPplanningOp_COperation_DHE_mode_simple` ENUM ('0', '1') NOT NULL DEFAULT '0'";
     $this->addQuery($query);
     $this->makeRevision("1.20");
     $query = "ALTER TABLE `protocole`\r\n              CHANGE `chir_id` `chir_id` INT (11) UNSIGNED,\r\n              ADD `function_id` INT (11) UNSIGNED AFTER `chir_id`,\r\n              ADD `group_id` INT (11) UNSIGNED AFTER `function_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n              ADD INDEX (`function_id`),\r\n              ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.21");
     $query = "ALTER TABLE `sejour`\r\n                ADD `discipline_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD INDEX (`discipline_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.22");
     $query = "ALTER TABLE `sejour`\r\n      ADD `mode_entree` ENUM('6','7','8') AFTER `codes_ccam`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX (`mode_entree`);";
     $this->addQuery($query);
     $this->makeRevision("1.23");
     $query = "ALTER TABLE `protocole`\r\n              ADD `cote` ENUM ('droit','gauche','bilatéral','total','inconnu') AFTER `libelle`";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n              ADD `assurance_maladie` VARCHAR (255),\r\n              ADD `rques_assurance_maladie` TEXT,\r\n              ADD `assurance_accident` VARCHAR (255),\r\n              ADD `rques_assurance_accident` TEXT,\r\n              ADD `date_accident` DATE,\r\n              ADD `nature_accident` ENUM ('P','T','D','S','J','C','L','B','U');";
     $this->addQuery($query);
     $this->makeRevision("1.24");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `etablissement_entree_transfert_id` `etablissement_entree_id` INT (11) UNSIGNED,\r\n      CHANGE `etablissement_transfert_id` `etablissement_sortie_id` INT(11) UNSIGNED,\r\n      CHANGE `service_entree_mutation_id` `service_entree_id` INT (11) UNSIGNED,\r\n      CHANGE `service_mutation_id` `service_sortie_id` INT (11) UNSIGNED";
     $this->addQuery($query);
     $this->getFieldRenameQueries("CSejour", "etablissement_entree_transfert_id", "etablissement_entree_id");
     $this->getFieldRenameQueries("CSejour", "etablissement_transfert_id", "etablissement_sortie_id");
     $this->getFieldRenameQueries("CSejour", "service_entree_mutation_id", "service_entree_id");
     $this->getFieldRenameQueries("CSejour", "service_mutation_id", "service_sortie_id");
     $this->makeRevision("1.25");
     $query = "ALTER TABLE `sejour`\r\n              ADD `ald` ENUM ('0','1') DEFAULT '0' AFTER discipline_id;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n              CHANGE `recuse` `recuse` ENUM ('-1','0','1') DEFAULT '-1';";
     $this->addQuery($query);
     $this->makeRevision("1.26");
     $query = "UPDATE `sejour`\r\n      SET `etablissement_entree_id` = `sejour`.`adresse_par_etab_id`\r\n      WHERE `etablissement_entree_id` IS NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      DROP `adresse_par_etab_id`;";
     $this->addQuery($query);
     $this->makeRevision("1.27");
     $this->addDependency("dPcompteRendu", "0.1");
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("RPU - Provenance", "Sejour - Provenance");
     $this->addQuery($query);
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("RPU - Destination", "Sejour - Destination");
     $this->addQuery($query);
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("RPU - Tranport", "Sejour - Transport");
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD `provenance` ENUM('1','2','3','4','5','6', '7', '8'),\r\n      ADD `destination` ENUM('1','2','3','4','6','7'),\r\n      ADD `transport` ENUM('perso','perso_taxi','ambu','ambu_vsl','vsab','smur','heli','fo') NOT NULL;";
     $this->addQuery($query);
     // Déplacer les champs que si le module dPurgences est actif
     if (CModule::getActive("dPurgences")) {
         $query = "UPDATE sejour, rpu\r\n      SET `sejour`.`provenance` = `rpu`.`provenance`\r\n      WHERE `rpu`.`sejour_id` = `sejour`.`sejour_id`";
         $this->addQuery($query);
         $query = "UPDATE sejour, rpu\r\n      SET `sejour`.`destination` = `rpu`.`destination`\r\n      WHERE `rpu`.`sejour_id` = `sejour`.`sejour_id`";
         $this->addQuery($query);
         $query = "UPDATE sejour, rpu\r\n        SET `sejour`.`transport` = `rpu`.`transport`\r\n        WHERE `rpu`.`sejour_id` = `sejour`.`sejour_id`";
         $this->addQuery($query);
     }
     $this->makeRevision("1.28");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `transport` `transport` ENUM('perso','perso_taxi','ambu','ambu_vsl','vsab','smur','heli','fo');";
     $this->addQuery($query);
     $this->makeRevision("1.29");
     $query = "ALTER TABLE `sejour`\r\n      ADD `type_pec` ENUM ('M','C','O');";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD `type_pec` ENUM ('M','C','O');";
     $this->addQuery($query);
     $this->makeRevision("1.30");
     $query = "ALTER TABLE `sejour`\r\n    ADD `grossesse_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.31");
     $query = "ALTER TABLE `sejour`\r\n      ADD `duree_uscpo` INT (11) UNSIGNED DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD `duree_uscpo` INT (11) UNSIGNED DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.32");
     $query = "ALTER TABLE `sejour`\r\n                ADD `confirme` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD INDEX ( `confirme` )";
     $this->addQuery($query);
     $this->makeRevision("1.33");
     $query = "ALTER TABLE `operations`\r\n                ADD `duree_uscpo` INT (11) UNSIGNED DEFAULT '0';";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n                LEFT JOIN `sejour` ON `sejour`.`sejour_id` = `operations`.`sejour_id`\r\n                SET `operations`.`duree_uscpo` = `sejour`.`duree_uscpo`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                DROP `duree_uscpo`";
     $this->addQuery($query);
     $this->makeRevision("1.34");
     $query = "ALTER TABLE `sejour`\r\n                CHANGE `zt` `UHCD` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.35");
     $query = "ALTER TABLE `operations`\r\n      ADD `cloture_activite_1` ENUM ('0','1') DEFAULT '0',\r\n      ADD `cloture_activite_4` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD `cloture_activite_1` ENUM ('0','1') DEFAULT '0',\r\n      ADD `cloture_activite_4` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.36");
     $query = "ALTER TABLE `sejour`\r\n       CHANGE `saisi_SHS` `entree_preparee` ENUM ('0','1') DEFAULT '0',\r\n       ADD `sortie_preparee` ENUM ('0','1') DEFAULT '0',\r\n       CHANGE `modif_SHS` `entree_modifiee` ENUM ('0','1') DEFAULT '0',\r\n       ADD `sortie_modifiee` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.37");
     $query = "ALTER TABLE `protocole`\r\n      ADD `presence_preop` TIME,\r\n      ADD `presence_postop` TIME;";
     $this->addQuery($query);
     $this->makeRevision("1.38");
     $query = "ALTER TABLE `operations`\r\n      ADD `presence_preop` TIME,\r\n      ADD `presence_postop` TIME;";
     $this->addQuery($query);
     $this->makeRevision("1.39");
     $query = "ALTER TABLE `operations`\r\n              ADD `rank_voulu` TINYINT (4) NOT NULL DEFAULT '0' AFTER `rank`;";
     $this->addQuery($query);
     $this->makeRevision("1.40");
     $query = "ALTER TABLE `sejour`\r\n                ADD `forfait_fsd` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.41");
     $query = "ALTER TABLE `sejour`\r\n                CHANGE `forfait_fsd` `forfait_sd` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.42");
     $query = "ALTER TABLE `operations`\r\n      ADD `duree_preop` TIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD `duree_preop` TIME;";
     $this->addQuery($query);
     $this->makeRevision("1.43");
     $query = "ALTER TABLE `operations`\r\n      ADD `passage_uscpo` ENUM ('0','1') AFTER duree_uscpo;";
     $this->addQuery($query);
     $this->makeRevision("1.44");
     $query = "ALTER TABLE `operations` CHANGE `date_visite_anesth` `date_visite_anesth` DATE;";
     $this->addQuery($query);
     $this->makeRevision("1.45");
     $query = "ALTER TABLE `sejour`\r\n                ADD `transport_sortie` ENUM ('perso','perso_taxi','ambu','ambu_vsl','vsab','smur','heli','fo'),\r\n                ADD `rques_transport_sortie` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.46");
     $query = "ALTER TABLE `protocole`\r\n      ADD `uf_hebergement_id` INT (11) UNSIGNED AFTER `group_id`,\r\n      ADD `uf_medicale_id` INT (11) UNSIGNED AFTER `uf_hebergement_id`,\r\n      ADD `uf_soins_id` INT (11) UNSIGNED AFTER `uf_medicale_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD `uf_hebergement_id` INT (11) UNSIGNED AFTER `group_id`,\r\n      ADD `uf_medicale_id` INT (11) UNSIGNED AFTER `uf_hebergement_id`,\r\n      ADD `uf_soins_id` INT (11) UNSIGNED AFTER `uf_medicale_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD INDEX (`uf_hebergement_id`),\r\n      ADD INDEX (`uf_medicale_id`),\r\n      ADD INDEX (`uf_soins_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n      ADD INDEX (`uf_hebergement_id`),\r\n      ADD INDEX (`uf_medicale_id`),\r\n      ADD INDEX (`uf_soins_id`);";
     $this->makeRevision("1.47");
     $query = "ALTER TABLE `type_anesth`\r\n      ADD `actif` ENUM ('0','1') NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("1.48");
     $query = "ALTER TABLE `operations`\r\n              ADD `exam_extempo` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.49");
     $query = "CREATE TABLE `pose_dispositif_vasculaire` (\r\n              `pose_dispositif_vasculaire_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `operation_id` INT (11) UNSIGNED,\r\n              `sejour_id` INT (11) UNSIGNED NOT NULL,\r\n              `date` DATETIME NOT NULL,\r\n              `lieu` VARCHAR (255),\r\n              `urgence` ENUM ('0','1') NOT NULL DEFAULT '0',\r\n              `operateur_id` INT (11) UNSIGNED NOT NULL,\r\n              `encadrant_id` INT (11) UNSIGNED,\r\n              `type_materiel` ENUM ('cvc','cvc_tunnelise','cvc_dialyse','cvc_bioactif','chambre_implantable','autre') NOT NULL,\r\n              `voie_abord_vasc` TEXT\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `pose_dispositif_vasculaire`\r\n              ADD INDEX (`operation_id`),\r\n              ADD INDEX (`sejour_id`),\r\n              ADD INDEX (`date`),\r\n              ADD INDEX (`operateur_id`),\r\n              ADD INDEX (`encadrant_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.50");
     $query = "ALTER TABLE `operations`\r\n              ADD `flacons_anapath` TINYINT (4) AFTER `anapath`,\r\n              ADD `labo_anapath` VARCHAR (255)  AFTER `flacons_anapath`,\r\n              ADD `description_anapath` TEXT    AFTER `labo_anapath`;";
     $this->addQuery($query);
     $this->makeRevision("1.51");
     $query = "ALTER TABLE `operations`\r\n      ADD `chir_2_id` INT (11) UNSIGNED AFTER `chir_id`,\r\n      ADD `chir_3_id` INT (11) UNSIGNED AFTER `chir_2_id`,\r\n      ADD `chir_4_id` INT (11) UNSIGNED AFTER `chir_3_id`;";
     $this->addQuery($query);
     $this->makeRevision("1.52");
     $query = "ALTER TABLE `operations`\r\n      ADD `envoi_mail` DATETIME;";
     $this->addQuery($query);
     $this->makeRevision("1.53");
     $query = "UPDATE `sejour`\r\n      SET `sejour`.`recuse` = '0'\r\n      WHERE `sejour`.`type` != 'ssr';";
     $this->addQuery($query);
     $this->makeRevision("1.54");
     $query = "ALTER TABLE `operations`\r\n              ADD `conventionne` ENUM ('0','1') DEFAULT '1' AFTER `depassement`;";
     $this->addQuery($query);
     $this->makeRevision("1.55");
     $query = "ALTER TABLE `operations`\r\n              ADD `flacons_bacterio` TINYINT (4) AFTER `labo`,\r\n              ADD `labo_bacterio` VARCHAR (255)  AFTER `flacons_bacterio`,\r\n              ADD `description_bacterio` TEXT    AFTER `labo_bacterio`;";
     $this->addQuery($query);
     $this->makeRevision("1.56");
     $query = "CREATE TABLE `charge_price_indicator` (\r\n                `charge_price_indicator_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `code` VARCHAR (255) NOT NULL,\r\n                `type` ENUM ('comp','ambu','exte','seances','ssr','psy','urg','consult') NOT NULL DEFAULT 'ambu',\r\n                `group_id` INT (11) UNSIGNED NOT NULL,\r\n                `libelle` VARCHAR (255),\r\n                `actif` ENUM ('0','1') DEFAULT '0'\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `charge_price_indicator`\r\n                ADD INDEX (`group_id`),\r\n                ADD INDEX (`code`);";
     $this->addQuery($query);
     $this->makeRevision("1.57");
     $query = "ALTER TABLE `sejour`\r\n                ADD `charge_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD INDEX (`grossesse_id`),\r\n                ADD INDEX (`service_entree_id`),\r\n                ADD INDEX (`charge_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.58");
     $query = "ALTER TABLE `charge_price_indicator`\r\n              ADD `type_pec` ENUM ('M','C','O'),\r\n              ADD INDEX (`type_pec`)";
     $this->addQuery($query);
     $this->makeRevision("1.59");
     $query = "ALTER TABLE `protocole`\r\n      ADD `exam_extempo` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.60");
     $query = "ALTER TABLE `protocole`\r\n      CHANGE `cote` `cote` ENUM ('droit','gauche','haut','bas','bilatéral','total','inconnu');";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      CHANGE `cote` `cote` ENUM ('droit','gauche','haut','bas','bilatéral','total','inconnu') NOT NULL DEFAULT 'inconnu',\r\n      CHANGE `cote_admission` `cote_admission` ENUM ('droit','gauche','haut','bas','bilatéral','total','inconnu'),\r\n      CHANGE `cote_consult_anesth` `cote_consult_anesth` ENUM ('droit','gauche','haut','bas','bilatéral','total','inconnu'),\r\n      CHANGE `cote_hospi` `cote_hospi` ENUM ('droit','gauche','haut','bas','bilatéral','total','inconnu'),\r\n      CHANGE `cote_bloc` `cote_bloc` ENUM ('droit','gauche','haut','bas','bilatéral','total','inconnu');";
     $this->addQuery($query);
     $this->makeRevision("1.61");
     $query = "ALTER TABLE `operations`\r\n      ADD `poste_sspi_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD INDEX (`chir_2_id`),\r\n      ADD INDEX (`chir_3_id`),\r\n      ADD INDEX (`chir_4_id`),\r\n      ADD INDEX (`poste_sspi_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.62");
     $this->setTimeLimit(1800);
     $query = "ALTER TABLE `sejour`\r\n      ADD `isolement_date` DATETIME AFTER `isolement`,\r\n      ADD `raison_medicale` TEXT AFTER `isolement_date`;";
     $this->addQuery($query);
     $this->makeRevision("1.63");
     $query = "ALTER TABLE `operations`\r\n      CHANGE `sortie_reveil` `sortie_reveil_possible` TIME,\r\n      ADD `sortie_reveil_reel` TIME AFTER `sortie_reveil_possible`;";
     $this->addQuery($query);
     $query = "UPDATE `operations`\r\n      SET `sortie_reveil_reel` = `sortie_reveil_possible`";
     $this->addQuery($query);
     $this->makeRevision("1.64");
     $query = "ALTER TABLE `sejour`\r\n      ADD `isolement_fin` DATETIME AFTER `isolement_date`;";
     $this->addQuery($query);
     $this->makeRevision("1.65");
     $query = "ALTER TABLE `operations`\r\n      ADD `examen_operation_id` INT (11) UNSIGNED,\r\n      ADD INDEX (`examen_operation_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.66");
     $this->getFieldRenameQueries("COperation", "sortie_reveil", "sortie_reveil_possible");
     $this->makeRevision("1.67");
     $query = "ALTER TABLE `sejour`\r\n                CHANGE `assurance_maladie` `assurance_maladie` INT (11) UNSIGNED,\r\n                CHANGE `assurance_accident` `assurance_accident` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD INDEX (`assurance_maladie`),\r\n                ADD INDEX (`assurance_accident`);";
     $this->addQuery($query);
     $this->makeRevision("1.68");
     $query = "CREATE TABLE `mode_entree_sejour` (\r\n                `mode_entree_sejour_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `code` VARCHAR (40) NOT NULL,\r\n                `mode` VARCHAR (20) NOT NULL,\r\n                `group_id` INT (11) UNSIGNED NOT NULL,\r\n                `libelle` VARCHAR (255),\r\n                `actif` ENUM ('0','1') DEFAULT '0'\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `mode_entree_sejour`\r\n              ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $query = "CREATE TABLE `mode_sortie_sejour` (\r\n                `mode_sortie_sejour_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `code` VARCHAR (40) NOT NULL,\r\n                `mode` VARCHAR (20) NOT NULL,\r\n                `group_id` INT (11) UNSIGNED NOT NULL,\r\n                `libelle` VARCHAR (255),\r\n                `actif` ENUM ('0','1') DEFAULT '0'\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `mode_sortie_sejour`\r\n                ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD `mode_entree_id` INT (11) UNSIGNED AFTER `mode_entree`,\r\n                ADD `mode_sortie_id` INT (11) UNSIGNED AFTER `mode_sortie`,\r\n                ADD INDEX (`mode_entree_id`),\r\n                ADD INDEX (`mode_sortie_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.69");
     $query = "ALTER TABLE `protocole` \r\n              ADD `type_anesth` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations` \r\n              ADD `ASA` ENUM ('1','2','3','4','5') DEFAULT '1',\r\n              ADD `position` ENUM ('DD','DV','DL','GP','AS','TO','GYN');";
     $this->addQuery($query);
     $query = "UPDATE `operations`, `consultation_anesth`\r\n      SET `operations`.`ASA` = `consultation_anesth`.`ASA`,\r\n      `operations`.`position` = `consultation_anesth`.`position`\r\n      WHERE `consultation_anesth`.`operation_id` = `operations`.`operation_id`;";
     $this->addQuery($query);
     $this->makeRevision("1.70");
     $query = "ALTER TABLE `sejour` DROP INDEX `assurance_maladie`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour` DROP INDEX `assurance_accident`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n           DROP `assurance_accident`,\r\n           DROP `assurance_maladie`,\r\n           DROP `rques_assurance_accident`,\r\n           DROP `rques_assurance_maladie`;";
     $this->addQuery($query);
     $this->makeRevision("1.71");
     $query = "ALTER TABLE `sejour`\r\n      CHANGE `ATNC` `ATNC` ENUM ('0', '1')";
     $this->addQuery($query);
     $query = "UPDATE `sejour`\r\n      SET `ATNC` = NULL\r\n      WHERE `ATNC` = '0';";
     $this->addQuery($query);
     $this->makeRevision("1.72");
     $query = "CREATE TABLE `regle_sectorisation` (\r\n              `regle_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n              `service_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n              `function_id` INT (11) UNSIGNED,\r\n              `praticien_id` INT (11) UNSIGNED,\r\n              `duree_min` INT (11),\r\n              `duree_max` INT (11),\r\n              `date_min` DATETIME,\r\n              `date_max` DATETIME,\r\n              `type_adminission` ENUM ('comp','ambu','exte','seances','ssr','psy','urg','consult'),\r\n              `type_pec` ENUM ('M','C','O'),\r\n              `group_id` INT (11) UNSIGNED NOT NULL DEFAULT '0')\r\n              /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `regle_sectorisation`\r\n              ADD INDEX (`service_id`),\r\n              ADD INDEX (`function_id`),\r\n              ADD INDEX (`praticien_id`),\r\n              ADD INDEX (`date_min`),\r\n              ADD INDEX (`date_max`),\r\n              ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $this->makeRevision("1.73");
     $query = "ALTER TABLE `regle_sectorisation`\r\n    CHANGE `type_adminission` `type_admission` ENUM( 'comp', 'ambu', 'exte', 'seances', 'ssr', 'psy', 'urg', 'consult' )\r\n    NULL DEFAULT NULL ";
     $this->addQuery($query);
     $this->makeRevision("1.74");
     $query = "ALTER TABLE `operations`\r\n                CHANGE `ASA` `ASA` ENUM ('1','2','3','4','5','6') DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("1.75");
     if (!CAppUI::conf("dPplanningOp CSejour use_recuse")) {
         $query = "UPDATE `sejour`\r\n        SET `sejour`.`recuse` = '0'\r\n        WHERE `sejour`.`type` != 'ssr'";
         $this->addQuery($query);
     }
     $this->makeRevision("1.76");
     $query = "ALTER TABLE `sejour`\r\n                CHANGE `mode_sortie` `mode_sortie` ENUM ('normal','transfert','mutation','deces');";
     $this->addQuery($query);
     $this->makeRevision("1.77");
     $query = "ALTER TABLE `operations`\r\n                ADD `graph_pack_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.78");
     $query = "ALTER TABLE `protocole`\r\n                ADD `duree_heure_hospi` TINYINT (4) UNSIGNED DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.79");
     $query = "ALTER TABLE `operations`\r\n                ADD `tarif` VARCHAR (255);";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD `tarif` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("1.80");
     $query = "ALTER TABLE `operations`\r\n                ADD `remise_chir` TIME,\r\n                ADD `tto` TIME,\r\n                ADD `rques_personnel` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.81");
     $query = "ALTER TABLE `operations`\r\n                CHANGE `ASA` `ASA` ENUM ('1','2','3','4','5','6');";
     $this->addQuery($query);
     $this->makeRevision("1.82");
     $query = "ALTER TABLE `mode_entree_sejour`\r\n                CHANGE `actif` `actif` ENUM ('0','1') DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("1.83");
     $query = "ALTER TABLE `mode_sortie_sejour`\r\n                CHANGE `actif` `actif` ENUM ('0','1') DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("1.84");
     $query = "CREATE TABLE `operation_workflow` (\r\n      `miner_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n      `operation_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n      `date` DATE NOT NULL,\r\n      `remined` ENUM ('0','1') NOT NULL DEFAULT '0',\r\n      `date_operation` DATETIME NOT NULL,\r\n      `date_creation` DATETIME,\r\n      `date_cancellation` DATETIME,\r\n      `date_consult_chir` DATETIME,\r\n      `date_consult_anesth` DATETIME,\r\n      `date_creation_consult_chir` DATETIME,\r\n      `date_creation_consult_anesth` DATETIME,\r\n      `date_visite_anesth` DATE\r\n    )/*! ENGINE=MyISAM */";
     $this->addQuery($query);
     $query = "ALTER TABLE `operation_workflow`\r\n      ADD INDEX (`operation_id`),\r\n      ADD INDEX (`date`)";
     $this->addQuery($query);
     $this->makeRevision("1.85");
     $query = "ALTER TABLE `protocole`\r\n                ADD `facturable` ENUM ('0','1') NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("1.86");
     $query = "ALTER TABLE `operations`\r\n      ADD `sortie_locker_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.87");
     $query = "ALTER TABLE `sejour`\r\n      ADD `confirme_date` DATETIME AFTER `confirme`;";
     $this->addQuery($query);
     $query = "UPDATE `sejour`\r\n      SET `confirme_date` = `sejour`.`sortie_prevue`\r\n      WHERE `sejour`.`confirme` = '1'";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      DROP `confirme`,\r\n      CHANGE `confirme_date` `confirme` DATETIME";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n      ADD `confirme_user_id` INT (11) UNSIGNED AFTER `confirme`;";
     $this->addQuery($query);
     $this->makeRevision("1.88");
     // Synchronisation de la date de l'intervention avec celle de la plage
     $query = "UPDATE `operations`\r\n                LEFT JOIN plagesop ON plagesop.plageop_id = `operations`.`plageop_id`\r\n                SET `operations`.`date` = plagesop.date\r\n                WHERE `operations`.plageop_id IS NOT NULL";
     $this->addQuery($query);
     $this->makeRevision('1.89');
     $query = "ALTER TABLE `protocole`\r\n                ADD `charge_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->addDefaultConfigCIP();
     $this->makeRevision('1.90');
     $query = "ALTER TABLE `type_anesth`\r\n                ADD `group_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $query = "ALTER TABLE `type_anesth`\r\n                ADD INDEX (`group_id`);";
     $this->addQuery($query);
     $this->makeRevision('1.91');
     $query = "ALTER TABLE `sejour`\r\n                ADD `exec_tarif` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD INDEX (`exec_tarif`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n                ADD `exec_tarif` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n                ADD INDEX (`exec_tarif`);";
     $this->addQuery($query);
     $this->makeRevision('1.92');
     $query = "ALTER TABLE `sejour`\r\n                ADD `reception_sortie` DATETIME,\r\n                ADD `completion_sortie` DATETIME;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                ADD INDEX (`reception_sortie`),\r\n                ADD INDEX (`completion_sortie`);";
     $this->addQuery($query);
     $this->makeRevision("1.93");
     $query = "ALTER TABLE `charge_price_indicator`\r\n                CHANGE `group_id` `group_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                ADD `color` VARCHAR (6) NOT NULL DEFAULT 'ffffff';";
     $this->addQuery($query);
     $this->makeRevision("1.94");
     $query = "ALTER TABLE `operation_workflow`\r\n                ADD `postmined` ENUM ('0','1') NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("1.95");
     $query = "ALTER TABLE `operations`\r\n                ADD `poste_preop_id` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("1.96");
     $query = "ALTER TABLE `sejour`\r\n                ADD `technique_reanimation` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("1.97");
     $query = "ALTER TABLE `operations`\r\n                ADD `entree_chir` TIME AFTER induction_debut,\r\n                ADD `entree_anesth` TIME AFTER entree_chir;";
     $this->addQuery($query);
     $this->makeRevision("1.98");
     $this->makeRevision("1.99");
     $query = "ALTER TABLE `sejour`\r\n      ADD `consult_related_id` INT (11) UNSIGNED AFTER `group_id`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n      ADD `consult_related_id` INT (11) UNSIGNED AFTER `salle_id`;";
     $this->addQuery($query);
     $this->addFunctionalPermQuery("allowed_check_entry", "0");
     $this->makeRevision("2.00");
     $query = "CREATE TABLE `sejour_affectation` (\r\n                `sejour_affectation_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `sejour_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `user_id` INT (11) UNSIGNED NOT NULL DEFAULT '0'\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour_affectation`\r\n                ADD INDEX (`sejour_id`),\r\n                ADD INDEX (`user_id`);";
     $this->addQuery($query);
     $this->makeRevision("2.01");
     $query = "ALTER TABLE `operations`\r\n              DROP `entree_chir`,\r\n              DROP `entree_anesth`;";
     $this->addQuery($query);
     $this->makeRevision("2.02");
     $dsn = CSQLDataSource::get('std');
     if (!$dsn->fetchRow($dsn->exec('SHOW TABLES LIKE \'libelleop\';'))) {
         $query = "CREATE TABLE `libelleop` (\r\n                  `libelleop_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                  `statut` ENUM ('valide','no_valide','indefini'),\r\n                  `nom` VARCHAR (255) NOT NULL,\r\n                  `date_debut` DATETIME,\r\n                  `date_fin` DATETIME,\r\n                  `services` VARCHAR (255),\r\n                  `mots_cles` VARCHAR (255),\r\n                  `numero` INT (11) NOT NULL DEFAULT '0',\r\n                  `version` INT (11) DEFAULT '1',\r\n                  `group_id` INT (11) UNSIGNED\r\n                )/*! ENGINE=MyISAM */;";
         $this->addQuery($query, true);
         $query = "ALTER TABLE `libelleop`\r\n                ADD INDEX `date_debut` (`date_debut`),\r\n                ADD INDEX `group_id` (`group_id`),\r\n                ADD INDEX `date_fin` (`date_fin`);";
         $this->addQuery($query, true);
     }
     $this->makeRevision("2.03");
     if (!$dsn->fetchRow($dsn->exec('SHOW TABLES LIKE \'liaison_libelle\';'))) {
         $query = "CREATE TABLE `liaison_libelle` (\r\n                `liaison_libelle_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `libelleop_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `operation_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `numero` TINYINT (4) UNSIGNED DEFAULT '1')/*! ENGINE=MyISAM */;";
         $this->addQuery($query, true);
         $query = "ALTER TABLE `liaison_libelle`\r\n                ADD INDEX `libelleop_id` (`libelleop_id`),\r\n                ADD INDEX `operation_id` (`operation_id`);";
         $this->addQuery($query, true);
     }
     $this->makeRevision("2.04");
     $query = "ALTER TABLE `sejour`\r\n                ADD `handicap` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision('2.05');
     $query = "ALTER TABLE `mode_sortie_sejour`\r\n                ADD `destination` ENUM('1','2','3','4','6','7'),\r\n                ADD `orientation` ENUM('HDT','HO','SC','SI','REA','UHCD','MED','CHIR','OBST','FUGUE','SCAM','PSA','REO');";
     $this->addQuery($query);
     $this->makeRevision("2.06");
     $query = "ALTER TABLE `regle_sectorisation`\r\n                ADD `priority` INT (11) NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("2.07");
     $query = "CREATE TABLE `operation_commande` (\r\n                `commande_materiel_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `operation_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `etat` ENUM ('a_commander','commandee','modify','recue','annulee','a_annuler') NOT NULL DEFAULT 'a_commander',\r\n                `date` DATE,\r\n                `commentaire` VARCHAR (255)\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `operation_commande`\r\n                ADD INDEX (`operation_id`),\r\n                ADD INDEX (`date`);";
     $this->addQuery($query);
     $query = "ALTER TABLE `operations`\r\n                ADD `exam_per_op` TEXT;";
     $this->addQuery($query);
     $query = "ALTER TABLE `protocole`\r\n                ADD `exam_per_op` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("2.08");
     $query = "INSERT INTO `operation_commande` (`operation_id` ,`etat`,`date`)\r\n        SELECT o.operation_id, 'commandee', p.date\r\n        FROM operations o, plagesop p\r\n        WHERE o.commande_mat = '1'\r\n        AND o.annulee = '0'\r\n        AND o.plageop_id = p.plageop_id;";
     $this->addQuery($query);
     $query = "INSERT INTO `operation_commande` (`operation_id` ,`etat`,`date`)\r\n        SELECT o.operation_id, 'a_annuler', p.date\r\n        FROM operations o, plagesop p\r\n        WHERE o.commande_mat = '1'\r\n        AND o.annulee = '1'\r\n        AND o.plageop_id = p.plageop_id;";
     $this->addQuery($query);
     $this->makeRevision('2.09');
     $query = "ALTER TABLE `mode_sortie_sejour`\r\n                CHANGE `destination` `destination` ENUM('0', '1','2','3','4','6','7');";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour`\r\n                CHANGE `destination` `destination` ENUM('0', '1','2','3','4','6','7');";
     $this->addQuery($query);
     $this->makeRevision('2.10');
     $query = "ALTER TABLE `sejour`\r\n                ADD `date_entree_reelle_provenance` DATETIME;";
     $this->addQuery($query);
     $this->makeRevision('2.11');
     $query = "ALTER TABLE sejour ADD INDEX consult_related_id (consult_related_id)";
     $this->addQuery($query, true);
     $query = "ALTER TABLE operations ADD INDEX consult_related_id (consult_related_id)";
     $this->addQuery($query, true);
     $this->makeRevision("2.12");
     $query = "ALTER TABLE `regle_sectorisation`\r\n                ADD `age_min` TINYINT UNSIGNED,\r\n                ADD `age_max` TINYINT UNSIGNED,\r\n                ADD `handicap` ENUM('0', '1');";
     $this->addQuery($query);
     $this->makeRevision("2.13");
     $query = "ALTER TABLE `operations`\r\n               CHANGE `position` `position` ENUM ('DD','DV','DL','GP','AS','TO','GYN','DDA')";
     $this->addQuery($query);
     $this->makeRevision("2.14");
     $query = "ALTER TABLE `operations`\r\n      ADD `time_visite_anesth` TIME AFTER `date_visite_anesth`";
     $this->addQuery($query);
     $this->makeRevision("2.15");
     $query = "ALTER TABLE `operations`\r\n      ADD `suture_fin` TIME AFTER `induction_fin`";
     $this->addQuery($query);
     $this->makeRevision("2.16");
     $this->addMethod("moveConfigUFSoins");
     $this->makeRevision("2.17");
     $query = "ALTER TABLE `sejour`\r\n                CHANGE `provenance` `provenance` ENUM ('1','2','3','4','5','6','7','8','R');";
     $this->addQuery($query);
     $this->makeRevision("2.18");
     $query = "CREATE TABLE `sejour_appel` (\r\n                `appel_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `sejour_id` INT (11) UNSIGNED NOT NULL DEFAULT '0',\r\n                `datetime` DATETIME NOT NULL,\r\n                `type` ENUM ('admission','sortie') NOT NULL DEFAULT 'admission',\r\n                `etat` ENUM ('realise','echec') NOT NULL DEFAULT 'realise',\r\n                `commentaire` TEXT\r\n              )/*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour_appel`\r\n                ADD INDEX (`sejour_id`),\r\n                ADD INDEX (`datetime`);";
     $this->addQuery($query);
     $this->makeRevision("2.19");
     $query = "ALTER TABLE `sejour_appel`\r\n                ADD `user_id` INT (11) UNSIGNED NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $query = "ALTER TABLE `sejour_appel`\r\n                ADD INDEX (`user_id`);";
     $this->addQuery($query);
     $this->mod_version = '2.20';
 }
Exemplo n.º 2
0
 function __construct()
 {
     parent::__construct();
     $this->mod_name = "mediusers";
     $this->makeRevision("all");
     $query = "CREATE TABLE `users_mediboard` (\r\n               `user_id` INT(11) UNSIGNED NOT NULL,\r\n               `function_id` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\r\n               PRIMARY KEY (`user_id`)\r\n             ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "CREATE TABLE `functions_mediboard` (\r\n               `function_id` TINYINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n               `group_id` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\r\n               `text` VARCHAR(50) NOT NULL,\r\n               `color` VARCHAR(6) NOT NULL DEFAULT 'ffffff',\r\n               PRIMARY KEY (`function_id`)\r\n             ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $this->makeRevision("0.1");
     $query = "ALTER TABLE `users_mediboard` ADD `remote` TINYINT DEFAULT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.11");
     $query = "ALTER TABLE `users_mediboard` ADD `adeli` int(9) DEFAULT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.12");
     $query = "ALTER TABLE `users_mediboard` CHANGE `adeli` `adeli` VARCHAR(9);";
     $this->addQuery($query);
     $this->makeRevision("0.13");
     $query = "CREATE TABLE `discipline` (\r\n                `discipline_id` TINYINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n                `text` VARCHAR(100) NOT NULL,\r\n                PRIMARY KEY (`discipline_id`)\r\n              ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `users_mediboard` ADD `discipline_id` TINYINT(4) DEFAULT NULL AFTER `function_id`";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ADDICTOLOGIE CLINIQUE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('AIDE MEDICALE URGENTE OU MEDECINE D\\'URGENCE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ALLERGOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ANATOMIE ET CYTOLOGIE PATHOLOGIQUES');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ANDROLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ANESTHESIE-REANIMATION');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ANGIOLOGIE/ MEDECINE VASCULAIRE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('BIOLOGIE MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CANCEROLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CARDIOLOGIE / PATHOLOGIE CARDIO-VASCULAIRE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE DE LA FACE ET DU COU');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE GENERALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE INFANTILE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE MAXILLO-FACIALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE MAXILLO-FACIALE ET STOMATOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE ORTHOPEDIQUE ET TRAUMATOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE PLASTIQUE, RECONSTRUCTRICE ET ESTHETIQUE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE THORACIQUE ET CARDIO-VASCULAIRE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE UROLOGIQUE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE VASCULAIRE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('CHIRURGIE VISCERALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('DERMATOLOGIE ET VENEREOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ENDOCRINOLOGIE ET METABOLISMES');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('EVALUATION ET TRAITEMENT DE LA DOULEUR');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('GASTRO-ENTEROLOGIE ET HEPATOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('GENETIQUE MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('GERIATRIE / GERONTOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('GYNECOLOGIE MEDICALE, OBSTETRIQUE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('GYNECOLOGIE-OBSTETRIQUE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('HEMATOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('HEMOBIOLOGIE-TRANSFUSION / TECHNOLOGIE TRANSFUSION');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('HYDROLOGIE ET CLIMATOLOGIE MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('IMMUNOLOGIE ET IMMUNOPATHOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE AEROSPATIALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE DE CATASTROPHE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE DE LA REPRODUCTION ET GYNECOLOGIE MEDICAL');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE DU TRAVAIL');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE ET BIOLOGIE DU SPORT');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE GENERALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE INTERNE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE LEGALE ET EXPERTISES MEDICALES');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE NUCLEAIRE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE PENITENTIAIRE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('MEDECINE PHYSIQUE ET DE READAPTATION');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('NEPHROLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('NEUROCHIRURGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('NEUROLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('NEUROPSYCHIATRIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('NUTRITION');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ONCOLOGIE MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ONCOLOGIE OPTION RADIOTHERAPIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('OPHTALMOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('ORTHOPEDIE DENTO-MAXILLO-FACIALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('OTO-RHINO-LARYNGOLOGIE ET CHIRURGIE CERVICO-FACIALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('PATHOLOGIE INFECTIEUSE ET TROPICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('PEDIATRIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('PHONIATRIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('PNEUMOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('PSYCHIATRIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('PSYCHIATRIE DE L\\'ENFANT ET DE L\\'ADOLESCENT');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('RADIO-DIAGNOSTIC ET IMAGERIE MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('RADIOTHERAPIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('REANIMATION MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('RECHERCHE MEDICALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('RHUMATOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('SANTE PUBLIQUE ET MEDECIN SOCIALE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('STOMATOLOGIE');";
     $this->addQuery($query);
     $query = "INSERT INTO `discipline` (`text`) VALUES('TOXICOMANIES ET ALCOOLOGIE');";
     $this->addQuery($query);
     $this->makeRevision("0.14");
     $query = "ALTER TABLE `functions_mediboard`\r\n              ADD `type` ENUM('administratif', 'cabinet') DEFAULT 'administratif' NOT NULL AFTER `group_id`;";
     $this->addQuery($query);
     $this->addMethod("updateFct");
     $this->makeRevision("0.15");
     $query = "ALTER TABLE `functions_mediboard` ADD INDEX ( `group_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `users_mediboard` ADD INDEX ( `function_id` ) ;";
     $this->addQuery($query);
     $query = "ALTER TABLE `users_mediboard` ADD INDEX ( `discipline_id` ) ;";
     $this->addQuery($query);
     $this->makeRevision("0.16");
     $query = "ALTER TABLE `discipline` \r\n                CHANGE `discipline_id` `discipline_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `text` `text` varchar(255) NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `functions_mediboard` \r\n                CHANGE `function_id` `function_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `group_id` `group_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `text` `text` varchar(255) NOT NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `users_mediboard` \r\n                CHANGE `user_id` `user_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                CHANGE `function_id` `function_id` int(11) unsigned NOT NULL DEFAULT '0',\r\n                CHANGE `adeli` `adeli` int(9) unsigned zerofill NULL,\r\n                CHANGE `remote` `remote` enum('0','1') NULL,\r\n                CHANGE `discipline_id` `discipline_id` int(11) unsigned NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.17");
     $query = "ALTER TABLE `users_mediboard` \r\n                ADD `commentaires`  text NULL,\r\n                ADD `actif` enum('0','1') NOT NULL DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("0.18");
     $query = "ALTER TABLE `users_mediboard` \r\n                ADD `deb_activite` datetime NULL,\r\n                ADD `fin_activite` datetime NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.19");
     $query = "ALTER TABLE `users_mediboard` \r\n                CHANGE `deb_activite` `deb_activite` date NULL,\r\n                CHANGE `fin_activite` `fin_activite` date NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.20");
     $query = "CREATE TABLE `spec_cpam` (\r\n               `spec_cpam_id` TINYINT(4) UNSIGNED NOT NULL,\r\n               `text` VARCHAR(255) NOT NULL,\r\n               `actes` VARCHAR(255) NOT NULL,\r\n               PRIMARY KEY (`spec_cpam_id`)\r\n               ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `users_mediboard` ADD `spec_cpam_id` TINYINT(4) DEFAULT NULL AFTER `discipline_id`";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(1,'MEDECINE GENERALE','C|K|Z|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(2,'ANESTHESIOLOGIE - REANIMATION CHIRURGICALE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(3,'PATHOLOGIE CARDIO-VASCULAIRE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(4,'CHIRURGIE GENERALE','CS|K|KC|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(5,'DERMATOLOGIE ET VENEROLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(6,'RADIODIAGNOSTIC ET IMAGERIE MEDICALE','C|K|Z|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(7,'GYNECOLOGIE OBSTETRIQUE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(8,'GASTRO-ENTEROLOGIE ET HEPATOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(9,'MEDECINE INTERNE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(10,'NEUROCHIRURGIEN','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(11,'OTO RHINO LARYNGOLOGISTE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(12,'PEDIATRE','CS|K|FPE|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(13,'PNEUMOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(14,'RHUMATOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(15,'OPHTAMOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(16,'CHIRURGIE UROLOGIQUE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(17,'NEURO PSYCHIATRIE','CNP');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(18,'STOMATOLOGIE','CS|Z|SCM|PRO|ORT|K|FDA|FDC|FDO|FDR|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(19,'CHIRURGIE DENTAIRE','C|Z|D|DC|SPR|SC|FDA|FDC|FDO|FDR');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(21,'SAGE FEMME','C|SF|SFI');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(24,'INFIRMIER','AMI');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(26,'MASSEUR KINESITHERAPEUTE','AMC');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(27,'PEDICURE','AMP');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(28,'ORTHOPHONISTE','AMO');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(29,'ORTHOPTISTE','AMY');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(30,'LABORATOIRE D\\'ANALYSES MEDICALES','B|KB');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(31,'MEDECINE PHYSIQUE ET DE READAPTATION','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(32,'NEUROLOGIE','CNP|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(33,'PSYCHIATRIE GENERALE','CNP');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(35,'NEPHROLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(36,'CHIRURGIE DENTAIRE (Spéc. O.D.F.)','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(37,'ANATOMIE-CYTOLOGIE-PATHOLOGIQUES','CS|P');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(38,'MEDECIN BIOLOGISTE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(39,'LABORATOIRE POLYVALENT','B');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(40,'LABORATOIRE ANATOMO-PATHOLOGISTE','B');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(41,'CHIRURGIE ORTHOPEDIQUE et TRAUMATOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(42,'ENDOCRINOLOGIE et METABOLISMES','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(43,'CHIRURGIE INFANTILE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(44,'CHIRURGIE MAXILLO-FACIALE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(45,'CHIRURGIE MAXILLO-FACIALE ET STOMATOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(46,'CHIRURGIE PLASTIQUE RECONSTRUCTRICE ET ESTHECS','K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(47,'CHIRURGIE THORACIQUE ET CARDIO-VASCULAIRE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(48,'CHIRURGIE VASCULAIRE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(49,'CHIRURGIE VISCERALE ET DIGESTIVE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(50,'PHARMACIEN','');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(70,'GYNECOLOGIE MEDICALE','CS|K|ZM|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(71,'HEMATOLOGIE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(72,'MEDECINE NUCLEAIRE','CS|K|ZN|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(73,'ONCOLOGIE MEDICALE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(74,'ONCOLOGIE RADIOTHERAPIQUE','CS|K|Z|ZN|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(75,'PSYCHIATRIE DE L''ENFANT ET DE L''ADOLESCENT','CNP');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(76,'RADIOTHERAPIE','CS|Z|ZN|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(77,'OBSTETRIQUE','CS|K|Z|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`)\r\n              VALUES(78,'GENETIQUE MEDICALE','CS|K|ADE|ADI|ADC|ACO|ADA|ATM');";
     $this->addQuery($query);
     $this->makeRevision("0.21");
     $query = "ALTER TABLE `users_mediboard` CHANGE `spec_cpam_id` `spec_cpam_id` int(11) unsigned NULL;";
     $this->addQuery($query);
     $query = "ALTER TABLE `spec_cpam` CHANGE `spec_cpam_id` `spec_cpam_id` int(11) unsigned NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.22");
     $query = "ALTER TABLE `users_mediboard` ADD `titres`  text NULL AFTER adeli;";
     $this->addQuery($query);
     $this->makeRevision("0.23");
     $query = "ALTER TABLE `functions_mediboard` \r\n                ADD `adresse` TEXT NULL,\r\n                ADD `cp` int(5) unsigned zerofill NULL,\r\n                ADD `ville` VARCHAR( 50 ) NULL,\r\n                ADD `tel` bigint(10) unsigned zerofill NULL,\r\n                ADD `fax` bigint(10) unsigned zerofill NULL,\r\n                ADD `soustitre` TEXT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.24");
     $query = "ALTER TABLE `discipline` ADD `categorie` enum('ORT','ORL','OPH','DER','STO','GAS','ARE','RAD','GYN','EST') NULL";
     $this->addQuery($query);
     $this->makeRevision("0.25");
     $query = "UPDATE `users_mediboard` SET `discipline_id` = NULL WHERE `discipline_id` = '0';";
     $this->addQuery($query);
     $this->makeRevision("0.26");
     $query = "ALTER TABLE `users_mediboard` ADD `compte` VARCHAR(23);";
     $this->addQuery($query);
     $this->makeRevision("0.27");
     $query = "ALTER TABLE `users_mediboard` ADD `banque_id` INT(11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.28");
     $query = "ALTER TABLE `functions_mediboard` ADD `compta_partagee` BOOL NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.29");
     $query = "CREATE TABLE `secondary_function` (\r\n               `secondary_function_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n               `function_id` INT (11) UNSIGNED NOT NULL,\r\n               `user_id` INT (11) UNSIGNED NOT NULL\r\n             ) /*! ENGINE=MyISAM */;";
     $this->addQuery($query);
     $query = "ALTER TABLE `secondary_function`\r\n              ADD INDEX (`function_id`),\r\n              ADD INDEX (`user_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.30");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `rpps` BIGINT (11) UNSIGNED ZEROFILL AFTER `adeli`;";
     $this->addQuery($query);
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD INDEX (`deb_activite`),\r\n              ADD INDEX (`fin_activite`),\r\n              ADD INDEX (`banque_id`),\r\n              ADD INDEX (`spec_cpam_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.31");
     $query = "INSERT INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`) VALUES(80,'SANTE PUBLIQUE ET MEDECINE SOCIALE','');";
     $this->addQuery($query);
     $this->makeRevision("0.32");
     $query = "ALTER TABLE `users_mediboard` ADD `code_intervenant_cdarr` CHAR (2) DEFAULT NULL;";
     $this->addQuery($query);
     $this->makeRevision("0.33");
     $query = "ALTER TABLE `functions_mediboard`\r\n              ADD `actif` ENUM ('0','1') DEFAULT '1',\r\n              ADD `admission_auto` ENUM ('0','1') DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.34");
     $query = "ALTER TABLE `functions_mediboard`\r\n              ADD `consults_partagees` ENUM ('0','1') NOT NULL DEFAULT '1' AFTER compta_partagee;";
     $this->addQuery($query);
     $this->makeRevision("0.35");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `secteur` ENUM ('1','2'),\r\n              ADD `cab` VARCHAR (255),\r\n              ADD `conv` VARCHAR (255),\r\n              ADD `zisd` VARCHAR (255),\r\n              ADD `ik` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("0.36");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `cps` BIGINT ZEROFILL AFTER `rpps`;";
     $this->addQuery($query);
     $this->makeRevision("0.37");
     $query = "ALTER TABLE `users_mediboard`\r\n              CHANGE `cps` `cps` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("0.38");
     $query = "ALTER TABLE `functions_mediboard`\r\n              ADD `quotas` INT (11) UNSIGNED;";
     $this->addQuery($query);
     $this->makeRevision("0.39");
     $query = "ALTER TABLE `functions_mediboard`\r\n              CHANGE `tel` `tel` VARCHAR (20),\r\n              CHANGE `fax` `fax` VARCHAR (20)";
     $this->addQuery($query);
     $this->makeRevision("0.40");
     $query = "ALTER TABLE `users_mediboard`\r\n               ADD `ean` VARCHAR (30),\r\n               ADD `rcc` VARCHAR (30),\r\n               ADD `adherent` VARCHAR (30);";
     $this->addQuery($query);
     $this->makeRevision("0.41");
     $query = "ALTER TABLE `users_mediboard`\r\n               ADD `mail_apicrypt` VARCHAR (50);";
     $this->addQuery($query);
     $this->makeRevision("0.42");
     $query = "ALTER TABLE `users_mediboard`\r\n               ADD `compta_deleguee` BOOL NOT NULL DEFAULT '0';";
     $this->addQuery($query);
     $this->makeRevision("0.43");
     $query = "ALTER TABLE `users_mediboard`\r\n               ADD `num_astreinte` VARCHAR (20)";
     $this->addQuery($query);
     $this->makeRevision("0.44");
     $query = "ALTER TABLE `users_mediboard`\r\n               DROP `num_astreinte`";
     $this->addQuery($query);
     $this->makeRevision("0.45");
     $query = "ALTER TABLE `functions_mediboard`\r\n               ADD `facturable` ENUM ('0','1') DEFAULT '1';";
     $this->addQuery($query);
     $this->makeRevision("0.46");
     $query = "ALTER TABLE `users_mediboard`\r\n            ADD `initials` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision("0.47");
     $query = "ALTER TABLE `users_mediboard`\r\n            ADD `debut_bvr` VARCHAR (10);";
     $this->addQuery($query);
     $this->makeRevision("0.48");
     $this->makeRevision("0.49");
     $query = CSetupdPcompteRendu::renameTemplateFieldQuery("Praticien - Spécialité", "Praticien - Discipline");
     $this->addQuery($query, true);
     $this->makeRevision("0.50");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `last_ldap_checkout` DATE;";
     $this->addQuery($query);
     $this->makeRevision("0.51");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `service_account` ENUM ('0','1') NOT NULL DEFAULT '0' AFTER `actif`;";
     $this->addQuery($query);
     $this->makeRevision("0.52");
     $query = "ALTER TABLE `users_mediboard`\r\n              DROP `service_account`;";
     $this->addQuery($query);
     $this->makeRevision("0.53");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `other_specialty_id` INT (11) UNSIGNED,\r\n              ADD INDEX (`other_specialty_id`);";
     $this->addQuery($query);
     $this->makeRevision("0.54");
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `color` VARCHAR (6);";
     $this->addQuery($query);
     $this->makeRevision("0.55");
     $query = "ALTER TABLE `users_mediboard`\r\n                ADD `use_bris_de_glace` ENUM ('0','1') NOT NULL DEFAULT '0' AFTER `actif`;";
     $this->addQuery($query);
     $this->makeRevision('0.56');
     $query = "ALTER TABLE `users_mediboard`\r\n                ADD `contrat_acces_soins` ENUM('0', '1'),\r\n                ADD `option_coordination` ENUM('0', '1');";
     $this->addQuery($query);
     $query = "INSERT IGNORE INTO `spec_cpam` (`spec_cpam_id`, `text`, `actes`) VALUES\r\n                (20, 'Réanimation médicale', ''),\r\n                (34, 'Gériatrie', ''),\r\n                (51, 'Pharmacien mutualiste', ''),\r\n                (53, 'Chirurgie dentaire orale', ''),\r\n                (78, 'Génétique médicale', ''),\r\n                (79, 'Gynécologie obstétrique et gynécologie médicale', '');";
     $this->addQuery($query);
     $this->makeRevision('0.57');
     $query = "ALTER TABLE `users_mediboard`\r\n              ADD `inami` BIGINT (11) UNSIGNED ZEROFILL AFTER `rpps`;";
     $this->addQuery($query);
     $this->makeRevision('0.58');
     $query = "ALTER TABLE `users_mediboard`\r\n                ADD `electronic_bill` ENUM ('0','1') DEFAULT '0',\r\n                ADD `specialite_tarmed` MEDIUMINT (4) UNSIGNED ZEROFILL;";
     $this->addQuery($query);
     $this->makeRevision('0.59');
     $query = "ALTER TABLE `users_mediboard`\r\n                ADD `ean_base` VARCHAR (255),\r\n                ADD `role_tarmed` VARCHAR (255),\r\n                ADD `place_tarmed` VARCHAR (255);";
     $this->addQuery($query);
     $this->makeRevision('0.60');
     $query = "ALTER TABLE `users_mediboard`\r\n                ADD `reminder_text` TEXT;";
     $this->addQuery($query);
     $this->makeRevision("0.61");
     $query = "ALTER TABLE `functions_mediboard`\r\n              ADD `initials` VARCHAR(255) AFTER `text`;";
     $this->addQuery($query);
     $this->mod_version = '0.62';
 }
Exemplo n.º 3
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);
         }
     }
 }