<?xml version="1.0" encoding="ISO-8859-15"?>

<COMPONENTS>

	<COMPONENT name="FILTRES_GROUPBY_TEXT" label="Libellés regroupements" >
		
			<SELECTIONS label="Libellés regroupements" displayText="= var display:String = '';

						if (SELECT.GROUPBY_2 != '-1') {
							display = '#B# Regroupements #/B# = ';
							display =  display + 'Niveau 2 : #B# ' + SELECT.GROUPBY_2_LABEL + '#/B#' ;
							
							if (SELECT.GROUPBY_3 != '-1') {
								display = display + ', Niveau 3: #B# ' + SELECT.GROUPBY_3_LABEL + ' #/B#' ;
							}	
						
						}
						return display;" 
			/>

	</COMPONENT>
		
	<COMPONENT name="FILTRES_PRESTATIONS_SELECTIONS" label="Filtres Prestations">
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres Prestations" displayText="= var display:String = '';
					if (SELECT.PRESTATION != '-1') {
						display += '  Prestation : #B#' + SELECT.PRESTATION_LABEL + '#/B#';
					}
					if (SELECT.FIDES_DETAIL != '-1') {
						display += '  Valorisation FIDES (ligne) : #B#' + SELECT.FIDES_DETAIL_LABEL + '#/B#';
					}
					if (SELECT.LAMDA != '-1') {
						display += '  Intégration LAMDA : #B#' + SELECT.LAMDA_LABEL + '#/B#';
					}
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="Prestation">
				<FIELD name="PRESTATION" label="Prestation" UI="combo" tree="true" width="400" default="-1" globalListProvider="PRESTATION" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Valorisation FIDES (ligne)">
				<FIELD name="FIDES_DETAIL" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true">
					<OPTION label="Pas de sélection" data="-1" />
					<OPTION label="Non renseigné" data="X" />
					<OPTION label="Oui" data="1" />
					<OPTION label="Non" data="0" />
				</FIELD>
			</GROUP>
			<GROUP label="LAMDA">
				<FIELD name="LAMDA" width="220" label="" UI="combo" default="-1" visible="= ENV.OPTPMSI_LAMDA == '1' ">
					<OPTION data="-1" label="Avec LAMDA éventuel"/>
					<OPTION data="1" label="Sans LAMDA"/>
					<OPTION data="2" label="Ecarts LAMDA"/>
				</FIELD>
			</GROUP>
		</SELECTIONS>
		
		
		<QUERIES />
		
	</COMPONENT>	
    
    <COMPONENT name="FILTRES_PRESTATIONS_SELECTIONS_REJETS" label="Filtres Prestations">
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres Prestations" displayText="= var display:String = '';
					if (SELECT.PRESTATION != '-1') {
						display += '  Prestation : #B#' + SELECT.PRESTATION_LABEL + '#/B#';
					}
					if (SELECT.LAMDA != '-1') {
						display += '  Intégration LAMDA : #B#' + SELECT.LAMDA_LABEL + '#/B#';
					}
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="Prestation">
				<FIELD name="PRESTATION" label="Prestation" UI="combo" tree="true" width="400" default="-1" value ="return '#LICTI_GHS_SUPPL'" visible="false" globalListProvider="PRESTATION" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="LAMDA">
				<FIELD name="LAMDA" width="220" label="" UI="combo" default="-1" visible="= ENV.OPTPMSI_LAMDA == '1' ">
					<OPTION data="-1" label="Avec LAMDA éventuel"/>
					<OPTION data="1" label="Sans LAMDA"/>
					<OPTION data="2" label="Ecarts LAMDA"/>
				</FIELD>
			</GROUP>
		</SELECTIONS>
		
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_LPP_SELECTIONS" label="Filtres LPP" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres LPP" displayText="= var display:String = '';
					if (SELECT.LPP != '-1') {
						display += '  LPP : #B#' + SELECT.LPP_LABEL + '#/B#';
					}
					if (SELECT.PRIS_EN_COMPTE != '-1') {
						display += '  #B#' + SELECT.PRIS_EN_COMPTE_LABEL + '#/B#';
					}
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="LPP">
				<FIELD name="LPP" label="LPP" UI="combo" tree="true" width="400" default="-1" globalListProvider="LPP" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="">
				<FIELD name="PRIS_EN_COMPTE" label="Valorisé OVALIDE" UI="combo" width="400" default="-1" showIfNotDefault="true">
					<OPTION label="Pas de sélection" treeLevel="1" data="-1" />
					<OPTION label="LPP pris en compte par OVALIDE" treeLevel="1" data="1" />
					<OPTION label="LPP non pris en compte par OVALIDE" treeLevel="1" data="0" />
				</FIELD>
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_UCD_SELECTIONS" label="Filtres UCD" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres UCD" displayText="= var display:String = '';
        
					display += '  Type UCD  : #B#' + SELECT.T_UCD_LABEL + '#/B#';
                    
                    if (SELECT.UCD != '-1') {
						display += '  UCD : #B#' + SELECT.UCD_LABEL + '#/B#';
					}                    
                    if (SELECT.I_UCD != '-1') {
						display += '  Indication UCD : #B#' + SELECT.I_UCD_LABEL + '#/B#';
					}
					if (SELECT.PRIS_EN_COMPTE != '-1') {
						display += '  #B#' + SELECT.PRIS_EN_COMPTE_LABEL + '#/B#';
					}
					if (display != '') {
						display = '#B#Filtres UCD#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="UCD">
				<FIELD name="UCD" label="UCD" UI="combo" tree="true" width="400" default="-1" globalListProvider="UCD" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="">
				<FIELD name="T_UCD" label="Type UCD" UI="combo" tree="true" width="400" default="TU1" globalListProvider="T_UCD" showIfNotDefault="true" />
			</GROUP>			
            <GROUP label="">
				<FIELD name="I_UCD" label="Indication UCD" UI="combo" tree="true" width="400" default="-1" globalListProvider="I_UCD" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="">
				<FIELD name="PRIS_EN_COMPTE" label="Valorisé OVALIDE" UI="combo" width="400" default="-1" showIfNotDefault="true">
					<OPTION label="Pas de sélection" treeLevel="1" data="-1" />
					<OPTION label="UCD pris en compte par OVALIDE" treeLevel="1" data="1" />
					<OPTION label="UCD non pris en compte par OVALIDE" treeLevel="1" data="0" />
				</FIELD>
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_DIAG_SELECTIONS" label="Filtres Diagnostics" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres Diagnostics" displayText="= var display:String = '';
					if (SELECT.T_DIAG  != '-1') {
						display += '  ' + SELECT.T_DIAG_LABEL + ' : #B#' + SELECT.DIAG_LABEL + '#/B#';
					}
                    
					if (SELECT.F_DIAGSEV  != '-1') {
						display += '  ' + SELECT.F_DIAGSEV_LABEL + ' : #B#' + SELECT.DIAGSEV_LABEL + '#/B#';
					}
                    
                    if (SELECT.POLE != '-1') {
						display += '  Pole : #B#' + SELECT.POLE_LABEL + '#/B#';
					}
					if (SELECT.UM != '-1') {
						display += '  Unité médicale : #B#' + SELECT.UM_LABEL + '#/B#';
					}
                    
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="Diagnostic analysé">
				<FIELD name="T_DIAG" label="Diagnostic analysé" UI="combo" width="150" default="-1" globalListProvider="T_DIAG" showIfNotDefault="true" />
				<FIELD name="DIAG" label="" UI="combo" tree="true" width="400" default="" globalListProvider="DIAG" visible="= SELECT.T_DIAG != '-1'" showIfNotDefault="true"/>
			</GROUP>
            <GROUP label="Sévérité">
				<FIELD name="F_DIAGSEV" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="F_DIAGSEV" showIfNotDefault="true"/>
			</GROUP>
            <GROUP label="Pole">
				<FIELD name="POLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="POLE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Unité médicale">
				<FIELD name="UM" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_ACTE_SELECTIONS" label="Filtres Actes" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres Actes" displayText="= var display:String = '';
					if (SELECT.ACTE != '-1') {
						display += '  Actes : #B#' + SELECT.ACTE_LABEL + ' (' + SELECT.ACTE_ACTIVITE_CCAM_LABEL + ')#/B#';
					}
					if (SELECT.ACTE == '-1' &amp;&amp; SELECT.ACTE_ACTIVITE_CCAM != '-1') {
						display += '  Actes : #B#' + SELECT.ACTE_ACTIVITE_CCAM_LABEL + '#/B#';
					}
					if (SELECT.MEDECIN != '-1') {
						display += '  Médecin exécutant : #B#' + SELECT.MEDECIN_LABEL + '#/B#';
					}
                    if (SELECT.POLE != '-1') {
						display += '  Pole : #B#' + SELECT.POLE_LABEL + '#/B#';
					}
					if (SELECT.UM != '-1') {
						display += '  Unité médicale : #B#' + SELECT.UM_LABEL + '#/B#';
					}
					if (SELECT.UF != '-1') {
						display += '  Unité fonctionnelle : #B#' + SELECT.UF_LABEL + '#/B#';
					}
					if (SELECT.ACTE_EXTENSION_DOC != '-1') {
						display += '  Extension documentaire : #B#' + SELECT.ACTE_EXTENSION_DOC_LABEL + '#/B#';
					}
					if (SELECT.ICR_CLASSIFICATION != '-1') {
						display += '  Classification ICR : #B#' + SELECT.ICR_CLASSIFICATION_LABEL + '#/B#';
					}
					if (SELECT.MCC != '-1') {
						display += '  Modificateurs : #B#' + SELECT.MCC_LABEL + '#/B#';
					}
					if (SELECT.ANP != '-1') {
						display += '  Association non prevue : #B#' + SELECT.ANP_LABEL + '#/B#';
					}
					
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="Acte">
				<FIELD name="ACTE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE" showIfNotDefault="true" />
				<FIELD name="ACTE_ACTIVITE_CCAM" label="" UI="combo" default="-1" showIfNotDefault="true"  tree="true">
                    <OPTION label="Toutes activités" data="-1" />
                    <OPTION label="Chirurgie-médecine (codes 1,2,3,5)" data="6"  treeLevel="1" />
                    <OPTION label="Geste principal (code 1)" data="1" treeLevel="2" />            
                    <OPTION label="2ème geste éventuel (code 2)" data="2" treeLevel="2" />
                    <OPTION label="3ème geste éventuel (code 3)" data="3" treeLevel="2" />            
                    <OPTION label="Surveillance d'une CEC (code 5)" data="5" treeLevel="2" />                
                    <OPTION label="Anesthésie (code 4)" data="4"  treeLevel="1" />
				</FIELD>
			</GROUP>
			<GROUP label="Modificateurs CCAM">
				<FIELD name="MCC" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MCC" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Assoc. non prévue">
				<FIELD name="ANP" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ANP" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Classification ICR">
				<FIELD name="ICR_CLASSIFICATION" label="" UI="combo" width="400" default="-1" showIfNotDefault="true">
					<OPTION label="AMELI (NX)" data="-1" />
					<OPTION label="ATIH Privé" data="ATIHPRIVE" />
					<OPTION label="ATIH Public" data="ATIHPUBLIC" />
				</FIELD>
			</GROUP>
			<GROUP label="Ext. documentaire">
				<FIELD name="ACTE_EXTENSION_DOC" label="" UI="combo" width="400" default="-1" showIfNotDefault="true" globalListProvider="ACTE_EXTENSION_DOC" />
			</GROUP>
			<GROUP label="Médecin exécutant">
				<FIELD name="MEDECIN" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MEDECIN_ACTE" showIfNotDefault="true" />
			</GROUP>
            <GROUP label="Pole">
				<FIELD name="POLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="POLE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Unité médicale">
				<FIELD name="UM" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="UF d'exécution">
				<FIELD name="UF" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UF" showIfNotDefault="true" />
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_INTERV_SELECTIONS" label="Filtres Interventions" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres Interventions" displayText="= var display:String = '';
					if (SELECT.ACTE != '-1') {
						display += '  Interventions : #B#' + SELECT.ACTE_LABEL +'#/B#';
					}
					if (SELECT.MEDECIN != '-1') {
						display += '  Médecin exécutant : #B#' + SELECT.MEDECIN_LABEL + '#/B#';
					}
					if (SELECT.ANESTHESISTE != '-1') {
						display += '  Anesthésiste : #B#' + SELECT.ANESTHESISTE_LABEL + '#/B#';
					}
                    if (SELECT.POLE != '-1') {
						display += '  Pole : #B#' + SELECT.POLE_LABEL + '#/B#';
					}
					if (SELECT.UF != '-1') {
						display += '  Unité fonctionnelle : #B#' + SELECT.UF_LABEL + '#/B#';
					}
					if (SELECT.UM != '-1') {
						display += '  Unité médicale : #B#' + SELECT.UM_LABEL + '#/B#';
					}
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="Acte">
				<FIELD name="ACTE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE_PRINCIPAL_INTERVENTION" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Classification ICR">
				<FIELD name="ICR_CLASSIFICATION" label="" UI="combo" width="400" default="-1" showIfNotDefault="true">
					<OPTION label="AMELI (NX)" data="-1" />
					<OPTION label="ATIH Privé" data="ATIHPRIVE" />
					<OPTION label="ATIH Public" data="ATIHPUBLIC" />
				</FIELD>
			</GROUP>
			<GROUP label="Médecin exécutant">
				<FIELD name="MEDECIN" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MEDECIN_INTERVENTION" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Anesthésiste">
				<FIELD name="ANESTHESISTE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ANESTHESISTE_INTERVENTION" showIfNotDefault="true" />
			</GROUP>
            <GROUP label="Pole">
				<FIELD name="POLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="POLE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Unité médicale">
				<FIELD name="UM" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="UF d'exécution">
				<FIELD name="UF" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UF" showIfNotDefault="true" />
			</GROUP>
			<!--<GROUP label="N° Intervention">
				<FIELD name="NO_INTERV" label="" UI="text" width="400" default="" showIfNotDefault="true" visible="= VIEW.CPT_INTERV == 'CTI'" />
			</GROUP>
			-->
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_PRESTATION_RUM_SELECTIONS" label="Filtres Prestations/Unités Médicales" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres Prestations/Unités Médicales" displayText="= var display:String = '';
					if (SELECT.PRESTATION != '-1') {
						display += '  Prestation : #B#' + SELECT.PRESTATION_LABEL + '#/B#'
					}
					if (SELECT.FIDES_DETAIL != '-1') {
						display += '  Valorisation FIDES (ligne) : #B#' + SELECT.FIDES_DETAIL_LABEL + '#/B#';
					}
                    if (SELECT.POLE != '-1') {
						display += '  Pole : #B#' + SELECT.POLE_LABEL + '#/B#';
					}
					if (SELECT.UM != '-1') {
						display += '  Unité médicale : #B#' + SELECT.UM_LABEL + '#/B#'
					}
					if (SELECT.UM_AUT  != '-1') {
						display += '  Type autorisation : #B#' + SELECT.UM_AUT_LABEL + '#/B#'
					}
					if (SELECT.LAMDA != '-1') {
						display += '  Intégration LAMDA : #B#' + SELECT.LAMDA_LABEL + '#/B#'
					}
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
			<GROUP label="Prestation">
				<FIELD name="PRESTATION" label="Prestation" UI="combo" tree="true" width="400" default="-1" globalListProvider="PRESTATION" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Valorisation FIDES (ligne)">
				<FIELD name="FIDES_DETAIL" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true">
					<OPTION label="Pas de sélection" data="-1" />
					<OPTION label="Non renseigné" data="X" />
					<OPTION label="Oui" data="1" />
					<OPTION label="Non" data="0" />
				</FIELD>
			</GROUP>
            <GROUP label="Pole">
				<FIELD name="POLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="POLE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="UM">
				<FIELD name="UM" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Type autorisation">
				<FIELD name="UM_AUT" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM_AUT" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="LAMDA">
				<FIELD name="LAMDA" width="220" label="" UI="combo" default="-1" visible="= ENV.OPTPMSI_LAMDA == '1' ">
					<OPTION data="-1" label="Avec LAMDA éventuel" />
					<OPTION data="1" label="Sans LAMDA" />
					<OPTION data="2" label="Ecarts LAMDA" />
				</FIELD>
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_RUM_SELECTIONS" label="Filtres RUM" >
	
		<VIEWPROPERTIES />
		
		<SELECTIONS label="Filtres RUM" displayText="= var display:String = '';
        	if (SELECT.POLE != '-1') {
						display += '  Pole : #B#' + SELECT.POLE_LABEL + '#/B#';
					}
                    
					if (SELECT.UM != '-1') {display = display + 'Unité médicale : #B#' + SELECT.UM_LABEL + '#/B#'}

					if (SELECT.UM_AUT != '-1') {
						display += '  Type autorisation : #B#' + SELECT.UM_AUT_LABEL + '#/B#';
					}
					if (SELECT.UM_HOS  != '-1') {display = display + '  Mode hospit. : #B#' + SELECT.UM_HOS_LABEL + '#/B#'}
					if (SELECT.UM_DIS  != '-1') {display = display + '  Discipline SAE : #B#' + SELECT.UM_DIS_LABEL + '#/B#'}

					if (SELECT.MODE_ENTREE_RUM  != '-1') {
						display = display + '  Mode entrée RUM : #B#' + SELECT.MODE_ENTREE_RUM_LABEL + '#/B#';
					}
					if (SELECT.PROVENANCE_RUM  != '-1') {
						display = display + '  Provenance : #B#' + SELECT.PROVENANCE_RUM_LABEL + '#/B#';
					}
					if (SELECT.MODE_SORTIE_RUM  != '-1') {
						display = display + '  Mode sortie RUM : #B#' + SELECT.MODE_SORTIE_RUM_LABEL + '#/B#';
					}
					if (SELECT.DESTINATION_RUM  != '-1') {
						display = display + '  Destination : #B#' + SELECT.DESTINATION_RUM_LABEL + '#/B#';
					}
					if (SELECT.DUREE_SEJOUR_RUM != '' || SELECT.DUREE_SEJOUR_RUM2 != '') {
						display = display + ' Durée séjour RUM : #B#';
						if (SELECT.DUREE_SEJOUR_RUM != '') {
							if (SELECT.DUREE_SEJOUR_RUM2 != '') {
								display = display + '#GE# ' + SELECT.DUREE_SEJOUR_RUM + ' et #LE# ' + SELECT.DUREE_SEJOUR_RUM2 + ' nuit(s)';
							}
							else {
								display = display + '#GE# ' + SELECT.DUREE_SEJOUR_RUM + ' nuit(s)';
							}
						}
						else {
							display = display + '#LE# ' + SELECT.DUREE_SEJOUR_RUM2 + ' nuit(s)';
						}
						display = display + '#/B#';
					}
					if (SELECT.MEDECIN_RUM  != '-1') {
						display = display + '  Médecin RUM : #B#' + SELECT.MEDECIN_RUM_LABEL + '#/B#';
					}
					
					if (display != '') {
						display = '#B#Analyse#/B# = ' + display;
					}
					return display;
					">
            <GROUP label="Pole">
				<FIELD name="POLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="POLE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="UM">
				<FIELD name="UM" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Type autorisation">
				<FIELD name="UM_AUT" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM_AUT" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Mode hospit.">
				<FIELD name="UM_HOS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM_HOS" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Discipline SAE">
				<FIELD name="UM_DIS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM_DIS" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Mode entrée RUM">
				<FIELD name="MODE_ENTREE_RUM" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="MODE_ENTREE" showIfNotDefault="true" />
				<FIELD name="PROVENANCE_RUM" label="Provenance" labelWidth="80" UI="combo" tree="false" width="200" default="-1" globalListProvider="PROVENANCES" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Mode sortie RUM">
				<FIELD name="MODE_SORTIE_RUM" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="MODE_SORTIE" showIfNotDefault="true" />
				<FIELD name="DESTINATION_RUM" label="Destination" labelWidth="80" UI="combo" tree="false" width="200" default="-1" globalListProvider="DESTINATIONS" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Durée séjour RUM">
				<FIELD name="DUREE_SEJOUR_RUM" label="" UI="numberInterval" width="100" default="" default2="" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Médecin RUM">
				<FIELD name="MEDECIN_RUM" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MEDECIN_RUM"  showIfNotDefault="true" />
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_EXPERT_SELECTIONS" label="Filtres Expert" >
	
		<VIEWPROPERTIES>
		
			<PROPERTY name="EXPERT_CONTROLE_SELECT">
				<value><![CDATA[[EVAL 
					
					$mode = substr('[EXPERT_CONTROLE]',0,2);
					$oid = substr('[EXPERT_CONTROLE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[EXPERT_CONTROLE]');
						$oid = PMSI_get_classe_oid('[EXPERT_CONTROLE]');
					}
					$subselect = '';
					
					if ($mode == 'LI') {$subselect = " AND expert_controle_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = " AND expert_controle_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = " AND expert_controle_id IN (SELECT oid FROM pmsi.t_expert_controle WHERE $section_id = $oid)";}
					if ($mode == 'C*') {$subselect = " AND expert_controle_id IN (SELECT oid FROM pmsi.t_expert_controle WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					if ($mode == 'DT') {$subselect = " AND expert_controle_id = $oid ";}
					
					$mode = substr('[EXPERT_CONTROLE_GRAVITE]',0,2);
					$oid = substr('[EXPERT_CONTROLE_GRAVITE]',2);
					if ($mode == 'DT') {$subselect = "$subselect AND expert_controle_gravite_id = $oid";}
					if ($mode == 'LI' && $oid == "59") {$subselect = "$subselect AND expert_controle_gravite_id IN (5,9)";}
					
					$mode = substr('[EXPERT_CONTROLE_GRAVITE_ALERTES]',0,2);
                    $oid = substr('[EXPERT_CONTROLE_GRAVITE_ALERTES]',2);
                    if ($mode == 'D2' && $oid == "99") {$subselect = "$subselect AND alert_exp = '1'";}


                    $mode = substr('[EXPERT_CONTROLE_OPT]',0,2);
					$oid = substr('[EXPERT_CONTROLE_OPT]',2);
					if ($mode == '-1') {$subselect = "$subselect AND etat = ''";}
					if ($mode == 'LI' && $oid == "IT") {$subselect = "$subselect AND etat IN ('I','T')";}
					if ($mode == 'LI' && $oid == "_IT") {$subselect = "$subselect AND etat IN ('','I','T')";}
					if ($mode == 'DT') {$subselect = "$subselect AND etat = '$oid'";}
					
					if ('[SIGNAL_PERIODE]' != '-1') {$subselect = "$subselect AND date_signalement >= '[SIGNAL_PERIODE]'";}
					if ('[SIGNAL_TOPERIODE]' != '-1') {$subselect = "$subselect AND date_signalement <= '[SIGNAL_TOPERIODE]'";}
					
					if ('[CORRECT_PERIODE]' != '-1') {$subselect = "$subselect AND date_correction >= '[CORRECT_PERIODE]'";}
					if ('[CORRECT_TOPERIODE]' != '-1') {$subselect = "$subselect AND date_correction <= '[CORRECT_TOPERIODE]'";}
					
					if ('[GROUP_PERIODE]' != '-1') {$subselect = "$subselect AND v_rss_etat_1.date_groupage >= '[GROUP_PERIODE]'";}
					if ('[GROUP_TOPERIODE]' != '-1') {$subselect = "$subselect AND v_rss_etat_1.date_groupage <= '[GROUP_TOPERIODE]'";}
					
					return "$subselect";
					
				EVAL]]]></value>
			</PROPERTY>
		
		</VIEWPROPERTIES>
		
		<SELECTIONS label="Filtres Expert" displayText="= var display:String = '';
					if (SELECT.EXPERT_CONTROLE != '-1') {display = display + 'Controle : #B#' + SELECT.EXPERT_CONTROLE_LABEL + ' #/B#'}
					display += ' #B#' + SELECT.EXPERT_CONTROLE_OPT_LABEL + ' #/B#';
					if (SELECT.EXPERT_CONTROLE_GRAVITE != '-1') {display += ' #B#(' + SELECT.EXPERT_CONTROLE_GRAVITE_LABEL + ') #/B#'}

                    if (SELECT.EXPERT_CONTROLE_GRAVITE_ALERTES == 'D299') {display += ' #B#(' + 'Alertes' + ') #/B#'}

					if (SELECT.SIGNAL_PERIODE != '-1' &amp;&amp; SELECT.SIGNAL_TOPERIODE == '-1') {
						display += ' Signalement après #B#' + SELECT.SIGNAL_PERIODE_LABEL + ' #/B#';
					}
					if (SELECT.SIGNAL_TOPERIODE != '-1' &amp;&amp; SELECT.SIGNAL_PERIODE == '-1') {
						display += ' Signalement avant #B#' + SELECT.SIGNAL_TOPERIODE_LABEL + ' #/B#';
					}
					if (SELECT.SIGNAL_PERIODE != '-1' &amp;&amp; SELECT.SIGNAL_TOPERIODE != '-1') {
						display += ' Signalement entre #B# ' + SELECT.SIGNAL_PERIODE_LABEL + ' et ' + SELECT.SIGNAL_TOPERIODE_LABEL + ' #/B#';
					}
					
					if (SELECT.CORRECT_PERIODE != '-1' &amp;&amp; SELECT.CORRECT_TOPERIODE == '-1') {
						display += ' Correction après #B#' + SELECT.CORRECT_PERIODE_LABEL + ' #/B#';
					}
					if (SELECT.CORRECT_TOPERIODE != '-1' &amp;&amp; SELECT.CORRECT_PERIODE == '-1') {
						display += ' Correction avant #B#' + SELECT.CORRECT_TOPERIODE_LABEL + ' #/B#';
					}
					if (SELECT.CORRECT_PERIODE != '-1' &amp;&amp; SELECT.CORRECT_TOPERIODE != '-1') {
						display += ' Correction entre #B# ' + SELECT.CORRECT_PERIODE_LABEL + ' et ' + SELECT.CORRECT_TOPERIODE_LABEL + ' #/B#';
					}
					
					if (SELECT.GROUP_PERIODE != '-1' &amp;&amp; SELECT.GROUP_TOPERIODE == '-1') {
						display += ' Groupage après #B#' + SELECT.GROUP_PERIODE_LABEL +  '#/B#';
					}
					else if (SELECT.GROUP_TOPERIODE != '-1' &amp;&amp; SELECT.GROUP_PERIODE == '-1') {
						display += ' Groupage avant #B#' + SELECT.GROUP_TOPERIODE_LABEL + ' #/B#';
					}
					else if (SELECT.GROUP_PERIODE != '-1' &amp;&amp; SELECT.GROUP_TOPERIODE != '-1') {
                        if (SELECT.GROUP_PERIODE == SELECT.GROUP_TOPERIODE) {
                            display += ' Groupage le #B#' + SELECT.GROUP_PERIODE_LABEL + ' #/B#';
                        }
                        else if ((SELECT.GROUP_PERIODE2 == SELECT.GROUP_TOPERIODE2) &amp;&amp;
                                (Number(String(SELECT.GROUP_TOPERIODE).substr(8,2))) - Number(String(SELECT.GROUP_PERIODE).substr(8,2)) &gt; 7) {
                            display += ' Groupage en #B#' + SELECT.GROUP_PERIODE_LABEL + ' #/B#';
                        }
                        else {
                            display += ' Groupage entre #B#' + SELECT.GROUP_PERIODE_LABEL + ' et ' + SELECT.GROUP_TOPERIODE_LABEL + ' #/B#';
                        }
					}
					
					if (display != '') {
						display = '#B#Filtre Expert = #/B#' + display;
					}
					return display;
					">
			<GROUP label="Date Signalement">
				<FIELD name="SIGNAL_PERIODE" label="" UI="combo" tree="true" width="200" default="-1" showIfNotDefault="true" globalListProvider="SIGNAL_DATE_DEBUT" />
				<FIELD name="SIGNAL_TOPERIODE" label="à" UI="combo" tree="true" width="200" default="-1" showIfNotDefault="true" globalListProvider="SIGNAL_DATE_FIN" />
			</GROUP>
			<GROUP label="Date Correction">
				<FIELD name="CORRECT_PERIODE" label="" UI="combo" tree="true" width="200" default="-1" showIfNotDefault="true" globalListProvider="SIGNAL_DATE_DEBUT" />
				<FIELD name="CORRECT_TOPERIODE" label="à" UI="combo" tree="true" width="200" default="-1" showIfNotDefault="true" globalListProvider="SIGNAL_DATE_FIN" />
			</GROUP>
			<GROUP label="Date Groupage">
				<FIELD name="GROUP_PERIODE" label="" UI="combo" tree="true" width="200" default="-1" showIfNotDefault="true" globalListProvider="GROUP_DATE_DEBUT" />
				<FIELD name="GROUP_TOPERIODE" label="à" UI="combo" tree="true" width="200" default="-1" showIfNotDefault="true" globalListProvider="GROUP_DATE_FIN" />
			</GROUP>
			<GROUP label="Controle Expert">
				<FIELD name="EXPERT_CONTROLE" label="" UI="combo" tree="true" width="420" default="-1" globalListProvider="EXC" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Gravité">
				<FIELD name="EXPERT_CONTROLE_GRAVITE" label="" UI="combo" default="-1" tree="true">
					<OPTION label="Pas de sélection" data="-1" aliasData="1" treeLevel="1" />
					<OPTION label="Informations" data="DT0" treeLevel="1" />
					<OPTION label="Avertissements" data="DT5" treeLevel="1" />
					<OPTION label="Erreurs" data="DT9" treeLevel="1" />
					<OPTION label="Avertissements et Erreurs" data="LI59" treeLevel="1" />
				</FIELD>
			</GROUP>
            <GROUP label="Alertes expert">
                <FIELD name="EXPERT_CONTROLE_GRAVITE_ALERTES" label="Alertes" UI="check" selectedValue="D299" unselectedValue="" default="" showIfNotDefault="true" />
            </GROUP>

			<GROUP label="Option">
				<FIELD name="EXPERT_CONTROLE_OPT" label="" UI="combo" default="-1" tree="true">
					<OPTION label="Anomalies ou atypies non corrigées" data="-1" aliasData="1" treeLevel="1" />
					<OPTION label="Anomalies ou atypies corrigées et ignorées" data="LIIT" aliasData="1" treeLevel="1" />
					<OPTION label="Anomalies ou atypies corrigées" data="DTT" aliasData="1" treeLevel="1" />
					<OPTION label="Anomalies ou atypies ignorées" data="DTI" aliasData="1" treeLevel="1" />
					<OPTION label="Toutes les anomalies ou atypies" data="LI_IT" aliasData="1" treeLevel="1" />
				</FIELD>
			</GROUP>
		</SELECTIONS>
		
		<QUERIES />
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_RSS_SELECTIONS" label="Filtre RSS" >
	
		<VIEWPROPERTIES>
		
			<PROPERTY name="DMS_FIELD">
				<value><![CDATA[[EVAL 
					
					if (substr('[DMS_CLASSE]', 0, 6)  == 'GHMDMS') {
						return 'dms_ghm_' . substr('[DMS_CLASSE]', 6);
					}
					return 'dms_nationale_ghs';
					
				EVAL]]]></value>
			</PROPERTY>
            <PROPERTY name="NO_RSS_SELECT" >
                    <value><![CDATA[
                            [EVAL 
                            if ('[NO_RSS]' == '') {return "";}
                            
                            return "
                                AND v_rss_1.no_rss 
                                = ANY (
                                    string_to_array(
                                        regexp_replace(
                                                trim(
                                                    regexp_replace('[NO_RSS]', '[^0-9]', ' ', 'g')
                                                )
                                                , ' +', ' ', 'g'
                                            )
                                            , ' '
                                        )
                                    )";							
                        EVAL]
                    ]]></value>
            </PROPERTY>
			
			<PROPERTY name="PERIODE_MOIS_LIST">
					<value><![CDATA[[EVAL 
								$month_list = '';
 								$m = 0;
 								
 								$toTime = mktime(0,0,0,intval(substr('[TOPERIODE]',5,2)),intval(substr('[TOPERIODE]',8,2)),intval(substr('[TOPERIODE]',0,4)));
 								$fromTime = mktime(0,0,0,intval(substr('[PERIODE]',5,2)),intval(substr('[PERIODE]',8,2)),intval(substr('[PERIODE]',0,4)));
 								$month_list = date('Ym',$fromTime);
								
 								while ($fromTime <= $toTime && $m <= 1000) {
 									$m = $m + 1;
 									$fromTime = mktime(0,0,0,intval(substr('[PERIODE]',5,2) + $m) ,intval(substr('[PERIODE]',8,2)),intval(substr('[PERIODE]',0,4)));
 									if (date('Ym',$fromTime) <= date('Ym',$toTime)) {
 										$month_list = $month_list . ', ' . date('Ym',$fromTime);
 									}
 								}
  								return($month_list);
					EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="PERIODE_D_MOIS_LIST">
				<value><![CDATA[[EVAL 
					
					$month_list = '';
					$m = 0;
					
					$toTime = mktime(0,0,0,intval(substr('[TOPERIODE_D]',5,2)),intval(substr('[TOPERIODE_D]',8,2)),intval(substr('[TOPERIODE_D]',0,4)));
					$fromTime = mktime(0,0,0,intval(substr('[PERIODE_D]',5,2)),intval(substr('[PERIODE_D]',8,2)),intval(substr('[PERIODE_D]',0,4)));
					$month_list = date('Ym',$fromTime);
					
					while ($fromTime <= $toTime && $m <= 1000) {
						$m = $m + 1;
						$fromTime = mktime(0,0,0,intval(substr('[PERIODE_D]',5,2) + $m) ,intval(substr('[PERIODE_D]',8,2)),intval(substr('[PERIODE_D]',0,4)));
						if (date('Ym',$fromTime) <= date('Ym',$toTime)) {
							$month_list = $month_list . ', ' . date('Ym',$fromTime);
						}
					}
					
					return($month_list);
					
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="FILTRE_RSS_SELECT">
				<value><![CDATA[[EVAL 
				
						// <?php
				
						$select = '';
						
						// Grand Régime
						if ('[REGIME]' != '-1') {
							$oid = substr('[REGIME]',2);
							$select = $select. " AND v_rsf_total_1.regime_id = $oid ";
						}
						
						// Prise en charge - Séjour facturable à l'assurance maladie
						if ('[PEC]' != '-1') {
							$oid = substr('[PEC]',2);
							$select = $select. " AND v_rsf_total_1.code_pec_id = $oid ";
						}
						
						// Motif de non facturation à l'assurance maladie
						if ('[MOTIF_NON_FACTURATION]' != '-1') {
							$oid = substr('[MOTIF_NON_FACTURATION]',2);
							$select = $select. " AND v_rsf_total_1.motif_non_facturation_id = $oid ";
						}
						
						// Nature d'assurance
						if ('[NATURE_PEC]' != '-1') {
							$oid = substr('[NATURE_PEC]',2);
							$select = $select. " AND v_rsf_total_1.nature_pec_id = $oid ";
						}
						
						// Tyoe de contrat à l'organisme complémentaire
						if ('[TYPE_CONTRAT_OC]' != '-1') {
							$oid = substr('[TYPE_CONTRAT_OC]',2);
							$select = $select. " AND v_rsf_total_1.type_contrat_oc_id = $oid ";
						}
						
						// Prise en charge du forfait journalier
						if ('[PEC_FJ]' != '-1') {
							$oid = substr('[PEC_FJ]',2);
							$select = $select. " AND v_rsf_total_1.code_pec_fj_id = $oid ";
						}
						
						// Exonération du ticket modérateur
						if ('[EXONERATION_TM]' != '-1') {
							$oid = substr('[EXONERATION_TM]',2);
							$select = $select. " AND v_rsf_total_1.exoneration_tm_id = $oid ";
						}
						
						// Prise en charge forfait journalier
						if ('[FAC_18EUROS]' != '-1') {
							$oid = substr('[FAC_18EUROS]',2);
							$select = $select. " AND v_rsf_total_1.facturation_18euros_id = $oid ";
						}
						
						// Patient bénéficiaire de la CMU
						if ('[PAT_BENEF_CMU]' != '-1') {
							$oid = '[PAT_BENEF_CMU]';
							if ($oid == 'X') {
								$select = $select . " AND v_rsf_total_1.pat_benef_cmu is null ";
							}
							else {
								$select = $select . " AND v_rsf_total_1.pat_benef_cmu = $oid::integer ";
							}
						}
						
						// Valorisation FIDES
						if ('[VALORISE_FIDES]' != '-1') {
							$oid = '[VALORISE_FIDES]';
							if ($oid == 'X') {
                                $select = $select . " AND v_rsf_total_1.valorise_fides_id is null ";
							}
							else {
                                $select = $select . " AND v_rsf_total_1.valorise_fides_id = $oid::integer ";
							}
						}
						
						// Finess
						
						if ('[FINESS]' != '-1') {
							$mode = substr('[FINESS]',0,2);
							$oid = '[FINESS]';
							if ($mode == 'LS') {
								$section_id = PMSI_get_section_id('[FINESS]');
								$oid = PMSI_get_classe_oid('[FINESS]');
							}
							if ($mode != 'LI' && $mode != 'SL' && $mode != 'LS' ) {
								$mode = 'FI';
							}
							if ($mode == 'LI' || $mode == 'SL') {
								$oid = substr('[FINESS]',2);
							}
							$subselect_select = '';
							
							if ($mode == 'LI') {$subselect_select = " v_rss_1.finess_id IN (SELECT to_id FROM base.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect_select = " v_rss_1.finess_id NOT IN (SELECT to_id FROM base.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect_select = " v_rss_1.finess_id IN (SELECT oid FROM base.t_finess WHERE $section_id = $oid)";}
							if ($mode == 'FI') {$subselect_select = " v_rss_1.finess = '$oid' ";}
							
							if ($subselect_select != '') {
								$select = $select. " AND $subselect_select ";
							}
						}
						
						if ('[VIEW_DATATYPE]' != 'ETATDOSSIER') {
						
							$champ = '[CHAMP]';
							
							switch ($champ) {
								case 'EX' :
									$select .= " AND v_rss_1.en_cours = '0' ";
									break;
								case 'EXTR' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('21', '22', '23', '24', '25', '26', '30', '31', '32', '33') ";
									break;	
								case 'EXVA' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('30','31', '32', '33') ";
									break;
								case 'EXVA30' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('30') ";
									break;
								case 'EXVA3032' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('30','32') ";
									break;
								case 'EXVA31' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('31') ";
									break;
								case 'EXVA32' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('32') ";
									break;
								case 'EXVA33' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('33') ";
									break;
								case 'EXNVA' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('21', '22', '23', '24', '25', '26') ";
									break;
								case 'EXNVA21' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '21' ";
									break;
								case 'EXNVA22' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '22' ";
									break;
								case 'EXNVA23' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '23' ";
									break;
								case 'EXNVA24' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '24' ";
									break;
								case 'EXNVA25' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '25' ";
									break;
								case 'EXNVA26' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '26' ";
									break;
								case 'EXNTR' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('11', '12', '13', '14', '15') ";
									break;
								case 'EXNTR11' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '11' ";
									break;
								case 'EXNTR12' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '12' ";
									break;
								case 'EXNTR13' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '13' ";
									break;
								case 'EXNTR14' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '14' ";
									break;
								case 'EXNTR15' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '15' ";
									break;
								case 'EXNTRNVA' :
									$select .= " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('11', '12', '13', '14', '15', '21', '22', '23', '24', '25', '26') ";
									break;

								case 'NEX' :
									$select .= " AND v_rss_1.en_cours <> '0' ";
									break;
								case 'NEXSO' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('S') ";
									break;
								case 'NEXGR' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('G','V','F') ";
									break;
								case 'NEXVA' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('V','F') ";
									break;
								case 'NEXVANFA' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('V') ";
									break;
								case 'NEXFA' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('F') ";
									break;
								case 'NEXGRNFA' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('G','V') ";
									break;
								case 'NEXNFA' :
									$select .= " AND v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('S','G','V') ";
									break;	
									
								
								case 'EXNEX' :
									break;
								case 'EXNEXSO' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('S')) ";
									break;
								case 'EXNEXGR' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('G','V','F')) ";
									break;
								case 'EXNEXVA' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('V','F')) ";
									break;
								case 'EXNEXVANFA' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('V')) ";
									break;
								case 'EXNEXFA' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('F')) ";
									break;
								case 'EXNEXGRNFA' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('G','V')) ";
									break;
								case 'EXNEXNFA' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours <> '0' AND v_rss_1.en_cours_etat IN ('S','G','V')) ";
									break;		
								
								// Anciens codes pour compatibilité
								case 'EXGR' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours_etat IN ('G', 'V')) ";
									break; 
								case 'EXGV' :
									$select .= " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours_etat = 'V') ";
									break;
								case 'GR' :
									$select .= " AND v_rss_1.en_cours_etat IN ('G', 'V') ";
									break;

								
								default :
									$select .= "";
									break;
							}
						}
						
						
						// Sélection des GHM
						
						$mode = substr('[GHM]',0,2);
						$oid = substr('[GHM]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[GHM]');
							$oid = PMSI_get_classe_oid('[GHM]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.ghm_id IN (SELECT to_id FROM pmsi.t_ghm_c JOIN pmsi.t_listes_contenu ON to_id = t_ghm_c.oid WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.ghm_id NOT IN (SELECT to_id FROM pmsi.t_ghm_c JOIN pmsi.t_listes_contenu ON to_id = t_ghm_c.oid WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE $section_id = $oid)";}
						if ($mode == 'CM') {$subselect_select = " v_rss_1.cmd_id = $oid ";}
						if ($mode == 'GH') {$subselect_select = " v_rss_1.ghm_id = $oid ";}
						
						if ($mode == 'CA') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE severite_ghm_code IN ('V', 'W'))";}
						if ($mode == 'CW') {$subselect_select = " v_rss_1.ghm_id IN (SELECT to_id FROM pmsi.v_ghm_3 WHERE oid = $oid )";}
						if ($mode == 'CS') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE severite_ghm_code = 'S')";}
						if ($mode == 'SV') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE severite_ghm_code = '$oid')";}
						
						if ($mode == 'C*') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						$mode = substr('[GHM5]',0,2);
						$oid = substr('[GHM5]',2);
						if ($mode == 'C*') {$select = $select. " AND v_rss_1.ghm5_id IN (SELECT oid FROM pmsi.t_ghm5 WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'G5') {$select = $select. " AND v_rss_1.ghm5_id = $oid";}

						$mode = substr('[GHMSEV]',0,2);
						$oid = substr('[GHMSEV]',2);
						if ($mode == 'C*') {$select = $select. " AND v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm WHERE severite ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'SV') {
								if ($oid=='9'){$select = $select. " AND v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm WHERE severite IN (1,2,3,4))";}
								else {$select = $select. " AND v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm WHERE severite = '$oid')";}
								}

						// Sévérité CTI 
                        $oid = substr('[CTISEV]',0);
                        if($oid != '-1'){$select = $select. " AND v_rss_1.severite_cti_code = $oid";}
                        
                        
						
						// Sélection des GHS
						
						$mode = substr('[GHS]',0,2);
						$oid = substr('[GHS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[GHS]');
							$oid = PMSI_get_classe_oid('[GHS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.ghs_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.ghs_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = " v_rss_1.ghs_id IN (SELECT oid FROM pmsi.t_ghs WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'GS') {$subselect_select = " v_rss_1.ghs_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						if (substr('[OAP]',0,2) == 'PO') {
							$select = $select. ' AND v_rss_1.pole_oap_id = ' . substr('[OAP]',2);
						}
						if (substr('[OAP]',0,2) == 'LO') {
							$select = $select. ' AND v_rss_1.ligne_oap_id = ' . substr('[OAP]',2);
						}
						
						if (substr('[GA]',0,2) == 'GA') {
							$select = $select. ' AND v_rss_1.groupe_activite_id = ' . substr('[GA]',2);
						}
						

						$mcosToOmit = array();
						if ('[MCO_M]' != 'M') {
							$mcosToOmit[] = "M";
						}
						if ('[MCO_C]' != 'C') {
							$mcosToOmit[] = "C";
						}
						if ('[MCO_O]' != 'O') {
							$mcosToOmit[] = "O";
						}
						if ('[MCO_S]' != 'S') {
							$mcosToOmit[] = "S";
						}
						if ('[MCO_H]' != '*') {
							$mcosToOmit[] = "*";
						}
						if (!empty($mcosToOmit)) {
							$mcosToOmitString = "'".implode("','",$mcosToOmit)."'";
							$select .= " AND v_rss_1.mcos_code <> ALL(ARRAY[$mcosToOmitString]) "; 
						}
						
					// Catégories d'activités de soins
						
						$casToOmit = array();
						if ('[CAS_C]' != 'C') {
							$casToOmit[] = "C";
						}
						if ('[CAS_K]' != 'K') {
							$casToOmit[] = "K";
						}
						if ('[CAS_X]' != 'X') {
							$casToOmit[] = "X";
						}
						if ('[CAS_N]' != 'N') {
							$casToOmit[] = "N";
						}
						if ('[CAS_O]' != 'O') {
							$casToOmit[] = "O";
						}
						if ('[CAS_S]' != 'S') {
							$casToOmit[] = "S";
						}
						if ('[CAS_W]' != '*') {
							$casToOmit[] = "*";
							$casToOmit[] = "?";
						}
						
						if (!empty($casToOmit)) {
							$casToOmitString = "'".implode("','",$casToOmit)."'";
							$select .= " AND v_rss_1.cas_code <> ALL(ARRAY[$casToOmitString]) "; 
						}
						
						if ('[ACT_URG]' == '*') {
							$select .= " AND activite_urgence = '1' ";
						}						

						
						// Sélection des paramètres personnalisés
						
						$mode = substr('[PARAMETRE_PERSONNALISE_RSS_1]',0,2);
						$oid = substr('[PARAMETRE_PERSONNALISE_RSS_1]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[PARAMETRE_PERSONNALISE_RSS_1]');
							$oid = PMSI_get_classe_oid('[PARAMETRE_PERSONNALISE_RSS_1]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_parametres_personnalises_1.parametre_personnalise_1_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_parametres_personnalises_1.parametre_personnalise_1_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_parametres_personnalises_1.parametre_personnalise_1_id IN (SELECT oid FROM pmsi.t_parametre_personnalise_rss_1 WHERE $section_id = $oid)";}
						if ($mode == 'DT') {$subselect_select = " v_rss_parametres_personnalises_1.parametre_personnalise_1_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						$mode = substr('[PARAMETRE_PERSONNALISE_RSS_2]',0,2);
						$oid = substr('[PARAMETRE_PERSONNALISE_RSS_2]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[PARAMETRE_PERSONNALISE_RSS_2]');
							$oid = PMSI_get_classe_oid('[PARAMETRE_PERSONNALISE_RSS_2]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_parametres_personnalises_2.parametre_personnalise_2_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_parametres_personnalises_2.parametre_personnalise_2_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_parametres_personnalises_2.parametre_personnalise_2_id IN (SELECT oid FROM pmsi.t_parametre_personnalise_rss_2 WHERE $section_id = $oid)";}
						if ($mode == 'DT') {$subselect_select = " v_rss_parametres_personnalises_2.parametre_personnalise_2_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						
						// Sélection des médecins
						
						$mode = substr('[MEDECIN_RSS]',0,2);
						$oid = substr('[MEDECIN_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[MEDECIN_RSS]');
							$oid = PMSI_get_classe_oid('[MEDECIN_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.medecin_rss_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.medecin_rss_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.medecin_rss_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
						if ($mode == 'SP') {$subselect_select = " v_medecin_rss_link.specialite_interne_medecin_reference_rss_id = $oid ";}
						if ($mode == 'SO') {$subselect_select = " v_medecin_rss_link.specialite_medecin_rss_id = $oid ";}
						if ($mode == 'C*') {$subselect_select = " v_rss_1.medecin_rss_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'MD') {$subselect_select = " v_medecin_rss_link.medecin_reference_rss_id = $oid ";}
						if ($mode == 'DT') {$subselect_select = " v_medecin_rss_link.medecin_reference_rss_id = $oid ";}
						if ($mode == 'D2') {$subselect_select = " v_medecin_rss_link.specialite_interne_medecin_reference_rss_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						
						// Comités médicaux
						
						$mode = substr('[COMITE_MEDICAL]',0,2);
						$oid = substr('[COMITE_MEDICAL]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[COMITE_MEDICAL]');
							$oid = PMSI_get_classe_oid('[COMITE_MEDICAL]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.comite_medical_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.comite_medical_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.comite_medical_id IN (SELECT oid FROM pmsi.t_comites_medicaux WHERE $section_id = $oid)";}
						if ($mode == 'CM') {$subselect_select = " v_rss_1.comite_medical_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						
						// Sélection des Modes d'entrée, modes de sortie, provenances et destinations
						// Les ComboBoxes MEN_PROV_RSS_RUM et MSO_DEST_RSS_RUM permettent de choisir si on veut filtrer
						// les modes d'entrées/Provenances et les modes de sortie/destinations sur les enregistrements RSS ou sur les RUM
						
						if (substr('[MODE_ENTREE]',0,1) == 'I') {
							if ('[MEN_PROV_RSS_RUM]' == 'RUM') {
								if(substr('[MODE_ENTREE]',1) == 'T'){
									$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.mode_entree_rum in ('0','7'))";
								}
								else {
									$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.mode_entree_rum = '" . substr('[MODE_ENTREE]',1) . "')";
								}
							}
							else if(substr('[MODE_ENTREE]',1) == 'T'){
								$select = $select. " AND v_rss_1.mode_entree in ('0','7')";
							}else{
								$select = $select. " AND v_rss_1.mode_entree = '" . substr('[MODE_ENTREE]',1) . "'";
							}
						}
						if (substr('[MODE_ENTREE]',0,1) == 'S') {
							if ('[MEN_PROV_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.mode_entree_rum <> '" . substr('[MODE_ENTREE]',1) . "')";
							}
							$select = $select. " AND v_rss_1.mode_entree <> '" . substr('[MODE_ENTREE]',1) . "'";
						}
						if (substr('[MODE_SORTIE]',0,1) == 'I') {
							if ('[MSO_DEST_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.mode_sortie_rum = '" . substr('[MODE_SORTIE]',1) . "')";
							}
							else
								$select = $select. " AND v_rss_1.mode_sortie = '" . substr('[MODE_SORTIE]',1) . "'";
						}
						if (substr('[MODE_SORTIE]',0,1) == 'S') {
							if ('[MSO_DEST_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.mode_sortie_rum <> '" . substr('[MODE_SORTIE]',1) . "')";
							}
							$select = $select. " AND v_rss_1.mode_sortie <> '" . substr('[MODE_SORTIE]',1) . "'";
						}
						if (substr('[PROVENANCE]',0,1) == 'I' && strlen('[PROVENANCE]') > 1) {
							if ('[MEN_PROV_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.provenance_rum = '" . substr('[PROVENANCE]',1) . "')";
							}
							else 
								$select = $select. " AND v_rss_1.provenance = '" . substr('[PROVENANCE]',1) . "'";
						}
						if (substr('[PROVENANCE]',0,1) == 'S' && strlen('[PROVENANCE]') > 1) {
							if ('[MEN_PROV_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.provenance_rum  <> '" . substr('[PROVENANCE]',1) . "')";
							}
							$select = $select. " AND v_rss_1.provenance <> '" . substr('[PROVENANCE]',1) . "'";
						}
						if (substr('[DESTINATION]',0,1) == 'I' && strlen('[DESTINATION]') > 1) {
							if ('[MSO_DEST_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.destination_rum = '" . substr('[DESTINATION]',1) . "')";
							}
							$select = $select. " AND v_rss_1.destination = '" . substr('[DESTINATION]',1) . "'";
						}
						if (substr('[DESTINATION]',0,1) == 'S' && strlen('[DESTINATION]') > 1) {
							if ('[MSO_DEST_RSS_RUM]' == 'RUM') {
								$select = $select . " AND v_rss_1.no_rss in ( SELECT distinct no_rss from pmsi.v_rss_rum_2 WHERE v_rss_rum_2.destination_rum <> '" . substr('[DESTINATION]',1) . "')";
							}
							$select = $select. " AND v_rss_1.destination <> '" . substr('[DESTINATION]',1) . "'";
						}
                        
						// Etablissement de provenance
						
                        $oid = '[ETAB_PROVE]';
                        if('[ETAB_PROVE]' != '-1'){
							if('[ETAB_PROVE]' == 'SANS'){
								$select = $select ." AND (etablissement_provenance_code is null OR etablissement_provenance_code ilike '%**%')";
							}else  if('[ETAB_PROVE]' == 'AVEC'){
								$select = $select ." AND etablissement_provenance_code IS DISTINCT FROM NULL";
                                    }else {
                                        $select = $select ." AND etablissement_provenance_id = $oid";
                                    }
                        }    
                        
						// Etablissement de destination
						
                        $oid = '[ETAB_DEST]';
						if('[ETAB_DEST]' != '-1'){
							if('[ETAB_DEST]' == 'SANS'){
								$select = $select ." AND (etablissement_destination_code is null OR etablissement_destination_code ilike '%**%')";
							}else  if('[ETAB_DEST]' == 'AVEC'){
                                            $select = $select ." AND etablissement_destination_code IS DISTINCT FROM NULL";
                                    }else {
                                        $select = $select ." AND etablissement_destination_id = $oid";
                                    }
                        }


						// Type de séjour OVALIDE
                        
                        if('[T_TYPE_SEJ_OVALIDE]' == '1'){
                                $select = $select."AND type_sejour_ovalide = '1'";
                            }else if ('[T_TYPE_SEJ_OVALIDE]' == '2'){
                                $select = $select."AND type_sejour_ovalide = '2'";
                            }else if ('[T_TYPE_SEJ_OVALIDE]' == '3'){
                                $select = $select."AND type_sejour_ovalide = '3'";
                            }                      
                            
                        // Conversion HP,HC
                        $oid = substr('[F_HPHC]',2);
                        if('[F_HPHC]' != '-1'){
							if('[F_HPHC]' == 'CO5'){
									$select = $select."AND v_rss_1.conversion_hp_hc_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.conversion_hp_hc_id = $oid ";
                            }
						}

						// CA_GHS_EXH
						if ('[F_CA_GHS_EXH]' != '-1') {
							
							if ('[F_CA_GHS_EXH]' == 'INTERVAL'){
								// Intervalle
								if('[CA_GHS_EXH_I]' != ''){
									$select .= ' AND v_rss_1.ca_ghs + v_rss_1.ca_exh >= ' . intval('[CA_GHS_EXH_I]');
									if('[CA_GHS_EXH_I2]' != ''){
										$select .= ' AND v_rss_1.ca_ghs + v_rss_1.ca_exh <= ' . intval('[CA_GHS_EXH_I2]');
									}
								}else{
									$select .= ' AND v_rss_1.ca_ghs + v_rss_1.ca_exh <= ' . intval('[CA_GHS_EXH2]');
								}
							}
							
							//Greater / Lower 
							if ('[F_CA_GHS_EXH]' == 'GREATER'){
								$select .= ' AND v_rss_1.ca_ghs + v_rss_1.ca_exh >= ' . intval('[CA_GHS_EXH_GL]');
							}

							if ('[F_CA_GHS_EXH]' == 'LOWER'){
								$select .= ' AND v_rss_1.ca_ghs + v_rss_1.ca_exh <= ' . intval('[CA_GHS_EXH_GL]');
							}
						}
						

						// RAAC
                        $oid = substr('[F_RAAC]',2);
                        if('[F_RAAC]' != '-1'){
							if('[F_RAAC]' == 'RA5'){
									$select = $select."AND v_rss_1.raac_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.raac_id = $oid ";
                            }
						}

						// NP
                        $oid = substr('[F_NP]',2);
                        if('[F_NP]' != '-1'){
							if('[F_NP]' == 'NP5'){
									$select = $select."AND v_rss_1.np_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.np_id = $oid ";
                            }
						}  

						// PASSAGE URGENCE
                        $oid = substr('[F_PASSAGE_URGENCES]', 3);		
						if( '[F_PASSAGE_URGENCES]'  != '-1'){
							if('[F_PASSAGE_URGENCES]' == 'URG5'){
								$select = $select."AND v_passage_urgences_link.passage_urgences_id != 0 ";
							}else{
                                $select = $select."AND v_passage_urgences_link.passage_urgences_id = $oid ";
                            }
                        }
                                            
							
						// rescrit tarifaire
                        $oid = substr('[F_RESC_TARIF]',2);
                        if('[F_RESC_TARIF]' != '-1'){
							if('[F_RESC_TARIF]' == 'RT5'){
                                $select = $select."AND v_rss_1.rescrit_tarif_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.rescrit_tarif_id = $oid ";
							}
                        }    						
						
						// variable administration de produits de la réserve hospitalière
                        $oid = substr('[F_ADM_PROD_RESHOSPI]',2);
                        if('[F_ADM_PROD_RESHOSPI]' != '-1'){
							if('[F_ADM_PROD_RESHOSPI]' == 'AP5'){
                                $select = $select."AND v_rss_1.adm_prod_reshospi_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.adm_prod_reshospi_id = $oid ";
							}
                        }
						
						// La variable contexte du patient
                        $oid = substr('[F_CTX_PAT]',2);
                        if('[F_CTX_PAT]' != '-1'){
							if('[F_CTX_PAT]' == 'CP5'){
                                $select = $select."AND v_rss_1.contexte_pat_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.contexte_pat_id = $oid ";
							}
                        }
						
						// Nombre d'intervention
                        $oid = substr('[F_NB_INTERV]',2);
                        if('[F_NB_INTERV]' != '-1'){
							if('[F_NB_INTERV]' == 'NI5'){
                                $select = $select."AND v_rss_1.nb_intervention_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.nb_intervention_id = $oid ";
							}
                        }
						
						
						// Sélection des durées
						
						$mode = substr('[T_DUREE_SEJOUR]',0,2);
						$oid = substr('[T_DUREE_SEJOUR]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[T_DUREE_SEJOUR]');
							$oid = PMSI_get_classe_oid('[T_DUREE_SEJOUR]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.duree_sejour IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.duree_sejour NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.duree_sejour IN (SELECT oid FROM pmsi.t_durees_sejour_c WHERE $section_id = $oid)";}
						if ($mode == 'DU') {$subselect_select = " v_rss_1.duree_sejour = $oid ";}
						
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						else {
							
							// Anciennes codifications
							if ('[T_DUREE_SEJOUR]' == '0') {
								$select = $select. ' AND v_rss_1.duree_sejour = 0';
							}
							if ('x[T_DUREE_SEJOUR]x' == 'x1x') {
								$select = $select. ' AND v_rss_1.duree_sejour = 1';
							}
							if ('[T_DUREE_SEJOUR]' == '1EX') {
								$select = $select. ' AND v_rss_1.duree_sejour >= 1';
							}
							if ('[T_DUREE_SEJOUR]' == '01') {
								$select = $select. ' AND v_rss_1.duree_sejour <= 1';
							}
							if ('[T_DUREE_SEJOUR]' == '012') {
								$select = $select. ' AND v_rss_1.duree_sejour <= 2';
							}
							if ('[T_DUREE_SEJOUR]' == '1X') {
								$select = $select. ' AND v_rss_1.duree_sejour > 1';
							}
							if ('[T_DUREE_SEJOUR]' == '2') {
								$select = $select. ' AND v_rss_1.duree_sejour = 2';
							}
							if ('[T_DUREE_SEJOUR]' == 'X') {
								$select = $select. ' AND v_rss_1.duree_sejour > 2';
							}
							if ('[T_DUREE_SEJOUR]' == 'S') {
								$select = $select. ' AND v_rss_1.nb_seances > 0';
							}
							if ('[T_DUREE_SEJOUR]' == 'SS') {
								$select = $select. ' AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR]' == 'SAMB') {
								$select = $select. ' AND (v_rss_1.nb_seances > 0 OR v_rss_1.duree_sejour = 0)';
							}
							if ('[T_DUREE_SEJOUR]' == 'I' && '[DUREE_SEJOUR]' != '' ) {
								$select = $select. ' AND v_rss_1.duree_sejour >= ' . intval('[DUREE_SEJOUR]');
							}
							if ('[T_DUREE_SEJOUR]' == 'I' && '[DUREE_SEJOUR2]' != '' ) {
								$select = $select. ' AND v_rss_1.duree_sejour <= ' . intval('[DUREE_SEJOUR2]');
							}
						
						}
						
						// Sélection taux remboursement
						if ('[TAUX_REMB]' != '' && '[TAUX_REMB2]' != '' ) {
							$select = $select. ' AND v_rss_1.taux_remboursement >= ' . intval('[TAUX_REMB]') . ' AND v_rss_1.taux_remboursement <= ' . intval('[TAUX_REMB2]');
						}
						if ('[TAUX_REMB]' != '' && '[TAUX_REMB2]' == '') {
							$select = $select. ' AND v_rss_1.taux_remboursement = ' . intval('[TAUX_REMB]');
						}
						if ('[TAUX_REMB2]' != '' && '[TAUX_REMB]' == '') {
							$select = $select. ' AND v_rss_1.taux_remboursement <= ' . intval('[TAUX_REMB2]');
						}
						
						
						
						// Ecart par rapport à la DMS
						
						if('[T_ECART_DMS]' != '-1') {
							$operator = '';
							$field1 = '[ECART_DMS_FIELD1]';
							$field2 = '[ECART_DMS_FIELD2]';
							switch([ECART_DMS_OPERATOR]){
								case 1 :
									$operator = '= '.$field1;
									break;
								case 2 :
									$operator = '>= '.$field1;
									break;
								case 3 :
									$operator = '<= '.$field1;
									break;
								case 4 :
									// Si la borne inf est plus grande que la borne sup, on inverse les bornes
									if (intval($field1) > intval($field2))
										$operator = 'BETWEEN '.$field2.' AND '.$field1;
									else
										$operator = 'BETWEEN '.$field1.' AND '.$field2;
									break;
								case 5 :
									$operator = '<> '.$field1;
									break;
							}
							$select = $select . ' AND ecart_[VIEW.DMS_FIELD] ' . $operator . ' AND v_rss_1.nb_seances = 0';
						}
						
						// Nb de diagnostics

						if ('[T_NB_DIAG_RSS]' != '-1') {
							$field1 = trim('[NB_DIAG_RSS]');
							$field2 = trim('[NB_DIAG_RSS2]');
							$type = '[T_NB_DIAG2_RSS]';
							$diag_count = '';
							$diag_select = '';  
							
							if ($field1 != '' && $field2 != '') {
								$diag_count .= "AND count(diagnostic_id) BETWEEN $field1 AND $field2";
							} else if ($field1 != '' && $field2 == '') {
								$diag_count .= "AND count(diagnostic_id) >= $field1";
							} else if ($field1 == '' && $field2 != '') {
								$diag_count .= "AND count(diagnostic_id) <= $field2";
							} 

					    
							
							switch ($type) {
								case 'D' :
									// Tout diagnostic => pas de filtrage.
									break; 
								case 'DHDD' :
									$diag_select .= "AND type_diagnostic != 'DD'";
									break;
								case 'DP' :
									$diag_select .= "AND type_diagnostic_rss = 'DP'";
									break;
								case 'DPRRSS' :
									$diag_select .= "AND type_diagnostic_rss IN ('DP', 'DR')";
									break;
								case 'DR' :
									$diag_select .= "AND type_diagnostic_rss = 'DR'";
									break;
								case 'DARSS' :
									$diag_select .= "AND type_diagnostic_rss = 'DA'";
									break;
								case 'DP2' :
									$diag_select .= "AND type_diagnostic = 'DP'";
									break;
								case 'DPR' :
									$diag_select .= "AND type_diagnostic IN ('DP', 'DR')";
									break;
								case 'DRRUM' :
									$diag_select .= "AND type_diagnostic = 'DR'";
									break;
								case 'DA' :
									$diag_select .= "AND type_diagnostic IN ('DA', 'DS')";
									break;
								case 'DD' :
									$diag_select .= "AND type_diagnostic = 'DD'";
									break;
							}
							
							$select .= "
								AND v_rss_1.rss_id IN (
									SELECT rss_id
									FROM pmsi.p_rss_diagnostics 
									WHERE 1=1
										$diag_select
									GROUP BY 1
									HAVING 1=1
										$diag_count
									)
							";
						}
						
						// Type de diagnostic
						if ('[T_DIAG_1_RSS]' != '-1') {
							$mode = substr('[DIAG_1_RSS]',0,2);
							$oid = substr('[DIAG_1_RSS]',2);
							if ($mode == 'LS') {
								$section_id = PMSI_get_section_id('[DIAG_1_RSS]');
								$oid = PMSI_get_classe_oid('[DIAG_1_RSS]');
							}
							$diag_select = '';
							
							if ('[T_DIAG_1_RSS]' == 'DP' || '[T_DIAG_1_RSS]' == 'DR') {
								if ('[T_DIAG_1_RSS]' == 'DP') {
									if ($mode == 'LI') {$diag_select = "diagnostic_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_principal_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								else {
									if ($mode == 'LI') {$diag_select = "diagnostic_relie_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_relie_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_relie_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								if ($diag_select != '') {
									$select = $select. " AND v_rss_1.$diag_select";
								}
							}
							else {
								if ($mode == 'LI') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'SL') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'DG') {$diag_select = "diagnostic_id = $oid ";}
								if ($mode == 'DR') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
								if ($mode == 'LS') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
								if ($mode == 'C*') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								
								if ('[T_DIAG_1_RSS]' == 'DRRUM') {$diag_select = $diag_select . " AND type_diagnostic = 'DR' ";}
								if ('[T_DIAG_1_RSS]' == 'DA') {$diag_select = $diag_select . " AND type_diagnostic IN ('DA', 'DS') ";}
								if ('[T_DIAG_1_RSS]' == 'DPR') {$diag_select = $diag_select . " AND type_diagnostic IN ('DP', 'DR') ";}
								if ('[T_DIAG_1_RSS]' == 'DP2') {$diag_select = $diag_select . " AND type_diagnostic = 'DP' ";}
								if ('[T_DIAG_1_RSS]' == 'DD') {$diag_select = $diag_select . " AND type_diagnostic = 'DD' ";}
								if ('[T_DIAG_1_RSS]' == 'DHDD') {$diag_select = $diag_select . " AND type_diagnostic != 'DD' ";}
								if ('[T_DIAG_1_RSS]' == 'DPRRSS') {$diag_select = $diag_select . " AND type_diagnostic_rss IN ('DP', 'DR') ";}
								if ('[T_DIAG_1_RSS]' == 'DARSS') {$diag_select = $diag_select . " AND type_diagnostic_rss = 'DA' ";}
								
								if ($diag_select != '') {
									if ($mode != 'SL') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
								}
							}
						}
						
						if ('[T_DIAG_2_RSS]' != '-1') {
							$mode = substr('[DIAG_2_RSS]',0,2);
							$oid = substr('[DIAG_2_RSS]',2);
							if ($mode == 'LS') {
								$section_id = PMSI_get_section_id('[DIAG_2_RSS]');
								$oid = PMSI_get_classe_oid('[DIAG_2_RSS]');
							}
							$diag_select = '';
							
							if ('[T_DIAG_2_RSS]' == 'DP' || '[T_DIAG_2_RSS]' == 'DR') {
								if ('[T_DIAG_2_RSS]' == 'DP') {
									if ($mode == 'LI') {$diag_select = "diagnostic_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_principal_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								else {
									if ($mode == 'LI') {$diag_select = "diagnostic_relie_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_relie_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_relie_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								if ($diag_select != '') {
									$select = $select. " AND v_rss_1.$diag_select";
								}
							}
							else {
								if ($mode == 'LI') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'SL') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'DG') {$diag_select = "diagnostic_id = $oid ";}
								if ($mode == 'DR') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
								if ($mode == 'LS') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
								if ($mode == 'C*') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								
								if ('[T_DIAG_2_RSS]' == 'DRRUM') {$diag_select = $diag_select . " AND type_diagnostic = 'DR' ";}
								if ('[T_DIAG_2_RSS]' == 'DA') {$diag_select = $diag_select . " AND type_diagnostic IN ('DA', 'DS') ";}
								if ('[T_DIAG_2_RSS]' == 'DPR') {$diag_select = $diag_select . " AND type_diagnostic IN ('DP', 'DR') ";}
								if ('[T_DIAG_2_RSS]' == 'DP2') {$diag_select = $diag_select . " AND type_diagnostic = 'DP' ";}
								if ('[T_DIAG_2_RSS]' == 'DD') {$diag_select = $diag_select . " AND type_diagnostic = 'DD' ";}
								if ('[T_DIAG_2_RSS]' == 'DHDD') {$diag_select = $diag_select . " AND type_diagnostic != 'DD' ";}
								if ('[T_DIAG_2_RSS]' == 'DPRRSS') {$diag_select = $diag_select . " AND type_diagnostic_rss IN ('DP', 'DR') ";}
								if ('[T_DIAG_2_RSS]' == 'DARSS') {$diag_select = $diag_select . " AND type_diagnostic_rss = 'DA' ";}
								
								if ($diag_select != '') {
									if ($mode != 'SL') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
								}
							}
						}
						
						
						
						// Type facturation
						$mode = substr('[TYPFAC]',0,2);
						$oid = substr('[TYPFAC]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[TYPFAC]', 2, 2, 'type_facturation_section_id');
							$oid = PMSI_get_classe_oid('[TYPFAC]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.prestation_principale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.prestation_principale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.prestation_principale_id IN (SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)";}
						if ($mode == 'DT') {$subselect_select = " v_rss_1.prestation_principale_id = $oid ";}
						if ($mode == 'PR') {$subselect_select = " v_rss_1.prestation_principale_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						if ('[SEXE]' != '-1') {
							$select = $select. ' AND v_rss_1.sexe = ' .''. '[SEXE]' .''. ' ';
						}
						
						
						
						// Sélection des AGES
						
						$mode = substr('[T_AGE]',0,2);
						$oid = substr('[T_AGE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[T_AGE]');
							$oid = PMSI_get_classe_oid('[T_AGE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.age IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.age NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.age IN (SELECT oid FROM pmsi.t_ages_c WHERE $section_id = $oid)";}
						if ($mode == 'AG') {$subselect_select = " v_rss_1.age = $oid ";}
						
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						else {
						
							// Anciennes codifications
							if ('[T_AGE]' == '0') {
								$select = $select. ' AND v_rss_1.age = 0';
							}
							if ('[T_AGE]' == '1') {
								$select = $select. ' AND v_rss_1.age >= 1 AND v_rss_1.age <= 5' ;
							}
							if ('[T_AGE]' == '6') {
								$select = $select. ' AND v_rss_1.age >= 6 AND v_rss_1.age <= 12' ;}
							if ('[T_AGE]' == '13') {
								$select = $select. ' AND v_rss_1.age >= 13 AND v_rss_1.age <= 20' ;
							}
							if ('[T_AGE]' == '21') {
								$select = $select. ' AND v_rss_1.age >= 21 AND v_rss_1.age <= 30' ;
							}
							if ('[T_AGE]' == '31') {
								$select = $select. ' AND v_rss_1.age >= 31 AND v_rss_1.age <= 40' ;
							}
							if ('[T_AGE]' == '41') {
								$select = $select. ' AND v_rss_1.age >= 41 AND v_rss_1.age <= 50' ;
							}
							if ('[T_AGE]' == '51') {
								$select = $select. ' AND v_rss_1.age >= 51 AND v_rss_1.age <= 60' ;
							}
							if ('[T_AGE]' == '61') {
								$select = $select. ' AND v_rss_1.age >= 61 AND v_rss_1.age <= 70' ;
							}
							if ('[T_AGE]' == '71') {
								$select = $select. ' AND v_rss_1.age >= 71 AND v_rss_1.age <= 80' ;
							}
							if ('[T_AGE]' == '81') {
								$select = $select. ' AND v_rss_1.age >= 81' ;
							}
							if ('[T_AGE]' == 'I' && '[AGE]' != '' && '[AGE2]' != '' ) {
								$select = $select. ' AND v_rss_1.age >= ' . intval('[AGE]') . ' AND v_rss_1.age <= ' . intval('[AGE2]');
							}
							if ('[T_AGE]' == 'I' && '[AGE]' != '' ) {
								$select = $select. ' AND v_rss_1.age >= ' . intval('[AGE]');
							}
							if ('[T_AGE]' == 'I' && '[AGE2]' != '' ) {
								$select = $select. ' AND v_rss_1.age <= ' . intval('[AGE2]');
							}
						
						}
						
						// Sélection des âges en jours
						
						$mode = substr('[T_AGE_JOURS]',0,2);
						$oid = substr('[T_AGE_JOURS]',2);
						$subselect_select = '';
						
						if ($mode == 'AJ') {$subselect_select = " v_rsa_1.age_jours = $oid ";}
						
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						else {
						
							if ('[T_AGE_JOURS]' == 'I' && '[AGE_JOURS]' != '' && '[AGE_JOURS2]' != '' ) {
								$select = $select. ' AND v_rsa_1.age_jours >= ' . intval('[AGE_JOURS]') . ' AND v_rsa_1.age_jours <= ' . intval('[AGE_JOURS2]');
							}
							if ('[T_AGE_JOURS]' == 'I' && '[AGE_JOURS]' != '' ) {
								$select = $select. ' AND v_rsa_1.age_jours >= ' . intval('[AGE_JOURS]');
							}
							if ('[T_AGE_JOURS]' == 'I' && '[AGE_JOURS2]' != '' ) {
								$select = $select. ' AND v_rsa_1.age_jours BETWEEN 0 AND ' . intval('[AGE_JOURS2]');
							}
						
						}
						
						if ('[T_GEST]' != '-1') {
							if('[GEST]' != ''){
								$select .= ' AND v_rss_1.age_gestationnel >= ' . intval('[GEST]');
								if('[GEST2]' != ''){
									$select .= ' AND v_rss_1.age_gestationnel <= ' . intval('[GEST2]');
								}
							}else{
								$select .= ' AND v_rss_1.age_gestationnel <= ' . intval('[GEST2]');
							}
						}
						
						if ('[T_POIDS_BEBE]' != '-1') {
							if('[POIDS_BEBE]' != ''){
								$select .= ' AND v_rss_1.poids_bebe >= ' . intval('[POIDS_BEBE]');
								if('[POIDS_BEBE2]' != ''){
									$select .= ' AND v_rss_1.poids_bebe <= ' . intval('[POIDS_BEBE2]');
								}
							}else{
								$select .= ' AND v_rss_1.poids_bebe <= ' . intval('[POIDS_BEBE2]');
							}
						}
						
						if ('[NIP]' != '' && Number([NIP]) > 0) {
							$select .= " AND no_patient IN (".str_replace(' ',',','[NIP]').")";				
						}
						// LPP
						
						$mode = substr('[LPP_RSS]',0,2);
						$oid = substr('[LPP_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[LPP_RSS]');
							$oid = PMSI_get_classe_oid('[LPP_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "lpp_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "lpp_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LP') {$subselect_select = "lpp_id = $oid ";}
						if ($mode == 'LS') {$subselect_select = "lpp_id IN (SELECT oid FROM pmsi.t_lpp WHERE $section_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = "lpp_id IN (SELECT oid FROM pmsi.t_lpp WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_lpp WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_lpp WHERE $subselect_select)";
							}
						}
						
						// Listes RSS
						
						$mode = substr('[LIRSS]',0,2);
						$oid = substr('[LIRSS]',2);
						
						if ($mode == 'F5') {$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_fiche5_rss WHERE enquete_id = $oid)";}
						

                        // Etat RSS
						
						$mode = substr('[ETAT_RSS]',0,2);
						$oid = substr('[ETAT_RSS]',2);
                        
						
						$subselect_select = '';
                        
                        
                        if ($mode == 'SL') {$subselect_select = "v_rss_1.etat_sejour = '$oid'";}
						
                        if ($subselect_select != '') {
							
								$select = $select. " AND $subselect_select";
							
						}
                        
                        
						// UCD
						
						$mode = substr('[UCD_RSS]',0,2);
						$oid = substr('[UCD_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UCD_RSS]');
							$oid = PMSI_get_classe_oid('[UCD_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "ucd_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "ucd_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'UC') {$subselect_select = "ucd_id = $oid ";}
						if ($mode == 'LS') {$subselect_select = "ucd_id IN (SELECT oid FROM pmsi.t_ucd WHERE $section_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = "ucd_id IN (SELECT oid FROM pmsi.t_ucd WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_ucd WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_ucd WHERE $subselect_select)";
							}
						}						
                        
                        // Indication UCD RSS
						
						$mode = substr('[IUCD_RSS]',0,2);
						$oid = substr('[IUCD_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[IUCD_RSS]');
							$oid = PMSI_get_classe_oid('[IUCD_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "indication_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "indication_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'IU') {$subselect_select = "indication_id = $oid ";}
						if ($mode == 'LS') {$subselect_select = "indication_id IN (SELECT oid FROM pmsi.t_indication WHERE $section_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = "indication_id IN (SELECT oid FROM pmsi.t_indication WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id = ANY (SELECT rss_id FROM pmsi.p_rss_ucd WHERE $subselect_select GROUP BY 1)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id <> ALL (SELECT rss_id FROM pmsi.p_rss_ucd WHERE $subselect_select GROUP BY 1)";
							}
						}
						
						
						
						// 1ère UM 
						
						$mode = substr('[PREMIERE_UM]',0,2);
						$oid = substr('[PREMIERE_UM]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[PREMIERE_UM]');
							$oid = PMSI_get_classe_oid('[PREMIERE_UM]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id = ANY(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'SL') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id != ALL(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'LS') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)::bigint[])";}
						if ($mode == 'AN') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')::bigint[])";}
						if ($mode == 'AT') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')::bigint[])";}
						if ($mode == 'AU') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')::bigint[])";}
						if ($mode == 'UM') {$subselect_select = " v_premiere_unite_medicale_link.premiere_unite_medicale_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}						
                        
                        // Unité principale
						
						$mode = substr('[UM_PRINCIPALE]',0,2);
						$oid = substr('[UM_PRINCIPALE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UM_PRINCIPALE]');
							$oid = PMSI_get_classe_oid('[UM_PRINCIPALE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.unite_medicale_principale_id = ANY(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.unite_medicale_principale_id != ALL(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.unite_medicale_principale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)::bigint[])";}
						if ($mode == 'AN') {$subselect_select = " v_rss_1.unite_medicale_principale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')::bigint[])";}
						if ($mode == 'AT') {$subselect_select = " v_rss_1.unite_medicale_principale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')::bigint[])";}
						if ($mode == 'AU') {$subselect_select = " v_rss_1.unite_medicale_principale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')::bigint[])";}
						if ($mode == 'UM') {$subselect_select = " v_rss_1.unite_medicale_principale_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
                        
                        // Pole principal
						
						$mode = substr('[POLE_PRINCIPAL]',0,2);
						$oid = substr('[POLE_PRINCIPAL]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[POLE_PRINCIPAL]');
							$oid = PMSI_get_classe_oid('[POLE_PRINCIPAL]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " pole_principal_id = ANY(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'SL') {$subselect_select = " pole_principal_id != ALL(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'LS') {$subselect_select = " pole_principal_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)::bigint[])";}
						if ($mode == 'DT') {$subselect_select = " pole_principal_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						
						$mode = substr('[UM_RSS]',0,2);
						$oid = substr('[UM_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UM_RSS]');
							$oid = PMSI_get_classe_oid('[UM_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
						if ($mode == 'AN') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
						if ($mode == 'AT') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
						if ($mode == 'AU') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
						if ($mode == 'UM') {$subselect_select = "unite_medicale_id = $oid ";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL' && $mode != 'AN' ) {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_rum WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_rum WHERE $subselect_select)";
							}
						}
						
						$mode = substr('[UF_RSS]',0,2);
						$oid = substr('[UF_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UF_RSS]');
							$oid = PMSI_get_classe_oid('[UF_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "unite_fonctionnelle_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "unite_fonctionnelle_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = "unite_fonctionnelle_id IN (SELECT oid FROM pmsi.t_unites_fonctionnelles WHERE $section_id = $oid)";}
						if ($mode == 'UF') {$subselect_select = "unite_fonctionnelle_id = $oid ";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL' ) {
								$select = $select. " AND v_rss_1.rss_id = ANY (ARRAY(SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect_select)::bigint[])";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id != ALL (ARRAY(SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect_select)::bigint[])";
							}
						}
						
						
						$mode = substr('[PRESTATION_RSS]',0,2);
						$oid = substr('[PRESTATION_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[PRESTATION_RSS]');
							$oid = PMSI_get_classe_oid('[PRESTATION_RSS]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "prestation_id = ANY(ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'SL') {$subselect_select = "prestation_id = ANY(ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
						if ($mode == 'LS') {$subselect_select = "prestation_id = ANY(ARRAY(SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)::bigint[])";}
						if ($mode == 'PR') {$subselect_select = "prestation_id = $oid ";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id = ANY(ARRAY (SELECT rss_id FROM pmsi.p_rsf_detail WHERE $subselect_select GROUP BY 1)::bigint[])";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id != ALL(ARRAY (SELECT rss_id FROM pmsi.p_rsf_detail WHERE $subselect_select GROUP BY 1)::bigint[])";
							}
						}
						
						if('[MONO_UHCD]' === '1'){
							$select = $select. " AND v_rss_1.nb_rum = 1 AND v_rss_1.unite_medicale_principale_id IN (SELECT oid FROM pmsi.t_unites_medicales where type_autorisation like '07A')";
						}else if('[MONO_UHCD]' === '2'){
							$select = $select. " AND (v_rss_1.nb_rum = 1 AND v_rss_1.unite_medicale_principale_id NOT IN (SELECT oid FROM pmsi.t_unites_medicales where type_autorisation like '07A') OR  v_rss_1.nb_rum > 1)";
						}

						if ('[ACTE_RSS_SANS_ANESTHESIE]' == 'SANSANESTHESIE') {
							$select = $select. " AND v_rss_1.avec_anesthesie IS DISTINCT FROM '1' ";
						} else if ('[ACTE_RSS_SANS_ANESTHESIE]' == 'AVECANESTHESIE') {
							$select = $select. " AND v_rss_1.avec_anesthesie = '1' ";
						}
						
						// Extension documentaire CCAM
						if ('[EXTDOC]' != '-1') {
							$val = '';
							if ('[EXTDOC]' != '0') {
								$val = "[EXTDOC]";
							}
							$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE extension_ccam = '" . $val . "')";
						}
						
						// Modificateurs CCAM 
                        $mode = substr('[RSSMCC]',0,2);
						$oid = substr('[RSSMCC]',2);
						if ('[RSSMCC]' != '-1') {
                            if (strlen($oid) == 1) {
                                $select = $select. " AND v_rss_1.rss_id = ANY(ARRAY(SELECT rss_id FROM pmsi.p_rss_actes WHERE ((modificateur_ccam_1 = '$oid'::text) OR (modificateur_ccam_2 = '$oid'::text ) OR (modificateur_ccam_3 = '$oid'::text) OR (modificateur_ccam_4 = '$oid'::text)) GROUP BY 1)::bigint[])";
                            }
                            else {
                                $select = $select. " AND v_rss_1.rss_id = ANY(ARRAY(SELECT rss_id FROM pmsi.p_rss_actes WHERE (char_length(modificateur_ccam_1 || modificateur_ccam_2 || modificateur_ccam_3 || modificateur_ccam_4) < 4) GROUP BY 1)::bigint[])";
                            }
						}
						
						

						
						// Nb d'actes.
						if ('[T_NB_ACTE_RSS]' != '-1') {
							$field1 = trim('[NB_ACTE_RSS]');
							$field2 = trim('[NB_ACTE_RSS2]');
							$acte_count = '';
							
							if ($field1 != '' && $field2 != '') {
								$acte_count .= "AND sum(nombre) BETWEEN $field1 AND $field2";
							} else if ($field1 != '' && $field2 == '') {
								$acte_count .= "AND sum(nombre) >= $field1";
							} else if ($field1 == '' && $field2 != '') {
								$acte_count .= "AND sum(nombre) <= $field2";
							}
							
                            $select .= "
                                AND v_rss_1.rss_id = ANY (ARRAY(
                                                                    SELECT 
                                                                        rss_id
                                                                    FROM pmsi.p_rss_actes 
                                                                    GROUP BY 1
                                                                    HAVING 1=1
                                                                    $acte_count
                                                                )::bigint[]
                                                        ) 
                            ";
						}
						
						// Actes
						$mode = substr('[ACTE_RSS]',0,2);
						$oid = substr('[ACTE_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[ACTE_RSS]');
							$oid = PMSI_get_classe_oid('[ACTE_RSS]');
						}
						$subselect = '';
						
						if ('[ACTE_RSS_ACTIVITE_CCAM]' != 'P') {
							if ($mode == 'SC') {
								switch(substr('[ACTE_RSS]', 2, 1)){
									case '1' : $sujet = 'topographie_1_id'; break;
									case '2' : $sujet = 'topographie_2_id'; break;
									case '3' : $sujet = 'action_id'; break;
									case '4' : $sujet = 'technique_id'; break;
								}
								$oid = substr('[ACTE_RSS]', 3);
								$subselect = "acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $sujet = $oid)";
							}
							if ($mode == 'TA') {
								$subselect = "acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE type_id = $oid)";
							}
							if ($mode == 'CH') {
								$niveau_chapitre = substr('[ACTE_RSS]', 2, 1);
								$oid = substr('[ACTE_RSS]', 3);
								$subselect = "acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE chapitre_".$niveau_chapitre."_id = $oid)";
							}
							if ($mode == 'C*') {
								$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid'))) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid'))))";
							}
							if ($mode == 'LI') {$subselect = "(acte_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid))";}
							if ($mode == 'SL') {$subselect = "(acte_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid))";}
							if ($mode == 'LS') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid))";}
							if ($mode == 'NO') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid') OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid'))";}
							if ($mode == 'GX') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0))";}
							if ($mode == 'GM') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid))";}
							if ($mode == 'RC') {$subselect = "acte_regroupement_id = $oid ";}
							if ($mode == 'AC') {$subselect = "(acte_id = $oid OR acte_ccam_descriptif_id = $oid)";}
							
							if ('[ACTE_RSS_ACTIVITE_CCAM]' == '1') {$subselect = $subselect . " AND activite_ccam <> '4' ";}
							if ('[ACTE_RSS_ACTIVITE_CCAM]' == '4') {$subselect = $subselect . " AND activite_ccam = '4' ";}
							
							if ($subselect != '') {
								if (substr($subselect, 0 , 4) == ' AND') {
									$subselect = substr($subselect, 4);
								}
								if ($mode != 'SL') {
									if ($mode != 'RC') {
										$select = $select. " AND v_rss_1.rss_id = ANY (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id = ANY (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
									}
								}
								else {
									$select = $select. " AND v_rss_1.rss_id != ALL (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
								}
							}
							
						}
						else {
							if ($mode == 'SC') {
								switch(substr('[ACTE_RSS]', 2, 1)){
									case '1' : $sujet = 'topographie_1_id'; break;
									case '2' : $sujet = 'topographie_2_id'; break;
									case '3' : $sujet = 'action_id'; break;
									case '4' : $sujet = 'technique_id'; break;
								}
								$oid = substr('[ACTE_RSS]', 3);
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $sujet = $oid)";
							}
							if ($mode == 'TA') {
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE type_id = $oid)";
							}
							if ($mode == 'CH') {
								$niveau_chapitre = substr('[ACTE_RSS]', 2, 1);
								$oid = substr('[ACTE_RSS]', 3);
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE chapitre_".$niveau_chapitre."_id = $oid)";
							}
							if ($mode == 'C*') {
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
							}
							if ($mode == 'LI') {$subselect = "v_rss_1.acte_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect = "v_rss_1.acte_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
							if ($mode == 'NO') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
							if ($mode == 'GX') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
							if ($mode == 'GM') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
							if ($mode == 'RC') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE acte_regroupement_id = $oid)";}
							if ($mode == 'AC') {$subselect = "v_rss_1.acte_principal_id = $oid ";}
							
							if ($subselect != '') {
								$select = $select. " AND $subselect ";
							}
						}
						
						
						
						// Actes (2)
						
						$mode = substr('[ACTE_2_RSS]',0,2);
						$oid = substr('[ACTE_2_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[ACTE_2_RSS]');
							$oid = PMSI_get_classe_oid('[ACTE_2_RSS]');
						}
						$subselect = '';
						
						if ('[ACTE_2_RSS_ACTIVITE_CCAM]' != 'P') {
							if ($mode == 'SC') {
								switch(substr('[ACTE_2_RSS]', 2, 1)){
									case '1' : $sujet = 'topographie_1_id'; break;
									case '2' : $sujet = 'topographie_2_id'; break;
									case '3' : $sujet = 'action_id'; break;
									case '4' : $sujet = 'technique_id'; break;
								}
								$oid = substr('[ACTE_2_RSS]', 3);
								$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $sujet = $oid)";
							}
							if ($mode == 'TA') {
								$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE type_id = $oid)";
							}
							if ($mode == 'CH') {
								$niveau_chapitre = substr('[ACTE_2_RSS]', 2, 1);
								$oid = substr('[ACTE_2_RSS]', 3);
								$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE chapitre_".$niveau_chapitre."_id = $oid)";
							}
							if ($mode == 'C*') {
								$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid'))) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid'))))";
							}
							if ($mode == 'LI') {$subselect = "(acte_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid))";}
							if ($mode == 'SL') {$subselect = "(acte_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid))";}
							if ($mode == 'LS') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid))";}
							if ($mode == 'NO') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid') OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid'))";}
							if ($mode == 'GX') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0))";}
							if ($mode == 'GM') {$subselect = "(acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid))";}
							if ($mode == 'RC') {$subselect = "acte_regroupement_id = $oid ";}
							if ($mode == 'AC') {$subselect = "(acte_id = $oid OR acte_ccam_descriptif_id = $oid)";}
							
							if ('[ACTE_2_RSS_ACTIVITE_CCAM]' == '1') {$subselect = $subselect . " AND activite_ccam <> '4' ";}
							if ('[ACTE_2_RSS_ACTIVITE_CCAM]' == '4') {$subselect = $subselect . " AND activite_ccam = '4' ";}
							
							if ($subselect != '') {
								if (substr($subselect, 0 , 4) == ' AND') {
									$subselect = substr($subselect, 4);
								}
								if ($mode != 'SL') {
									if ($mode != 'RC') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
									}	
								}
								else {
									$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
								}
							}
							
						}
						else {
							if ($mode == 'SC') {
								switch(substr('[ACTE_2_RSS]', 2, 1)){
									case '1' : $sujet = 'topographie_1_id'; break;
									case '2' : $sujet = 'topographie_2_id'; break;
									case '3' : $sujet = 'action_id'; break;
									case '4' : $sujet = 'technique_id'; break;
								}
								$oid = substr('[ACTE_2_RSS]', 3);
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $sujet = $oid)";
							}
							if ($mode == 'TA') {
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE type_id = $oid)";
							}
							if ($mode == 'CH') {
								$niveau_chapitre = substr('[ACTE_2_RSS]', 2, 1);
								$oid = substr('[ACTE_2_RSS]', 3);
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE chapitre_".$niveau_chapitre."_id = $oid)";
							}
							if ($mode == 'C*') {
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
							}
							if ($mode == 'LI') {$subselect = "v_rss_1.acte_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect = "v_rss_1.acte_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
							if ($mode == 'NO') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
							if ($mode == 'GX') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
							if ($mode == 'GM') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
							if ($mode == 'RC') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE acte_regroupement_id = $oid)";}
							if ($mode == 'AC') {$subselect = "v_rss_1.acte_principal_id = $oid ";}
							
							if ($subselect != '') {
								$select = $select. " AND $subselect ";
							}
						}
						
						
						
						// exécutant Actes
						
						$mode = substr('[MEDECIN_ACTE_RSS]',0,2);
						$oid = substr('[MEDECIN_ACTE_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[MEDECIN_ACTE_RSS]');
							$oid = PMSI_get_classe_oid('[MEDECIN_ACTE_RSS]');
						}
						$subselect = '';
						
						
						if ($mode == 'LI') {$subselect = "medecin_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect = "medecin_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect = "medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
						if ($mode == 'SP') {$subselect = "specialite_interne_medecin_reference_id = $oid ";}
						if ($mode == 'SO') {$subselect = "specialite_medecin_reference_id = $oid ";}
						if ($mode == 'C*') {$subselect = "medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'MD') {$subselect = "medecin_reference_id = $oid ";}
						if ($mode == 'DT') {$subselect = "medecin_reference_id = $oid ";}
						if ($mode == 'D2') {$subselect = "specialite_interne_medecin_reference_id = $oid ";}
						
						if ($subselect != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
							}
						}

						// médecins rum RSS
						
						$mode = substr('[MEDECIN_RUM_RSS]',0,2);
						$oid = substr('[MEDECIN_RUM_RSS]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[MEDECIN_RUM_RSS]');
							$oid = PMSI_get_classe_oid('[MEDECIN_RUM_RSS]');
						}
						$subselect = '';
						
						if ($mode == 'LI') {$subselect_ = " v_rss_rum_2.medecin_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_ = " v_rss_rum_2.medecin_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_ = " v_rss_rum_2.medecin_rum_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
						if ($mode == 'SP') {$subselect_ = " v_rss_rum_2.specialite_medecin_reference_rum_id = $oid ";}
						if ($mode == 'SO') {$subselect_ = " v_rss_rum_2.specialite_medecin_reference_rum_id = $oid ";}
						if ($mode == 'C*') {$subselect_ = " v_rss_rum_2.medecin_rum_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'MD') {$subselect_ = " v_rss_rum_2.medecin_rum_id = $oid ";}
						if ($mode == 'DT') {$subselect_ = " v_rss_rum_2.medecin_rum_id = $oid ";}
						if ($mode == 'D2') {$subselect_ = " v_rss_rum_2.specialite_medecin_reference_rum_id = $oid ";}
						
						if ($subselect_ != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.v_rss_rum_2 WHERE $subselect_)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.v_rss_rum_2 WHERE $subselect_)";
							}
						}

						
						
						// Sélection origine
						
						$mode = substr('[CODE_POSTAL]',0,2);
						$oid = substr('[CODE_POSTAL]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[CODE_POSTAL]');
							$oid = PMSI_get_classe_oid('[CODE_POSTAL]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.code_postal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT oid FROM pmsi.t_codes_postaux_c WHERE $section_id = $oid)";}
						if ($mode == 'DP') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT oid FROM pmsi.t_codes_postaux_c WHERE departement_id = $oid)";}
						if ($mode == 'DG') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT oid FROM pmsi.t_codes_postaux_c WHERE departement_id = $oid)";}
						if ($mode == 'RG') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT oid FROM pmsi.t_codes_postaux_c WHERE region_id = $oid)";}
						if ($mode == 'GP') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT oid FROM pmsi.t_codes_postaux_c WHERE code_geographique_pmsi_id = $oid)";}
						if ($mode == 'TS') {$subselect_select = " v_rss_1.code_postal_id IN (SELECT oid FROM pmsi.t_codes_postaux_c WHERE territoire_sante_id = $oid)";}
						if ($mode == 'CP') {$subselect_select = " v_rss_1.code_postal_id = $oid ";}
						
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						if ('[DIVERS]' == 'MULTIRUM') {
							$select = $select. ' AND (v_rss_1.nb_rum > 1 )';
						}
						if ('[DIVERS]' == 'MONORUM') {
							$select = $select. ' AND (v_rss_1.nb_rum = 1 )';
						}
						if ('[DIVERS]' == 'EXB') {
							$select = $select. ' AND v_rss_1.nb_exb <> 0 ';
						}
						if ('[DIVERS]' == 'OMITFACNUL') {
							$select = $select. ' AND (v_rss_1.nb_factures_nulles = 0 )';
						}
						if ('[DIVERS]' == 'OMITFACNULBB') {
							$select = $select. ' AND (v_rss_1.base_remboursement <> 0 )';
						}
						if ('[DIVERS]' == 'OMITBB') {
							$select = $select. " AND (v_rss_1.ghm_code NOT ILIKE '15%')";
						}
						
						
						
						//  IPA
						
						if (substr('[IPA]',0,2) == 'II') {	// include IPA
							$select = $select. " AND v_rss_ipa_1.ipa_id = '" . substr('[IPA]',2) . "'";
						}
						if (substr('[IPA]',0,2) == 'SI') {	// sauf IPA
							$select = $select. " AND v_rss_ipa_1.ipa_id <> '" . substr('[IPA]',2) . "'";
						}
						
						if (substr('[IPA]',0,2) == 'IC') {	// include categorie
							$select = $select. " AND v_rss_ipa_1.categorie_ipa_id = '" . substr('[IPA]',2) . "'";
						}
						if (substr('[IPA]',0,2) == 'SC') {	// sauf categorie
							$select = $select. " AND v_rss_ipa_1.categorie_ipa_id <> '" . substr('[IPA]',2) . "'";
						}
						
						
						
						//  Geste Marqueur
						
						if (substr('[GESTE_MARQUEUR]',0,1) == 'X') {	// Acte Principal diff. de Geste Marqueur principal
							$select = $select . " 	AND v_rss_gm_1.gm_code NOT IN ('**', '***', '****')
													AND v_rss_1.acte_principal_id NOT IN
													(
														SELECT
															to_id
														FROM
															pmsi.t_classes_sections_elements
															JOIN pmsi.t_classes_sections ON t_classes_sections.oid = t_classes_sections_elements.section_id
															JOIN pmsi.t_classes ON t_classes.oid = t_classes_sections.classe_id
															JOIN pmsi.t_listes_tables ON t_listes_tables.oid = t_classes.table_id
														WHERE
															t_listes_tables.code = 'ACTE'
															AND t_classes.sequence = 9
															AND t_classes_sections.code = v_rss_gm_1.gm_code
													)";
						}
						else if (substr('[GESTE_MARQUEUR]',0,1) == 'I') {	// include geste marqueur
							$select = $select. " AND v_rss_gm_1.gm_code = '" . substr('[GESTE_MARQUEUR]',1) . "'";
						}
						else if (substr('[GESTE_MARQUEUR]',0,1) == 'S') {	// sauf geste marqueur
							if (substr('[GESTE_MARQUEUR]',1,1) == '*') {	// au moins un geste marqueur
								$select = $select. " AND v_rss_gm_1.gm_code NOT IN ('**', '***', '****') ";
							}
							else {
								$select = $select. " AND v_rss_gm_1.gm_code <> '" . substr('[GESTE_MARQUEUR]',1) . "'";
							}
						}
						
						
						
						// Seuils de cancérologie soumise à seuil
						
						if ('[SEUIL_CANCERO]' != '-1') { 
						
							$mode = substr('[SEUIL_CANCERO]', 0, 2);
							$code = substr('[SEUIL_CANCERO]', 2);
							
							switch ($mode) {
								// Sans code de cancéro
								case 'SA' :
									$select .= " AND v_rss_cancero_1.cancero_code IS NULL ";
									break;
								// Avec au moins un code cancéro
								case 'AV' :
									$select .= " AND v_rss_cancero_1.cancero_code IS DISTINCT FROM NULL ";
									break;
								// Avec code de cancéro =
								case 'II' :
									$select .= " AND v_rss_cancero_1.cancero_code = '" . $code . "' ";
									break;
								// Sans code de cancéro =
								case 'SI' :
									$select .= " AND v_rss_cancero_1.cancero_code <> '" . $code . "' ";
									break;
								// Avec activité de cancéro =
								case 'IC' :
									$select .= " AND v_rss_cancero_1.activite_cancero_code = '" . $code . "'";
									break;
								// Sans activité de cancéro =
								case 'SC' :
									$select .= " AND v_rss_cancero_1.activite_cancero_code <> '" . $code . "'";
									break;
							}
						}
						
						// Seuils de cancérologie soumise à seuil principal
						
						if ('[SEUIL_CANCERO_PRINCIPAL]' != '-1') { 
						
							$mode = substr('[SEUIL_CANCERO_PRINCIPAL]', 0, 2);
							$code = substr('[SEUIL_CANCERO_PRINCIPAL]', 2);
							
							switch ($mode) {
								// Sans code de cancéro
								case 'SA' :
									$select .= " AND v_rss_cancero_2022.cancero_principal_code IS NULL ";
									break;
								// Avec au moins un code cancéro
								case 'AV' :
									$select .= " AND v_rss_cancero_2022.cancero_principal_code IS DISTINCT FROM NULL ";
									break;
								// Avec code de cancéro =
								case 'II' :
									$select .= " AND v_rss_cancero_2022.cancero_principal_code = '" . $code . "' ";
									break;
								// Sans code de cancéro =
								case 'SI' :
									$select .= " AND v_rss_cancero_2022.cancero_principal_code <> '" . $code . "' ";
									break;
								// Avec activité de cancéro =
								case 'IC' :
									$select .= " AND v_rss_cancero_2022.activite_cancero_principal_code = '" . $code . "'";
									break;
								// Sans activité de cancéro =
								case 'SC' :
									$select .= " AND v_rss_cancero_2022.activite_cancero_principal_code <> '" . $code . "'";
									break;
							}
						}

                    
                        if ('[T_GHSASSOS]' != '-1'  ) {
                            // avec GHS associé
                            if ('[T_GHSASSOS]' == 'I**') {
                            
                                if ('[GHSASSOS]' != '-1') { 
                                    $mode = substr('[GHSASSOS]',0,2);
                                    $oid = substr('[GHSASSOS]',2);
                                    if ($mode == 'LS') {
                                        $section_id = PMSI_get_section_id('[GHSASSOS]');
                                        $oid = PMSI_get_classe_oid('[GHSASSOS]');
                                    }
                                    $subselect_select = '';
                                        
                                    if ($mode == 'LI') {$subselect_select = " v_rsf_detail_1.ghs_id = ANY(ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
                                    if ($mode == 'SL') {$subselect_select = " v_rsf_detail_1.ghs_id = ANY(ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
                                    if ($mode == 'C*') {$subselect_select = " v_rsf_detail_1.ghs_id = ANY(ARRAY(SELECT oid FROM pmsi.t_ghs WHERE $section_id = $oid)::bigint[])";}
                                    if ($mode == 'GS') {$subselect_select = " v_rsf_detail_1.ghs_id = $oid ";}
                                    
                                    if ($subselect_select != '') {
                                        if ($mode != 'SL') {
                                            $select = $select. " AND v_rss_1.rss_id = ANY(ARRAY (SELECT v_rsf_detail_1.rss_id FROM pmsi.v_rsf_detail_1 JOIN pmsi.v_rss_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id WHERE ($subselect_select AND v_rsf_detail_1.ghs_code <> '0' AND v_rss_1.ghs_code <> v_rsf_detail_1.ghs_code) GROUP BY 1)::bigint[])";
                                        }
                                        else {
                                            $select = $select. " AND v_rss_1.rss_id != ALL(ARRAY (SELECT v_rsf_detail_1.rss_id FROM pmsi.v_rsf_detail_1 JOIN pmsi.v_rss_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id WHERE ($subselect_select AND v_rsf_detail_1.ghs_code <> '0' AND v_rss_1.ghs_code <> v_rsf_detail_1.ghs_code) GROUP BY 1)::bigint[])";
                                        }
                                    }
                                }
                                else {
                                    //[T_GHSASSOS]' == 'I**
                                    $select = $select .  " AND v_rss_1.rss_id = ANY(ARRAY (SELECT v_rsf_detail_1.rss_id FROM pmsi.v_rsf_detail_1 JOIN pmsi.v_rss_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id WHERE ( v_rsf_detail_1.ghs_code <> '0' AND v_rss_1.ghs_code <> v_rsf_detail_1.ghs_code) GROUP BY 1)::bigint[])";
                                }
                            }
                            // sans GHS associé
                            if ('[T_GHSASSOS]' == 'X**') {
                                '[GHSASSOS]' == '-1"';
                                $select = $select .  " AND v_rss_1.rss_id != ALL(ARRAY (SELECT v_rsf_detail_1.rss_id FROM pmsi.v_rsf_detail_1 JOIN pmsi.v_rss_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id WHERE ( v_rsf_detail_1.ghs_code <> '0' AND v_rss_1.ghs_code <> v_rsf_detail_1.ghs_code) GROUP BY 1)::bigint[])";
                            } 
                         } 

                        if('[LS_DATA]' == 'CA_OVA_LSDATA_14') {
                            $select = $select. " AND ghm_code in (SELECT ghm_code from pmsi.v_rss_7 v_rss_1 where date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND v_rss_1.en_cours = '0' AND v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm where severite = '1') AND v_rss_1.cas_code not in ('K','X','N','O','S','*','?') AND v_rss_1.mode_sortie ='8' AND nb_rsa_0n >0 )";
                        }
                        if('[NO_RSS]' != ''){
													$no_rss = preg_split("/[\s,]+/",trim('[NO_RSS]'));
													$no_rss = implode(',',$no_rss);
													
													if(substr($no_rss,-1) == ','){
														$no_rss = substr($no_rss,0,-1);
													}
													$select = $select. " AND v_rss_1.rss_id = ANY (array (SELECT rss_id from pmsi.v_rss_1 where no_rss in (" . $no_rss. ") AND v_rss_1.date_sortie >= '[PERIODE]' group by 1)::bigint[])";
												}
						
						return $select;
						
						// ?>
						
				EVAL]]]></value>
			</PROPERTY>

			
		</VIEWPROPERTIES>
		
		<SELECTIONS label="Filtres RSS" displayText="= var display:String = '';
					
					if (SELECT.REGIME  != '-1') {
						display = display + '  Grand régime : #B#' + SELECT.REGIME_LABEL + '#/B#';
					}
					
					if (SELECT.PEC  != '-1') {
						display = display + '  Facturable AMO : #B#' + SELECT.PEC_LABEL + '#/B#';
					}
					
					if (SELECT.PEC_FJ  != '-1') {
						display = display + '  Forfait Journalier : #B#' + SELECT.PEC_FJ_LABEL + '#/B#';
					}
					
					if (SELECT.MOTIF_NON_FACTURATION  != '-1') {
						display = display + '  Motif non facturation : #B#' + SELECT.MOTIF_NON_FACTURATION_LABEL + '#/B#';
					}
					
					if (SELECT.NATURE_PEC  != '-1') {
						display = display + '  Nature assurance : #B#' + SELECT.NATURE_PEC_LABEL + '#/B#';
					}
					
					if (SELECT.TYPE_CONTRAT_OC  != '-1') {
						display = display + '  Type contrat OC : #B#' + SELECT.TYPE_CONTRAT_OC_LABEL + '#/B#';
					}
					
					if (SELECT.EXONERATION_TM  != '-1') {
						display = display + '  Exonération TM : #B#' + SELECT.EXONERATION_TM_LABEL + '#/B#';
					}
					
					if (SELECT.FAC_18EUROS  != '-1') {
						display = display + '  Facturation 18 euros : #B#' + SELECT.FAC_18EUROS_LABEL + '#/B#';
					}
					
					if (SELECT.PAT_BENEF_CMU  != '-1') {
						display = display + '  Patient avec CMU : #B#' + SELECT.PAT_BENEF_CMU_LABEL + '#/B#';
					}
					
					if (SELECT.VALORISE_FIDES  != '-1') {
						display = display + '  Valorisation FIDES : #B#' + SELECT.VALORISE_FIDES_LABEL + '#/B#';
					}
					
					if (SELECT.FINESS  != '-1') {
						display = display + '  Etablissement : #B#' + SELECT.FINESS_LABEL + '#/B#';
					}
					
					if (VIEW.VIEW_DATATYPE != 'ETATDOSSIER') {
						display = display + '  Champ e-PMSI : #B#' + SELECT.CHAMP_LABEL + '#/B#';
					}



					
					if (SELECT.MCO_M + SELECT.MCO_C + SELECT.MCO_O + SELECT.MCO_S + SELECT.MCO_H != 'MCOS*') {
						display += '  ASO : #B#';
						if (SELECT.MCO_M + SELECT.MCO_C + SELECT.MCO_O + SELECT.MCO_S == 'MCOS') {
							display += 'M.C.O. ';
						}
						else {
							if (SELECT.MCO_M == 'M') {
								display += 'Médecine ';
							}
							if (SELECT.MCO_C == 'C') {
								display += 'Chirurgie ';
							}
							if (SELECT.MCO_O == 'O') {
								display += 'Obstétrique ';
							}
							if (SELECT.MCO_S == 'S') {
								display += 'Séance ';
							}
							if (SELECT.MCO_H == '*') {
								display += 'e-PMSI hors GHM ';
							}
						}
						display += '#/B#';
					}
					
					var cas:String = SELECT.CAS_C + SELECT.CAS_K + SELECT.CAS_X + SELECT.CAS_N + SELECT.CAS_O + SELECT.CAS_S + SELECT.CAS_W + SELECT.ACT_URG;
					if (cas != 'CKXNOS*') {
						display += '  Catégorie d\'activités de soins : #B#';
						if (cas == 'CKXNOS0') {
							display += 'e-PMSI avec GHM';
						}
						else {
							if (SELECT.CAS_C == 'C') {
								display += 'Chirurgie, ';
							}
							if (SELECT.CAS_K == 'K') {
								display += 'Techniques peu invasives, ';
							}
							if (SELECT.CAS_X == 'X') {
								display += 'Sans acte classant (M+Z), ';
							}
							if (SELECT.CAS_N == 'N') {
								display += 'Nouveaux-nés, ';
							}
							if (SELECT.CAS_O == 'O') {
								display += 'Obstétrique, ';
							}
							if (SELECT.CAS_S == 'S') {
								display += 'Séances, ';
							}
							if (SELECT.CAS_W == '*') {
								display += 'e-PMSI hors GHM, ';
							}
    						if (SELECT.ACT_URG == '*') {
								display += 'Avec activité urgence, ';
							}
							display = display.substr(0, -2);
						}
						display += '#/B#';
					}
					if (SELECT.T_DUREE_SEJOUR  != '-1') {
						display = display + '  Durée séjour : #B#';
						if (SELECT.T_DUREE_SEJOUR != 'I') {
							display = display + SELECT.T_DUREE_SEJOUR_LABEL;
						}
						else {
							if (SELECT.DUREE_SEJOUR != '') {
								if (SELECT.DUREE_SEJOUR2 != '') {
									display = display + '#GE# ' + SELECT.DUREE_SEJOUR + ' et #LE# ' + SELECT.DUREE_SEJOUR2 + ' nuit(s)';
								}
								else {
									display = display + '#GE# ' + SELECT.DUREE_SEJOUR + ' nuit(s)';
								}
							}
							else {
								display = display + '#LE# ' + SELECT.DUREE_SEJOUR2 + ' nuit(s)';
							}
						}
						display = display + '#/B#';
					}
					if (SELECT.T_ECART_DMS  != '-1') {
						display = display + '  Ecart DMS : #B#';
						if (SELECT.ECART_DMS_OPERATOR ==  1)
							display = display + SELECT.ECART_DMS_FIELD1_LABEL;
						else if (SELECT.ECART_DMS_OPERATOR ==  2)
							display = display + 'sup. ou = à ' + SELECT.ECART_DMS_FIELD1_LABEL;
						else if (SELECT.ECART_DMS_OPERATOR ==  3)
							display = display + 'inf. ou = à ' + SELECT.ECART_DMS_FIELD1_LABEL;
						else if (SELECT.ECART_DMS_OPERATOR ==  4)
							display = display + 'entre ' + SELECT.ECART_DMS_FIELD1_LABEL + ' et ' + SELECT.ECART_DMS_FIELD2_LABEL;
						else if (SELECT.ECART_DMS_OPERATOR ==  5)
							display = display + 'différent de ' + SELECT.ECART_DMS_FIELD1_LABEL;
						display = display + ' jours';
						display = display + '#/B#';
						display = display + '  DMS Référence: #B#';
						display = display + SELECT.DMS_CLASSE_LABEL;
						display = display + '#/B#';
					}
					else {
						if (SELECT.SHOWDMSREF  == '1') {
							display = display + '  DMS Référence: #B#';
							display = display + SELECT.DMS_CLASSE_LABEL;
							display = display + '#/B#';
						}
					}
					if (SELECT.MODE_ENTREE  != '-1') {
						if (SELECT.MEN_PROV_RSS_RUM == 'RUM')
							display = display + '  Mode entrée RUM : #B#' + SELECT.MODE_ENTREE_LABEL + '#/B#';
						else
							display = display + '  Mode entrée : #B#' + SELECT.MODE_ENTREE_LABEL + '#/B#';
					}
					if (SELECT.PROVENANCE  != '-1') {
						if (SELECT.MEN_PROV_RSS_RUM == 'RUM')
							display = display + '  Provenance RUM : #B#' + SELECT.PROVENANCE_LABEL + '#/B#';
						else
							display = display + '  Provenance : #B#' + SELECT.PROVENANCE_LABEL + '#/B#';
					}                    
                    if (SELECT.ETAB_DEST  != '-1') {
						if (SELECT.MSO_DEST_RSS_RUM == 'RUM')
							display = display + '  Etablissement destination RUM : #B#' + SELECT.ETAB_DEST_LABEL + '#/B#';
						else
							display = display + ' Etablissement destination : #B#' + SELECT.ETAB_DEST_LABEL + '#/B#';
					}                    
                    if (SELECT.ETAB_PROVE  != '-1') {
						if (SELECT.MSO_DEST_RSS_RUM == 'RUM')
							display = display + '  Etablissement provenance RUM : #B#' + SELECT.ETAB_DEST_LABEL + '#/B#';
						else
							display = display + ' Etablissement provenance : #B#' + SELECT.ETAB_PROVE_LABEL + '#/B#';
					}
					if (SELECT.MODE_SORTIE  != '-1') {
						if (SELECT.MSO_DEST_RSS_RUM == 'RUM')
							display = display + '  Mode sortie RUM : #B#' + SELECT.MODE_SORTIE_LABEL + '#/B#';
						else
							display = display + '  Mode sortie : #B#' + SELECT.MODE_SORTIE_LABEL + '#/B#';
					}
					if (SELECT.DESTINATION  != '-1') {
						if (SELECT.MSO_DEST_RSS_RUM == 'RUM')
							display = display + '  Destination RUM : #B#' + SELECT.DESTINATION_LABEL + '#/B#';
						else
							display = display + '  Destination : #B#' + SELECT.DESTINATION_LABEL + '#/B#';
					}
					if (SELECT.OAP  != '-1') {
						display = display + '  OAP : #B#' + SELECT.OAP_LABEL + '#/B#';
					}
					if (SELECT.GHM  != '-1') {
						display = display + '  ';
						if (SELECT.GHM.substr(0,2) == 'CM') {
							display = display + 'CMD';
						}
						else {
							if (SELECT.GHM.substr(0,2) == 'GH') {
								display = display + 'GHM';
							}
							else {
								if (SELECT.GHM.substr(0,2) == 'CW') {
									display = display + 'GHM';
								}
								else {
									if (SELECT.GHM.substr(0,2) == 'SV') {
										display = display + 'Sévérité GHM';
									}
									else {
										display = display + 'GHM';
									}
								}
							}
						}
						
						display = display + ' : #B#' + SELECT.GHM_LABEL + '#/B#';
						
					
					}
					if (SELECT.GHM5  != '-1') {
						display = display + '  Racine GHM : #B#' + SELECT.GHM5_LABEL + '#/B#';
					}
					if (SELECT.GHMSEV  != '-1') {
						display = display + '  Sévérité GHM : #B#' + SELECT.GHMSEV_LABEL + '#/B#';
					}					
                    if (SELECT.CTISEV  != '-1') {
						display = display + '  Sévérité CTI : #B#' + SELECT.CTISEV_LABEL + '#/B#';
					}
					if (SELECT.GA  != '-1') {
						display = display + '  Groupe activité : #B#' + SELECT.GA_LABEL + '#/B#';
					}
					if (SELECT.PARAMETRE_PERSONNALISE_RSS_1  != '-1') {
						display = display + '  [DICT.PMSI.PARAMETRE_PERSONNALISE_RSS_1] : #B#' + SELECT.PARAMETRE_PERSONNALISE_RSS_1_LABEL + '#/B#';
					}
					if (SELECT.PARAMETRE_PERSONNALISE_RSS_2  != '-1') {
						display = display + '  [DICT.PMSI.PARAMETRE_PERSONNALISE_RSS_2] : #B#' + SELECT.PARAMETRE_PERSONNALISE_RSS_2_LABEL + '#/B#';
					}
					if (SELECT.MEDECIN_RSS  != '-1') {
						display = display + '  Médecin RSS : #B#' + SELECT.MEDECIN_RSS_LABEL + '#/B#';
					}
					if (SELECT.COMITE_MEDICAL  != '-1') {
						display = display + '  Comité médical : #B#' + SELECT.COMITE_MEDICAL_LABEL + '#/B#';
					}
					if (SELECT.T_NB_DIAG_RSS  != '-1') {
						display += '  avec ' + SELECT.T_NB_DIAG2_RSS_LABEL + ' : #B#';
						if (SELECT.NB_DIAG_RSS != '' &amp;&amp; SELECT.NB_DIAG_RSS2 != '') {
							display += 'entre ' + SELECT.NB_DIAG_RSS + ' et ' + SELECT.NB_DIAG_RSS2;
						} else if (SELECT.NB_DIAG_RSS != '' &amp;&amp; SELECT.NB_DIAG_RSS2 == '') {
							display += '#GE# ' + SELECT.NB_DIAG_RSS;
						} else if (SELECT.NB_DIAG_RSS == '' &amp;&amp; SELECT.NB_DIAG_RSS2 != '') {
							display += '#LE# ' + SELECT.NB_DIAG_RSS2;
						}
						display += '#/B#';
					}
                    

					if (SELECT.T_DIAG_1_RSS  != '-1') {
						display = display + '  avec ' + SELECT.T_DIAG_1_RSS_LABEL + ' : #B#' + SELECT.DIAG_1_RSS_LABEL + '#/B#';
					}
					if (SELECT.T_DIAG_2_RSS  != '-1') {
						display = display + '  avec ' + SELECT.T_DIAG_2_RSS_LABEL + ' : #B#' + SELECT.DIAG_2_RSS_LABEL + '#/B#';
					}
					if (SELECT.T_NB_ACTE_RSS  != '-1') {
						display += '  Nb actes : #B#';
						if (SELECT.NB_ACTE_RSS != '' &amp;&amp; SELECT.NB_ACTE_RSS2 != '') {
							display += 'entre ' + SELECT.NB_ACTE_RSS + ' et ' + SELECT.NB_ACTE_RSS2;
						} else if (SELECT.NB_ACTE_RSS != '' &amp;&amp; SELECT.NB_ACTE_RSS2 == '') {
							display += '#GE# ' + SELECT.NB_ACTE_RSS;
						} else if (SELECT.NB_ACTE_RSS == '' &amp;&amp; SELECT.NB_ACTE_RSS2 != '') {
							display += '#LE# ' + SELECT.NB_ACTE_RSS2;
						}
						display += '#/B#';
					}
					if (SELECT.ACTE_RSS_SANS_ANESTHESIE  != '-1') {
						display = display + '  Particularité actes : #B#' + SELECT.ACTE_RSS_SANS_ANESTHESIE_LABEL + '#/B#';
					}
					if (SELECT.EXTDOC  != '-1') {
						display = display + '  Extension documentaire : #B#' + SELECT.EXTDOC_LABEL + '#/B#';
					}
					if (SELECT.ACTE_RSS  != '-1') {
						if (SELECT.ACTE_RSS_ACTIVITE_CCAM != 'P') {
							display = display + '  avec Acte : #B#' + SELECT.ACTE_RSS_LABEL + ' (' + SELECT.ACTE_RSS_ACTIVITE_CCAM_LABEL + ')#/B#';
						}
						else {
							display = display + '  Acte principal : #B#' + SELECT.ACTE_RSS_LABEL + '#/B#';
						}
						if (SELECT.ACTE_2_RSS  != '-1') {
							if (SELECT.ACTE_2_RSS_ACTIVITE_CCAM != 'P') {
								display = display + '  et Acte : #B#' + SELECT.ACTE_2_RSS_LABEL + ' (' + SELECT.ACTE_2_RSS_ACTIVITE_CCAM_LABEL + ')#/B#';
							}
							else {
								display = display + '  et Acte principal : #B#' + SELECT.ACTE_2_RSS_LABEL + '#/B#';
							}
						}
					}
					else {
						if (SELECT.ACTE_2_RSS  != '-1' ) {
							if (SELECT.ACTE_2_RSS_ACTIVITE_CCAM != 'P') {
								display = display + '  avec Acte : #B#' + SELECT.ACTE_2_RSS_LABEL + ' (' + SELECT.ACTE_2_RSS_ACTIVITE_CCAM_LABEL + ')#/B#';
							}
							else {
								display = display + '  Acte principal : #B#' + SELECT.ACTE_2_RSS_LABEL + '#/B#';
							}
						}
					}
					if (SELECT.ACTE_RSS == '-1' &amp;&amp; SELECT.ACTE_RSS_ACTIVITE_CCAM != '-1' &amp;&amp; SELECT.ACTE_RSS_ACTIVITE_CCAM != 'P') {
						display = display + '  Avec Acte : #B#' + SELECT.ACTE_RSS_ACTIVITE_CCAM_LABEL + '#/B#';
					}
					if (SELECT.MEDECIN_ACTE_RSS  != '-1') {
						display = display + '  avec Médecin acte : #B#' + SELECT.MEDECIN_ACTE_RSS_LABEL + '#/B#';
					}
					if (SELECT.RSSMCC != '-1') {
						display += ' avec modificateurs CCAM : #B#' + SELECT.RSSMCC_LABEL + '#/B#';
					}
					if (SELECT.UM_RSS  != '-1') {
						display = display + '  passé dans UM : #B#' + SELECT.UM_RSS_LABEL + '#/B#';
					}
					if (SELECT.UF_RSS  != '-1') {
						display = display + '  acte réalisé dans UF : #B#' + SELECT.UF_RSS_LABEL + '#/B#';
					}
					if (SELECT.UM_PRINCIPALE  != '-1') {
						display = display + '  UM principale : #B#' + SELECT.UM_PRINCIPALE_LABEL + '#/B#';
					}					
                    if (SELECT.PREMIERE_UM  != '-1') {
						display = display + '  1ère UM : #B#' + SELECT.PREMIERE_UM_LABEL + '#/B#';
					}
                    if (SELECT.POLE_PRINCIPAL  != '-1') {
						display = display + '  Pole principal : #B#' + SELECT.POLE_PRINCIPAL_LABEL + '#/B#';
					}
					if (SELECT.LPP_RSS  != '-1') {
						display = display + '  avec LPP : #B#' + SELECT.LPP_RSS_LABEL + '#/B#';
					}
                    if (SELECT.LIRSS  != '-1') {
						display = display + '  avec liste RSS (fiche n°5) : #B#' + SELECT.LIRSS_LABEL + '#/B#';
					}
                    if (SELECT.ETAT_RSS  != '-1') {
						display = display + '  Etat de séjours : #B#' + SELECT.ETAT_RSS_LABEL + '#/B#';
					}
					if (SELECT.UCD_RSS  != '-1') {
						display = display + '  avec UCD : #B#' + SELECT.UCD_RSS_LABEL + '#/B#';
					}					
                    if (SELECT.IUCD_RSS  != '-1') {
						display = display + '  Indication UCD : #B#' + SELECT.IUCD_RSS_LABEL + '#/B#';
					}
					if (SELECT.TYPFAC  != '-1') {
						display = display + '  Type facturation : #B#' + SELECT.TYPFAC_LABEL + '#/B#';
					}
					if (SELECT.GHS  != '-1') {
						display = display + '  GHS : #B#' + SELECT.GHS_LABEL + '#/B#';
					}
					if (SELECT.PRESTATION_RSS  != '-1') {
						display = display + '  avec Prestation : #B#' + SELECT.PRESTATION_RSS_LABEL + '#/B#';
					}
					if (SELECT.SEXE  != '-1') {
						display = display + '  Sexe : #B#' + SELECT.SEXE_LABEL + '#/B#';
					}
					if (SELECT.T_AGE  != '-1') {
						display = display + '  Age : #B#';
						if (SELECT.T_AGE != 'I') {
							display = display + SELECT.T_AGE_LABEL;
						}
						else {
							if (SELECT.AGE != '') {
								if (SELECT.AGE2 != '') {
									display = display + '#GE# ' + SELECT.AGE + ' et #LE# ' + SELECT.AGE2 + ' an(s)';
								}
								else {
									display = display + '#GE# ' + SELECT.AGE + ' an(s)';
								}
							}
							else {
								display = display + '#LE# ' + SELECT.AGE2 + ' an(s)';
							}
						}
						display = display + '#/B#';
					}
					if (SELECT.T_AGE_JOURS  != '-1') {
						display = display + '  Age en jours : #B#';
						if (SELECT.T_AGE_JOURS != 'I') {
							display = display + SELECT.T_AGE_JOURS_LABEL;
						}
						else {
							if (SELECT.AGE_JOURS != '') {
								if (SELECT.AGE_JOURS2 != '') {
									display = display + '#GE# ' + SELECT.AGE_JOURS + ' et #LE# ' + SELECT.AGE_JOURS2 + ' jour(s)';
								}
								else {
									display = display + '#GE# ' + SELECT.AGE_JOURS + ' jour(s)';
								}
							}
							else {
								display = display + '#LE# ' + SELECT.AGE_JOURS2 + ' jour(s)';
							}
						}
						display = display + '#/B#';
					}
					if (SELECT.T_GEST  != '-1') {
						display += '  Age gestationnel : #B#';
						if (SELECT.T_GEST == 'I') {
							if (SELECT.GEST != '') {
								if (SELECT.GEST2 != '') {
									display += '#GE# ' + SELECT.GEST + ' et #LE# ' + SELECT.GEST2 + ' sem(s)';
								}
								else {
									display += '#GE# ' + SELECT.GEST + ' sem(s)';
								}
							}
							else {
								display += '#LE# ' + SELECT.GEST2 + ' sem(s)';
							}
						}
						display += '#/B#';
					}
					if (SELECT.T_POIDS_BEBE  != '-1') {
						display += '  poids bébé : #B#';
						if (SELECT.T_POIDS_BEBE == 'I') {
							if (SELECT.POIDS_BEBE != '') {
								if (SELECT.POIDS_BEBE2 != '') {
									display += '#GE# ' + SELECT.POIDS_BEBE + ' et #LE# ' + SELECT.POIDS_BEBE2 + ' g';
								}
								else {
									display += '#GE# ' + SELECT.POIDS_BEBE + ' g';
								}
							}
							else {
								display += '#LE# ' + SELECT.POIDS_BEBE2 + ' g';
							}
						}
						display += '#/B#';
					}
					if (SELECT.CODE_POSTAL  != '-1') {
						display = display + '  originaire de : #B#';
						if (SELECT.CODE_POSTAL.substr(0,2) == 'TS') {
							display = display + 'Territoire de santé ' + SELECT.CODE_POSTAL_LABEL;
						}
						else if (SELECT.CODE_POSTAL.substr(0,2) == 'GP') {
							display = display + 'Code PMSI ' + SELECT.CODE_POSTAL_LABEL;
						}
						else {
							if (SELECT.CODE_POSTAL.substr(0,2) == 'CP') {
								display = display + 'Code postal ' + SELECT.CODE_POSTAL_LABEL;
							}
							else {
								display = display + SELECT.CODE_POSTAL_LABEL;
							}
						}
						display = display + '#/B#';
					}
					if (SELECT.DIVERS  != '-1') {
						display = display + '  Autres : #B#' + SELECT.DIVERS_LABEL + '#/B#';
					}
					
					if (SELECT.NIP  != '') {
						display = display + '  Numéros patient : #B#' + SELECT.NIP + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Filtres RSS#/B# = ' + display;
					}
					
					if (SELECT.IPA  != '-1') {
						display = display + '  Indicateur I.P.A. : #B#' + SELECT.IPA_LABEL + '#/B#';
					}
					
					if (SELECT.GESTE_MARQUEUR != '-1') {
						display = display + '  Geste Marqueur : #B#' + SELECT.GESTE_MARQUEUR_LABEL + '#/B#';
					}
						
					if (SELECT.SEUIL_CANCERO_PRINCIPAL != '-1') {
						display = display + '  Cancéro. soumise à seuil (code principal) : #B#' + SELECT.SEUIL_CANCERO_PRINCIPAL_LABEL + '#/B#';
					}
					
					if (SELECT.SEUIL_CANCERO != '-1' &amp;&amp; SELECT.SEUIL_CANCERO != null) {
						display = display + '  Cancéro. soumise à seuil : #B#' + SELECT.SEUIL_CANCERO_LABEL + '#/B#';
					}
					
					if (SELECT.TAUX_REMB != '') {
						if (SELECT.TAUX_REMB2 != '') {
							display = display + ' Taux remboursement :#B# #GE# ' + SELECT.TAUX_REMB + '% et #LE# ' + SELECT.TAUX_REMB2 + '%' + '#/B#';
						}
						else {
							display = display + ' Taux remboursement :#B# ' + SELECT.TAUX_REMB + '%' + '#/B#';
						}
					}
					else {
						if (SELECT.TAUX_REMB2 != '') {
							display = display + ' Taux remboursement :#B# #LE# ' + SELECT.TAUX_REMB2 + '%'+ '#/B#';
						}
					}

                    if (SELECT.T_GHSASSOS  != '-1'  ) {
                        if (SELECT.T_GHSASSOS.substr(0,1) == 'I') {
                            display = display + '  ' + SELECT.T_GHSASSOS_LABEL;

                            if (SELECT.GHSASSOS  != '-1') {
                                display = display + '  dont : #B#' + SELECT.GHSASSOS_LABEL + '#/B#';
                            }
                        }
                        if (SELECT.T_GHSASSOS.substr(0,1) == 'X') {
                            display = display + '  ' + SELECT.T_GHSASSOS_LABEL;
                        }
                    }

					if (SELECT.F_CA_GHS_EXH  != '-1') {
						display += '  CA GHS et EXH facturé : #B#';
						if (SELECT.F_CA_GHS_EXH == 'INTERVAL') {
							if (SELECT.CA_GHS_EXH_I != '') {
								if (SELECT.CA_GHS_EXH_I2 != '') {
									display += 'entre ' + SELECT.CA_GHS_EXH_I + ' et ' + SELECT.CA_GHS_EXH_I2 + ' euros';
								}
								else {
									display += '#GE# ' + SELECT.CA_GHS_EXH_I + ' euros';
								}
							}
							else {
								display += '#LE# ' + SELECT.CA_GHS_EXH_I2 + ' euros';
							}
						}
						if (SELECT.F_CA_GHS_EXH == 'GREATER') {
							display += '#GE# ' + SELECT.CA_GHS_EXH_GL + ' euros';
						}
						if (SELECT.F_CA_GHS_EXH == 'LOWER') {
							display += '#LE# ' + SELECT.CA_GHS_EXH_GL + ' euros';
						}
						display += '#/B#';
					}                       
                    
                    if (SELECT.T_TYPE_SEJ_OVALIDE  != '-1'  ) {
                            display = display + '  Type séjour OVALIDE :#B# ' + SELECT.T_TYPE_SEJ_OVALIDE_LABEL + '#/B#';
                        
                    }
					if (SELECT.NO_RSS  != '') {
						display = display + ' RSS ID: #B#' + SELECT.NO_RSS.split(/[\s,]+/gm).join(', ');
						display = display + '#/B# ';
					}					
                    if (SELECT.F_RAAC  != '-1') {
						display = display + ' RAAC : #B#' + SELECT.F_RAAC_LABEL;
						display = display + '#/B# ';
					}                    
                    if (SELECT.F_NP  != '-1') {
						display = display + ' NP : #B#' + SELECT.F_NP_LABEL;
						display = display + '#/B# ';
					}                   

					if (SELECT.F_PASSAGE_URGENCES  != '-1') {
						display = display + ' Passage Urgence : #B#' + SELECT.F_PASSAGE_URGENCES_LABEL;
						display = display + '#/B# ';
					}        

                    if (SELECT.F_HPHC  != '-1') {
						display = display + ' Conversion (HP,HC) : #B#' + SELECT.F_HPHC_LABEL;
						display = display + '#/B# ';
					}
                    if (SELECT.F_RESC_TARIF  != '-1') {
						display = display + ' Rescrit tarifaire : #B#' + SELECT.F_RESC_TARIF_LABEL;
						display = display + '#/B# ';
					}
					if (SELECT.F_ADM_PROD_RESHOSPI  != '-1') {
						display = display + ' Administration de produits de la réserve hospitalière : #B#' + SELECT.F_ADM_PROD_RESHOSPI_LABEL;
						display = display + '#/B# ';
					}
					if (SELECT.F_CTX_PAT  != '-1') {
						display = display + ' Contexte du patient : #B#' + SELECT.F_CTX_PAT_LABEL;
						display = display + '#/B# ';
					}
					if (SELECT.F_NB_INTERV  != '-1') {
						display = display + ' Nombre intervention : #B#' + SELECT.F_NB_INTERV_LABEL;
						display = display + '#/B# ';
					}
					if (SELECT.MONO_UHCD  !== '-1') {
						display = display + ' RUM en UHCD : #B#' + SELECT.MONO_UHCD_LABEL;
						display = display + '#/B# ';
					}
					if (SELECT.MEDECIN_RUM_RSS  !== '-1') {
						display = display + ' Avec médecin RUM : #B#' + SELECT.MEDECIN_RUM_RSS_LABEL;
						display = display + '#/B# ';
					} 
					
					return display;
					" 
			>
			
			<GROUP label="Etablissement">
				<FIELD name="FINESS" label="" UI="combo" tree="true" width="400" default="-1" showIfNotDefault="true" globalListProvider="Etablissement" />
			</GROUP>
			<GROUP label="Champ e-PMSI">
				<FIELD name="CHAMP" label="Champ e-PMSI" UI="combo" tree="true" width="400" default="EX" globalListProvider="CHAMP" 
					showIfNotDefault="true"/>
			</GROUP>
			<GROUP label="C.A.S.">
				<FIELD name="CAS_C" label="Chirurgie (C)" UI="check" selectedValue="C" unselectedValue="0" default="C" showIfNotDefault="true" />
				<FIELD name="CAS_K" label="Techniques peu invasives (K)" UI="check" selectedValue="K" unselectedValue="0" default="K" showIfNotDefault="true" />
				<FIELD name="CAS_X" label="Sans Acte classant (X)" UI="check" selectedValue="X" unselectedValue="0" default="X" showIfNotDefault="true" />
			</GROUP>
			<GROUP label = " ">
				<FIELD name="CAS_N" label="Nouveaux-nés (N)" UI="check" selectedValue="N" unselectedValue="0" default="N" showIfNotDefault="true" />
				<FIELD name="CAS_O" label="Obstétrique (O)" UI="check" selectedValue="O" unselectedValue="0" default="O" showIfNotDefault="true" />
				<FIELD name="CAS_S" label="Séances (S)" UI="check" selectedValue="S" unselectedValue="0" default="S" showIfNotDefault="true" />
			</GROUP>			
            <GROUP label = "e-PMSI sans GHM">
				<FIELD name="CAS_W" label="" UI="check" selectedValue="*" unselectedValue="N" default="N" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Type OVALIDE">
				<FIELD name="T_TYPE_SEJ_OVALIDE" label="" UI="combo" tree="true" width="300" default="-1" globalListProvider="T_TYPE_SEJ_OVALIDE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label = "Activité urgence">
				<FIELD name="ACT_URG" label="" UI="check" selectedValue="*" unselectedValue="N" default="N" showIfNotDefault="true" />
			</GROUP>			
            <GROUP label="Durée de séjour">
				<FIELD name="T_DUREE_SEJOUR" label="Durée de séjour" UI="combo" tree="true" width="200" default="-1" globalListProvider="T_DUREE_SEJOUR" showIfNotDefault="true" />
				<FIELD name="DUREE_SEJOUR" label="" UI="numberInterval" width="125" default="" default2="" visible="= SELECT.T_DUREE_SEJOUR == 'I'" />
			</GROUP>
			<GROUP label="Age">
				<FIELD name="T_AGE" label="Age" UI="combo" width="200" default="-1" tree="true" globalListProvider="T_AGE"  showIfNotDefault="true" />
				<FIELD name="AGE" label="Age" UI="numberInterval" width="100" default=""  default2="" 
						hidable="= SELECT.T_AGE == '-1' " visible="= SELECT.T_AGE == 'I'">
				</FIELD>
			</GROUP>
			<GROUP label="Facturable AMO">
				<FIELD name="PEC" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="PEC" />
			</GROUP>
			<GROUP label="GHM" direction="vertical" collapsible="true">
				<GROUP label="CMD - GHM">
					<FIELD name="GHM" label="CMD - GHM" UI="combo" tree="true" width="400" default="-1" hidable="= SELECT.GHM == '-1'" globalListProvider="GHM"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Racine GHM">
					<FIELD name="GHM5" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="GHM5" showIfNotDefault="true" />
				</GROUP>				
                <GROUP label="Sévérité">
					<FIELD name="GHMSEV" label="" UI="combo" tree="true" width="195" default="-1" globalListProvider="GHMSEV" showIfNotDefault="true" />
					<FIELD name="CTISEV" label="" UI="combo" tree="true" width="195" default="-1" globalListProvider="SEVCTI" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="GHS">
					<FIELD name="GHS" label="GHS" UI="combo" tree="true" width="400" default="-1" globalListProvider="GHS"  showIfNotDefault="true" />
				</GROUP>
                <GROUP label="GHS Asssocié">
               	 	<FIELD name="T_GHSASSOS" label="" UI="combo" width="150" default="-1" globalListProvider="T_GHSASSOS"  hidable="= SELECT.T_GHSASSOS == '-1'" showIfNotDefault="true" />
                    <FIELD name="GHSASSOS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="GHS" visible="= SELECT.T_GHSASSOS != '-1' &amp;&amp; SELECT.T_GHSASSOS != 'X**'" />
                </GROUP>                
				<GROUP label="CA GHS + EXH Facturé">
					<FIELD name="F_CA_GHS_EXH" label="CA GHS + EXH Facturé" UI="combo" width="200" default="-1" tree="false" globalListProvider="F_CA_GHS_EXH"  showIfNotDefault="true" />
					<FIELD name="CA_GHS_EXH_I" label="" UI="numberInterval" width="100" default=""  default2="" visible="= SELECT.F_CA_GHS_EXH == 'INTERVAL'" />
					<FIELD name="CA_GHS_EXH_GL" label="" UI="number" width="100" default=""  default2="" visible="= SELECT.F_CA_GHS_EXH == 'GREATER' || SELECT.F_CA_GHS_EXH == 'LOWER'" />
				</GROUP>               
				<GROUP label="ASo">
					<FIELD name="MCO_M" label="Médecine" UI="check" selectedValue="M" unselectedValue="" default="M"  showIfNotDefault="true" />
					<FIELD name="MCO_C" label="Chirurgie" UI="check" selectedValue="C" unselectedValue="" default="C"  showIfNotDefault="true" />
					<FIELD name="MCO_O" label="Obstétrique" UI="check" selectedValue="O" unselectedValue="" default="O" showIfNotDefault="true" />
					<FIELD name="MCO_S" label="Séances" UI="check" selectedValue="S" unselectedValue="" default="S" showIfNotDefault="true" />
					<FIELD name="MCO_H" label="e-PMSI Hors GHM" UI="check" selectedValue="*" unselectedValue="" default="*" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="OAP">
					<FIELD name="OAP" label="OAP" UI="combo" tree="true" width="400" default="-1" hidable="= SELECT.OAP == '-1'" globalListProvider="OAP" showIfNotDefault="true" />
				</GROUP>
			</GROUP>
			<GROUP label="Médecin" direction="vertical" collapsible="true">
				<GROUP label="Médecin RSS">
					<FIELD name="MEDECIN_RSS" label="Médecin RSS" UI="combo" tree="true" width="400" default="-1"  globalListProvider="MEDECIN_RSS"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Médecin Acte">
					<FIELD name="MEDECIN_ACTE_RSS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MEDECIN_ACTE"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Médecin rum">
					<FIELD name="MEDECIN_RUM_RSS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MEDECIN_RUM"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Comité médical">
					<FIELD name="COMITE_MEDICAL" label="Comité médical" UI="combo" tree="true" width="400" default="-1" globalListProvider="COMITE_MEDICAL"  showIfNotDefault="true"
					visible="= ENV.OPTPMSI_COMITE == '1'" />
				</GROUP>
			</GROUP>
			<GROUP label="Variables" direction="vertical" collapsible="true">
            	<GROUP label="Conversion (HP,HC)">
					<FIELD name="F_HPHC" label="        " UI="combo" width="200" default="-1" tree="true" globalListProvider="F_HPHC"  showIfNotDefault="true" />
				</GROUP>            
            	<GROUP label="RAAC">
					<FIELD name="F_RAAC" label="        " UI="combo" width="200" default="-1" tree="true" globalListProvider="F_RAAC"  showIfNotDefault="true" />
				</GROUP>				
            	<GROUP label="NP">
					<FIELD name="F_NP" label="        " UI="combo" width="200" default="-1" tree="true" globalListProvider="F_NP"  showIfNotDefault="true" />
				</GROUP>	
				<GROUP label="Rescrit tarifaire">
					<FIELD name="F_RESC_TARIF" label="        " UI="combo" tree="true" width="400" default="-1"  globalListProvider="F_RESC_TARIF"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Produits réserve hospitalière">
					<FIELD name="F_ADM_PROD_RESHOSPI" label="        " UI="combo" tree="true" width="400" default="-1" globalListProvider="F_ADM_PROD_RESHOSPI"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Contexte patient">
					<FIELD name="F_CTX_PAT" label="        " UI="combo" tree="true" width="400" default="-1" globalListProvider="F_CTX_PAT"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Nb d'intervention">
					<FIELD name="F_NB_INTERV" label="        " UI="combo" tree="true" width="400" default="-1" globalListProvider="F_NB_INTERV"  showIfNotDefault="true" />
				</GROUP>
			</GROUP>
			<GROUP label="Diagnostic" direction="vertical" collapsible="true">
				<GROUP label="Nb Diags">
				<FIELD name="T_NB_DIAG_RSS" label="" UI="combo" width="200" default="-1" tree="false" globalListProvider="T_NB_DIAG_RSS" showIfNotDefault="true" />
				<FIELD name="T_NB_DIAG2_RSS" label="" UI="combo" width="150" default="D" globalListProvider="T_DIAG2" hidable="= SELECT.T_NB_DIAG_RSS == '-1'" visible="= SELECT.T_NB_DIAG_RSS == 'I'" />
				<FIELD name="NB_DIAG_RSS" label="" UI="numberInterval" width="100" default=""  default2="" hidable="= SELECT.T_NB_DIAG_RSS == '-1' " visible="= SELECT.T_NB_DIAG_RSS == 'I'" showIfNotDefault="true" />
			</GROUP>
				<GROUP label="Diagnostic RSS">
				<FIELD name="T_DIAG_1_RSS" label="Diagnostic RSS" UI="combo" width="150" default="-1" globalListProvider="T_DIAG" hidable="= SELECT.T_DIAG_1_RSS == '-1'" showIfNotDefault="true" />
					<FIELD name="DIAG_1_RSS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="DIAG" visible="= SELECT.T_DIAG_1_RSS != '-1'" />
				</GROUP>
				<GROUP label="Diagnostic RSS">
				<FIELD name="T_DIAG_2_RSS" label="Diagnostic RSS" UI="combo" width="150" default="-1" globalListProvider="T_DIAG" hidable="= SELECT.T_DIAG_2_RSS == '-1'" showIfNotDefault="true" />
					<FIELD name="DIAG_2_RSS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="DIAG" visible="= SELECT.T_DIAG_2_RSS != '-1'" />
				</GROUP>
				<GROUP label="Seuil Cancéro.">
					<FIELD name="SEUIL_CANCERO_PRINCIPAL" UI="combo" tree="true" width="400" default="-1" globalListProvider="SEUIL_CANCERO" showIfNotDefault="true" />
				</GROUP>
				</GROUP>
			<GROUP label="Acte" direction="vertical" collapsible="true">
				<GROUP label="Nb Actes RSS">
				<FIELD name="T_NB_ACTE_RSS" label="" UI="combo" width="200" default="-1" tree="false" globalListProvider="T_NB_ACTE_RSS"  showIfNotDefault="true" />
				<FIELD name="NB_ACTE_RSS" label="" UI="numberInterval" width="100" default=""  default2="" hidable="= SELECT.T_NB_ACTE_RSS == '-1' " visible="= SELECT.T_NB_ACTE_RSS == 'I'" />
			</GROUP>
				<GROUP label="Acte RSS">
					<FIELD name="ACTE_RSS" label="Acte RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE"  showIfNotDefault="true" />
					<FIELD name="ACTE_RSS_ACTIVITE_CCAM" label="" UI="combo" default="-1" globalListProvider="ACTE_RSS_ACTIVITE_CCAM" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Acte RSS">
					<FIELD name="ACTE_2_RSS" label="Acte RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE"  showIfNotDefault="true" />
					<FIELD name="ACTE_2_RSS_ACTIVITE_CCAM" label="" UI="combo" default="-1" globalListProvider="ACTE_RSS_ACTIVITE_CCAM" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="GM Principal">
					<FIELD name="GESTE_MARQUEUR" label="GM Principal" UI="combo" tree="true" width="400" default="-1" globalListProvider="GESTE_MARQUEUR" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Sans anesthésie">
					<FIELD name="ACTE_RSS_SANS_ANESTHESIE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE_RSS_SANS_ANESTHESIE"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Ext. documentaire">
					<FIELD name="EXTDOC" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE_EXTENSION_DOC" showIfNotDefault="true" />
				</GROUP>
                <GROUP label="Modificateurs CCAM">
                    <FIELD name="RSSMCC" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MCC" showIfNotDefault="true" />
                </GROUP>
				<GROUP label="UF réalisation">
					<FIELD name="UF_RSS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UF"  showIfNotDefault="true" />
				</GROUP>
			</GROUP>
			<GROUP label="RSS" direction="vertical" collapsible="true">
				<GROUP label="Listes RSS">
					<FIELD name="LIRSS" label="Fiche n°5" UI="combo" tree="true" width="400" default="-1" globalListProvider="LIRSS"  showIfNotDefault="true" />
				</GROUP>
            <GROUP label="N° de RSS">
                <FIELD name="NO_RSS" label="" UI="textArea" width="200" height="40" default="" showIfNotDefault="true" />
            </GROUP>
                <GROUP label="Etat de séjours">
					<FIELD name="ETAT_RSS" label="Etat de séjours" UI="combo" tree="true" width="400" default="-1" globalListProvider="ETAT_RSS"  showIfNotDefault="true" />
				</GROUP>
                <GROUP label="Ecart DMS">
					<FIELD name="T_ECART_DMS" width="120" label="Ecart DMS" UI="combo" showIfNotDefault="true" default="-1">
						<OPTION label="Pas de sélection" data="-1" />
						<OPTION label="Valeur" data="1" />
					</FIELD>
					<FIELD name="ECART_DMS_OPERATOR" width="100" label="" UI="combo" default="2" visible="= SELECT.T_ECART_DMS != '-1' " showIfNotDefault="true">
						<OPTION label="=" data="1" />
						<OPTION label="&gt;=" data="2" />
						<OPTION label="&lt;=" data="3" />
						<OPTION label="entre" data="4" />
						<OPTION label="différent de" data="5" />
					</FIELD>
					<FIELD name="ECART_DMS_FIELD1" width="30" label="" UI="number" default="" visible="= SELECT.T_ECART_DMS != '-1' " showIfNotDefault="true" />
					<FIELD name="ECART_DMS_FIELD2" width="30" label="et" UI="number" default="" visible="= (SELECT.T_ECART_DMS != '-1') &amp;&amp; (SELECT.ECART_DMS_OPERATOR == '4') " showIfNotDefault="true" />
					<FIELD name="DMS_CLASSE" label="DMS de réf." UI="combo" width="185" default="-1" globalListProvider="DMS_CLASSES" showIfNotDefault="true"  visible="= SELECT.T_ECART_DMS != '-1' || SELECT.SHOWDMSREF == '1'" />
				</GROUP>
				<GROUP label="Type facturation">
					<FIELD name="TYPFAC" label="Type facturation" UI="combo" tree="true" width="400" default="-1" globalListProvider="TYPFAC"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="I.P.A.">
					<FIELD name="IPA" label="I.P.A." UI="combo" tree="true" width="400" default="-1" globalListProvider="IPA" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="LPP RSS">
					<FIELD name="LPP_RSS" label="LPP RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="LPP"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="UCD RSS">
					<FIELD name="UCD_RSS" label="UCD RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="UCD"  showIfNotDefault="true" />
				</GROUP>				
                <GROUP label="Indication UCD RSS">
					<FIELD name="IUCD_RSS" label="Indication UCD RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="I_UCD"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Prestation RSS">
					<FIELD name="PRESTATION_RSS" label="Prestation RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="PRESTATION"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Divers">
					<FIELD name="DIVERS" label="Divers" UI="combo" width="400" default="-1" globalListProvider="DIVERS_RSS" showIfNotDefault="true" />
				</GROUP>
				<!-- Groupe activité deprecated -->
				<GROUP label="Groupe activité">
					<FIELD name="GA" label="Groupe activité" UI="combo" width="400" default="-1" globalListProvider="GA" showIfNotDefault="true" visible="false" />
				</GROUP>
				<GROUP>
					<FIELD name="PARAMETRE_PERSONNALISE_RSS_1" label="[DICT.PMSI.PARAMETRE_PERSONNALISE_RSS_1]" 
						UI="combo" tree="true" width="400" default="-1"  
						globalListProvider="PARAMETRE_PERSONNALISE_RSS_1" 
						visible="= '[DICT.PMSI.PARAMETRE_PERSONNALISE_RSS_1]' != 'NULL'"
						showIfNotDefault="true" />
				</GROUP>
				<GROUP>
					<FIELD name="PARAMETRE_PERSONNALISE_RSS_2" label="[DICT.PMSI.PARAMETRE_PERSONNALISE_RSS_2]" 
						UI="combo" tree="true" width="400" default="-1"  
						globalListProvider="PARAMETRE_PERSONNALISE_RSS_2" 
						visible="= '[DICT.PMSI.PARAMETRE_PERSONNALISE_RSS_2]' != 'NULL'"
						showIfNotDefault="true" />
				</GROUP>
			</GROUP>
			<GROUP label="RUM" direction="vertical" collapsible="true">
				<GROUP label="Unité principale">
					<FIELD name="UM_PRINCIPALE" label="" UI="combo" tree="true" width="400" default="-1"  globalListProvider="UM"  showIfNotDefault="true" />
				</GROUP>				
                <GROUP label="1ère UM">
					<FIELD name="PREMIERE_UM" label="" UI="combo" tree="true" width="400" default="-1"  globalListProvider="UM"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Passé dans UM">
					<FIELD name="UM_RSS" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM"  showIfNotDefault="true" />
				</GROUP>
                <GROUP label="Pole principal">
					<FIELD name="POLE_PRINCIPAL" label="" UI="combo" tree="true" width="400" default="-1"  globalListProvider="POLE"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="RUM/UHCD">
					<FIELD name="MONO_UHCD" width="400" label="" UI="combo" default="-1" showIfNotDefault="true">
						<OPTION label="Pas de sélection" data="-1" />
						<OPTION label="Mono RUM en UHCD" data="1" />
						<OPTION label="Mono/multi RUM (mono hors UHCD)" data="2" />
					</FIELD>
				</GROUP>
			</GROUP>
			<GROUP label="Patient" direction="vertical" collapsible="true">
				<GROUP label="Sexe">
					<FIELD name="SEXE" label="Sexe" UI="combo" width="200" default="-1" globalListProvider="SEXE" showIfNotDefault="true" />
				</GROUP>
				
				<GROUP label="Origine géo.">
					<FIELD name="CODE_POSTAL" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="CODE_POSTAL"  showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Modes entrée">
					<FIELD name="MODE_ENTREE" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="MODE_ENTREE" showIfNotDefault="true" />
					<FIELD name="PROVENANCE" label="Prov." labelWidth="40" UI="combo" tree="false" width="200" default="-1" globalListProvider="PROVENANCES" showIfNotDefault="true" />
					<FIELD name="MEN_PROV_RSS_RUM" width="80" label="" UI="combo" default="RSS" showIfNotDefault="true">
						<OPTION label="RSS" data="RSS" />
						<OPTION label="RUM" data="RUM" />
					</FIELD>
				</GROUP>				
                <GROUP label="Etab. provenance">
					<FIELD name="ETAB_PROVE" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="ETABLISSEMENTS_PROVENANCE" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Passage Urgences">
					<FIELD name="F_PASSAGE_URGENCES" label="" UI="combo" width="200" default="-1" tree="true" globalListProvider="F_PASSAGE_URGENCES"  showIfNotDefault="true" />
				</GROUP>			
				<GROUP label="Modes sortie">
					<FIELD name="MODE_SORTIE" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="MODE_SORTIE" showIfNotDefault="true" />
					<FIELD name="DESTINATION" label="Dest." labelWidth="40" UI="combo" tree="false" width="200" default="-1" globalListProvider="DESTINATIONS" showIfNotDefault="true" />
					<FIELD name="MSO_DEST_RSS_RUM" width="80" label="" UI="combo" default="RSS" showIfNotDefault="true">
						<OPTION label="RSS" data="RSS" />
						<OPTION label="RUM" data="RUM" />
					</FIELD>
				</GROUP>
                <GROUP label="Etab. destination">
					<FIELD name="ETAB_DEST" label="" labelWidth="40" UI="combo" tree="false" width="200" default="-1" globalListProvider="ETABLISSEMENTS_DESTINATION" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Age gestationnel">
					<FIELD name="T_GEST" label="Age gestationnel" UI="combo" width="200" default="-1" tree="false" globalListProvider="T_GEST"  showIfNotDefault="true" />
					<FIELD name="GEST" label="Age gestationnel" UI="numberInterval" width="100" default=""  default2="" 
							hidable="= SELECT.T_GEST == '-1' " visible="= SELECT.T_GEST == 'I'" />
				</GROUP>
                <GROUP label="Age en jours">
                    <FIELD name="T_AGE_JOURS" label="" UI="combo" width="200" default="-1" tree="true" globalListProvider="T_AGE_JOURS" showIfNotDefault="true" />
                    <FIELD name="AGE_JOURS" label="" UI="numberInterval" width="100" default=""  default2="" 
                            hidable="= SELECT.T_AGE_JOURS == '-1' " visible="= SELECT.T_AGE_JOURS == 'I'">
                    </FIELD>
                </GROUP>
				<GROUP label="Poids bébé">
					<FIELD name="T_POIDS_BEBE" label="Poids bébé" UI="combo" width="200" default="-1" tree="false" globalListProvider="T_POIDS_BEBE"  showIfNotDefault="true" />
					<FIELD name="POIDS_BEBE" label="Poids bébé" UI="numberInterval" width="100" default=""  default2="" 
							hidable="= SELECT.T_POIDS_BEBE == '-1' " visible="= SELECT.T_POIDS_BEBE == 'I'" />
				</GROUP>
				<GROUP>
						<FIELD name="NIP" label="N° Patients (NIP)" UI="text" width="200" default="" showIfNotDefault="true"/>
				</GROUP>
			</GROUP>
			<GROUP label="Prise en charge" direction="vertical" collapsible="true">
				<GROUP label="Taux de remboursement">
					<FIELD name="TAUX_REMB" label="" UI="numberInterval" width="125" default="" default2="" showIfNotDefault="true" />
				</GROUP>
				<GROUP label="Grand régime">
					<FIELD name="REGIME" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="REGIME" />
				</GROUP>
				<GROUPx label="Facturable AMO">
					<FIELD name="PEC" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="PEC" />
				</GROUPx>
				<GROUP label="Motif non fact.">
					<FIELD name="MOTIF_NON_FACTURATION" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="MOTIF_NON_FACTURATION" />
				</GROUP>
				<GROUP label="Nature assurance">
					<FIELD name="NATURE_PEC" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="NATURE_PEC" />
				</GROUP>
				<GROUP label="Type contrat OC">
					<FIELD name="TYPE_CONTRAT_OC" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="TYPE_CONTRAT_OC" />
				</GROUP>
				<GROUP label="Forfait journalier">
					<FIELD name="PEC_FJ" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="PEC_FJ" />
				</GROUP>
				<GROUP label="Exonération TM">
					<FIELD name="EXONERATION_TM" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="EXONERATION_TM" />
				</GROUP>
				<GROUP label="Facturation 18¤">
					<FIELD name="FAC_18EUROS" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true" globalListProvider="FAC_18EUROS" />
				</GROUP>
				<GROUP label="CMU">
					<FIELD name="PAT_BENEF_CMU" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true">
						<OPTION label="Pas de sélection" data="-1" />
						<OPTION label="Non renseigné" data="X" />
						<OPTION label="Oui" data="1" />
						<OPTION label="Non" data="0" />
					</FIELD>
				</GROUP>
				<GROUP label="Valorisation FIDES">
					<FIELD name="VALORISE_FIDES" label="" UI="combo" tree="false" width="400" default="-1" showIfNotDefault="true">
						<OPTION label="Pas de sélection" data="-1" />
						<OPTION label="Non renseigné" data="X" />
						<OPTION label="Oui" data="1" />
						<OPTION label="Non" data="0" />
					</FIELD>
				</GROUP>
			</GROUP>
		</SELECTIONS>
		<QUERIES />
	</COMPONENT>
	
	<COMPONENT name="FILTRES_RSS_SOUSSELECTIONS" label="Sous sélections RSS" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PRSA') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PCA') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'RGHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières racines de GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'RGHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières racines de GHM du classement C.A.';}
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="250" UI="combo"  default="-1" tree="true" globalListProvider="RSS_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_MODE" label="" UI="combo"  default="N" visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" >
					<OPTION data="P" label="En pourcentage" />
					<OPTION data="N" label="En nombre" />
				</FIELD>
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'"/>
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_LPP_SOUSSELECTIONS" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNLPP') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre LPP';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNLPP') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre LPP';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NCALPP') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement C.A. LPP';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PCALPP') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A. LPP';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="LPP_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_UCD_SOUSSELECTIONS" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNUCD') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre UCD';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNUCD') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre UCD';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NCAUCD') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement C.A. UCD';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PCAUCD') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A. UCD';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="UCD_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_PRESTATION_SOUSSELECTIONS" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNPRESTA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement prestations en nombre';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNPRESTA') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement prestations en nombre';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NCAPRESTA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement prestations en C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PCAPRESTA') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement prestations en C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="PRESTATION_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	
	<COMPONENT name="FILTRES_PRESTATION_RUM_SOUSSELECTIONS" label="Sous sélections" >
	
		<VIEWPROPERTIES>
	
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_DATA">
				<value>
					<![CDATA[
						[EVAL 
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'S_PU_CA') {
								return "v_rsf_detail_1.base_remboursement_rum";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'S_PU_NB') {
								return "DISTINCT v_rsf_detail_1.rss_id::text || '-' || no_rum::text";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMCA') {
								return "*PMSIGHM5 [VIEW.RSS_SOUSSELECT_OID_WHENIN]";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNB') {
								return "*PMSIGHM5 [VIEW.RSS_SOUSSELECT_OID_WHENIN]";
							}
							return '';
						EVAL]
					]]>
				</value>
			</PROPERTY>

		</VIEWPROPERTIES>
		
		<SELECTIONS label="Données significatives" collapsible="true" displayText="= var display:String = '';

					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMCA') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNB') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'S_PU_CA') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premieres lignes du classement C.A.';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'S_PU_NB') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement occurences';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premieres lignes du classement occurences';
						}
					}

					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
					>
		
			<GROUP  label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="250" UI="combo" default="-1" tree="true" showIfNotDefault="true">
					<OPTION data="-1" label="Toutes les lignes" />
					<OPTION label="Niveau de regroupement analyse" data="S_PU_CA" treeLevel="1" />
					<OPTION label="Selon Rémunération (CA)" data="S_PU_CA" treeLevel="2" />
					<OPTION label="Selon Occurences (Nombre RUM)" data="S_PU_NB" treeLevel="2" />
					<OPTION label="Classement des GHM" data="GHMCA" treeLevel="1" />
					<OPTION label="GHM les plus rémunérateurs" data="GHMCA" treeLevel="2" />
					<OPTION label="GHM les plus fréquents" data="GHMNB" treeLevel="2" />
				</FIELD>
				<FIELD name="ACTIVITE_SIGNIFICATIVE_MODE" label="" UI="combo"  default="P" visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'">
					<OPTION data="P" label="En pourcentage" />
					<OPTION data="N" label="En nombre" />
				</FIELD>
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'"/>
			</GROUP>

		</SELECTIONS>
	
	</COMPONENT>
	
	
	<COMPONENT name="FILTRES_RUM_SOUSSELECTIONS" label="Sous sélections" >
	
		<VIEWPROPERTIES>
	
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_DATA">
				<value>
					<![CDATA[
						[EVAL 
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'S_RU_DUR') {
								return "v_rss_rum_2.duree_sejour_rum";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'S_RU_IGS') {
								return "v_rss_rum_2.igs2_rum";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'S_RU_NB') {
								return "v_rss_rum_2.nb_rum_rum";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMCA') {
								return "*PMSIGHM5 [VIEW.RSS_SOUSSELECT_OID_WHENIN]";
							}
							if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNB') {
								return "*PMSIGHM5 [VIEW.RSS_SOUSSELECT_OID_WHENIN]";
							}
							return '';
						EVAL]
					]]>
				</value>
			</PROPERTY>

		</VIEWPROPERTIES>
		
		<SELECTIONS label="Données significatives" collapsible="true" displayText="= var display:String = '';

					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMCA') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNB') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'S_RU_DUR') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement Durée';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premieres lignes du classement Durée';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'S_RU_IGS') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement IGS';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premieres lignes du classement IGS';
						}
					}
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'S_RU_NB') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'P') {
							display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement occurences';
						}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_MODE == 'N') {
							display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premieres lignes du classement occurences';
						}
					}

					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
					>
		
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="250" UI="combo" default="-1" tree="true" showIfNotDefault="true">
					<OPTION data="-1" label="Toutes les lignes" />
					<OPTION label="Niveau de regroupement analyse" data="S_RU_DUR" treeLevel="1" />
					<OPTION label="Selon Durée de séjour" data="S_RU_DUR" treeLevel="2" />
					<OPTION label="Selon Occurences (Nombre RUM)" data="S_RU_NB" treeLevel="2" />
					<OPTION label="Selon IGS (Nombre RUM)" data="S_RU_IGS" treeLevel="2" />
					<OPTION label="Classement des GHM" data="GHMCA" treeLevel="1" />
					<OPTION label="GHM les plus rémunérateurs" data="GHMCA" treeLevel="2" />
					<OPTION label="GHM les plus fréquents" data="GHMNB" treeLevel="2" />
				</FIELD>
				<FIELD name="ACTIVITE_SIGNIFICATIVE_MODE" label="" UI="combo"  default="P" visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" >
					<OPTION data="P" label="En pourcentage" />
					<OPTION data="N" label="En nombre" />
				</FIELD>
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>

		</SELECTIONS>
	
	</COMPONENT>
	
	<COMPONENT name="FILTRES_RUM_SOUSSELECTIONSx" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNRUM') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre RUM';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNRUM') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre RUM';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NIGRUM') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement IGS2 RUM';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PIGRUM') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement IGS2 RUM';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NDURUM') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement durée de séjour RUM';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PDURUM') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement durée de séjour RUM';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="RUM_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_DIAG_SOUSSELECTIONS" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNDIAG') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre diagnostics';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNDIAG') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre diagnostics';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNPDIAG') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre diagnostics principaux';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNPDIAG') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre diagnostics principaux';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="DIAG_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_ACTE_SOUSSELECTIONS" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNACTE') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre actes';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNACTE') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre actes';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NICRACTE') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement ICR actes';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PICRACTE') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement ICR actes';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="ACTE_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_INTERV_SOUSSELECTIONS" label="Sous sélections" >
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
		
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NNINTERV') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement nombre interventions';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PNINTERV') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement nombre interventions';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NICRINTERV') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement ICR interventions';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PICRINTERV') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement ICR interventions';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" width="300" UI="combo" default="-1" tree="true" globalListProvider="INTERV_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
	
	<COMPONENT name="FILTRES_RSS_SOUSSELECTIONS_ANNEE" label="Sous sélections RSS" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_BASE">
				<value><![CDATA[[EVAL 
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '-1') {
						return '*all';
					}
					else {
						if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0NRSA' || '[ACTIVITE_SIGNIFICATIVE_BASE]' == '0PRSA' || '[ACTIVITE_SIGNIFICATIVE_BASE]' == '0NCA' || '[ACTIVITE_SIGNIFICATIVE_BASE]' == '0PCA') {
							if ('[GROUPBY]' == '1') {return 'v_rss_1.cmd_id';}
							if ('[GROUPBY]' == '2') {return 'v_rss_1.pole_oap_id';}
							if ('[GROUPBY]' == '9') {return 'v_rss_1.ligne_oap_id';}
							if ('[GROUPBY]' == '3') {return 'v_rss_1.groupe_activite_id';}
							if ('[GROUPBY]' == '4') {return 'v_rss_1.ghm_id';}
							if ('[GROUPBY]' == '6') {return 'v_medecin_rss_link.medecin_reference_rss_id';}
							if ('[GROUPBY]' == '7') {return 'v_medecin_rss_link.specialite_interne_medecin_reference_rss_id';}
							if ('[GROUPBY]' == '10') {return 'v_rss_1.diagnostic_principal_id';}
							if ('[GROUPBY]' == 'DIAGPROOT') {return 'v_rss_1.diagnostic_principal_racine_id';}
							if ('[GROUPBY]' == 'UP') {return 'v_rss_1.unite_medicale_principale_id';}
							if ('[GROUPBY]' == '8') {return 'v_rss_1.no_oid, v_rss_1.mcos';}
							if ('[GROUPBY]' == 'FIN') {return 'v_rss_1.finess_id';}
							if ('[GROUPBY]' == 'GHS') {return 'v_rss_1.ghs_id';}
							if ('[GROUPBY]' == 'GHM5') {return 'v_rss_1.ghm5_id';}
							if ('[GROUPBY]' == 'GHMSEV') {return 'v_rss_1.no_oid, v_rss_1.severite_ghm_code';}
							if ('[GROUPBY]' == 'CTISEV') {return 'v_rss_1.no_oid, v_rss_1.severite_cti_code';}
							if ('[GROUPBY]' == 'TYPFAC') {return 'v_rss_1.prestation_principale_id';}
							if ('[GROUPBY]' == 'ACTEP') {return 'v_rss_1.acte_principal_id';}
							return 'v_rss_1.ghm_id';
						}
						else {
							return 'v_rss_1.ghm_id';
						}
					}
					EVAL]]]></value>
			</PROPERTY>
			
			
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_PERCENT">
				<value><![CDATA[[EVAL 
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0PRSA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0PCA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMPRSA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMPCA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					
					return 0;
			EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_NUMBER">
				<value><![CDATA[[EVAL 
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0NRSA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0NCA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNRSA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNCA') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					return 0;
			EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_DATA">
				<value><![CDATA[[EVAL 
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0NRSA') {return 'v_rss_1.nb_rsa';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0PRSA') {return 'v_rss_1.nb_rsa';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0NCA') {return 'v_rss_1.base_remboursement';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '0PCA') {return 'v_rss_1.base_remboursement';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNRSA') {return 'v_rss_1.nb_rsa';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMPRSA') {return 'v_rss_1.nb_rsa';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNCA') {return 'v_rss_1.base_remboursement';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMPCA') {return 'v_rss_1.base_remboursement';}
					return 'v_rss_1.nb_rsa';
			EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_OID_COL">
				<value><![CDATA[[EVAL 
				return "CASE WHEN [VIEW.RSS_SOUSSELECT_OID_WHENIN] THEN -9999997 ELSE -9999998 END ";
			EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="ACTIVITE_SIGNIFICATIVE_TXT_COL">
				<value><![CDATA[[EVAL 
				return  "CASE WHEN [VIEW.RSS_SOUSSELECT_OID_WHENIN] THEN 'Activité significative ([VIEW.RSS_SOUSSELECT_SELECT_PERCENT])' ELSE 'Autres ([VIEW.RSS_SOUSSELECT_OTHER_PERCENT])' END ";
			EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY dataLink="RSS_SOUSSELECT_VIEWPROPERTIES" nameField="name" valueField="value" />
			
		</VIEWPROPERTIES>
		
		<SELECTIONS label="Activité significative" collapsible="true" displayText="= var display:String = '';
					
					if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE  != '-1') {
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PRSA') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0NCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premières lignes du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == '0PCA') {display = display + 'Lignes représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNRSA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPRSA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement séjours';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMNCA') {display = display + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + ' premiers GHM du classement C.A.';}
						if (SELECT.ACTIVITE_SIGNIFICATIVE_BASE == 'GHMPCA') {display = display + 'GHM représentant ' + SELECT.ACTIVITE_SIGNIFICATIVE_NUMBER + '% du classement C.A.';}
						
						display = display + '#/B#';
					}
					
					
					if (display != '') {
						display = '#B#Activité significative#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="Basée sur">
				<FIELD name="ACTIVITE_SIGNIFICATIVE_BASE" label="" UI="combo" tree="true" default="-1" globalListProvider="RSS_SOUSSELECT_LIGNE_OPTIONS" showIfNotDefault="true" />
				<FIELD name="ACTIVITE_SIGNIFICATIVE_NUMBER" label="nombre ou %" UI="text" width="50" default="" 
					visible="= SELECT.ACTIVITE_SIGNIFICATIVE_BASE != '-1'" />
			</GROUP>
			
		</SELECTIONS>
		
		<QUERIES>
			
			<QUERY type="propertiesLink" name="RSS_SOUSSELECT_VIEWPROPERTIES" forRows="false" forSelections="false"> 
				
				<SQL 
					optimizer="V_RSS_X"
					cacheEnabled="true"
					select="
							SELECT name, value  
								FROM pmsi.get_oids_from_classement(
									'#V_RSS_X#', 
									'[VIEW.ACTIVITE_SIGNIFICATIVE_BASE]', 
									'[VIEW.ACTIVITE_SIGNIFICATIVE_DATA]' , 
									[VIEW.ACTIVITE_SIGNIFICATIVE_PERCENT], 
									[VIEW.ACTIVITE_SIGNIFICATIVE_NUMBER], 
									'[DOUBLEQUOTES(date_sortie &gt;= '[ANNEE]0101' AND date_sortie &lt;='[ANNEE]1231')DOUBLEQUOTES]',
									'[DOUBLEQUOTES([VIEW.FILTRE_RSS_SELECT] )DOUBLEQUOTES]',
									''
									) AS (name text, value text)
							" >
					
					<FIELDS>
						<FIELD name="name" />
						<FIELD name="value" />
					</FIELDS>
				</SQL>
				
			</QUERY>
			
		</QUERIES>
		
	</COMPONENT>

	<COMPONENT name="FILTRES_REENTREE_SELECTIONS" label="Filtre RSS" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="DELAI_REENTREE_SELECT">
				<value><![CDATA[[EVAL 
						if ('[DELAI_REENTREE]' != '' && '[DELAI_REENTREE2]' != '' ) {return 'AND delai >= ' . intval('[DELAI_REENTREE]') . ' AND delai <= ' . intval('[DELAI_REENTREE2]');}
						if ('[DELAI_REENTREE]' != '' ) {return 'AND delai >= ' . intval('[DELAI_REENTREE]');}
						if ('[DELAI_REENTREE2]' != '' ) {return 'AND delai <= ' . intval('[DELAI_REENTREE2]');}
						return '';
					EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="FILTRE_REENTREE_SELECT">
				<value><![CDATA[[EVAL 
						$select = '';
						
						
						// Finess
						if ('[FINESS_REENTREE]' != '-1') {
							$mode = substr('[FINESS_REENTREE]',0,2);
							$oid = '[FINESS_REENTREE]';
							if ($mode == 'LS') {
								$section_id = PMSI_get_section_id('[FINESS_REENTREE]');
								$oid = PMSI_get_classe_oid('[FINESS_REENTREE]');
							}
							if ($mode != 'LI' && $mode != 'SL' && $mode != 'LS' ) {
								$mode = 'FI';
							}
							if ($mode == 'LI' || $mode == 'SL') {
								$oid = substr('[FINESS_REENTREE]',2);
							}
							$subselect_select = '';
							
							if ($mode == 'LI') {$subselect_select = " v_rss_1.finess_id IN (SELECT to_id FROM base.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect_select = " v_rss_1.finess_id NOT IN (SELECT to_id FROM base.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect_select = " v_rss_1.finess_id IN (SELECT oid FROM base.t_finess WHERE $section_id = $oid)";}
							if ($mode == 'FI') {$subselect_select = " v_rss_1.finess = '$oid' ";}
							
							if ($subselect_select != '') {
								$select = $select. " AND $subselect_select ";
							}
						}
						
						if ('[CHAMP_REENTREE]' == 'EXGR') {
							$select = $select. " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours_etat IN ('G', 'V')) ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXGV') {
							$select = $select. " AND (v_rss_1.en_cours = '0' OR v_rss_1.en_cours_etat = 'V') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'GR') {
							$select = $select. " AND v_rss_1.en_cours_etat IN ('G', 'V') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EX') {
							$select = $select. " AND v_rss_1.en_cours = '0' ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXTR') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('21', '22', '23', '24', '25', '26', '30', '31', '32', '33') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNTR') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('11', '12', '13', '14', '15') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNTR11') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '11' ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNTR12') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '12' ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNTR13') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '13' ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNTR14') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '14' ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNTR15') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '15' ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXVA') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('30','31','32','33') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXVA30') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('30') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXVA31') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('31') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXVA32') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('32') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXVA33') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('33') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNVA') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi IN ('21', '22', '23', '24', '25', '26') ";
						}
						
						if ('[CHAMP_REENTREE]' == 'EXNVA21') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '21' ";
						}
						if ('[CHAMP_REENTREE]' == 'EXNVA22') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '22' ";
						}
						if ('[CHAMP_REENTREE]' == 'EXNVA23') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '23' ";
						}
						if ('[CHAMP_REENTREE]' == 'EXNVA24') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '24' ";
						}
						if ('[CHAMP_REENTREE]' == 'EXNVA25') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '25' ";
						}
						if ('[CHAMP_REENTREE]' == 'EXNVA26') {
							$select = $select. " AND v_rss_1.en_cours = '0' AND v_rss_1.traitement_epmsi = '26' ";
						}
						
						// Sélection des GHM
						$mode = substr('[GHM_REENTREE]',0,2);
						$oid = substr('[GHM_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[GHM_REENTREE]');
							$oid = PMSI_get_classe_oid('[GHM_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.ghm_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.ghm_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE $section_id = $oid)";}
						if ($mode == 'CM') {$subselect_select = " v_rss_1.cmd_id = $oid ";}
						if ($mode == 'GH') {$subselect_select = " v_rss_1.ghm_id = $oid ";}
						
						if ($mode == 'CA') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE severite_ghm_code IN ('V', 'W'))";}
						if ($mode == 'CW') {$subselect_select = " v_rss_1.ghm_id IN (SELECT to_id FROM pmsi.v_ghm_3 WHERE oid = $oid )";}
						if ($mode == 'CS') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE severite_ghm_code = 'S')";}
						if ($mode == 'SV') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE severite_ghm_code = '$oid')";}
						
						if ($mode == 'C*') {$subselect_select = " v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						$mode = substr('[GHM5_REENTREE]',0,2);
						$oid = substr('[GHM5_REENTREE]',2);
						if ($mode == 'C*') {$select = $select. " AND v_rss_1.ghm5_id IN (SELECT oid FROM pmsi.t_ghm5 WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'G5') {$select = $select. " AND v_rss_1.ghm5_id = $oid";}
						
						$mode = substr('[GHMSEV_REENTREE]',0,2);
						$oid = substr('[GHMSEV_REENTREE]',2);
						if ($mode == 'C*') {$select = $select. " AND v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm WHERE severite ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'SV') {$select = $select. " AND v_rss_1.ghm_id IN (SELECT oid FROM pmsi.t_ghm WHERE severite = '$oid')";}

						
						
						// Sélection des GHS
						$mode = substr('[GHS_REENTREE]',0,2);
						$oid = substr('[GHS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[GHS_REENTREE]');
							$oid = PMSI_get_classe_oid('[GHS_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.ghs_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.ghs_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = " v_rss_1.ghs_id IN (SELECT oid FROM pmsi.t_ghs WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'GS') {$subselect_select = " v_rss_1.ghs_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						if (substr('[OAP_REENTREE]',0,2) == 'PO') {
							$select = $select. ' AND v_rss_1.pole_oap_id = ' . substr('[OAP_REENTREE]',2);
						}
						if (substr('[OAP_REENTREE]',0,2) == 'LO') {
							$select = $select. ' AND v_rss_1.ligne_oap_id = ' . substr('[OAP_REENTREE]',2);
						}
						
						if (substr('[GA_REENTREE]',0,2) == 'GA') {
							$select = $select. ' AND v_rss_1.groupe_activite_id = ' . substr('[GA_REENTREE]',2);
						}
						
						
						if ('[MCO_M_REENTREE]' != 'M') {
							$select .= " AND v_rss_1.mcos_code != 'M' ";
						}
						if ('[MCO_C_REENTREE]' != 'C') {
							$select .= " AND v_rss_1.mcos_code != 'C' ";
						}
						if ('[MCO_O_REENTREE]' != 'O') {
							$select .= " AND v_rss_1.mcos_code != 'O' ";
						}
						if ('[MCO_S_REENTREE]' != 'S') {
							$select .= " AND v_rss_1.mcos_code != 'S' ";
						}
						if ('[MCO_H_REENTREE]' != '*') {
							$select .= " AND v_rss_1.mcos_code != '*' ";
						}
						
						
						
						// Sélection des médecins
						$mode = substr('[MEDECIN_RSS_REENTREE]',0,2);
						$oid = substr('[MEDECIN_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[MEDECIN_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[MEDECIN_RSS_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.medecin_rss_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.medecin_rss_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.medecin_rss_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
						if ($mode == 'SP') {$subselect_select = " v_medecin_rss_link.specialite_interne_medecin_reference_rss_id = $oid ";}
						if ($mode == 'SO') {$subselect_select = " v_medecin_rss_link.specialite_medecin_rss_id = $oid ";}
						if ($mode == 'C*') {$subselect_select = " v_rss_1.medecin_rss_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'MD') {$subselect_select = " v_medecin_rss_link.medecin_reference_rss_id = $oid ";}
						if ($mode == 'DT') {$subselect_select = " v_medecin_rss_link.medecin_reference_rss_id = $oid ";}
						if ($mode == 'D2') {$subselect_select = " v_medecin_rss_link.specialite_interne_medecin_reference_rss_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						
						
						
						if (substr('[MODE_ENTREE_REENTREE]',0,1) == 'I') {
							$select = $select. ' AND v_rss_1.mode_entree = ' . substr('[MODE_ENTREE_REENTREE]',1);
						}
						if (substr('[MODE_ENTREE_REENTREE]',0,1) == 'S') {
							$select = $select. ' AND v_rss_1.mode_entree <> ' . substr('[MODE_ENTREE_REENTREE]',1);
						}
						if (substr('[MODE_SORTIE_REENTREE]',0,1) == 'I') {
							$select = $select. ' AND v_rss_1.mode_sortie = ' . substr('[MODE_SORTIE_REENTREE]',1);
						}
						if (substr('[MODE_SORTIE_REENTREE]',0,1) == 'S') {
							$select = $select. ' AND v_rss_1.mode_sortie <> ' . substr('[MODE_SORTIE_REENTREE]',1);
						}
						if (substr('[PROVENANCE_REENTREE]',0,1) == 'I') {
							$select = $select. ' AND v_rss_1.provenance = ' . substr('[PROVENANCE_REENTREE]',1);
						}
						if (substr('[PROVENANCE_REENTREE]',0,1) == 'S') {
							$select = $select. ' AND v_rss_1.provenance <> ' . substr('[PROVENANCE_REENTREE]',1);
						}
						if (substr('[DESTINATION_REENTREE]',0,1) == 'I') {
							$select = $select. ' AND v_rss_1.destination = ' . substr('[DESTINATION_REENTREE]',1);
						}
						if (substr('[DESTINATION_REENTREE]',0,1) == 'S') {
							$select = $select. ' AND v_rss_1.destination <> ' . substr('[DESTINATION_REENTREE]',1);
						}
						
						// Sélection des durées
						$mode = substr('[T_DUREE_SEJOUR_REENTREE]',0,2);
						$oid = substr('[T_DUREE_SEJOUR_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[T_DUREE_SEJOUR_REENTREE]');
							$oid = PMSI_get_classe_oid('[T_DUREE_SEJOUR_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.duree_sejour IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.duree_sejour NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.duree_sejour IN (SELECT oid FROM pmsi.t_durees_sejour_c WHERE $section_id = $oid)";}
						if ($mode == 'DU') {$subselect_select = " v_rss_1.duree_sejour = $oid ";}
						
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select AND v_rss_1.nb_seances = 0 ";
						}
						else {
							
							// Anciennes codifications
							if ('[T_DUREE_SEJOUR_REENTREE]' == '0') {
								$select = $select. ' AND v_rss_1.duree_sejour = 0 AND v_rss_1.nb_seances = 0';
							}
							if ('x[T_DUREE_SEJOUR_REENTREE]x' == 'x1x') {
								$select = $select. ' AND v_rss_1.duree_sejour = 1 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == '1EX') {
								$select = $select. ' AND v_rss_1.duree_sejour >= 1 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == '01') {
								$select = $select. ' AND v_rss_1.duree_sejour <= 1 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == '012') {
								$select = $select. ' AND v_rss_1.duree_sejour <= 2 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == '1X') {
								$select = $select. ' AND v_rss_1.duree_sejour > 1 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == '2') {
								$select = $select. ' AND v_rss_1.duree_sejour = 2 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == 'X') {
								$select = $select. ' AND v_rss_1.duree_sejour > 2 AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == 'S') {
								$select = $select. ' AND v_rss_1.nb_seances > 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == 'SS') {
								$select = $select. ' AND v_rss_1.nb_seances = 0';
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == 'I' && '[DUREE_SEJOUR]' != '' && '[DUREE_SEJOUR2]' != '' ) {
								$select = $select. ' AND v_rss_1.duree_sejour >= ' . intval('[DUREE_SEJOUR]') . ' AND duree_sejour <= ' . intval('[DUREE_SEJOUR2] AND v_rss_1.nb_seances = 0');
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == 'I' && '[DUREE_SEJOUR]' != '' ) {
								$select = $select. ' AND v_rss_1.duree_sejour >= ' . intval('[DUREE_SEJOUR] AND v_rss_1.nb_seances = 0');
							}
							if ('[T_DUREE_SEJOUR_REENTREE]' == 'I' && '[DUREE_SEJOUR2]' != '' ) {
								$select = $select. ' AND v_rss_1.duree_sejour <= ' . intval('[DUREE_SEJOUR2] AND v_rss_1.nb_seances = 0');
							}
						
						}
						
						
						
						if ('[T_DIAG_1_RSS_REENTREE]' != '-1') {
							$mode = substr('[DIAG_1_RSS_REENTREE]',0,2);
							$oid = substr('[DIAG_1_RSS_REENTREE]',2);
							if ($mode == 'LS') {
								$section_id = PMSI_get_section_id('[DIAG_1_RSS_REENTREE]');
								$oid = PMSI_get_classe_oid('[DIAG_1_RSS_REENTREE]');
							}
							$diag_select = '';
							
							if ('[T_DIAG_1_RSS_REENTREE]' == 'DP' || '[T_DIAG_1_RSS_REENTREE]' == 'DR') {
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DP') {
									if ($mode == 'LI') {$diag_select = "diagnostic_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_principal_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								else {
									if ($mode == 'LI') {$diag_select = "diagnostic_relie_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_relie_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_relie_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								if ($diag_select != '') {
									$select = $select. " AND v_rss_1.$diag_select";
								}
							}
							else {
								if ($mode == 'LI') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'SL') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'DG') {$diag_select = "diagnostic_id = $oid ";}
								if ($mode == 'DR') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
								if ($mode == 'LS') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
								if ($mode == 'C*') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DRRUM') {$diag_select = $diag_select . " AND type_diagnostic = 'DR' ";}
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DA') {$diag_select = $diag_select . " AND type_diagnostic IN ('DA', 'DS') ";}
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DPR') {$diag_select = $diag_select . " AND type_diagnostic IN ('DP', 'DR') ";}
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DP2') {$diag_select = $diag_select . " AND type_diagnostic = 'DP' ";}
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DD') {$diag_select = $diag_select . " AND type_diagnostic = 'DD' ";}
								if ('[T_DIAG_1_RSS_REENTREE]' == 'DHDD') {$diag_select = $diag_select . " AND type_diagnostic != 'DD' ";}
								
								if ($diag_select != '') {
									if ($mode != 'SL') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
								}
							}
						}
						
						if ('[T_DIAG_2_RSS_REENTREE]' != '-1') {
							$mode = substr('[DIAG_2_RSS_REENTREE]',0,2);
							$oid = substr('[DIAG_2_RSS_REENTREE]',2);
							if ($mode == 'LS') {
								$section_id = PMSI_get_section_id('[DIAG_2_RSS_REENTREE]');
								$oid = PMSI_get_classe_oid('[DIAG_2_RSS_REENTREE]');
							}
							$diag_select = '';
							
							if ('[T_DIAG_2_RSS_REENTREE]' == 'DP' || '[T_DIAG_2_RSS_REENTREE]' == 'DR') {
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DP') {
									if ($mode == 'LI') {$diag_select = "diagnostic_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_principal_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_principal_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								else {
									if ($mode == 'LI') {$diag_select = "diagnostic_relie_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'SL') {$diag_select = "diagnostic_relie_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
									if ($mode == 'DG') {$diag_select = "diagnostic_relie_id = $oid ";}
									if ($mode == 'DR') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
									if ($mode == 'LS') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
									if ($mode == 'C*') {$diag_select = "diagnostic_relie_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								}
								if ($diag_select != '') {
									$select = $select. " AND v_rss_1.$diag_select";
								}
							}
							else {
								if ($mode == 'LI') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'SL') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
								if ($mode == 'DG') {$diag_select = "diagnostic_id = $oid ";}
								if ($mode == 'DR') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
								if ($mode == 'LS') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
								if ($mode == 'C*') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
								
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DRRUM') {$diag_select = $diag_select . " AND type_diagnostic = 'DR' ";}
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DA') {$diag_select = $diag_select . " AND type_diagnostic IN ('DA', 'DS') ";}
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DPR') {$diag_select = $diag_select . " AND type_diagnostic IN ('DP', 'DR') ";}
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DP2') {$diag_select = $diag_select . " AND type_diagnostic = 'DP' ";}
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DD') {$diag_select = $diag_select . " AND type_diagnostic = 'DD' ";}
								if ('[T_DIAG_2_RSS_REENTREE]' == 'DHDD') {$diag_select = $diag_select . " AND type_diagnostic != 'DD' ";}
								
								if ($diag_select != '') {
									if ($mode != 'SL') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
									}
								}
							}
						}		
						
						
						
						// Type facturation
						$mode = substr('[TYPFAC_REENTREE]',0,2);

						$oid = substr('[TYPFAC_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[TYPFAC_REENTREE]', 2, 2, 'type_facturation_section_id');
							$oid = PMSI_get_classe_oid('[TYPFAC_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.prestation_principale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.prestation_principale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.prestation_principale_id IN (SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)";}
						if ($mode == 'DT') {$subselect_select = " v_rss_1.prestation_principale_id = $oid ";}
						if ($mode == 'PR') {$subselect_select = " v_rss_1.prestation_principale_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						if ('[SEXE]' != '-1') {
							$select = $select. ' AND v_rss_1.sexe = ' .''. '[SEXE]' .''. ' ';
						}
						
						
						
						$mode = substr('[LPP_RSS_REENTREE]',0,2);
						$oid = substr('[LPP_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[LPP_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[LPP_RSS_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "lpp_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "lpp_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LP') {$subselect_select = "lpp_id = $oid ";}
						if ($mode == 'LS') {$subselect_select = "lpp_id IN (SELECT oid FROM pmsi.t_lpp WHERE $section_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = "lpp_id IN (SELECT oid FROM pmsi.t_lpp WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_lpp WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_lpp WHERE $subselect_select)";
							}
						}
						
						$mode = substr('[UCD_RSS_REENTREE]',0,2);
						$oid = substr('[UCD_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UCD_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[UCD_RSS_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "ucd_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "ucd_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LP') {$subselect_select = "ucd_id = $oid ";}
						if ($mode == 'LS') {$subselect_select = "ucd_id IN (SELECT oid FROM pmsi.t_ucd WHERE $section_id = $oid)";}
						if ($mode == 'C*') {$subselect_select = "ucd_id IN (SELECT oid FROM pmsi.t_ucd WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_ucd WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_ucd WHERE $subselect_select)";
							}
						}
						
						
						$mode = substr('[UM_PRINCIPALE_REENTREE]',0,2);
						$oid = substr('[UM_PRINCIPALE_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UM_PRINCIPALE_REENTREE]');
							$oid = PMSI_get_classe_oid('[UM_PRINCIPALE_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = " v_rss_1.unite_medicale_principale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = " v_rss_1.unite_medicale_principale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = " v_rss_1.unite_medicale_principale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
						if ($mode == 'AN') {$subselect_select = " v_rss_1.unite_medicale_principale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')";}
						if ($mode == 'AT') {$subselect_select = " v_rss_1.unite_medicale_principale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
						if ($mode == 'AU') {$subselect_select = " v_rss_1.unite_medicale_principale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
						if ($mode == 'UM') {$subselect_select = " v_rss_1.unite_medicale_principale_id = $oid ";}
						
						if ($subselect_select != '') {
							$select = $select. " AND $subselect_select ";
						}
						
						
						
						$mode = substr('[UM_RSS_REENTREE]',0,2);
						$oid = substr('[UM_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[UM_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[UM_RSS_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
						if ($mode == 'AN') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
						if ($mode == 'AT') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
						if ($mode == 'AU') {$subselect_select = "unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
						if ($mode == 'UM') {$subselect_select = "unite_medicale_id = $oid ";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_rum WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_rum WHERE $subselect_select)";
							}
						}
						
						
						$mode = substr('[PRESTATION_RSS_REENTREE]',0,2);
						$oid = substr('[PRESTATION_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[PRESTATION_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[PRESTATION_RSS_REENTREE]');
						}
						$subselect_select = '';
						
						if ($mode == 'LI') {$subselect_select = "prestation_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_select = "prestation_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_select = "prestation_id IN (SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)";}
						if ($mode == 'PR') {$subselect_select = "prestation_id = $oid ";}
						
						if ($subselect_select != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rsf_detail WHERE $subselect_select)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rsf_detail WHERE $subselect_select)";
							}
						}
						
						
					
						
						if ('[ACTE_RSS_SANS_ANESTHESIE_REENTREE]' == 'SANSANESTHESIE') {
							$select = $select. " AND v_rss_1.avec_anesthesie IS DISTINCT FROM '1' ";
						} else if ('[ACTE_RSS_SANS_ANESTHESIE_REENTREE]' == 'AVECANESTHESIE') {
							$select = $select. " AND v_rss_1.avec_anesthesie = '1' ";
						}
						
						
						
						// Actes
						$mode = substr('[ACTE_RSS_REENTREE]',0,2);
						$oid = substr('[ACTE_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[ACTE_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[ACTE_RSS_REENTREE]');
						}
						$subselect = '';
						
						if ('[ACTE_RSS_ACTIVITE_CCAM_REENTREE]' != 'P') {
							if ($mode == 'C*') {
								$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
							}
							if ($mode == 'LI') {$subselect = "acte_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect = "acte_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
							if ($mode == 'NO') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
							if ($mode == 'GX') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
							if ($mode == 'GM') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
							if ($mode == 'RC') {$subselect = "acte_regroupement_id = $oid ";}
							if ($mode == 'AC') {$subselect = "acte_id = $oid ";}
							
							if ('[ACTE_RSS_ACTIVITE_CCAM_REENTREE]' == '1') {$subselect = $subselect . " AND activite_ccam <> '4' ";}
							if ('[ACTE_RSS_ACTIVITE_CCAM_REENTREE]' == '4') {$subselect = $subselect . " AND activite_ccam = '4' ";}
							
							if ($subselect != '') {
								if (substr($subselect, 0 , 4) == ' AND') {
									$subselect = substr($subselect, 4);
								}
								if ($mode != 'SL') {
									if ($mode != 'RC') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
									}	
								}
								else {
									$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
								}
							}
							
						}
						else {
							if ($mode == 'C*') {
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
							}
							if ($mode == 'LI') {$subselect = "v_rss_1.acte_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect = "v_rss_1.acte_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
							if ($mode == 'NO') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
							if ($mode == 'GX') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
							if ($mode == 'GM') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
							if ($mode == 'RC') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE acte_regroupement_id = $oid)";}
							if ($mode == 'AC') {$subselect = "v_rss_1.acte_principal_id = $oid ";}
							
							if ($subselect != '') {
								$select = $select. " AND $subselect ";
							}
						}
						
						
						
						
						
						// Actes (2)
						$mode = substr('[ACTE_2_RSS_REENTREE]',0,2);
						$oid = substr('[ACTE_2_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[ACTE_2_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[ACTE_2_RSS_REENTREE]');
						}
						$subselect = '';
						
						if ('[ACTE_2_RSS_ACTIVITE_CCAM_REENTREE]' != 'P') {
							if ($mode == 'C*') {
								$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
							}
							if ($mode == 'LI') {$subselect = "acte_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect = "acte_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
							if ($mode == 'NO') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
							if ($mode == 'GX') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
							if ($mode == 'GM') {$subselect = "acte_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
							if ($mode == 'RC') {$subselect = "acte_regroupement_id = $oid ";}
							if ($mode == 'AC') {$subselect = "acte_id = $oid ";}
							
							if ('[ACTE_2_RSS_ACTIVITE_CCAM_REENTREE]' == '1') {$subselect = $subselect . " AND activite_ccam <> '4' ";}
							if ('[ACTE_2_RSS_ACTIVITE_CCAM_REENTREE]' == '4') {$subselect = $subselect . " AND activite_ccam = '4' ";}
							
							if ($subselect != '') {
								if (substr($subselect, 0 , 4) == ' AND') {
									$subselect = substr($subselect, 4);
								}
								if ($mode != 'SL') {
									if ($mode != 'RC') {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
									}
									else {
										$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
									}	
								}
								else {
									$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_actes WHERE $subselect)";
								}
							}
							
						}
						else {
							if ($mode == 'C*') {
								$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
							}
							if ($mode == 'LI') {$subselect = "v_rss_1.acte_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'SL') {$subselect = "v_rss_1.acte_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
							if ($mode == 'LS') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
							if ($mode == 'NO') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
							if ($mode == 'GX') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
							if ($mode == 'GM') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
							if ($mode == 'RC') {$subselect = "v_rss_1.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE acte_regroupement_id = $oid)";}
							if ($mode == 'AC') {$subselect = "v_rss_1.acte_principal_id = $oid ";}
							
							if ($subselect != '') {
								$select = $select. " AND $subselect ";
							}
						}
						
						
						
						// exécutant Actes
						$mode = substr('[MEDECIN_ACTE_RSS_REENTREE]',0,2);
						$oid = substr('[MEDECIN_ACTE_RSS_REENTREE]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[MEDECIN_ACTE_RSS_REENTREE]');
							$oid = PMSI_get_classe_oid('[MEDECIN_ACTE_RSS_REENTREE]');
						}
						$subselect = '';
						
						
						if ($mode == 'LI') {$subselect = "medecin_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect = "medecin_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect = "medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
						if ($mode == 'SP') {$subselect = "specialite_interne_medecin_reference_id = $oid ";}
						if ($mode == 'SO') {$subselect = "specialite_medecin_reference_id = $oid ";}
						if ($mode == 'C*') {$subselect = "medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'MD') {$subselect = "medecin_reference_id = $oid ";}
						if ($mode == 'DT') {$subselect = "medecin_reference_id = $oid ";}
						if ($mode == 'D2') {$subselect = "specialite_interne_medecin_reference_id = $oid ";}
						
						if ($subselect != '') {
							if ($mode != 'SL') {
								$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
							}
							else {
								$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.v_rss_actes_1 WHERE $subselect)";
							}
						}
						
						if ('[DIVERS_REENTREE]' == 'MULTIRUM') {
							$select = $select. ' AND (v_rss_1.nb_rum > 1 )';
						}
						if ('[DIVERS_REENTREE]' == 'MONORUM') {
							$select = $select. ' AND (v_rss_1.nb_rum = 1 )';
						}
						if ('[DIVERS_REENTREE]' == 'EXB') {
							$select = $select. ' AND v_rss_1.nb_exb <> 0 ';
						}
						if ('[DIVERS_REENTREE]' == 'OMITFACNUL') {
							$select = $select. ' AND (v_rss_1.nb_factures_nulles = 0 )';
						}
						if ('[DIVERS_REENTREE]' == 'OMITFACNULBB') {
							$select = $select. ' AND (v_rss_1.base_remboursement <> 0 )';
						}
						if ('[DIVERS_REENTREE]' == 'OMITBB') {
							$select = $select. " AND (v_rss_1.ghm_code NOT ILIKE '15%')";
						}
						
						
						return $select;
					EVAL]]]></value>
			</PROPERTY>
		
		</VIEWPROPERTIES>
		
		<SELECTIONS label="Filtres Ré-Entrées" displayText="= var display:String = '';

					if (SELECT.DELAI_REENTREE != '') {
						display = display + '  Délai de Ré-Entrée : #B#';
						if (SELECT.DELAI_REENTREE2 != '') {
							display = display + '#GE# ' + SELECT.DELAI_REENTREE + ' et #LE# ' + SELECT.DELAI_REENTREE2 + ' jour(s)';
						}
						else {
							display = display + '#GE# ' + SELECT.DELAI_REENTREE + ' jour(s)';
						}
						display = display + '#/B#';
					}
					else {
						if (SELECT.DELAI_REENTREE2 != '') {
							display = display + '  Délai de Ré-Entrée : #B#';
							display = display + '#LE# ' + SELECT.DELAI_REENTREE2 + ' jour(s)';
							display = display + '#/B#';
						}
					}
					
					
					if (SELECT.FINESS_REENTREE  != '-1') {
						display = display + '  FINESS_REENTREE : #B#' + SELECT.FINESS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.CHAMP_REENTREE  != 'EX') {
						display = display + '  Champ e-PMSI : #B#' + SELECT.CHAMP_REENTREE_LABEL + '#/B#';
					}
					
					if (SELECT.MCO_M_REENTREE + SELECT.MCO_C_REENTREE + SELECT.MCO_O_REENTREE + SELECT.MCO_S_REENTREE + SELECT.MCO_H_REENTREE != 'MCOS*') {
						display += '  ASO : #B#';
						if (SELECT.MCO_M_REENTREE + SELECT.MCO_C_REENTREE + SELECT.MCO_O_REENTREE + SELECT.MCO_S_REENTREE == 'MCOS') {
							display += 'M.C.O. ';
						}
						else {
							if (SELECT.MCO_M_REENTREE == 'M') {
								display += 'Médecine ';
							}
							if (SELECT.MCO_C_REENTREE == 'C') {
								display += 'Chirurgie ';
							}
							if (SELECT.MCO_O_REENTREE == 'O') {
								display += 'Obstétrique ';
							}
							if (SELECT.MCO_S_REENTREE == 'S') {
								display += 'Séance ';
							}
							if (SELECT.MCO_H_REENTREE == '*') {
								display += 'e-PMSI hors GHM ';
							}
						}
						display += '#/B#';
					}
					if (SELECT.T_DUREE_SEJOUR_REENTREE  != '-1') {
						display = display + '  Durée séjour : #B#';
						if (SELECT.T_DUREE_SEJOUR_REENTREE != 'I') {
							display = display + SELECT.T_DUREE_SEJOUR_REENTREE_LABEL;
						}
						else {
							if (SELECT.DUREE_SEJOUR_REENTREE != '') {
								if (SELECT.DUREE_SEJOUR_REENTREE2 != '') {
									display = display + '#GE# ' + SELECT.DUREE_SEJOUR_REENTREE + ' et #LE# ' + SELECT.DUREE_SEJOUR_REENTREE2 + ' nuit(s)';
								}
								else {
									display = display + '#GE# ' + SELECT.DUREE_SEJOUR_REENTREE + ' nuit(s)';
								}
							}
							else {
								display = display + '#LE# ' + SELECT.DUREE_SEJOUR_REENTREE2 + ' nuit(s)';
							}
						}
						display = display + '#/B#';
					}
					
					if (SELECT.MODE_ENTREE_REENTREE  != '-1') {
						display = display + '  Mode entrée : #B#' + SELECT.MODE_ENTREE_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.PROVENANCE_REENTREE  != '-1') {
						display = display + '  Provenance : #B#' + SELECT.PROVENANCE_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.MODE_SORTIE_REENTREE  != '-1') {
						display = display + '  Mode sortie : #B#' + SELECT.MODE_SORTIE_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.DESTINATION_REENTREE  != '-1') {
						display = display + '  Destination : #B#' + SELECT.DESTINATION_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.OAP_REENTREE  != '-1') {
						display = display + '  OAP : #B#' + SELECT.OAP_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.GHM_REENTREE  != '-1') {
						display = display + '  ';
						if (SELECT.GHM_REENTREE.substr(0,2) == 'CM') {
							display = display + 'CMD';
						}
						else {
							if (SELECT.GHM_REENTREE.substr(0,2) == 'GH') {
								display = display + 'GHM';
							}
							else {
								if (SELECT.GHM_REENTREE.substr(0,2) == 'CW') {
									display = display + 'GHM';
								}
								else {
									if (SELECT.GHM_REENTREE.substr(0,2) == 'SV') {
										display = display + 'Sévérité GHM';
									}
									else {
										display = display + 'GHM';
									}
								}
							}
						}
						
						display = display + ' : #B#' + SELECT.GHM_REENTREE_LABEL + '#/B#';
						
					
					}
					if (SELECT.GHM5_REENTREE  != '-1') {
						display = display + '  Racine GHM : #B#' + SELECT.GHM5_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.GHMSEV_REENTREE  != '-1') {
						display = display + '  Sévérité GHM : #B#' + SELECT.GHMSEV_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.GA_REENTREE  != '-1') {
						display = display + '  Groupe activité : #B#' + SELECT.GA_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.MEDECIN_RSS_REENTREE  != '-1') {
						display = display + '  Médecin RSS : #B#' + SELECT.MEDECIN_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.T_DIAG_1_RSS_REENTREE  != '-1') {
						display = display + '  avec ' + SELECT.T_DIAG_1_RSS_REENTREE_LABEL + ' : #B#' + SELECT.DIAG_1_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.T_DIAG_2_RSS_REENTREE  != '-1') {
						display = display + '  avec ' + SELECT.T_DIAG_2_RSS_REENTREE_LABEL + ' : #B#' + SELECT.DIAG_2_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.ACTE_RSS_SANS_ANESTHESIE_REENTREE  != '-1') {
						display = display + '  Particularité actes : #B#' + SELECT.ACTE_RSS_SANS_ANESTHESIE_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.ACTE_RSS  != '-1') {
						if (SELECT.ACTE_RSS_ACTIVITE_CCAM_REENTREE != 'P') {
							display = display + '  avec Acte : #B#' + SELECT.ACTE_RSS_REENTREE_LABEL + ' (' + SELECT.ACTE_RSS_ACTIVITE_CCAM_REENTREE_LABEL + ')#/B#';
						}
						else {
							display = display + '  Acte principal : #B#' + SELECT.ACTE_RSS_REENTREE_LABEL + '#/B#';
						}
						if (SELECT.ACTE_2_RSS_REENTREE  != '-1') {
							if (SELECT.ACTE_2_RSS_ACTIVITE_CCAM_REENTREE != 'P') {
								display = display + '  et Acte : #B#' + SELECT.ACTE_2_RSS_REENTREE_LABEL + ' (' + SELECT.ACTE_2_RSS_ACTIVITE_CCAM_REENTREE_LABEL + ')#/B#';
							}
							else {
								display = display + '  et Acte principal : #B#' + SELECT.ACTE_2_RSS_LABEL + '#/B#';
							}
						}
					}
					else {
						if (SELECT.ACTE_2_RSS_REENTREE  != '-1' ) {
							if (SELECT.ACTE_2_RSS_ACTIVITE_REENTREE_CCAM != 'P') {
								display = display + '  avec Acte : #B#' + SELECT.ACTE_2_RSS_REENTREE_LABEL + ' (' + SELECT.ACTE_2_RSS_ACTIVITE_CCAM_REENTREE_LABEL + ')#/B#';
							}
							else {
								display = display + '  Acte principal : #B#' + SELECT.ACTE_2_RSS_REENTREE_LABEL + '#/B#';
							}
						}
					}
					if (SELECT.ACTE_RSS == '-1' &amp;&amp; SELECT.ACTE_RSS_ACTIVITE_CCAM_REENTREE != '-1' &amp;&amp; SELECT.ACTE_RSS_ACTIVITE_CCAM_REENTREE != 'P') {
						display = display + '  Avec Acte : #B#' + SELECT.ACTE_RSS_ACTIVITE_CCAM_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.MEDECIN_ACTE_RSS_REENTREE  != '-1') {
						display = display + '  avec Médecin acte : #B#' + SELECT.MEDECIN_ACTE_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.UM_RSS_REENTREE  != '-1') {
						display = display + '  passé dans Unité : #B#' + SELECT.UM_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.UM_PRINCIPALE_REENTREE  != '-1') {
						display = display + '  Unité principale : #B#' + SELECT.UM_PRINCIPALE_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.LPP_RSS_REENTREE  != '-1') {
						display = display + '  avec LPP : #B#' + SELECT.LPP_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.UCD_RSS_REENTREE  != '-1') {
						display = display + '  avec UCD : #B#' + SELECT.UCD_RSS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.TYPFAC_REENTREE  != '-1') {
						display = display + '  Type facturation : #B#' + SELECT.TYPFAC_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.GHS_REENTREE  != '-1') {
						display = display + '  GHS : #B#' + SELECT.GHS_REENTREE_LABEL + '#/B#';
					}
					if (SELECT.PRESTATION_RSS_REENTREE  != '-1') {
						display = display + '  avec Prestation : #B#' + SELECT.PRESTATION_RSS_REENTREE_LABEL + '#/B#';
					}
					
					if (SELECT.DIVERS_REENTREE  != '-1') {
						display = display + '  Autres : #B#' + SELECT.DIVERS_REENTREE_LABEL + '#/B#';
					}
					
					if (display != '') {
						display = '#B#Filtres Ré-Entrées#/B# = ' + display;
					}
					return display;
					" 
			>
			
			<GROUP label="">
				<FIELD name="DELAI_REENTREE" label="Délai Ré-Entrée" UI="numberInterval" width="100" default="" default2="" showIfNotDefault="true" />
			</GROUP>
			
			<GROUP label="Etablissement">
				<FIELD name="FINESS_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" showIfNotDefault="true" globalListProvider="Etablissement" />
			</GROUP>
			<GROUP label="Champ e-PMSI">
				<FIELD name="CHAMP_REENTREE" label="Champ e-PMSI" UI="combo" tree="true" width="400" default="EX" globalListProvider="CHAMP" showIfNotDefault="true" />
			</GROUP>
			
			<GROUP label="ASo">
				<FIELD name="MCO_M_REENTREE" label="Médecine" UI="check" selectedValue="M" unselectedValue="" default="M"  showIfNotDefault="true" />
				<FIELD name="MCO_C_REENTREE" label="Chirurgie" UI="check" selectedValue="C" unselectedValue="" default="C"  showIfNotDefault="true" />
				<FIELD name="MCO_O_REENTREE" label="Obstétrique" UI="check" selectedValue="O" unselectedValue="" default="O" showIfNotDefault="true" />
				<FIELD name="MCO_S_REENTREE" label="Séances" UI="check" selectedValue="S" unselectedValue="" default="S" showIfNotDefault="true" />
				<FIELD name="MCO_H_REENTREE" label="e-PMSI hors GHM" UI="check" selectedValue="*" unselectedValue="" default="*" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Durée de séjour">
				<FIELD name="T_DUREE_SEJOUR_REENTREE" label="Durée de séjour" UI="combo" tree="true" width="200" default="-1" globalListProvider="T_DUREE_SEJOUR" showIfNotDefault="true" />
				<FIELD name="DUREE_SEJOUR_REENTREE" label="" UI="numberInterval" width="100" default="" default2="" 
						visible="= SELECT.T_DUREE_SEJOUR_REENTREE == 'I'" />
			</GROUP>
			
			<GROUP label="OAP">
				<FIELD name="OAP_REENTREE" label="OAP" UI="combo" tree="true" width="400" default="-1" hidable="= SELECT.OAP == '-1'" globalListProvider="OAP" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="CMD - GHM">
				<FIELD name="GHM_REENTREE" label="CMD - GHM" UI="combo" tree="true" width="400" default="-1" hidable="= SELECT.GHM == '-1'" globalListProvider="GHM"  showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Racine GHM, Sévérité">
				<FIELD name="GHM5_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="GHM5" showIfNotDefault="true" />
				<FIELD name="GHMSEV_REENTREE" label="" UI="combo" tree="true" width="140" default="-1" globalListProvider="GHMSEV" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Groupe activité">
				<FIELD name="GA_REENTREE" label="Groupe activité" UI="combo" width="400" default="-1" globalListProvider="GA" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Médecin RSS">
				<FIELD name="MEDECIN_RSS_REENTREE" label="Médecin RSS" UI="combo" tree="true" width="400" default="-1"  globalListProvider="MEDECIN_RSS"  showIfNotDefault="true" />
			</GROUP>
			
			<GROUP label="Diagnostic RSS">
				<FIELD name="T_DIAG_1_RSS_REENTREE" label="Diagnostic RSS" UI="combo" width="150" default="-1" globalListProvider="T_DIAG"
						showIfNotDefault="true" />
				<FIELD name="DIAG_1_RSS_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="DIAG" visible="= SELECT.T_DIAG_1_RSS_REENTREE != '-1'" />
			</GROUP>
			<GROUP label="Diagnostic RSS">
				<FIELD name="T_DIAG_2_RSS_REENTREE" label="Diagnostic RSS" UI="combo" width="150" default="-1" globalListProvider="T_DIAG"
						showIfNotDefault="true" />
				<FIELD name="DIAG_2_RSS_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="DIAG" visible="= SELECT.T_DIAG_2_RSS_REENTREE != '-1'" />
			</GROUP>
			
			<GROUP label="Sans anesthésie">
				<FIELD name="ACTE_RSS_SANS_ANESTHESIE_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE_RSS_SANS_ANESTHESIE" showIfNotDefault="true" />
			</GROUP>
			
			<GROUP label="Acte RSS">
				<FIELD name="ACTE_RSS_REENTREE" label="Acte RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE" showIfNotDefault="true" />
				<FIELD name="ACTE_RSS_ACTIVITE_CCAM_REENTREE" label="" UI="combo" default="-1" globalListProvider="ACTE_RSS_ACTIVITE_CCAM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Acte RSS">
				<FIELD name="ACTE_2_RSS_REENTREE" label="Acte RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="ACTE" showIfNotDefault="true" />
				<FIELD name="ACTE_2_RSS_ACTIVITE_CCAM_REENTREE" label="" UI="combo" default="-1" globalListProvider="ACTE_RSS_ACTIVITE_CCAM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Médecin Acte">
				<FIELD name="MEDECIN_ACTE_RSS_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="MEDECIN_ACTE" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Unité principale">
				<FIELD name="UM_PRINCIPALE_REENTREE" label="" UI="combo" tree="true" width="400" default="-1"  globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Passé dans unité">
				<FIELD name="UM_RSS_REENTREE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="UM" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="LPP RSS">
				<FIELD name="LPP_RSS_REENTREE" label="LPP RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="LPP" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="UCD RSS">
				<FIELD name="UCD_RSS_REENTREE" label="UCD RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="UCD" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="GHS">
				<FIELD name="GHS_REENTREE" label="GHS" UI="combo" tree="true" width="400" default="-1" globalListProvider="GHS" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Type facturation">
				<FIELD name="TYPFAC_REENTREE" label="Type facturation" UI="combo" width="400" tree="true" default="-1" globalListProvider="TYPFAC" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Prestation RSS">
				<FIELD name="PRESTATION_RSS_REENTREE" label="Prestation RSS" UI="combo" tree="true" width="400" default="-1" globalListProvider="PRESTATION" showIfNotDefault="true" />
			</GROUP>
			
			<GROUP label="Modes entrée">
				<FIELD name="MODE_ENTREE_REENTREE" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="MODE_ENTREE" showIfNotDefault="true" />
				<FIELD name="PROVENANCE_REENTREE" label="Provenance" labelWidth="80" UI="combo" tree="false" width="200" default="-1" globalListProvider="PROVENANCES" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Modes sortie">
				<FIELD name="MODE_SORTIE_REENTREE" label="" UI="combo" tree="false" width="200" default="-1" globalListProvider="MODE_SORTIE" showIfNotDefault="true" />
				<FIELD name="DESTINATION_REENTREE" label="Destination" labelWidth="80" UI="combo" tree="false" width="200" default="-1" globalListProvider="DESTINATIONS" showIfNotDefault="true" />
			</GROUP>
			<GROUP label="Divers">
				<FIELD name="DIVERS_REENTREE" label="Divers" UI="combo" width="400" default="-1" globalListProvider="DIVERS_RSS" showIfNotDefault="true" />
			</GROUP>
			
		</SELECTIONS>
		
	</COMPONENT>
    
    <COMPONENT name="MCO_LS_DATA_VIEWLINK"  >
		<ARGS name="DATA1">
			<value><![CDATA[
				
				var my_str_gen = SELECT.LS_DATA;
				var my_array_gen = my_str_gen.split("=");
				var my_str:String = my_array_gen[1];
				var my_array:Array = my_str.split(",");
			if(SELECT.LS_DATA != '-1'){
			
				LINKVARIABLES['DATA1'] = '1.1';
				LINKVARIABLES['DATA2'] = my_array[0];
				LINKVARIABLES['DATA3'] = my_array[1];
				LINKVARIABLES['DATA4'] = my_array[2];
				LINKVARIABLES['DATA5'] = my_array[3];
				LINKVARIABLES['DATA6'] = my_array[4];
				LINKVARIABLES['DATA7'] = my_array[5];
				LINKVARIABLES['DATA8'] = my_array[6];
				LINKVARIABLES['DATA9'] = my_array[7];
				LINKVARIABLES['DATA10'] = my_array[8];
				LINKVARIABLES['DATA011'] = my_array[9];
				LINKVARIABLES['DATA012'] = my_array[10];
				LINKVARIABLES['DATA013'] = my_array[11];
				LINKVARIABLES['DATA014'] = my_array[12];
				LINKVARIABLES['DATA015'] = my_array[13];
				
                LINKVARIABLES['DATA01'] = '16.1';
				LINKVARIABLES['DATA02'] = my_array[0];
				LINKVARIABLES['DATA03'] = my_array[1];
				LINKVARIABLES['DATA04'] = my_array[2];
				LINKVARIABLES['DATA05'] = my_array[3];
				LINKVARIABLES['DATA06'] = my_array[4];
				LINKVARIABLES['DATA07'] = my_array[5];
				LINKVARIABLES['DATA08'] = my_array[6];
				LINKVARIABLES['DATA09'] = my_array[7];
				LINKVARIABLES['DATA10'] = my_array[8];
				LINKVARIABLES['DATA11'] = my_array[9];
				LINKVARIABLES['DATA12'] = my_array[10];
				LINKVARIABLES['DATA13'] = my_array[11];
				LINKVARIABLES['DATA14'] = my_array[12];
				LINKVARIABLES['DATA15'] = my_array[13];				
			} else {						
					if(SELECT.DATA1 != '0'){ 
						LINKVARIABLES['DATA1'] = SELECT.DATA01;
					}					
                    if(SELECT.DATA2 != '0'){ 
						LINKVARIABLES['DATA2'] = SELECT.DATA02;
					}					
                    if(SELECT.DATA3 != '0'){ 
						LINKVARIABLES['DATA3'] = SELECT.DATA03;
					}					
                    if(SELECT.DATA4 != '0'){ 
						LINKVARIABLES['DATA4'] = SELECT.DATA04;
					}							
					if(SELECT.DATA5 != '0'){ 
						 LINKVARIABLES['DATA5'] = SELECT.DATA05;
					}						
					if(SELECT.DATA6 != '0'){ 
						LINKVARIABLES['DATA6'] = SELECT.DATA06;	
					}						
					if(SELECT.DATA7 != '0'){ 
						LINKVARIABLES['DATA7'] = SELECT.DATA07;	
					}						
					if(SELECT.DATA8 != '0'){ 

						LINKVARIABLES['DATA8'] = SELECT.DATA08;	
					}						
					if(SELECT.DATA9 != '0'){ 
						LINKVARIABLES['DATA9'] = SELECT.DATA09;	
					}						
					if(SELECT.DATA10 != '0'){ 
						LINKVARIABLES['DATA10'] = SELECT.DATA10;	
					}						
					if(SELECT.DATA011 != '0'){ 
						LINKVARIABLES['DATA011'] = SELECT.DATA11;	
					}						
					if(SELECT.DATA012 != '0'){ 
						LINKVARIABLES['DATA012'] = SELECT.DATA12;	
					}						
					if(SELECT.DATA013 != '0'){ 
						LINKVARIABLES['DATA013'] = SELECT.DATA13;	
					}						
					if(SELECT.DATA014 != '0'){ 
						LINKVARIABLES['DATA014'] = SELECT.DATA14;	
					}						
					if(SELECT.DATA015 != '0'){ 
						LINKVARIABLES['DATA015'] = SELECT.DATA15;	
					}					
                    
                    if(SELECT.DATA01 != '0'){ 
						LINKVARIABLES['DATA01'] = SELECT.DATA01;
					}					
                    if(SELECT.DATA02 != '0'){ 
						LINKVARIABLES['DATA02'] = SELECT.DATA02;
					}					
                    if(SELECT.DATA03 != '0'){ 
						LINKVARIABLES['DATA03'] = SELECT.DATA03;
					}					
                    if(SELECT.DATA04 != '0'){ 
						LINKVARIABLES['DATA04'] = SELECT.DATA04;
					}							
					if(SELECT.DATA05 != '0'){ 
						 LINKVARIABLES['DATA05'] = SELECT.DATA05;
					}						
					if(SELECT.DATA6 != '0'){ 
						LINKVARIABLES['DATA6'] = SELECT.DATA06;	
					}						
					if(SELECT.DATA07 != '0'){ 
						LINKVARIABLES['DATA07'] = SELECT.DATA07;	
					}						
					if(SELECT.DATA08 != '0'){ 

						LINKVARIABLES['DATA08'] = SELECT.DATA08;	
					}						
					if(SELECT.DATA09 != '0'){ 
						LINKVARIABLES['DATA09'] = SELECT.DATA09;	
					}						
					if(SELECT.DATA10 != '0'){ 
						LINKVARIABLES['DATA10'] = SELECT.DATA10;	
					}						
					if(SELECT.DATA11 != '0'){ 
						LINKVARIABLES['DATA11'] = SELECT.DATA11;	
					}						
					if(SELECT.DATA12 != '0'){ 
						LINKVARIABLES['DATA12'] = SELECT.DATA12;	
					}						
					if(SELECT.DATA13 != '0'){ 
						LINKVARIABLES['DATA13'] = SELECT.DATA13;	
					}						
					if(SELECT.DATA14 != '0'){ 
						LINKVARIABLES['DATA14'] = SELECT.DATA14;	
					}						
					if(SELECT.DATA15 != '0'){ 
						LINKVARIABLES['DATA15'] = SELECT.DATA15;	
					}						

			}
			]]></value>
		</ARGS>	
	</COMPONENT>
	
	<COMPONENT name="DATE_COMP_VIEWLINK" >
		<ARG name="PERIODE">
			<value><![CDATA[
					if (COLUMN.NAME == 'COL0D') {return SELECT.PERIODE_D}
					if (COLUMN.NAME == 'COL0F') {return SELECT.PERIODE}
					if (COLUMN.NAME == 'COL1D') {return SELECT.PERIODE_D}
					if (COLUMN.NAME == 'COL1F') {return SELECT.PERIODE}
					if (COLUMN.NAME == 'COL2D') {return SELECT.PERIODE_D}
					if (COLUMN.NAME == 'COL2F') {return SELECT.PERIODE}
					if (COLUMN.NAME == 'COL3D') {return SELECT.PERIODE_D}
					if (COLUMN.NAME == 'COL3F') {return SELECT.PERIODE}
			]]></value>
		</ARG>
		<ARG name="TOPERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'COL0D') {return SELECT.TOPERIODE_D}
				if (COLUMN.NAME == 'COL0F') {return SELECT.TOPERIODE}
				if (COLUMN.NAME == 'COL1D') {return SELECT.TOPERIODE_D}
				if (COLUMN.NAME == 'COL1F') {return SELECT.TOPERIODE}
				if (COLUMN.NAME == 'COL2D') {return SELECT.TOPERIODE_D}
				if (COLUMN.NAME == 'COL2F') {return SELECT.TOPERIODE}
				if (COLUMN.NAME == 'COL3D') {return SELECT.TOPERIODE_D}
				if (COLUMN.NAME == 'COL3F') {return SELECT.TOPERIODE}
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="DATE_COMP_2_VIEWLINK" >
		<ARG name="PERIODE" value="	
									if (SELECT.GROUPBY == 'AMSOR') {
										return ROW.OID;
									}
									var col:String = String(COLUMN.NAME).slice(-3);
									if (SELECT.GROUPBY == 'MSOR') {
										if (col == 'OLD') {return SELECT.TOPERIODE_D.substr(0,4) + ROW.COD;}
										else {return SELECT.TOPERIODE.substr(0,4) + ROW.COD;}
									}
									if (col == 'OLD') {return SELECT.PERIODE_D;}
									else {return SELECT.PERIODE;}" />
		<ARG name="TOPERIODE" value="
									if (SELECT.GROUPBY == 'AMSOR') {
										return ROW.OID;
									}
									var col:String = String(COLUMN.NAME).slice(-3);
									if (SELECT.GROUPBY == 'MSOR') {
										if (col == 'OLD') {return SELECT.TOPERIODE_D.substr(0,4) + ROW.COD;}
										else {return SELECT.TOPERIODE.substr(0,4) + ROW.COD;}
									}
									if (col == 'OLD') {return SELECT.TOPERIODE_D;}
									else {return SELECT.TOPERIODE;}" />
	</COMPONENT>
	
	<COMPONENT name="DATE_COMP_3_VIEWLINK" >
		<ARG name="PERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'D1_2') {return VIEW.PERIODE_D2}
				if (COLUMN.NAME == 'D1') {return VIEW.PERIODE_D}
				if (COLUMN.NAME == 'F1') {return SELECT.PERIODE}
				if (COLUMN.NAME == 'D2_2') {return VIEW.PERIODE_D2}
				if (COLUMN.NAME == 'D2') {return VIEW.PERIODE_D}
				if (COLUMN.NAME == 'F2') {return SELECT.PERIODE}
				if (COLUMN.NAME == 'D3_2') {return VIEW.PERIODE_D2}
				if (COLUMN.NAME == 'D3') {return VIEW.PERIODE_D}
				if (COLUMN.NAME == 'F3') {return SELECT.PERIODE}
			]]></value>
		</ARG>
		<ARG name="TOPERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'D1_2') {return VIEW.TOPERIODE_D2}
				if (COLUMN.NAME == 'D1') {return VIEW.TOPERIODE_D}
				if (COLUMN.NAME == 'F1') {return SELECT.TOPERIODE}
				if (COLUMN.NAME == 'D2_2') {return VIEW.TOPERIODE_D2}
				if (COLUMN.NAME == 'D2') {return VIEW.TOPERIODE_D}
				if (COLUMN.NAME == 'F2') {return SELECT.TOPERIODE}
				if (COLUMN.NAME == 'D3_2') {return VIEW.TOPERIODE_D2}
				if (COLUMN.NAME == 'D3') {return VIEW.TOPERIODE_D}
				if (COLUMN.NAME == 'F3') {return SELECT.TOPERIODE}
			]]></value>
		</ARG>
	</COMPONENT>
	
	<COMPONENT name="DATE_EVOL_VIEWLINK" >
		
		<ARG name="PERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'COL1') {return VIEW.D1}
				if (COLUMN.NAME == 'COL2') {return VIEW.D2}
				if (COLUMN.NAME == 'COL3') {return VIEW.D3}
				if (COLUMN.NAME == 'COL4') {return VIEW.D4}
				if (COLUMN.NAME == 'COL5') {return VIEW.D5}
				if (COLUMN.NAME == 'COL6') {return VIEW.D6}
				if (COLUMN.NAME == 'COL7') {return VIEW.D7}
				if (COLUMN.NAME == 'COL8') {return VIEW.D8}
				if (COLUMN.NAME == 'COL9') {return VIEW.D9}
				if (COLUMN.NAME == 'COL10') {return VIEW.D10}
				if (COLUMN.NAME == 'COL11') {return VIEW.D11}
				if (COLUMN.NAME == 'COL12') {return VIEW.D12}
			]]></value>
		</ARG>
		<ARG name="TOPERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'COL1') {return VIEW.F1}
				if (COLUMN.NAME == 'COL2') {return VIEW.F2}
				if (COLUMN.NAME == 'COL3') {return VIEW.F3}
				if (COLUMN.NAME == 'COL4') {return VIEW.F4}
				if (COLUMN.NAME == 'COL5') {return VIEW.F5}
				if (COLUMN.NAME == 'COL6') {return VIEW.F6}
				if (COLUMN.NAME == 'COL7') {return VIEW.F7}
				if (COLUMN.NAME == 'COL8') {return VIEW.F8}
				if (COLUMN.NAME == 'COL9') {return VIEW.F9}
				if (COLUMN.NAME == 'COL10') {return VIEW.F10}
				if (COLUMN.NAME == 'COL11') {return VIEW.F11}
				if (COLUMN.NAME == 'COL12') {return VIEW.F12}
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="DATE_EVOL_2_VIEWLINK" >
		
		<ARG name="PERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'N0') {return VIEW.COLD0}
				if (COLUMN.NAME == 'N1') {return VIEW.COLD1}
				if (COLUMN.NAME == 'N2') {return VIEW.COLD2}
				if (COLUMN.NAME == 'N3') {return VIEW.COLD3}
				if (COLUMN.NAME == 'N4') {return VIEW.COLD4}
				if (COLUMN.NAME == 'N5') {return VIEW.COLD5}
				if (COLUMN.NAME == 'N6') {return VIEW.COLD6}
				if (COLUMN.NAME == 'N7') {return VIEW.COLD7}
				if (COLUMN.NAME == 'N8') {return VIEW.COLD8}
				if (COLUMN.NAME == 'N9') {return VIEW.COLD9}
				if (COLUMN.NAME == 'N10') {return VIEW.COLD10}
				if (COLUMN.NAME == 'N11') {return VIEW.COLD11}
				if (COLUMN.NAME == 'N12') {return VIEW.COLD12}
				if (COLUMN.NAME == 'N13') {return VIEW.COLD13}
				if (COLUMN.NAME == 'N14') {return VIEW.COLD14}
				if (COLUMN.NAME == 'N15') {return VIEW.COLD15}
				if (COLUMN.NAME == 'N16') {return VIEW.COLD16}
				if (COLUMN.NAME == 'N16') {return VIEW.COLD16}
				if (COLUMN.NAME == 'N17') {return VIEW.COLD17}
				if (COLUMN.NAME == 'N18') {return VIEW.COLD18}
				if (COLUMN.NAME == 'N19') {return VIEW.COLD19}
				if (COLUMN.NAME == 'N20') {return VIEW.COLD20}
				if (COLUMN.NAME == 'N21') {return VIEW.COLD21}
				if (COLUMN.NAME == 'N23') {return VIEW.COLD23}
				if (COLUMN.NAME == 'N24') {return VIEW.COLD24}
				if (COLUMN.NAME == 'N25') {return VIEW.COLD25}
				if (COLUMN.NAME == 'N26') {return VIEW.COLD26}
				if (COLUMN.NAME == 'N27') {return VIEW.COLD27}
				if (COLUMN.NAME == 'N28') {return VIEW.COLD28}
				if (COLUMN.NAME == 'N29') {return VIEW.COLD29}
				if (COLUMN.NAME == 'N30') {return VIEW.COLD30}
				if (COLUMN.NAME == 'N31') {return VIEW.COLD31}
			]]></value>
		</ARG>
		<ARG name="TOPERIODE">
			<value><![CDATA[
				if (COLUMN.NAME == 'N0') {return VIEW.COLF0}
				if (COLUMN.NAME == 'N1') {return VIEW.COLF1}
				if (COLUMN.NAME == 'N2') {return VIEW.COLF2}
				if (COLUMN.NAME == 'N3') {return VIEW.COLF3}
				if (COLUMN.NAME == 'N4') {return VIEW.COLF4}
				if (COLUMN.NAME == 'N5') {return VIEW.COLF5}
				if (COLUMN.NAME == 'N6') {return VIEW.COLF6}
				if (COLUMN.NAME == 'N7') {return VIEW.COLF7}
				if (COLUMN.NAME == 'N8') {return VIEW.COLF8}
				if (COLUMN.NAME == 'N9') {return VIEW.COLF9}
				if (COLUMN.NAME == 'N10') {return VIEW.COLF10}
				if (COLUMN.NAME == 'N11') {return VIEW.COLF11}
				if (COLUMN.NAME == 'N12') {return VIEW.COLF12}
				if (COLUMN.NAME == 'N13') {return VIEW.COLF13}
				if (COLUMN.NAME == 'N14') {return VIEW.COLF14}
				if (COLUMN.NAME == 'N15') {return VIEW.COLF15}
				if (COLUMN.NAME == 'N16') {return VIEW.COLF16}
				if (COLUMN.NAME == 'N16') {return VIEW.COLF16}
				if (COLUMN.NAME == 'N17') {return VIEW.COLF17}
				if (COLUMN.NAME == 'N18') {return VIEW.COLF18}
				if (COLUMN.NAME == 'N19') {return VIEW.COLF19}
				if (COLUMN.NAME == 'N20') {return VIEW.COLF20}
				if (COLUMN.NAME == 'N21') {return VIEW.COLF21}
				if (COLUMN.NAME == 'N23') {return VIEW.COLF23}
				if (COLUMN.NAME == 'N24') {return VIEW.COLF24}
				if (COLUMN.NAME == 'N25') {return VIEW.COLF25}
				if (COLUMN.NAME == 'N26') {return VIEW.COLF26}
				if (COLUMN.NAME == 'N27') {return VIEW.COLF27}
				if (COLUMN.NAME == 'N28') {return VIEW.COLF28}
				if (COLUMN.NAME == 'N29') {return VIEW.COLF29}
				if (COLUMN.NAME == 'N30') {return VIEW.COLF30}
				if (COLUMN.NAME == 'N31') {return VIEW.COLF31}
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="RSS_BASE_VIEWLINK"  >
		
		<ARG name="PERIODE">
			<value><![CDATA[
			
				var row_cod:String = '';
				var annee_periode:String = SELECT.PERIODE.substr(0,4);
				var mois_periode:String = SELECT.PERIODE.substr(5,2);
				var annee_toperiode:String = SELECT.TOPERIODE.substr(0,4);
				var mois_toperiode:String = SELECT.TOPERIODE.substr(5,2);

				if(ROW.OID === '-9999999'){
					return SELECT.PERIODE;
				}
				if (SELECT.GROUPBY == 'AMSOR' || SELECT.GROUPBY_2 == 'AMSOR') {
					row_cod = (SELECT.GROUPBY == 'AMSOR') ? ROW.COD1 : ROW.COD2;
					if (row_cod.substr(0,4) == annee_periode && row_cod.substr(4,2) == mois_periode) {
						return SELECT.PERIODE;
					}
					else {
						return row_cod;
					}
				}
				else if (SELECT.GROUPBY == 'MSOR' || SELECT.GROUPBY_2 == 'MSOR') {
					row_cod = (SELECT.GROUPBY == 'MSOR') ? ROW.COD1 : ROW.COD2;
					
					if (row_cod.substr(0,4) == annee_periode && row_cod.substr(4,2) == mois_periode) {
						return SELECT.PERIODE;
					}
					else {
						return annee_periode + row_cod;
					}
			
					if (SELECT.GROUPBY == 'ASOR') {
						if (ROW.COD2 == mois_periode && ROW.COD1 == annee_periode) {
							return SELECT.PERIODE;
						}
						else { 
							return ROW.COD1 + ROW.COD2;
						}
					}
					else if (SELECT.GROUPBY == 'ATRIMSOR') {
						var annee:String = ROW.COD1.substr(0,4);
						if (annee == annee_periode && row_cod == mois_periode) {
							return SELECT.PERIODE;
						}
						else {
							return annee + row_cod;
						}
					}
					else if (parseInt(row_cod) <= parseInt(mois_toperiode)) {
						if ((annee_toperiode == annee_periode && row_cod == mois_periode) || ROW.OID2 == -9999999) {
							return SELECT.PERIODE;
						}
						else {
							return annee_toperiode + row_cod;
						}
					}
					else {
						if (parseInt(annee_toperiode) == (parseInt(annee_periode) + 1) && row_cod == mois_periode) {
							return SELECT.PERIODE;
						}
						else {
							return (parseInt(annee_toperiode) - 1).toString() + row_cod;
						}
					}
				}
				else if (SELECT.GROUPBY == 'ATRIMSOR' || SELECT.GROUPBY_2 == 'ATRIMSOR') {
					row_cod = (SELECT.GROUPBY == 'ATRIMSOR') ? ROW.COD1 : ROW.COD2;
					
					// Mois de début du trimestre
					var mois_debut:int = 1 + 3 * (parseInt(row_cod.substr(-1)) - 1);
					
					var annee:String = row_cod.substr(0,4);
					
					if (annee == annee_periode && mois_debut <= parseInt(mois_periode, 10)) {
						return SELECT.PERIODE;
					}
					else {
						if (mois_debut < 10) {
							annee += '0';
						}
						return annee + mois_debut.toString();
					}
				}
				else if (SELECT.GROUPBY == 'TRIMSOR' || SELECT.GROUPBY_2 == 'TRIMSOR') {
					/*
					 *	L'accès au détail pour un regroupement par trimestre se fera systémtiquement sur les
					 *	derniers trimestre de la période. Exemple :
					 *	Période d'analyse de février 2010 à mars 2011. les résultats seront :
					 *	Trimestre 1 : 4500 	(janv 2011 à fév 2011  +  fév 2010 à mars 2010)
					 *	Trimestre 2 : 3400	(avril 2010 à juin 2010)
					 *	Trimestre 3 : 3300	(juil 2010 à sept 2010)
					 *	Trimestre 4 : 3450	(oct 2010 à déc 2010)
					 *	
					 *	L'accès au détail donnera :
					 *	Trimestre 1 --> janv 2011 à fév 2011
					 *	Trimestre 2 --> avril 2010 à juin 2010
					 *	Trimestre 3 --> juil 2010 à sept 2010
					 *	Trimestre 4 --> oct 2010 à déc 2010
					 *	
					 *	On constate que la période de février 2010 à mars 2010 n'est pas prise en compte pour l'accès
					 *	au détail alors qu'elle l'est bien pour l'affichage des résultats.
					 *	Cette différence de traitement s'explique par le fait qu'il est impossible de sélectionner
					 *	plus d'une période dans les combobox de sélection de période de la vue des justificatifs.
					 */
					
					var annee:String = '';
					// Code du trimestre sélectionné (de 1 à 4)
					row_cod = (SELECT.GROUPBY == 'TRIMSOR') ? ROW.OID1 : ROW.OID2;
					// Mois de début du trimestre
					var mois_debut:int = 1 + 3 * (parseInt(row_cod, 10) - 1);
					// Mois de fin du trimestre
					var mois_fin:int = 3 * parseInt(row_cod, 10);
					// Nombre d'années entre le début et la fin de la période d'analyse
					var nb_annees = parseInt(annee_toperiode, 10) - parseInt(annee_periode, 10);
					
					if (SELECT.GROUPBY == 'ASOR') {
						if (ROW.COD1 == annee_periode && (mois_debut <= parseInt(mois_periode, 10) <= mois_fin)) {
							return SELECT.PERIODE; 
						}
						else {
							annee = ROW.COD1;
						}
					}
					else {
						if (mois_debut <= parseInt(mois_toperiode, 10)) {
							if (nb_annees == 0 && mois_debut <= mois_periode) {
								return SELECT_PERIODE;
							}
							else {
								annee = annee_toperiode;
							}
						}
						else {
							if (mois_debut <= parseInt(mois_periode, 10) && nb_annees == 1) {
								return SELECT.PERIODE;
							}
							else {
								annee = (parseInt(annee_toperiode, 10) - 1).toString()
							}
						}
					}
					if (mois_debut < 10) {
						annee += '0';
					}
					return annee + mois_debut.toString();
				}
				else if (SELECT.GROUPBY == 'ASOR'|| SELECT.GROUPBY_2 == 'ASOR') {
				
					row_cod = (SELECT.GROUPBY == 'ASOR') ? ROW.COD1 : ROW.COD2;
					

					if (row_cod == annee_periode) {
						return SELECT.PERIODE;
					}
					else {
						return row_cod + '01';
					}
				}
				else {
					return SELECT.PERIODE;
				}
				
			]]></value>
		</ARG>
		<ARG name="TOPERIODE">
			<value><![CDATA[
			
				var row_cod:String = '';
				var annee_periode:String = SELECT.PERIODE.substr(0,4);
				var mois_periode:String = SELECT.PERIODE.substr(5,2);
				var annee_toperiode:String = SELECT.TOPERIODE.substr(0,4);
				var mois_toperiode:String = SELECT.TOPERIODE.substr(5,2);

				if(ROW.OID === '-9999999'){
					return SELECT.TOPERIODE;
				}
                if (SELECT.GROUPBY == 'AMSOR' || SELECT.GROUPBY_2 == 'AMSOR') {
					row_cod = (SELECT.GROUPBY == 'AMSOR') ? ROW.COD1 : ROW.COD2;

					if (row_cod.substr(0,4) == annee_toperiode && row_cod.substr(4,2) == mois_toperiode) {
						return SELECT.TOPERIODE;
					}
					else {
						return row_cod;
					}
				}
				else if (SELECT.GROUPBY == 'MSOR' || SELECT.GROUPBY_2 == 'MSOR') {
					row_cod = (SELECT.GROUPBY == 'MSOR') ? ROW.COD1 : ROW.COD2;
					if (row_cod.substr(0,4) == annee_toperiode && row_cod.substr(4,2) == mois_toperiode) {
						return SELECT.TOPERIODE;
					}
					else {
						return annee_toperiode + row_cod;
					}

                    if (SELECT.GROUPBY == 'ASOR') {
						if (ROW.COD2 == mois_toperiode && ROW.COD1 == annee_toperiode) {
							return SELECT.TOPERIODE;
						}
						else { 
							return ROW.COD1 + ROW.COD2;
						}
					}
					else if (SELECT.GROUPBY == 'ATRIMSOR') {
						var annee:String = ROW.COD1.substr(0,4);
						if (annee == annee_toperiode && row_cod == mois_toperiode) {
							return SELECT.TOPERIODE;
						}
						else {
							return annee + row_cod;
						}
					}
					else if (row_cod == mois_toperiode || ROW.OID2 == -9999999) {
						return SELECT.TOPERIODE;
					}
					else if (parseInt(row_cod) < parseInt(mois_toperiode)) {
						return annee_toperiode + row_cod;
					}
					else {
						return (parseInt(annee_toperiode) - 1).toString() + row_cod;
					}
				}
				else if (SELECT.GROUPBY == 'ATRIMSOR' || SELECT.GROUPBY_2 == 'ATRIMSOR') {
					row_cod = (SELECT.GROUPBY == 'ATRIMSOR') ? ROW.COD1 : ROW.COD2;
					

					// Mois de fin du trimestre
					var mois_fin:int = 3 * parseInt(row_cod.substr(-1));
					
					var annee:String = row_cod.substr(0,4);
					
					if (annee == annee_toperiode && mois_fin >= parseInt(mois_toperiode, 10)) {
						return SELECT.TOPERIODE;
					}
					else {
						if (mois_fin < 10) {
							annee += '0';
						}
						return annee + mois_fin.toString();
					}
				}
				else if (SELECT.GROUPBY == 'TRIMSOR' || SELECT.GROUPBY_2 == 'TRIMSOR') {
				
					row_cod = (SELECT.GROUPBY == 'TRIMSOR') ? ROW.OID1 : ROW.OID2;

                    var mois_debut:int = 1 + 3 * (parseInt(row_cod, 10) - 1);
					var mois_fin:int = 3 * parseInt(row_cod, 10);
					var annee:String = '';
					
					if (SELECT.GROUPBY == 'ASOR') {
						if (ROW.COD1 == annee_toperiode && (mois_debut <= parseInt(mois_toperiode, 10) <= mois_fin)) {
							return SELECT.TOPERIODE; 
						}
						else {
							annee = ROW.COD1;
						}
					}
					else {
						if (mois_debut <= parseInt(mois_toperiode, 10) <= mois_fin) {
							return SELECT.TOPERIODE;
						}
						else if (mois_fin < parseInt(mois_toperiode, 10)) {
							annee = annee_toperiode;
						}
						else {
							annee = (parseInt(annee_toperiode) - 1).toString();
						}
					}
					if (annee != '') {
						if (mois_fin < 10) {
							annee += '0';
						}
						return annee + mois_fin.toString();
					}
				}
				else if (SELECT.GROUPBY == 'ASOR'|| SELECT.GROUPBY_2 == 'ASOR') {
				
					row_cod = (SELECT.GROUPBY == 'ASOR') ? ROW.COD1 : ROW.COD2;
					

					if (row_cod == annee_toperiode) {
						return SELECT.TOPERIODE;
					}
					else {
						return row_cod + '12';
					}
				}
				else {
					return SELECT.TOPERIODE;
				}
			]]></value>
		</ARG>
		<ARG name="NO_RSS" value="return ''" />
		<ARG name="NO_SEJOUR" value="return ''" />
		<ARG name="NOM" value="return ''" />
		<ARG name="FINESS">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'FIN' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'FIN' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'FIN') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="MCO_M">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == '8' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == '8' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == '8') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="MCO_C">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == '8' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == '8' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == '8') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="MCO_O">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == '8' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == '8' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == '8') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="MCO_H">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == '8' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == '8' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == '8') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="MCO_S">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == '8' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == '8' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == '8') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="CAS_C">
			<value><![CDATA[

				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="CAS_K">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="CAS_X">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="CAS_N">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
								
			]]></value>
		</ARG>
		<ARG name="CAS_O">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="CAS_S">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="CAS_W">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CAS' && ROW.COD3 != '') {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CAS' && ROW.COD2 != '') {return ROW.COD2}
				if (SELECT.GROUPBY == 'CAS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="IPA">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3 == 'IPA' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'II' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'RIPA' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'IC' + ROW.OID3}                
                if (SELECT.GROUPBY_2 == 'IPA' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'II' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'RIPA' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'IC' + ROW.OID2}
				if (SELECT.GROUPBY == 'IPA' && ROW.OID1 != '-9999999') {return 'II' + ROW.OID1}
				if (SELECT.GROUPBY == 'RIPA' && ROW.OID1 != '-9999999') {return 'IC' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="OAP">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3 == '2' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'PO' + ROW.OID3}
				if (SELECT.GROUPBY_3 == '9' && ROW.OID3 != '0' && ROW.OID3 != '-9999999')  {return 'LO' + ROW.OID3}                
                if (SELECT.GROUPBY_2 == '2' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'PO' + ROW.OID2}
				if (SELECT.GROUPBY_2 == '9' && ROW.OID2 != '0' && ROW.OID2 != '-9999999')  {return 'LO' + ROW.OID2}
				if (SELECT.GROUPBY == '2' && ROW.OID1 != '-9999999') {return 'PO' + ROW.OID1}
				if (SELECT.GROUPBY == '9' && ROW.OID1 != '-9999999') {return 'LO' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="GHM">
			<value><![CDATA[
				if (SELECT.GROUPBY_3.substr(0,6) == 'GHMCLS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6,2) + ROW.OID3}
				if (SELECT.GROUPBY_3 == '1' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'CM' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == '4' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'GH' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'GHMCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999' && SELECT.GROUPBY != '4') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
                if (SELECT.GROUPBY_2.substr(0,6) == 'GHMCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999' && SELECT.GROUPBY == '4') {return 'GH' + ROW.OID1}
				if (SELECT.GROUPBY_2 == '1' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'CM' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == '4' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'GH' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'GHMCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == '1' && ROW.OID1 != '-9999999') {return 'CM' + ROW.OID1} 
				if (SELECT.GROUPBY == '4' && ROW.OID1 != '-9999999') {return 'GH' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="GHMSEV">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GHMSEV' && ROW.COD3 != '' && ROW.OID3 != '-9999999') {return 'SV' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'GHMSEV' && ROW.COD2 != '' && ROW.OID2 != '-9999999') {return 'SV' + ROW.COD2}
				if (SELECT.GROUPBY == 'GHMSEV' && ROW.OID1 != '-9999999') {return 'SV' + ROW.COD1}
				
			]]></value>
		</ARG>		
        <ARG name="CTISEV">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'CTISEV' && ROW.COD3 != '' && ROW.OID3 != '-9999999') {return  ROW.COD3}
				if (SELECT.GROUPBY_2 == 'CTISEV' && ROW.COD2 != '' && ROW.OID2 != '-9999999') {return  ROW.COD2}
				if (SELECT.GROUPBY == 'CTISEV' && ROW.OID1 != '-9999999') {return  ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="GHM5">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GHM5' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'G5' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'GHM5' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'G5' + ROW.OID2}
				if (SELECT.GROUPBY == 'GHM5' && ROW.OID1 != '-9999999') {return 'G5' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="GHS">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GHS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'GS' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'GHS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'GS' + ROW.OID2}
				if (SELECT.GROUPBY == 'GHS' && ROW.OID1 != '-9999999') {return 'GS' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="TYPFAC">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PRPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'TYPFAC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'PR' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'PRPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'TYPFAC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'PR' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'PRPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'TYPFAC' && ROW.OID1 != '-9999999') {return 'PR' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="GA">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == '3' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'GA' + ROW.OID3}
				if (SELECT.GROUPBY_2 == '3' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'GA' + ROW.OID2}
				if (SELECT.GROUPBY == '3' && ROW.OID1 != '-9999999') {return 'GA' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'MEDCLS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == '6' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == '7' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D2' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'MEDCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == '6' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == '7' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'MEDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == '6' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				if (SELECT.GROUPBY == '7' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="COMITE_MEDICAL">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'CMMCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'CMM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'CM' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'CMMCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'CMM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'CM' + ROW.OID2} 
				if (SELECT.GROUPBY.substr(0,6) == 'CMMCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'CMM' && ROW.OID1 != '-9999999') {return 'CM' + ROW.OID1} 
				
			]]></value>
		</ARG>
		<ARG name="T_DIAG_1_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'DGPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DP'}	
				if (SELECT.GROUPBY_3 == 'DIAGPROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DP'}	
				if (SELECT.GROUPBY_3 == '10' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DP'}
				if (SELECT.GROUPBY_3.substr(0,6) == 'DGRCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR'}	
				if (SELECT.GROUPBY_3 == 'DIAGRROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR'}	
				if (SELECT.GROUPBY_3 == 'DIAGR' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR'}
				if (SELECT.GROUPBY_3 == '11' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') { return 'DP2'}                
                
                if (SELECT.GROUPBY_2.substr(0,6) == 'DGPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DP'}	
				if (SELECT.GROUPBY_2 == 'DIAGPROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DP'}	
				if (SELECT.GROUPBY_2 == '10' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DP'}
				if (SELECT.GROUPBY_2.substr(0,6) == 'DGRCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR'}	
				if (SELECT.GROUPBY_2 == 'DIAGRROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR'}	
				if (SELECT.GROUPBY_2 == 'DIAGR' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR'}
				if (SELECT.GROUPBY_2 == '11' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') { return 'DP2'}

				if (SELECT.GROUPBY.substr(0,6) == 'DGPCLS' && ROW.OID1 != '-9999999') {return 'DP'}
				if (SELECT.GROUPBY.substr(0,6) == 'DIACLS' && ROW.OID1 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY == 'DIAGPROOT' && ROW.OID1 != '-9999999') {return 'DP'}
				if (SELECT.GROUPBY == '10' && ROW.OID1 != '-9999999') {return 'DP'}
				if (SELECT.GROUPBY.substr(0,6) == 'DGRCLS' && ROW.OID1 != '-9999999') {return 'DR'}
				if (SELECT.GROUPBY == 'DIAGRROOT' && ROW.OID1 != '-9999999') {return 'DR'}
				if (SELECT.GROUPBY == 'DIAGR' && ROW.OID1 != '-9999999') {return 'DR'}
				if ( SELECT.GROUPBY == '11' && ROW.OID1 != '-9999999') { return 'DP2'}
				
			]]></value>
		</ARG>
		<ARG name="DIAG_1_RSS">
			<value><![CDATA[
                if (SELECT.GROUPBY_3.substr(0,6) == 'DGPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
                if (SELECT.GROUPBY_3.substr(0,6) == 'DIACLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'DIAGPROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR' + ROW.OID3}
				if (SELECT.GROUPBY_3 == '10' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DG' + ROW.OID3}
				if (SELECT.GROUPBY_3.substr(0,6) == 'DGRCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'DIAGRROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'DIAGR' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DG' + ROW.OID3}
				if (SELECT.GROUPBY_3 == '11' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DG' + ROW.OID3}
                
                if (SELECT.GROUPBY_2.substr(0,6) == 'DGPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
                if (SELECT.GROUPBY_2.substr(0,6) == 'DIACLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'DIAGPROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR' + ROW.OID2}
				if (SELECT.GROUPBY_2 == '10' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DG' + ROW.OID2}
				if (SELECT.GROUPBY_2.substr(0,6) == 'DGRCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'DIAGRROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'DIAGR' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DG' + ROW.OID2}
				if (SELECT.GROUPBY_2 == '11' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DG' + ROW.OID2}
				
                if (SELECT.GROUPBY.substr(0,6) == 'DGPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
                if (SELECT.GROUPBY.substr(0,6) == 'DIACLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'DIAGPROOT' && ROW.OID1 != '-9999999') {return 'DR' + ROW.OID1}
				if (SELECT.GROUPBY == '10' && ROW.OID1 != '-9999999') {return 'DG' + ROW.OID1}
				if (SELECT.GROUPBY.substr(0,6) == 'DGRCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'DIAGRROOT' && ROW.OID1 != '-9999999') {return 'DR' + ROW.OID1}
				if (SELECT.GROUPBY == 'DIAGR' && ROW.OID1 != '-9999999') {return 'DG' + ROW.OID1}
				if (SELECT.GROUPBY == '11' && ROW.OID1 != '-9999999') {return 'DG' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="ACTE_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'ACPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'ACTEP' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'ACPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'ACTEP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'ACPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'ACTEP' && ROW.OID1 != '-9999999') {return 'AC' + ROW.OID1}
				
			]]></value>
		</ARG>		
		<ARG name="GESTE_MARQUEUR">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'GM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2}
				if (SELECT.GROUPBY == 'GM' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="SEUIL_CANCERO_PRINCIPAL">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3 == 'SEUIL_CANCERO_PRINCIPAL' && ROW.OID3 != '0' && ROW.OID3 != '999') {return 'II' + ROW.COD3}
				if (SELECT.GROUPBY_3 == 'SEUIL_CANCERO_PRINCIPAL' && ROW.OID3 != '0' && ROW.OID3 == '999') {return 'SANS'}                
                if (SELECT.GROUPBY_3 == 'SEUIL_CANCERO_PRINCIPAL_ROOT' && ROW.OID3 != '0' && ROW.OID3 != '998') {return 'IC' + ROW.COD3}
				if (SELECT.GROUPBY_3 == 'SEUIL_CANCERO_PRINCIPAL_ROOT' && ROW.OID3 != '0' && ROW.OID3 == '998') {return 'SANS'}
                
                if (SELECT.GROUPBY_2 == 'SEUIL_CANCERO_PRINCIPAL' && ROW.OID2 != '0' && ROW.OID2 != '999') {return 'II' + ROW.COD2}
				if (SELECT.GROUPBY_2 == 'SEUIL_CANCERO_PRINCIPAL' && ROW.OID2 != '0' && ROW.OID2 == '999') {return 'SANS'}
				if (SELECT.GROUPBY_2 == 'SEUIL_CANCERO_PRINCIPAL_ROOT' && ROW.OID2 != '0' && ROW.OID2 != '998') {return 'IC' + ROW.COD2}
				if (SELECT.GROUPBY_2 == 'SEUIL_CANCERO_PRINCIPAL_ROOT' && ROW.OID2 != '0' && ROW.OID2 == '998') {return 'SANS'}				
                
				
				if (SELECT.GROUPBY == 'SEUIL_CANCERO_PRINCIPAL' && ROW.OID1 != '999') {return 'II' + ROW.COD1}
				if (SELECT.GROUPBY == 'SEUIL_CANCERO_PRINCIPAL' && ROW.OID1 == '999') {return 'SANS'}
				
				if (SELECT.GROUPBY == 'SEUIL_CANCERO_PRINCIPAL_ROOT' && ROW.OID1 != '0' && ROW.OID1 != '998') {return 'IC' + ROW.COD1}
				if (SELECT.GROUPBY == 'SEUIL_CANCERO_PRINCIPAL_ROOT' && ROW.OID1 != '0' && ROW.OID1 == '998') {return 'SANS'}
			]]></value>
		</ARG>
		
		<ARG name="ACTE_RSS_ACTIVITE_CCAM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'ACPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'P'}
				if (SELECT.GROUPBY_3 == 'ACTEP' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'P'}
                if (SELECT.GROUPBY_2.substr(0,6) == 'ACPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'P'}
				if (SELECT.GROUPBY_2 == 'ACTEP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'P'} 
				if (SELECT.GROUPBY.substr(0,6) == 'ACPCLS' && ROW.OID1 != '-9999999') {return 'P'}
				if (SELECT.GROUPBY == 'ACTEP' && ROW.OID1 != '-9999999') {return 'P'}
				
			]]></value>
		</ARG>	
		<!--<ARG name="EXTDOC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_2 == 'EXTDOC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {if (ROW.COD2 == '') { return '0';} else {return ROW.COD2}}
				if (SELECT.GROUPBY == 'EXTDOC') {if (ROW.COD1 == '') { return '0';} else {return ROW.COD1}}
				
			]]></value>
		</ARG>-->
		<ARG name="UM_PRINCIPALE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UMPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'UP' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UM' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'UMPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'UP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UM' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UMPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UP' && ROW.OID1 != '-9999999') {return 'UM' + ROW.OID1}
				
			]]></value>
		</ARG>		
        <ARG name="PREMIERE_UM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PUMCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'PUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UM' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'PUMCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'PUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UM' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'PUMCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'PUM' && ROW.OID1 != '-9999999') {return 'UM' + ROW.OID1}
				
			]]></value>
		</ARG>        
        <ARG name="UM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UMCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'UM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UM' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'UMCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'UM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UM' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UMCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UM' && ROW.OID1 != '-9999999') {return 'UM' + ROW.OID1}
				
			]]></value>
		</ARG>
        <ARG name="POLE_PRINCIPAL">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_2.substr(0,6) == 'POPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'POP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'POPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'POP' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="T_AGE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'AGECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'AGE') {return 'AG' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'AGECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'AGE') {return 'AG' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'AGECLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'AGE') {return 'AG' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="T_AGE_JOURS">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'AGEJOURS') {return 'AJ' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'AGEJOURS') {return 'AJ' + ROW.OID2}
				if (SELECT.GROUPBY == 'AGEJOURS') {return 'AJ' + ROW.OID1;}
				if (SELECT.GROUPBY == 'AGEJOURSx') {if (ROW.OID1 == '-1') {return 'AJX';} else { return ROW.OID1;}}
				
			]]></value>
		</ARG>
		<ARG name="T_DUREE_SEJOUR">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'DSJCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'DUREE_SEJOUR' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DU' + ROW.OID3}               
                if (SELECT.GROUPBY_2.substr(0,6) == 'DSJCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'DUREE_SEJOUR' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DU' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'DSJCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'DUREE_SEJOUR' && ROW.OID1 != '-9999999') {return 'DU' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="CODE_POSTAL">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'CDPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'REGION' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'RG' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'DEPARTEMENT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DP' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'CODEGEOPMSI' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'GP' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'CODEPOST' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'CP' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'TERSANTE' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'TS' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'CDPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'DEPARTEMENT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DP' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'REGION' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'RG' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'CODEGEOPMSI' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'GP' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'CODEPOST' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'CP' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'TERSANTE' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'TS' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'CDPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'REGION' && ROW.OID1 != '-9999999') {return 'RG' + ROW.OID1}
				if (SELECT.GROUPBY == 'DEPARTEMENT' && ROW.OID1 != '-9999999') {return 'DP' + ROW.OID1}
				if (SELECT.GROUPBY == 'CODEGEOPMSI' && ROW.OID1 != '-9999999') {return 'GP' + ROW.OID1}
				if (SELECT.GROUPBY == 'CODEPOST' && ROW.OID1 != '-9999999') {return 'CP' + ROW.OID1}
				if (SELECT.GROUPBY == 'TERSANTE' && ROW.OID1 != '-9999999') {return 'TS' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="PARAMETRE_PERSONNALISE_RSS_1">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PS1CLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'PS1' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'PS1CLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'PS1' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY.substr(0,6) == 'PS1CLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'PS1' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				
			]]></value>
		</ARG>
		<ARG name="PARAMETRE_PERSONNALISE_RSS_2">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PS2CLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'PS2' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3}               
                if (SELECT.GROUPBY_2.substr(0,6) == 'PS2CLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'PS2' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY.substr(0,6) == 'PS2CLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'PS2' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				
			]]></value>
		</ARG>
		
		<ARG name="EXPERT_CONTROLE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'EXCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'EXC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'EXCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'EXC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY.substr(0,6) == 'EXCCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'EXC' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				
			]]></value>
		</ARG>
		
		<ARG name="MODE_ENTREE">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'ME' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'ME' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2}
				if (SELECT.GROUPBY == 'ME' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1}
				if (SELECT.GROUPBY_3 == 'PR' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3.substr(0,1)}
				if (SELECT.GROUPBY_2 == 'PR' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2.substr(0,1)}
				if (SELECT.GROUPBY == 'PR' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1.substr(0,1)}
				
			]]></value>
		</ARG>
		
		<ARG name="PROVENANCE">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'PR' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3.substr(1,1)}
				if (SELECT.GROUPBY_2 == 'PR' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2.substr(1,1)}
				if (SELECT.GROUPBY == 'PR' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1.substr(1,1)}
				
			]]></value>
		</ARG>		
        <ARG name="ETAB_PROVE">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'ETAB_PROV' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return ROW.OID3}
				if (SELECT.GROUPBY_2 == 'ETAB_PROV' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return ROW.OID2}
				if (SELECT.GROUPBY == 'ETAB_PROV' && ROW.OID1 != '-9999999') {return  ROW.OID1}
				
			]]></value>
		</ARG>        
        <ARG name="ETAB_DEST">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'ETAB_DEST' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return ROW.OID3}
				if (SELECT.GROUPBY_2 == 'ETAB_DEST' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return ROW.OID2}
				if (SELECT.GROUPBY == 'ETAB_DEST' && ROW.OID1 != '-9999999') {return  ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="MODE_SORTIE">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'MS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'MS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2}
				if (SELECT.GROUPBY == 'MS' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1}
				if (SELECT.GROUPBY_3 == 'DS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3.substr(0,1)}
				if (SELECT.GROUPBY_2 == 'DS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2.substr(0,1)}
				if (SELECT.GROUPBY == 'DS' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1.substr(0,1)}
				
			]]></value>
		</ARG>
		
		<ARG name="DESTINATION">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'DS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'I' + ROW.COD3.substr(1,1)}
				if (SELECT.GROUPBY_2 == 'DS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'I' + ROW.COD2.substr(1,1)}
				if (SELECT.GROUPBY == 'DS' && ROW.OID1 != '-9999999') {return 'I' + ROW.COD1.substr(1,1)}
				
			]]></value>
		</ARG>
		
		<ARG name="TAUX_REMB">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'TX_REMB' && ROW.COD3 == ROW.COD) {return ROW.OID3}
				if (SELECT.GROUPBY_2 == 'TX_REMB' && ROW.COD2 == ROW.COD) {return ROW.OID2}
				if (SELECT.GROUPBY == 'TX_REMB') {return ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="TAUX_REMB2">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'TX_REMB' && ROW.COD3 == ROW.COD) {return ROW.OID3}
				if (SELECT.GROUPBY_2 == 'TX_REMB' && ROW.COD2 == ROW.COD) {return ROW.OID2}
				if (SELECT.GROUPBY == 'TX_REMB') {return ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="REGIME">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'REGIME' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'REGIME' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'REGIME') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="PEC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'PEC' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'PEC' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'PEC') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="MOTIF_NON_FACTURATION">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'MOTIF_NON_FACTURATION' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'MOTIF_NON_FACTURATION' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'MOTIF_NON_FACTURATION') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="NATURE_PEC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'NATURE_PEC' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'NATURE_PEC' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'NATURE_PEC') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="TYPE_CONTRAT_OC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'TYPE_CONTRAT_OC' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'TYPE_CONTRAT_OC' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'TYPE_CONTRAT_OC') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="PEC_FJ">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'PEC_FJ' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'PEC_FJ' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'PEC_FJ') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="EXONERATION_TM">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'EXONERATION_TM' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'EXONERATION_TM' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'EXONERATION_TM') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="FAC_18EUROS">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'FAC_18EUROS' && ROW.COD3 == ROW.COD) {return 'DT' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'FAC_18EUROS' && ROW.COD2 == ROW.COD) {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY == 'FAC_18EUROS') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="PAT_BENEF_CMU">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'PAT_BENEF_CMU' && ROW.COD3 == ROW.COD) {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'PAT_BENEF_CMU' && ROW.COD2 == ROW.COD) {return ROW.COD2}
				if (SELECT.GROUPBY == 'PAT_BENEF_CMU') {return ROW.COD1}
				
			]]></value>
		</ARG>
		
		<ARG name="VALORISE_FIDES">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'VALORISE_FIDES' && ROW.COD3 == ROW.COD) {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'VALORISE_FIDES' && ROW.COD2 == ROW.COD) {return ROW.COD2}
				if (SELECT.GROUPBY == 'VALORISE_FIDES') {return ROW.COD1}
				
			]]></value>
		</ARG>		
        
        <ARG name="NO_RSS">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'RSS' && ROW.COD3 == ROW.COD) {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'RSS' && ROW.COD2 == ROW.COD) {return ROW.COD2}
				if (SELECT.GROUPBY == 'RSS') {return ROW.COD1}
				
			]]></value>
		</ARG>
		
		<ARG name="CHAMP">
			<value><![CDATA[ 
			
				var champ:String = '';
				
				if (SELECT.GROUPBY_3 == 'ETAT_EPMSI' && ROW.COD3 == ROW.COD) {champ = ROW.OID3.toString();}
				if (SELECT.GROUPBY_2 == 'ETAT_EPMSI' && ROW.COD2 == ROW.COD) {champ = ROW.OID2.toString();}
				if (SELECT.GROUPBY == 'ETAT_EPMSI') {champ = ROW.OID1.toString();}
				
				if (champ != '') {
					if (champ == '11') { 
						return 'EXNTR11';
					}
					else if (champ == '12') { 
						return 'EXNTR12';
					}
					else if (champ == '13') { 
						return 'EXNTR13';
					}
					else if (champ == '15') { 
						return 'EXNTR15';
					}
					else if (champ == '21') { 
						return 'EXNVA21';
					}
					else if (champ == '22') { 
						return 'EXNVA22';
					}
					else if (champ == '23') { 
						return 'EXNVA23';
					}
					else if (champ == '24') { 
						return 'EXNVA24';
					}
					else if (champ == '25') { 
						return 'EXNVA25';
					}
					else if (champ == '26') { 
						return 'EXNVA26';
					}
					else if (champ == '30') { 
						return 'EXVA30';
					}
					else if (champ == '31') { 
						return 'EXVA31';
					}
					else if (champ == '32') { 
						return 'EXVA32';
					}
					else if (champ == '33') { 
						return 'EXVA33';
					}
					else {
						return 'EX';
					}
				}
				else { 
					return SELECT.CHAMP; 
				}
				
			]]></value>
		</ARG>

        <ARG name="GHSASSOS">
            <value><![CDATA[
                
                if (SELECT.GROUPBY_3 == 'GHSASSOS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'GS' + ROW.OID2}
                if (SELECT.GROUPBY_2 == 'GHSASSOS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'GS' + ROW.OID2}
                if (SELECT.GROUPBY == 'GHSASSOS' && ROW.OID1 != '-9999999') {return 'GS' + ROW.OID1}
                
            ]]></value>
        </ARG>

        <ARG name="T_GHSASSOS">
            <value><![CDATA[
                
                if (SELECT.GROUPBY_3 == 'GHSASSOS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return "I**" ;}
                if (SELECT.GROUPBY_2 == 'GHSASSOS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return "I**" ;}
                if (SELECT.GROUPBY == 'GHSASSOS' && ROW.OID1 != '-9999999') {return "I**" ;}
                
            ]]></value>
        </ARG>

        <ARG name="ETAT_RSS">
            <value><![CDATA[
                
                if (SELECT.GROUPBY_2 == 'ETAT_RSS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {if(ROW.COD1 == '**'){return 'SL' + '8';}else{return 'SL' + ROW.COD2 ;}}
                if (SELECT.GROUPBY == 'ETAT_RSS' && ROW.OID1 != '-9999999') {if(ROW.COD1 == '**'){return 'SL' + '8';}else{return 'SL' + ROW.COD1 ;}}
                
            ]]></value>
        </ARG>        
        <ARG name="T_TYPE_SEJ_OVALIDE">
            <value><![CDATA[
                
                if (SELECT.GROUPBY_2 == 'TYPE_SEJ_OVA' && ROW.OID2 != '0' && ROW.OID2 != '-9999999'){return ROW.COD2 ;}
                if (SELECT.GROUPBY == 'TYPE_SEJ_OVA' && ROW.OID1 != '-9999999'){return ROW.COD1;}
                
            ]]></value>
        </ARG>        

        <ARG name="IUCD_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'IUCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'IND_UCD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'IU' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'IUCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'IND_UCD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'IU' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'IUCCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'IND_UCD' && ROW.OID1 != '-9999999') {return 'IU' + ROW.OID1}
				
				
			]]></value>
		</ARG>

		<ARG name="F_HPHC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GHPHC' && ROW.COD3 == ROW.COD) {return 'CO' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'GHPHC' && ROW.COD2 == ROW.COD) {return 'CO' + ROW.COD2}
				if (SELECT.GROUPBY == 'GHPHC') {return 'CO' + ROW.COD1}
				
			]]></value>
		</ARG>

		<ARG name="F_RAAC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GRAAC' && ROW.COD3 == ROW.COD) {return 'RA' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'GRAAC' && ROW.COD2 == ROW.COD) {return 'RA' + ROW.OID2}
				if (SELECT.GROUPBY == 'GRAAC') {return 'RA' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="F_NP">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GNP' && ROW.COD3 == ROW.COD) {return 'NP' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'GNP' && ROW.COD2 == ROW.COD) {return 'NP' + ROW.OID2}
				if (SELECT.GROUPBY == 'GNP') {return 'NP' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="F_PASSAGE_URGENCES">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'G_PASSAGE_URGENCES') {return 'URG' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'G_PASSAGE_URGENCES') {return 'URG' + ROW.OID2}
				if (SELECT.GROUPBY == 'G_PASSAGE_URGENCES') {return 'URG' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="F_RESC_TARIF">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GRESC_TARF' && ROW.COD3 == ROW.COD) {return 'RT' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'GRESC_TARF' && ROW.COD2 == ROW.COD) {return 'RT' + ROW.COD2}
				if (SELECT.GROUPBY == 'GRESC_TARF') {return 'RT' + ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="F_ADM_PROD_RESHOSPI">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GPRO_RES_HOSP' && ROW.COD3 == ROW.COD) {return 'AP' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'GPRO_RES_HOSP' && ROW.COD2 == ROW.COD) {return 'AP' + ROW.COD2}
				if (SELECT.GROUPBY == 'GPRO_RES_HOSP') {return 'AP' + ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="F_CTX_PAT">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GCONT_PAT' && ROW.COD3 == ROW.COD) {return 'CP' + ROW.COD3}
				if (SELECT.GROUPBY_2 == 'GCONT_PAT' && ROW.COD2 == ROW.COD) {return 'CP' + ROW.COD2}
				if (SELECT.GROUPBY == 'GCONT_PAT') {return 'CP' + ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="F_NB_INTERV">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'GNB_INTERV' && ROW.COD3 == ROW.COD) {return 'NI' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'GNB_INTERV' && ROW.COD2 == ROW.COD) {return 'NI' + ROW.OID2}
				if (SELECT.GROUPBY == 'GNB_INTERV') {return 'NI' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN_RUM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'MRUCLS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'MEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'SPEMEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D2' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'MRUCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'MEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'SPEMEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'MRUCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'MEDRUM' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				if (SELECT.GROUPBY == 'SPEMEDRUM' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>
	</COMPONENT>
    
	<COMPONENT name="EXPERT_VIEWLINK">
       <ARG name="GROUP_PERIODE">
			<value><![CDATA[
                
                var row_cod:String = '';
				
				if (SELECT.GROUPBY == 'EXC_DATE_GROUP' || SELECT.GROUPBY_2 == 'EXC_DATE_GROUP') {
					row_cod = (SELECT.GROUPBY == 'EXC_DATE_GROUP') ? ROW.COD1 : ROW.COD2;
					return row_cod;
				}
                else if (SELECT.GROUPBY == 'EXC_ANSE_GROUP' || SELECT.GROUPBY_2 == 'EXC_ANSE_GROUP') {
                    row_cod = (SELECT.GROUPBY == 'EXC_ANSE_GROUP') ? ROW.COD1 : ROW.COD2;
                    return toSql(getDateFromYearWeek(row_cod, 6));
                }
                else if (SELECT.GROUPBY == 'EXC_ANMO_GROUP' || SELECT.GROUPBY_2 == 'EXC_ANMO_GROUP') {
                    row_cod = (SELECT.GROUPBY == 'EXC_ANMO_GROUP') ? ROW.COD1 : ROW.COD2;
                    return row_cod;
                }
				else {
					return '-1';
				}
				
			]]></value>
		</ARG>
		<ARG name="GROUP_TOPERIODE">
			<value><![CDATA[
                
                var row_cod:String = '';
                
				if (SELECT.GROUPBY == 'EXC_DATE_GROUP' || SELECT.GROUPBY_2 == 'EXC_DATE_GROUP') {
					row_cod = (SELECT.GROUPBY == 'EXC_DATE_GROUP') ? ROW.COD1 : ROW.COD2;
					return row_cod;
				}
                else if (SELECT.GROUPBY == 'EXC_ANSE_GROUP' || SELECT.GROUPBY_2 == 'EXC_ANSE_GROUP') {
                    row_cod = (SELECT.GROUPBY == 'EXC_ANSE_GROUP') ? ROW.COD1 : ROW.COD2;
                    return toSql(getDateFromYearWeek(row_cod, 0));
                }
                else if (SELECT.GROUPBY == 'EXC_ANMO_GROUP' || SELECT.GROUPBY_2 == 'EXC_ANMO_GROUP') {
                    row_cod = (SELECT.GROUPBY == 'EXC_ANMO_GROUP') ? ROW.COD1 : ROW.COD2;
                    return row_cod;
                }
				else {
					return '-1';
				}
                
			]]></value>
		</ARG>
    </COMPONENT>
    
	<COMPONENT name="RSS_OTHERS_VIEWLINK"  >
		
		<ARG name="T_DIAG_2_RSS">
			<value><![CDATA[
				
                if(SELECT.T_DIAG == '-1' && SELECT.GROUPBY.substr(0,3) =='DIA') {   return 'D' } else {

				    if(SELECT.T_DIAG == 'D')      { return 'D'}
				    if(SELECT.T_DIAG == 'DHDD')   { return 'DHDD'}
				    if(SELECT.T_DIAG == 'DP')     { return 'DP'}
				    if(SELECT.T_DIAG == 'DPRRSS') { return 'DPRRSS'}
				    if(SELECT.T_DIAG == 'DR')     { return 'DR'}
				    if(SELECT.T_DIAG == 'DARSS')  { return 'DARSS'}
				    if(SELECT.T_DIAG == 'DP2')    { return 'DP2'}
				    if(SELECT.T_DIAG == 'DPR')    { return 'DPR'}
				    if(SELECT.T_DIAG == 'DRRUM')  { return 'DRRUM'}
				    if(SELECT.T_DIAG == 'DA')     { return 'DA'}
				    if(SELECT.T_DIAG == 'DD')     { return 'DD'}
                }

				
			]]></value>
		</ARG>
		<ARG name="DIAG_2_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'DIACLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'DIAGROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'DIAG' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DG' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'DIACLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'DIAGROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'DIAG' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DG' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'DIACLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'DIAGROOT' && ROW.OID1 != '-9999999') {return 'DR' + ROW.OID1}
				if (SELECT.GROUPBY == 'DIAG' && ROW.OID1 != '-9999999') {return 'DG' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="UM_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UMDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'UM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UM' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'UMDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'UM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UM' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UMDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UM' && ROW.OID1 != '-9999999') {return 'UM' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="UF_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UFCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'UF' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UF' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UFCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'UF' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UF' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UFCCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UF' && ROW.OID1 != '-9999999') {return 'UF' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="LPP_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'LPPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'LPP' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LP' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'LPPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'LPP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LP' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'LPPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'LPP' && ROW.OID1 != '-9999999') {return 'LP' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="UCD_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UCDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'UCD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UC' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UCDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'UCD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UC' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UCDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UCD' && ROW.OID1 != '-9999999') {return 'UC' + ROW.OID1}
				
			]]></value>
		</ARG>		
        <ARG name="IUCD_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'IUCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'IND_UCD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'IU' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'IUCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'IND_UCD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'IU' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'IUCCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'IND_UCD' && ROW.OID1 != '-9999999') {return 'IU' + ROW.OID1}
				
				
			]]></value>
		</ARG>
		<ARG name="PRESTATION_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PRECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'PRESTA' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'PR' + ROW.OID3}             
                if (SELECT.GROUPBY_2.substr(0,6) == 'PRECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'PRESTA' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'PR' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'PRECLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'PRESTA' && ROW.OID1 != '-9999999') {return 'PR' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="ACTE_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'ACTCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'ACTE' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3}
				if (SELECT.GROUPBY_3.substr(0,6) == 'ACDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'ACD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'REGCCAM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'RC' + ROW.OID3}               
                if (SELECT.GROUPBY_2.substr(0,6) == 'ACTCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'ACTE' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2}
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'ACD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'REGCCAM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'RC' + ROW.OID2}
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACTCLS' && SELECT.GROUPBY == '-1'  &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY.substr(0,6) == 'ACTCLS'  && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'ACTE' && ROW.OID1 != '-9999999') {return 'AC' + ROW.OID1} 
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACDCLS' && SELECT.GROUPBY == '-1' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY.substr(0,6) == 'ACDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'ACD' && ROW.OID1 != '-9999999') {return 'AC' + ROW.OID1} 
				if (SELECT.GROUPBY == 'REGCCAM' && ROW.OID1 != '-9999999') {return 'RC' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN_ACTE_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'EXECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'EXEC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3}               
                if (SELECT.GROUPBY_2.substr(0,6) == 'EXECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'EXEC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'EXECSPE' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'EXECLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'EXEC' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				if (SELECT.GROUPBY == 'EXECSPE' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN_RUM_RSS">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'MRUCLS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'MEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'SPEMEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D2' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'MRUCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'MEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'SPEMEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'MRUCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'MEDRUM' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				if (SELECT.GROUPBY == 'SPEMEDRUM' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="EXTDOC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'EXTDOC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {if (ROW.COD3 == '') { return '0';} else {return ROW.COD3}}
				if (SELECT.GROUPBY_2 == 'EXTDOC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {if (ROW.COD2 == '') { return '0';} else {return ROW.COD2}}
				if (SELECT.GROUPBY == 'EXTDOC' && ROW.OID1 != '-9999999') {if (ROW.COD1 == '') { return '0';} else {return ROW.COD1}}
				
			]]></value>
		</ARG>							
		
	</COMPONENT>
	
	<COMPONENT name="RUM_VIEWLINK"  >
		
		<ARG name="UM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UMDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'UM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UM' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UMDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'UM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UM' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UMDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UM' && ROW.OID1 != '-9999999') {return 'UM' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="UM_AUT">
			<value><![CDATA[
				if (SELECT.GROUPBY_2 == 'UMAUT' && ROW.COD2) {return ROW.COD2}
				if (SELECT.GROUPBY == 'UMAUT') {return ROW.COD1}
				if (SELECT.GROUPBY3 == 'UMHOS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'MA' + ROW.OID3}
				if (SELECT.GROUPBY2 == 'UMHOS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'MA' + ROW.OID2}
				if (SELECT.GROUPBY == 'UMHOS' && ROW.OID1 != '-9999999') {return 'MA' + ROW.OID1}
				if (SELECT.GROUPBY3 == 'UMDIS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DA' + ROW.OID3}
				if (SELECT.GROUPBY2 == 'UMDIS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DA' + ROW.OID2}
				if (SELECT.GROUPBY == 'UMDIS' && ROW.OID1 != '-9999999') {return 'DA' + ROW.OID1}
					
			]]></value>
		</ARG>
        <ARG name="POLE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_2.substr(0,6) == 'POLCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'POL' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'POLCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'POL' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN_RUM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'MRUCLS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'MEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'SPEMEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D2' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'MRUCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'MEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'SPEMEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'MRUCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'MEDRUM' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				if (SELECT.GROUPBY == 'SPEMEDRUM' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="LPP_VIEWLINK"  >
		
		<ARG name="LPP">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'LPPCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'LPP' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LP' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'LPPCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'LPP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LP' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'LPPCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'LPP' && ROW.OID1 != '-9999999') {return 'LP' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="QUELLE_DATE" value="	SELECT.QUELLE_DATE" />
		
	</COMPONENT>
	
	<COMPONENT name="UCD_VIEWLINK"  >
		
		<ARG name="UCD">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UCDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'UCD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UC' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UCDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'UCD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UC' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UCDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UCD' && ROW.OID1 != '-9999999') {return 'UC' + ROW.OID1}
					
			]]></value>
		</ARG>		
        
        <ARG name="I_UCD">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'IUCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'IND_UCD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'IU' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'IUCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'IND_UCD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'IU' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'IUCCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'IND_UCD' && ROW.OID1 != '-9999999') {return 'IU' + ROW.OID1}
					
			]]></value>
		</ARG>
		
		<ARG name="T_UCD">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'T_UCD') {return 'TU' + ROW.OID3}
				if (SELECT.GROUPBY_2 == 'T_UCD') {return 'TU' + ROW.OID2}
				if (SELECT.GROUPBY == 'T_UCD') {return 'TU' + ROW.OID1}
					
			]]></value>
		</ARG>
		
		<ARG name="QUELLE_DATE" value="SELECT.QUELLE_DATE" />
		
	</COMPONENT>
	
	<COMPONENT name="PRESTATION_VIEWLINK"  >
		
		<ARG name="PRESTATION">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PRECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'PRESTA' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'PR' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'PRECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'PRESTA' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'PR' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'PRECLS' && ROW.OID1 != -9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'PRESTA' && ROW.OID1 != -9999999') {return 'PR' + ROW.OID1}
				return '-1;
				
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="PRESTATION_UM_VIEWLINK"  >
		
		<ARG name="PRESTATION">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'PRECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'PRESTA' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'PR' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'PRECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'PRESTA' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'PR' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'PRECLS' && ROW.OID1 != -9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'PRESTA' && ROW.OID1 != -9999999') {return 'PR' + ROW.OID1}
				return '-1';
				
			]]></value>
		</ARG>
		<ARG name="UM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UMDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'UM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UM' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UMDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'UM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UM' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UMDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UM' && ROW.OID1 != '-9999999') {return 'UM' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="UM_AUT">
			<value><![CDATA[
			
				if (SELECT.GROUPBY_3 == 'UMAUT' && ROW.COD3) {return ROW.COD3}
				if (SELECT.GROUPBY_2 == 'UMAUT' && ROW.COD2) {return ROW.COD2}
				if (SELECT.GROUPBY == 'UMAUT') {return ROW.COD1}
				
			]]></value>
		</ARG>
        <ARG name="POLE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_2.substr(0,6) == 'POLCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'POL' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'POLCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'POL' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN_RUM">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'MRUCLS' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'MEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'SPEMEDRUM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D2' + ROW.OID3}
                if (SELECT.GROUPBY_2.substr(0,6) == 'MRUCLS' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'MEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'SPEMEDRUM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'MRUCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'MEDRUM' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1} 
				if (SELECT.GROUPBY == 'SPEMEDRUM' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="DIAG_VIEWLINK"  >
		
		<ARG name="T_DIAG">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'DIACLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY_3 == 'DIAGROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY_3 == 'DIAG' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'D'}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'DIACLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY_2 == 'DIAGROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY_2 == 'DIAG' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY.substr(0,6) == 'DIACLS' && ROW.OID1 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY == 'DIAGROOT' && ROW.OID1 != '-9999999') {return 'D'}
				if (SELECT.GROUPBY == 'DIAG' && ROW.OID1 != '-9999999') {return 'D'}
				
			]]></value>
		</ARG>
	
		<ARG name="DIAG">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'DIACLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'DIAGROOT' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DR' + ROW.OID3}
				if (SELECT.GROUPBY_3 == 'DIAG' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DG' + ROW.OID3}                
				if (SELECT.GROUPBY_2.substr(0,6) == 'DIACLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'DIAGROOT' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DR' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'DIAG' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'DG' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'DIACLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'DIAGROOT' && ROW.OID1 != '-9999999') {return 'DR' + ROW.OID1}
				if (SELECT.GROUPBY == 'DIAG' && ROW.OID1 != '-9999999') {return 'DG' + ROW.OID1}
				
			]]></value>
		</ARG>
		
		<ARG name="F_DIAGSEV">
			<value><![CDATA[
				if (SELECT.GROUPBY_3 == 'G_DIAGSEV' && ROW.OID3 != '-9999999') {return 'DT' + ROW.COD3;}
				if (SELECT.GROUPBY_2 == 'G_DIAGSEV' && ROW.OID2 != '-9999999') {return 'DT' + ROW.COD2;}
				if (SELECT.GROUPBY == 'G_DIAGSEV' && ROW.OID1 != '-9999999') {return 'DT' + ROW.COD1;}

			]]></value>
		</ARG>


        <ARG name="POLE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_2.substr(0,6) == 'POLCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'POL' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'POLCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'POL' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="PERIODICITE_VIEWLINK"  >
		
		<ARG name="PERIODICITE">
			<value><![CDATA[
				var annee_periode:String = parseInt(SELECT.PERIODE.substr(0,4));
				var mois_periode:String = parseInt(SELECT.PERIODE.substr(5,2));
				var jour_periode:String = parseInt(SELECT.PERIODE.substr(8,2));
				var annee_toperiode:String = parseInt(SELECT.TOPERIODE.substr(0,4));
				var mois_toperiode:String = parseInt(SELECT.TOPERIODE.substr(5,2));
				var jour_toperiode:String = parseInt(SELECT.TOPERIODE.substr(8,2));
				
				if (annee_periode > annee_toperiode) {return 'MONTH';}
				else if (annee_toperiode > annee_periode) {return 'QUARTER';}
				else if (mois_toperiode > mois_periode || mois_periode > mois_toperiode) {return 'MONTH';}
				else if (jour_toperiode - jour_periode > 7) {return 'WEEK2';}
				else {return 'DAY';}
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="ACTE_VIEWLINK"  >
		
		<ARG name="ACTE">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3.substr(0,6) == 'ACTCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'ACTE' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3} 
				if (SELECT.GROUPBY_3.substr(0,6) == 'ACDCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'ACD' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'REGCCAM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'RC' + ROW.OID3}                
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACTCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'ACTE' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2} 
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACDCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACDCLS' && SELECT.GROUPBY == '-1' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY_2 == 'ACD' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'REGCCAM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'RC' + ROW.OID2}
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACTCLS' && SELECT.GROUPBY == '-1' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY.substr(0,6) == 'ACTCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'ACTE' && ROW.OID1 != '-9999999') {return 'AC' + ROW.OID1} 
				if (SELECT.GROUPBY.substr(0,6) == 'ACDCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'ACD' && ROW.OID1 != '-9999999') {return 'AC' + ROW.OID1} 
				if (SELECT.GROUPBY == 'REGCCAM' && ROW.OID1 != '-9999999') {return 'RC' + ROW.OID1}
				return "-1";
				
			]]></value>
		</ARG>
		<ARG name="UF">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UFCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'UF' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'UF' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UFCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'UF' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'UF' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UFCCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UF' && ROW.OID1 != '-9999999') {return 'UF' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'EXECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'EXEC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'EXECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'EXEC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'EXECSPE' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'D2' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'EXECLS' &&  ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'EXEC' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				if (SELECT.GROUPBY == 'EXECSPE' && ROW.OID1 != '-9999999') {return 'D2' + ROW.OID1}
				
			]]></value>
		</ARG>		
        <ARG name="ANP">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'ANPNP' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AN' + ROW.COD3}                
				if (SELECT.GROUPBY_2 == 'ANPNP' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AN' + ROW.COD2}
				if (SELECT.GROUPBY == 'ANPNP' && ROW.OID1 != '-9999999') {return 'AN' + ROW.COD1}
				
			]]></value>
		</ARG>
		<ARG name="ACTE_EXTENSION_DOC">
			<value><![CDATA[
				
				if (SELECT.GROUPBY_3 == 'EXTDOC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {if (ROW.COD3 == '') { return '0';} else {return ROW.COD3}}
				if (SELECT.GROUPBY_2 == 'EXTDOC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {if (ROW.COD2 == '') { return '0';} else {return ROW.COD2}}
				if (SELECT.GROUPBY == 'EXTDOC' && ROW.OID1 != '-9999999') {if (ROW.COD1 == '') { return '0';} else {return ROW.COD1}}
				
			]]></value>
		</ARG>
        
        <ARG name="POLE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_2.substr(0,6) == 'POLCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'POL' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'POLCLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'POL' && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		
	</COMPONENT>
	
	<COMPONENT name="INTERVENTION_VIEWLINK"  >
		
		<ARG name="ACTE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'ACICLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'INTACTE' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'AC' + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'INTREGCCAM' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'RC' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'ACICLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'INTACTE' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'AC' + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'INTREGCCAM' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'RC' + ROW.OID2}
				if (SELECT.GROUPBY_2.substr(0,6) == 'ACICLS' && SELECT.GROUPBY == '-1' && ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY.substr(0,6) == 'ACICLS' && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'INTACTE' && ROW.OID1 != '-9999999') {return 'AC' + ROW.OID1} 
				if (SELECT.GROUPBY == 'INTREGCCAM' && ROW.OID1 != '-9999999') {return 'RC' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="UF">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'UFCCLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'UF' && ROW.OID3 != '0' && ROW.OID3 != '-9999999') {return 'UF' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'UFCCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'UF' && ROW.OID2 != '0' && ROW.OID2 != '-9999999') {return 'UF' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'UFCCLS'  && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'UF'  && ROW.OID1 != '-9999999') {return 'UF' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="MEDECIN">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_3.substr(0,6) == 'EXECLS' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'LS' + SELECT.GROUPBY_3.substr(6) + ROW.OID3} 
				if (SELECT.GROUPBY_3 == 'EXEC' && ROW.OID3 != '0' &&  ROW.OID3 != '-9999999') {return 'DT' + ROW.OID3}                
                if (SELECT.GROUPBY_2.substr(0,6) == 'EXECLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2} 
				if (SELECT.GROUPBY_2 == 'EXEC' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'EXECLS'  && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'EXEC'  && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
		<ARG name="ANESTHESISTE" value="if (SELECT.GROUPBY == 'ANESTH') {return 'DT' + ROW.OID} " />
        
        <ARG name="POLE">
			<value><![CDATA[
				
                if (SELECT.GROUPBY_2.substr(0,6) == 'POLCLS' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'LS' + SELECT.GROUPBY_2.substr(6) + ROW.OID2}
				if (SELECT.GROUPBY_2 == 'POL' && ROW.OID2 != '0' &&  ROW.OID2 != '-9999999') {return 'DT' + ROW.OID2}
				if (SELECT.GROUPBY.substr(0,6) == 'POLCLS'  && ROW.OID1 != '-9999999') {return 'LS' + SELECT.GROUPBY.substr(6) + ROW.OID1} 
				if (SELECT.GROUPBY == 'POL'  && ROW.OID1 != '-9999999') {return 'DT' + ROW.OID1}
				
			]]></value>
		</ARG>
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_RSS" label="Propriétés diverses RSS" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="VIEW_DATATYPE" value="[EVAL 
					return 'RSS';
			EVAL]" />
            <PROPERTY name="ORDERBY">
                <value>
                    <![CDATA[
                        [EVAL 
                        $groupbys = array(
                                            '[GROUPBY]', 
                                            '[GROUPBY_2]', 
                                            '[GROUPBY_3]',
                                            substr('[GROUPBY]', 0, 6), 
                                            substr('[GROUPBY_2]', 0, 6), 
                                            substr('[GROUPBY_3]', 0, 6)
                                        );
                        $exceptions = array('AGE','AGECLS','AMSOR','MSOR');
                        
                        $result = array_intersect($groupbys, $exceptions);
                        
                        if (count($result) > 0) {
                            return "DEFAULT";
                        }
                        else {
                            return "indicateurs[17]";
                        }
                            
                        EVAL] 
                        ]]>
                    </value>
            </PROPERTY>
			<PROPERTY name="NB_DATA">
				<value>
					<![CDATA[
						[EVAL 
							$array1 = array('[DATA1]', '[DATA2]', '[DATA3]','[DATA4]','[DATA5]','[DATA6]','[DATA7]','[DATA8]','[DATA9]','[DATA10]','[DATA011]','[DATA012]','[DATA013]','[DATA014]','[DATA015]');
	
							for($i=0;$i<=14;$i++){
								if($array1[$i] != '0'){
										$nb_data = $i + 1 ;
								}
							}
							return $nb_data;
						EVAL] 
						]]>
					</value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_ETATDOSSIER" label="Propriétés diverses Etats dossiers PMSI" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="VIEW_DATATYPE" value="ETATDOSSIER" />
			
		</VIEWPROPERTIES>
		
	</COMPONENT>

	<COMPONENT name="PROPERTIES_ACTES" label="Propriétés diverses actes" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="VIEW_DATATYPE">
				<value><![CDATA[[EVAL 
					return 'ACTES';
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="QUELLEDATE">
				<value><![CDATA[[EVAL 
					if ('[QUELLEDATE]' == '2') {return 'date_acte';}
					return 'date_sortie';
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="ICR_FIELD">
				<value><![CDATA[[EVAL 
					if ('[ICR_CLASSIFICATION]' == 'ATIHPRIVE') {return 'icr_prive_atih';}
					if ('[ICR_CLASSIFICATION]' == 'ATIHPUBLIC') {return 'icr_public_atih';}
					return 'icr';
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="FILTRE_ACTE_SELECT">
				<value><![CDATA[[EVAL 
					
					$mode = substr('[ACTE]',0,2);
					$oid = substr('[ACTE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[ACTE]');
						$oid = PMSI_get_classe_oid('[ACTE]');
					}
					$subselect = '';
					
					if ($mode == 'SC') {
						switch(substr('[ACTE]', 2, 1)){
							case '1' : $sujet = 'topographie_1_id'; break;
							case '2' : $sujet = 'topographie_2_id'; break;
							case '3' : $sujet = 'action_id'; break;
							case '4' : $sujet = 'technique_id'; break;
						}
						$oid = substr('[ACTE]', 3);
						$subselect = " AND acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $sujet = $oid)";
					}
					if ($mode == 'TA') {
						$subselect = " AND acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE type_id = $oid)";
					}
					if ($mode == 'CH') {
						$niveau_chapitre = substr('[ACTE]', 2, 1);
						$oid = substr('[ACTE]', 3);
						$subselect = " AND acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE chapitre_".$niveau_chapitre."_id = $oid)";
					}
					if ($mode == 'C*') {
						$subselect = " AND (acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid'))) OR acte_ccam_descriptif_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid'))))";
					}
					if ($mode == 'LI') {$subselect = " AND (acte_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid))";}
					if ($mode == 'SL') {$subselect = " AND (acte_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid) AND acte_ccam_descriptif_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid))";}
					if ($mode == 'LS') {$subselect = " AND (acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid))";}
					if ($mode == 'NO') {$subselect = " AND (acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid') OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid'))";}
					if ($mode == 'GX') {$subselect = " AND (acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0))";}
					if ($mode == 'GM') {$subselect = " AND (acte_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid) OR acte_ccam_descriptif_id = ANY (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid))";}
					if ($mode == 'RC') {$subselect = " AND acte_regroupement_id = $oid ";}
					if ($mode == 'AC') {$subselect = " AND (acte_id = $oid OR acte_ccam_descriptif_id = $oid)";}
					
					if ('[ACTE_ACTIVITE_CCAM]' == '6') {$subselect = $subselect . " AND activite_ccam <> '4' ";}
					if ('[ACTE_ACTIVITE_CCAM]' == '4') {$subselect = $subselect . " AND activite_ccam = '4' ";}
                    if ('[ACTE_ACTIVITE_CCAM]' == '2') {$subselect = $subselect . " AND activite_ccam = '2' ";}
                    if ('[ACTE_ACTIVITE_CCAM]' == '3') {$subselect = $subselect . " AND activite_ccam = '3' ";}
                    if ('[ACTE_ACTIVITE_CCAM]' == '5') {$subselect = $subselect . " AND activite_ccam = '5' ";}
                    if ('[ACTE_ACTIVITE_CCAM]' == '1') {$subselect = $subselect . " AND activite_ccam = '1' ";}
					
				    // Modificateurs CCAM 
				    $mode = substr('[MCC]',0,2);
					$code = substr('[MCC]',2);
                    if ($mode == 'MC') {
					$subselect = $subselect . "AND ((modificateur_ccam_1 = '$code'::text) OR (modificateur_ccam_2 = '$code'::text ) OR (modificateur_ccam_3 = '$code'::text) OR (modificateur_ccam_4 = '$code'::text)) ";
                    }
					
					// Association non prévue 
				    $mode = substr('[ANP]',0,2);
					$code = substr('[ANP]',2);
                    if ($mode == 'AN') {
					$subselect = $subselect . "AND association_nonprevue_ccam = '$code'::text ";
                    }
                    
					// exécutant Actes
					$mode = substr('[MEDECIN]',0,2);
					$oid = substr('[MEDECIN]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[MEDECIN]');
						$oid = PMSI_get_classe_oid('[MEDECIN]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND medecin_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = $subselect . " AND medecin_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = $subselect . " AND medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
					if ($mode == 'SP') {$subselect = $subselect . " AND specialite_interne_medecin_reference_id = $oid ";}
					if ($mode == 'SO') {$subselect = $subselect . " AND specialite_medecin_reference_id = $oid ";}
					if ($mode == 'C*') {$subselect = $subselect . " AND medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					if ($mode == 'MD') {$subselect = $subselect . " AND medecin_reference_id = $oid ";}
					if ($mode == 'DT') {$subselect = $subselect . " AND medecin_reference_id = $oid ";}
					if ($mode == 'D2') {$subselect = $subselect . " AND specialite_interne_medecin_reference_id = $oid ";}

                    // Pole
					$mode = substr('[POLE]',0,2);
					$oid = substr('[POLE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[POLE]');
						$oid = PMSI_get_classe_oid('[POLE]');
					}
                    if ($mode == 'LI') {$subselect = "$subselect AND pole_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = "$subselect AND pole_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = "$subselect AND pole_rum_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'DT') {$subselect = "$subselect AND pole_rum_id = $oid ";}
                    
					// Unité médicale
					$mode = substr('[UM]',0,2);
					$oid = substr('[UM]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UM]');
						$oid = PMSI_get_classe_oid('[UM]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = $subselect . " AND unite_medicale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'AN') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')";}
					if ($mode == 'AT') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
					if ($mode == 'AU') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
					if ($mode == 'UM') {$subselect = $subselect . " AND unite_medicale_id = $oid ";}
					
					// Unité fonctionnelle
					$mode = substr('[UF]',0,2);
					$oid = substr('[UF]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UF]');
						$oid = PMSI_get_classe_oid('[UF]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND unite_fonctionnelle_id = ANY( ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'SL') {$subselect = $subselect . " AND unite_fonctionnelle_id != ALL (ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'LS') {$subselect = $subselect . " AND unite_fonctionnelle_id = ANY( ARRAY(SELECT oid FROM pmsi.t_unites_fonctionnelles WHERE $section_id = $oid)::bigint[])";}
					if ($mode == 'UF') {$subselect = $subselect . " AND unite_fonctionnelle_id = $oid ";}
					
					if ('[ACTE_EXTENSION_DOC]' != '-1') {
						$val = '';
						if ('[ACTE_EXTENSION_DOC]' != '0') {
							$val = "[ACTE_EXTENSION_DOC]";
						}
						$subselect = $subselect .  " AND extension_ccam = '" . $val . "'";
					}

					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_INTERVENTIONS" label="Propriétés diverses interventions" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="VIEW_DATATYPE">
				<value><![CDATA[[EVAL 
					return 'INTERVENTIONS';
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="QUELLEDATE">
				<value><![CDATA[[EVAL 
					if ('[QUELLEDATE]' == '2') {return 'date_acte';}
					return 'date_sortie';
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="ICR_FIELD">
				<value><![CDATA[[EVAL 
					if ('[ICR_CLASSIFICATION]' == 'ATIHPRIVE') {return 'icr_prive_atih';}
					if ('[ICR_CLASSIFICATION]' == 'ATIHPUBLIC') {return 'icr_public_atih';}
					return 'icr';
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY name="FILTRE_INTERV_SELECT">
				<value><![CDATA[[EVAL 
					
					$mode = substr('[ACTE]',0,2);
					$oid = substr('[ACTE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[ACTE]');
						$oid = PMSI_get_classe_oid('[ACTE]');
					}
					$subselect = '';
					if ($mode == 'C*') {
						$subselect = " AND v_rss_actes_4.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";
					}
					if ($mode == 'LI') {$subselect = " AND v_rss_actes_4.acte_principal_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = " AND v_rss_actes_4.acte_principal_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = " AND v_rss_actes_4.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE $section_id = $oid)";}
					if ($mode == 'NO') {$subselect = " AND v_rss_actes_4.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE nomenclature = '$oid')";}
					if ($mode == 'GX') {$subselect = " AND v_rss_actes_4.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id > 0)";}
					if ($mode == 'GM') {$subselect = " AND v_rss_actes_4.acte_principal_id IN (SELECT oid FROM pmsi.t_actes_c WHERE geste_marqueur_id = $oid)";}
					if ($mode == 'RC') {$subselect = " AND v_rss_actes_4.acte_principal_regroupement_id = $oid ";}
					if ($mode == 'AC') {$subselect = " AND v_rss_actes_4.acte_principal_id = $oid ";}
					
					
					// exécutant Actes
					$mode = substr('[MEDECIN]',0,2);
					$oid = substr('[MEDECIN]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[MEDECIN]');
						$oid = PMSI_get_classe_oid('[MEDECIN]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND v_rss_actes_4.medecin_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = $subselect . " AND v_rss_actes_4.medecin_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = $subselect . " AND v_rss_actes_4.medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
					if ($mode == 'SP') {$subselect = $subselect . " AND v_rss_actes_4.specialite_interne_medecin_reference_id = $oid ";}
					if ($mode == 'SO') {$subselect = $subselect . " AND v_rss_actes_4.specialite_medecin_reference_id = $oid ";}
					if ($mode == 'C*') {$subselect = $subselect . " AND v_rss_actes_4.medecin_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					if ($mode == 'MD') {$subselect = $subselect . " AND v_rss_actes_4.medecin_reference_id = $oid ";}
					if ($mode == 'DT') {$subselect = $subselect . " AND v_rss_actes_4.medecin_reference_id = $oid ";}
					if ($mode == 'D2') {$subselect = $subselect . " AND v_rss_actes_4.specialite_interne_medecin_reference_id = $oid ";}
					
					// anesthesiste Actes
					$mode = substr('[ANESTHESISTE]',0,2);
					$oid = substr('[ANESTHESISTE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[ANESTHESISTE]');
						$oid = PMSI_get_classe_oid('[ANESTHESISTE]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND v_rss_actes_4.anesthesiste_reference_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = $subselect . " AND v_rss_actes_4.anesthesiste_reference_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = $subselect . " AND v_rss_actes_4.anesthesiste_id IN (SELECT oid FROM pmsi.t_anesthesistes_c WHERE $section_id = $oid)";}
					if ($mode == 'SP') {$subselect = $subselect . " AND v_rss_actes_4.specialite_interne_anesthesiste_reference_id = $oid ";}
					if ($mode == 'SO') {$subselect = $subselect . " AND v_rss_actes_4.specialite_anesthesiste_reference_id = $oid ";}
					if ($mode == 'C*') {$subselect = $subselect . " AND v_rss_actes_4.anesthesiste_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					if ($mode == 'MD') {$subselect = $subselect . " AND v_rss_actes_4.anesthesiste_reference_id = $oid ";}
					if ($mode == 'DT') {$subselect = $subselect . " AND v_rss_actes_4.anesthesiste_reference_id = $oid ";}
					if ($mode == 'D2') {$subselect = $subselect . " AND v_rss_actes_4.specialite_interne_anesthesiste_reference_id = $oid ";}
					
					// Pole
					$mode = substr('[POLE]',0,2);
					$oid = substr('[POLE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[POLE]');
						$oid = PMSI_get_classe_oid('[POLE]');
					}
                    if ($mode == 'LI') {$subselect = "$subselect AND pole_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = "$subselect AND pole_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = "$subselect AND pole_rum_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'DT') {$subselect = "$subselect AND pole_rum_id = $oid ";}
                    
                    // Unité médicale
					$mode = substr('[UM]',0,2);
					$oid = substr('[UM]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UM]');
						$oid = PMSI_get_classe_oid('[UM]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = $subselect . " AND unite_medicale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'AN') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')";}
					if ($mode == 'AT') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
					if ($mode == 'AU') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
					if ($mode == 'UM') {$subselect = $subselect . " AND unite_medicale_id = $oid ";}
					
					// Unité fonctionnelle
					$mode = substr('[UF]',0,2);
					$oid = substr('[UF]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UF]');
						$oid = PMSI_get_classe_oid('[UF]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND v_rss_actes_4.unite_fonctionnelle_id = ANY( ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'SL') {$subselect = $subselect . " AND v_rss_actes_4.unite_fonctionnelle_id != ALL (ARRAY(SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'LS') {$subselect = $subselect . " AND v_rss_actes_4.unite_fonctionnelle_id = ANY( ARRAY(SELECT oid FROM pmsi.t_unites_fonctionnelles WHERE $section_id = $oid)::bigint[])";}
					if ($mode == 'UF') {$subselect = $subselect . " AND v_rss_actes_4.unite_fonctionnelle_id = $oid ";}
					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
			<PROPERTY dataLink="CPT_INTERV" nameField="name" valueField="value" />
			
		</VIEWPROPERTIES>
		
		<QUERIES>
			<QUERY type="propertiesLink" name="CPT_INTERV" forRows="false" forSelections="false"> 
				<SQL>
					<select><![CDATA[ 
					
						SELECT 'CPT_INTERV', valeur from pmsi.t_divers where code = 'OPTPMSI_CPT_INTERV'
						
					]]></select>
					<FIELDS>
						<FIELD name="name" />
						<FIELD name="value" />
					</FIELDS>
				</SQL>
			</QUERY>
		</QUERIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_SEVERITES" label="Propriétés diverses Sévérités" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="DATA">
				<value><![CDATA[[EVAL 
				
					// code sévérité (*,1,2,3,4,C,E,J,S,T,V,W,Z)
					$severite = substr('[DATA]', 2, 1);
					
					// 0: pas de duree | 1: duree < 2 jours | 2: duree >= 2  jours
					$duree = substr('[DATA]', 3, 1);
					
					switch ($duree) {
						case '0' :
							$select = " CASE WHEN severite_ghm_code = '" . $severite . "' THEN 1 ELSE 0 END ";
							break;
						case '1' :
							$select = " CASE WHEN duree_sejour < 2 AND severite_ghm_code = '" . $severite . "' THEN 1 ELSE 0 END ";
							break;
						case '2' :
							$select = " CASE WHEN duree_sejour >= 2 AND severite_ghm_code = '" . $severite . "' THEN 1 ELSE 0 END ";
							break;
						default :
							$select = " CASE WHEN severite_ghm_code = '1' THEN 1 ELSE 0 END ";
					}
					return $select;
					
				EVAL]]]></value>
			</PROPERTY>
			<PROPERTY name="DATAT">
				<value><![CDATA[[EVAL 
				
					// 0: pas de duree | 1: duree < 2 jours | 2: duree >= 2  jours
					$duree = substr('[DATA]', 3, 1);
					
					switch ($duree) {
						case '0' :
							$select = " nb_rsa ";
							break;
						case '1' :
							$select = " CASE WHEN duree_sejour < 2 THEN 1 ELSE 0 END ";
							break;
						case '2' :
							$select = " CASE WHEN duree_sejour >= 2 THEN 1 ELSE 0 END ";
							break;
						default :
							$select = " nb_rsa ";
					}
					return $select;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_LPP" label="Propriétés diverses LPP" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="QUELLEDATE">
				<value><![CDATA[[EVAL 
					if ('[QUELLEDATE]' == '2') {return 'date_lpp';}
					return 'date_sortie';
				EVAL]]]></value>
			</PROPERTY>
		
			<PROPERTY name="LPP_SELECT">
				<value><![CDATA[[EVAL 
					
					$mode = substr('[LPP]',0,2);
					$oid = substr('[LPP]',2);
					if ($mode == 'LS') {
						if (substr('[LPP]',4,1) != '.') {
							$section_id = PMSI_get_section_id('[LPP]');
							$oid = PMSI_get_classe_oid('[LPP]');
						}
						else {
							$section_id = PMSI_get_section_id('[LPP]');
							$oid = PMSI_get_classe_oid('[LPP]', 6);
						}
						
					}
					$subselect = '';
					
					if ($mode == 'LI') {$subselect = " lpp_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = " lpp_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = " lpp_id IN (SELECT oid FROM pmsi.t_lpp WHERE $section_id = $oid)";}
					if ($mode == 'C*') {$subselect = " lpp_id IN (SELECT oid FROM pmsi.t_lpp WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					if ($mode == 'LP') {$subselect = " lpp_id = $oid ";}
					
					if ($subselect != '') {
						$subselect = " AND $subselect ";
					}
					
					if ('[PRIS_EN_COMPTE]' == '1') {
						$subselect = $subselect . " AND non_pris_en_compte <> '1' AND traitement_epmsi LIKE '3%' ";
					}
					if ('[PRIS_EN_COMPTE]' == '0') {
						$subselect = $subselect . " AND (non_pris_en_compte = '1' OR traitement_epmsi NOT LIKE '3%') ";
					}
					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_UCD" label="Propriétés diverses UCD" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="QUELLEDATE">
				<value><![CDATA[[EVAL 
					if ('[QUELLEDATE]' == '2') {return 'date_ucd';}
					return 'date_sortie';
				EVAL]]]></value>
			</PROPERTY>
		
			<PROPERTY name="UCD_SELECT">
				<value><![CDATA[[EVAL 
					
					$mode = substr('[UCD]',0,2);
					$oid = substr('[UCD]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UCD]');
						$oid = PMSI_get_classe_oid('[UCD]');
					}
					$subselect = '';
					
					if ($mode == 'LI') {$subselect = " ucd_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = " ucd_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = " ucd_id IN (SELECT oid FROM pmsi.t_ucd WHERE $section_id = $oid)";}
					if ($mode == 'C*') {$subselect = " ucd_id IN (SELECT oid FROM pmsi.t_ucd WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					if ($mode == 'UC') {$subselect = " ucd_id = $oid ";}
					
					if ($subselect != '') {
						$subselect = " AND $subselect ";
					}
					
					if ('[PRIS_EN_COMPTE]' == '1') {
						$subselect = $subselect . " AND non_pris_en_compte <> '1' AND traitement_epmsi LIKE '3%' ";
					}
					if ('[PRIS_EN_COMPTE]' == '0') {
						$subselect = $subselect . " AND (non_pris_en_compte = '1' OR traitement_epmsi NOT LIKE '3%') ";
					}
                    
                    // Type UCD
                    $mode = substr('[T_UCD]',0,2);
					$oid = intval(substr('[T_UCD]',2));
                    
                    if ($mode == 'TU') {$subselect .= " AND type_ucd_id = $oid ";}
                    
                    // indication UCD
						
						$mode = substr('[I_UCD]',0,2);
						$oid = substr('[I_UCD]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[I_UCD]');
							$oid = PMSI_get_classe_oid('[I_UCD]');
						}

						if ($mode == 'LI') {$subselect  .= "and indication_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect  .= "and indication_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'IU') {$subselect  .= "and indication_id = $oid ";}
						if ($mode == 'LS') {$subselect  .= "and indication_id IN (SELECT oid FROM pmsi.t_indication WHERE $section_id = $oid)";}
						if ($mode == 'C*') {$subselect  .= "and indication_id IN (SELECT oid FROM pmsi.t_indication WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_PRESTATIONS" label="Propriétés diverses prestations" >
		
		<VIEWPROPERTIES>
		
			<PROPERTY name="PRESTATION_SELECT">
				<value><![CDATA[[EVAL 
						
					$subselect = '';
					
					// Prestation
					$mode = substr('[PRESTATION]',0,2);
					$oid = substr('[PRESTATION]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[PRESTATION]');
						$oid = PMSI_get_classe_oid('[PRESTATION]');
					}
					
					
					$subselect2 = '';
					if ($mode == 'LI') {$subselect2 = " prestation_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect2 = " prestation_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect2 = " prestation_id IN (SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)";}
					if ($mode == 'PR') {$subselect2 = " prestation_id = $oid ";}
					
					if ($subselect2 != '') {
						$subselect = "$subselect AND $subselect2 ";
					}
					
					// Valorisation FIDES
					if ('[FIDES_DETAIL]' != '-1') {
						$oid = '[FIDES_DETAIL]';
						if ($oid == 'X') {
							$subselect = $subselect . " AND v_rsf_detail_1.fides_detail_id is null ";
						}
						else {
							$subselect = $subselect . " AND v_rsf_detail_1.fides_detail_id = $oid::integer ";
						}
					}
					
					
					// LAMDA
					$subselect2 = '';
					if ('[LAMDA]' == '1') {$subselect2 = " operation_lamda NOT IN ('2','3')";}
					if ('[LAMDA]' == '2') {$subselect2 = " operation_lamda IN ('2','3')";}
					if ($subselect2 == '') {$subselect2 = " operation_lamda NOT IN ('1','2')";}
					
					if ($subselect2 != '') {
						$subselect = "$subselect AND $subselect2 ";
					}

					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_PRESTATIONS_UM" label="Propriétés diverses prestations" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="PRESTATION_SELECT">
				<value><![CDATA[[EVAL 
					
					$subselect = '';
					
					$mode = substr('[PRESTATION]',0,2);
					$oid = substr('[PRESTATION]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[PRESTATION]');
						$oid = PMSI_get_classe_oid('[PRESTATION]');
					}
					
					$subselect_u = '';
					
					if ($mode == 'LI') {$subselect_u = " prestation_id = ANY(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'SL') {$subselect_u = " prestation_id != ALL(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'LS') {$subselect_u = " prestation_id = ANY(ARRAY (SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)::bigint[])";}
					if ($mode == 'PR') {$subselect_u = " prestation_id = $oid ";}
					
					if ($subselect_u != '') {
						$subselect = $subselect . " AND $subselect_u ";
					}
					
					// Valorisation FIDES
					if ('[FIDES_DETAIL]' != '-1') {
						$oid = '[FIDES_DETAIL]';
						if ($oid == 'X') {
							$subselect = $subselect . " AND fides_detail_id is null ";
						}
						else {
							$subselect = $subselect . " AND fides_detail_id = $oid::integer ";
						}
					}
					
					$mode = substr('[UM]',0,2);
					$oid = substr('[UM]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UM]');
						$oid = PMSI_get_classe_oid('[UM]');
					}
					$subselect_u = '';
					
					if ($mode == 'LI') {$subselect_u = " unite_medicale_id = ANY(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'SL') {$subselect_u = " unite_medicale_id != ALL(ARRAY (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)::bigint[])";}
					if ($mode == 'LS') {$subselect_u = " unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)::bigint[])";}
					if ($mode == 'AN') {$subselect_u = " unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')::bigint[])";}
					if ($mode == 'AT') {$subselect_u = " unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')::bigint[])";}
					if ($mode == 'AU') {$subselect_u = " unite_medicale_id = ANY(ARRAY (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')::bigint[])";}
					if ($mode == 'UM') {$subselect_u = " unite_medicale_id = $oid ";}
					
					if ($subselect_u != '') {
						$subselect = $subselect . " AND $subselect_u ";
					}
                    
                    // Pole
					$mode = substr('[POLE]',0,2);
					$oid = substr('[POLE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[POLE]');
						$oid = PMSI_get_classe_oid('[POLE]');
					}
                    if ($mode == 'LI') {$subselect = "$subselect AND pole_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = "$subselect AND pole_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = "$subselect AND pole_rum_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'DT') {$subselect = "$subselect AND pole_rum_id = $oid ";}
					
					// LAMDA
					$subselect_u = '';
					if ('[LAMDA]' == '1') {$subselect_u = " operation_lamda NOT IN ('2','3')";}
					if ('[LAMDA]' == '2') {$subselect_u = " operation_lamda IN ('2','3')";}
					if ($subselect_u == '') {$subselect_u = " operation_lamda NOT IN ('1','2')";}
					
					if ($subselect_u != '') {
						$subselect = $subselect . " AND $subselect_u ";
					}
					
					if ('[UM_AUT]' == 'NA') {$subselect = $subselect . " AND type_autorisation = '' ";}
					if ('[UM_AUT]' == 'TT') {$subselect = $subselect . " AND type_autorisation <> '' ";}
					if (substr('[UM_AUT]',0,2) == 'TA') {$subselect = $subselect . " AND type_autorisation = '" . substr('[UM_AUT]',2) . "' ";}
					
				    
					if (substr('[UM_HOS]',0,2) == 'MH') {$subselect = $subselect . " AND mode_hospitalisation_id = '" . substr('[UM_HOS]',2) . "' ";}
					
					
					if (substr('[UM_DIS]',0,2) == 'DI') {$subselect = $subselect . " AND mode_hospitalisation_id = '" . substr('[UM_DIS]',2) . "' ";}
					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_RUM" label="Propriétés diverses RUMs" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="FILTRE_RUM_SELECT">
				<value><![CDATA[[EVAL 
						
					$mode = substr('[UM]',0,2);
					$oid = substr('[UM]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UM]');
						$oid = PMSI_get_classe_oid('[UM]');
					}
					$subselect = '';
					
					if ($mode == 'LI') {$subselect = " unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = " unite_medicale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = " unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'AN') {$subselect = " unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')";}
					if ($mode == 'AT') {$subselect = " unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
					if ($mode == 'AU') {$subselect = " unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
					if ($mode == 'UM') {$subselect = " unite_medicale_id = $oid ";}
					
					if ($subselect != '') {
						$subselect = " AND $subselect ";
					}
                    
                    $mode = substr('[POLE]',0,2);
					$oid = substr('[POLE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[POLE]');
						$oid = PMSI_get_classe_oid('[POLE]');
					}
                    if ($mode == 'LI') {$subselect = "$subselect AND pole_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = "$subselect AND pole_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = "$subselect AND pole_rum_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'DT') {$subselect = "$subselect AND pole_rum_id = $oid ";}
                    
					
					
					if ('[UM_AUT]' == 'NA') {$subselect = $subselect . " AND type_autorisation = '' ";}
					if ('[UM_AUT]' == 'TT') {$subselect = $subselect . " AND type_autorisation <> '' ";}
					if (substr('[UM_AUT]',0,2) == 'TA') {$subselect = $subselect . " AND type_autorisation = '" . substr('[UM_AUT]',2) . "' ";}
					
					
					if (substr('[UM_HOS]',0,2) == 'MH') {$subselect = $subselect . " AND mode_hospitalisation_id = '" . substr('[UM_HOS]',2) . "' ";}
					
					if (substr('[UM_DIS]',0,2) == 'DI') {$subselect = $subselect . " AND discipline_sae_id = '" . substr('[UM_DIS]',2) . "' ";}
					

					
					
					if (substr('[MODE_ENTREE_RUM]',0,1) == 'I') {$subselect = $subselect . " AND mode_entree_rum = '" . substr('[MODE_ENTREE_RUM]',1) . "' ";}
					if (substr('[MODE_ENTREE_RUM]',0,1) == 'S') {$subselect = $subselect . " AND mode_entree_rum <> '" . substr('[MODE_ENTREE_RUM]',1) . "' ";}
					
					if (substr('[MODE_SORTIE_RUM]',0,1) == 'I') {$subselect = $subselect . " AND mode_sortie_rum = '" . substr('[MODE_SORTIE_RUM]',1) . "' ";}
					if (substr('[MODE_SORTIE_RUM]',0,1) == 'S') {$subselect = $subselect . " AND mode_sortie_rum <> '" . substr('[MODE_SORTIE_RUM]',1) . "' ";}
					
					if (substr('[PROVENANCE_RUM]',0,1) == 'I') {$subselect = $subselect . " AND provenance_rum = '" . substr('[PROVENANCE_RUM]',1) . "' ";}
					if (substr('[PROVENANCE_RUM]',0,1) == 'S') {$subselect = $subselect . " AND provenance_rum <> '" . substr('[PROVENANCE_RUM]',1) . "' ";}
					
					if (substr('[DESTINATION_RUM]',0,1) == 'I') {$subselect = $subselect . " AND destination_rum = '" . substr('[DESTINATION_RUM]',1) . "' ";}
					if (substr('[DESTINATION_RUM]',0,1) == 'S') {$subselect = $subselect . " AND destination_rum <> '" . substr('[DESTINATION_RUM]',1) . "' ";}
					
					if ('[DUREE_SEJOUR_RUM]' != '' && '[DUREE_SEJOUR_RUM2]' != '' ) {$subselect = $subselect . ' AND duree_sejour_rum BETWEEN ' . intval('[DUREE_SEJOUR_RUM]') . ' AND ' . intval('[DUREE_SEJOUR_RUM2]');}
					if ('[DUREE_SEJOUR_RUM]' != '' ) {$subselect = $subselect . ' AND duree_sejour_rum >= ' . intval('[DUREE_SEJOUR_RUM]');}
					if ('[DUREE_SEJOUR_RUM2]' != '' ) {$subselect = $subselect . ' AND duree_sejour_rum <= ' . intval('[DUREE_SEJOUR_RUM2]');}
					
						// Sélection des médecins
						
						$mode = substr('[MEDECIN_RUM]',0,2);
						$oid = substr('[MEDECIN_RUM]',2);
						if ($mode == 'LS') {
							$section_id = PMSI_get_section_id('[MEDECIN_RUM]');
							$oid = PMSI_get_classe_oid('[MEDECIN_RUM]');
						}
						
						if ($mode == 'LI') {$subselect_ = " v_rss_rum_2.medecin_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect_ = " v_rss_rum_2.medecin_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect_ = " v_rss_rum_2.medecin_rum_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE $section_id = $oid)";}
						if ($mode == 'SP') {$subselect_ = " v_rss_rum_2.specialite_medecin_reference_rum_id = $oid ";}
						if ($mode == 'SO') {$subselect_ = " v_rss_rum_2.specialite_medecin_reference_rum_id = $oid ";}
						if ($mode == 'C*') {$subselect_ = " v_rss_rum_2.medecin_rum_id IN (SELECT oid FROM pmsi.t_medecins_c WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'MD') {$subselect_ = " v_rss_rum_2.medecin_rum_id = $oid ";}
						if ($mode == 'DT') {$subselect_ = " v_rss_rum_2.medecin_rum_id = $oid ";}
						if ($mode == 'D2') {$subselect_ = " v_rss_rum_2.specialite_medecin_reference_rum_id = $oid ";}
						
						if ($subselect_ != '') {
							$subselect = $subselect. " AND $subselect_";
						}
					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>
	
	<COMPONENT name="PROPERTIES_DIAG" label="Propriétés diverses diagnostics" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="FILTRE_DIAG_SELECT">
				<value><![CDATA[[EVAL 
					
					$mode = substr('[DIAG]',0,2);
					$oid = substr('[DIAG]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[DIAG]');
						$oid = PMSI_get_classe_oid('[DIAG]');
					}
					$subselect = '';


					if ('[F_DIAGSEV]' != '-1'){
						$code = substr('[F_DIAGSEV]',2);
						$subselect = " AND diagnostic_severite_fg2023_code = $code";
					}


					if ('[T_DIAG]' != '-1') {
					
						if ($mode == 'LI') {$subselect = " AND diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'SL') {$subselect = " AND diagnostic_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
						if ($mode == 'LS') {$subselect = " AND diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
						if ($mode == 'DR') {$subselect = " AND diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
						if ($mode == 'C*') {$subselect = " AND diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
						if ($mode == 'DG') {$subselect = " AND diagnostic_id = $oid ";}
						
						
						if ('[T_DIAG]' == 'DP') {$subselect = $subselect . " AND type_diagnostic_rss = 'DP' ";}
						if ('[T_DIAG]' == 'DP2') {$subselect = $subselect . " AND type_diagnostic = 'DP' ";}
						if ('[T_DIAG]' == 'DPR') {$subselect = $subselect . " AND type_diagnostic IN ('DP', 'DR') ";}
						if ('[T_DIAG]' == 'DR') {$subselect = $subselect . " AND type_diagnostic = 'DR' ";}
						if ('[T_DIAG]' == 'DA') {$subselect = $subselect . " AND type_diagnostic IN ('DA', 'DS') ";}
						if ('[T_DIAG]' == 'DD') {$subselect = $subselect . " AND type_diagnostic = 'DD' ";}
						if ('[T_DIAG]' == 'DHDD') {$subselect = $subselect . " AND type_diagnostic != 'DD' ";}
                        if ('[T_DIAG]' == 'DARSS') {$subselect = $subselect . " AND type_diagnostic_rss = 'DA' ";}
                        if ('[T_DIAG]' == 'DPRRSS') {$subselect = $subselect . " AND type_diagnostic_rss IN ('DP', 'DR') ";}
                        if ('[T_DIAG]' == 'DRRUM') {$subselect = $subselect . " AND type_diagnostic = 'DR' ";}


					}
                    
                    // Pole
					$mode = substr('[POLE]',0,2);
					$oid = substr('[POLE]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[POLE]');
						$oid = PMSI_get_classe_oid('[POLE]');
					}
                    if ($mode == 'LI') {$subselect = "$subselect AND pole_rum_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = "$subselect AND pole_rum_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = "$subselect AND pole_rum_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'DT') {$subselect = "$subselect AND pole_rum_id = $oid ";}
					
					$mode = substr('[UM]',0,2);
					$oid = substr('[UM]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[UM]');
						$oid = PMSI_get_classe_oid('[UM]');
					}
					
					if ($mode == 'LI') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect = $subselect . " AND unite_medicale_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE $section_id = $oid)";}
					if ($mode == 'AN') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '')";}
					if ($mode == 'AT') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation <> '')";}
					if ($mode == 'AU') {$subselect = $subselect . " AND unite_medicale_id IN (SELECT oid FROM pmsi.t_unites_medicales WHERE type_autorisation = '$oid')";}
					if ($mode == 'UM') {$subselect = $subselect . $subselect . " AND unite_medicale_id = $oid ";}
					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
	</COMPONENT>

	<COMPONENT name="PROPERTIES_SELECT_TABTREE" label="Propriétés diverses SELECT" >
		
		<VIEWPROPERTIES>
			
			<PROPERTY name="SELECT_TABTREE_PREFIX">
				<value><![CDATA[
					[EVAL 	
					
					$prefixe = '';
					$groupby = '[GROUPBY]';

					if ($groupby == '-1') {
						return $prefixe ;
					}

					if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
						if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
							$groupby = '[GROUPBY_2]';
						}
					}
					
					$cls6 = substr($groupby, 0 , 6);
					
					$prefixe = selectPrefixTabtree($groupby, $cls6);
					
					return $prefixe;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_OID_FIELD">
				<value><![CDATA[
					[EVAL 	
						
						$oid_field = '0';
						$groupby = '[GROUPBY]';

						if ($groupby == '-1') {
							return $oid_field;
						}	
							
						$prefixe = '[VIEW.SELECT_TABTREE_PREFIX]';
						

						if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
							if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
								$groupby = '[GROUPBY_2]';
							}
						}

						// Regroupements grâce aux classes 
						if (substr($groupby, 3, 3) == 'CLS') {
							$groupby_section = substr($groupby, 6);
							$oid_field = $prefixe . "_id[$groupby_section]::bigint";
							return $oid_field; 
						}

						$suffixe = selectSuffixeLinkid($groupby);
						
						$oid_field = selectOidTabtree($groupby, $prefixe, $suffixe);
						
						return $oid_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_COD_FIELD">
				<value><![CDATA[
					[EVAL 	
						
						$cod_field = "''";
						$groupby = '[GROUPBY]';

						if ($groupby == '-1') {
							return $cod_field;
						}

						if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
							if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
								$groupby = '[GROUPBY_2]';
							}
						}


						$prefixe = '[VIEW.SELECT_TABTREE_PREFIX]';
						
						if (substr($groupby, 3, 3) == 'CLS') {
							$groupby_section = substr($groupby, 6);
							$cod_field = $prefixe . "_code[$groupby_section]";
							return $cod_field;
						}

						$suffixe = selectLinkcodeSuffixe($groupby);

						$cod_field = selectCodeTabtree($groupby, $prefixe, $suffixe);
						
						return $cod_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_TXT_FIELD">
				<value><![CDATA[
					[EVAL 	
						
						$txt_field = "''";
						$groupby = '[GROUPBY]';

						if ($groupby == '-1') {
							return $txt_field;
						}

						$prefixe = '[VIEW.SELECT_TABTREE_PREFIX]';

						if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
							if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
								$groupby = '[GROUPBY_2]';
							}
						}
						
						if (substr($groupby, 3, 3) == 'CLS') {
							$groupby_section = substr($groupby, 6);
							$txt_field = $prefixe . "_texte[$groupby_section]";
							return $txt_field;
						}

								
						$txt_field = selectTexteTabtree($groupby, $prefixe);
						
						return $txt_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_2_PREFIX">
				<value><![CDATA[
					[EVAL 	
					
					$prefixe = '';
					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1') {
						return $prefixe;
					}

					if('[GROUPBY_2]' == 'RSS' && '[LIRSS]' == '-1'){
						return $prefixe;
					}

					$groupby_2 = '[GROUPBY_2]';

					if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
						if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
							$groupby_2 = '[GROUPBY]';
						}
					}
					
					$cls6 = substr($groupby_2, 0 , 6);
					
                    $prefixe = selectPrefixTabtree($groupby_2, $cls6);

					return $prefixe;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_2_OID_FIELD">
				<value><![CDATA[
					[EVAL 	
					
					$oid_field = '0';

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' ) {
						return $oid_field;
					}
					if('[GROUPBY_2]' == 'RSS' && '[LIRSS]' == '-1'){
						return $oid_field;
					}


					$groupby_2 = '[GROUPBY_2]';
					$prefixe = '[VIEW.SELECT_TABTREE_2_PREFIX]';
					$suffixe = '_id';

					if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
						if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
							$groupby_2 = '[GROUPBY]';
						}
					}

					if (substr($groupby_2, 3, 3) == 'CLS') {
						$groupby_2_section = substr($groupby_2, 6);
						$oid_field = $prefixe . "_id[$groupby_2_section]";
						return $oid_field;
					}

					$suffixe = selectSuffixeLinkid($groupby_2);

					$oid_field = selectOidTabtree($groupby_2, $prefixe, $suffixe);					

					return $oid_field;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_2_COD_FIELD">
				<value><![CDATA[
					[EVAL 	
					
					$cod_field = "''";

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' ) {
						return $cod_field;
					}
                    if('[GROUPBY_2]' == 'RSS' && '[LIRSS]' == '-1'){
						return $cod_field;
					}

					$groupby_2 = '[GROUPBY_2]';
					$prefixe = '[VIEW.SELECT_TABTREE_2_PREFIX]';
	
					if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
						if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
							$groupby_2 = '[GROUPBY]';
						}
					}
					
					if (substr($groupby_2, 3, 3) == 'CLS') {
						$groupby_2_section = substr($groupby_2, 6);
						$cod_field = $prefixe . "_code[$groupby_2_section]";
						return $cod_field;
					}
						
					$suffixe = selectLinkcodeSuffixe($groupby_2);

					$cod_field = selectCodeTabtree($groupby_2, $prefixe, $suffixe);
						
					return $cod_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_2_TXT_FIELD">
				<value><![CDATA[
					[EVAL 	
					
					$txt_field = "''"; 

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' ) {
						return $txt_field;
					}
                    if('[GROUPBY_2]' == 'RSS' && '[LIRSS]' == '-1'){
						return $txt_field;
					}
					
					$groupby_2 = '[GROUPBY_2]';
					$prefixe = '[VIEW.SELECT_TABTREE_2_PREFIX]';


					if ('[GROUPBY]' == 'ACTE' || '[GROUPBY]' == 'EXECACTE') {
						if (substr('[GROUPBY_2]',0,6) == 'ACTCLS') {
							$groupby_2 = '[GROUPBY]';
						}
					}
	
					if (substr($groupby_2, 3, 3) == 'CLS') {
						$groupby_2_section = substr($groupby_2, 6);
						$txt_field = $prefixe . "_texte[$groupby_2_section]";
						return $txt_field;
					}
					
					$txt_field = selectTexteTabtree($groupby_2, $prefixe);

					return $txt_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_3_PREFIX">
				<value><![CDATA[
					[EVAL 	
					
					$prefixe = '';

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' || '[GROUPBY_3]' == '-1') {
						return $prefixe;
					}
					if('[GROUPBY_3]' =='RSS' && '[LIRSS]' =='-1'){
						return $prefixe;
					}

					$groupby_3 = '[GROUPBY_3]';

					if ('[GROUPBY_2]' == 'ACTE' || '[GROUPBY_2]' == 'EXECACTE') {
						if (substr('[GROUPBY_3]',0,6) == 'ACTCLS') {
							$groupby_3 = '[GROUPBY_2]';
						}
					}
					
					$cls6 = substr($groupby_3, 0 , 6);
                    
					$prefixe = selectPrefixTabtree($groupby_3, $cls6);
					
					return $prefixe;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_3_OID_FIELD">
				<value><![CDATA[
					[EVAL 	
					
					$oid_field = '0';

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' || '[GROUPBY_3]' == '-1') {
						return $oid_field;
					}
					if('[GROUPBY_3]' == 'RSS' && '[LIRSS]' == '-1'){
						return $oid_field;
					}

					$groupby_3 = '[GROUPBY_3]';
					$prefixe = '[VIEW.SELECT_TABTREE_3_PREFIX]';

					if ('[GROUPBY_2]' == 'ACTE' || '[GROUPBY_2]' == 'EXECACTE') {
						if (substr('[GROUPBY_3]',0,6) == 'ACTCLS') {
							$groupby_3 = '[GROUPBY_2]';
						}
					}
					
					if (substr($groupby_3, 3, 3) == 'CLS') {
						$groupby_3_section = substr($groupby_3, 6);
						$oid_field = $prefixe . "_id[$groupby_3_section]";
						return $oid_field;
					}
				
					$suffixe = selectSuffixeLinkid($groupby_3);

					$oid_field = selectOidTabtree($groupby_3, $prefixe, $suffixe);	
				
					return $oid_field;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_3_COD_FIELD">
				<value><![CDATA[
					[EVAL 	

					$cod_field = "''";

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' || '[GROUPBY_3]' == '-1') {
						return $cod_field;
					}
					if('[GROUPBY_3]' == 'RSS' && '[LIRSS]' == '-1'){
						return $cod_field;
					}
					
					$groupby_3 = '[GROUPBY_3]';
					$prefixe = '[VIEW.SELECT_TABTREE_3_PREFIX]';

					if ('[GROUPBY_2]' == 'ACTE' || '[GROUPBY_2]' == 'EXECACTE') {
						if (substr('[GROUPBY_3]',0,6) == 'ACTCLS') {
							$groupby_3 = '[GROUPBY_2]';
						}
					}

					if (substr($groupby_3, 3, 3) == 'CLS') {
						$groupby_3_section = substr($groupby_3, 6);
						$cod_field = $prefixe . "_code[$groupby_3_section]";
						return $cod_field;
					}
				
					$suffixe = selectLinkcodeSuffixe($groupby_3);

					$cod_field = selectCodeTabtree($groupby_3, $prefixe, $suffixe);
						
					return $cod_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_3_TXT_FIELD">
				<value><![CDATA[
					[EVAL 	
					
					$txt_field = "''"; 

					if ('[GROUPBY]' == '-1' || '[GROUPBY_2]' == '-1' || '[GROUPBY_3]' == '-1') {
						return $txt_field;
					}
					if('[GROUPBY_3]' == 'RSS' && '[LIRSS]' == '-1'){
						return $txt_field;
					}

					$groupby_3 = '[GROUPBY_3]';
					$prefixe = '[VIEW.SELECT_TABTREE_3_PREFIX]';

					if ('[GROUPBY_2]' == 'ACTE' || '[GROUPBY_2]' == 'EXECACTE') {
						if (substr('[GROUPBY_3]',0,6) == 'ACTCLS') {
							$groupby_3 = '[GROUPBY_2]';
						}
					}
					
					if (substr($groupby_3, 3, 3) == 'CLS') {
						$groupby_3_section = substr($groupby_3, 6);
						$txt_field = $prefixe . "_texte[$groupby_3_section]";
						return $txt_field;
					}

					$txt_field = selectTexteTabtree($groupby_3, $prefixe);

					return $txt_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			            
            
			<PROPERTY name="SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_BASE">
				<value><![CDATA[
					[EVAL 	
					
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 0, 2) == 'S_') {
						return '*all';
					}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == '-1') {
						return '*all';
					}

					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 0, 3) != 'GHM') {
						return '[VIEW.SELECT_TABTREE_OID_FIELD]';
					}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 0, 1) != 'R') {
						return 'v_rss_1.ghm5_id';
					}
					else {
						return 'v_rss_1.ghm_id';
					}

					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_PERCENT">
				<value><![CDATA[
					[EVAL 	
					if ('[ACTIVITE_SIGNIFICATIVE_MODE]' == 'P') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 0, 4) == 'GHMP') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 1, 1) == 'P') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}

					return 0;
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_NUMBER">
				<value><![CDATA[
					[EVAL 
					if ('[ACTIVITE_SIGNIFICATIVE_MODE]' == 'N') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 0, 4) == 'GHMN') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', 1, 1) == 'N') {return intval('[ACTIVITE_SIGNIFICATIVE_NUMBER]');}
					
					
					return 0;
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_DATA">
				<value><![CDATA[
					[EVAL 	
					$signif = '';
					
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMNB') {$signif = 'v_rss_1.nb_rsa';}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' == 'GHMCA') {$signif = 'v_rss_1.base_remboursement';}
					
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -3, 3) == 'RSA') {$signif = 'v_rss_1.nb_rsa';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -2, 2) == 'CA') {$signif = 'v_rss_1.base_remboursement';}
					
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -4, 4) == 'NLPP') {$signif = 'v_rss_lpp_1.nombre';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -5, 5) == 'CALPP') {$signif = 'v_rss_lpp_1.montant_facture';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -4, 4) == 'NUCD') {$signif = 'v_rss_ucd_1.nombre';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -5, 5) == 'CAUCD') {$signif = 'v_rss_ucd_1.montant_facture';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -7, 7) == 'NPRESTA') {$signif = 'v_rsf_detail_1.nombre';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -8, 8) == 'CAPRESTA') {$signif = 'v_rsf_detail_1.base_remboursement';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -4, 4) == 'NRUM') {$signif = 'v_rss_rum_2.nb_rum_rum';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -5, 5) == 'DURUM') {$signif = 'v_rss_rum_2.duree_sejour_rum';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -5, 5) == 'IGRUM') {$signif = 'v_rss_rum_2.igs2_rum';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -5, 5) == 'NDIAG') {$signif = 'v_rss_diagnostics_1.nb_diagnostics';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -6, 6) == 'NPDIAG') {$signif = 'v_rss_diagnostics_1.nb_diagnostics_p';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -5, 5) == 'NACTE') {$signif = 'v_rss_actes_1.nombre';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -7, 7) == 'ICRACTE') {$signif = 'v_rss_actes_1.icr';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -7, 7) == 'NINTERV') {$signif = 'v_rss_actes_4.nb_interventions';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -9, 9) == 'ICRINTERV') {$signif = 'v_rss_actes_4.icr';}
					return $signif;
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_SUBSELECT">
				<value><![CDATA[
					[EVAL 	
					
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -3, 3) == 'LPP') {return '[VIEW.LPP_SELECT]';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -3, 3) == 'UCD') {return '[VIEW.UCD_SELECT]';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -6, 6) == 'PRESTA') {return '[VIEW.PRESTATION_SELECT]';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -3, 3) == 'RUM') {return '[VIEW.FILTRE_RUM_SELECT]';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -4, 4) == 'DIAG') {return '[VIEW.FILTRE_DIAG_SELECT]';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -4, 4) == 'ACTE') {return '[VIEW.FILTRE_ACTE_SELECT]';}
					if (substr('[ACTIVITE_SIGNIFICATIVE_BASE]', -6, 6) == 'INTERV') {return '[VIEW.FILTRE_INTERV_SELECT]';}
					
				
				return '';
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY dataLink="SELECT_TABTREE_RSS_SOUSSELECT_VIEWPROPERTIES" nameField="name" valueField="value" />
			
			<PROPERTY name="SELECT_TABTREE_COLUMNS">
				<value><![CDATA[
					[EVAL 	
					
					$groupby = '[GROUPBY]';
					$groupby_2 = '[GROUPBY_2]';
					if ($groupby == '-1') {
						$groupby = '[GROUPBY_2]'; 
						$groupby_2 = '-1'; 
					}
					
					$return = '';
					
					if ($groupby_2 != '-1' && '[GROUPBY_TAB]' == 'TAB') {
						$return = $return . "
						CASE WHEN subview_mode.mode IN ('1T', '2T') THEN [VIEW.SELECT_TABTREE_OID_FIELD] ELSE -9999999 END as A,
						CASE WHEN subview_mode.mode IN ('1T', '2T') THEN SUBSTR([VIEW.SELECT_TABTREE_COD_FIELD] || ' ' || [VIEW.SELECT_TABTREE_TXT_FIELD], 1, 15) ELSE ' Synthese' END as B,
						CASE WHEN subview_mode.mode IN ('1T', '2T') THEN [VIEW.SELECT_TABTREE_COD_FIELD] || ' ' || [VIEW.SELECT_TABTREE_TXT_FIELD] ELSE 'Synthese' END as C, ";
					}
					else {
						$return = $return . "-9999999 as A, '' as B, '' as C, ";
					}
					
					$return = $return . "
					CASE WHEN subview_mode.mode IN ('1A', '1T', '2T') THEN [VIEW.SELECT_TABTREE_OID_FIELD]::bigint 
						WHEN subview_mode.mode IN ('2A') THEN [VIEW.SELECT_TABTREE_OID_FIELD]::bigint 
						WHEN subview_mode.mode IN ('7') THEN -9999997
						WHEN subview_mode.mode IN ('8') THEN -9999998
						WHEN subview_mode.mode IN ('9') THEN -9999999
							ELSE -9999999 END AS oid1, 
					CASE WHEN subview_mode.mode IN ('1A','1T') THEN [VIEW.SELECT_TABTREE_COD_FIELD]::text 
						WHEN subview_mode.mode IN ('2A','2T') THEN [VIEW.SELECT_TABTREE_COD_FIELD]::text 
						ELSE chr(1) END as cod1, ";
						
					if ($groupby_2 != '-1') {
						$return = $return . "
						CASE WHEN subview_mode.mode IN ('1A', '1T') THEN 0::bigint 
							WHEN subview_mode.mode IN ('2A', '2T') THEN [VIEW.SELECT_TABTREE_2_OID_FIELD]::bigint 
							WHEN subview_mode.mode IN ('7') THEN 0
							WHEN subview_mode.mode IN ('8') THEN 0
							WHEN subview_mode.mode IN ('9') THEN 0
								ELSE -9999999 END AS oid2, 
						CASE WHEN subview_mode.mode IN ('1A', '1T') THEN chr(1)
							WHEN subview_mode.mode IN ('2A', '2T') THEN [VIEW.SELECT_TABTREE_2_COD_FIELD]::text 
							ELSE chr(1) END as cod2, 
						";
					}
					else {
						$return = $return . "0 AS oid2, '' as cod2, ";
					}
					
					$return = $return ."
					CASE WHEN subview_mode.mode IN ('1A') THEN [VIEW.SELECT_TABTREE_OID_FIELD]::bigint 
						WHEN subview_mode.mode IN ('2A', '2T') THEN [VIEW.SELECT_TABTREE_2_OID_FIELD]::bigint 
						WHEN subview_mode.mode IN ('7') THEN -9999997
						WHEN subview_mode.mode IN ('8') THEN -9999998
						WHEN subview_mode.mode IN ('9') THEN -9999999
							ELSE -9999999 END AS oid, 
					CASE WHEN subview_mode.mode IN ('1A') THEN [VIEW.SELECT_TABTREE_COD_FIELD]::text 
						WHEN subview_mode.mode IN ('2A', '2T') THEN [VIEW.SELECT_TABTREE_2_COD_FIELD]::text 
						ELSE chr(1) END as cod,  
					CASE WHEN subview_mode.mode IN ('1A') THEN [VIEW.SELECT_TABTREE_TXT_FIELD]::text 
						WHEN subview_mode.mode IN ('2A', '2T') THEN [VIEW.SELECT_TABTREE_2_TXT_FIELD]::text 
						WHEN subview_mode.mode IN ('7') THEN 'Données significatives ([VIEW.RSS_SOUSSELECT_SELECT_PERCENT])'::text 
						WHEN subview_mode.mode IN ('8') THEN 'Autres ([VIEW.RSS_SOUSSELECT_OTHER_PERCENT])'::text 
						ELSE '' END as txt, 
					CASE WHEN subview_mode.mode IN ('1A', '1T', '2T') THEN 1 WHEN subview_mode.mode = '2A' THEN 2 ELSE 9 END  AS level
					
					";
					
					return $return;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_VIEW">
				<value><![CDATA[
					[EVAL 
					
					$groupby = '[GROUPBY]';
					$groupby_2 = '[GROUPBY_2]';
					if ($groupby == '-1') {
						$groupby = '[GROUPBY_2]'; 
						$groupby_2 = '-1'; 
					}
					
					$return = "(SELECT '1A' AS mode ";
					if ($groupby_2 != '-1' && '[GROUPBY_TAB]' == 'TAB') {$return = $return . " UNION SELECT '1T' AS mode ";} 
					if ($groupby_2 != '-1' && '[GROUPBY_TAB]' != 'TAB') {$return = $return . " UNION SELECT '2A' AS mode ";} 
					if ($groupby_2 != '-1' && '[GROUPBY_TAB]' == 'TAB') {$return = $return . " UNION SELECT '2T' AS mode ";} 
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' != '-1' && '[VIEW.RSS_SOUSSELECT_OID_IN]' != '') {$return = $return . " UNION SELECT '7' AS mode UNION SELECT '8' AS mode ";}
					$return = $return . " UNION SELECT '9' AS mode ";
					$return = $return . ") subview_mode ";
					
					return $return;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_TABTREE_WHERE">
				<value><![CDATA[
					[EVAL 	
					
					$return = ''; 
					
					if ('[GROUPBY]' == 'SEUIL_CANCERO' || '[GROUPBY]' == 'SEUIL_CANCERO_ROOT' || '[GROUPBY_2]' == 'SEUIL_CANCERO' || '[GROUPBY_2]' == 'SEUIL_CANCERO_ROOT') {
						if ('[CDC]' == '2008') {
							$return .= " AND (v_rss_cancero_1.cdc = '2008' OR v_rss_cancero_1.cdc IS NULL) ";
						}
						else {
							$return .= " AND (v_rss_cancero_1.cdc = '2011' OR v_rss_cancero_1.cdc IS NULL) ";
						}
					}
					
					$return .= " AND (subview_mode.mode IN ('1A', '2A', '1T', '2T') ";
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' != '-1') {
						$return = $return . "AND [VIEW.RSS_SOUSSELECT_OID_WHENIN] ";
					}
					if ('[ACTIVITE_SIGNIFICATIVE_BASE]' != '-1' && '[VIEW.RSS_SOUSSELECT_OID_IN]' != '') {$return = $return . "OR subview_mode.mode = '7' AND [VIEW.RSS_SOUSSELECT_OID_WHENIN]	OR	subview_mode.mode = '8' AND NOT [VIEW.RSS_SOUSSELECT_OID_WHENIN] ";}
					$return = $return . " OR subview_mode.mode = '9')";
					
					return $return;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_COLUMNBY_PREFIX">
				<value><![CDATA[
					[EVAL 	
					
					$prefixe = '';
					$columnby = '[COLUMNBY]';
					
					$cls6 = substr($columnby, 0 , 6);
					
					$prefixe = selectPrefixTabtree($columnby, $cls6) ;
				
					return $prefixe;
					
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_COLUMNBY_OID_FIELD">
				<value><![CDATA[
					[EVAL 	
						
						$oid_field = '0';
						$columnby = '[COLUMNBY]';

						if ($columnby  === -1){
							return $oid_field;
						}

						$prefixe = '[VIEW.SELECT_COLUMNBY_PREFIX]';
						$suffixe = '_id';
						
						if (substr($columnby, 3, 3) == 'CLS') {
							$columnby_section = substr($columnby, 6);
							$oid_field = $prefixe . "_id[$columnby_section]";
							return $oid_field;
						}

						$suffixe = selectSuffixeLinkid($columnby);
						
						$oid_field = selectOidTabtree($columnby, $prefixe, $suffixe) ;
						
						return $oid_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_COLUMNBY_COD_FIELD">
				<value><![CDATA[
					[EVAL 	
						
						$cod_field = '';
						$prefixe = '[VIEW.SELECT_COLUMNBY_PREFIX]';
						$columnby = '[COLUMNBY]';

						if ($columnby == '-1') {
							return $cod_field;
						}
						
						if (substr($columnby, 3, 3) == 'CLS') {
							$columnby_section = substr($columnby, 6);
							$cod_field = $prefixe . "_code[$columnby_section]";
							return $cod_field; 
						}


						$suffixe = selectLinkcodeSuffixe($columnby);

						$cod_field = selectCodeTabtree($columnby, $prefixe, $suffixe);
						
						return $cod_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
			<PROPERTY name="SELECT_COLUMNBY_TXT_FIELD">
				<value><![CDATA[
					[EVAL 	
						
						$txt_field = '';
						$prefixe = '[VIEW.SELECT_COLUMNBY_PREFIX]';
						$columnby = '[COLUMNBY]';


						if ($columnby == '-1') {
							return $cod_field;
						}
						
						if (substr($columnby, 3, 3) == 'CLS') {
							$columnby_section = substr($columnby, 6);
							$txt_field = $prefixe . "_texte[$columnby_section]";
							return $txt_field;
						}

						$txt_field = selectTexteTabtree($columnby, $prefixe);
						
						return $txt_field;
						
					EVAL]
				]]></value>
			</PROPERTY>
			
		</VIEWPROPERTIES>
		
		<QUERIES>
			<QUERY type="propertiesLink" name="SELECT_TABTREE_RSS_SOUSSELECT_VIEWPROPERTIES" forRows="false" forSelections="false"> 
				
				<SQL 
					optimizer="V_RSS_X"
					cacheEnabled="true"
					select="
							SELECT name, value 
								FROM pmsi.get_oids_from_classement(
									'#V_RSS_X#', 
									'[VIEW.SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_BASE]', 
									'[VIEW.SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_DATA]' , 
									[VIEW.SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_PERCENT], 
									[VIEW.SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_NUMBER], 
									'mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND [DOUBLEQUOTES(date_sortie &gt;= '[PERIODE]' AND date_sortie &lt;='[TOPERIODE]')DOUBLEQUOTES]',
									'[DOUBLEQUOTES([VIEW.FILTRE_RSS_SELECT] )DOUBLEQUOTES]',
									'[DOUBLEQUOTES([VIEW.SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_SUBSELECT] )DOUBLEQUOTES]'
									) AS (name text, value text)
							" >
					
					<FIELDS>
						<FIELD name="name" />
						<FIELD name="value" />
					</FIELDS>
				</SQL>
				
			</QUERY>
		</QUERIES>
			
	</COMPONENT>
	
	
	
	<COMPONENT name="STANDARD_FUNCTIONS" label="Fonctions standards" >

			<value><![CDATA[ 
			
				function PMSI_get_section_id($param, $start = 2, $length = 2, $field = 'section_id') {
					return $field . '[' . intval(substr($param, $start, $length)) . ']';
				}
				
				function PMSI_get_classe_oid($param, $start = 4) {
					return substr($param, $start);
				}
						
				function PMSI_RUM_data($DATA) {
				
					switch ($DATA) {
						case "NBRSS" :
							return "<AGG>count(DISTINCT v_rss_1.rss_id)</AGG>";
							break;
						case "NBRUM" :
							return "<AGG>SUM(nb_rum_rum)</AGG>";
							break;
						case "NBRUMA" :
							return "<AGG>SUM(nb_rum_avec_autorisation)</AGG>";
							break;
						case "NBJOU" :
							return "<AGG>SUM(duree_sejour_rum)</AGG>";
							break;
						case "DMS" :
							return "base.cti_division(
									<AGG>SUM(duree_sejour_rum)</AGG>
									,
									<AGG>SUM(CASE WHEN cmd_code <> '28' THEN nb_rum_rum ELSE 0 END)</AGG>
									)";
							break;
						case "NBSEA" :
							return "<AGG>SUM(nb_seances_rum)</AGG>";
							break;
						case "IGS2" :
							return "<AGG>SUM(igs2_rum)</AGG>";
							break;
						case "1ME0" :
							return "<AGG>SUM(nb_rum_mode_entree_0)</AGG>";
							break;
						case "1ME6" :
							return "<AGG>SUM(nb_rum_mode_entree_6)</AGG>";
							break;
						case "1ME7" :
							return "<AGG>SUM(nb_rum_mode_entree_7)</AGG>";
							break;
						case "1ME8" :
							return "<AGG>SUM(nb_rum_mode_entree_8)</AGG>";
							break;
						case "1MS0" :
							return "<AGG>SUM(nb_rum_mode_sortie_0)</AGG>";
							break;
						case "1MS6" :
							return "<AGG>SUM(nb_rum_mode_sortie_6)</AGG>";
							break;
						case "1MS7" :
							return "<AGG>SUM(nb_rum_mode_sortie_7)</AGG>";
							break;
						case "1MS8" :
							return "<AGG>SUM(nb_rum_mode_sortie_8)</AGG>";
							break;
						case "1MS9" :
							return "<AGG>SUM(nb_rum_mode_sortie_9)</AGG>";
							break;
						default :
							return "SUM(0)";
						}
				}
				
				
				function PMSI_PRESTATION_RUM_data($DATA) {
				
					if ($DATA == 'SEJVAL') {
						return "<AGG>count(DISTINCT CASE WHEN rum_valorise = '1' THEN v_rss_1.rss_id ELSE NULL END)</AGG>";
					}
					if ($DATA == 'NB') {
						return "<AGG>SUM(v_rsf_detail_1.nombre)</AGG>";
					}
					if ($DATA == 'RUMVAL') {
						return "<AGG>count(DISTINCT CASE WHEN rum_valorise = '1' THEN v_rsf_detail_1.rss_id::text || '-' || no_rum::text ELSE NULL END)</AGG>";
					}
					if ($DATA == 'DURVAL') {
						return "<AGG>base.cti_sum_distinct_on(DISTINCT ARRAY[v_rsf_detail_1.rss_id::text || '-' || no_rum::text, v_rsf_detail_1.duree_sejour_rum::text])</AGG>";
					}
					if ($DATA == 'BR') {
						return "<AGG>SUM(v_rsf_detail_1.base_remboursement_rum)</AGG>";
					}
					if ($DATA == 'BRMRUM') {
						return "base.cti_division(
									<AGG>SUM(v_rsf_detail_1.base_remboursement_rum)</AGG>,
									<AGG>count(DISTINCT CASE WHEN rum_valorise = '1' THEN v_rsf_detail_1.rss_id::text || '-' || no_rum::text ELSE NULL END)</AGG>
									)";
					}
					if ($DATA == 'BRMJOU') {
						return "base.cti_division(
									<AGG>SUM(v_rsf_detail_1.base_remboursement_rum)</AGG>,
									<AGG>base.cti_sum_distinct_on(DISTINCT CASE WHEN rum_valorise = '1' THEN ARRAY[v_rsf_detail_1.rss_id::text || '-' || no_rum::text, GREATEST(v_rsf_detail_1.duree_sejour_rum,1)::text] ELSE NULL END)</AGG>
									)";
					}
					if ($DATA == 'BRHT') {
						return "<AGG>SUM(v_rsf_detail_1.base_remboursement_rum_sauf_transition)</AGG>";
					}
					if ($DATA == 'SR') {
						return "<AGG>SUM(v_rsf_detail_1.sejour_remboursable_rum)</AGG>";
					}

					return "SUM(0)";
				}
				
						
				function PMSI_EXC_data($DATA) {
				
					switch ($DATA) {
						case "NBRSS" :
							return "<AGG>count(DISTINCT v_rss_1.rss_id)</AGG>";
							break;
						case "NBERR" :
							return "<AGG>count(v_rss_1.rss_id)</AGG>";
							break;
						case "DELCOR" :
							return "<AGG>AVG(delai_correction)</AGG>";
							break;
						default :
							return "SUM(0)";
						}
				}
                
				
                
                function PMSI_CA_data_param_data($LS_DATA, $LS_DATA_COL, $DATA, $DEFAULT="", $CASE="", $PERIODE_DUREE="",$COL) {
					
					$wdata = $DATA;
					if ($LS_DATA != "-1") {

								$wdata_array_1 = explode("=",$LS_DATA);
								$wdata_array_2 = $wdata_array_1[1];
								$wdata_array = explode(",",$wdata_array_2);
								$wdata = $wdata_array[$LS_DATA_COL-1];

					}
					if($wdata != ""){
						return PMSI_CA_data($wdata, $DEFAULT="", $CASE="", $PERIODE_DUREE="",$COL);
					}
				}

				function PMSI_CA_data($DATA, $DEFAULT="", $CASE="", $PERIODE_DUREE="",$COL) {

					$caseWhen = "";
					$caseElseZero = "";
					$caseElseNull = "";

					if ($CASE != "") {
						$caseWhen = "CASE WHEN $CASE THEN";
						$caseElseZero = "ELSE 0 END";
						$caseElseNull = "ELSE NULL END";
					}

					$colWhen= "";
					$colEsleZero = "";
					$colElseNull = "";

					if ($COL == '1') {
						$colWhen="CASE WHEN COLUMNCHECKSEQUENCE THEN";
						$colEsleZero = "ELSE 0 END";
						$colElseNull = "ELSE NULL END";
					}

					switch ($DATA) {
						case '1.1': // Nombre de séjours
							return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id  $colElseNull $caseElseNull)";
							break;
						case '1.2': // Nombre de séjours 0 nuit
							return "SUM($caseWhen $colWhen nb_rsa_0n $colEsleZero $caseElseZero)";
							break;
						case '1.22': // Taux de séjours 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen nb_rsa_0n $colEsleZero $caseElseZero),COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id  $colElseNull $caseElseNull))*100";
							break;                                
						case '1.3':	 // Nombre de séjours 1 nuit
							return "SUM($caseWhen $colWhen nb_rsa_1n $colEsleZero $caseElseZero)";
							break;                                
						case '1.4':	 // Nombre de séjours > 1 nuit
							return "SUM($caseWhen $colWhen nb_rsa_2n + nb_rsa_xn $colEsleZero $caseElseZero)";
							break;
						case '1.5':	 // Nombre de séjours 2 nuit
							return "SUM($caseWhen $colWhen nb_rsa_2n $colEsleZero $caseElseZero)";
							break;                                
						case '1.6':	 // Nombre de séjours > 2 nuits
							return "SUM($caseWhen $colWhen nb_rsa_xn $colEsleZero $caseElseZero)";
							break;                                
						case '1.7':	 // Nombre de séances
							return "SUM($caseWhen $colWhen nb_seances $colEsleZero $caseElseZero)";
							break;                                
						case '1.8':	 // Nombre de patients
							return "COUNT(DISTINCT $caseWhen $colWhen patient_id $colElseNull $caseElseNull)";
							break;
						case '1.9':	 // Nombre de journées hospitalisé
							return "SUM($caseWhen $colWhen duree_sejour $colEsleZero $caseElseZero)";
							break;                                
						case '1.11':	 // Nombre de journées d'hospitalisation
							return "SUM($caseWhen $colWhen duree_sejour + nb_rsa_0n + nb_seances $colEsleZero $caseElseZero)";
							break;                                 
						case '1.12':	 // Nombre EXH
							return "SUM($caseWhen $colWhen nb_exh $colEsleZero $caseElseZero)";
							break;                                
						case '1.13':	 // Nombre EXB
							return "SUM($caseWhen $colWhen nb_exb $colEsleZero $caseElseZero)";
							break;                                
						case '1.14':	// Nombre de séjours hospitalisé
							return "SUM($caseWhen $colWhen nb_rsa_1n + nb_rsa_2n + nb_rsa_xn $colEsleZero $caseElseZero)";
							break;                          
						case '1.15': // Age moyen des patients
							return "base.cti_division(SUM($caseWhen $colWhen v_rss_1.age $colEsleZero $caseElseZero),COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id $colElseNull $caseElseNull))";
							break;
						case '10.13':	// Age moy public qualifié
							return "base.cti_division(SUM($caseWhen $colWhen age_public $colEsleZero $caseElseZero),SUM($caseWhen $colWhen nb_rsa_public $colEsleZero $caseElseZero))";
							break;
						case '10.14':	// Age moy privé qualifié
							return "base.cti_division(SUM($caseWhen $colWhen ghm_nat.age_prive $colEsleZero $caseElseZero),SUM($caseWhen $colWhen ghm_nat.nb_rsa_prive $colEsleZero $caseElseZero))";
							break;
						case '1.16':	// Séjours dont séances
							return "SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero)";
							break;                                
						case '3.1': // DMS
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '3.15': // DMS hospi
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN cmd_code <> '28' AND duree_sejour >=1 THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN duree_sejour >=1 THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '2.1':	// CA T2A
							return "SUM($caseWhen $colWhen t2a_facture $colEsleZero $caseElseZero)";
							break;                                
						case '5.1':	// CA T2A 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '6.1':	// CA T2A 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '7.1':	// CA T2A hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '2.2':	// CA etablissement, clinique
							return "SUM($caseWhen $colWhen base_remboursement $colEsleZero $caseElseZero)";
							break;                                    
						case '5.2':	// CA etab, cli 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN base_remboursement ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '6.2':	// CA etab, cli 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN base_remboursement ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '7.2':	// CA etab, cli hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN base_remboursement ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.3': // CA moyen etablissement, clinique
							return "base.cti_division(SUM($caseWhen $colWhen base_remboursement $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;                                
						case '10.2':	// CA Clinique journalier
							return "base.cti_division(SUM($caseWhen $colWhen base_remboursement $colEsleZero $caseElseZero),SUM($caseWhen $colWhen duree_sejour + nb_rsa_0n + nb_seances $colEsleZero $caseElseZero))";
							break;                                
						case '5.3': // CA moyen etablissement, clinique 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN base_remboursement ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                
						case '6.3': // CA moyen etablissement, clinique 1 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN base_remboursement ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                
						case '7.3': // CA moyen etablissement, clinique hospitalisé
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN base_remboursement ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                
						case '2.4': // CA moyen T2A
							return "base.cti_division(SUM($caseWhen $colWhen t2a_facture $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '5.4': // CA moyen T2A 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                
						case '6.4': // CA moyen T2A 1 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                
						case '7.4': // CA moyen T2A hospitalisé
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                
						case '2.5': // CA T2A journalier
							return "base.cti_division(SUM($caseWhen $colWhen t2a_facture $colEsleZero $caseElseZero),SUM($caseWhen $colWhen duree_sejour + nb_rsa_0n + nb_seances $colEsleZero $caseElseZero))";
							break;
						case '5.5': // CA T2A journalier 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen nb_rsa_0n + nb_seances $colEsleZero $caseElseZero))";
							break;                                
						case '6.5': // CA T2A journalier 1 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen nb_rsa_1n + nb_seances $colEsleZero $caseElseZero))";
							break;                                
						case '7.5': // CA T2A journalier hospitalisé
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN t2a_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen duree_sejour + nb_seances $colEsleZero $caseElseZero))";
							break;
						case '2.6':	// CA GHS facturé
							return "SUM($caseWhen $colWhen ca_ghs $colEsleZero $caseElseZero)";
							break;
						case '5.6': // CA GHS facturé 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN ca_ghs ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '6.6': // CA GHS facturé 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN ca_ghs ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '7.6': // CA GHS facturé hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN ca_ghs ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '2.7': //  CA GHS Théorique
							return "SUM($caseWhen $colWhen ca_ghs_theorique $colEsleZero $caseElseZero)";
							break;
						case '5.7': // CA GHS Théorique 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN ca_ghs_theorique ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '6.7': // CA GHS Théorique 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN ca_ghs_theorique ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '7.7': // CA GHS Théorique hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN ca_ghs_theorique ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.8': // CA moyen GHS
							return "base.cti_division(SUM($caseWhen $colWhen ca_ghs $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '5.8': // CA moyen GHS 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN ca_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '6.8': // CA moyen GHS 1 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN ca_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '7.8':	// CA moyen GHS hospitalisé
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN ca_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '2.9': // CA DMI
							return "SUM($caseWhen $colWhen dmi_facture $colEsleZero $caseElseZero)";
							break;
						case '5.9':	// CA DMI 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN dmi_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '6.9':	// CA DMI 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN dmi_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '7.9':	// CA DMI hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN dmi_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.17':	// CA moyen DMI
							return "base.cti_division(SUM($caseWhen $colWhen dmi_facture $colEsleZero  $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '5.17':	// CA moyen DMI 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN dmi_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '6.17':	// CA moyen DMI 1 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN dmi_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '7.17':	// CA moyen DMI hospitalisé
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN dmi_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '2.11':	// CA PHC
							return "SUM($caseWhen $colWhen phc_facture $colEsleZero $caseElseZero)";
							break;
						case '5.11':	// CA PHC 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN phc_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '6.11':	// CA PHC 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN phc_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '7.11':	// CA PHC hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN phc_facture ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.12':	// CA moyen PHC
							return "base.cti_division(SUM($caseWhen $colWhen phc_facture $colEsleZero  $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '5.12':	// CA moyen PHC 0 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN phc_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '6.12':	// CA moyen PHC 1 nuit
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN phc_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '7.12':	// CA moyen PHC hospitalisé
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN phc_facture ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero))";
							break;                                    
						case '2.13':	// CA EXH
							return "SUM($caseWhen $colWhen ca_exh $colEsleZero $caseElseZero)";
							break;
						case '7.13':   // CA EXH hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN ca_exh ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.14':	// CA EXB
							return "SUM($caseWhen $colWhen ca_exb $colEsleZero $caseElseZero)";
							break;
						case '7.14':   // CA EXB hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN ca_exb ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.15':   // CA manque à gagner EXB
							return "SUM($caseWhen $colWhen 0 - ca_perte_exb $colEsleZero $caseElseZero)";
							break;
						case '7.15':   // CA manque à gagner EXB hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN ca_perte_exb ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '2.16':	// CA honoraires
							return "SUM($caseWhen $colWhen honoraires_factures $colEsleZero $caseElseZero)";
							break;
						case '5.16':	// CA honoraires 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN honoraires_factures ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '6.16':	// CA honoraires 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN honoraires_factures ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '7.16':	// CA honoraires hospitalisé
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN honoraires_factures ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '9.0':	// CA total
							return "SUM($caseWhen $colWhen base_remboursement + honoraires_factures $colEsleZero $caseElseZero)";
							break;
						case '10.0':	// CA total 0 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_seances > '0' OR nb_rsa_0n > '0' THEN base_remboursement + honoraires_factures ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '10.01':	// CA total 1 nuit
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' THEN base_remboursement + honoraires_factures ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '10.1':	// CA total hospitalisés
							return "SUM($caseWhen $colWhen CASE WHEN nb_rsa_1n > '0' OR nb_rsa_xn > '0' OR nb_rsa_2n > '0' THEN base_remboursement + honoraires_factures ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '9.9':	// CA total moyen
							return "base.cti_division(SUM($caseWhen $colWhen base_remboursement + honoraires_factures $colEsleZero  $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '9.1': // CA Forfaits
							return "SUM($caseWhen $colWhen forfait_facture $colEsleZero $caseElseZero)";
							break;
						case '9.3':	// Nombre de séjours 0 nuit avec seances
							return "SUM($caseWhen $colWhen CASE WHEN duree_sejour = '0' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '9.4':	// CA Autre
							return "SUM($caseWhen $colWhen base_remboursement - (t2a_facture + dmi_facture + phc_facture) $colEsleZero $caseElseZero)";
							break;                                
						case '9.6':	// CA Autre T2A
							return "SUM($caseWhen $colWhen t2a_facture - (ca_ghs + ca_exh + forfait_facture) $colEsleZero $caseElseZero)";
							break;
						case '9.5':	// Nombre de GHM
							return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.ghm_id $colElseNull $caseElseNull)";
							break;
						case '9.7': // Rehosp même GHM
							return "SUM($caseWhen $colWhen CASE WHEN rehosp_meme_ghm = '1' THEN ca_perte_exb ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '9.8': // Minoration forfaitaire
							return "SUM($caseWhen $colWhen CASE WHEN rehosp_meme_ghm = '0' AND nb_ghsmin = '1' AND ca_perte_exb > '0' THEN ca_perte_exb ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '10':	// Nombre CHIR AMBU
							return "SUM($caseWhen $colWhen CASE WHEN duree_sejour = '0' AND cas_code = 'C' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '10.12':	// Nombre décès 
							return "SUM($caseWhen $colWhen CASE WHEN mode_sortie = '9' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                    
						case '10.11':	// DMS GHS nationale
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN  cmd_code <> '28' THEN dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;                                 
						case '3.2':	// Ecart DMS
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN  cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero)) - base.cti_division(SUM($caseWhen $colWhen CASE WHEN  cmd_code <> '28' THEN dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero)) ";
							break;
						case '3.3':		// Performance ATIH
							return "base.cti_division(SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero) * base.cti_division(SUM($caseWhen $colWhen CASE WHEN  cmd_code <> '28' THEN dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero)),SUM($caseWhen $colWhen duree_sejour $colEsleZero $caseElseZero)) ";
							break;                                 
						case '3.4':		// Performance ANAP
							return "base.cti_division(SUM($caseWhen $colWhen duree_sejour $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero) * base.cti_division(SUM($caseWhen $colWhen CASE WHEN  cmd_code <> '28' THEN dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))) ";
							break;
						case '3.5':		// Jours bénéficiaires 
							return "SUM($caseWhen $colWhen CASE WHEN ecart_[VIEW.DMS_FIELD] < 0 THEN 0 - ecart_[VIEW.DMS_FIELD] ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '3.6':		// Jours indus 
							return "SUM($caseWhen $colWhen CASE WHEN ecart_[VIEW.DMS_FIELD] > 0 THEN ecart_[VIEW.DMS_FIELD] ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '3.7':		// Ratio Indus / Bénéficiaires
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN ecart_[VIEW.DMS_FIELD] > 0 THEN ecart_[VIEW.DMS_FIELD] ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN ecart_[VIEW.DMS_FIELD] < 0 THEN 0 - ecart_[VIEW.DMS_FIELD] ELSE 0 END $colEsleZero $caseElseZero)) ";
							break;
						case '3.8':	// Séjours < DMS Ref
							return "SUM($caseWhen $colWhen CASE WHEN  ecart_[VIEW.DMS_FIELD] < 0 THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '3.9':		// Séjours = DMS Ref
							return "SUM($caseWhen $colWhen CASE WHEN  ecart_[VIEW.DMS_FIELD] = 0 THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '3.11':		// Séjours = DMS Ref + 1
							return "SUM($caseWhen $colWhen CASE WHEN  ecart_[VIEW.DMS_FIELD] = 1 THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '3.12':		// Séjours = DMS Ref + 2
							return "SUM($caseWhen $colWhen CASE WHEN  ecart_[VIEW.DMS_FIELD] = 2 THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '3.13':		// Séjours = DMS Ref + 3
							return "SUM($caseWhen $colWhen CASE WHEN  ecart_[VIEW.DMS_FIELD] = 3 THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '3.14':		// Séjours > DMS Ref + 3
							return "SUM($caseWhen $colWhen CASE WHEN  ecart_[VIEW.DMS_FIELD] > 3 THEN  v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '10.30':		// Séjours dans département
							return "count(DISTINCT $caseWhen $colWhen  case when substring(v_rss_1.finess from 1 for 2) = substring(v_rss_1.code_postal from 1 for 2) then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;                                
						case '10.31':		// Séjours hors département
							return "count(DISTINCT $caseWhen $colWhen  case when substring(v_rss_1.finess from 1 for 2) != substring(v_rss_1.code_postal from 1 for 2) then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;                                
						case '10.32':		// Séjours dans région
							return "COUNT (DISTINCT $caseWhen $colWhen  CASE WHEN (SELECT region_id FROM pmsi.v_codes_postaux_2 where substring(v_rss_1.finess from 1 for 2) = substring(v_codes_postaux_2.code_postal_code from 1 for 2) limit 1) = v_codes_postaux_2.region_id  THEN v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;	                                
						case '10.33':		// Séjours hors région
							return "COUNT (DISTINCT $caseWhen $colWhen CASE WHEN (SELECT region_id FROM pmsi.v_codes_postaux_2 where substring(v_rss_1.finess from 1 for 2) = substring(v_codes_postaux_2.code_postal_code from 1 for 2) limit 1) != v_codes_postaux_2.region_id  THEN v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;                                
						case '10.34':		// Séjours patient hommes
							return "SUM($caseWhen $colWhen  CASE WHEN v_rss_1.sexe = '1' THEN CASE WHEN cmd_code = '28' THEN 1 ELSE v_rss_1.nb_rsa END ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '10.35':		// Séjours patient femmes
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.sexe = '2' THEN CASE WHEN cmd_code = '28' THEN 1 ELSE v_rss_1.nb_rsa END ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '10.36':		// Age médian séjour
							return "base.cti_array_median(array_agg(age))";
							break;
						case '11.1': // Nombre de rsa transmis
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '11.2': // RSA en CMD 90 : nombre de RSA groupés dans la CM 90 (groupage en erreur) 
							return "SUM($caseWhen $colWhen CASE WHEN substr(ghm_code,1,2) = '90' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '11.3': // : nombre de RSA correspondant aux séjours 9999
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.ghs_code ilike '9999%' AND en_cours = '0' AND cas_code not in ('*','?')  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                 
						case '11.4': // dont RSA en J ou T0
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND duree_sejour = '0' AND ( SUBSTRING(ghm_code,6,1) = 'J'  OR ghm_code in ('01M05T','01M07T','01M08T','01M09T','01M10T','01M17T','01M21T','01M22T','01M28T','02M04T','02M05T','02M07T','02M08T','03M02T','03M07T','03M10T','03M11T','04M08T','04M13T','04M14T','04M17T','04M19T','04M20T','04M23T','04M26T','05M06T','05M10T','05M16T','05M23T','06M07T','06M17T','07M04T','07M08T','07M09T','07M14T','08M09T','08M10T','08M14T','08M15T','08M33T','08M34T','08M36T','09M02T','09M03T','09M06T','09M07T','09M10T','09M11T','09M14T','10M09T','10M11T','10M14T','11M03T','11M04T','11M08T','11M10T','11M15T','11M16T','11M19T','12M05T','12M07T','14M03T','16M09T','16M13T','16M15T','17M08T','17M09T','17M15T','17M16T','17M17T','18M10T','19M12T','19M19T','21M04T','21M15T','23M02T','23M10T','23M11T','23M21T','23Z02T'))  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '11.5': // Nb de RSA en UHCD réaffecté
							return "SUM($caseWhen $colWhen CASE WHEN mode_entree ='8' AND mode_sortie='8'  AND duree_sejour > '0' AND en_cours = '0' AND cas_code not in ('*','?') AND top_uhcd='1'  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '11.6': // Nombre de séjours/seances total
							return "SUM($caseWhen $colWhen CASE WHEN type_sejour_ovalide in ('1','2','3')  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '11.7': // Type de séjour =  Mode Entrée=7 et Mode sortie=7
							return "SUM($caseWhen $colWhen CASE WHEN mode_entree = '7' AND mode_sortie = '7' AND type_sejour_ovalide in ('1','2','3') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '11.8': // Type de séjour = Mode Entrée=6 et Mode sortie=6
							return "SUM($caseWhen $colWhen CASE WHEN mode_entree = '6' AND mode_sortie = '6' AND type_sejour_ovalide in ('1','2','3') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                 
						case '11.9': // Type de séjour =  multirum
							return "SUM($caseWhen $colWhen CASE WHEN nb_rum > 1 AND type_sejour_ovalide in ('1','2','3') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '12.1': // Nombre de séjours/seances de type de séjour = GHM niveau J ou T ou duree séjour < 2 (type_sejour_ovalide = '1')
							return "SUM($caseWhen $colWhen CASE WHEN  type_sejour_ovalide = '1' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '12.2': // Nombre de séjours/seances de type de séjour = CM 28 (type_sejour_ovalide = '2')
							return "SUM($caseWhen $colWhen CASE WHEN  type_sejour_ovalide = '2' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '12.3': //  Nombre de séjours/seances type de séjour (type_sejour_ovalide = '3') = autres GHM (hors niveau J ou T ou durée de séjour < 2 et CM 28).
							return "SUM($caseWhen $colWhen CASE WHEN  type_sejour_ovalide = '3' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;  
						case '13.1': // Nombre de séjours en chirurgie
							return "SUM($caseWhen $colWhen CASE WHEN substring(ghm_code,3,1) = 'C' AND en_cours = '0' AND cas_code not in ('*','?')  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '13.2': // Nombre de séjours en chirurgie avec acte opératoire le jour d'entrée
							return "SUM($caseWhen $colWhen CASE WHEN cas_code ='C' AND en_cours = '0' AND cas_code not in ('*','?') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '13.3': // Nombre de séjours avec sortie transfert ou mutation
							return "SUM($caseWhen $colWhen CASE WHEN mode_sortie = '6' OR mode_sortie in ('0','7') AND en_cours = '0' AND cas_code not in ('*','?')  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '13.4': // Nombre de séjours avec sortie domicile
							return "SUM($caseWhen $colWhen CASE WHEN mode_sortie = '8' AND en_cours = '0' AND cas_code not in ('*','?')  THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '13.5':	 // Nombre de journées d'hospitalisation
							return "SUM($caseWhen $colWhen duree_sejour + nb_seances $colEsleZero  $caseElseZero)";
							break; 
						case '13.6':	 // Nombre de séjours autres GHM
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND cmd_code <> '28' AND  ( SUBSTRING(ghm_code,6,1) <> 'J')  AND ( ghm_code NOT IN ('01M05T','01M07T','01M08T','01M09T','01M10T','01M17T','01M21T','01M22T','01M28T','02M04T','02M05T','02M07T','02M08T','03M02T','03M07T','03M10T','03M11T','04M08T','04M13T','04M14T','04M17T','04M19T','04M20T','04M23T','04M26T','05M06T','05M10T','05M16T','05M23T','06M07T','06M17T','07M04T','07M08T','07M09T','07M14T','08M09T','08M10T','08M14T','08M15T','08M33T','08M34T','08M36T','09M02T','09M03T','09M06T','09M07T','09M10T','09M11T','09M14T','10M09T','10M11T','10M14T','11M03T','11M04T','11M08T','11M10T','11M15T','11M16T','11M19T','12M05T','12M07T','14M03T','16M09T','16M13T','16M15T','17M08T','17M09T','17M15T','17M16T','17M17T','18M10T','19M12T','19M19T','21M04T','21M15T','23M02T','23M10T','23M11T','23M21T','23Z02T')) THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '13.7': // Nombre de RSA de la CM 28
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND cmd_code = '28' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '13.8': // Nombre moyen de séances par RSA établissement
							return "base.cti_division(SUM($caseWhen $colWhen nb_seances $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;
						case '13.9' : // Nombre de RSA hors séances
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND cmd_code <> '28' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '14.0' : // Nb décés / rsa
							return "SUM($caseWhen $colWhen CASE WHEN mode_sortie = '9' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero";
							break;
						case '14.1' : // Ratio décès /rsa base nationale
							return "base.cti_division(SUM($caseWhen $colWhen ghm_nat.nb_deces_prive $colEsleZero $caseElseZero),SUM($caseWhen $colWhen ghm_nat.nb_rsa_prive $colEsleZero $caseElseZero))*100";
							break;
						case '14.2' : // Nombre séjours / séances niveau J ou T
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = 'J'  OR SUBSTRING (ghm_code,6,1) = 'T') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.3' : // Nombre séjours / séances niveau 1 ou A
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = '1'  OR SUBSTRING (ghm_code,6,1) = 'A') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.4' : // Nombre séjours / séances niveau 2 ou B
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = '2'  OR SUBSTRING (ghm_code,6,1) = 'B') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.5' : // Nombre séjours / séances niveau 3 ou C
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = '3'  OR SUBSTRING (ghm_code,6,1) = 'C') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.6' : // Nombre séjours / séances niveau 4 ou D
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = '4'  OR SUBSTRING (ghm_code,6,1) = 'D') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.7' : // Nombre séjours / séances niveau E
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = 'E') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.8' : // Nombre séjours / séances niveau Z
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  AND ( SUBSTRING(ghm_code,6,1) = 'Z') THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '14.9' : // séjours / séances niveau J ou T base nationale
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND (nb_sev_j_prive > 0 OR nb_sev_t_prive > 0) THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)"; 
							break;
						case '15.1': // Nombre de journées hors CMD28 et niveau J ou T0
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND (SUBSTRING(ghm_code,6,1) <> 'J'  OR ghm_code not in ('01M05T','01M07T','01M08T','01M09T','01M10T','01M17T','01M21T','01M22T','01M28T','02M04T','02M05T','02M07T','02M08T','03M02T','03M07T','03M10T','03M11T','04M08T','04M13T','04M14T','04M17T','04M19T','04M20T','04M23T','04M26T','05M06T','05M10T','05M16T','05M23T','06M07T','06M17T','07M04T','07M08T','07M09T','07M14T','08M09T','08M10T','08M14T','08M15T','08M33T','08M34T','08M36T','09M02T','09M03T','09M06T','09M07T','09M10T','09M11T','09M14T','10M09T','10M11T','10M14T','11M03T','11M04T','11M08T','11M10T','11M15T','11M16T','11M19T','12M05T','12M07T','14M03T','16M09T','16M13T','16M15T','17M08T','17M09T','17M15T','17M16T','17M17T','18M10T','19M12T','19M19T','21M04T','21M15T','23M02T','23M10T','23M11T','23M21T','23Z02T')) AND cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '15.2': // Nombre de journées hors CMD28 et niveau J ou T0 standardisé
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND (SUBSTRING(ghm_code,6,1) <> 'J'  OR ghm_code not in ('01M05T','01M07T','01M08T','01M09T','01M10T','01M17T','01M21T','01M22T','01M28T','02M04T','02M05T','02M07T','02M08T','03M02T','03M07T','03M10T','03M11T','04M08T','04M13T','04M14T','04M17T','04M19T','04M20T','04M23T','04M26T','05M06T','05M10T','05M16T','05M23T','06M07T','06M17T','07M04T','07M08T','07M09T','07M14T','08M09T','08M10T','08M14T','08M15T','08M33T','08M34T','08M36T','09M02T','09M03T','09M06T','09M07T','09M10T','09M11T','09M14T','10M09T','10M11T','10M14T','11M03T','11M04T','11M08T','11M10T','11M15T','11M16T','11M19T','12M05T','12M07T','14M03T','16M09T','16M13T','16M15T','17M08T','17M09T','17M15T','17M16T','17M17T','18M10T','19M12T','19M19T','21M04T','21M15T','23M02T','23M10T','23M11T','23M21T','23Z02T')) AND cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '15.3': // Performance globale
							return "base.cti_division (SUM(),SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND (SUBSTRING(ghm_code,6,1) <> 'J'  OR ghm_code not in ('01M05T','01M07T','01M08T','01M09T','01M10T','01M17T','01M21T','01M22T','01M28T','02M04T','02M05T','02M07T','02M08T','03M02T','03M07T','03M10T','03M11T','04M08T','04M13T','04M14T','04M17T','04M19T','04M20T','04M23T','04M26T','05M06T','05M10T','05M16T','05M23T','06M07T','06M17T','07M04T','07M08T','07M09T','07M14T','08M09T','08M10T','08M14T','08M15T','08M33T','08M34T','08M36T','09M02T','09M03T','09M06T','09M07T','09M10T','09M11T','09M14T','10M09T','10M11T','10M14T','11M03T','11M04T','11M08T','11M10T','11M15T','11M16T','11M19T','12M05T','12M07T','14M03T','16M09T','16M13T','16M15T','17M08T','17M09T','17M15T','17M16T','17M17T','18M10T','19M12T','19M19T','21M04T','21M15T','23M02T','23M10T','23M11T','23M21T','23Z02T')) AND cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero))";
							break;
						case '15.4': // Nombre de séjours standardisé
							return "SUM($caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') AND (SUBSTRING(ghm_code,6,1) <> 'J'  OR ghm_code not in ('01M05T','01M07T','01M08T','01M09T','01M10T','01M17T','01M21T','01M22T','01M28T','02M04T','02M05T','02M07T','02M08T','03M02T','03M07T','03M10T','03M11T','04M08T','04M13T','04M14T','04M17T','04M19T','04M20T','04M23T','04M26T','05M06T','05M10T','05M16T','05M23T','06M07T','06M17T','07M04T','07M08T','07M09T','07M14T','08M09T','08M10T','08M14T','08M15T','08M33T','08M34T','08M36T','09M02T','09M03T','09M06T','09M07T','09M10T','09M11T','09M14T','10M09T','10M11T','10M14T','11M03T','11M04T','11M08T','11M10T','11M15T','11M16T','11M19T','12M05T','12M07T','14M03T','16M09T','16M13T','16M15T','17M08T','17M09T','17M15T','17M16T','17M17T','18M10T','19M12T','19M19T','21M04T','21M15T','23M02T','23M10T','23M11T','23M21T','23Z02T')) AND cmd_code <> '28' THEN v_rss_1.nb_rsa*dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '15.5': // Diffénce DMS BNat - DMS ETAB
							return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN cmd_code <> '28' THEN dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen CASE WHEN cmd_code <> '28' THEN v_rss_1.nb_rsa ELSE 0 END $colEsleZero $caseElseZero)) - base.cti_division(SUM($caseWhen $colWhen CASE WHEN cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen v_rss_1.nb_rsa $colEsleZero $caseElseZero))";
							break;                                
						case '15.6': // Nombre de diagnostics
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?')  THEN diagnostic_principal_id + diagnostic_relie_id ELSE NULL END $colElseNull $caseElseNull)";
							break;
						case '16.1': // Nombre de séjours
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rss_1.rss_id::text,$caseWhen $colWhen (nb_rsa)::text $colElseNull $caseElseNull])";
							break;								
						case '16.2': // Nombre de Patients
							return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.patient_id $colElseNull $caseElseNull)";
							break;                                 
						case '16.3':	 // Nombre prestations Quantité de prestations : Nombre x Coefficient
							return "SUM($caseWhen $colWhen nombre_coefficient $colEsleZero $caseElseZero)";
							break;                                
						case '16.4':	 // Montant facturé (BR)
							return "SUM($caseWhen $colWhen v_rsf_detail_1.base_remboursement $colEsleZero $caseElseZero)";
							break;                                
						case '16.5':	 // Montant facturé (BR) Hors coefficient
							return "SUM($caseWhen $colWhen v_rsf_detail_1.base_remboursement_sauf_transition $colEsleZero $caseElseZero)";
							break;                                
						case '16.6':	 // Montant remboursé
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi IN ('30') then v_rsf_detail_1.sejour_remboursable ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '16.7': // Nombre de séjours non valorisé
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi IN ('21','22','23','24','25','26') then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;
						case '16.8':	 // Montant non valorisés
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi IN ('21','22','23','24','25','26') then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '16.9':	 // Nombre de séjours non traités prestation inter-établissement
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi = '12' then v_rss_1.rss_id  ELSE NULL END $colElseNull $caseElseNull)";
							break;                               
						case '17.1':	 // Montant non traités prestation inter-établissement
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi = '12' then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '17.2':	 // Nombre de séjours non valorisés pb chainage
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi = '21' then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;                               
						case '17.3':	 // Montant non valorisés pb chainage
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi = '21' then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                 
						case '17.4':	 // Nombre de séjours non valorisés pb variable bloquante
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi = '22' then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;                               
						case '17.5':	 // Montant non valorisés pb variable bloquante
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi = '22' then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '17.6':	 // Nombre de séjours non valorisés non facturable AM
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('24','31','33') THEN nb_rsa ELSE NULL END $colElseNull $caseElseNull)::text])";									
							break;                                
						case '17.7':	 // Montant non valorisés non facturable AM
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('24','31','33') then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                                                 
						case '17.8':	 // Montant lié à la suppression des SI/SC en cas de limitation
							return "SUM( $caseWhen $colWhen CASE WHEN prestation_code = 'LIM_SRC' AND v_rsf_detail_1.base_remboursement_sauf_transition < 0 then (v_rsf_detail_1.base_remboursement_sauf_transition)*(-1) ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '17.9':	 // Nombre de séjours valorisés
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') THEN nb_rsa ELSE NULL END $colElseNull $caseElseNull)::text])";									
							break;                                
						case '18.1':	 // Nombre de séjours valorisés en hospitalisation complète
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') and duree_sejour > 0 then v_rss_1.rss_id  ELSE NULL END $colElseNull $caseElseNull)";
							break;                                
						case '18.2':	 // Nombre de séjours sans nuitée
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') THEN nb_rsa_0n ELSE NULL END $colElseNull $caseElseNull)::text])";									
							break;                                
						case '18.3':	 // Nombre de séances valorisés
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND cmd_code = '28' THEN nb_rsa  ELSE NULL END $colElseNull $caseElseNull)::text])";									
							break;
						case '18.4': // Nombre de séjours transmis
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN en_cours = '0' AND cas_code not in ('*','?') THEN v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break; 								
						case '18.5':	 // Montant des séjours supprimés
							return "SUM( $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi not in ('30','32') then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '19.0': // Nombre de séjours transmis
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text, nb_rsa::text])";
							break;
						case '19.1': // Nombre de séjours Non traités
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('11','12','13','14','15','21','22','23','24','25','26','31','32','33') THEN nb_rsa  ELSE NULL END $colElseNull $caseElseNull)::text])";									
							break;                                
						case '19.2': // Montant non traités
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi  in ('11','12','13','14','15','21','22','23','24','25','26','31','32','33')  THEN v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '19.3':	 // Montant valorisés
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '19.4':	 // Montant valorisés hospitalisation compléte 
							return "SUM($caseWhen $colWhen CASE WHEN  duree_sejour > 0 AND  v_rss_1.traitement_epmsi IN ('30') AND  prestation_code != 'LIM_SRC' then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;								
						case '19.5':	 // Montant valorisés sans nuitée
							return "SUM($caseWhen $colWhen CASE WHEN  duree_sejour = 0 AND  v_rss_1.traitement_epmsi IN ('30') AND  prestation_code != 'LIM_SRC' AND cmd_code <> '28' then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;								
						case '19.6':	 // Montant valorisés des séances
							return "SUM($caseWhen $colWhen CASE WHEN cmd_code = '28' AND v_rss_1.traitement_epmsi IN ('30') AND  prestation_code != 'LIM_SRC' then v_rsf_detail_1.base_remboursement_sauf_transition ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '19.7':  // Nombre prestations supprimé Quantité de prestations : Nombre x Coefficient
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi not in ('30','32') THEN nombre_coefficient ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '19.8':  // Séjours taux de remb différent de 100 et montant TM égal à 0
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text, ($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND  v_vidhosp_1.taux_remboursement_utilise <> 100 and v_vidhosp_1.montant_tm = 0 THEN nb_rsa  ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;                                
						case '19.9':  // Séjours taux de remb égal à 100 et montant TM différent de 0
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text, ($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND  v_vidhosp_1.taux_remboursement_utilise = 100 and v_vidhosp_1.montant_tm <> 0 THEN nb_rsa  ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;
						case '20.1':  // Séjours FJ à la charge de l'assuré et montant FJ égal à 0
							return "COUNT(DISTINCT $caseWhen $colWhen case when  v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.code_pec_fj_id = 2 AND v_vidhosp_1.montant_fj = 0 then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;
						case '20.2': // Séjours FJ n'est pas applicable et montant FJ différent de 0
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,(   $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND  v_vidhosp_1.code_pec_fj_utilise = 'X' and montant_fj <> 0 THEN nb_rsa  ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;
						case '20.3' : // Séjours où FJ et DS non compatibles (à voir)
							return "COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30') AND v_vidhosp_1.code_pec_fj_utilise <> 'X' and 1=0 and  (((v_rss_1.duree_sejour * 20) <> v_vidhosp_1.montant_fj)  or  ((v_rss_1.duree_sejour * 18) <> v_vidhosp_1.montant_fj) or ((v_rss_1.duree_sejour + 1 * 20) <> v_vidhosp_1.montant_fj) OR ((v_rss_1.duree_sejour + 1 * 18) <> v_vidhosp_1.montant_fj))  then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;
						case '20.4': // Séjours où mnt BR différent de mnt AM + mnt TM
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,(   $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND v_vidhosp_1.base_remboursement <>  ( v_vidhosp_1.montant_remboursable_amo + v_vidhosp_1.montant_tm) THEN nb_rsa  ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;
						case '20.5' : // Séjours de + 30 jours avec exo Tm=2, transfert depuis MCO et Tx remb différent de 100% (**)
								return "COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_rss_1.duree_sejour > 30  AND v_vidhosp_1.exoneration_tm_code = '2' AND mode_entree = '7' AND provenance = '1' and  v_vidhosp_1.taux_remboursement <> 100 then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;
						case '20.6': // Autres séjours avec exo Tm=2 et Tx remb=100% (***)
							return "COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.exoneration_tm_code = '2' AND v_vidhosp_1.taux_remboursement = 100 then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)";
							break;                         
						case '20.7': // Séjours sans anomalies
							return "COUNT(DISTINCT $caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30','31','32','33') then v_rss_1.rss_id  ELSE NULL END $colElseNull $caseElseNull) - (
								
								COUNT(DISTINCT $caseWhen $colWhen case when  v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.taux_remboursement = 100 and v_vidhosp_1.montant_tm <> 0  then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)
								+
								COUNT(DISTINCT $caseWhen $colWhen case when  v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.code_pec_fj_id = 2 AND v_vidhosp_1.montant_fj = 0 then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)
								+
								COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.code_pec_fj_code='X' and montant_fj <> 0 and no_entree <> '' then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)
								+
								COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.base_remboursement <>  ( v_vidhosp_1.montant_remboursable_amo + v_vidhosp_1.montant_tm) then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)
								+
								COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_rss_1.duree_sejour > 30  AND v_vidhosp_1.exoneration_tm_code = '2' AND mode_entree = '7' AND provenance = '1' and  v_vidhosp_1.taux_remboursement <> 100 then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)
								+
								COUNT(DISTINCT $caseWhen $colWhen case when v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_vidhosp_1.exoneration_tm_code = '2' AND v_vidhosp_1.taux_remboursement = 100 then v_rss_1.rss_id ELSE NULL END $colElseNull $caseElseNull)
							
							)";
							break;
						case '21.1': // Nombre de séjours EXB
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND nb_exb = 1  AND rehosp_meme_ghm <> '1' THEN nb_rsa ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;                                
						case '21.2': // Nombre de séjours avec réhosp dans le même GHM
							return "COUNT(DISTINCT $caseWhen $colWhen CASE  WHEN (nb_ghsmin = 1 OR rehosp_meme_ghm = '1') AND ca_perte_exb <> 0 THEN v_rss_1.no_rss ELSE NULL END $colElseNull $caseElseNull)";
							break;
						case '21.3': // Montant BR des séjours EXB avec coefficient prudentiel 
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rss_1.no_rss::text, ($caseWhen $colWhen CASE WHEN nb_exb <> 0 AND nb_ghsmin = 0 AND rehosp_meme_ghm <> '1' THEN 0 - ca_perte_exb ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;                                
						case '21.4': // Montant BR total des séjours EXB
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rss_1.no_rss::text, ($caseWhen $colWhen CASE WHEN nb_exb <> 0 AND nb_ghsmin = 0 AND rehosp_meme_ghm <> '1' THEN 0 - base_remboursement_exb_sauf_transition_sans_arrondi ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;                                    
						case '21.5': // Montant BR des séjours avec réhosp dans le même GHM avec coefficient prudentiel 
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rss_1.no_rss::text, ($caseWhen $colWhen CASE WHEN nb_exb = 1  AND rehosp_meme_ghm = '1' THEN 0 - ca_perte_exb ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;                                
						case '21.6': // Montant de séjours avec réhosp dans le même GHM
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rss_1.no_rss::text, ($caseWhen $colWhen CASE WHEN nb_exb = 1  AND rehosp_meme_ghm = '1' THEN 0 - base_remboursement_exb_sauf_transition_sans_arrondi ELSE NULL END $colElseNull $caseElseNull)::text])";
							break;
						case '21.7':	 // Montant facturé (BR) avec coefficient prudentiel sans déduction montant EXB
							return "SUM($caseWhen $colWhen v_rsf_detail_1.base_remboursement + ca_perte_exb  $colEsleZero  $caseElseZero)";
							break;
						case '21.8':	 // Montant BR sans déduction du montant EXB 
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') then v_rsf_detail_1.base_remboursement_sauf_transition - base_remboursement_exb_sauf_transition_sans_arrondi ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '21.9':	 // Montant GHS sans déduction du montant EXB 
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND prestation_code='GHS' then v_rsf_detail_1.base_remboursement_sauf_transition - base_remboursement_exb_sauf_transition_sans_arrondi ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '22.1':	 //Dt Nb réalisés aux urgences 
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND activite_urgence='1' then nombre_coefficient ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '22.2':	 //Dt Mnt BR réalisé aux urgences
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND activite_urgence='1' then v_rsf_detail_1.base_remboursement ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '22.3':	 //Dt Mnt AM réalisé aux urgences
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') AND activite_urgence='1' then v_rsf_detail_1.sejour_remboursable ELSE 0 END $colEsleZero $caseElseZero)";
							break;                                
						case '22.4':	 //MT activité programmée hors urgence
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30') then v_rsf_detail_1.sejour_remboursable ELSE 0 END $colEsleZero $caseElseZero) - SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30','31','32','33') AND activite_urgence='1' then v_rsf_detail_1.sejour_remboursable ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '22.5':	 //MT BR valorisé par FIDES
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.cas_code not in ('C','K','X','N','O','S')  AND v_rsf_total_1.valorise_fides_id = 1 AND  v_rss_1.traitement_epmsi IN ('30', '31', '32','33') THEN v_rsf_detail_1.base_remboursement ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '22.6':	 //MT BR non valorisé par FIDES
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.cas_code not in ('C','K','X','N','O','S')  AND v_rsf_total_1.valorise_fides_id = 0 AND  v_rss_1.traitement_epmsi IN ('30', '31', '32','33') THEN v_rsf_detail_1.base_remboursement ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '22.7':	 //MT remboursé AM valorisé par FIDES
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.cas_code not in ('C','K','X','N','O','S')  AND v_rsf_total_1.valorise_fides_id = 1 AND  v_rss_1.traitement_epmsi IN ('30', '31', '32','33') THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '22.8':	 //MT Remboursé AM non valorisé par FIDES
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.cas_code not in ('C','K','X','N','O','S')  AND v_rsf_total_1.valorise_fides_id = 0 AND  v_rss_1.traitement_epmsi IN ('30', '31', '32','33') THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '22.9':	 //Dt Nb de prestations valorisé par FIDES
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_rsf_total_1.valorise_fides_id = 1 then nombre_coefficient ELSE 0 END $colEsleZero $caseElseZero)";
							break;
						case '23.1':	 //Dt Nb de prestations non valorisé par FIDES
							return "SUM($caseWhen $colWhen CASE WHEN v_rss_1.traitement_epmsi in ('30','31','32','33') AND v_rsf_total_1.valorise_fides_id = 0 then nombre_coefficient ELSE 0 END $colEsleZero $caseElseZero)";
							break;								
						case '23.2':	 //Nb séjours non controlés
							return "base.cti_sum_distinct_on( DISTINCT   ARRAY[v_rsf_detail_1.no_rss::text,(CASE WHEN (v_vidhosp_1.taux_remboursement_utilise <> v_vidhosp_1.taux_remboursement and v_vidhosp_1.taux_remboursement_utilise = 100 and (hospit_nouveau_ne = 1 or prelevement_organe = 1)) OR (code_pec <> '1'  AND v_vidhosp_1.taux_remboursement_utilise = 80)  THEN nb_rsa  ELSE NULL END)::text])";
							break;
						case '23.3':	// CA GHS BRUT
							return "SUM($caseWhen $colWhen v_rss_1.ca_ghs_sans_coefficient $colEsleZero $caseElseZero)";
							break;
						default:
							return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id $colElseNull $caseElseNull)";
					}
				}
                
                function PMSI_RSS_data($DATA, $DEFAULT="", $CASE="", $PERIODE_DUREE="",$COL) {

					$caseWhen = "";
					$caseElseZero = "";
					$caseElseNull = "";

					if ($CASE != "") {
						$caseWhen = "CASE WHEN $CASE THEN";
						$caseElseZero = "ELSE 0 END";
						$caseElseNull = "ELSE NULL END";
					}

					$colWhen= "";
					$colEsleZero = "";
					$colElseNull = "";
				
					if ($COL == '1') {
						$colWhen="CASE WHEN COLUMNCHECKSEQUENCE THEN";
						$colEsleZero = "ELSE 0 END";
						$colElseNull = "ELSE NULL END";
					}
					
					switch ($DATA) {
								case '1': // Nombre de séjours
									return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id $colElseNull $caseElseNull)";
									break;
                                case '2': // Nombre de séjours 0 nuit
									return "SUM($caseWhen $colWhen nb_rsa_0n $colEsleZero $caseElseZero)";
									break;
                                case '3':	 // Nombre de séjours 1 nuit
									return "SUM($caseWhen $colWhen nb_rsa_1n $colEsleZero $caseElseZero)";
									break;
                                case '3.3':	 // Nombre de séjours > 1 nuit
									return "SUM($caseWhen $colWhen nb_rsa_2n + nb_rsa_xn $colEsleZero $caseElseZero)";
									break;
                                case '4':	 // Nombre de séjours 2 nuit
									return "SUM($caseWhen $colWhen nb_rsa_2n $colEsleZero $caseElseZero)";
									break;                                
                                case '5':	 // Nombre de séjours > 2 nuits
									return "SUM($caseWhen $colWhen nb_rsa_xn $colEsleZero $caseElseZero)";
									break;
                                case '10':	// Nombre CHIR AMBU
									return "SUM($caseWhen $colWhen CASE WHEN duree_sejour = '0' AND cas_code = 'C' THEN nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
									break;
                                case '1.16':	// Séjours dont séances
									return "SUM($caseWhen $colWhen nb_rsa $colEsleZero $caseElseZero)";
									break;
                                case '6':	 // Nombre de séances
									return "SUM($caseWhen $colWhen nb_seances $colEsleZero $caseElseZero)";
									break;                                
                                case '7':	 // Nombre de journées hospitalisé
									return "SUM($caseWhen $colWhen duree_sejour $colEsleZero $caseElseZero)";
									break;
                                case '1.17':	// Nombre de GHM
									return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.ghm_id $colElseNull $caseElseNull)";
									break;
                                case '9':	// Nombre décès 
									return "SUM($caseWhen $colWhen CASE WHEN mode_sortie = '9' THEN nb_rsa ELSE 0 END $colEsleZero $caseElseZero)";
									break;                                    
								case '1.15': // Age moyen des patients
									return "base.cti_division(SUM($caseWhen $colWhen age $colEsleZero $caseElseZero),COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id $colElseNull $caseElseNull))";
									break;
                                case '10.13':	// Age moy public qualifié
									return "base.cti_division(SUM($caseWhen $colWhen age_public $colEsleZero $caseElseZero),SUM($caseWhen $colWhen nb_rsa_public $colEsleZero $caseElseZero))";
									break;
                                case '10.14':	// Age moy privé qualifié
									return "base.cti_division(SUM($caseWhen $colWhen ghm_nat.age_prive $colEsleZero $caseElseZero),SUM($caseWhen $colWhen ghm_nat.nb_rsa_prive $colEsleZero $caseElseZero))";
									break;
                                case '8': // DMS
									return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN cmd_code <> '28' THEN duree_sejour ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen nb_rsa $colEsleZero $caseElseZero))";
									break;								
                                case '8.1':	// DMS GHS
									return "base.cti_division(SUM($caseWhen $colWhen CASE WHEN  cmd_code <> '28' THEN dms_nationale_ghs ELSE 0 END $colEsleZero $caseElseZero),SUM($caseWhen $colWhen nb_rsa $colEsleZero $caseElseZero))";
									break;                                 
                                case '1.8':	 // Nombre de patients
									return "COUNT(DISTINCT $caseWhen $colWhen patient_id $colElseNull $caseElseNull)";
									break;								
                                case '1.11':	 // Nombre de journées d'hospitalisation
									return "SUM($caseWhen $colWhen duree_sejour + nb_rsa_0n + nb_seances $colEsleZero $caseElseZero)";
									break;
                                case '1.14':	// Nombre de séjours hospitalisé
									return "SUM($caseWhen $colWhen nb_rsa_1n + nb_rsa_2n + nb_rsa_xn $colEsleZero $caseElseZero)";
									break;					
								
								default:
									return "COUNT(DISTINCT $caseWhen $colWhen v_rss_1.rss_id $colElseNull $caseElseNull)";

					}

				}	
			]]>
			</value>

	</COMPONENT>
		
	<COMPONENT name="SELECT_TABTREE_FUNCTIONS" label="Fonctions pour les regroupements" >

			<value><![CDATA[ 
			

				///////////////////////////////     PROPERTIES_SELECT_TABTREE (REGROUPEMENTS)     ///////////////////////////////

				//Permet de choisir le bon préfixe pour les regroupements

				function selectPrefixTabtree($groupby, $cls6) {
			
					$prefixe = '';

					// Spécial actes
					if ($groupby == 'ACTE') {$prefixe = 'acte';}
					if ($cls6 == 'ACTCLS') {$prefixe = 'acte_section';}
					if ($groupby == 'ACD') {$prefixe = 'acte_ccam_descriptif';}
					if ($cls6 == 'ACDCLS') {$prefixe = 'acte_ccam_descriptif_section';}
					if ($groupby == 'REGCCAM') {$prefixe = 'acte_regroupement';}
					if ($groupby == 'EXEC' || $groupby == 'EXECACTE') {$prefixe = 'medecin_reference';}
					if ($groupby == 'EXECSPE') {$prefixe = 'specialite_interne_medecin_reference';}
					if ($cls6 == 'EXECLS') {$prefixe = 'medecin_reference_section';}
					if ($groupby == 'CH1CCAM') {$prefixe = 'ccam_chapitre_1';}
					if ($groupby == 'CH2CCAM') {$prefixe = 'ccam_chapitre_2';}
					if ($groupby == 'CH3CCAM') {$prefixe = 'ccam_chapitre_3';}
					if ($groupby == 'CH4CCAM') {$prefixe = 'ccam_chapitre_4';}
					if ($groupby == 'SC1CCAM') {$prefixe = 'ccam_topographie_1';}
					if ($groupby == 'SC2CCAM') {$prefixe = 'ccam_topographie_2';}
					if ($groupby == 'SC3CCAM') {$prefixe = 'ccam_action';}
					if ($groupby == 'SC4CCAM') {$prefixe = 'ccam_technique';}
					if ($groupby == 'TYCCAM') {$prefixe = 'ccam_type';}
					if ($groupby == 'EXTDOC') {$prefixe = 'extension_ccam';}
					if ($groupby == 'UF') {$prefixe = 'unite_fonctionnelle';}
					if ($cls6 == 'UFCCLS') {$prefixe = 'unite_fonctionnelle_section';}
					
					// Spécial interventions
					if ($groupby == 'INTACTE') {$prefixe = 'v_rss_actes_4.acte_principal';}
					if ($cls6 == 'ACICLS') {$prefixe = 'v_rss_actes_4.acte_principal_section';}
					if ($groupby == 'INTREGCCAM') {$prefixe = 'acte_principal_regroupement';}
					if ($groupby == 'ANESTH') {$prefixe = 'anesthesiste_reference';}
					if ($cls6 == 'ARECLS') {$prefixe = 'anesthesiste_reference_section';}
					
					// Spécial DIAG
					if ($groupby == 'DIAG') {$prefixe = 'diagnostic';}
					if ($groupby == 'DIAGROOT') {$prefixe = 'diagnostic_racine';}
					if ($groupby == 'G_DIAGSEV') {$prefixe = 'diagnostic_severite';}
					if ($cls6 == 'DIACLS') {$prefixe = 'diagnostic_section';}
					
					// Spécial prestations
					if ($groupby == 'PRESTA') {$prefixe = 'prestation';}
					if ($cls6 == 'PRECLS') {$prefixe = 'prestation_section';}
					if ($groupby == 'FIDES_DETAIL') {$prefixe = 'v_rsf_detail_1.fides_detail';}
					
					// Spécial LPP
					if ($groupby == 'LPP') {$prefixe = 'lpp';}
					if ($cls6 == 'LPPCLS') {$prefixe = 'lpp_section';}
					
					// Spécial UCD
					if ($groupby == 'UCD') {$prefixe = 'ucd';}
					if ($groupby == 'T_UCD') {$prefixe = 'type_ucd';}
					if ($groupby == 'IND_UCD') {$prefixe = 'indication';}
					if ($cls6 == 'UCDCLS') {$prefixe = 'ucd_section';}
					if ($cls6 == 'IUCCLS') {$prefixe = 'iucd_section';}
					
					// Spécial RUM
					if ($groupby == 'POL') {$prefixe = 'pole_rum';}
					if ($cls6 == 'POLCLS') {$prefixe = 'pole_rum_section';}

					if ($groupby == 'UM') {$prefixe = 'unite_medicale';}
					if ($groupby == 'PUM') {$prefixe = 'v_premiere_unite_medicale_link.premiere_unite_medicale';}
					if ($groupby == 'UMAUT') {$prefixe = 'type_autorisation';}
					if ($groupby == 'UPAUT') {$prefixe = 'v_unite_medicale_principale_link.type_autorisation_principale';}
					if ($groupby == 'UMHOS') {$prefixe = 'mode_hospitalisation';}
					if ($groupby == 'UMDIS') {$prefixe = 'discipline_sae';}
					if ($cls6 == 'UMDCLS') {$prefixe = 'unite_medicale_section';}
					if ($groupby == '11') {$prefixe = 'diagnostic_principal_rum';}
					if ($groupby == 'MENRUM') {$prefixe = 'v_rss_rum_2';}
					if ($groupby == 'MSORUM') {$prefixe = 'v_rss_rum_2';}
					if ($groupby == 'MEDRUM') {$prefixe = 'medecin_rum';}
					if ($cls6 == 'MRUCLS') {$prefixe = 'medecin_rum_section';}
					if ($groupby == 'SPEMEDRUM') {$prefixe = 'specialite_medecin_reference_rum';}
					
					// Spécial Controle Expert
					if ($groupby == 'EXC_ANMO_SIGNAL') {$prefixe = 'date_signalement_mois';}
					if ($groupby == 'EXC_ANSE_SIGNAL') {$prefixe = 'date_signalement_semaine';}
					if ($groupby == 'EXC_DATE_SIGNAL') {$prefixe = 'date_signalement';}
					if ($groupby == 'EXC_ANMO_CORREC') {$prefixe = 'date_correction_mois';}
					if ($groupby == 'EXC_ANSE_CORREC') {$prefixe = 'date_correction_semaine';}
					if ($groupby == 'EXC_DATE_CORREC') {$prefixe = 'date_correction';}
					if ($groupby == 'EXC_ANMO_GROUP') {$prefixe = 'date_groupage_mois';}
					if ($groupby == 'EXC_ANSE_GROUP') {$prefixe = 'date_groupage_semaine';}
					if ($groupby == 'EXC_DATE_GROUP') {$prefixe = 'date_groupage';}
					if ($cls6 == 'EXCCLS') {$prefixe = 'expert_controle_section';}
					if ($groupby == 'EXC') {$prefixe = 'expert_controle';}
					
					
					// Standard RSS
					if ($groupby == 'RSS') {$prefixe = 'v_rss_1.rss';}
					if ($groupby == '1') {$prefixe = 'v_rss_1.cmd';}
					if ($groupby == '2') {$prefixe = 'v_rss_1.pole_oap';}
					if ($groupby == '9') {$prefixe = 'v_rss_1.ligne_oap';}
					if ($groupby == '3') {$prefixe = 'v_rss_1.groupe_activite';}
					if ($groupby == '4') {$prefixe = 'v_rss_1.ghm';}
					if ($cls6 == 'GHMCLS') {$prefixe = 'v_rss_1.ghm_section';}
					if ($groupby == '6') {$prefixe = 'v_medecin_rss_link.medecin_reference_rss';}
					if ($cls6 == 'MEDCLS') {$prefixe = 'v_medecin_rss_link.medecin_rss_section';}
					if ($groupby == '7') {$prefixe = 'v_medecin_rss_link.specialite_interne_medecin_reference_rss';}
					if ($groupby == 'CMM') {$prefixe = 'v_comites_medicaux_1.comite_medical';}
					if ($cls6 == 'CMMCLS') {$prefixe = 'v_comites_medicaux_1.comite_medical_section';}
					if ($groupby == '10') {$prefixe = 'v_diagnostic_principal_link.diagnostic_principal';}
					if ($cls6 == 'DGPCLS') {$prefixe = 'v_diagnostic_principal_link.diagnostic_principal_section';}
					if ($groupby == 'DIAGPROOT') {$prefixe = 'v_diagnostic_principal_link.diagnostic_principal_racine';}
					if ($groupby == 'DIAGR') {$prefixe = 'v_diagnostic_relie_link.diagnostic_relie';}
					if ($cls6 == 'DGRCLS') {$prefixe = 'v_diagnostic_relie_link.diagnostic_relie_section';}
					if ($groupby == 'DIAGRROOT') {$prefixe = 'v_diagnostic_relie_link.diagnostic_relie_racine';}
					if ($groupby == 'UP') {$prefixe = 'v_unite_medicale_principale_link.unite_medicale_principale';}
					if ($cls6 == 'UMPCLS') {$prefixe = 'v_unite_medicale_principale_link.unite_medicale_principale_section';}
					if ($groupby == 'POP') {$prefixe = 'pole_principal';}
					if ($cls6 == 'POPCLS') {$prefixe = 'pole_principal_section';}
					if ($groupby == '8') {$prefixe = 'v_rss_1.mcos';}
					if ($groupby == 'FIN') {$prefixe = 'v_rss_1.finess';}
					if ($cls6 == 'FINCLS') {$prefixe = 'v_rss_1.finess_section';}
					if ($groupby == 'GHS') {$prefixe = 'v_rss_1.ghs';}
					if ($groupby == 'GHSASSOS') {$prefixe = 'v_rsf_detail_1.ghs';}
					if ($groupby == 'IPA') {$prefixe = 'v_rss_ipa_1.ipa';}
					if ($groupby == 'RIPA') {$prefixe = 'v_rss_ipa_1.categorie_ipa';}
					if ($groupby == 'GHM5') {$prefixe = 'v_rss_1.ghm5';}
					if ($groupby == 'CAS') {$prefixe = 'v_rss_1.cas';}
					if ($groupby == 'GHMSEV') {$prefixe = 'v_rss_1.severite_ghm';}
					if ($groupby == 'CTISEV') {$prefixe = 'v_rss_1.severite_cti';}
					if ($groupby == 'TYPFAC') {$prefixe = 'v_prestation_principale_link.prestation_principale';}
					if ($cls6 == 'PRPCLS') {$prefixe = 'v_prestation_principale_link.prestation_principale_section';}
					if ($groupby == 'ACTEP') {$prefixe = 'v_acte_principal_link.acte_principal';}
					if ($cls6 == 'ACPCLS') {$prefixe = 'v_acte_principal_link.acte_principal_section';}
					if ($groupby == 'ASOR') {$prefixe = 'extract(year from v_rss_1.date_sortie)';}
					if ($groupby == 'TRIMSOR') {$prefixe = 'extract(quarter from v_rss_1.date_sortie)';}
					if ($groupby == 'ATRIMSOR') {$prefixe = 'v_rss_1.date_sortie';}
					if ($groupby == 'AMSOR') {$prefixe = 'v_rss_1.mois_sortie';}
					if ($groupby == 'MSOR') {$prefixe = 'v_rss_1.mois_sortie_mm';}
					if ($groupby == 'AGEJOURS') {$prefixe = 'v_rsa_1.age_jours';}
					if ($groupby == 'AGE') {$prefixe = 'v_ages_1.age';}
					if ($cls6 == 'AGECLS') {$prefixe = 'v_ages_1.age_section';}
					if ($groupby == 'DUREE_SEJOUR') {$prefixe = 'v_durees_sejour_1.duree_sejour';}
					if ($cls6 == 'DSJCLS') {$prefixe = 'v_durees_sejour_1.duree_sejour_section';}
					if ($groupby == 'CODEPOST') {$prefixe = 'v_codes_postaux_2.code_postal';}
					if ($groupby == 'DEPARTEMENT') {$prefixe = 'v_codes_postaux_2.departement';}
					if ($groupby == 'REGION') {$prefixe = 'v_codes_postaux_2.region';}
					if ($groupby == 'CODEGEOPMSI') {$prefixe = 'v_codes_postaux_2.code_geographique_pmsi';}
					if ($groupby == 'TERSANTE') {$prefixe = 'v_codes_postaux_2.territoire_sante';}
					if ($cls6 == 'CDPCLS') {$prefixe = 'v_codes_postaux_2.code_postal_section';}
					if ($groupby == 'GM') {$prefixe = 'v_rss_gm_1.gm';}
					if ($groupby == 'SEUIL_CANCERO') {$prefixe = 'v_rss_cancero_1.cancero';}
					if ($groupby == 'SEUIL_CANCERO_ROOT') {$prefixe = 'v_rss_cancero_1.activite_cancero';}
					if ($groupby == 'SEUIL_CANCERO_PRINCIPAL') {$prefixe = 'v_rss_cancero_2022.cancero_principal';}
					if ($groupby == 'SEUIL_CANCERO_PRINCIPAL_ROOT') {$prefixe = 'v_rss_cancero_2022.activite_cancero_principal';}
					if ($groupby == 'ME') {$prefixe = 'v_rss_1.mode_entree';}
					if ($groupby == 'MS') {$prefixe = 'v_rss_1.mode_sortie';}
					if ($groupby == 'ERR_GROUP') {$prefixe = 'v_rss_leg_1.code_retour_groupeur';}
					if ($groupby == 'RULE_NON_VAL') {$prefixe = 'v_rsf_detail_non_valorise_1.regle_non_valorisation';}
					if ($groupby == 'ETAT_EPMSI') {$prefixe = 'v_rss_1.traitement_epmsi';}
					if ($groupby == 'ETAT_RSS') {$prefixe = 'v_etat_sejour_link.etat_sejour';}
					if ($groupby == 'TYPE_SEJ_OVA') {$prefixe = 'v_rss_1.type_sejour_ovalide';}
					if ($groupby == 'ETAB_PROV') {$prefixe = 'etablissement_provenance';}
					if ($groupby == 'ETAB_DEST') {$prefixe = 'etablissement_destination';} 

					//Ré-entrée
					if ($groupby == 'G_RE_ENTREE_GHM') {$prefixe = 'w_reentrees.apres_ghm';}                   
					if ($groupby == 'G_RE_ENTREE_RACINE_GHM') {$prefixe = 'w_reentrees.apres_ghm5';}                   
					if ($groupby == 'G_RE_ENTREE_DIAG') {$prefixe = 'w_reentrees.apres_diagnostic_principal';}                   
					if ($groupby == 'G_RE_ENTREE_MEDECIN') {$prefixe = 'w_reentrees.apres_medecin_rss';}                   
					
					// Prise en charge
					if ($groupby == 'PEC') {$prefixe = 'v_rsf_total_1.code_pec';}
					if ($groupby == 'MOTIF_NON_FACTURATION') {$prefixe = 'v_rsf_total_1.motif_non_facturation';}
					if ($groupby == 'REGIME') {$prefixe = 'v_rsf_total_1.regime';}
					if ($groupby == 'NATURE_PEC') {$prefixe = 'v_rsf_total_1.nature_pec';}
					if ($groupby == 'TYPE_CONTRAT_OC') {$prefixe = 'v_rsf_total_1.type_contrat_oc';}
					if ($groupby == 'PEC_FJ') {$prefixe = 'v_rsf_total_1.code_pec_fj';}
					if ($groupby == 'EXONERATION_TM') {$prefixe = 'v_rsf_total_1.exoneration_tm';}
					if ($groupby == 'FAC_18EUROS') {$prefixe = 'v_rsf_total_1.facturation_18euros';}
					if ($groupby == 'TX_REMB') {$prefixe = 'v_rss_1.taux_remboursement';}
					if ($groupby == 'PAT_BENEF_CMU') {$prefixe = 'v_rsf_total_1.pat_benef_cmu';}
					if ($groupby == 'VALORISE_FIDES') {$prefixe = 'v_rsf_total_1.valorise_fides';}

					// Variables
					if ($groupby == 'GHPHC') {$prefixe = 'v_conversion_hp_hc_link.conversion_hp_hc';}
					if ($groupby == 'GRAAC') {$prefixe = 'v_raac_link.raac';}
					if ($groupby == 'GNP') {$prefixe = 'v_np_link.np';}
					if ($groupby == 'G_PASSAGE_URGENCES') {$prefixe = 'v_passage_urgences_link.passage_urgences';}
					if ($groupby == 'GRESC_TARF') {$prefixe = 'v_rescrit_tarif_link.rescrit_tarif';}
					if ($groupby == 'GPRO_RES_HOSP') {$prefixe = 'v_adm_prod_reshospi_link.adm_prod_reshospi';}
					if ($groupby == 'GCONT_PAT') {$prefixe = 'v_contexte_pat_link.contexte_pat';}
					if ($groupby == 'GNB_INTERV') {$prefixe = 'v_nb_interventions_link.nb_intervention';}
					
					// Paramètres personnalisés
					if ($groupby == 'PS1') {$prefixe =  'v_rss_parametres_personnalises_1.parametre_personnalise_1';}
					if ($cls6 == 'PS1CLS') {$prefixe =  'v_rss_parametres_personnalises_1.parametre_personnalise_1_section';}
					if ($groupby == 'PS2') {$prefixe =  'v_rss_parametres_personnalises_1.parametre_personnalise_2';}
					if ($cls6 == 'PS2CLS') {$prefixe =  'v_rss_parametres_personnalises_1.parametre_personnalise_2_section';}
					
					// prestations non valorisées
					if ($groupby == 'PRESTA_NON_VAL') {$prefixe = 'v_rsf_detail_non_valorise_1.prestation';}
					
					if ($prefixe == '') {
						$prefixe = 'v_rss_1.ghm';
					}

					return $prefixe;
			}



			// $field_with_linkid : Tableau qui répertorie les champs que l'on récupère grâce au db_optimizer et qui utilise une v_view_link 
			// On rajoute le suffixe linkid pour éviter les erreurs d'ambiguité si les champs sont aussi présents dans une autre v_view 
			// ex: acte_principal est présent dans v_acte_principal_link et v_rss_actes_4

			function selectSuffixeLinkid($groupby){

				$field_with_linkid = array('10', 'ACTEP', 'GCONT_PAT', 'DIAGR', 'GNP', 'GHPHC', 'GNB_INTERV', 'GRESC_TARF', 'GPRO_RES_HOSP', 'GRAAC', 'TYPFAC', 'UP');
				$suffixe = '_id';
				if (in_array($groupby, $field_with_linkid)){
					$suffixe = '_linkid';
				}

				return $suffixe;
			}


			function selectOidTabtree($groupby, $prefixe, $suffixe){

				$oid_field = $prefixe . $suffixe;
					
				if ($groupby == 'ASOR' || $groupby == 'TRIMSOR') {$oid_field = $prefixe;}
				if ($groupby == 'ATRIMSOR') {$oid_field = '(extract(year FROM v_rss_1.date_sortie) || extract(quarter FROM v_rss_1.date_sortie))';}
				if ($groupby == 'AMSOR') {$oid_field = 'v_rss_1.mois_sortie';}
				if ($groupby == 'MSOR') {$oid_field = 'v_rss_1.mois_sortie_mm_code';}
				
				if ($groupby == 'G_DIAGSEV') {$oid_field = 'v_rss_diagnostics_1.diagnostic_severite_fg2023_code';}
				
				if ($groupby == 'MENRUM') {$oid_field = $prefixe.'.mode_entree_rum';}
				if ($groupby == 'MSORUM') {$oid_field = $prefixe.'.mode_sortie_rum';}
				
				if ($groupby == 'TERSANTE') {$oid_field = 'COALESCE(' . $oid_field . ', 0)';}
				if ($groupby == 'SEUIL_CANCERO' || $groupby == 'SEUIL_CANCERO_PRINCIPAL') {$oid_field = 'COALESCE(' . $oid_field . ', 999)';}
				if ($groupby == 'SEUIL_CANCERO_ROOT' || $groupby == 'SEUIL_CANCERO_PRINCIPAL_ROOT') {$oid_field = 'COALESCE(' . $oid_field . ', 998)';}
				
				if ($groupby == 'GHMSEV') {$oid_field = 'ascii(v_rss_1.severite_ghm_code)';}
				if ($groupby == 'CTISEV') {$oid_field = 'ascii(v_rss_1.severite_cti_code)';}
				if ($groupby == 'UMAUT') {$oid_field = 'base.cti_to_ascii(type_autorisation)';}
				//if ($groupby == 'UPAUT') {$oid_field = 'base.cti_to_ascii(type_autorisation_principale_id)';}
				if ($groupby == 'ME') {$oid_field = 'base.cti_to_ascii(v_rss_1.mode_entree)';}
				if ($groupby == 'MS') {$oid_field = 'base.cti_to_ascii(v_rss_1.mode_sortie)';}
				if ($groupby == 'PR') {$oid_field = 'base.cti_to_ascii(v_rss_1.mode_entree || v_rss_1.provenance)';}
				if ($groupby == 'DS') {$oid_field = 'base.cti_to_ascii(v_rss_1.mode_sortie || v_rss_1.destination)';}	
				
				if ($groupby == 'TX_REMB') {$oid_field = 'v_rss_1.taux_remboursement';}
				
				if ($groupby == 'ETAT_EPMSI') {$oid_field = 'v_rss_1.traitement_epmsi';}
				
				if ($groupby == 'EXTDOC') {$oid_field = "COALESCE(ascii(extension_ccam), 0)";}
				
				if ($groupby == 'ANPNP') {$oid_field = "COALESCE(ascii(association_nonprevue_ccam), 0)";}

				return $oid_field;
			}




			// $field_with_lincode : Tableau qui répertorie les champs que l'on récupère grâce au db_optimizer et qui utilise une v_view_link 
			// On rajoute le suffixe linkcode pour éviter les erreurs d'ambiguité si les champs sont aussi présents dans une autre v_view 
			// ex: passage_urgences_code est présent dans v_passage_urgences_link et v_rss_base

			function selectLinkcodeSuffixe($groupby){

				$field_with_linkcode = array('G_PASSAGE_URGENCES');
				$suffixe = '_code';
				if (in_array($groupby, $field_with_linkcode)){
					$suffixe = '_linkcode';
				}

				return $suffixe;
			}

					
			function selectCodeTabtree($groupby, $prefixe, $suffixe){

				$cod_field = $prefixe . $suffixe;

				if ($groupby == 'RSS') {$cod_field = $prefixe . '_id';}
				if ($groupby == 'FIN') {$cod_field = $prefixe;}
				if ($groupby == 'UMAUT') {$cod_field = $prefixe;}
				if ($groupby == 'ASOR') {$cod_field = $prefixe;}
				if ($groupby == 'TRIMSOR') {$cod_field = "'T' || " . $prefixe;}
				if ($groupby == 'ATRIMSOR') {$cod_field = "(extract(year FROM v_rss_1.date_sortie)::text || 'T' || extract(quarter FROM v_rss_1.date_sortie)::text)";}
				
				if ($groupby == 'AMSOR') {$cod_field = $prefixe;}
				
				
				if ($groupby == 'G_DIAGSEV') {$cod_field = 'v_rss_diagnostics_1.diagnostic_severite_fg2023_code';}
				
				if ($groupby == 'TERSANTE') {$cod_field = "COALESCE(" . $cod_field . ", chr(255) || '*******')";}
				if ($groupby == 'SEUIL_CANCERO' || $groupby == 'SEUIL_CANCERO_ROOT' || $groupby == 'SEUIL_CANCERO_PRINCIPAL_ROOT' || $groupby == 'SEUIL_CANCERO_PRINCIPAL') {$cod_field = "COALESCE(" . $cod_field . ", chr(255) || '*****')";}
				
				if ($groupby == 'MENRUM') {$cod_field = $prefixe.'.mode_entree_rum';}
				if ($groupby == 'MSORUM') {$cod_field = $prefixe.'.mode_sortie_rum';}
				if ($groupby == 'ME') {$cod_field = 'v_rss_1.mode_entree';}
				if ($groupby == 'MS') {$cod_field = 'v_rss_1.mode_sortie';}
				if ($groupby == 'PR') {$cod_field = 'v_rss_1.mode_entree || v_rss_1.provenance';}
				if ($groupby == 'DS') {$cod_field = 'v_rss_1.mode_sortie || v_rss_1.destination';}
				
				if ($groupby == 'TX_REMB') {$cod_field = "v_rss_1.taux_remboursement";}
				
				if ($groupby == 'ETAT_EPMSI') {$cod_field = 'v_rss_1.traitement_epmsi';}
				if ($groupby == 'TYPE_SEJ_OVA') {$prefixe = 'v_rss_1.type_sejour_ovalide';}
				if ($groupby == 'EXTDOC') {$cod_field = "COALESCE(extension_ccam, 'N/R'::text)";}
				if ($groupby == 'ANPNP') {$cod_field = "COALESCE(association_nonprevue_ccam, 'N/R'::text)";}

				return $cod_field . '::text';
			}
					

			function selectTexteTabtree($groupby, $prefixe){

				$txt_field = $prefixe . '_texte';
				
				if ($groupby == 'ME') {$txt_field = 'v_modes_entree_link.mode_entree_texte';}
				if ($groupby == 'MS') {$txt_field = 'v_modes_sortie_link.mode_sortie_texte';}

				if ($groupby == 'RSS') {$txt_field = "('N° RSS : ' ||(v_rss_1.no_rss )::text || ' (' || to_char(v_rss_1.date_entree,'DD/MM/YYYY')) || CASE WHEN v_rss_1.date_entree <> v_rss_1.date_sortie THEN '-' || to_char(v_rss_1.date_sortie,'DD/MM/YYYY') ELSE '' END || ')'";}
				if ($groupby == '6' || $groupby == 'MEDRUM') {$txt_field = $prefixe .  '_nom';}
				if ($groupby == 'EXEC' || $groupby == 'EXECACTE') {$txt_field = $prefixe .  '_nom';}
				if ($groupby == 'ANESTH') {$txt_field = $prefixe .  '_nom';}
				if ($groupby == 'TYPFAC') {$txt_field = $prefixe .  '_code';}
				if ($groupby == 'ASOR') {$txt_field = $prefixe;}
				if ($groupby == 'TRIMSOR') {$txt_field = "'Trimestre ' || " . $prefixe . "::text";}
				if ($groupby == 'ATRIMSOR') {$txt_field = "(extract(year FROM v_rss_1.date_sortie)::text || ' Trimestre ' || extract(quarter FROM v_rss_1.date_sortie)::text)";}
				if ($groupby == 'G_DIAGSEV') {$txt_field = "CASE 
															WHEN diagnostic_severite_fg2023_code = '0' THEN 'Pas de Severite'
															ELSE 'Niveau ' || diagnostic_severite_fg2023_code END
															";}
				if ($groupby == 'TERSANTE') {$txt_field = "COALESCE(" . $txt_field . ", 'Non renseigné')";}
				if ($groupby == 'SEUIL_CANCERO' || $groupby == 'SEUIL_CANCERO_ROOT' || $groupby == 'SEUIL_CANCERO_PRINCIPAL_ROOT' || $groupby == 'SEUIL_CANCERO_PRINCIPAL') {$txt_field = "COALESCE(" . $txt_field . ", 'Hors Cancéro. soumise à seuil')";}
				if ($groupby == 'MENRUM') {$txt_field = $prefixe.'.mode_entree_rum_texte';}
				if ($groupby == 'MSORUM') {$txt_field = $prefixe.'.mode_sortie_rum_texte';}
				if ($groupby == 'PR') {$txt_field = "v_modes_entree_link.mode_entree_texte || CASE WHEN v_rss_1.provenance = '' THEN '' ELSE ' - ' || v_provenances_entree_link.provenance_texte END";}
				if ($groupby == 'DS') {$txt_field = "v_modes_sortie_link.mode_sortie_texte || CASE WHEN v_rss_1.destination = '' THEN '' ELSE ' - ' || v_destinations_sortie_link.destination_texte END";}

				if ($groupby == 'TX_REMB') {$txt_field = "v_rss_1.taux_remboursement::text || ' %'";}
				if ($groupby == 'ETAT_EPMSI') {$txt_field = "CASE 
				
																WHEN traitement_epmsi = '00' THEN 'Dossier en cours'
																WHEN traitement_epmsi = '11' THEN 'Non traités. CMD 90 hors 90H02Z et 90H03Z'
																WHEN traitement_epmsi = '12' THEN 'Non traités. Prestation inter_établissement'
																WHEN traitement_epmsi = '13' THEN 'Non traités. GHS 9999'
																WHEN traitement_epmsi = '14' THEN 'Sans titre'
																WHEN traitement_epmsi = '15' THEN 'Cohérence RSF'
																WHEN traitement_epmsi = '21' THEN 'Non valorisés. Pb chainage'
																WHEN traitement_epmsi = '22' THEN 'Non valorisés. Pb variable bloquante'
																WHEN traitement_epmsi = '23' THEN 'Non valorisés. Attente décision droits'
																WHEN traitement_epmsi = '24' THEN 'Non valorisés. Non facturables AM'
																WHEN traitement_epmsi = '25' THEN 'Non valorisés. Prélèvement organes patient décédé'
																WHEN traitement_epmsi = '26' THEN 'Non valorisés. Erreur inconnue (VALOSEJ)'
																WHEN traitement_epmsi = '30' THEN 'Valorisé'
																WHEN traitement_epmsi = '31' THEN 'Valorisé (AME)'
																WHEN traitement_epmsi = '32' THEN 'Valorisé (IVG)'
																WHEN traitement_epmsi = '33' THEN 'Valorisé (SU)'
																ELSE 'Code non répertorié' END
																";}
				if ($groupby == 'EXTDOC') {$txt_field = "CASE 
															WHEN extension_ccam = '1' THEN 'Anesthésie générale'
															WHEN extension_ccam = '2' THEN 'Anesthésie locorégionale péridurale ou épidurale'
															WHEN extension_ccam = '3' THEN 'Anesthésie locorégionale subarachnoïdienne [rachianesthésie]'
															WHEN extension_ccam = '4' THEN 'Anesthésie locorégionale plexique ou tronculaire'
															WHEN extension_ccam = '5' THEN 'Anesthésie locorégionale intraveineuse'
															WHEN extension_ccam = '6' THEN 'Anesthésie générale ou avec anesthésie locorégionale'
															ELSE 'Non renseigée'
															END";}
	
				return $txt_field . '::text';
			
			}	
			]]>
			</value>

	</COMPONENT>
</COMPONENTS>