<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000020" label="PMSI. Diagnostics" title="= 'Fréquence des diagnostics 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:diagnostics" helpDokuWIkiFile="pmsi000020"  helpFile="iCTI_PMSI_PMSI000020.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_DIAG" />
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
		<PROPERTY name="SORTBY">
			<value><![CDATA[[EVAL 
			
				if (substr('[GROUPBY]',0,6) == 'DIACLS') {
					return 'DEFAULT';
				}
				else {
					return 'indicateurs[2]';
				}
			EVAL]]]></value>
		</PROPERTY>		
        <PROPERTY name="SORTBYASCDESC">
			<value><![CDATA[[EVAL 
			
				if (substr('[GROUPBY]',0,6) == 'DIACLS') {
					return 'ASC';
				}
				else {
					return 'DESC';
				}
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse">
		<GROUP>
			<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="DIAG" tree="true">
				<OPTION label="Options" data="" globalListProvider="DIAG_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="DIAG_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="DIAG_GROUPBY_OPTIONS" />
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_DIAG_SELECTIONS" />
	<SELECTIONS componentName="FILTRES_DIAG_SOUSSELECTIONS" />
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_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]}
						INDICATORS{
                                count(DISTINCT v_rss_1.patient_id),
                                count(DISTINCT v_rss_1.rss_id),
                                sum(nb_diagnostics),
                                sum(nb_diagnostics_rss_p),
                                sum(nb_diagnostics_rss_r),
                                sum(nb_diagnostics_rss_a),
                                sum(nb_diagnostics_rss_d),
                                min(diagnostic_severite_fg2023_code)::bigint,
                                count(DISTINCT CASE WHEN (nb_diag_polyhand_liste1 + nb_diag_polyhand_liste2 + nb_diag_polyhand_liste3 +nb_diag_polyhand_liste4 ) = 1 THEN v_rss_1.rss_id ELSE NULL END),
                                count(DISTINCT CASE WHEN (nb_diag_polyhand_liste1 + nb_diag_polyhand_liste2 + nb_diag_polyhand_liste3 +nb_diag_polyhand_liste4 ) = 2 THEN v_rss_1.rss_id ELSE NULL END),
                                count(DISTINCT CASE WHEN (nb_diag_polyhand_liste1 + nb_diag_polyhand_liste2 + nb_diag_polyhand_liste3 +nb_diag_polyhand_liste4 ) = 3 THEN v_rss_1.rss_id ELSE NULL END),
                                count(DISTINCT CASE WHEN (nb_diag_polyhand_liste1 + nb_diag_polyhand_liste2 + nb_diag_polyhand_liste3 +nb_diag_polyhand_liste4 ) = 4 THEN v_rss_1.rss_id ELSE NULL END),
                                count(DISTINCT CASE WHEN v_rss_diagnostics_1.diagnostic_code = ANY (ARRAY['Z5500'::text,'Z5508'::text,'Z551'::text,'Z590'::text,'Z5910'::text,'Z5911'::text,'Z5912'::text,'Z5913'::text,'Z5918'::text,'Z5950'::text,'Z5958'::text,'Z5960'::text,'Z5961'::text,'Z5962'::text,'Z5968'::text,'Z5970'::text,'Z5978'::text,'Z6020'::text,'Z6028'::text,'Z6030'::text,'Z6038'::text])  THEN v_rss_diagnostics_1.rss_id ELSE NULL END),
                                base.cti_sum_distinct_on(DISTINCT ARRAY[v_rss_1.rss_id::text, duree_sejour::text]),
                                count(DISTINCT CASE WHEN nb_rsa_0n > 0 THEN v_rss_1.rss_id ELSE NULL END)
                       }
                        ORDERBY{[VIEW.SORTBY],,[VIEW.SORTBYASCDESC]}
					FROM #V_RSS_X#
                    LEFT JOIN pmsi.v_rss_diag_handicaplourd_1 ON v_rss_1.rss_id = v_rss_diag_handicaplourd_1.rss_id 
						
					WHERE 
                        mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'

						[VIEW.FILTRE_RSS_SELECT]
						[VIEW.FILTRE_DIAG_SELECT]
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="SORT" />
					<FIELD name="PAT" />
					<FIELD name="SEJ" />
					<FIELD name="NB" />
					<FIELD name="NBP" />
					<FIELD name="NBR" />
					<FIELD name="NBA" />
					<FIELD name="NBD" />
					<FIELD name="CMA" />
					<FIELD name="SHL1" />
					<FIELD name="SHL2" />
					<FIELD name="SHL3" />
					<FIELD name="SHL4" />
					<FIELD name="NBSEJDIAGPREC" />
					<FIELD name="NBJOUR" />
					<FIELD name="NB0N" />
				</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="PMSI000023.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="DATA1" value="'1'" />
				<ARG name="DATA2" value="'2'" />
				<ARG name="DATA3" value="'4'" />
			</VIEWLINK>
			<VIEWLINK label="Evolution" shortLabel="Evolution" view="PMSI000022.XML" enabled="true" rowContext="false" componentName="PERIODICITE_VIEWLINK" buttonType="EVOLUTION">
				<ARG name="DATA" value="'1'" />
			</VIEWLINK>
			<VIEWLINK label="Analyse croisée" shortLabel="Analyse croisée" view="PMSI000218.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="'1'" />
				<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 Diagnostics par RSS" shortLabel="Liste Diagnostics" view="PMSI000021.XML" componentName="RSS_BASE_VIEWLINK" component2Name="DIAG_VIEWLINK" component3Name="" >
			</VIEWLINK>
			<VIEWLINK label="Liste des RSS" shortLabel="Liste RSS" view="PMSI000005.XML" componentName="RSS_BASE_VIEWLINK" component2Name="RSS_OTHERS_VIEWLINK" component3Name="DIAG_VIEWLINK" >
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Analyse diagnostics" label="Analyse diagnostics" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
            <CHART title="" type="group" subType="h" percentHeight="100" fromTotal="false">			
				<CHART title="Nombre de Diagnostics" type="pieChart" subType="" maxItems="10" maxItemsSortOn="NB" maxItemsSortSeq="D" sortField="NB" sortSeq="D" condition="ROW.LVL == '1'">
					<CATEGORY field="TXT" type="Char" />
					<SERIE field="NB" displayName="Diagnostics" />
				</CHART>
                <CHART title="Décomposition des plus fréquents" type="columnChart" subType="stacked" maxItems="10" sortField="NB" sortSeq="D">
                    <CATEGORY field="COD" type="Char" />
                    <SERIE field="NBP" displayName="Diagnostics principaux" />
                    <SERIE field="NBR" displayName="Diagnostics reliés" />
                    <SERIE field="NBA" displayName="Diagnostics associés" />
                    <SERIE field="NBD" displayName="Diagnostics documentaires" />
                </CHART>
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="60" variableRowHeight="true" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'"
				sortable="= SELECT.GROUPBY_3 == '-1' &amp;&amp; (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="PAT" width="65" type="Number" outputFormat="#" headerText="Patients" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de patients différents" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                     
				<COLUMN dataField="SEJ" width="65" type="Number" outputFormat="#" headerText="Séjours" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours différents" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>				
                <COLUMN dataField="NBJOUR" width="65" type="Number" outputFormat="#" headerText="Nombre de journées" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de journées" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>				
                <COLUMN dataField="NB0N" width="65" type="Number" outputFormat="#" headerText="Séjours&#xD;0 nuit" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de séjours de 0 nuit" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN> 
				<COLUMN dataField="NB" width="70" type="Number" outputFormat="#" headerText="Diagnostics" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de diagnostics (DP, DR, DA et DD confondus)" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                     
				<COLUMN dataField="PNB" type="Number" headerText="% / Total" width="50" outputFormat="#,00%" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true"
					description="Poids du nombre de diagnostics du critère de regroupement dans le nombre de diagnosctics total">
					<CALC formula="ROW.NB / TOTALROW.NB * 100" />
                    <HEADERCELLSTYLE name="textAlign" value="center"/> 
				</COLUMN>
				<COLUMN dataField="NBP" width="85" type="Number" outputFormat="#" headerText="Diagnostics&#xD;principaux" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de diagnostics principaux" />
				<COLUMN dataField="PNBP" type="Number" headerText="% DP" width="55" outputFormat="#,00%" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true"
					description="Pourcentage de diagnostics qui sont des diagnostics principaux. Rapport (en pourcentage) entre les colonnes &lt;b&gt;Dont DP&lt;/b&gt; et &lt;b&gt;Diagnostics&lt;/b&gt;">
					<CALC formula="ROW.NBP / ROW.NB * 100" />
				</COLUMN>
				<COLUMN dataField="NBR" width="85" type="Number" outputFormat="#" headerText="Diagnostics&#xD;reliés" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de diagnostics reliés" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                
				<COLUMN dataField="NBA" width="85" type="Number" outputFormat="#" headerText="Diagnostics&#xD;associés" textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de diagnostics associés" >
                <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                
				<COLUMN dataField="NBD" width="85" type="Number" outputFormat="#" headerText="Diagnostics&#xD;doc." textAlign="right" totalFunction="sum" otherFunction="sum"
					description="Nombre de diagnostics documentaires" >
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
                </COLUMN>
				<COLUMN dataField="CMA" width="85" type="Number" outputFormat="#" headerText="Sévérité CMA" textAlign="right" totalFunction="text" totalComplement="Sévérité" visibleCondition="SELECT.GROUPBY == 'DIAG' || SELECT.GROUPBY_2 == 'DIAG'"
					description="Complications ou Morbidité Associées" >
					<HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                    
                <COLUMN dataField="NBSEJDIAGPREC" width="85" type="Number" outputFormat="#" headerText="Séjours&#xD;avec diag. &#xD;de précarité" textAlign="right" totalFunction="sum" otherFunction="sum" 
					description="Nombre de séjours avec diagnosctics de précarité" >
					<HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                    
                <COLUMN dataField="PNBSEJDIAGPREC" type="Number" headerText="%@LF@Total" width="55" outputFormat="#,00%" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true" description="% total">
					<CALC formula="ROW.NBSEJDIAGPREC * 100/ TOTALROW.SEJ" />
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>
                <COLUMN dataField="SHL" width="85" type="Number" outputFormat="#" headerText="Séjours avec handicap lourd" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true" 
					description="Nombre de séjours avec polyhandicap lourd" >
                    <CALC formula="ROW.SHL1 + ROW.SHL2 + ROW.SHL3 + ROW.SHL4" />
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>
				<COLUMN dataField="PSHL" type="Number" headerText="%@LF@Total" width="55" outputFormat="#,00%" textAlign="right" totalFunction="calc" otherFunction="calc" calc="true" description="% total">
					<CALC formula="ROW.SHL * 100/ TOTALROW.SEJ" />
                    <HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>				
                <COLUMN dataField="SHL1" width="85" type="Number" outputFormat="#" headerText="Dont séjours&#xD;avec diag. &#xD;dans 1 liste" textAlign="right" totalFunction="sum" otherFunction="sum" 
					description="Nombre de séjours avec au moins un code dans une liste parmi les listes des codes de la CIM-10 pour l'identification du polyhandicap lourd.&#xD;Liste 1 : Déficiences mentales ou psychiatriques sévères.&#xD;Liste 2 : Troubles moteurs.&#xD;Liste 3 : Critères de mobilité réduite.&#xD;Liste 4 : Restrictions extrêmes de l'autonomie" >
					<HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                
                <COLUMN dataField="SHL2" width="85" type="Number" outputFormat="#" headerText="Dont séjours&#xD;avec diag. &#xD;dans 2 listes" textAlign="right" totalFunction="sum" otherFunction="sum" 
					description="Nombre de séjours avec au moins un code dans deux listes parmi les listes des codes de la CIM-10 pour l'identification du polyhandicap lourd.&#xD;Liste 1 : Déficiences mentales ou psychiatriques sévères.&#xD;Liste 2 : Troubles moteurs.&#xD;Liste 3 : Critères de mobilité réduite.&#xD;Liste 4 : Restrictions extrêmes de l'autonomie" >
					<HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                    
                <COLUMN dataField="SHL3" width="85" type="Number" outputFormat="#" headerText="Dont séjours&#xD;avec diag. &#xD;dans 3 listes" textAlign="right" totalFunction="sum" otherFunction="sum" 
					description="Nombre de séjours avec au moins un code dans trois listes parmi les listes des codes de la CIM-10 pour l'identification du polyhandicap lourd.&#xD;Liste 1 : Déficiences mentales ou psychiatriques sévères.&#xD;Liste 2 : Troubles moteurs.&#xD;Liste 3 : Critères de mobilité réduite.&#xD;Liste 4 : Restrictions extrêmes de l'autonomie" >
					<HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                    
                <COLUMN dataField="SHL4" width="85" type="Number" outputFormat="#" headerText="Dont séjours&#xD;avec diag. &#xD;dans 4 listes" textAlign="right" totalFunction="sum" otherFunction="sum" 
					description="Nombre de séjours avec au moins un code dans quatre listes parmi les listes des codes de la CIM-10 pour l'identification du polyhandicap lourd.&#xD;Liste 1 : Déficiences mentales ou psychiatriques sévères.&#xD;Liste 2 : Troubles moteurs.&#xD;Liste 3 : Critères de mobilité réduite.&#xD;Liste 4 : Restrictions extrêmes de l'autonomie" >
					<HEADERCELLSTYLE name="textAlign" value="center"/>
				</COLUMN>                    
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
