<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000510" label="Impact financier RAAC" title="= 'Impact financier RAAC par ' + SELECT.GROUPBY_LABEL + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ') - ' + SELECT.VERSION_GROUPAGE_LABEL" database="iCTI" swf="*CTI_view1" softCode="iCTI_pmsi" typeEts="" globals="PMSI_globals.XML" componentsFile="PMSI_components.XML" helpDokuWIkiDir="pmsi:sejours_analyse_globale:rss:chiffre_d_affaire_rss" helpDokuWIkiFile="pmsi000007"  helpFile="iCTI_PMSI_PMSI000510.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_RSS" />
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
	</VIEWPROPERTIES>
	<VIEWPROPERTIES>
		<PROPERTY name="ORDERBY_CA">
			<value><![CDATA[[EVAL 
			
				if ('[GROUPBY_3]' != '-1' &&'[GROUPBY_2]' != '-1' && '[GROUPBY]' != '-1' && '[GROUPBY_TAB]' != 'TAB') {
					return 'ORDER BY 5,4,7,6';
				}
				else {
					return 'ORDER BY 12,19 DESC,5,7';
				}
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="ORDERBY_T2A">
			<value><![CDATA[[EVAL 
			
				if ('[GROUPBY_2]' != '-1' && '[GROUPBY]' != '-1' && '[GROUPBY_TAB]' != 'TAB') {
					return 'ORDER BY 5,4,7,6';
				}
				else {
					return 'ORDER BY 13,20 DESC,5,7';
				}
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="RAAC">
			<value><![CDATA[[EVAL 
			
						$oid = substr('[S_RAAC]',2);
                        if('[S_RAAC]' != '-1'){
							if('[S_RAAC]' == 'RA5'){
									$select = $select."AND v_rss_1.raac_id != 0 ";
							}else{
                                $select = $select."AND v_rss_1.raac_id = $oid ";
                            }
						}
						
						return $select;
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	<SELECTIONS label="" collapsible="false" displayText="= var display:String = ''; 
                    	
                    if (SELECT.S_RAAC  != '-1') {
						display = display + ' RAAC : #B#' + SELECT.S_RAAC_LABEL;
						display = display + '#/B# ';
					} 
                        return display;
    ">
		<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="Période" UI="combo" tree="true" width="200" default="2014-07-01" printable="false" globalListProvider="DATE_DEBUT" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" printable="false" globalListProvider="DATE_FIN" />
		</GROUP>
		<GROUP label="Regroupements">
			<FIELD name="GROUPBY" width="300" 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="300" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1" />
				<OPTION label="Options" data="" globalListProvider="RSS_GROUPBY_OPTIONS" />
			</FIELD>
             <FIELD name="GROUPBY_3" width="300" 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="RAAC">
			<FIELD name="S_RAAC" label="" UI="combo" visible="false" width="200" default="RA1" tree="true" globalListProvider="F_RAAC"  showIfNotDefault="true" />
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SOUSSELECTIONS" />
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" cacheEnabled="true">
				<comment><![CDATA[
						
					. 	Sélection de toutes les données dans w_tmp
						
					. 	w_order_ca_total permet de classer les codes de la première rupture de w_tmp par CA Total décroissant. 
						Cet	ordre est marqué dans le champ order_ca_total de la table w_tmp
						
					.	w_order_ca_t2a permet de classer les codes de la première rupture de w_tmp par CA T2A décroissant. 
						Cet	ordre est marqué dans le champ order_ca_t2a de la table w_tmp
				]]></comment>
				<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]}
						INDICATORS{
							0::bigint,
							0::bigint,
							count(DISTINCT patient_id),
                            count(v_rss_1.rss_id),
							sum(nb_rsa),
							sum(CASE WHEN duree_sejour = 0 THEN nb_rsa ELSE 0 END),
							sum(duree_sejour),
							case 
								when sum(case when cmd_code &lt;&gt; '28' then nb_rsa else 0 end) &gt; 0 
									then sum(case WHEN cmd_code &lt;&gt; '28' then duree_sejour else 0 end) / sum(case WHEN cmd_code &lt;&gt; '28' then nb_rsa else 0 end) 
								else 0 end ,
							sum(base_remboursement),
							sum(t2a_facture),
							sum(dmi_facture),
							sum(phc_facture),
							sum(forfait_facture),
							sum(ca_ghs),
							sum(ca_exh),
							sum(ca_ghs_theorique),
                            sum(nb_exh),
							sum(0 - CASE WHEN rehosp_meme_ghm = '1' THEN ca_perte_exb ELSE 0 END),
							sum(0 - CASE WHEN rehosp_meme_ghm = '0' AND nb_ghsmin = '1' AND ca_perte_exb > 0 THEN ca_perte_exb ELSE 0 END),
							sum(0 - CASE WHEN rehosp_meme_ghm = '0' AND nb_ghsmin = '0' AND ca_perte_exb > 0 THEN ca_perte_exb ELSE 0 END),
							sum(honoraires_factures),
							sum(CASE WHEN nb_seances > 0 OR nb_rsa_0n > 0 THEN base_remboursement ELSE 0 END),
							sum(CASE WHEN nb_rsa_1n > 0 OR nb_rsa_2n > 0 OR nb_rsa_xn > 0 THEN base_remboursement ELSE 0 END),
							count(distinct ghm_id),
							count(distinct ghm5_id),
                            sum(nb_seances),
							sum(v_rss_1.ca_ghs_sans_coefficient),
							sum(v_rss_1.ca_ghs_raac),
							sum( CA_GHS - CA_GHS_RAAC)

                            }
                            ORDERBY{indicateurs[14],, DESC}
						FROM #V_RSS_X#
						WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.FILTRE_RSS_SELECT]
							[VIEW.RAAC]
					;
                    
					]]>
				</select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="SORT" />
					<FIELD name="NB_P" />
					<FIELD name="NB_PT" />
					<FIELD name="NB_PAT" />
					<FIELD name="NO_RSS" />
					<FIELD name="NB_RSA" />
					<FIELD name="NB_ON" />
					<FIELD name="DUR" />
					<FIELD name="DMSETS" />
					<FIELD name="CA_SEJ" />
					<FIELD name="CA_T2A" />
					<FIELD name="CA_DMI" />
					<FIELD name="CA_PHC" />
					<FIELD name="CA_FOR" />
					<FIELD name="CA_GHS" />
					<FIELD name="CA_EXH" />
					<FIELD name="CA_GHST" />
                    <FIELD name="NB_EXH" />
					<FIELD name="CA_REHOSP" />
					<FIELD name="CA_MINFOR" />
					<FIELD name="CA_EXBP" />
					<FIELD name="CA_HON" />
					<FIELD name="CA_ON" />
					<FIELD name="CA_XN" />
					<FIELD name="NB_GHM" />
					<FIELD name="NB_RGHM" />
					<FIELD name="NB_SEA" />
					<FIELD name="CA_GHS_BRUT" />
					<FIELD name="CA_GHS_RAAC" />
					<FIELD name="IMPACT_RAAC" />
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL>
				<select><![CDATA[
						SELECT 'X_PERIODE_D', greatest(to_date(to_char('[PERIODE]'::date - INTERVAL  '1 year', 'YYYY-MM-DD'), 'YYYY-MM-DD'), (SELECT min(date_debut) FROM pmsi.p_imports))::text
					UNION ALL
						SELECT 'X_TOPERIODE_D', greatest(to_date(to_char('[TOPERIODE]'::date - INTERVAL  '1 year', 'YYYY-MM-DD'), 'YYYY-MM-DD'), (SELECT min(date_debut) FROM pmsi.p_imports))::text
					UNION ALL
						SELECT 'X_PERIODE', greatest(to_date(to_char('[PERIODE]'::date - INTERVAL  '3 year', 'YYYY-MM-DD'), 'YYYY-MM-DD'), (SELECT min(date_debut) FROM pmsi.p_imports))::text
				]]></select>
				<FIELDS>
					<FIELD name="name"/>
					<FIELD name="value"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
            <VIEWLINK label="Justificatif des RSS"  shortLabel="Justificatif RSS"  rowContext="false" buttonType="BUTTON_MCO_ZOOM">			
                <VIEWITEM label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000038.XML" componentName="RSS_BASE_VIEWLINK" component2Name="DATE_COMP_2_VIEWLINK" />
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="CA Détail T2A" label="" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
            <CHART title="" type="group" subType="h" percentHeight="100" fromTotal="false" visibleCondition="SELECT.GROUPBY != 'AMSOR' &amp;&amp; SELECT.GROUPBY != 'MSOR'" condition="ROW.LVL == '1'">			
                <CHART title="Nombre Séjours (10 premiers)" type="pieChart" maxItems="10" maxItemsSortOn="NO_RSS" maxItemsSortSeq="D" sortField="NO_RSS" sortSeq="D"  condition="ROW.LVL == '1'">
                    <CATEGORY field="TXT" type="Char"/>
                    <SERIE field="NO_RSS" displayName="'Séjours'" displayNameCalc="true"/>
                </CHART>			
                <CHART title="Décomposition C.A. GHS" type="columnChart" subType="stacked" maxItems="10" maxItemsSortOn="IMPACT_RAAC" maxItemsSortSeq="D" sortField="IMPACT_RAAC" sortSeq="D" visibleCondition="SELECT.GROUPBY != 'AMSOR' &amp;&amp; SELECT.GROUPBY != 'MSOR'" condition="ROW.LVL == '1'">
                    <CATEGORY field="COD" type="Char" />
                    <SERIE field="CA_GHS_RAAC" displayName="GHS RAAC" />
                    <SERIE field="IMPACT_RAAC" displayName="IMPACT RAAC" />

                </CHART>
			</CHART>
			<CHART title="Répartition autour du C.A. T2A Moyen" type="mixedChart" ctiColors="true" showLegend="false" maxItems="20" maxItemsSortOn="CA_T2A" maxItemsSortSeq="D" sortField="CA_T2A" sortSeq="D" visibleCondition="SELECT.GROUPBY != 'AMSOR' &amp;&amp; SELECT.GROUPBY != 'MSOR'" condition="ROW.LVL == '1'">
				<CATEGORY field="COD" type="Char" />
				<SERIE field="COL" displayName="C.A. T2A Moyen" minField="COLTOT" type="column" />
				<SERIE field="COLTOT" displayName="C.A. T2A Moyen Total" type="line" />
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" key="COD" headerHeight="54" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'" sortable="=  (SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB')">
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				<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">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="150" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres">
				</COLUMN>
				<COLUMN dataField="CODTXT" 	type="Char" visible="false" totalFunction="text" otherFunction="text" calc="true">
					<CALC formula="ROW.COD + ' ' + ROW.TXT.toString().substr(0,10) + '.'"/>
				</COLUMN>
                <COLUMN dataField="NO_RSS" 	type="Number" width="60" outputFormat="#" headerText="Séjours" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours. Pour les séjours de la CMD 28, on compte le nombre de RSA, peu importe le nombre de séances dans le RSA" />
				<COLUMN dataField="NB_RSA" 	type="Number" width="60" outputFormat="#" headerText="Séjours dont séa." textAlign="right" totalFunction="sum" otherFunction="sum" visibleCondition="VIEW.NB_SEANCES != '0'"
					description="Nombre de RSS (pour la CMD 28, nombre de séances)" />
				<COLUMN dataField="DUR" 	type="Number" width="60" outputFormat="#" currency="" currencyAlign="right" headerText="Journées Hospit." textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Somme des durées de séjour" />
				<COLUMN dataField="CA_T2A" 	type="Number" width="90" fixed="false" outputFormat="0#E" 	headerText="CA T2A" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Somme du montant des prestations liées à la T2A (GHS, suppléments, forfaits). Voir le détail des prestations concernées dans la classe &lt;b&gt;Décomposition CA (CTI)&lt;/b&gt; (Menu P.M.S.I. MCO | Paramètres | Classification | Classes | Prestations). Les prestations comprises dans le calcul du &lt;i&gt;CA T2A&lt;/i&gt; sont celles des sections &lt;b&gt;T2A. GHS&lt;/b&gt;, &lt;b&gt;T2A. EXH&lt;/b&gt;, &lt;b&gt;T2A. Forfaits et suppléments&lt;/b&gt; et &lt;b&gt;T2A. Autres&lt;/b&gt;" />
				<COLUMN dataField="COL" 	type="Number" width="55" fixed="false" outputFormat="0#E" 	headerText="CA T2A moyen" visible="true" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true"
					description="Chiffre d'affaires T2A moyen par séjour : rapport entre les colonnes &lt;b&gt;CA T2A&lt;/b&gt; et &lt;b&gt;Séjours&lt;/b&gt;">
					<CALC dataField="CA_T2A" />
					<CALC dataField="NO_RSS" operator="/" />
				</COLUMN>
				<COLUMN dataField="DAYS"  type="Number" width="60" fixed="false" outputFormat="#" 	headerText="Nbre jours d'hospitalisations" visible="true" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true"
					description="Nombre de jours total &lt;b&gt;Journées Hospitalisés&lt;/b&gt; + &lt;b&gt;le Nombre de 0 nuits&lt;/b&gt; sur la période">
					<CALC dataField="DUR" />
					<CALC dataField="NB_ON" operator="+" /> 
				</COLUMN>
				<COLUMN dataField="COLDAY" 	type="Number" width="60" fixed="false" outputFormat="0#E" 	headerText="CA T2A journalier" visible="true" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true"
					description="Chiffre d'affaires T2A journalier : rapport entre la colonne &lt;b&gt;CA T2A&lt;/b&gt; et &lt;b&gt;le Nombre de jours D'hospitalisations&lt;/b&gt;">
					<CALC dataField="CA_T2A" />
					<CALC dataField="DAYS" operator="/" /> 
				</COLUMN>
				<COLUMN dataField="COLTOT" 	type="Number" width="55" fixed="false" outputFormat="0#E" 	visible="false" totalFunction="calc" otherFunction="calc" calc="true">
					<CALC formula="TOTALROW.COL"/>
				</COLUMN>
				<COLUMN dataField="CA_GHS_BRUT" type="Number" width="90" fixed="false" outputFormat="0#E" 	headerText="CA GHS Brut" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Chiffre d'affaires théorique des prestations GHS. N'est pris en compte que le tarif unitaire du GHS brut sans coefficient."/>
				<COLUMN dataField="CA_GHS" 	type="Number" width="90" fixed="false" outputFormat="0#E" 	headerText="CA GHS avec coefficients" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Chiffre d'affaires des prestations GHS avec prise en compte des coefficients, des EXB mais sans la part liée aux EXH." />
				<COLUMN dataField="P_GHS" 	type="Number" width="50" fixed="false" outputFormat="0#,0%" headerText="% CA GHS avec coefficients" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true"
					description="Part du chiffre d'affaires GHS dans le chiffre d'affaires T2A : rapport entre les colonnes &lt;b&gt;GHS avec coefficients&lt;/b&gt; et &lt;b&gt;CA T2A&lt;/b&gt; multiplié par 100">
					<CALC dataField="CA_GHS" />
					<CALC dataField="CA_T2A" operator="/" />
					<CALC dataField="*constant" value="100" operator="*" />
				</COLUMN>
				<COLUMN dataField="CAGHSMOY" 	type="Number" width="75" fixed="false" outputFormat="0#E" 	headerText="CA GHS coef. moyen" visible="true" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true"
					description="Chiffre d'affaires GHS avec coefficients moyen par séjour : rapport entre les colonnes &lt;b&gt;GHS avec coefficients&lt;/b&gt; et &lt;b&gt;Séjours&lt;/b&gt;">
					<CALC dataField="CA_GHS" />
					<CALC dataField="NB_RSA" operator="/" />
				</COLUMN>
				<COLUMN dataField="CA_GHS_RAAC" type="Number" width="90" fixed="false" outputFormat="0#E" 	headerText="CA GHS SANS RAAC" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Chiffre d'affaires théorique des prestations GHS sans prendre en compte la variable réhabilitation améliorée après chirurgie (RAAC)."/>
				<COLUMN dataField="IMPACT_RAAC" type="Number" width="90" fixed="false" outputFormat="0#E" 	headerText="Impact CA RAAC" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Impact financier de la prise en compte RAAC sur le CA GHS avec coefficients"/>			
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>