<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000043" label="PMSI. Age population" title="= 'Age population 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:sejours_analyse_globale:population" helpDokuWIkiFile="pmsi000043"  helpFile="">
	<VIEWPROPERTIES componentName="PROPERTIES_RSS"/>
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE"/>
	<VIEWPROPERTIES>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<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="Regroupements">
			<FIELD name="GROUPBY" width="220" label="" UI="combo" default="AGECLS09" tree="true">
				<OPTION label="Options" data="" globalListProvider="AGE_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" treeLevel="1"/>
				<OPTION label="Options" data="" globalListProvider="AGE_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" treeLevel="1"/>
				<OPTION label="Options" data="" globalListProvider="AGE_GROUPBY_OPTIONS"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SOUSSELECTIONS"/>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" cacheEnabled="false">
					<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]}
							COLUMNBY[PERIODICITE]{date_sortie,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, [VIEW.COLUMN_OPTION]}
							OPTIONS{NOTZERO=1}						
							INDICATORS{
								count(DISTINCT v_rss_1.patient_id),
								count(DISTINCT CASE WHEN v_rss_1.sexe = '1' THEN patient_id ELSE null END),
								count(DISTINCT CASE WHEN v_rss_1.sexe = '2' THEN patient_id ELSE null END),
								sum(CASE WHEN cmd_code = '28' THEN 1 ELSE nb_rsa END),
								sum(CASE WHEN v_rss_1.sexe = '1' THEN CASE WHEN cmd_code = '28' THEN 1 ELSE nb_rsa END ELSE 0 END),
								sum(CASE WHEN v_rss_1.sexe = '2' THEN CASE WHEN cmd_code = '28' THEN 1 ELSE nb_rsa END ELSE 0 END),
								sum(age),
								/* count(distinct v_rss_1.rss_id), */
								base.cti_array_median(array_agg(age)),
								base.cti_division(sum(CASE WHEN v_rss_1.sexe = '2' THEN CASE WHEN cmd_code = '28' THEN 1 ELSE nb_rsa END ELSE null END), sum(CASE WHEN cmd_code = '28' THEN 1 ELSE nb_rsa END)) * 100
							}
                            ORDERBY{[VIEW.ORDERBY],, DESC}
						FROM 
							#V_RSS_X#
						WHERE mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.FILTRE_RSS_SELECT]

					]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS" />
					<FIELD name="SORT"/>
					<FIELD name="NP"/>
					<FIELD name="PM"/>
					<FIELD name="PF"/>
					<FIELD name="NB"/>
					<FIELD name="NM"/>
					<FIELD name="NF"/>
					<FIELD name="AG"/>
					<!--<FIELD name="NBRSS"/>-->
					<FIELD name="AGEMEDIAN"/>
					<FIELD name="PFEMME" />
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000005.XML" componentName="RSS_BASE_VIEWLINK">
				<ARG name="SEXE" value="if (COLUMN.NAME == 'NM') {return '1'} 
										if (COLUMN.NAME == 'PM') {return '1'} 
										if (COLUMN.NAME == 'NF') {return '2'} 
										if (COLUMN.NAME == 'PF') {return '2'} 
										return SELECT.SEXE"/>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Tranches d'age" label="Tranches d'age" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
            <CHART title="" type="group" subType="h" percentHeight="100" fromTotal="false" visibleCondition="SELECT.GROUPBY.substr(0,6) == 'AGECLS' || SELECT.GROUPBY == 'AGE' || SELECT.GROUPBY_2.substr(0,6) == 'AGECLS' || SELECT.GROUPBY_2 == 'AGE'">			
                <CHART title="Pyramide (séjours)" type="barChart" subType="overlaid" sortField="COD" sortSeq="A" maxItems="150" visibleCondition="SELECT.GROUPBY.substr(0,6) == 'AGECLS' || SELECT.GROUPBY == 'AGE'" condition="ROW.LVL == '1'">
                    <CATEGORY field="TXT" type="Number"/>
                    <SERIEx field="NB" displayName="Total"/>
                    <SERIE field="NMPYR" displayName="Hommes"/>
                    <SERIE field="NF" displayName="Femmes"/>
                </CHART>
                <CHART title="Sexes (séjours)" type="pieChart" subType="" fromTotal="true" serieIsCategory="true" visibleCondition="SELECT.GROUPBY.substr(0,6) == 'AGECLS' || SELECT.GROUPBY == 'AGE'">
                    <CATEGORY field="TXT" type="Number"/>
                    <SERIE field="NM" displayName="Hommes"/>
                    <SERIE field="NF" displayName="Femmes"/>
                </CHART>
			</CHART>             
            <CHART title="" type="group" subType="h" percentHeight="100" fromTotal="false" visibleCondition="SELECT.GROUPBY.substr(0,6) != 'AGECLS' &amp;&amp; SELECT.GROUPBY != 'AGE'">			
                <CHART title="Age moyen" type="lineChart" subType="" sortField="COD" sortSeq="A" maxItems="20" maxItemsSortOn="NB" maxItemsSortSeq="D" visibleCondition="SELECT.GROUPBY.substr(0,6) != 'AGECLS' &amp;&amp; SELECT.GROUPBY != 'AGE'" condition="ROW.LVL == '1'">
                    <CATEGORY field="COD" type="Number"/>
                    <SERIE field="AGM" displayName="Age moyen"/>
                </CHART>
                <CHART title="Décomposition masculin/féminin (séjours)" type="columnChart" subType="stacked" sortField="NB" sortSeq="D" maxItems="20" maxItemsSortOn="NB" maxItemsSortSeq="D" visibleCondition="SELECT.GROUPBY.substr(0,6) != 'AGECLS' &amp;&amp; SELECT.GROUPBY != 'AGE'">
                    <CATEGORY field="COD" type="Number"/>
                    <SERIE field="NM" displayName="Hommes"/>
                    <SERIE field="NF" displayName="Femmes"/>
                </CHART>
			</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' || 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="NBRSS" width="60" type="Number" visible="false" headerText="Nb RSS" />-->
				<COLUMN dataField="AMI" width="60" type="Number" visible="false" headerText="Age min" />
				<COLUMN dataField="AMX" width="60" type="Number" visible="false" headerText="Age max" />
				<COLUMN dataField="AG" width="60" type="Number" visible="false" totalFunction="sum" otherFunction="sum" headerText="Total age" />
				<COLUMN dataField="COD" width="60" 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" minWidth="200" maxWidth="300" headerText="Texte" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres" />
				<COLUMN dataField="NB" width="80" type="Number" outputFormat="#" headerText="Nb total séjours" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours différents. Les séjours multi séances comptent pour 1" />
				<COLUMN dataField="PSEJ" width="80" type="Number" outputFormat="#,0%" headerText="% Séjours" textAlign="right" fixed="false" totalFunction="calc" otherFunction="calc" calc="true"
					description="Poids du nombre de séjours du critère de regroupement dans le nombre de séjours total">
					<CALC formula="ROW.NB / TOTALROW.NB * 100" />
				</COLUMN>			
				<COLUMN dataField="NM" width="80" type="Number" selectable="true" outputFormat="#" headerText="Nb séjours hommes" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours de patients de sexe masculin" />
                <COLUMN dataField="PHOMME" width="80" type="Number" outputFormat="#,0%" headerText="%  hommes" textAlign="right" fixed="false" totalFunction="calc" otherFunction="calc" calc="true"
					description="Rapport (en pourcentage) entre les colonnes &lt;b&gt;Nb séjours hommes&lt;/b&gt; et &lt;b&gt;Nb total hommes &lt;/b&gt;">
					<CALC formula="ROW.NM / TOTALROW.NM * 100" />
				</COLUMN>
				<COLUMN dataField="NF" width="80" type="Number" selectable="true" outputFormat="#" headerText="Nb séjours femmes" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum" 
					description="Nombre de séjours de patients de sexe féminin" />
				<COLUMN dataField="NMPYR" width="80" type="Number" visible="false" outputFormat="@#" headerText="Nb séjours hommes" textAlign="right" fixed="false" totalFunction="calc" otherFunction="calc" calc="true">
					<CALC formula="0 - ROW.NM" />
				</COLUMN>
                <COLUMN dataField="PFEMME" width="80" type="Number" outputFormat="#,0%" headerText="%  Femmes" textAlign="right" fixed="false" totalFunction="calc" otherFunction="calc" calc="true"
					description="Rapport (en pourcentage) entre les colonnes &lt;b&gt;Nb séjours femmes&lt;/b&gt; et &lt;b&gt;Nb total séjours femmes&lt;/b&gt;">
					<CALC formula="ROW.NF / TOTALROW.NF * 100" />
				</COLUMN>				
                <COLUMN dataField="AGM" width="80" type="Number" outputFormat="0#,0" headerText="Age moyen séjour" textAlign="right" fixed="false" totalFunction="calc" otherFunction="calc" calc="true"
					description="Somme des âges de chaque séjour divisé par le nombre de séjours.&lt;br/&gt;L'âge est déterminé à l'entrée du patient dans l'établissement et correspond à la différence entre la date d'entrée et la date de naissance">
					<CALC formula="ROW.AG / ROW.NB" />
				</COLUMN>
				<COLUMN dataField="AGEMEDIAN" width="80" type="Number" selectable="true" outputFormat="0#,0" headerText="Age médian séjour" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum"
					description="Age pour lequel il y a autant de séjours dont le patient a un âge inférieur que de séjours dont le patient a un âge supérieur.&lt;br/&gt;L'âge est déterminé à l'entrée du patient dans l'établissement et correspond à la différence entre la date d'entrée et la date de naissance" />
				<COLUMN dataField="NP" width="80" type="Number" outputFormat="#" headerText="Nb total patients" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum"
					description="Nombre de patients différents" />
				<!--
				<COLUMN dataField="AGP" width="80" type="Number" outputFormat="0#,0" headerText="Age moyen patient" textAlign="right" fixed="false" totalFunction="calc" otherFunction="calc" calc="true"
					description="Somme des ages de chaque séjour divisé par le nombre de séjours">
					<CALC formula="ROW.AG / ROW.NBRSS" />
				</COLUMN>
				-->
				<COLUMN dataField="PM" width="80" type="Number" selectable="true" outputFormat="#" headerText="Nb patients hommes" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum"
					description="Nombre de patients de sexe masculin" />
				<COLUMN dataField="PF" width="80" type="Number" selectable="true" outputFormat="#" headerText="Nb patients femmes" textAlign="right" fixed="false" totalFunction="sum" otherFunction="sum"
					description="Nombre de patients de sexe féminin" />			
            </DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
