<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000014" label="PMSI. Evolution annuelle DMS" title="= 'Evolution annuelle DMS par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.ANNEE_LABEL + ') - ' + SELECT.VERSION_GROUPAGE_LABEL" database="iCTI" swf="*CTI_view1" softCode="iCTI_pmsi" globals="PMSI_globals.XML" componentsFile="PMSI_components.XML" helpDokuWIkiDir="pmsi:sejours_analyse_globale:dms:ecart_dms" helpDokuWIkiFile="pmsi000014"  helpFile="iCTI_PMSI_PMSI000014.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_RSS"/>
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE"/>
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
		<PROPERTY name="ORDERBY">
			<value><![CDATA[[EVAL 
			
				if ('[GROUPBY_2]' != '-1' && '[GROUPBY]' != '-1' && '[GROUPBY_TAB]' != 'TAB') {
					return 'ORDER BY 2,5,7';
				}
				else {
					return 'ORDER BY 17 DESC,5,7';
				}
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="ANNEE2">
			<value><![CDATA[[EVAL 
					return intval('[ANNEE]') - 2;
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Année de référence">
			<FIELD name="ANNEE" label="" UI="combo" width="100" default="2014" default2="2013" printable="false">
				<OPTION dataLink="ANNEE" dataField="aa" data2Field="aa2" labelField="aa"/>
			</FIELD>
		</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"/>
				<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"/>
				<OPTION label="Options" data="" globalListProvider="RSS_GROUPBY_OPTIONS"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="SHOWDMSREF" label="" width="1" UI="text" default="1" printable="false" visible="false"/>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SOUSSELECTIONS_ANNEE"/>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" cacheEnabled="true" select="
				SELECT [VIEW.SELECT_TABTREE_COLUMNS],
				
					CASE WHEN sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END) &gt; 0
						THEN
							sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 AND cmd_code &lt;&gt; '28' THEN [VIEW.DMS_FIELD] * nb_rsa ELSE 0 END)
							/ sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END)
						ELSE 0 END,
					sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 2 THEN nb_rsa ELSE 0 END),
					CASE WHEN sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 2 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END) &gt; 0
						THEN
							sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 2 AND cmd_code &lt;&gt; '28' THEN duree_sejour * nb_rsa ELSE 0 END)
							/ sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 2 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END)
						ELSE 0 END,
					sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 1 THEN nb_rsa ELSE 0 END),
					CASE WHEN sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 1 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END) &gt; 0
						THEN
							sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 1 AND cmd_code &lt;&gt; '28' THEN duree_sejour * nb_rsa ELSE 0 END)
							/ sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 1 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END)
						ELSE 0 END,
					sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 THEN nb_rsa ELSE 0 END),
					CASE WHEN sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END) &gt; 0
						THEN
							sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 AND cmd_code &lt;&gt; '28' THEN duree_sejour * nb_rsa ELSE 0 END)
							/ sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 AND cmd_code &lt;&gt; '28' THEN nb_rsa ELSE 0 END)
						ELSE 0 END,
					sum(CASE WHEN [ANNEE] - extract(year from date_sortie) = 0 THEN base_remboursement ELSE 0 END)
					
				FROM #V_RSS_X#, [VIEW.SELECT_TABTREE_VIEW]
				WHERE 
					date_sortie &gt;= '[VIEW.ANNEE2]-01-01'	AND date_sortie &lt;='[ANNEE]-12-31'
				
					[VIEW.FILTRE_RSS_SELECT]
					[VIEW.SELECT_TABTREE_WHERE]
					
				GROUP BY 1,2,3,4,5,6,7,8,9,10,11
				[VIEW.ORDERBY]
					">
				<FIELDS>
					<FIELD name="TABD"/>
					<FIELD name="TABDL"/>
					<FIELD name="TABDLL"/>
					<FIELD name="OID1"/>
					<FIELD name="COD1"/>
					<FIELD name="OID2"/>
					<FIELD name="COD2"/>
					<FIELD name="OID"/>
					<FIELD name="COD"/>
					<FIELD name="TXT"/>
					<FIELD name="LVL"/>
					<FIELD name="DMSNAT"/>
					<FIELD name="N2"/>
					<FIELD name="DMS2"/>
					<FIELD name="N1"/>
					<FIELD name="DMS1"/>
					<FIELD name="N0"/>
					<FIELD name="DMS0"/>
					<FIELD name="CA0"/>
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL select="SELECT DISTINCT 'A' || [ANNEE] - annee, annee 
						FROM base.p_calendrier_mois
						WHERE annee &gt;= [VIEW.ANNEE2] AND annee &lt;= [ANNEE]
						">
				<FIELDS>
					<FIELD name="name"/>
					<FIELD name="value"/>
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="comboLink" name="ANNEE" forRows="false">
			<SQL select="SELECT DISTINCT p_calendrier_mois.annee, p_calendrier_mois.annee - 2
							FROM base.p_calendrier_mois, pmsi.p_chiffrier 
							WHERE p_calendrier_mois.mois = p_chiffrier.mois 
							ORDER by annee
							">
				<FIELDS>
					<FIELD name="aa"/>
					<FIELD name="aa2"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000005.XML" componentName="RSS_BASE_VIEWLINK">
				<ARG name="PERIODE" value="SELECT.ANNEE + '-01-01'"/>
				<ARG name="TOPERIODE" value="SELECT.ANNEE + '-12-31'"/>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Analyse DMS" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
			<CHART title="Décomposition des plus fréquents" type="columnChart" subType="" maxItems="20" sortField="N0" sortSeq="D" visibleCondition="SELECT.GROUPBY != 'AMSOR' &amp;&amp; SELECT.GROUPBY != 'MSOR'" condition="ROW.LVL == '1'">
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="DMS2" displayName="'DMS ' + VIEW.A2" displayNameCalc="true"/>
				<SERIE field="DMS1" displayName="'DMS ' + VIEW.A1" displayNameCalc="true"/>
				<SERIE field="DMS0" displayName="'DMS ' + VIEW.A0" displayNameCalc="true"/>
				<SERIE field="DMSNAT" displayName="DMS Ref"/>
			</CHART>
			<CHART title="Décomposition des plus rémunérateurs" type="columnChart" subType="" maxItems="20" sortField="CA0" sortSeq="D" visibleCondition="SELECT.GROUPBY != 'AMSOR' &amp;&amp; SELECT.GROUPBY != 'MSOR'" condition="ROW.LVL == '1'">
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="DMS2" displayName="'DMS ' + VIEW.A2" displayNameCalc="true"/>
				<SERIE field="DMS1" displayName="'DMS ' + VIEW.A1" displayNameCalc="true"/>
				<SERIE field="DMS0" displayName="'DMS ' + VIEW.A0" displayNameCalc="true"/>
				<SERIE field="DMSNAT" displayName="DMS Ref"/>
			</CHART>
			<CHART title="Evolution" type="columnChart" subType="" maxItems="36" maxItemsSortOn="COD" maxItemsSortSeq="D" sortField="COD" sortSeq="A" visibleCondition="SELECT.GROUPBY == 'AMSOR' || SELECT.GROUPBY == 'MSOR'" condition="ROW.LVL == '1'">
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="DMS2" displayName="'DMS ' + VIEW.A2" displayNameCalc="true"/>
				<SERIE field="DMS1" displayName="'DMS ' + VIEW.A1" displayNameCalc="true"/>
				<SERIE field="DMS0" displayName="'DMS ' + VIEW.A0" displayNameCalc="true"/>
				<SERIE field="DMSNAT" displayName="DMS Ref"/>
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="36" variableRowHeight="true" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'"
				sortable="= SELECT.GROUPBY_3 == '-1' &amp;&amp; (SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB')">
				<ROWSTYLE name="fontSize" value="11"/>
				<FOOTERROWSTYLE name="fontSize" value="11"/>
				<ROWSTYLE name="rowHeight" value="20" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="backgroundColor" value="0xFFD393" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="borderSides" value="top bottom" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="borderStyle" value="solid" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="borderThickness" value="2" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<COLUMN dataField="LVL" width="50" type="Char" visible="false" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="OID1" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD1" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="OID2" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD2" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="70" type="Char" visible="true" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
					<CELLSTYLE name="paddingLeft" value="15" condition="ROW.LVL == '2' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="200" headerText="Texte" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="Autres">
				</COLUMN>
				<COLUMN dataField="N2" width="60" type="Number" outputFormat="#" headerText="'Séjours     ' + VIEW.A2" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="DMS2" type="Number" headerText="'DMS     ' + VIEW.A2" headerTextCalc="true" width="50" outputFormat="#,0" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="N1" width="60" type="Number" outputFormat="#" headerText="'Séjours     ' + VIEW.A1" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="DMS1" type="Number" headerText="'DMS    ' + VIEW.A1" headerTextCalc="true" width="50" outputFormat="#,0" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum">
					<CELLSTYLE name="color" value="0xFF0000" condition="ROW.P_DMS1 &gt; 1"/>
					<CELLSTYLE name="color" value="0x009900" condition="ROW.P_DMS1 &lt; -1"/>
					<CELLSTYLE name="fontWeight" value="bold" condition="ROW.P_DMS1 &lt; -10 || ROW.P_DMS1 &gt; 10"/>
				</COLUMN>
				<COLUMN dataField="P_DMS1" type="Number" headerText="'% ' + VIEW.A1 + ' / ' + VIEW.A2" headerTextCalc="true" width="60" outputFormat="#,0%" fixed="false" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC dataField="DMS2"/>
					<CALC dataField="DMS1" operator="%+"/>
					<CELLSTYLE name="color" value="0xFF0000" condition="ROW.P_DMS1 &gt; 1"/>
					<CELLSTYLE name="color" value="0x009900" condition="ROW.P_DMS1 &lt; -1"/>
					<CELLSTYLE name="fontWeight" value="bold" condition="ROW.P_DMS1 &lt; -10 || ROW.P_DMS1 &gt; 10"/>
				</COLUMN>
				<COLUMN dataField="N0" width="60" type="Number" outputFormat="#" headerText="'Séjours   ' + VIEW.A0" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="CA0" width="70" type="Number" outputFormat="#" visible="false" headerText="CA" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="DMS0" type="Number" headerText="'DMS    ' + VIEW.A0" headerTextCalc="true" width="50" outputFormat="#,0" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum">
					<CELLSTYLE name="color" value="0xFF0000" condition="ROW.P_DMS0 &gt; 1"/>
					<CELLSTYLE name="color" value="0x009900" condition="ROW.P_DMS0 &lt; -1"/>
					<CELLSTYLE name="fontWeight" value="bold" condition="ROW.P_DMS0 &lt; -10 || ROW.P_DMS0 &gt; 10"/>
				</COLUMN>
				<COLUMN dataField="P_DMS0" type="Number" headerText="'% ' + VIEW.A0 + ' / ' + VIEW.A1" headerTextCalc="true" width="50" outputFormat="#,0%" fixed="false" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC dataField="DMS1"/>
					<CALC dataField="DMS0" operator="%+"/>
					<CELLSTYLE name="color" value="0xFF0000" condition="ROW.P_DMS0 &gt; 1"/>
					<CELLSTYLE name="color" value="0x009900" condition="ROW.P_DMS0 &lt; -1"/>
					<CELLSTYLE name="fontWeight" value="bold" condition="ROW.P_DMS0 &lt; -10 || ROW.P_DMS0 &gt; 10"/>
				</COLUMN>
				<COLUMN dataField="DMSNAT" type="Number" headerText="DMS Ref" width="50" outputFormat="#,0" fixed="false" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="P_DMS" type="Number" headerText="'% ' + VIEW.A0 + ' / DMS Ref'" headerTextCalc="true" width="60" outputFormat="#,0%" fixed="false" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC dataField="DMSNAT"/>
					<CALC dataField="DMS0" operator="%+"/>
					<CELLSTYLE name="color" value="0xFF0000" condition="ROW.P_DMS &gt; 1"/>
					<CELLSTYLE name="color" value="0x009900" condition="ROW.P_DMS &lt; -1"/>
					<CELLSTYLE name="fontWeight" value="bold" condition="ROW.P_DMS &lt; -10 || ROW.P_DMS &gt; 10"/>
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
