<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000032" label="PMSI. Comparaison Actes" title="= 'Comparaison Actes par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.QUELLEDATE_LABEL + ' : ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ' vs ' + SELECT.PERIODE_D_LABEL + ' à ' + SELECT.TOPERIODE_D_LABEL + ') - ' + SELECT.VERSION_GROUPAGE_LABEL" database="iCTI" swf="*CTI_view1" softCode="iCTI_pmsi" globals="PMSI_globals.XML" componentsFile="PMSI_components.XML" helpDokuWIkiDir="pmsi:sejour_analyse_detaillee:actes" helpDokuWIkiFile="pmsi000029"  helpFile="iCTI_PMSI_PMSI000032.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_ACTES" />
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE" />
	<VIEWPROPERTIES>
		<PROPERTY name="DATAFUNC">
			<value><![CDATA[[EVAL 
				// <?php
				
				function PMSI000032_calcSQL($data) {
					
					// Pas de donnée sélectionnée, on renvoie des valeurs à zéro
					if ($data == '0') {
						return '0, 0';
					}
					
					$countDistinctCaseWhen = "count(DISTINCT CASE WHEN [VIEW.QUELLEDATE] BETWEEN @date_debut@ AND @date_fin@ %s THEN %s ELSE null END)";
					$sumCaseWhen = "sum(CASE WHEN [VIEW.QUELLEDATE] BETWEEN @date_debut@ AND @date_fin@ THEN %s ELSE 0 END)";
					$periodeDebut = '\'[PERIODE]\'::date';
					$periodeFin = '\'[TOPERIODE]\'::date';
					$periodePrecDebut = '\'[PERIODE_D]\'::date';
					$periodePrecFin = '\'[TOPERIODE_D]\'::date';
					$tmp0 = '';
					
					switch ($data) {
						case '1':	// Nombre total d'actes
							$tmp = sprintf($sumCaseWhen, 'nombre');
							break;
						case '2':	// Nombre d'actes hors anesthésie
							$tmp = sprintf($sumCaseWhen, 'nombre_activite_1');
							break;
						case '3':	// Nombre d'actes d'anesthésie
							$tmp = sprintf($sumCaseWhen, 'nombre_activite_4');
							break;
						case '4':	// Total ICR
							$tmp = sprintf($sumCaseWhen, '[VIEW.ICR_FIELD]');
							break;
						case '5':	// ICR hors anesthésie
							$tmp = sprintf($sumCaseWhen, '[VIEW.ICR_FIELD]_activite_1');
							break;
						case '6':	// ICR anesthésies
							$tmp = sprintf($sumCaseWhen, '[VIEW.ICR_FIELD]_activite_4');
							break;
						case '7':	// Nombre de séjours
							$tmp = sprintf($countDistinctCaseWhen, $tmp0, 'v_rss_1.rss_id');
							break;
						case '8':	// Nombre de séjours 0 nuit
							$tmp0 = 'AND duree_sejour = 0';
							$tmp = sprintf($countDistinctCaseWhen, $tmp0, 'v_rss_1.rss_id');
							break;
						case '9':	// Taux de séjours 0 nuit
							$tmpA = sprintf($countDistinctCaseWhen, $tmp0, 'v_rss_1.rss_id');
							$tmp0 = 'AND duree_sejour = 0';
							$tmpB = sprintf($countDistinctCaseWhen, $tmp0, 'v_rss_1.rss_id');
							$tmp = sprintf('100.0 * base.cti_division(%s, %s)', $tmpB, $tmpA);
							break;
						default :	// Nombre total d'actes par défaut
							$tmp = sprintf($sumCaseWhen, 'nombre');
					}
					
					$toReplace = array(
						'@date_debut@',
						'@date_fin@'
					);
					
					$curPeriod = array(
						$periodeDebut,
						$periodeFin
					);
					
					$prevPeriod = array(
						$periodePrecDebut,
						$periodePrecFin
					);
					
					return str_replace($toReplace, $curPeriod, $tmp) . ', ' . str_replace($toReplace, $prevPeriod, $tmp);
				}
				
				// ?>
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DATASQL">
			<value><![CDATA[[EVAL 
				// <?php
				
				return 
					PMSI000032_calcSQL('[DATA1]') . ', 0, 0, ' . PHP_EOL . 
					PMSI000032_calcSQL('[DATA2]') . ', 0, 0, ' . PHP_EOL . 
					PMSI000032_calcSQL('[DATA3]') . ', 0, 0, ' . PHP_EOL . 
					PMSI000032_calcSQL('1') . ', ' . PHP_EOL . 
					PMSI000032_calcSQL('4');
				
				// ?>
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse">
		<GROUP label="Période">
			<FIELD name="QUELLEDATE" label="" width="200" UI="combo" default="1" printable="false">
				<OPTION label="Date sortie" data="1" data2="date_sortie" />
				<OPTION label="Date acte" data="2" data2="date_acte" />
			</FIELD>
			<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="2014-07-01" printable="false" globalListProvider="DATE_DEBUT" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="150" default="2014-12-31" printable="false" globalListProvider="DATE_FIN" />
		</GROUP>
		<GROUP label="Période précédente">
			<FIELD name="FILLER" label="" width="200" UI="text" default="" printable="false" visible="false" />
			<FIELD name="PERIODE_D" label="Période précédente" UI="combo" tree="true" width="150" default="2014-01-01" printable="false" globalListProvider="DATE_DEBUT" />
			<FIELD name="TOPERIODE_D" label="à" UI="combo" tree="true" width="150" default="2014-06-30" printable="false" globalListProvider="DATE_FIN" />
		</GROUP>
		<GROUP label="Regroupements">
			<FIELD name="GROUPBY" width="250" label="" UI="combo" default="ACTE" tree="true">
				<OPTION label="Options" data="" globalListProvider="ACTE_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="250" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1" />
				<OPTION label="Options" data="" globalListProvider="ACTE_GROUPBY_OPTIONS" />
			</FIELD>
		</GROUP>		
        <GROUP label="">
			<FIELD name="GROUPBY_3" width="250" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de troisième niveau" data="-1" />
				<OPTION label="Options" data="" globalListProvider="ACTE_GROUPBY_OPTIONS" />
			</FIELD>
		</GROUP>
		<GROUP>
			<FIELD name="DATA1" label="Données" UI="combo" default="1" default2="Nb Actes" default3="#" tree="true" printable="false">
				<OPTION label="Options" data="" globalListProvider="DATA_ACTE" />
			</FIELD>
			<FIELD name="DATA2" label="" UI="combo" default="0" default2="0" default3="0" tree="true" printable="false">
				<OPTION label="" data="0" />
				<OPTION label="Options" data="" globalListProvider="DATA_ACTE" />
			</FIELD>
			<FIELD name="DATA3" label="" UI="combo" default="0" default2="0" default3="0" tree="true" printable="false">
				<OPTION label="" data="0" />
				<OPTION label="Options" data="" globalListProvider="DATA_ACTE" />
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_ACTE_SELECTIONS" />
	<SELECTIONS componentName="FILTRES_ACTE_SOUSSELECTIONS" />
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" optimizer2="V_RSS_ACTES_X" cacheEnabled="true">
				<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]}
						SIGNIFDATA{[VIEW.SELECT_TABTREE_ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
						OPTIONS{NOTZERO=1}
						ORDERBY{[VIEW.DATA1],, DESC}
						INDICATORS{
							[VIEW.DATASQL]
						}
					FROM #V_RSS_X#
						JOIN #V_RSS_ACTES_X# ON v_rss_1.rss_id = v_rss_actes_1.rss_id
					WHERE 1=1
						AND (
								[VIEW.QUELLEDATE] BETWEEN '[PERIODE_D]' AND '[TOPERIODE_D]' 
								OR 
								[VIEW.QUELLEDATE] BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							)
						[VIEW.FILTRE_ACTE_SELECT]
						[VIEW.FILTRE_RSS_SELECT]
						
					AFTER{
						UPDATE w_table SET 
							indicateurs[3] = indicateurs[1] - indicateurs[2],
							indicateurs[4] = CASE 
												WHEN indicateurs[1] > 0 AND indicateurs[2] > 0 THEN base.cti_division(indicateurs[1] - indicateurs[2], indicateurs[2]) * 100
											 ELSE 0 END,
							indicateurs[7] = indicateurs[5] - indicateurs[6],
							indicateurs[8] = CASE 
												WHEN indicateurs[5] > 0 AND indicateurs[6] > 0 THEN base.cti_division(indicateurs[5] - indicateurs[6], indicateurs[6]) * 100
											 ELSE 0 END,
							indicateurs[11] = indicateurs[9] - indicateurs[10],
							indicateurs[12] = CASE 
												WHEN indicateurs[9] > 0 AND indicateurs[10] > 0 THEN base.cti_division(indicateurs[9] - indicateurs[10], indicateurs[10]) * 100
											  ELSE 0 END
					}
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS" />
					<FIELD name="SORT" />
					
					<!-- Première donnée -->
					<FIELD name="D1_NOW" />
					<FIELD name="D1_OLD" />
					<FIELD name="D1_ECA" />
					<FIELD name="D1_PCT" />
					
					<!-- Deuxième donnée -->
					<FIELD name="D2_NOW" />
					<FIELD name="D2_OLD" />
					<FIELD name="D2_ECA" />
					<FIELD name="D2_PCT" />
					
					<!-- Troisième donnée -->
					<FIELD name="D3_NOW" />
					<FIELD name="D3_OLD" />
					<FIELD name="D3_ECA" />
					<FIELD name="D3_PCT" />
					
					<!-- Premier graphique (Nombre d'actes) -->
					<FIELD name="AC_NOW" />
					<FIELD name="AC_OLD" />
					
					<!-- Deuxmième graphique (ICR total) -->
					<FIELD name="IC_NOW" />
					<FIELD name="IC_OLD" />
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Justificatif Actes par RSS" shortLabel="Liste Actes" view="PMSI000030.XML" componentName="RSS_BASE_VIEWLINK" component2Name="ACTE_VIEWLINK" component3Name="DATE_COMP_2_VIEWLINK">
				<ARG name="T_DUREE_SEJOUR">
					<value><![CDATA[ 	
						var col:String = COLUMN.NAME.substr(0,2);
						if ((col == 'D1' && SELECT.DATA1 == '8') || (col == 'D2' && SELECT.DATA2 == '8') || (col == 'D3' && SELECT.DATA3 == '8'))
							{return 'DU0';}
						else { return '-1';}
					]]></value>
				</ARG>
				<ARG name="ACTE_ACTIVITE_CCAM">
					<value><![CDATA[ 
						var col:String = COLUMN.NAME.substr(0,2);
						if ((col == 'D1' && (SELECT.DATA1 == '2' || SELECT.DATA1 == '5')) || (col == 'D2' && (SELECT.DATA2 == '2' || SELECT.DATA2 == '5')) || (col == 'D3' && (SELECT.DATA3 == '2' || SELECT.DATA3 == '5')))
							{return '1';}
						else if ((col == 'D1' && (SELECT.DATA1 == '3' || SELECT.DATA1 == '6')) || (col == 'D2' && (SELECT.DATA2 == '3' || SELECT.DATA2 == '6')) || (col == 'D3' && (SELECT.DATA3 == '3' || SELECT.DATA3 == '6')))
							{return '4';}
						else {return '-1';};
					]]></value>
				</ARG>
			</VIEWLINK>
			<VIEWLINK label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000005.XML" componentName="RSS_BASE_VIEWLINK" component2Name="RSS_OTHERS_VIEWLINK" component3Name="DATE_COMP_2_VIEWLINK">
				<ARG name="T_DUREE_SEJOUR">
					<value><![CDATA[ 
						var col:String = COLUMN.NAME.substr(0,2);
						if ((col == 'D1' && SELECT.DATA1 == '8') || (col == 'D2' && SELECT.DATA2 == '8') || (col == 'D3' && SELECT.DATA3 == '8'))
							{return 'DU0';}
						else { return '-1';}
					]]></value>
				</ARG>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Comparatif actes" label="Comparatif actes" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
			<CHART title="Nombre pour les 12 premiers" type="columnChart" maxItems="12" maxItemsSortOn="AC_NOW" maxItemsSortSeq="D" sortField="CODTXT" sortSeq="A" condition="ROW.LVL == '1'">
				<CATEGORY field="CODTXT" type="Char" />
				<SERIE field="AC_OLD" displayName="'Nb ' + SELECT.PERIODE_D_LABEL + '-' + SELECT.TOPERIODE_D_LABEL" displayNameCalc="true" />
				<SERIE field="AC_NOW" displayName="'Nb ' + SELECT.PERIODE_LABEL + '-' + SELECT.TOPERIODE_LABEL" displayNameCalc="true" />
			</CHART>
			<CHART title="ICR pour les 12 premiers" type="columnChart" maxItems="12" maxItemsSortOn="IC_NOW" maxItemsSortSeq="D" sortField="CODTXT" sortSeq="A" condition="ROW.LVL == '1'">
				<CATEGORY field="CODTXT" type="Char" />
				<SERIE field="IC_OLD" displayName="'ICR ' + SELECT.PERIODE_D_LABEL + '-' + SELECT.TOPERIODE_D_LABEL" displayNameCalc="true" />
				<SERIE field="IC_NOW" displayName="'ICR ' + SELECT.PERIODE_LABEL + '-' + SELECT.TOPERIODE_LABEL" displayNameCalc="true" />
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="54" variableRowHeight="true" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'"
				sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_3 == '-1' || SELECT.GROUPBY_TAB == 'TAB'">
				<INSERT name="DATAGRID_MULTITAB_STYLES" />
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="AC_OLD" visible="false" />
				<COLUMN dataField="AC_NOW" visible="false" />
				<COLUMN dataField="IC_OLD" visible="false" />
				<COLUMN dataField="IC_NOW" visible="false" />
				<COLUMN dataField="COD" width="90" type="Char" 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="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="Autres" />
				<COLUMN dataField="CODTXT" type="Char" minWidth="200" visible="false" totalFunction="text" otherFunction="text" calc="true">
					<CALC formula="ROW.COD + ' ' + ROW.TXT.toString().substr(0,10)" />
				</COLUMN>
				
				<COLUMN dataField="D1_OLD" type="Number" width="80" outputFormat="= SELECT.DATA13" selectable="true" headerText="SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL + '\n' + SELECT.DATA12" headerTextCalc="true" />
				<COLUMN dataField="D1_NOW" type="Number" width="80" outputFormat="= SELECT.DATA13" selectable="true" headerText="SELECT.PERIODE_LABEL + '\n' + SELECT.TOPERIODE_LABEL + '\n' + SELECT.DATA12" headerTextCalc="true" />
				<COLUMN dataField="D1_ECA" type="Number" width="70" outputFormat="= if (ROW.D1_OLD == '0' &amp;&amp; ROW.D1_NOW == '0') { return '#';} else { if (SELECT.DATA1 == '9') { return '0#,0 pt';} else {return SELECT.DATA13;}}" headerText="Ecart">
					<CELLSTYLE name="cellIndicator" value="triangle_down, 10, left middle, 0xD63E00" condition="ROW.D1_NOW &lt; ROW.D1_OLD" />
					<CELLSTYLE name="cellIndicator" value="triangle_up, 10, left middle, 0x75a0eb" condition="ROW.D1_NOW &gt; ROW.D1_OLD" />
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0xFFA500" condition="ROW.D1_NOW != null &amp;&amp; ROW.D1_OLD != null &amp;&amp; ROW.D1_NOW == ROW.D1_OLD" />
				</COLUMN>
				<COLUMN dataField="D1_PCT" type="Number" width="45" visibleCondition="SELECT.DATA1 != '9'" outputFormat="= if (ROW.D1_OLD !=0) {return '0%'} else {return '#'}" headerText="% évol." />
				
				<COLUMN dataField="D2_OLD" type="Number" width="80" visibleCondition="SELECT.DATA2 != '0'" outputFormat="= SELECT.DATA23" selectable="true" headerText="SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL + '\n' + SELECT.DATA22" headerTextCalc="true" />
				<COLUMN dataField="D2_NOW" type="Number" width="80" visibleCondition="SELECT.DATA2 != '0'" outputFormat="= SELECT.DATA23" selectable="true" headerText="SELECT.PERIODE_LABEL + '\n' + SELECT.TOPERIODE_LABEL + '\n' + SELECT.DATA22" headerTextCalc="true" />
				<COLUMN dataField="D2_ECA" type="Number" width="70" visibleCondition="SELECT.DATA2 != '0'" outputFormat="= if (ROW.D2_OLD == '0' &amp;&amp; ROW.D2_NOW == '0') { return '#';} else { if (SELECT.DATA2 == '9') { return '0#,0 pt';} else {return SELECT.DATA23;}}" headerText="Ecart">
					<CELLSTYLE name="cellIndicator" value="triangle_down, 10, left middle, 0xD63E00" condition="ROW.D2_NOW &lt; ROW.D2_OLD" />
					<CELLSTYLE name="cellIndicator" value="triangle_up, 10, left middle, 0x75a0eb" condition="ROW.D2_NOW &gt; ROW.D2_OLD" />
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0xFFA500" condition="ROW.D2_NOW != null &amp;&amp; ROW.D2_OLD != null &amp;&amp; ROW.D2_NOW == ROW.D2_OLD" />
				</COLUMN>
				<COLUMN dataField="D2_PCT" type="Number" width="45" visibleCondition="SELECT.DATA2 != '0' &amp;&amp; SELECT.DATA2 != '9'" outputFormat="= if (ROW.D2_OLD != 0) {return '0%'} else {return '#'}" headerText="% évol." />
				
				<COLUMN dataField="D3_OLD" type="Number" width="80" visibleCondition="SELECT.DATA3 != '0'" outputFormat="= SELECT.DATA33" selectable="true" headerText="SELECT.PERIODE_D_LABEL + '\n' + SELECT.TOPERIODE_D_LABEL + '\n' + SELECT.DATA32" headerTextCalc="true" />
				<COLUMN dataField="D3_NOW" type="Number" width="80" visibleCondition="SELECT.DATA3 != '0'" outputFormat="= SELECT.DATA33" selectable="true" headerText="SELECT.PERIODE_LABEL + '\n' + SELECT.TOPERIODE_LABEL + '\n' + SELECT.DATA32" headerTextCalc="true" />
				<COLUMN dataField="D3_ECA" type="Number" width="70" visibleCondition="SELECT.DATA3 != '0'" outputFormat="= if (ROW.D3_OLD == '0' &amp;&amp; ROW.D3_NOW == '0') { return '#';} else { if (SELECT.DATA3 == '9') { return '0#,0 pt';} else {return SELECT.DATA33;}}" headerText="Ecart">
					<CELLSTYLE name="cellIndicator" value="triangle_down, 10, left middle, 0xD63E00" condition="ROW.D3_NOW &lt; ROW.D3_OLD" />
					<CELLSTYLE name="cellIndicator" value="triangle_up, 10, left middle, 0x75a0eb" condition="ROW.D3_NOW &gt; ROW.D3_OLD" />
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0xFFA500" condition="ROW.D3_NOW != null &amp;&amp; ROW.D3_OLD != null &amp;&amp; ROW.D3_NOW == ROW.D3_OLD" />
				</COLUMN>
				<COLUMN dataField="D3_PCT" type="Number" width="45" visibleCondition="SELECT.DATA3 != '0' &amp;&amp; SELECT.DATA3 != '9'" outputFormat="= if (ROW.D3_OLD != 0) {return '0%'} else {return '#'}" headerText="% évol." />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
