
ALTER TABLE `system` DROP KEY `name`, ADD UNIQUE KEY `nameGroupe` (`name`, `groupe`);

ALTER TABLE `actes_base` CHANGE `type` `type` enum('NGAP','CCAM', 'Libre') NOT NULL DEFAULT 'CCAM';

ALTER TABLE `objets_data` ADD `byID` INT(11) UNSIGNED;

ALTER TABLE `printed` CHANGE `type` `type` ENUM('cr','ordo','courrier','ordoLAP') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'cr';

ALTER TABLE `printed` ADD `anonyme` ENUM('','y') NULL DEFAULT '' AFTER `outdated`;

ALTER TABLE `forms_cat` ADD UNIQUE(`name`);

ALTER TABLE `prescriptions_cat` ADD `toID` MEDIUMINT(6) UNSIGNED NOT NULL DEFAULT '0' AFTER `fromID`;
ALTER TABLE `prescriptions_cat` ADD UNIQUE(`name`);
ALTER TABLE `prescriptions` CHANGE `cat` `cat` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0';

UPDATE `prescriptions_cat` set `type`='user';
ALTER TABLE `prescriptions_cat` CHANGE `type` `type` ENUM('nonlap','lap','user') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'nonlap';
UPDATE `prescriptions_cat` set `type`='nonlap';
ALTER TABLE `prescriptions_cat` CHANGE `type` `type` ENUM('nonlap','lap') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'nonlap';

INSERT IGNORE INTO `data_cat` (`groupe`, `name`, `label`, `description`, `type`, `fromID`, `creationDate`) VALUES
('medical', 'aldCat', 'ALD', 'paramètres pour la gestion des ALD', 'base', 1, '2018-01-01 00:00:00'),
('medical', 'catAtcdStruc', 'ATCD structurés', 'données pour antécédents structurés', 'base', 1, '2018-01-01 00:00:00'),
('typecs', 'catTypeCsATCD', 'Antécédents et allergies', 'antécédents et allergies', 'base', 1, '2018-01-01 00:00:00'),
('relation', 'catAllergiesStruc', 'Allergies structurées', 'données pour allergies structurées', 'base', 1, '2018-01-01 00:00:00'),
('ordo', 'lapCatPorteurs', 'LAP porteurs', 'data pour les porteurs LAP', 'base', 1, '2018-01-01 00:00:00'),
('ordo', 'lapCatLignePrescription', 'LAP ligne de prescription', 'data des lignes de prescription', 'base', 1, '2018-01-01 00:00:00'),
('ordo', 'lapCatMedicament', 'LAP médicament', 'data pour les médicaments', 'base', 1, '2018-01-01 00:00:00'),
('ordo', 'lapCatSams', 'LAP SAMs', 'data pour SAMs LAP', 'base', 1, '2018-01-01 00:00:00');

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='porteursReglement');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`,`cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
 ('reglement', 'reglePorteurS1', '', 'Règlement conventionné S1', 'Règlement conventionné S1', '', '', '', 'baseReglementS1', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1),
 ('reglement', 'reglePorteurLibre', '', 'Règlement non conventionné', 'Règlement non conventionné', '', '', '', 'baseReglementLibre', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='reglementItems');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('reglement', 'regleTarifLibreCejour', '', 'Tarif', 'tarif appliqué ce jour', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1),
('reglement', 'regleModulCejour', '', 'Modulation', 'modulation appliquée ce jour', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='declencheur');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('typecs', 'nouvelleGrossesse', '', 'Nouvelle grossesse', 'support parent pour nouvelle grossesse', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 86400, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='grossesse');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('medical', 'groFermetureSuivi', '', 'Fermeture de la grossesse', 'date de fermeture de la grossesse (porteur)', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('medical', 'DDR', 'ddr', 'DDR', 'date des dernières règles', '', 'validedate,\'d/m/Y\'', 'date', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('medical', 'ddg', 'ddg', 'DDG (théorique)', 'date de début de grossesse', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('medical', 'ddgReel', '', 'DDG (retenue)', 'date de début de grossesse corrigé', '', '', 'date', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('medical', 'termeDuJour', '', 'Terme du jour', 'terme du jour', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('medical', 'terme9mois', '', 'Terme (9 mois)', 'terme', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='dataCliniques');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('medical', 'taSystolique', '', 'TAS', 'tension artérielle systolique en mm Hg', '', '', 'text', '', 'base', @catID, 1, '2018-05-14 13:41:48', 60, 1),
('medical', 'taDiastolique', '', 'TAD', 'tension artérielle diastolique en mm Hg', '', '', 'text', '', 'base', @catID, 1, '2018-05-14 13:41:54', 60, 1),
('medical', 'freqCardiaque', '', 'FC', 'fréquence cardiaque en bpm', '', '', 'text', '', 'base', @catID, 1, '2018-05-14 13:41:42', 60, 1),
('medical', 'spO2', '', 'SpO2', 'saturation en oxygène', '', '', 'text', '', 'base', @catID, 1, '2018-05-15 10:08:20', 60, 1);



UPDATE `data_types` SET `name`='regleTarifSSCejour' WHERE `name`='regleTarifCejour';
UPDATE `data_types` SET `name`='reglePorteurS2', `label`='Règlement conventionné S2', `placeholder`='Règlement conventionné S2', `formValues`='baseReglementS2' WHERE `name`='reglePorteur';
UPDATE `data_types` SET `placeholder`='type et nom de la voie', `label`='Voie', `description`='Adresse perso : voie' WHERE `name`='street';
UPDATE `data_types` SET `placeholder`='type et nom de la voie', `label`='Voie', `description`='Adresse pro : voie' WHERE `name`='rueAdressePro';
UPDATE `data_types` SET `placeholder`='n° dans la voie', `label`='n°', `description`='Adresse perso : n° dans la voie' WHERE `name`='streetNumber';
UPDATE `data_types` SET `placeholder`='n° dans la voie', `label`='n°', `description`='Adresse pro : n° dans la voie' WHERE `name`='numAdressePro';
UPDATE `data_types` SET `placeholder`='mobile: 0x xx xx xx xx' WHERE  `name`='mobilePhone';
UPDATE `data_types` SET `placeholder`='fixe: 0x xx xx xx xx' WHERE  `name`='homePhone';
UPDATE `data_types` SET `placeholder`='naissance: dd/mm/YYYY' WHERE  `name`='birthdate';
UPDATE `data_types` SET `placeholder`='décès: dd/mm/YYYY' WHERE  `name`='deathdate';
UPDATE `data_types` SET `placeholder`='nom marital ou d\'usage' WHERE  `name`='lastname';
UPDATE `data_types` SET `placeholder`='nom' WHERE  `name`='birthname';
UPDATE `data_types` SET `label`='Informations paiement', `description`='Information complémentaires sur le paiement', `placeholder`='n° de chèque, nom du payeur si différent du patient,...' WHERE  `name`='regleIdentiteCheque';

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='dataBio');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('medical', 'clairanceCreatinine', 'ml/min', 'Clairance créatinine', 'clairance de la créatinine', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='atcd');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('medical', 'allaitementActuel', '', 'Allaitement', 'allaitement actuel', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('medical', 'insuffisanceHepatique', '', 'Insuffisance hépatique', 'degré d\'insuffisance hépatique', '', '', 'select', '\'z\': "?"\n\'n\': "Pas d\'insuffisance hépatique connue"\n\'1\': \'Légère\'\n\'2\': \'Modérée\'\n\'3\': \'Sévère\'', 'base', @catID, 3, '2018-01-01 00:00:00', 3600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='aldCat');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('medical', 'aldNumber', '', 'ALD', 'ALD choisie', '', '', 'select', '1: "Accident vasculaire cérébral invalidant"\n2: "Insuffisances médullaires et autres cytopénies chroniques"\n3: "Artériopathies chroniques avec manifestations ischémiques"\n4: "Bilharziose compliquée"\n5: "Insuffisance cardiaque grave, troubles du rythme graves, cardiopathies valvulaires graves, cardiopathies  congénitales graves"\n6: "Maladies chroniques actives du foie et cirrhoses"\n7: "Déficit immunitaire primitif grave nécessitant un traitement prolongé, infection par le virus de 9: l\'immuno-déficience humaine (VIH)"\n8: "Diabète de type 1 et diabète de type 2"\n9: "Formes graves des affections neurologiques et musculaires (dont myopathie), épilepsie grave"\n10: "Hémoglobinopathies, hémolyses, chroniques constitutionnelles et acquises sévères"\n11: "Hémophilies et affections constitutionnelles de l\'hémostase graves"\n12: "Maladie coronaire"\n13: "Insuffisance respiratoire chronique grave"\n14: "Maladie d\'Alzheimer et autres démences"\n15: "Maladie de Parkinson"\n16: "Maladies métaboliques héréditaires nécessitant un traitement prolongé spécialisé"\n17: "Mucoviscidose"\n18: "Néphropathie chronique grave et syndrome néphrotique primitif"\n19: "Paraplégie"\n20: "Vascularites, lupus érythémateux systémique, sclérodermie systémique"\n21: "Polyarthrite rhumatoïde évolutive"\n22: "Affections psychiatriques de longue durée"\n23: "Rectocolite hémorragique et maladie de Crohn évolutives"\n24: "Sclérose en plaques"\n25: "Scoliose idiopathique structurale évolutive (dont l\'angle est égal ou supérieur à 25 degrés) jusqu\'à maturation rachidienne"\n26: "Spondylarthrite grave"\n27: "Suites de transplantation d\'organe"\n28: "Tuberculose active, lèpre"\n29: "Tumeur maligne, affection maligne du tissu lymphatique ou hématopoïétique"\n31: "Affection hors liste"\n32: "Etat polypathologique"', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'aldDateDebutPriseEnCharge', '', 'Début de prise en charge', 'date de début de prise en charge', '', '', 'date', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'aldDateFinPriseEnCharge', '', 'Fin de prise en charge', 'date de fin de prise en charge', '', '', 'date', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'aldCIM10', '', 'Code CIM10 associé', 'Code CIM10 attaché à l\'ALD', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'aldCIM10label', '', 'Label CIM10 associé', 'Label CIM10 attaché à l\'ALD', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='catAtcdStruc');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('medical', 'atcdStrucCIM10', '', 'Code CIM 10', 'code CIM 10 de l\'atcd', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucCIM10Label', '', 'Label CIM 10', 'label CIM 10 de l\'atcd', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucDateDebutJour', '', 'Jour', 'jour de début de l\'atcd', '', '', 'number', '0', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucDateFinJour', '', 'Jour', 'jour de fin de l\'atcd', '', '', 'number', '0', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucDateDebutMois', '', 'Mois', 'mois de début de l\'atcd', '', '', 'select', '\'0\' : \'non précisé\'\n\'1\' : \'janvier\'\n\'2\' : \'février\'\n\'3\' : \'mars\'\n\'4\' : \'avril\'\n\'5\' : \'mai\'\n\'6\' : \'juin\'\n\'7\' : \'juillet\'\n\'8\' : \'août\'\n\'9\' : \'septembre\'\n\'10\' : \'octobre\'\n\'11\' : \'novembre\'\n\'12\' : \'décembre\'', 'base', 80, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucDateFinMois', '', 'Mois', 'mois de fin de l\'atcd', '', '', 'select', '\'0\' : \'non précisé\'\n\'1\' : \'janvier\'\n\'2\' : \'février\'\n\'3\' : \'mars\'\n\'4\' : \'avril\'\n\'5\' : \'mai\'\n\'6\' : \'juin\'\n\'7\' : \'juillet\'\n\'8\' : \'août\'\n\'9\' : \'septembre\'\n\'10\' : \'octobre\'\n\'11\' : \'novembre\'\n\'12\' : \'décembre\'', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucDateDebutAnnee', '', 'Année', 'année de début de l\'atcd', '', '', 'number', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucDateFinAnnee', '', 'Année', 'année de fin de l\'atcd', '', '', 'number', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucNotes', 'notes concernant cet antécédents', 'Notes', 'notes concernant l\'atcd', '', '', 'textarea', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('medical', 'atcdStrucCIM10InLap', '', 'A prendre en compte dans le LAP', 'prise en compte ou non dans le LAP', '', '', 'select', '\'o\': \'oui\'\n\'n\': \'non\'', 'base',  @catID, 1, '2018-01-01 00:00:00', 3600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='catTypeCsATCD');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('typecs', 'csAtcdStrucDeclaration', NULL, 'Ajout d\'antécédent', 'support parent pour déclaration d\'antécédent structuré', NULL, NULL, '', 'atcdStrucDeclaration', 'base', @catID, 1, '2018-01-01 00:00:00', 84600, 1),
('typecs', 'csAldDeclaration', NULL, 'Déclaration ALD', 'support parent pour déclaration ALD', NULL, NULL, '', 'aldDeclaration', 'base', @catID, 1, '2018-01-01 00:00:00', 84600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='catAllergiesStruc');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('relation', 'allergieLibelleTheriaque', '', 'Libelle Thériaque de l\'allergie', 'libelle Thériaque de l\'allergie', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0),
('relation', 'allergieCodeTheriaque', '', 'Code Thériaque de l\'allergie', 'code Thériaque de l\'allergie', '', '', 'text', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 0);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='lapCatSams');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('ordo', 'lapSamCommentaire', '', 'Commentaire patient SAM', 'commentaire par patient pour un SAM', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1),
('ordo', 'lapSamDisabled', '', 'Marqueur de SAM bloqué', 'marqueur de SAM bloqué', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='lapCatMedicament');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('ordo', 'lapMedicamentEstPrescriptibleEnDC', '', 'Médicament prescriptible en DC', 'médicament prescriptible en DC', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentDC', '', 'DC du médicament', 'DC du médicament', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentCodeATC', '', 'Code ATC du médicament', 'code ATC du médicament', '', '', '', '', 'base', 86, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentPresentationCodeTheriaque', '', 'Code Thériaque de la présentation', 'code Thériaque de la présentation (a priori le CIP7)', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentSpecialiteCodeTheriaque', '', 'Code Thériaque de la spécialité', 'code Thériaque de la spécialité', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentSpecialiteNom', '', 'Nom de la spécialité', 'nom de la spécialité', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentCodeSubstanceActive', '', 'Code substance active du médicament', 'code substance active du médicament', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapMedicamentMotifPrescription', '', 'Motif de prescription du médicament', 'motif de prescription du médicament', '', '', '', '', 'base', @catID, 1, '2018-04-30 20:30:06', 3600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='lapCatLignePrescription');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
( 'ordo', 'lapLignePrescriptionDureeJours', '', 'Durée de la prescription en jours', 'durée de la prescription en jours', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
( 'ordo', 'lapLignePrescriptionDatePriseFinEffective', '', 'Date effective de fin de prise', 'date effective de fin de prise', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescriptionDatePriseFin', '', 'Date de fin de prise', 'date de fin de prise', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescriptionDatePriseDebut', '', 'Date de début de prise', 'date de début de prise', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescriptionIsChronique', '', 'isChronique', 'ligne TT chronique ou non', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescriptionIsALD', '', 'isALD', 'ligne ALD ou non', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescriptionDatePriseFinAvecRenouv', '', 'Date de fin de prise renouvellements inclus', 'date de fin de prise renouvellements inclus', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescriptionRenouvelle', '', 'ID de la ligne qui est renouvelée par cette ligne', 'ID de la ligne qui est renouvelée par cette ligne', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='lapCatPorteurs');
INSERT IGNORE INTO `data_types` (`groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('ordo', 'lapLigneMedicament', '', 'Médicament', 'médicament LAP', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapLignePrescription', '', 'Ligne de prescription', 'ligne de prescription LAP', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapOrdonnance', '', 'Ordonnance', 'ordonnance LAP', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 1),
('ordo', 'lapSam', '', 'SAM', 'porteur SAM LAP', '', '', '', '', 'base', @catID, 1, '2018-01-01 00:00:00', 1576800000, 1);

SET @catID = (SELECT data_cat.id FROM data_cat WHERE data_cat.name='catModelesCourriers');
INSERT IGNORE INTO `data_types`( `groupe`, `name`, `placeholder`, `label`, `description`, `validationRules`, `validationErrorMsg`, `formType`, `formValues`, `module`, `cat`, `fromID`, `creationDate`, `durationLife`, `displayOrder`) VALUES
('courrier', 'modeleCourrierTtEnCours', '', 'Traitement en cours', 'modèle de courrier pour l\'impression du traitement en cours', '', '', '', 'courrier-ttEnCours', 'base', @catID, 1, '2018-01-01 00:00:00', 3600, 6);

SET @catID = (SELECT forms_cat.id FROM forms_cat WHERE forms_cat.name='formCS');
INSERT IGNORE INTO `forms` ( `module`, `internalName`, `name`, `description`, `dataset`, `groupe`, `formMethod`, `formAction`, `cat`, `type`, `yamlStructure`, `yamlStructureDefaut`, `printModel`) VALUES
('base', 'aldDeclaration', 'Déclaration d\'ALD', 'formulaire d\'enregistrement d\'une ALD', 'data_types', 'medical', 'post', '/patient/actions/saveCsForm/', @catID, 'public', 'structure:\r\n  row1:\r\n    head: Enregistrement d\'une prise en charge en ALD\r\n  row2:\r\n    col1:\r\n     size: 12\r\n     bloc:\r\n       - aldNumber                                 		#878  ALD\n  row3:\r\n    col1:\r\n     size: 4\r\n     bloc:\r\n       - aldDateDebutPriseEnCharge                 		#879  Début de prise en charge\n    col2:\r\n      size: 4\r\n      bloc:\r\n       - aldDateFinPriseEnCharge                   		#880  Fin de prise en charge\n  row4:\r\n    col1:\r\n     size: 2\r\n     bloc:\r\n       - aldCIM10,plus={<i class="fa fa-search"></i>} 		#881  Code CIM10 associé\n    col2:\r\n     size: 10\r\n     bloc:\r\n       - aldCIM10label,class=my-1,readonly                    		#883  Label CIM10 associé', NULL, ''),
('base', 'atcdStrucDeclaration', 'Déclaration d\'atcd structuré', 'ajout d\'antécédents structuré et codé CIM 10', 'data_types', 'medical', 'post', '/patient/actions/saveCsForm/', @catID, 'public', 'structure: \r\n  row1:\r\n   head : Ajout d\'un antécédent à partir de la classification CIM 10\r\n  row2:\r\n   col1: \r\n     size: 2\r\n     bloc:\r\n       - atcdStrucCIM10,plus={<i class="fa fa-search"></i>} 		#884  Code CIM 10\n   col2: \r\n     size: 10\r\n     bloc:\r\n       - atcdStrucCIM10Label,class=my-1,readonly              		#885  Label CIM 10\n  row3:\r\n    head: "Début"                  		\r\n    col1: \r\n     size: 1\r\n     bloc:\r\n       - atcdStrucDateDebutJour                    		#886  Jour\n    col2: \r\n     size: 2\r\n     bloc:\r\n       - atcdStrucDateDebutMois                    		#888  Mois\n    col3: \r\n     size: 2\r\n     bloc:\r\n       - atcdStrucDateDebutAnnee,min=1910,step=1   		#890  Année\n  row4:\r\n    head: "Fin"\r\n    col1: \r\n     size: 1\r\n     bloc:\r\n       - atcdStrucDateFinJour                      		#887  Jour\n    col2: \r\n     size: 2\r\n     bloc:\r\n       - atcdStrucDateFinMois                      		#889  Mois\n    col3: \r\n     size: 2\r\n     bloc:\r\n       - atcdStrucDateFinAnnee,min=1910,step=1     		#891  Année\n  row5:\r\n    head: "Notes"\r\n    col1: \r\n     size: 12\r\n     bloc:\r\n       - atcdStrucNotes,nolabel                    		#893  Notes', NULL, '');

SET @catID = (SELECT forms_cat.id FROM forms_cat WHERE forms_cat.name='systemForm');
INSERT IGNORE INTO `forms` (`module`, `internalName`, `name`, `description`, `dataset`, `groupe`, `formMethod`, `formAction`, `cat`, `type`, `yamlStructure`, `yamlStructureDefaut`, `printModel`) VALUES
('base', 'baseReglementS1', 'Règlement conventionné S1', 'Formulaire pour le règlement d\'honoraires conventionnés secteur 1', 'data_types', 'reglement', 'post', '/patient/ajax/saveReglementForm/', 5, 'public', 'structure:\r\n row1:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleSituationPatient,class=regleSituationPatient                      		#197  Situation du patient\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleTarifSSCejour,required,readonly,plus={€},class=regleTarifCejour       		#198  Tarif SS\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleDepaCejour,plus={€},class=regleDepaCejour                 		#200  Dépassement\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleTiersPayeur,plus={€},class=regleTiersPayeur                		#202  Tiers\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur', 'structure:\r\n row1:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleSituationPatient,class=regleSituationPatient                      		#197  Situation du patient\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleTarifSSCejour,required,readonly,plus={€},class=regleTarifCejour       		#198  Tarif SS\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleDepaCejour,plus={€},class=regleDepaCejour                 		#200  Dépassement\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleTiersPayeur,plus={€},class=regleTiersPayeur                		#202  Tiers\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur', ''),
('base', 'baseReglementLibre', 'Formulaire règlement', 'formulaire pour le règlement d\'honoraires libres', 'data_types', 'reglement', 'post', '/patient/ajax/saveReglementForm/', @catID, 'public', 'structure:\r\n row1:\r\n  col1: \r\n    size: 4\r\n    bloc: \r\n      - regleTarifLibreCejour,readonly,plus={€},class=regleTarifCejour  		#199  Tarif\n  col2: \r\n    size: 4\r\n    bloc: \r\n      - regleModulCejour,plus={€},class=regleDepaCejour                 		#201  Dépassement\n  col3: \r\n    size: 4\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 4\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 4\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 4\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur', 'structure:\r\n row1:\r\n  col1: \r\n    size: 4\r\n    bloc: \r\n      - regleTarifLibreCejour,readonly,plus={€},class=regleTarifCejour  		#199  Tarif\n  col2: \r\n    size: 4\r\n    bloc: \r\n      - regleModulCejour,plus={€},class=regleDepaCejour                 		#201  Dépassement\n  col3: \r\n    size: 4\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 4\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 4\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 4\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur', '');

UPDATE `forms` SET `internalName`='baseReglementS2', `name`='Règlement conventionné S2', `description`='Formulaire pour le règlement d\'honoraires conventionnés secteur 2', `yamlStructure`='structure:\r\n row1:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleSituationPatient,class=regleSituationPatient                      		#197  Situation du patient\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleTarifSSCejour,required,readonly,plus={€},class=regleTarifCejour       		#198  Tarif SS\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleDepaCejour,plus={€},class=regleDepaCejour                 		#200  Dépassement\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleTiersPayeur,plus={€},class=regleTiersPayeur                		#202  Tiers\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur', `yamlStructureDefaut`='structure:\r\n row1:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleSituationPatient,class=regleSituationPatient                      		#197  Situation du patient\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleTarifSSCejour,required,readonly,plus={€},class=regleTarifCejour       		#198  Tarif SS\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleDepaCejour,plus={€},class=regleDepaCejour                 		#200  Dépassement\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleTiersPayeur,plus={€},class=regleTiersPayeur                		#202  Tiers\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur' WHERE `internalName`='baseReglement';

UPDATE `forms` SET `yamlStructure`='structure:\r\n  row1:                              \r\n    col1:                              \r\n      head: \'Etat civil\'             \r\n      size: 4\r\n      bloc:                          \r\n        - administrativeGenderCode                 		#14   Sexe\n        - birthname,required,autocomplete,data-acTypeID=2:1 		#1    Nom de naissance\n        - lastname,autocomplete,data-acTypeID=2:1  		#2    Nom d usage\n        - firstname,required,autocomplete,data-acTypeID=3:22:230:235:241 		#3    Prénom\n        - birthdate,class=pick-year               		#8    Date de naissance\n    col2:\r\n      head: \'Contact\'\r\n      size: 4\r\n      bloc:\r\n        - personalEmail                            		#4    Email personnelle\n        - mobilePhone                              		#7    Téléphone mobile\n        - homePhone                                		#10   Téléphone domicile\n    col3:\r\n      head: \'Adresse personnelle\'\r\n      size: 4\r\n      bloc: \r\n        - streetNumber                             		#9    Numéro\n        - street,autocomplete,data-acTypeID=11:55  		#11   Rue\n        - postalCodePerso                          		#13   Code postal\n        - city,autocomplete,data-acTypeID=12:56    		#12   Ville\n        - deathdate                                		#508  Date de décès\n  row2:\r\n    col1:\r\n      size: 12\r\n      bloc:\r\n        - notes,rows=5                             		#21   Notes', `yamlStructureDefaut`='structure:\r\n  row1:                              \r\n    col1:                              \r\n      head: \'Etat civil\'             \r\n      size: 4\r\n      bloc:                          \r\n        - administrativeGenderCode                 		#14   Sexe\n        - birthname,required,autocomplete,data-acTypeID=2:1 		#1    Nom de naissance\n        - lastname,autocomplete,data-acTypeID=2:1  		#2    Nom d usage\n        - firstname,required,autocomplete,data-acTypeID=3:22:230:235:241 		#3    Prénom\n        - birthdate,class=pick-year               		#8    Date de naissance\n    col2:\r\n      head: \'Contact\'\r\n      size: 4\r\n      bloc:\r\n        - personalEmail                            		#4    Email personnelle\n        - mobilePhone                              		#7    Téléphone mobile\n        - homePhone                                		#10   Téléphone domicile\n    col3:\r\n      head: \'Adresse personnelle\'\r\n      size: 4\r\n      bloc: \r\n        - streetNumber                             		#9    Numéro\n        - street,autocomplete,data-acTypeID=11:55  		#11   Rue\n        - postalCodePerso                          		#13   Code postal\n        - city,autocomplete,data-acTypeID=12:56    		#12   Ville\n        - deathdate                                		#508  Date de décès\n  row2:\r\n    col1:\r\n      size: 12\r\n      bloc:\r\n        - notes,rows=5                             		#21   Notes' WHERE `internalName`='baseNewPatient';

UPDATE `forms` SET `yamlStructure`='col1:\r\n    head: "Date de naissance" \r\n    bloc: \r\n        - birthdate                                		#8    Date de naissance\ncol2:\r\n    head: "Tel" \r\n    blocseparator: " - "\r\n    bloc: \r\n        - mobilePhone                              		#7    Téléphone mobile\n        - homePhone                                		#10   Téléphone domicile\ncol3:\r\n    head: "Email"\r\n    bloc:\r\n        - personalEmail                            		#4    Email personnelle\ncol4:\r\n    head: "Ville"\r\n    bloc:\r\n        - city,text-uppercase                      		#12   Ville', `yamlStructureDefaut`='col1:\r\n    head: "Date de naissance" \r\n    bloc: \r\n        - birthdate                                		#8    Date de naissance\ncol2:\r\n    head: "Tel" \r\n    blocseparator: " - "\r\n    bloc: \r\n        - mobilePhone                              		#7    Téléphone mobile\n        - homePhone                                		#10   Téléphone domicile\ncol3:\r\n    head: "Email"\r\n    bloc:\r\n        - personalEmail                            		#4    Email personnelle\ncol4:\r\n    head: "Ville"\r\n    bloc:\r\n        - city,text-uppercase                      		#12   Ville' WHERE `internalName`='baseListingPatients';

UPDATE `forms` SET `yamlStructure`='structure:\r\n row1:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleSituationPatient,class=regleSituationPatient                      		#197  Situation du patient\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleTarifCejour,required,readonly,plus={€},class=regleTarifCejour       		#198  Tarif SS\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleDepaCejour,plus={€},class=regleDepaCejour                 		#199  Dépassement\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleTiersPayeur,plus={€},class=regleTiersPayeur                		#200  Tiers\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur', `yamlStructureDefaut`='structure:\r\n row1:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleSituationPatient,class=regleSituationPatient                      		#197  Situation du patient\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleTarifCejour,required,readonly,plus={€},class=regleTarifCejour       		#198  Tarif SS\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleDepaCejour,plus={€},class=regleDepaCejour                 		#199  Dépassement\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleFacture,readonly,plus={€},class=regleFacture           		#196  Facturé\n row2:\r\n  col1: \r\n    size: 3\r\n    bloc: \r\n      - regleCB,plus={€},class=regleCB                         		#194  CB\n  col2: \r\n    size: 3\r\n    bloc: \r\n      - regleCheque,plus={€},class=regleCheque                     		#193  Chèque\n  col3: \r\n    size: 3\r\n    bloc: \r\n      - regleEspeces,plus={€},class=regleEspeces                    		#195  Espèces\n  col4: \r\n    size: 3\r\n    bloc: \r\n      - regleTiersPayeur,plus={€},class=regleTiersPayeur                		#200  Tiers\n row3:\r\n  col1: \r\n    size: 6\r\n    bloc: \r\n      - regleIdentiteCheque,class=regleIdentiteCheque                        		#205  Identité payeur' WHERE internalName='baseReglement';

UPDATE `forms` SET `yamlStructure`='col1:\r\n    head: "Activité pro" \r\n    bloc: \r\n        - job                                      		#19   Activité professionnelle\ncol2:\r\n    head: "Tel" \r\n    bloc: \r\n        - telPro                                   		#57   Téléphone professionnel\ncol3:\r\n    head: "Fax" \r\n    bloc: \r\n        - faxPro                                   		#58   Fax professionnel\ncol4:\r\n    head: "Email"\r\n    bloc-separator: " - "\r\n    bloc:\r\n        - emailApicrypt                            		#59   Email apicrypt\n        - personalEmail                            		#4    Email personnelle\ncol5:\r\n    head: "Ville"\r\n    bloc:\r\n        - villeAdressePro,text-uppercase           		#56   Ville', `yamlStructureDefaut`='col1:\r\n    head: "Activité pro" \r\n    bloc: \r\n        - job                                      		#19   Activité professionnelle\ncol2:\r\n    head: "Tel" \r\n    bloc: \r\n        - telPro                                   		#57   Téléphone professionnel\ncol3:\r\n    head: "Fax" \r\n    bloc: \r\n        - faxPro                                   		#58   Fax professionnel\ncol4:\r\n    head: "Email"\r\n    bloc-separator: " - "\r\n    bloc:\r\n        - emailApicrypt                            		#59   Email apicrypt\n        - personalEmail                            		#4    Email personnelle\ncol5:\r\n    head: "Ville"\r\n    bloc:\r\n        - villeAdressePro,text-uppercase           		#56   Ville' WHERE `internalName`='baseListingPro';

UPDATE `forms` SET `yamlStructure`='structure:\r\n  row1: \r\n    col1: \r\n      size: 12 col-12 col-sm-4 col-lg-4\r\n      bloc: \r\n        - poids,plus={<i class="fa fa-clone duplicate"></i>} #34   Poids\r\n    col2: \r\n      size: 12 col-12 col-sm-4 col-lg-4\r\n      bloc: \r\n       - taillePatient,plus={<i class="fa fa-clone duplicate"></i>} #35   Taille\r\n    col3: \r\n      size: 12 col-12 col-sm-4 col-lg-4\r\n      bloc: \r\n       - imc,readonly #43   IMC\r\n  row2: \r\n   col1: \r\n     size: 12\r\n     bloc: \r\n       - job                                       		#19   Activité professionnelle\r\n       - allergies,rows=2                          		#66   Allergies\r\n       - toxiques                                  		#42   Toxiques\r\n  row3: \r\n    col1: \r\n     size: 12\r\n     bloc: \r\n       - atcdMedicChir,rows=6                      		#41   Antécédents médico-chirurgicaux\r\n       - atcdFamiliaux,rows=6                      		#38   Antécédents familiaux', `yamlStructureDefaut`='structure:\r\n  row1: \r\n    col1: \r\n      size: 12 col-12 col-sm-4 col-lg-4\r\n      bloc: \r\n        - poids,plus={<i class="fa fa-clone duplicate"></i>} #34   Poids\r\n    col2: \r\n      size: 12 col-12 col-sm-4 col-lg-4\r\n      bloc: \r\n       - taillePatient,plus={<i class="fa fa-clone duplicate"></i>} #35   Taille\r\n    col3: \r\n      size: 12 col-12 col-sm-4 col-lg-4\r\n      bloc: \r\n       - imc,readonly #43   IMC\r\n  row2: \r\n   col1: \r\n     size: 12\r\n     bloc: \r\n       - job                                       		#19   Activité professionnelle\r\n       - allergies,rows=2                          		#66   Allergies\r\n       - toxiques                                  		#42   Toxiques\r\n  row3: \r\n    col1: \r\n     size: 12\r\n     bloc: \r\n       - atcdMedicChir,rows=6                      		#41   Antécédents médico-chirurgicaux\r\n       - atcdFamiliaux,rows=6                      		#38   Antécédents familiaux' WHERE `internalName`='baseATCD';

UPDATE `forms` SET `yamlStructure`='global:\r\n  formClass: \'form-signin\' \r\nstructure:\r\n row1:\r\n  col1: \r\n    size: 12\r\n    bloc: \r\n      - username,required,nolabel                            		#1    Identifiant\n      - password,required,nolabel                          		#2    Mot de passe\n      - submit,Connexion,class=btn-primary,class=btn-block                                     		#3    Valider', `yamlStructureDefaut`='global:\r\n  formClass: \'form-signin\' \r\nstructure:\r\n row1:\r\n  col1: \r\n    size: 12\r\n    bloc: \r\n      - username,required,nolabel                            		#1    Identifiant\n      - password,required,nolabel                          		#2    Mot de passe\n      - submit,Connexion,class=btn-primary,class=btn-block                                     		#3    Valider' WHERE `internalName`='baseLogin';

UPDATE `forms` SET `formAction`='/user/ajax/userParametersClicRdv/', `yamlStructure`='global:\n  formClass:\'ajaxForm\'\nstructure:\n row1:\n  col1: \n    head: "Compte clicRDV"\n    size: 3\n    bloc:\n      - clicRdvUserId\n      - clicRdvPassword\n      - clicRdvGroupId\n      - clicRdvCalId\n      - clicRdvConsultId,nolabel', `yamlStructureDefaut`='global:\n  formClass:\'ajaxForm\'\nstructure:\n row1:\n  col1: \n    head: "Compte clicRDV"\n    size: 3\n    bloc:\n      - clicRdvUserId\n      - clicRdvPassword\n      - clicRdvGroupId\n      - clicRdvCalId\n      - clicRdvConsultId,nolabel' WHERE `internalName`='baseUserParametersClicRdv';

INSERT IGNORE INTO `forms` (`module`, `internalName`, `name`, `description`, `dataset`, `groupe`, `formMethod`, `formAction`, `cat`, `type`, `yamlStructure`, `yamlStructureDefaut`, `printModel`) VALUES
('base', 'baseModalNewPatient', 'Formulaire nouveau patient pour modal', 'formulaire d\'enregistrement d\'un nouveau patient dans fenêtre modale', 'data_types', 'admin', 'post', '', 1, 'public', 'structure:\r\n  row1:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 12\r\n      bloc:                          \r\n        - administrativeGenderCode,nolabel      		#14   Sexe\r\n  row2:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 6\r\n      bloc:                          \r\n        - birthname,required,nolabel,autocomplete,data-acTypeID=2:1 #1    Nom de naissance\r\n    col2:\r\n      size: 6\r\n      bloc:                          \r\n        - lastname,nolabel,autocomplete,data-acTypeID=2:1  		#2    Nom d usage\r\n  row3:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 12\r\n      bloc:                          \r\n        - firstname,nolabel,required,autocomplete,data-acTypeID=3:22:230:235:241 		#3    Prénom\r\n        - birthdate,nolabel,required,class=pick-years                   		#8    Date de naissance\r\n        - personalEmail,nolabel,class=updatable             		#4    Email personnelle\r\n  row4:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 6\r\n      bloc:                          \r\n        - mobilePhone,nolabel,class=updatable               		#7    Téléphone mobile\r\n    col2:\r\n      size: 6\r\n      bloc:                          \r\n        - homePhone,nolabel,class=updatable                 		#10   Téléphone domicile\r\n\r\n  row5:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 4\r\n      bloc: \r\n        - streetNumber,nolabel,class=updatable              		#9    Numéro\r\n        - postalCodePerso,nolabel,class=updatable           		#13   Code postal\r\n    col2:\r\n      size: 8\r\n      bloc: \r\n        - street,nolabel,autocomplete,data-acTypeID=11:55,class=updatable #11   Rue\r\n        - city,nolabel,autocomplete,data-acTypeID=12:56,class=updatable #12   Ville\r\n  row6:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 12\r\n      bloc:\r\n        - notes,nolabel,rows=5,class=updatable             		#21   Notes', 'structure:\r\n  row1:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 12\r\n      bloc:                          \r\n        - administrativeGenderCode,nolabel      		#14   Sexe\r\n  row2:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 6\r\n      bloc:                          \r\n        - birthname,required,nolabel,autocomplete,data-acTypeID=2:1 #1    Nom de naissance\r\n    col2:\r\n      size: 6\r\n      bloc:                          \r\n        - lastname,nolabel,autocomplete,data-acTypeID=2:1  		#2    Nom d usage\r\n  row3:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 12\r\n      bloc:                          \r\n        - firstname,nolabel,required,autocomplete,data-acTypeID=3:22:230:235:241 		#3    Prénom\r\n        - birthdate,nolabel,required,class=pick-years                   		#8    Date de naissance\r\n        - personalEmail,nolabel,class=updatable             		#4    Email personnelle\r\n  row4:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 6\r\n      bloc:                          \r\n        - mobilePhone,nolabel,class=updatable               		#7    Téléphone mobile\r\n    col2:\r\n      size: 6\r\n      bloc:                          \r\n        - homePhone,nolabel,class=updatable                 		#10   Téléphone domicile\r\n\r\n  row5:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 4\r\n      bloc: \r\n        - streetNumber,nolabel,class=updatable              		#9    Numéro\r\n        - postalCodePerso,nolabel,class=updatable           		#13   Code postal\r\n    col2:\r\n      size: 8\r\n      bloc: \r\n        - street,nolabel,autocomplete,data-acTypeID=11:55,class=updatable #11   Rue\r\n        - city,nolabel,autocomplete,data-acTypeID=12:56,class=updatable #12   Ville\r\n  row6:\r\n    class: \'my-0\'\r\n    col1:\r\n      size: 12\r\n      bloc:\r\n        - notes,nolabel,rows=5,class=updatable             		#21   Notes', '');

UPDATE `system` SET `value`='v4.0.0' WHERE `name`='base' and `groupe`='module';
INSERT IGNORE INTO `system` (`name`, `groupe`,`value`) VALUES
('state', 'system', 'normal');

CREATE TABLE IF NOT EXISTS `configuration` (
  `id` smallint(4) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `name` varchar(60) NOT NULL,
  `level` enum('default', 'module', 'user') DEFAULT 'default',
  `toID` int(11) UNSIGNED NOT NULL DEFAULT '0',
  `module` varchar(20) NOT NULL DEFAULT '',
  `cat` varchar(30) DEFAULT NULL,
  `type` varchar(30) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `value` text DEFAULT NULL,
  UNIQUE KEY `nameLevel` (`name`,`level`,`module`,`toID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT IGNORE INTO `configuration`(`name`, `cat`, `level`, `type`, `description`, `value`) VALUES
('PraticienPeutEtrePatient', 'Options', 'default', 'true/false', 'si false, le praticien peut toujours avoir une fiche patient séparée', 'true'),
('VoirRouletteObstetricale', 'Options', 'default', 'true/false', 'activer le lien roulette obstétricale du menu Outils', 'true'),
('administratifSecteurHonoraires', 'Options', 'default', 'vide/1/2', 'vide pour non conventionné', '1'),
('administratifPeutAvoirFacturesTypes', 'Options', 'default', 'true/false', 'peut avoir des factures types à son nom', 'false'),
('administratifPeutAvoirPrescriptionsTypes', 'Options', 'default', 'true/false', 'peut avoir des prescriptions types à son nom', 'false'),
('administratifPeutAvoirAgenda', 'Options', 'default', 'true/false', 'peut avoir un agenda à son nom', 'true'),
('administratifPeutAvoirRecettes', 'Options', 'default', 'true/false', 'peut enregistrer des recettes à son nom', 'true'),
('administratifComptaPeutVoirRecettesDe', 'Options', 'default', 'liste', 'ID des utilisateurs, séparés par des virgules (sans espace)', ''),
('templatesPdfFolder', 'Modèles de documents', 'default', 'dossier', 'répertoire des fichiers de template pour la génération de PDF', ''),
('templateDefautPage', 'Modèles de documents', 'default', 'fichier', 'template par défaut pour l\'impression', 'base-page-headAndFoot.html.twig'),
('templateOrdoHeadAndFoot', 'Modèles de documents', 'default', 'fichier', 'template pour header et footer des ordonnances standards (non ALD)', 'base-page-headAndFoot.html.twig'),
('templateOrdoBody', 'Modèles de documents', 'default', 'fichier', 'template pour le corps des ordonnances standards', 'ordonnanceBody.html.twig'),
('templateOrdoALD', 'Modèles de documents', 'default', 'fichier', 'template (complet) pour les ordonnances bizones ALD', 'ordonnanceALD.html.twig'),
('templateCrHeadAndFoot', 'Modèles de documents', 'default', 'fichier', 'template pour les compte-rendus', 'base-page-headAndNoFoot.html.twig'),
('templateCourrierHeadAndFoot', 'Modèles de documents', 'default', 'fichier', 'template pour les courriers', 'base-page-headAndNoFoot.html.twig'),
('smtpTracking', 'Mail', 'default', 'texte', 'permet d\'activer le tracking des mails envoyés via un service tiers', ''),
('smtpFrom', 'Mail', 'default', 'email', 'adresse de l’expéditeur des messages, ex: user@domain.net', ''),
('smtpFromName', 'Mail', 'default', 'texte', 'nom en clair de l\'expéditeur des messages', ''),
('smtpHost', 'Mail', 'default', 'url/ip', 'serveur SMTP', ''),
('smtpPort', 'Mail', 'default', 'nombre', 'port du serveur SMTP', '587'),
('smtpSecureType', 'Mail', 'default', 'texte', 'protocole ssl ou tls (ou rien)', 'tls'),
('smtpOptions', 'Mail', 'default', 'texte', 'options pour désactiver quelques options de sécurités', 'off'),
('smtpUsername', 'Mail', 'default', 'texte', 'login pour le serveur SMTP', ''),
('smtpPassword', 'Mail', 'default', 'texte', 'mot de passe pour le serveur SMTP', ''),
('smtpDefautSujet', 'Mail', 'default', 'texte', 'titre par défaut du mail expédié', 'Document vous concernant'),
('apicryptCheminInbox', 'Apicrypt', 'default', 'dossier', 'chemin du répertoire qui sert de boite de réception, doit être en zone accessible web', ''),
('apicryptCheminArchivesInbox', 'Apicrypt', 'default', 'dossier', 'chemin du répertoire qui sert à archiver par date de traitement les messages reçus, classés dans les dossiers comme non classés', ''),
('apicryptCheminFichierNC', 'Apicrypt', 'default', 'dossier', 'répertoire de travail pour Apicrypt, fichier non chiffrés', ''),
('apicryptCheminFichierC', 'Apicrypt', 'default', 'dossier', 'répertoire de travail apicrypt, fichiers chiffrés', ''),
('apicryptCheminVersClefs', 'Apicrypt', 'default', 'dossier', 'chemin vers les répertoire Clefs Apicrypt contenant les clefs de l’utilisateur', ''),
('apicryptCheminVersBinaires', 'Apicrypt', 'default', 'dossier', 'chemin vers le répertoire contenant les programmes Apicrypt en ligne de commande', ''),
('apicryptInboxMailForUserID', 'Apicrypt', 'default', 'nombre', 'ID numérique qui indique pour l\'utilisateur quels mails il est susceptible de pouvoir lire', '0'),
('apicryptUtilisateur', 'Apicrypt', 'default', 'texte', 'nom d\'utilisateur Apicrypt (portion devant le @ de l\'adresse)', ''),
('apicryptAdresse', 'Apicrypt', 'default', 'texte', 'adresse complète apicrypt, ex :  prenom.NOM@medicalXX.apicrypt.org', ''),
('apicryptSmtpHost', 'Apicrypt', 'default', 'url/ip', 'serveur smtp pour l\'envoi des messages Apicrypt, en règle générale : smtp.intermedic.org', 'smtp.intermedic.org'),
('apicryptSmtpPort', 'Apicrypt', 'default', 'nombre', 'port du serveur SMTP', '25'),
('apicryptPopHost', 'Apicrypt', 'default', 'url/ip', 'serveur pop pour la réception des messages Apicrypt', 'pop.intermedic.org'),
('apicryptPopPort', 'Apicrypt', 'default', 'nombre', 'port du serveur pop', '110'),
('apicryptPopUser', 'Apicrypt', 'default', 'texte', 'nom d\'utilisateur pour le serveur pop : prenom.NOM', ''),
('apicryptPopPassword', 'Apicrypt', 'default', 'texte', 'mot de passe apicrypt', ''),
('apicryptDefautSujet', 'Apicrypt', 'default', 'texte', 'sujet par défaut des mails Apicrypt (attention, n\'est pas chiffré : jamais d\'éléments d\'identité dans le sujet !)', 'Document concernant votre patient'),
('faxService', 'Fax', 'default', 'vide/ecofaxOVH', 'si non vide, active le service tiers concerné', ''),
('ecofaxMyNumber', 'Fax', 'default', 'n° fax', 'numéro du fax en réception, ex: 0900000000', ''),
('ecofaxPassword', 'Fax', 'default', 'texte', 'mot de passe du service de fax', ''),
('dicomHost', 'DICOM', 'default', 'url/ip', 'IP du serveur Orthanc', ''),
('dicomPrefixIdPatient', 'DICOM', 'default', 'texte', 'prefix à appliquer à l\'identifiant numérique MedShakeEHR pour en faire un identifiant DICOM unique', '1.100.100'),
('dicomAutoSendPatient', 'DICOM', 'default', 'true/false', 'générer automatiquement le fichier worklist pour Orthanc à l\'ouverture d’un dossier patient. Ne pas mettre à true pour une secrétaire par exemple !', 'false'),
('dicomDiscoverNewTags', 'DICOM', 'default', 'true/false', 'enregistrer automatiquement dans la base de données les nouveaux tags dicom rencontrés lors de la visualisation d\'études afin de pouvoir les associer par la suite automatiquement avec des données de formulaire MedShakeEHR', 'true'),
('dicomWorkListDirectory', 'DICOM', 'default', 'dossier', 'chemin du répertoire où Orthanc va récupérer le fichier dicom worklist généré par MedShakeEHR pour le passer à l\'appareil d\'imagerie', ''),
('dicomWorkingDirectory', 'DICOM', 'default', 'dossier', 'répertoire de travail local où on peut rapatrier des images à partir d\'Orthanc pour les parcourir ou les traiter (pdf, zip ...). Utiliser en général le même répertoire que celui indiqué dans workingDirectory des paramètres généraux. Doit être en zone web accessible', ''),
('phonecaptureFingerprint', 'Phonecapture', 'default', 'texte', 'chaîne aléatoire permettant une sécurisation de l\'identification des périphériques PhoneCapture', 'phonecapture'),
('phonecaptureCookieDuration', 'Phonecapture', 'default', 'nombre', 'durée de vie d\'identification d\'un périphérique pour PhoneCapture', '31104000'),
('phonecaptureResolutionWidth', 'Phonecapture', 'default', 'nombre', 'résolution des photos, largeur', '1920'),
('phonecaptureResolutionHeight', 'Phonecapture', 'default', 'nombre', ' résolution des photos, hauteur', '1080'),
('agendaService', 'Agenda', 'default', 'vide/clicRDV', 'si non vide, active le service tiers concerné', ''),
('agendaPremierJour', 'Agenda', 'default', 'vide/nombre', 'vide pour roulant, 0 pour dimanche, 1 pour lundi, etc...', '1'),
('agendaDistantLink', 'Agenda', 'default', 'url', 'lien à appliquer à Agenda sur les pages MedShakeEHR. Si agendaService est configuré, alors agendaDistantLink doit être vide', ''),
('agendaDistantPatientsOfTheDay', 'Agenda', 'default', 'url', 'url distante où l’on peut récupérer une liste horodatée des patients du jour', ''),
('agendaLocalPatientsOfTheDay', 'Agenda', 'default', 'fichier', 'fichier json de la liste horodatée des patients du jour', 'patientsOfTheDay.json'),
('agendaNumberForPatientsOfTheDay', 'Agenda', 'default', 'nombre', 'Numéro d\'agenda pour générer à partir de l\'agenda interne concerné une liste des patients du jour pour le menu Patients', '0'),
('agendaModePanneauLateral', 'Agenda', 'default', 'true/false', 'Utilisation du panneau latéral (true) ou d\'une fenêtre contextuelle (false)', 'true'),
('mailRappelActiver', 'Rappels mail', 'default', 'true/false', 'activer / désactiver les rappels par mail', 'false'),
('mailRappelLogCampaignDirectory', 'Rappels mail', 'default', 'dossier', 'chemin du répertoire où on va loguer les rappels de rendez-vous par mail', ''),
('mailRappelDaysBeforeRDV', 'Rappels mail', 'default', 'nombre', 'nombre de jours avant le rendez-vous pour l\'expédition du rappel', '3'),
('mailRappelMessage', 'Rappels mail', 'default', 'textarea', 'Les balises #heureRdv, #jourRdv et #praticien seront automatiquement remplacées dans le message envoyé', 'Bonjour,\n\nNous vous rappelons votre RDV du #jourRdv à #heureRdv avec le Dr #praticien.\nNotez bien qu\’aucun autre rendez-vous ne sera donné à un patient n\’ayant pas honoré le premier.\n\nMerci de votre confiance,\nÀ bientôt !\n\nP.S. : Ceci est un mail automatique, merci de ne pas répondre.'),
('smsRappelActiver', 'Rappels SMS', 'default', 'true/false', 'activer / désactiver les rappels par SMS', 'false'),
('smsProvider', 'Rappels SMS', 'default', 'url/ip', 'active le service tiers concerné', ''),
('smsLogCampaignDirectory', 'Rappels SMS', 'default', 'dossier', 'chemin du répertoire où on va loguer les rappels de rendez-vous par SMS', ''),
('smsRappelMessage', 'Rappels SMS', 'default', 'textarea', 'Les balises #heureRdv, #jourRdv et #praticien seront automatiquement remplacées dans le message envoyé', 'Rappel: Vous avez rdv à #heureRdv le #jourRdv avec le Dr #praticien'),
('smsDaysBeforeRDV', 'Rappels SMS', 'default', 'nombre', 'nombre de jours avant le rendez-vous pour l\'expédition du rappel SMS', '3'),
('smsCreditsFile', 'Rappels SMS', 'default', 'fichier', 'nom du fichier qui contient le nombre de SMS restants', 'creditsSMS.txt'),
('smsSeuilCreditsAlerte', 'Rappels SMS', 'default', 'nombre', 'prévenir dans l\'interface du logiciel si crédit inférieur ou égale à', '150'),
('smsTpoa', 'Rappels SMS', 'default', 'texte', 'La balise #praticien sera automatiquement remplacée dans le message envoyé', 'Dr #praticien'),
('allMySmsLogin', 'Rappels SMS', 'default', 'texte', 'login allMySMS', ''),
('allMySmsApiKey', 'Rappels SMS', 'default', 'texte', 'API key allMySMS', ''),
('clicRdvApiKey', 'clicRDV', 'default', 'texte', '', ''),
('clicRdvUserId', 'clicRDV', 'default', 'texte', '', ''),
('clicRdvPassword', 'clicRDV', 'default', 'texte', '', ''),
('clicRdvGroupId', 'clicRDV', 'default', 'nombre', '', ''),
('clicRdvCalId', 'clicRDV', 'default', 'nombre', '', ''),
('clicRdvConsultId', 'clicRDV', 'default', 'JSON', '', ''),
('utiliserLap', 'LAP', 'default', 'true/false', 'activer / désactiver le LAP', 'true'),
('lapActiverAtcdStrucSur', 'LAP', 'default', 'texte', 'champs sur lesquels activer les atcd structurés', ''),
('lapActiverAllergiesStrucSur', 'LAP', 'default', 'texte','champs sur lesquels activer les Allergies structurées', ''),
('lapAtcdStrucPersoPourAnalyse', 'LAP', 'default', 'texte','champs sur lesquels analyser les atcd structurés', ''),
('lapAllergiesStrucPersoPourAnalyse', 'LAP', 'default', 'texte','champs sur lesquels analyser les Allergies structurées', ''),
('theriaqueMode', 'LAP', 'default', 'texte','Mode d\'utilisation de Thériaque : WS (webservice) ou PG (base postgre en local)', ''),
('theriaqueWsURL', 'LAP', 'default', 'texte','url du webservice Thériaque', ''),
('theriaqueShowMedicHospi', 'LAP', 'default', 'true/false', 'voir les médicaments hospitaliers', 'true'),
('theriaqueShowMedicNonComer', 'LAP', 'default', 'true/false', 'voir les médicaments non commercialisés', 'false'),
('lapAlertPatientTermeGrossesseSup46', 'LAP', 'default', 'true/false', 'alerte pour terme sup à 46SA à l\'entrée dans le LAP', 'true'),
('lapAlertPatientAllaitementSup3Ans', 'LAP', 'default', 'true/false', 'alerte pour allaitement sup à 3 ans à l\'entrée dans le LAP', 'true'),
('lapSearchResultsSortBy', 'LAP', 'default', 'texte', 'ordre préférentiel d\'affichage des médicaments', 'nom'),
('lapSearchDefaultType', 'LAP', 'default', 'texte', 'mode de recherche par défaut des médicaments', 'dci'),
('lapPrintAllergyRisk', 'LAP', 'default', 'true/false', 'imprimer les risques allergiques détectés', 'true');

INSERT IGNORE INTO configuration (`name`, `level`, `toID`, `value`)
SELECT dt.name, 'user', od.toID, od.value FROM objets_data AS od
LEFT JOIN data_types AS dt ON dt.id=od.typeID
WHERE od.deleted='' and od.outdated='' and dt.groupe='user';
