<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000605" 
	label="PMSI. Chirurgie bariatrique" 
	title="= 'Chirurgie bariatrique. (CDC [CDC]) (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_pmsi"
	globals="PMSI_globals.XML"
	componentsFile="PMSI_components.XML">

	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
		<PROPERTY name="PERIODE_D">
			<value><![CDATA[[EVAL 
				
				switch ('[TYPE_COMPARAISON]') {
					case 'S' :
						return '[PERIODE_D]';
						break;
					case '2' : 
						return '[VIEW.WPERIODE_D]';
						break;
					case '3' : 
						return '[VIEW.WPERIODE_D]';
						break;
					default :
						return '0001-01-01';
				}
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="TOPERIODE_D">
			<value><![CDATA[[EVAL 
				
				switch ('[TYPE_COMPARAISON]') {
					case 'S' :
						return '[TOPERIODE_D]';
						break;
					case '2' : 
						return '[VIEW.WTOPERIODE_D]';
						break;
					case '3' : 
						return '[VIEW.WTOPERIODE_D]';
						break;
					default :
						return '0001-01-01';
				}
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="PERIODE_2D">
			<value><![CDATA[[EVAL 
				
				if ('[TYPE_COMPARAISON]' == '3') {
					return '[VIEW.WPERIODE_2D]';
				}
				else {
					return '0001-01-01';
				}
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="TOPERIODE_2D">
			<value><![CDATA[[EVAL 
				
				if ('[TYPE_COMPARAISON]' == '3') {
					return '[VIEW.WTOPERIODE_2D]';
				}
				else {
					return '0001-01-01';
				}
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="LAST_ANNEE">
			<value><![CDATA[[EVAL 

				$annee = substr('[TOPERIODE]',0,4);

				return $annee;
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="LAST_ANNEE_FORMAT_DEB">
			<value><![CDATA[[EVAL 

				$annee = substr('[TOPERIODE]',0,4);
				$annee_deb = $annee.'-01-01';
				return $annee_deb;
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="LAST_ANNEE_FORMAT_FIN">
			<value><![CDATA[[EVAL 

				$annee = substr('[TOPERIODE]',0,4);
				$annee_fin = $annee.'-12-31';
				return $annee_fin;
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="LAST_ANNEE_D">
			<value><![CDATA[[EVAL 

				$annee = intval(substr('[TOPERIODE]',0,4)) - 1;
				return $annee;
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="LAST_ANNEE_D_FORMAT_DEB">
			<value><![CDATA[[EVAL 

				$annee = intval(substr('[TOPERIODE]',0,4)) - 1;
				$annee_deb = $annee.'-01-01';
				return $annee_deb;
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="LAST_ANNEE_D_FORMAT_FIN">
			<value><![CDATA[[EVAL 

				$annee = intval(substr('[TOPERIODE]',0,4)) - 1;
				$annee_fin = $annee.'-12-31';
				return $annee_fin;
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="CHAMP_SELECT">
			<value><![CDATA[[EVAL 
				// <?php
						$toRet = "";
						switch ('[CHAMP]'){
							case 'EX' :
								$toRet =  " AND p_rss.en_cours = '0' ";
								break;
							case 'EXTR' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('21', '22', '23', '24', '25', '26', '30', '31', '32', '33') ";
								break;	
							case 'EXVA' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('30','31','32','33') ";
								break;
							case 'EXVA30' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('30') ";
								break;
							case 'EXVA3032' :
                                $select = " AND v_rss_1.en_cours = '0' AND p_rss.traitement_epmsi IN ('30','32') ";
                                break;
							case 'EXVA31' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('31') ";
								break;
							case 'EXVA32' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('32') ";
								break;
							case 'EXVA33' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('33') ";
								break;
							case 'EXNVA' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('21', '22', '23', '24', '25', '26') ";
								break;
							case 'EXNVA21' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '21' ";
								break;
							case 'EXNVA22' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '22' ";
								break;
							case 'EXNVA23' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '23' ";
								break;
							case 'EXNVA24' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '24' ";
								break;
							case 'EXNVA25' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '25' ";
								break;
							case 'EXNVA26' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '26' ";
								break;
							case 'EXNTR' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('11', '12', '13', '14', '15') ";
								break;
							case 'EXNTR11' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '11' ";
								break;
							case 'EXNTR12' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '12' ";
								break;
							case 'EXNTR13' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '13' ";
								break;
							case 'EXNTR14' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '14' ";
								break;
							case 'EXNTR15' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi = '15' ";
								break;
							case 'EXNTRNVA' :
								$toRet =  " AND p_rss.en_cours = '0' AND p_rss.traitement_epmsi IN ('11', '12', '13', '14', '15', '21', '22', '23', '24', '25', '26') ";
								break;
	
							case 'NEX' :
								$toRet =  " AND p_rss.en_cours <> '0' ";
								break;
							case 'NEXSO' :
								$toRet =  " AND p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('S') ";
								break;
							case 'NEXGR' :
								$toRet =  " AND p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('G','V','F') ";
								break;
							case 'NEXVA' :
								$toRet =  " AND p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('V','F') ";
								break;
							case 'NEXFA' :
								$toRet =  " AND p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('F') ";
								break;
							case 'NEXGRNFA' :
								$toRet =  " AND p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('G','V') ";
								break;
							case 'NEXNFA' :
								$toRet =  " AND p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('S','G','V') ";
								break;	
								
							
							case 'EXNEX' :
								break;
							case 'EXNEXSO' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('S')) ";
								break;
							case 'EXNEXGR' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('G','V','F')) ";
								break;
							case 'EXNEXVA' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('V','F')) ";
								break;
							case 'EXNEXFA' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('F')) ";
								break;
							case 'EXNEXGRNFA' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('G','V')) ";
								break;
							case 'EXNEXNFA' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours <> '0' AND p_rss.en_cours_etat IN ('S','G','V')) ";
								break;		
							
							// Anciens codes pour compatibilité
							case 'EXGR' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours_etat IN ('G', 'V')) ";
								break; 
							case 'EXGV' :
								$toRet =  " AND (p_rss.en_cours = '0' OR p_rss.en_cours_etat = 'V') ";
								break;
							case 'GR' :
								$toRet =  " AND p_rss.en_cours_etat IN ('G', 'V') ";
								break;
	
							
							default :
								$toRet =  "";
								break;
						}
						return $toRet ;
				// ?>
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Date sortie">
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2014-01-01" globalListProvider="DATE_DEBUT" printable="false" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" globalListProvider="DATE_FIN" printable="false" />
		</GROUP>
		<GROUP label="CDC">
			<FIELD name="CDC" label="" width="300" UI="combo" default="2022" tree="true">
				<OPTION label="2022" data="2022" treeLevel="1" />
			</FIELD>
		</GROUP>
		<GROUP label="Période précédente">
			<FIELD name="TYPE_COMPARAISON" width="250" UI="combo" default="S" printable="false">
				<OPTION label="Pas de comparaison" data="-1" />
				<OPTION label="Même période sur année précédente" data="2" />
				<OPTION label="Même période sur deux années précédentes" data="3" />
				<OPTION label="Saisie période" data="S" />
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="PERIODE_D" label=" " UI="combo" tree="true" width="200" default="2014-01-01" printable="false" globalListProvider="DATE_DEBUT" visible="= SELECT.TYPE_COMPARAISON == 'S'" />
			<FIELD name="TOPERIODE_D" label="à" UI="combo" tree="true" width="200" default="2014-12-31" printable="false" globalListProvider="DATE_FIN" visible="= SELECT.TYPE_COMPARAISON == 'S'" />
		</GROUP>
		<GROUP label="Champ">
			<FIELD name="CHAMP" label="" UI="combo" tree="true" width="400" default="EX" globalListProvider="CHAMP" showIfNotDefault="true"></FIELD>
		</GROUP>
	</SELECTIONS>
	<QUERIES>
		<QUERY label="Cahier des charges 2022"> 
			<SQL>
				<select><![CDATA[	
					
				DROP TABLE IF EXISTS w_etude_bariatrique_cdc
				;

				CREATE TEMP TABLE w_etude_bariatrique_cdc AS (
					SELECT 
						t_classes_sections.oid AS section_id,
						t_classes_sections.code AS section_code,
						t_classes_sections.texte AS section_texte,
						t_etude_bariatrique.seuil,
						t_classes_sections_elements.to_id AS acte_id,
						t_etude_bariatrique.liste_code
					FROM pmsi.t_etude_bariatrique 
					JOIN pmsi.t_classes ON t_classes.code = 'ETUDE_BARIATRIQUE_[CDC]'
					JOIN pmsi.t_classes_sections ON t_classes_sections.classe_id = t_classes.oid AND t_classes_sections.code = t_etude_bariatrique.section_code
					JOIN pmsi.t_classes_sections_elements ON t_classes_sections_elements.section_id = t_classes_sections.oid
					WHERE t_etude_bariatrique.cdc = [CDC]
				)
				;

				DROP TABLE IF EXISTS w_etude_bariatrique
				;

				CREATE TEMP TABLE w_etude_bariatrique AS 	
					SELECT 
						p_rss.date_sortie,
						p_rss_actes.rss_id,
						p_rss_actes.acte_id,
						p_rss_actes.nombre,
						t_actes.code AS acte_code,
						t_actes.texte_court AS acte_texte,
						p_rss.age AS age_patient,
						w_etude_bariatrique_cdc.section_id,
						w_etude_bariatrique_cdc.section_code,
						w_etude_bariatrique_cdc.section_texte,
						w_etude_bariatrique_cdc.seuil,
						t_finess.oid AS etablissement_id, 
						t_finess.code AS etablissement_code,
						t_finess.texte AS etablissement_texte
					FROM pmsi.p_rss
					JOIN pmsi.p_rss_actes ON p_rss_actes.rss_id = p_rss.oid
					JOIN w_etude_bariatrique_cdc ON w_etude_bariatrique_cdc.acte_id = p_rss_actes.acte_id
					JOIN pmsi.t_actes ON t_actes.oid = p_rss_actes.acte_id
					JOIN base.t_finess ON t_finess.code = p_rss.finess
					WHERE 
						(
							p_rss.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' 
				 			OR p_rss.date_sortie BETWEEN '[VIEW.PERIODE_D]' AND '[VIEW.TOPERIODE_D]'
				 			OR p_rss.date_sortie BETWEEN '[VIEW.PERIODE_2D]' AND '[VIEW.TOPERIODE_2D]'
				 			OR p_rss.date_sortie BETWEEN '[VIEW.LAST_ANNEE_FORMAT_DEB]' AND '[VIEW.LAST_ANNEE_FORMAT_FIN]'
				 			OR p_rss.date_sortie BETWEEN '[VIEW.LAST_ANNEE_D_FORMAT_DEB]' AND '[VIEW.LAST_ANNEE_D_FORMAT_FIN]' 
						)
						[VIEW.CHAMP_SELECT]
					ORDER BY rss_id
				;

				CTISELECT_TREE
					WORKTABLE{w_etude_bariatrique_1}
				[EVAL  
					if('[ENV.CONSOLIDATION]' == '1'){
						return "
							GROUPBY1{ETABLISSEMENT_ID,, ETABLISSEMENT_CODE,, ETABLISSEMENT_TEXTE}
							GROUPBY2{SECTION_ID,, SECTION_CODE,, SECTION_TEXTE}
							GROUPBY3{ACTE_ID,, ACTE_CODE,, ACTE_TEXTE}
						";
					}
					else {
						return "
							GROUPBY1{SECTION_ID,, SECTION_CODE,, SECTION_TEXTE}
							GROUPBY2{ACTE_ID,, ACTE_CODE,, ACTE_TEXTE}						
						";
					}
				EVAL]
					GROUPBY1MODE{[GROUPBY_TAB]}
					INDICATORS{
						COUNT(DISTINCT CASE WHEN date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN rss_id ELSE null END),
						COUNT(DISTINCT CASE WHEN date_sortie BETWEEN '[VIEW.PERIODE_D]' AND '[VIEW.TOPERIODE_D]' THEN rss_id ELSE null END),						
						COUNT(DISTINCT CASE WHEN date_sortie BETWEEN '[VIEW.PERIODE_2D]' AND '[VIEW.TOPERIODE_2D]' THEN rss_id ELSE null END),
						COUNT(DISTINCT CASE WHEN date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN rss_id ELSE null END),
						COUNT(DISTINCT CASE WHEN date_sortie BETWEEN '[VIEW.PERIODE_D]' AND '[VIEW.TOPERIODE_D]' THEN rss_id ELSE null END),						
						COUNT(DISTINCT CASE WHEN date_sortie BETWEEN '[VIEW.PERIODE_2D]' AND '[VIEW.TOPERIODE_2D]' THEN rss_id ELSE null END),
						AVG(SEUIL),
						COUNT(CASE WHEN age_patient <= 18 AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN 1 ELSE NULL END),
						COUNT(CASE WHEN age_patient <= 18 AND date_sortie BETWEEN '[VIEW.PERIODE_D]' AND '[VIEW.TOPERIODE_D]' THEN 1 ELSE NULL END),
						COUNT(CASE WHEN age_patient <= 18 AND date_sortie BETWEEN '[VIEW.PERIODE_2D]' AND '[VIEW.TOPERIODE_2D]' THEN 1 ELSE NULL END),
						(COUNT(CASE WHEN age_patient <= 18 AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN 1 ELSE NULL END) / SUM(nombre)) * 100,
						(COUNT(CASE WHEN age_patient <= 18 AND date_sortie BETWEEN '[VIEW.PERIODE_D]' AND '[VIEW.TOPERIODE_D]' THEN 1 ELSE NULL END) / SUM(nombre)) * 100,
						(COUNT(CASE WHEN age_patient <= 18 AND date_sortie BETWEEN '[VIEW.PERIODE_2D]' AND '[VIEW.TOPERIODE_2D]' THEN 1 ELSE NULL END) / SUM(nombre)) * 100
					}
					ORDERBY{[VIEW.ORDERBY],, DESC}
					FROM w_etude_bariatrique

				]]></select>
				
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="SORT" />
					<FIELD name="NBS" />
					<FIELD name="NBSD" />
					<FIELD name="NBS2D" />
					<FIELD name="NBA" />
					<FIELD name="NBAD" />
					<FIELD name="NBA2D" />
					<FIELD name="NBAS" />
					<FIELD name="NBAX18" />
					<FIELD name="NBAX18D" />
					<FIELD name="NBAX182D" />
					<FIELD name="NBAXP18" />
					<FIELD name="NBAXP18D" />
					<FIELD name="NBAXP182D" />
				</FIELDS>	
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL>
				<select><![CDATA[
							
						SELECT 
							'CLASSE_SEQUENCE', t_classes.sequence AS classe_sequence
						FROM pmsi.t_etude_bariatrique 
						JOIN pmsi.t_classes ON t_classes.code = 'ETUDE_BARIATRIQUE_2022'
						JOIN pmsi.t_listes ON t_listes.code = t_etude_bariatrique.liste_code
						WHERE t_etude_bariatrique.cdc = '2022'
						GROUP BY 1,2
					UNION ALL
						SELECT 
							'LISTE_ID', t_listes.oid AS liste_id
						FROM pmsi.t_etude_bariatrique 
						JOIN pmsi.t_classes ON t_classes.code = 'ETUDE_BARIATRIQUE_2022'
						JOIN pmsi.t_listes ON t_listes.code = t_etude_bariatrique.liste_code
						WHERE t_etude_bariatrique.cdc = '2022'
					GROUP BY 1,2
					;
					
				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
			<SQL>
				<select><![CDATA[
					
						SELECT 'WPERIODE_D', (date '[PERIODE]' + interval '1 day' - interval '1 year' - interval '1 day')::date
					UNION ALL
						SELECT 'WTOPERIODE_D', (date '[TOPERIODE]' + interval '1 day' - interval '1 year' - interval '1 day')::date
					UNION ALL
						SELECT 'WPERIODE_2D', (date '[PERIODE]' + interval '1 day' - interval '2 year' - interval '1 day')::date
					UNION ALL
						SELECT 'WTOPERIODE_2D', (date '[TOPERIODE]' + interval '1 day' - interval '2 year' - interval '1 day')::date
					
				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
			<SQL>
				<select><![CDATA[

						SELECT 
							'PERIODE_LABEL_COURT', 
							CASE WHEN extract(day from p_calendrier.date) > 1 THEN p_calendrier.texte_court ELSE p_calendrier_mois.texte_court END
						FROM 
							base.p_calendrier, base.p_calendrier_mois 
						WHERE 
							p_calendrier.mois = p_calendrier_mois.mois 
							AND p_calendrier.date = '[PERIODE]'
					UNION ALL	
						SELECT 
							'TOPERIODE_LABEL_COURT', 
							CASE WHEN dernier_jour = '1' THEN p_calendrier_mois.texte_court ELSE p_calendrier.texte_court END
						FROM 
							base.p_calendrier, base.p_calendrier_mois 
						WHERE 
							p_calendrier.mois = p_calendrier_mois.mois 
							AND p_calendrier.date = '[TOPERIODE]'
					UNION ALL
						SELECT 
							'PERIODE_D_LABEL', 
							CASE WHEN extract(day from p_calendrier.date) > 1 THEN p_calendrier.texte_court ELSE p_calendrier_mois.texte_court END
						FROM 
							base.p_calendrier, base.p_calendrier_mois 
						WHERE 
							p_calendrier.mois = p_calendrier_mois.mois 
							AND (p_calendrier.date + interval '1 day' + interval '1 year' - interval '1 day')::date = '[PERIODE]'
					UNION ALL
						SELECT 
							'TOPERIODE_D_LABEL', 
							CASE WHEN dernier_jour = '1' THEN p_calendrier_mois.texte_court ELSE p_calendrier.texte_court END
						FROM 
							base.p_calendrier, base.p_calendrier_mois 
						WHERE 
							p_calendrier.mois = p_calendrier_mois.mois 
							AND (p_calendrier.date + interval '1 day' + interval '1 year' - interval '1 day')::date = '[TOPERIODE]'
					UNION ALL
						SELECT 
							'PERIODE_2D_LABEL', 
							CASE WHEN extract(day from p_calendrier.date) > 1 THEN p_calendrier.texte_court ELSE p_calendrier_mois.texte_court END
						FROM 
							base.p_calendrier, base.p_calendrier_mois 
						WHERE 
							p_calendrier.mois = p_calendrier_mois.mois 
							AND (p_calendrier.date + interval '1 day' + interval '2 year' - interval '1 day')::date = '[PERIODE]'
					UNION ALL
						SELECT 
							'TOPERIODE_2D_LABEL', 
							CASE WHEN dernier_jour = '1' THEN p_calendrier_mois.texte_court ELSE p_calendrier.texte_court END
						FROM 
							base.p_calendrier, base.p_calendrier_mois 
						WHERE 
							p_calendrier.mois = p_calendrier_mois.mois 
							AND (p_calendrier.date + interval '1 day' + interval '2 year' - interval '1 day')::date = '[TOPERIODE]'
					
				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
			<SQL>
				<select><![CDATA[
					
					SELECT 
						'NB_JOURS', 
						'[TOPERIODE]'::date - '[PERIODE]'::date + 1
					
				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000034.XML" componentName="RSS_BASE_VIEWLINK">
				 <ARG name="ACTE_RSS" value=" if (ENV.CONSOLIDATION == '1'  &amp;&amp; ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3}
											  if (ENV.CONSOLIDATION == '1'  &amp;&amp; ROW.OID2 != '-9999999') {return 'LS' + VIEW.CLASSE_SEQUENCE + ROW.OID2}
											  if (ENV.CONSOLIDATION == '1'  &amp;&amp; ROW.OID1 != '-9999999') {return 'LI' + VIEW.LISTE_ID}
											  if (ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2}
											  if (ROW.OID1 != '-9999999') {return 'LS' + ROW.OID1}
											  if (ROW.OID1 == '-9999999') {return 'LI' + VIEW.LISTE_ID}
											  "/>
				 <ARG name="FINESS" value="if (ENV.CONSOLIDATION == '1') {return ROW.COD1} else {return '-1'}" />
				 <ARG name="PERIODE" value="if (COLUMN.NAME == 'NBAD' &amp;&amp; SELECT.TYPE_COMPARAISON == '2') {return VIEW.WPERIODE_D} 
											if (COLUMN.NAME == 'NBAD' &amp;&amp; SELECT.TYPE_COMPARAISON == 'S') {return SELECT.PERIODE_D}
											if (COLUMN.NAME == 'NBAD' &amp;&amp; SELECT.TYPE_COMPARAISON == '3') {return VIEW.WPERIODE_D}
											if (COLUMN.NAME == 'NBA2D' &amp;&amp; SELECT.TYPE_COMPARAISON == '2') {return VIEW.WPERIODE_2D} 
											if (COLUMN.NAME == 'NBA2D' &amp;&amp; SELECT.TYPE_COMPARAISON == 'S') {return SELECT.PERIODE_2D}
											if (COLUMN.NAME == 'NBA2D' &amp;&amp; SELECT.TYPE_COMPARAISON == '3') {return VIEW.WPERIODE_2D}
											return SELECT.PERIODE" />

				<ARG name="TOPERIODE" value="if (COLUMN.NAME == 'NBAD' &amp;&amp; SELECT.TYPE_COMPARAISON == '2') {return VIEW.WTOPERIODE_D} 
											 if (COLUMN.NAME == 'NBAD' &amp;&amp; SELECT.TYPE_COMPARAISON == 'S') {return SELECT.TOPERIODE_D}
											 if (COLUMN.NAME == 'NBAD' &amp;&amp; SELECT.TYPE_COMPARAISON == '3') {return VIEW.WTOPERIODE_D}
											 if (COLUMN.NAME == 'NBA2D' &amp;&amp; SELECT.TYPE_COMPARAISON == '2') {return VIEW.WTOPERIODE_2D} 
											 if (COLUMN.NAME == 'NBA2D' &amp;&amp; SELECT.TYPE_COMPARAISON == 'S') {return SELECT.TOPERIODE_2D}
											 if (COLUMN.NAME == 'NBA2D' &amp;&amp; SELECT.TYPE_COMPARAISON == '3') {return VIEW.WTOPERIODE_2D}
											 return SELECT.TOPERIODE" />
            </VIEWLINK>
		</VIEWLINKS>
		<VIEWREF label="Arrêté du 29 décembre 2022 fixant la liste des interventions chirurgicales mentionnées à l?article R. 6123-208 du code de la santé publique et le nombre minimal annuel d?actes pour l?activité de chirurgie bariatrique prévu à l?article R. 6123-212 du code de la santé publique et modifiant l?arrêté du 16 septembre 2022 fixant, pour un site autorisé, le nombre d?équipements d?imagerie en coupes en application du II de l?article R. 6123-161 du code de la santé publique " shortLabel="Extrait J.O" 
				url="http://www.ctisante.com/references/pmsi/JO_2022-12-31_ActiviteChirBariatrique_SeuilActes.pdf" rowContext="false" />
		<ONGLET excelLabel="Etude CDC 2022" queryNumber="0" >
			<DATAGRID title="" total="true" showOthers="false" key="COD" headerHeight="55" variableRowHeight="true" sortable="true" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'">
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				<COLUMN 
					dataField="OID" 
					width="80" 
					type="Char" 
					visible="false" 
					headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" 
					width="70" 
					type="Char" 
					visible="true" 
					headerText="Code"
					textAlign="left" 
					otherFunction="text" 
					totalFunction="text">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" 
					type="Char" 
					minWidth="150" 
					headerText="Actes"
					textAlign="left"
					totalFunction="text" 
					totalComplement="TOTAL" 
					otherFunction="text">
				</COLUMN>
				<COLUMN dataField="NBAS"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="Valeur du Seuil" 
					textAlign="right" 
					otherFunction="text"
					totalFunction="sum" 
					totalComplement=""
					largeSeparator="true"
					visibleCondition="ENV.CONSOLIDATION == '1'"
					calc="true">
					<CALC formula="ROW.NBAS - ROW.NBAS" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL != '1' ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL != '9' "/>
					<CALC formula="ROW.NBAS"/>
				</COLUMN>
				<COLUMN dataField="NBA"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="'Total actes \n' + VIEW.PERIODE_LABEL_COURT + '\n' + VIEW.TOPERIODE_LABEL_COURT;"
					textAlign="right" 
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					totalComplement=""
					selectable="true"
					largeSeparator="true">
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0x75a0eb" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL == '1' &amp;&amp; ROW.NBA &gt;= ROW.NBAS ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL == '9' &amp;&amp; ROW.NBA &gt;= ROW.NBAS"/>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL == '1' &amp;&amp; ROW.NBA &lt; ROW.NBAS ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL == '9' &amp;&amp; ROW.NBA &lt; ROW.NBAS"/>
				</COLUMN>
				<COLUMN dataField="NBAD"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="if (SELECT.TYPE_COMPARAISON != 'S') {
									return 'Total actes \n' + VIEW.PERIODE_D_LABEL + '\n' + VIEW.TOPERIODE_D_LABEL;
								}
								else {
									return 'Total actes \n' + SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL;
								}" 
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					totalComplement=""
					selectable="true"
					visibleCondition="SELECT.TYPE_COMPARAISON != '-1'"
					largeSeparator="true">
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0x75a0eb" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL == '1' &amp;&amp; ROW.NBAD &gt;= ROW.NBAS ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL == '9' &amp;&amp; ROW.NBAD &gt;= ROW.NBAS"/>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL == '1' &amp;&amp; ROW.NBAD &lt; ROW.NBAS ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL == '9' &amp;&amp; ROW.NBAD &lt; ROW.NBAS"/>
				</COLUMN>
				<COLUMN dataField="NBA2D"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="'Total actes \n' + VIEW.PERIODE_2D_LABEL + '\n' + VIEW.TOPERIODE_2D_LABEL;" 
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					totalComplement=""
					selectable="true"
					visibleCondition="SELECT.TYPE_COMPARAISON == '3'"
					largeSeparator="true">
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0x75a0eb" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL == '1' &amp;&amp; ROW.NBA2D &gt;= ROW.NBAS ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL == '9' &amp;&amp; ROW.NBA2D &gt;= ROW.NBAS"/>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" condition="ENV.CONSOLIDATION == '1' &amp;&amp; ROW.LVL == '1' &amp;&amp; ROW.NBA2D &lt; ROW.NBAS ||  ENV.CONSOLIDATION != '1' &amp;&amp; ROW.LVL == '9' &amp;&amp; ROW.NBA2D &lt; ROW.NBAS"/>
				</COLUMN>
				<COLUMN dataField="NBS"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="'Total séjours \n' + VIEW.PERIODE_LABEL_COURT + '\n' + VIEW.TOPERIODE_LABEL_COURT;"
					textAlign="right" 
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBSD"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="if (SELECT.TYPE_COMPARAISON != 'S') {
									return 'Total séjours \n' + VIEW.PERIODE_D_LABEL + '\n' + VIEW.TOPERIODE_D_LABEL;
								}
								else {
									return 'Total séjours \n' + SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL;
								}" 
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum"
					visibleCondition="SELECT.TYPE_COMPARAISON != '-1'"		
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBS2D"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="'Total séjours \n' + VIEW.PERIODE_2D_LABEL + '\n' + VIEW.TOPERIODE_2D_LABEL;" 
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					visibleCondition="SELECT.TYPE_COMPARAISON == '3'"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBAX18"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="'Dont enfants 0-18 ans \n' + VIEW.PERIODE_LABEL_COURT + '\n' + VIEW.TOPERIODE_LABEL_COURT;"
					textAlign="right" 
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBAX18D"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="if (SELECT.TYPE_COMPARAISON != 'S') {
									return 'Dont enfants 0-18 ans \n' + VIEW.PERIODE_D_LABEL + '\n' + VIEW.TOPERIODE_D_LABEL;
								}
								else {
									return 'Dont enfants 0-18 ans \n' + SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL;
								}
								" 
					headerTextCalc="true"										
					textAlign="right"
					otherFunction="text"
					totalFunction="sum"
					visibleCondition="SELECT.TYPE_COMPARAISON != '-1'"					
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBAX182D"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="'Dont enfants 0-18 ans \n' + VIEW.PERIODE_2D_LABEL + '\n' + VIEW.TOPERIODE_2D_LABEL;" 
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum"
					visibleCondition="SELECT.TYPE_COMPARAISON == '3'"					
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBAXP18"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#,00%"
					headerText="'Dont % enfants 0-18 ans \n' + VIEW.PERIODE_LABEL_COURT + '\n' + VIEW.TOPERIODE_LABEL_COURT;"
					textAlign="right" 
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBAXP18D"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#,00%"
					headerText="if (SELECT.TYPE_COMPARAISON != 'S') {
									return 'Dont % enfants 0-18 ans \n' + VIEW.PERIODE_D_LABEL + '\n' + VIEW.TOPERIODE_D_LABEL;
								}
								else {
									return 'Dont % enfants 0-18 ans \n' + SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL;
								}
								"
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum" 
					visibleCondition="SELECT.TYPE_COMPARAISON != '-1'"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBAXP182D"
					width="80"
					type="Number"
					visible="true"
					outputFormat="#,00%"
					headerText="'Dont % enfants 0-18 ans \n' + VIEW.PERIODE_2D_LABEL + '\n' + VIEW.TOPERIODE_2D_LABEL;" 
					textAlign="right"
					headerTextCalc="true"										
					otherFunction="text"
					totalFunction="sum"
					visibleCondition="SELECT.TYPE_COMPARAISON == '3'"					
					totalComplement="">
				</COLUMN>
				<ROWSTYLE name="rowHeight" value="20" condition="ROW.LVL == '1'" />
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.LVL == '1'" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>