<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000261" 
	label="PMSI. Etat des dossiers PMSI" 
	title="= 'Etat des dossiers PMSI par ' +  SELECT.GROUPBY_LABEL + ' de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL " 
	database="iCTI" 
	swf="*CTI_view1" 
	globals="PMSI_globals.XML" 
	componentsFile="PMSI_components.XML" 
	softCode="iCTI_pmsi"
	helpDokuWIkiDir="pmsi:sejours_analyse_globale:etat_des_dossiers_pmsi:" helpDokuWIkiFile="pmsi000261"  helpFile="">
	
	<VIEWPROPERTIES componentName="PROPERTIES_ETATDOSSIER" />
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE" />
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="">
			<FIELD name="VIEW_DATATYPE" UI="text" forceValue="ETATDOSSIER" visible="false"  />
		</GROUP>
		<GROUP label="Période">
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2014-01-01" globalListProvider="DATE_DEBUT" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" globalListProvider="DATE_FIN" />
		</GROUP>
		<GROUP label="Regroupements">
			<FIELD name="GROUPBY" width="220" label="" UI="combo" default="4" tree="true">
				<OPTION label="Options" data="" globalListProvider="RSS_GROUPBY_OPTIONS" />
			</FIELD>
			<FIELD name="GROUPBY_TAB" width="100" label="Présentation" UI="combo" default="AUTO" visible="= SELECT.GROUPBY_2 != '-1' ">
				<OPTION label="Automatique" data="AUTO" />
				<OPTION label="Arbre" data="TREE" />
				<OPTION label="Onglet" data="TAB" />
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_2" width="220" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1" treeLevel="1" />
				<OPTION label="Options" data="" globalListProvider="RSS_GROUPBY_OPTIONS" />
			</FIELD>
		</GROUP>		
        <GROUP label="">
			<FIELD name="GROUPBY_3" width="220" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de troisième niveau" data="-1" treeLevel="1" />
				<OPTION label="Options" data="" globalListProvider="RSS_GROUPBY_OPTIONS" />
			</FIELD>
		</GROUP>
	</SELECTIONS>

	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
	
	<QUERIES>
		<QUERY label=""> 
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[		

					CTISELECT_TREE
						GROUPBY1{[VIEW.SELECT_TABTREE_OID_FIELD],, [VIEW.SELECT_TABTREE_COD_FIELD],, [VIEW.SELECT_TABTREE_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{[VIEW.SELECT_TABTREE_2_OID_FIELD],, [VIEW.SELECT_TABTREE_2_COD_FIELD],, [VIEW.SELECT_TABTREE_2_TXT_FIELD]}
						GROUPBY3{[VIEW.SELECT_TABTREE_3_OID_FIELD],, [VIEW.SELECT_TABTREE_3_COD_FIELD],, [VIEW.SELECT_TABTREE_3_TXT_FIELD]}
						OPTIONS{NOTZERO=1}
						INDICATORS{
							COUNT(*),
							SUM(CASE WHEN en_cours = '0' THEN 1 ELSE 0 END),
							SUM(CASE WHEN en_cours IS DISTINCT FROM '0' THEN 1 ELSE 0 END),
							SUM(CASE WHEN en_cours IS DISTINCT FROM '0' AND 
								est_facture = '1' THEN 1 ELSE 0 END),
							SUM(CASE WHEN en_cours IS DISTINCT FROM '0' AND 
								est_facture IS DISTINCT FROM '1' AND 
								est_valide = '1' THEN 1 ELSE 0 END),
							SUM(CASE WHEN en_cours IS DISTINCT FROM '0' AND 
								est_facture IS DISTINCT FROM '1' AND 
								est_valide IS DISTINCT FROM '1' AND 
								est_groupe = '1' THEN 1 ELSE 0 END),
							SUM(CASE WHEN en_cours IS DISTINCT FROM '0' AND 
								est_facture IS DISTINCT FROM '1' AND 
								est_valide IS DISTINCT FROM '1' AND 
								est_groupe IS DISTINCT FROM '1' AND
								diagnostic_principal_id <> 0 THEN 1 ELSE 0 END),
							SUM(CASE WHEN en_cours IS DISTINCT FROM '0' AND 
								est_facture IS DISTINCT FROM '1' AND 
								est_valide IS DISTINCT FROM '1' AND 
								est_groupe IS DISTINCT FROM '1'  AND
								diagnostic_principal_id = 0 THEN 1 ELSE 0 END),
							base.cti_division(SUM((CASE WHEN est_groupe = '1' AND est_valide = '1' AND date_groupage <> '20991231' THEN date_groupage - date_sortie ELSE 0 END)*1), SUM(CASE WHEN est_groupe = '1' AND est_valide = '1' AND date_groupage <> '20991231' THEN 1 ELSE 0 END)),
						}	
					FROM #V_RSS_X#
					LEFT JOIN pmsi.p_rss_etat ON v_rss_1.rss_id = p_rss_etat.rss_id
					WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.FILTRE_RSS_SELECT]
					

				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="NRSA" />
					<FIELD name="NEXP" />
					<FIELD name="NNEX" />
					<FIELD name="NFAC" />
					<FIELD name="NVAL" />
					<FIELD name="NGRP" />
					<FIELD name="NSORDP" />
					<FIELD name="NSOR" />
					<FIELD name="DGRP" />
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Justificatif par RSS" shortLabel="Justificatif RSS" view="PMSI000260.XML" 
				componentName="RSS_BASE_VIEWLINK" >
				<ARG name="ETAT" value="if (COLUMN.NAME == 'NEXP') {return 'EX'}
										if (COLUMN.NAME == 'NNEX') {return 'NX'}
										if (COLUMN.NAME == 'NFAC') {return 'NXFA'}
										if (COLUMN.NAME == 'NVAL') {return 'NXNFVA'}
										if (COLUMN.NAME == 'NGRP') {return 'NXNFNVGR'}
										if (COLUMN.NAME == 'NSOR') {return 'NXNFNVNG'}
										if (COLUMN.NAME == 'NSORDP') {return 'NXNFNVNG'}
										return '-1'" />
			</VIEWLINK>
		</VIEWLINKS>		
		<ONGLET label="Onglet" multiTab="true" >

			<DATAGRID 	title="" 
						total="true" 
						headerHeight="60" 
						selectRowInRows="= ROW.OID == '-9999997'" 
						otherRowInRows="= ROW.OID == '-9999998'" 
						totalRowInRows="= ROW.OID == '-9999999'"
						variableRowHeight="true" 
						sortable="= SELECT.GROUPBY_3 == '-1' || SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'"> 
				
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				
				<COLUMN dataField="OID"
					type="Number"
					visible="false" />
				<COLUMN dataField="COD" 
					type="Char" 
					width="60"
					outputFormat="#"
					headerText="Code" 
					textAlign="left" 
					totalComplement="*ROW">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" 
					type="Char" 
					minWidth="110"
					headerText="Texte" 
					textAlign="left" 
					totalComplement="*ROW"/>
					
				
				<COLUMN dataField="NRSA" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Séjours sortis" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NEXP" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Expédiés" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NNEX" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Non Expédiés" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NFAC" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Facturés Non Expédiés" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NVAL" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Validés Non Facturés" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NGRP" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Groupés Non Validés" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NSORDP" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Sortis Non Groupés (avec DP)" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NSOR" 
					type="Number" 
					width="80"
					outputFormat="#"
					selectable="true"
					headerText="Dont Sortis Non Groupés (sans DP)" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="DGRP" 
					type="Number" 
					width="80"
					outputFormat="#,0j"
					headerText="Délai groupage" 
					textAlign="right"
					totalComplement="*ROW" />
			
				
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
