<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000160" label="PMSI. Décomposition C.A. par UM" title="= 'C.A. UM par ' +  SELECT.GROUPBY_LABEL + ' (' +  SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_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:rum:chiffre_daffaire_rum" helpDokuWIkiFile="pmsi000160"  helpFile="iCTI_PMSI_PMSI000160.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_PRESTATIONS_UM" />
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse">
		<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="de" UI="combo" tree="true" width="200" default="2014-01-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="220" label="" UI="combo" default="UM" tree="true">
				<OPTION label="Options" data="" globalListProvider="PRESTATIONS_UM_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="PRESTATIONS_UM_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="PRESTATIONS_UM_GROUPBY_OPTIONS" />
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_PRESTATION_RUM_SELECTIONS" />
	<SELECTIONS componentName="FILTRES_PRESTATION_RUM_SOUSSELECTIONS" />
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[

					CTISELECT_TREE
                        WORKTABLE{pmsi000160}
                        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.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
                        ORDERBY{indicateurs[6],, DESC}
                        OPTIONS{NOTZERO=1}
                        INDICATORS{
                            count(DISTINCT CASE WHEN rum_valorise = '1' THEN v_rss_1.rss_id ELSE NULL END),
                            count(DISTINCT CASE WHEN rum_valorise = '1' THEN v_rsf_detail_1.rss_id::text || '-'::text || no_rum::text ELSE NULL END),
                            sum(v_rsf_detail_1.base_remboursement_rum),
                            *%TOTAL[3],
                            sum(v_rsf_detail_1.base_remboursement_rum_sauf_transition),
                            sum(v_rsf_detail_1.sejour_remboursable_rum),
                            0,
                            count(DISTINCT v_rss_1.rss_id),
                            base.cti_sum_distinct_on(DISTINCT ARRAY[v_rss_1.rss_id, v_rss_1.nb_rsa]),
                            count(DISTINCT CASE WHEN nb_rum = 1 THEN v_rss_1.rss_id ELSE NULL END),
                            count(DISTINCT CASE WHEN nb_rum <> 1 THEN v_rss_1.rss_id ELSE NULL END),
                            count(DISTINCT v_rsf_detail_1.rss_id::text || '-'::text || no_rum::text),
                            base.cti_sum_distinct_on(DISTINCT ARRAY[v_rsf_detail_1.rss_id::text || '-'::text || no_rum::text, v_rsf_detail_1.duree_sejour_rum::text]),
                            base.cti_sum_distinct_on(DISTINCT CASE WHEN rum_valorise = '1' THEN ARRAY[v_rsf_detail_1.rss_id::text || '-'::text || no_rum::text, v_rsf_detail_1.duree_sejour_rum::text] ELSE NULL END),
                            base.cti_sum_distinct_on(DISTINCT CASE WHEN rum_valorise = '1' THEN ARRAY[v_rsf_detail_1.rss_id::text || '-'::text || no_rum::text, GREATEST(v_rsf_detail_1.duree_sejour_rum,1)::text] ELSE NULL END),
                            sum(v_rsf_detail_1.base_remboursement_rum_sauf_transition_sauf_ame)
                        }   
                    FROM #V_RSS_X#
                        JOIN pmsi.v_rsf_detail_rum_1 v_rsf_detail_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id
                    WHERE
                        date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
                        [VIEW.FILTRE_RSS_SELECT]
                        [VIEW.PRESTATION_SELECT]
                       
                    AFTER{   
                        UPDATE pmsi000160 SET
                            indicateurs[7] = base.cti_division(indicateurs[3], indicateurs[2]),
                            indicateurs[15] = base.cti_division(indicateurs[3], indicateurs[15])              
                    }
		
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS" />
					<FIELD name="SORT" />
					<FIELD name="NB_RSAV" />
					<FIELD name="NB_RUMV" />
					<FIELD name="MT_FAC" />
					<FIELD name="PT_FAC" />
					<FIELD name="MT_FAC_HT" />
					<FIELD name="MT_REM" />
					<FIELD name="PU_FACR" />
					<FIELD name="NB_RSA" />
					<FIELD name="NB_SEA" />
					<FIELD name="NB_RSA_1" />
					<FIELD name="NB_RSA_X" />
					<FIELD name="NB_RUM" />
					<FIELD name="NB_JOU" />
					<FIELD name="NB_JOUV" />
					<FIELD name="PU_FACJ" />
					<FIELD name="MT_FAC_HT_HAME" />
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY label="">
			<SQL>
				<select><![CDATA[

				WITH t_annee
				AS (
					SELECT - 9999999 AS oidt
						,'Synthèse' AS labelt
						,'Synthèse' AS textet
						,ROW_NUMBER() OVER (
							ORDER BY annee::TEXT || '-'::TEXT
							) AS oid1
						,ROW_NUMBER() OVER (
							ORDER BY annee::TEXT || '-'::TEXT
							) AS cod1
						,- 9999999 AS oid2
						,'' AS code2
						,'' AS oid3
						,'' AS code3
						,1 oid
						,annee::TEXT AS code
						,'PMS Année '::TEXT || annee::TEXT AS texte
						,1
						,0
						,0
						,0
						,0
					FROM pmsi.p_ventilation_um
						,pmsi.t_unites_medicales
					WHERE p_ventilation_um.unite_medicale_id = t_unites_medicales.oid
						AND t_unites_medicales.oid <> 0
						AND annee BETWEEN date_part('year', '[PERIODE]'::DATE)
							AND date_part('year', '[TOPERIODE]'::DATE)
					GROUP BY annee
					)
				SELECT *
				FROM t_annee

				UNION ALL

				(
					SELECT - 9999999 AS oidt
						,'Synthèse' AS labelt
						,'Synthèse' AS textet
						,t_annee.oid1 AS oid1
						,t_annee.cod1 AS cod1
						,ROW_NUMBER() OVER (
							ORDER BY annee::TEXT || '-'::TEXT || t_unites_medicales.code::TEXT
							) AS oid2
						,'' AS code2
						,'' AS oid3
						,'' AS code3
						,1 oid
						,annee::TEXT || '-'::TEXT || t_unites_medicales.code::TEXT AS code
						,t_unites_medicales.code::TEXT || ' '::TEXT || t_unites_medicales.texte::TEXT AS texte
						,2 AS LEVEL
						,nb_sejours_monorum
						,ca_ghs_monorum
						,pms
						,pmj
					FROM pmsi.p_ventilation_um
					JOIN pmsi.t_unites_medicales ON p_ventilation_um.unite_medicale_id = t_unites_medicales.oid
					JOIN t_annee ON t_annee.code = annee
					WHERE 1 = 1
						AND t_unites_medicales.oid <> 0
						AND annee BETWEEN date_part('year', '[PERIODE]'::DATE)
							AND date_part('year', '[TOPERIODE]'::DATE)
						AND (
							pms <> 0
							OR pmj <> 0
							)
					)
					
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS" />
					<FIELD name="SEJM" />
					<FIELD name="CAGM" />
					<FIELD name="PMS" />
                    <FIELD name="PMJ" />              
				</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="Comparatif" shortLabel="Comparatif" view="PMSI000174.XML" enabled="true" rowContext="false" buttonType="COMPARATIF">
				<ARG name="PERIODE_D" value="return VIEW.X_PERIODE_D;" />
				<ARG name="TOPERIODE_D" value="return VIEW.X_TOPERIODE_D;" />
				<ARG name="DATA" value="'BR'" />
			</VIEWLINK>
			<VIEWLINK label="Evolution" shortLabel="Evolution" view="PMSI000173.XML" enabled="true" rowContext="false" componentName="PERIODICITE_VIEWLINK" buttonType="EVOLUTION">
				<ARG name="DATA" value="'BR'" />
			</VIEWLINK>
			<VIEWLINK label="Analyse croisée" shortLabel="Analyse croisée" view="PMSI000223.XML" enabled="true" rowContext="false" buttonType="ANALYSE_CROISEE">
				<ARG name="ALIAS_PERIODE" value="'-1'" />
                <ARG name="PERIODE" value="return VIEW.X_PERIODE;" />
				<ARG name="DATA" value="'BR'" />
				<ARG name="COLUMNBY" value="'MSOR'" />
				<ARG name="GROUPBY" value="'ASOR'" />
				<ARG name="GROUPBY_2" value="if (SELECT.GROUPBY == 'ASOR') {return 'GHM';} else {return SELECT.GROUPBY;}" />
				<ARG name="GROUPBY_TAB" value="'TAB'" />
				<ARG name="COLUMNBYCOUNT" value="'12'" />
			</VIEWLINK>
			<VIEWLINK label="Justificatif par RUM" shortLabel="Liste RUM" view="PMSI000175.XML" componentName="RSS_BASE_VIEWLINK" component2Name="PRESTATION_UM_VIEWLINK" component3Name="DATE_COMP_VIEWLINK" />
			<VIEWLINK label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000005.XML" componentName="RSS_BASE_VIEWLINK" component2Name="RSS_OTHERS_VIEWLINK" component3Name="DATE_COMP_VIEWLINK" />
		</VIEWLINKS>
		<ONGLET excelLabel="Analyse" label="Analyse prestations" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
			<CHART title="Montant" type="pieChart" subType="" maxItems="10" maxItemsSortOn="MT_FAC" maxItemsSortSeq="D" sortField="CODTXT" sortSeq="A" condition="ROW.LVL == '1'">
				<CATEGORY field="CODTXT" type="Char" />
				<SERIE field="MT_FAC" displayName="Montant" />
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="48" variableRowHeight="true" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'" sortable="= SELECT.GROUPBY_3 == '-1' || 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 dataField="COD" width="100" visibleCondition="SELECT.GROUPBY != '11'" type="Char" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text">
					<CELLSTYLE name="paddingLeft" value="15" condition="ROW.LVL == '2' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'" />
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" visibleCondition="SELECT.GROUPBY != '11'" minWidth="200" maxWidth="300" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres" />
				<COLUMN dataField="TXT2" type="Date" visibleCondition="SELECT.GROUPBY == '11'" minWidth="200" maxWidth="300" inputFormat="AAAAMM" outputFormat="MMMM YY" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres" calc="true">
					<CALC formula="ROW.COD" />
				</COLUMN>
				<COLUMN dataField="CODTXT" type="Char" visible="false" totalFunction="text" otherFunction="text" calc="true">
					<CALC formula="if (SELECT.GROUPBY == '11') {return ROW.TXT2}
									return ROW.COD + ' ' + ROW.TXT.toString().substr(0,20)" />
				</COLUMN>
				<COLUMN dataField="NB_RSA" width="60" type="Number" outputFormat="#" currency="" currencyAlign="right" headerText="Séjours" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de RSS" />
				<COLUMN dataField="NB_SEA" width="60" type="Number" outputFormat="#" currency="" currencyAlign="right" headerText="Séjours dont séances" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours. Pour les séjours de la CMD 28, nombre de séances" />
				<COLUMN dataField="NB_RSA_1" width="60" type="Number" outputFormat="#" currency="" currencyAlign="right" headerText="dont mono-RUM" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de RSS mono-RUMs" />
				<COLUMN dataField="NB_RSA_X" width="60" type="Number" outputFormat="#" currency="" currencyAlign="right" headerText="dont multi-RUM" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de RSS multi-RUMs" />
				<COLUMN dataField="NB_RUM" width="60" type="Number" visible="true" outputFormat="#" headerText="RUM" textAlign="right" totalFunction="sum" otherFunction=""
					description="Nombre de RUMs différents" />
				<COLUMN dataField="NB_JOU" width="80" type="Number" visible="true" outputFormat="#j" headerText="Durée Séjour" textAlign="right" totalFunction="sum" otherFunction=""
					description="Somme des durées de séjour des RUMs" />
				<COLUMN dataField="NB_RSAV" width="60" type="Number" outputFormat="#" currency="" currencyAlign="right" headerText="Séjours valorisés" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours dont le RUM a été valorisé. Un RUM est marqué comme valorisé quand il correspond à une ligne dans le fichier des RSF" />
				<COLUMN dataField="NB_RUMV" width="60" type="Number" visible="true" outputFormat="#" headerText="RUM Séjours Valorisés" textAlign="right" totalFunction="sum" otherFunction=""
					description="Nombre de RUMs valorisés. Un RUM est marqué comme valorisé quand il correspond à une ligne dans le fichier des RSF" />
				<COLUMN dataField="NB_JOUV" width="80" type="Number" visible="true" outputFormat="#j" headerText="Durée Séjours Valorisés" textAlign="right" totalFunction="sum" otherFunction=""
					description="Somme des durées de séjour des RUMs valorisés. Un RUM est marqué comme valorisé quand il correspond à une ligne dans le fichier des RSF" />
				<COLUMN dataField="MT_FAC" width="100" type="Number" outputFormat="#E" headerText="Montant facturé (BR)" textAlign="right" totalFunction="sum" otherFunction=""
					description="= return &quot;Somme des bases de remboursement calculées selon la méthode paramétrée dans l'application (voir Onglet &lt;b&gt;Paramètres&lt;/b&gt;)&quot;" />
                <COLUMN dataField="MT_FAC_HT_HAME" width="100" type="Number" outputFormat="#E" headerText="Montant facturé (BR 100&#37; T2A)" textAlign="right" totalFunction="sum" otherFunction="" visibleCondition="ENV.TYPEETS != '1'"
					description="= return &quot;Somme des bases de remboursement 100&#37; T2A (nombre * coefficient * prix_unitaire) calculées selon la méthode paramétrée dans l'application (voir Onglet &lt;b&gt;Paramètres&lt;/b&gt;). Pour le GHS, les EXB sont déduits du montant&quot;"/>
				<COLUMN dataField="PT_FAC" type="Number" headerText="% / Total" width="80" outputFormat="0%" textAlign="right" totalComplement=""
					description="Poids du montant facturé du critère de regroupement dans le montant facturé total" />
				<COLUMN dataField="PU_FACR" width="80" type="Number" outputFormat="#,00E" visible="true" headerText="P.U Moyen (BR) / RUM" textAlign="right" otherFunction=""
					description="= return &quot;Montant facturé par RUM.&lt;br/&gt;Rapport entre les colonnes &lt;b&gt;Montant facturé (BR)&lt;/b&gt; et &lt;b&gt;RUM&lt;/b&gt;&quot;" />
				<COLUMN dataField="PU_FACJ" width="80" type="Number" outputFormat="#,00E" headerText="P.U Moyen (BR) / Jour" textAlign="right" totalFunction="sum" otherFunction=""
					description="= return &quot;Montant facturé par jour.&lt;br/&gt;Rapport entre la colonne &lt;b&gt;Montant facturé (BR)&lt;/b&gt; et la somme des durées de séjour des RUMs valorisés (Attention les séjours 0 nuit comptent ici pour 1 journée)&quot;" />
				<COLUMN dataField="MT_FAC_HT" width="100" type="Number" outputFormat="#E" headerText="Montant facturé (BR)&#xD;Hors coefficient" textAlign="right" totalFunction="sum" otherFunction=""
					description="= return &quot;Somme des bases de remboursement calculées selon la méthode paramétrée dans l'application (voir Onglet &lt;b&gt;Paramètres&lt;/b&gt;) hors coefficient (coefficient prudentiel * coefficient de transition)&quot;" />
				<COLUMN dataField="MT_REM" width="100" type="Number" outputFormat="#E" headerText="Montant remboursé" textAlign="right" totalFunction="sum" otherFunction=""
					description="Montant remboursé par la caisse d'assurance maladie" />
			</DATAGRID>
		</ONGLET>
		<ONGLET excelLabel="Paramètres" label="Elements du calcul PMS" queryNumber="1">
			<DATAGRID title="" total="false" showOthers="false" headerHeight="48" variableRowHeight="true">
				<INSERT name="DATAGRID_MULTITAB_STYLES" />
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD" width="100" visibleCondition="SELECT.GROUPBY != '11'" type="Char" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text">
					<CELLSTYLE name="paddingLeft" value="15" condition="ROW.LVL == '2' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'" />
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" visibleCondition="SELECT.GROUPBY != '11'" minWidth="200" maxWidth="300" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres" />
				<COLUMN dataField="SEJM" width="80" type="Number" outputFormat="#" currencyAlign="right" headerText="Séjours monorum" textAlign="right" totalFunction="sum" />
				<COLUMN dataField="CAGM" width="100" type="Number" outputFormat="#E" headerText="C.A. monorum" textAlign="right" totalFunction="sum" otherFunction="" />
				<COLUMN dataField="PMS" width="80" type="Number" outputFormat="#,0000E" visible="true" headerText="P.M.S." textAlign="right" totalFunction="sum" otherFunction="" />
                <COLUMN dataField="PMJ" width="80" type="Number" outputFormat="#,0000E" visible="true" headerText="P.M.J." textAlign="right" totalFunction="sum" otherFunction="" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
