<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="COMPTA000050" 
	label="Compta. Analyse coût patient SHS" 
	title="= 'Coût patient SHS par ' +  SELECT.GROUPBY_LABEL + ' de ' + SELECT.MOIS_LABEL + ' à ' + SELECT.TOMOIS_LABEL " 
	database="iCTI" 
	swf="*CTI_view1" 
	globals="COMPTA_globals.XML"
	componentsFile="COMPTA_components.XML"
	dboptimizer="COMPTA_dboptimizer.XML"
	softCode="iCTI_compta"
	softOption="iCTI_compta_analytique_shs">
	
	<VIEWPROPERTIES componentName="PROPERTIES_COUT_PATIENT"/>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Période">
			<FIELD name="MOIS" label="" UI="combo" width="250" default="201001" globalListProvider="MOIS">
			</FIELD>
			<FIELD name="TOMOIS" label="" UI="combo" width="250" default="201001" globalListProvider="MOIS">
			</FIELD>
		</GROUP>
		
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" label="" UI="combo" width="200" default="CSC" tree="true">
				<OPTION label="Elément de coût" data="CSC" treeLevel="1"  globalListProvider="CSC_GROUPBY_OPTION"/>
				<OPTION label="Unité d'oeuvre" data="CSU" treeLevel="1"  globalListProvider="CSU_GROUPBY_OPTION"/>
				<OPTION label="GHM" data="CSG" treeLevel="1"  globalListProvider="CSG_GROUPBY_OPTION"/>
				<OPTION label="Service" data="CSF" treeLevel="1"  globalListProvider="CSF_GROUPBY_OPTION"/>
				<OPTION label="Activité" data="CSA" treeLevel="1"  globalListProvider="CSA_GROUPBY_OPTION"/>
				<OPTION label="Etage" data="CSE" treeLevel="1"  globalListProvider="CSE_GROUPBY_OPTION"/>
				<OPTION label="Médecin" data="CSM" treeLevel="1"  globalListProvider="CSM_GROUPBY_OPTION"/>
				<OPTION label="Mois" data="MOI" treeLevel="1"  />
				<OPTION label="Exercice" data="EXE" treeLevel="2"  />
			</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" label="" width="200" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1"/>
				<OPTION label="Elément de coût" data="CSC" treeLevel="1"  globalListProvider="CSC_GROUPBY_OPTION"/>
				<OPTION label="Unité d'oeuvre" data="CSU" treeLevel="1"  globalListProvider="CSU_GROUPBY_OPTION"/>
				<OPTION label="GHM" data="CSG" treeLevel="1"  globalListProvider="CSG_GROUPBY_OPTION"/>
				<OPTION label="Service" data="CSF" treeLevel="1"  globalListProvider="CSF_GROUPBY_OPTION"/>
				<OPTION label="Activité" data="CSA" treeLevel="1"  globalListProvider="CSA_GROUPBY_OPTION"/>
				<OPTION label="Etage" data="CSE" treeLevel="1"  globalListProvider="CSE_GROUPBY_OPTION"/>
				<OPTION label="Médecin" data="CSM" treeLevel="1"  globalListProvider="CSM_GROUPBY_OPTION"/>
				<OPTION label="Mois" data="MOI" treeLevel="1"  />
				<OPTION label="Exercice" data="EXE" treeLevel="2"  />
			</FIELD>
		</GROUP>
	</SELECTIONS>
	

	<SELECTIONS componentName="FILTRES_COUT_PATIENT"/>
	
	<QUERIES>
		<QUERY label=""> 
			<SQL>
				<select><![CDATA[		

					CTISELECT_TREE
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
						INDICATORS{
							COUNT(DISTINCT v_couts_patient_shs_1.no_sejour),
							SUM(v_couts_patient_shs_1.cout),
							SUM(v_couts_patient_shs_1.montant_facture),
							SUM(v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout),
							base.cti_division(
								SUM(v_couts_patient_shs_1.cout),
								COUNT(DISTINCT v_couts_patient_shs_1.no_sejour)
							),
							base.cti_division(
								SUM(v_couts_patient_shs_1.montant_facture),
								COUNT(DISTINCT v_couts_patient_shs_1.no_sejour)
							),
							base.cti_division(
								SUM(v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout),
								COUNT(DISTINCT v_couts_patient_shs_1.no_sejour)
							)
						}	
					FROM compta.v_couts_patient_shs_1
					WHERE v_couts_patient_shs_1.mois_comptable_id BETWEEN [MOIS] AND [TOMOIS]
						[VIEW.COUT_PATIENT_SELECT]
						

				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="NSEJ" />
					<FIELD name="MCOU" />
					<FIELD name="MFAC" />
					<FIELD name="MRES" />
					<FIELD name="MMCOU" />
					<FIELD name="MMFAC" />
					<FIELD name="MMRES" />
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINKx label="Justificatif des arrêts" shortLabel="Justificatif des arrêts" view="RH000011.XML" componentName="RH_VIEWLINK" >
				<ARGS name="SPEC" >
					<value><![CDATA[
						LINKVARIABLES['GROUPBY_2'] = 'SAL'
						return 'OK';
			
					]]></value>
				</ARGS>
			</VIEWLINKx>
		</VIEWLINKS>		
		<ONGLET label="Onglet" multiTab="true" >


			<CHART title="Coût patient" 
				type="columnChart" 
				subType="" 
				maxItems="20" 
				maxItemsSortOn="MFAC" 
				maxItemsSortSeq="D" 
				sortField="COD" 
				sortSeq="A" 
				condition="ROW.LVL == '1'"
				visibleCondition="SELECT.GROUPBY != 'MOIPAI' &amp;&amp; SELECT.GROUPBY != 'ANNPAI'"
				>
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="MCOU" displayName="Coût"/>
				<SERIE field="MFAC" displayName="Facturé"/>

			</CHART>
			
			<CHART title="Coût patient" 
				type="lineChart" 
				subType="" 
				maxItems="20" 
				maxItemsSortOn="COD" 
				maxItemsSortSeq="D" 
				sortField="COD" 
				sortSeq="A" 
				condition="ROW.LVL == '1'"
				visibleCondition="SELECT.GROUPBY == 'MOI' || SELECT.GROUPBY == 'EXE'"
				>
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="MCOU" displayName="Coût"/>
				<SERIE field="MFAC" displayName="Facturé"/>
			</CHART>
			
				
			<DATAGRID 	title="" 
						total="true" 
						headerHeight="54" 
						selectRowInRows="= ROW.OID == '-9999997'" 
						otherRowInRows="= ROW.OID == '-9999998'" 
						totalRowInRows="= ROW.OID == '-9999999'"
						variableRowHeight="true" 
						sortable="= 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="NSEJ" 
					type="Number" 
					width="60"
					outputFormat="#"
					headerText="Séjours" 
					textAlign="right"
					totalComplement="*ROW" />	
				
				<COLUMN dataField="MCOU" 
					type="Number" 
					width="80"
					outputFormat="#E"
					headerText="Coût" 
					textAlign="right"
					totalComplement="*ROW" />	
				<COLUMN dataField="MFAC" 
					type="Number" 
					width="80"
					outputFormat="#E"
					headerText="Facturé" 
					textAlign="right"
					totalComplement="*ROW" />	
				<COLUMN dataField="MRES" 
					type="Number" 
					width="80"
					outputFormat="#E"
					headerText="Résultat" 
					textAlign="right"
					totalComplement="*ROW" />	
				
				<COLUMN dataField="MMCOU" 
					type="Number" 
					width="80"
					outputFormat="#E"
					headerText="Coût moyen" 
					textAlign="right"
					totalComplement="*ROW" />	
				<COLUMN dataField="MMFAC" 
					type="Number" 
					width="80"
					outputFormat="#E"
					headerText="Facturé moyen" 
					textAlign="right"
					totalComplement="*ROW" />	
				<COLUMN dataField="MMRES" 
					type="Number" 
					width="80"
					outputFormat="#E"
					headerText="Résultat moyen" 
					textAlign="right"
					totalComplement="*ROW" />	
				
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
