<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000039" label="PMSI. Analyse CMA" title="= 'Analyse ' + SELECT.DATA_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:sejours_analyse_globale:severites:severites_v10" helpDokuWIkiFile="pmsi000039">
	<VIEWPROPERTIES>
		<PROPERTYx dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					if (SELECT.OCCURENCE != '') {display = display + '#B#Analyse CMA#/B# : Occurences significative = #B#' + SELECT.OCCURENCE + '#/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="de" UI="combo" tree="true" width="200" default="2014-01-01" printable="false" globalListProvider="DATE_DEBUT">
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" printable="false" globalListProvider="DATE_FIN">
			</FIELD>
		</GROUP>
		<GROUP label="Présentation">
			<FIELD name="DATA" label="" UI="combo" default="1" printable="false">
				<OPTION label="CMA" data="1"/>
				<OPTION label="CMA Sévère" data="2"/>
			</FIELD>
			<FIELD name="OCCURENCE" label="Occurences significatives" UI="number" width="50" default="50" showIfNotDefault="true">
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" cacheEnabled="true" enabled="[DATA!=1::false]" select="SELECT oid, code, texte, taux_cma_national * 100,
							sum(vieww.nb_rsa) as nb_rsa_w,
							sum(viewt.nb_rsa) as nb_rsa

						FROM pmsi.t_ghm
					
						LEFT JOIN (
							SELECT ghm_code, sum(nb_rsa) as nb_rsa 
								FROM #V_RSS_X#
								WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie &gt;= '[PERIODE]' AND date_sortie &lt;='[TOPERIODE]' [VIEW.FILTRE_RSS_SELECT] GROUP BY ghm_code
								) AS vieww  ON (t_ghm.code = vieww.ghm_code) 
					
						LEFT JOIN (
							SELECT ghm_prefixe, sum(nb_rsa) as nb_rsa 
								FROM #V_RSS_X#
								WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie &gt;= '[PERIODE]' AND date_sortie &lt;='[TOPERIODE]' [VIEW.FILTRE_RSS_SELECT] GROUP BY ghm_prefixe
								) AS viewt  ON (substr(t_ghm.code,1,5) = viewt.ghm_prefixe) 

						WHERE substr(code, 6, 1) = 'W' 


					GROUP BY oid, code, texte, taux_cma_national * 100
					HAVING sum(viewt.nb_rsa)&gt; 0
					ORDER BY oid

					">
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="COD"/>
					<FIELD name="TXT"/>
					<FIELD name="TN"/>
					<FIELD name="NW"/>
					<FIELD name="NB"/>
				</FIELDS>
			</SQL>
			<SQL optimizer="V_RSS_X" cacheEnabled="true" enabled="[DATA==1::false]" select="SELECT oid, code, texte, taux_cma_national * 100,
							sum(vieww.nb_rsa) as nb_rsa_s,
							sum(viewt.nb_rsa) as nb_rsa

						FROM pmsi.t_ghm
					
						LEFT JOIN (
							SELECT ghm_code, sum(nb_rsa) as nb_rsa 
							FROM #V_RSS_X#
							WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie &gt;= '[PERIODE]' AND date_sortie &lt;='[TOPERIODE]' [VIEW.FILTRE_RSS_SELECT] GROUP BY ghm_code
								) AS vieww  ON (t_ghm.code = vieww.ghm_code) 
					
						LEFT JOIN (
							SELECT cmd_code, sum(nb_rsa) as nb_rsa 
							FROM #V_RSS_X# 
							WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie &gt;= '[PERIODE]' AND date_sortie &lt;='[TOPERIODE]' [VIEW.FILTRE_RSS_SELECT] GROUP BY cmd_code
								) AS viewt  ON (substr(t_ghm.code,1,2) = viewt.cmd_code) 

						WHERE substr(code, 6, 1) = 'S' 
							AND oid IN ( SELECT p_oids.oid FROM pmsi.p_oids WHERE p_oids.code_table::text = 'ghm')

					GROUP BY oid, code, texte,  taux_cma_national * 100
					HAVING sum(viewt.nb_rsa)&gt; 0
					ORDER BY oid

					">
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="COD"/>
					<FIELD name="TXT"/>
					<FIELD name="TN"/>
					<FIELD name="NW"/>
					<FIELD name="NB"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Justificatif par RSS" shortLabel="Justificatif RSS" view="PMSI000040.XML">
				<ARG name="GHM" value="if (ROW == null) {return SELECT.GHM}
				if (SELECT.DATA == '1' &amp; COLUMN.NAME == 'NW') {return 'GH' + ROW.OID} 
				if (SELECT.DATA == '1' &amp; COLUMN != 'NW') {return 'CW' + ROW.OID} 
				if (SELECT.DATA == '2') {return 'GH' + ROW.OID} 
				return SELECT.GHM"/>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Analyse CMA" label="Analyse CMA">
			<FILTERSELECTION condition="Number(SELECT.OCCURENCE) == 0 || Number(ROW.NB) &gt;= Number(SELECT.OCCURENCE)"/>
			<CHART title="% CMA" type="columnChart" subType="" sortField="COD" sortSeq="A" condition="">
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="PW" displayName="% Etablissement"/>
				<SERIE field="TN" displayName="% National"/>
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" key="NB" keySeq="D" headerHeight="48" printRatio="0.8">
				<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">
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="200" maxWidth="300" headerText="GHM" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres">
				</COLUMN>
				<COLUMN dataField="NB" width="70" type="Number" outputFormat="#" headerText="if (SELECT.DATA == '1') {return 'RSA V+W'}
								if (SELECT.DATA == '2') {return 'RSA CMD'}
								" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="NW" width="70" type="Number" selectable="true" outputFormat="#" headerText="if (SELECT.DATA == '1') {return 'RSA W'}
								if (SELECT.DATA == '2') {return 'RSA S'}
								" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="PW" width="70" type="Number" outputFormat="#,0%" headerText="% Etab." textAlign="right" totalFunction="calc" otherFunction="calc" calc="true">
					<CALC formula="ROW.NW / ROW.NB * 100"/>
				</COLUMN>
				<COLUMN dataField="TN" width="70" type="Number" outputFormat="#,0%" headerText="% National" textAlign="right" totalFunction="text" otherFunction="text">
				</COLUMN>
				<COLUMN dataField="ET" width="70" type="Number" outputFormat="#,0%" headerText="Ecart" textAlign="right" totalFunction="text" otherFunction="text" calc="true">
					<CALC formula="ROW.PW - ROW.TN"/>
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
