<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="COMPTA000051" 
	label="Compta. Analyse coût patient SHS" 
	title="= SELECT.DATA_LABEL + ' (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"/>
	
	<VIEWPROPERTIES>
		<PROPERTY name="TDATA">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'MCOU':
									return 'SUM(v_couts_patient_shs_1.cout)';
									break;
								case 'MFAC':
									return 'SUM(v_couts_patient_shs_1.montant_facture)';
									break;
								case 'MRES':
									return 'SUM(v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout)';
									break;
								case 'MMCOU':
									return 'base.cti_division(
												SUM(v_couts_patient_shs_1.cout),
												COUNT(DISTINCT v_couts_patient_shs_1.no_sejour)
											)';
									break;
								case 'MMFAC':
									return 'base.cti_division(
												SUM(v_couts_patient_shs_1.montant_facture),
												COUNT(DISTINCT v_couts_patient_shs_1.no_sejour)
											)';
									break;
								case 'MMRES':
									return '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)
											)';
									break;
								default:
									return 'SUM(v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout)';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="CDATA">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								
								case 'MCOU':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.cout ELSE NULL END)';
									break;
								case 'MFAC':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.montant_facture ELSE NULL END)';
									break;
								case 'MRES':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout ELSE NULL END)';
									break;
									
								case 'MMCOU':
									return 'base.cti_division(
												SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.cout ELSE NULL END),
												COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.no_sejour ELSE NULL END)
											)';
									break;
								case 'MMFAC':
									return 'base.cti_division(
												SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.montant_facture ELSE NULL END),
												COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.no_sejour ELSE NULL END)
											)';
									break;
								case 'MMRES':
									return 'base.cti_division(
												SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout ELSE NULL END),
												COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.no_sejour ELSE NULL END)
											)';
									break;
									
								default:
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN v_couts_patient_shs_1.montant_facture - v_couts_patient_shs_1.cout ELSE NULL END)';
								}
					EVAL]]]></value>
		</PROPERTY>

		
	</VIEWPROPERTIES>
	
	<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>
			<FIELD name="DATA" label="Donnée" UI="combo" default="MRES">
				<OPTION label="Résultat" data="MRES" data2="#E"/>
				<OPTION label="Coût" data="MCOU" data2="#E"/>
				<OPTION label="Montant facturé" data="MFAC" data2="#E"/>
				<OPTION label="Résultat moyen" data="MMRES" data2="#E"/>
				<OPTION label="Coût moyen" data="MMCOU" data2="#E"/>
				<OPTION label="Montant facturé moyen" data="MMFAC" data2="#E"/>
			</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>
		<GROUP label="Colonnes">
			<FIELD name="COLUMNBY" label="" UI="combo" width="200" default="CSU" tree="true">
				<OPTION label="Elément de coût" data="CSC" treeLevel="1"  globalListProvider="CSC_GROUPBY_OPTION"/>
				<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="COLUMNBYCOUNT" label="Nombre" UI="combo" default="10" tree="false">
				<OPTION label="5" data="5"/>
				<OPTION label="6" data="6"/>
				<OPTION label="7" data="7"/>
				<OPTION label="8" data="8"/>
				<OPTION label="9" data="9"/>
				<OPTION label="10" data="10"/>
				<OPTION label="11" data="11"/>
				<OPTION label="12" data="12"/>
				<OPTION label="13" data="13"/>
				<OPTION label="14" data="14"/>
				<OPTION label="15" data="15"/>
				<OPTION label="16" data="16"/>
				<OPTION label="17" data="17"/>
				<OPTION label="18" data="18"/>
				<OPTION label="19" data="19"/>
				<OPTION label="20" data="20"/>
			</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]}
						COLUMNBYOID{[VIEW.COLUMNBY_OID_FIELD],, [VIEW.COLUMNBY_COD_FIELD] ,, [VIEW.COLUMNBY_TXT_FIELD],, 1 ,, [COLUMNBYCOUNT]}
						INDICATORS{[VIEW.TDATA],}	
						INDICATORS_COLUMNS{[VIEW.CDATA], }
					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="N"/>
					<FIELD name="N1"/>
					<FIELD name="N2"/>
					<FIELD name="N3"/>
					<FIELD name="N4"/>
					<FIELD name="N5"/>
					<FIELD name="N6"/>
					<FIELD name="N7"/>
					<FIELD name="N8"/>
					<FIELD name="N9"/>
					<FIELD name="N10"/>
					<FIELD name="N11"/>
					<FIELD name="N12"/>
					<FIELD name="N13"/>
					<FIELD name="N14"/>
					<FIELD name="N15"/>
					<FIELD name="N16"/>
					<FIELD name="N17"/>
					<FIELD name="N18"/>
					<FIELD name="N19"/>
					<FIELD name="N20"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			
		</VIEWLINKS>
		<ONGLET excelLabel="Evolution mensuelle" label="Evolution mensuelle" multiTab="true">
			<CHARTx title="Evolution (Total)" type="lineChart" serieIsCategory="true" fromTotal="true">
				<CATEGORY field="TXT" type="Char"/>
				<SERIE field="N1" displayName="VIEW.COLH1" displayNameCalc="true" visibleCondition="VIEW.COLH1 != null"/>
				<SERIE field="N2" displayName="VIEW.COLH2" displayNameCalc="true" visibleCondition="VIEW.COLH2 != null"/>
				<SERIE field="N3" displayName="VIEW.COLH3" displayNameCalc="true" visibleCondition="VIEW.COLH3 != null"/>
				<SERIE field="N4" displayName="VIEW.COLH4" displayNameCalc="true" visibleCondition="VIEW.COLH4 != null"/>
				<SERIE field="N5" displayName="VIEW.COLH5" displayNameCalc="true" visibleCondition="VIEW.COLH5 != null"/>
				<SERIE field="N6" displayName="VIEW.COLH6" displayNameCalc="true" visibleCondition="VIEW.COLH6 != null"/>
				<SERIE field="N7" displayName="VIEW.COLH7" displayNameCalc="true" visibleCondition="VIEW.COLH7 != null"/>
				<SERIE field="N8" displayName="VIEW.COLH8" displayNameCalc="true" visibleCondition="VIEW.COLH8 != null"/>
				<SERIE field="N9" displayName="VIEW.COLH9" displayNameCalc="true" visibleCondition="VIEW.COLH9 != null"/>
				<SERIE field="N10" displayName="VIEW.COLH10" displayNameCalc="true" visibleCondition="VIEW.COLH10 != null"/>
				<SERIE field="N11" displayName="VIEW.COLH11" displayNameCalc="true" visibleCondition="VIEW.COLH11 != null"/>
				<SERIE field="N12" displayName="VIEW.COLH12" displayNameCalc="true" visibleCondition="VIEW.COLH12 != null"/>
			</CHARTx>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="36" variableRowHeight="true" sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'">
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="60" type="Char" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="50" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="N" width="80" visible="true" type="Number" outputFormat="= SELECT.DATA2" headerText="Total" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="N_P" type="Number" headerText="% / Total" width="40" outputFormat="0%" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.N / TOTALROW.N * 100"/>
				</COLUMN>

				<COLUMN dataField="N1" width="70" visibleCondition="VIEW.COLH1 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH1" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N2" width="70" visibleCondition="VIEW.COLH2 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N3" width="70" visibleCondition="VIEW.COLH3 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH3" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N4" width="70" visibleCondition="VIEW.COLH4 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH4" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N5" width="70" visibleCondition="VIEW.COLH5 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH5" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N6" width="70" visibleCondition="VIEW.COLH6 != null" type="Number" selectable="true" outputFormat="#" fixed="false" headerText="VIEW.COLH6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N7" width="70" visibleCondition="VIEW.COLH7 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH7" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N8" width="70" visibleCondition="VIEW.COLH8 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH8" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N9" width="70" visibleCondition="VIEW.COLH9 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH9" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N10" width="70" visibleCondition="VIEW.COLH10 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH10" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N11" width="70" visibleCondition="VIEW.COLH11 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH11" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N12" width="70" visibleCondition="VIEW.COLH12 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH12" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N13" width="70" visibleCondition="VIEW.COLH13 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH13" columnData="= VIEW.COLI13" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N14" width="70" visibleCondition="VIEW.COLH14 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH14" columnData="= VIEW.COLI14" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N15" width="70" visibleCondition="VIEW.COLH15 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH15" columnData="= VIEW.COLI15" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N16" width="70" visibleCondition="VIEW.COLH16 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH16" columnData="= VIEW.COLI16" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N17" width="70" visibleCondition="VIEW.COLH17 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH17" columnData="= VIEW.COLI17" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N18" width="70" visibleCondition="VIEW.COLH18 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH18" columnData="= VIEW.COLI18" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N19" width="70" visibleCondition="VIEW.COLH19 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH19" columnData="= VIEW.COLI19" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N20" width="70" visibleCondition="VIEW.COLH20 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH20" columnData="= VIEW.COLI20" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
