<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ACTI00091" 
	label="Interventions ARS Bretagne" 
	title="= 'Interventions ARS Bretagne ('  +  SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" database="iCTI" swf="*CTI_view1" 
	softCode="iCTI_activite"
	globals="ACTI_globals.XML"
	componentsFile="ACTI_components.XML"
    helpFile="iCTI_ACTI_ACTI000091.HTML"
    helpDokuWIkiDir="activite:qualite:etudes:interventions" 
    helpDokuWIkiFile="acti00091" 
    admProvider="r2i"
>

	<VIEWPROPERTIES>
		<PROPERTYx dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
		<PROPERTY name="TYP_SEJ" value="[EVAL 
		
			$select = '';
			if ('[TYP_H]' != 'H') {
				$select .= ' AND upper(substr(SEJO_NUM_SEJ, 1, 1)) != \'H\' ';
			}
			if ('[TYP_J]' != 'J') {
				$select .= ' AND upper(substr(SEJO_NUM_SEJ, 1, 1)) != \'J\' ';
			}
			if ('[TYP_E]' != 'E') {
				$select .= ' AND upper(substr(SEJO_NUM_SEJ, 1, 1)) != \'E\' ';
			}
			
			return $select;
			
		EVAL]"/>
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="= 
		var display:String = '';
		
		if (SELECT.TYP_H != 'H') {
			display += 'sans Hospitalisation ';
		}
		if (SELECT.TYP_J != 'J') {
			display += 'sans Ambulatoire ';
		}
		if (SELECT.TYP_E != 'E') {
			display += 'sans Externe ';
		}
				
		if (display != '') {
			display = '#B#Filtres #/B# = ' + display;
		}
		return display;
		" 
	>
		<GROUP>
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
            <FIELD name="PERIODE" label="Période" UI="combo" tree="true" width="150" default="2007-01-01"  globalListProvider="DATE_DEBUT" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="150" default="2007-01-31"  globalListProvider="DATE_FIN" >
			</FIELD>
		</GROUP>
		<GROUP label="Type séjour">
			<FIELD name="TYP_H" label="Hospitalisation" UI="check" selectedValue="H" unselectedValue="" default="H"  showIfNotDefault="true"/>
			<FIELD name="TYP_J" label="Ambulatoire" UI="check" selectedValue="J" unselectedValue="" default="J"  showIfNotDefault="true"/>
			<FIELD name="TYP_E" label="Externe" UI="check" selectedValue="E" unselectedValue="" default="E" showIfNotDefault="true"/>
		</GROUP>
	</SELECTIONS>


	<QUERIES>
	
		<QUERY label=""> 

			<SQL>
				<select><![CDATA[	
					SELECT 
						SEJO_NUM_SEJ,
						PATI_NOM_USU || ' ' || PATI_PRENOM,
						date(PATI_DAT_NAI),
						date(ACSA_DAT_EXE_DEB), 
						date_part('hour',ACSA_DAT_EXE_DEB),
						base.cti_group_concat(DISTINCT CASE WHEN ACSA_COD_ACT_D <> '4' AND t_ccam_regroupements.code <> 'ADA' THEN MEDE_NOM_USU || ' ' || COALESCE(MEDE_PRENOM,'') ELSE NULL END),
						base.cti_group_concat(DISTINCT CASE WHEN ACSA_COD_ACT_D <> '4' AND t_ccam_regroupements.code <> 'ADA' THEN ACSA_CODE_D ELSE NULL END),
						base.cti_group_concat(DISTINCT CASE WHEN ACSA_COD_ACT_D <> '4' AND t_ccam_regroupements.code <> 'ADA' THEN ACSA_CODE_D||' : '||t_actes.texte ELSE NULL END),
						base.cti_group_concat(DISTINCT CASE WHEN ACSA_COD_ACT_D = '4' OR t_ccam_regroupements.code = 'ADA' THEN MEDE_NOM_USU || ' ' || COALESCE(MEDE_PRENOM,'') ELSE NULL END),
						base.cti_group_concat(DISTINCT CASE WHEN ACSA_COD_ACT_D = '4' OR t_ccam_regroupements.code = 'ADA' THEN ACSA_CODE_D ELSE NULL END)


						FROM prod_hm.SAD_ACTIVITE_SAISIES
							JOIN prod_hm.IDE_SEJOUR ON ACSA_ID_SEJO = SEJO_ID_SEJO
							JOIN prod_hm.IDE_PATIENT ON SEJO_ID_PATI = PATI_ID_PATI
							JOIN prod_hm.IDE_MEDECIN ON ACSA_ID_MEDE = MEDE_ID_MEDE
							JOIN base.t_actes ON ACSA_CODE_D = t_actes.code
							JOIN base.t_ccam_regroupements ON ccam_regroupement_id_1 = t_ccam_regroupements.oid

						WHERE date(ACSA_DAT_EXE_DEB) BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND
							(t_actes.classant = 'Y' OR t_ccam_regroupements.code IN ('ADC', 'ADA', 'ACO'))
							[VIEW.TYP_SEJ]

						GROUP BY 1,2,3,4,5
	
				
				]]></select>	
				<FIELDS>
					<FIELD name="SEJ" />
					<FIELD name="NOM" ifHideNames="Non autorisé" />
					<FIELD name="NAI" />
					<FIELD name="DAT" />
					<FIELD name="HEU" />
					<FIELD name="EXEC" />
					<FIELD name="ACTC" />
					<FIELD name="ACTT" />
					<FIELD name="EXEA" />
					<FIELD name="ACTA" />
					
				</FIELDS>
			</SQL>
			
		</QUERY>
		
		
		
		
		
		
	</QUERIES>
	
	<PRESENTATION>
	
		<VIEWLINKS>
		
			
		
		</VIEWLINKS>
	
		<ONGLET excelLabel="Interventions ARS" label="Interventions ARS" >
				
			<DATAGRID title="" total="false" headerHeight="54" >
				
				<COLUMN dataField="SEJ"
					width="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Séjour" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="NOM"
					minWidth="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Nom" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="NAI"
					width="70"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					visible="true"
					fixed="false"
					headerText="Date naissance" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="DAT"
					width="70"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					visible="true"
					fixed="false"
					headerText="Date intervention" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="HEU"
					width="70"
					type="Number"
					outputFormat="00"
					visible="true"
					fixed="false"
					headerText="Heure" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="EXEC"
					minWidth="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Exécutant" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="ACTC"
					minWidth="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Actes" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="ACTT"
					minWidth="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Actes texte" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="EXEA"
					minWidth="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Anesthésiste" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				
				<COLUMN dataField="ACTA"
					minWidth="100"
					type="Char"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Actes Anesthésies" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
			</DATAGRID>
		
		</ONGLET>
		
				
				
	</PRESENTATION>
	
</VUE>

			
