<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000010" label="PMSI. Justificatif séjours extrêmes" title="= SELECT.DATA2 + ' par RSS (' + 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:rss:chiffre_d_affaire_rss:" helpDokuWIkiFile="pmsi000007"  helpFile="iCTI_PMSI_PMSI000010.HTML">
	<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="" 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="Données">
			<FIELD name="DATA" label="" UI="combo" default="1" printable="false">
				<OPTION label="Séjours EXH" data="1" data2="EXH"/>
				<OPTION label="Séjours EXB et Rehospitalisations même GHM" data="2" data2="EXB"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="SHOWDMSREF" label="" width="1" UI="text" default="1" printable="false" visible="false"/>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" select="
				(SELECT v_rss_1.rss_id, 
						v_rss_1.no_rss, 
						v_rss_1.finess, 
						identite_nom || ' ' || identite_prenom, 
						v_rss_1.no_patient, 
						ghm_code, 
						ghm_texte, 
						ligne_oap_code, 
						medecin_reference_rss_nom, 
						diagnostic_principal_code, 
						diagnostic_principal_texte,
						acte_principal_code, 
						acte_principal_texte, 
						date_entree, 
						mode_entree,
						date_sortie,
						mode_sortie,						
						base_remboursement, 
						t2a_facture, 
						dmi_facture,
						phc_facture, 
						duree_sejour, 
						nb_seances, 
						ghs_borne_basse, 
						ghs_borne_haute, 
						[VIEW.DMS_FIELD],
						[DATA!=2::nb_exh, ca_exh, 0, 0, 0]
						[DATA==2::nb_exb, 
								ca_ghs, 
								ca_ghs_theorique,
								CASE WHEN nb_ghsmin = 1 OR rehosp_meme_ghm = '1' THEN 0 ELSE 0 - ca_perte_exb END,
								CASE WHEN nb_ghsmin = 0 AND rehosp_meme_ghm = '1' THEN 0 - ca_perte_exb ELSE 0 END,
								CASE WHEN nb_ghsmin = 1 THEN 0 - ca_perte_exb ELSE 0 END
								]
				FROM #V_RSS_X#
				WHERE 
					mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie &gt;= '[PERIODE]'	AND date_sortie &lt;='[TOPERIODE]'
					

					[DATA!=2::AND nb_exh &lt;&gt; 0]
					[DATA==2::AND (nb_exb &lt;&gt; 0 OR nb_ghsmin &lt;&gt; 0)]

					
					[VIEW.FILTRE_RSS_SELECT]
				)
					
				UNION ALL
				
				(SELECT -9999999, 
						null, 
						'', 
						SUM(nb_rsa)::text || ' séjours, ' || COUNT(DISTINCT patient_id)::text || ' patients' ,
						0,
						'', 
						'', 
						'', 
						'', 
						'', 
						'', 
						'', 
						'', 
						null, 
						'',
						null,
						'',
						SUM(base_remboursement),
						0,
						0,
						0, 
						0, 
						0, 
						0, 
						0, 
						0,
						[DATA!=2::SUM(nb_exh), SUM(ca_exh), 0, 0, 0] 
						[DATA==2::
							SUM(nb_exb),
							SUM(ca_ghs),
							SUM(ca_ghs_theorique),
							0 - SUM(CASE WHEN nb_ghsmin = 1 OR rehosp_meme_ghm = '1' THEN 0 ELSE ca_perte_exb END),
							0 - SUM(CASE WHEN nb_ghsmin = 0 AND rehosp_meme_ghm = '1' THEN ca_perte_exb ELSE 0 END),
							0 - SUM(CASE WHEN nb_ghsmin = 1 THEN ca_perte_exb ELSE 0 END)
							]
				FROM #V_RSS_X# 
				WHERE 
					 mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) AND date_sortie &gt;= '[PERIODE]'	AND date_sortie &lt;='[TOPERIODE]'
					

					[DATA!=2::AND nb_exh &lt;&gt; 0]
					[DATA==2::AND (nb_exb &lt;&gt; 0 OR nb_ghsmin &lt;&gt; 0)]

					
					[VIEW.FILTRE_RSS_SELECT]
				)
										
				ORDER BY 2
				">
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="RSS"/>
					<FIELD name="FIN"/>
					<FIELD name="NOM" ifHideNames="Non autorisé"/>
					<FIELD name="IPP"/>
					<FIELD name="GHM"/>
					<FIELD name="GHMT"/>
					<FIELD name="OAP"/>
					<FIELD name="MED"/>
					<FIELD name="DIAGP"/>
					<FIELD name="DIAGPT"/>
					<FIELD name="ACTEP"/>
					<FIELD name="ACTEPT"/>
					<FIELD name="DENT"/>
					<FIELD name="MENT"/>
					<FIELD name="DSOR"/>
					<FIELD name="MSOR"/>
					<FIELD name="CA"/>
					<FIELD name="CT2A"/>
					<FIELD name="CDMI"/>
					<FIELD name="CPHC"/>
					<FIELD name="NBJ"/>
					<FIELD name="NSEA"/>
					<FIELD name="BBAS"/>
					<FIELD name="BHAU"/>
					<FIELD name="DMSN"/>
					<FIELD name="NEX"/>
					<FIELD name="CAEX"/>
					<FIELD name="CEX"/>
					<FIELD name="PEX"/>
					<FIELD name="PRH"/>
					<FIELD name="PMF"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Détail RSS" shortLabel="Détail RSS" view="PMSI000006.XML">
				<ARG name="OID" value="ROW.OID"/>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Séjours extrêmes" label="Séjours extrêmes">
			<DATAGRID title="" total="true" key="RSS" headerHeight="36" totalRowInRows="= ROW.OID == '-9999999'">
				<ROWSTYLE name="fontSize" value="11"/>
				<FOOTERROWSTYLE name="fontSize" value="11"/>
				<COLUMN dataField="OID" type="Char" visible="false">
				</COLUMN>
				<COLUMN dataField="FIN" width="60" type="Char" visible="true" headerText="Etablissement" textAlign="left" visibleCondition="ENV.CONSOLIDATION == '1'" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="RSS" width="60" type="Char" visible="true" headerText="N° RSS" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="NOM" minWidth="200" type="Char" visible="true" headerText="Nom" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="IPP" width="60" type="Char" visible="true" headerText="IPP" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="DENT" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date entrée" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="MENT" width="25" type="Char" visible="true" headerText="ME" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DSOR" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date sortie" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="MSOR" width="25" type="Char" visible="true" headerText="MS" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHM" width="60" type="Char" visible="true" headerText="GHM" textAlign="left" fixed="false" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHMT" minWidth="100" type="Char" visible="true" headerText="GHM" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="MED" width="100" type="Char" visible="true" headerText="Médecin" textAlign="left" fixed="false" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DIAGP" width="50" type="Char" visible="true" headerText="Diag P" fixed="false" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DIAGPT" minWidth="100" type="Char" visible="true" headerText="Diag P" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="ACTEP" width="60" type="Char" visible="true" headerText="Acte P" textAlign="left" fixed="false" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="ACTEPT" minWidth="100" type="Char" visible="true" headerText="Acte P" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="CA" width="80" visible="true" type="Number" outputFormat="#E" fixed="false" headerText="C.A. Séjour" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="NBJ" width="50" visible="true" type="Number" outputFormat="#" headerText="Durée séjour" fixed="false" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="BHAU" width="50" visibleCondition="SELECT.DATA == '1'" type="Number" outputFormat="#" headerText="Borne haute" fixed="false" textAlign="right" totalFunction="text" otherFunction="">
				</COLUMN>
				<COLUMN dataField="BBAS" width="50" visibleCondition="SELECT.DATA == '2'" type="Number" outputFormat="#" headerText="Borne basse" fixed="false" textAlign="right" totalFunction="text" otherFunction="">
				</COLUMN>
				<COLUMN dataField="DMSN" width="50" visible="true" type="Number" outputFormat="#,0" headerText="DMS Ref." fixed="false" textAlign="right" totalFunction="text" otherFunction="">
				</COLUMN>
				<COLUMN dataField="NEX" width="50" visible="true" type="Number" outputFormat="#" fixed="false" headerText="'Nb ' + SELECT.DATA2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" visibleCondition="SELECT.DATA == '1'">
				</COLUMN>
				<COLUMN dataField="CAEX" width="80" visible="true" type="Number" outputFormat="#E" fixed="false" headerText="C.A. GHS incluant EXB" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="CEX" width="80" visible="true" type="Number" outputFormat="#E" fixed="false" headerText="if (SELECT.DATA == '1') {return 'C.A. EXH'} else {return 'C.A. GHS théorique'}" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="PEX" width="80" visible="true" type="Number" outputFormat="#E" fixed="false" headerText="Manque à gagner EXB" textAlign="right" otherFunction="sum" totalFunction="sum" visibleCondition="SELECT.DATA == '2'">
				</COLUMN>
				<COLUMN dataField="PRH" width="80" visible="true" type="Number" outputFormat="#E" fixed="false" headerText="Réhosp" textAlign="right" otherFunction="sum" totalFunction="sum" visibleCondition="SELECT.DATA == '2'">
				</COLUMN>
				<COLUMN dataField="PMF" width="80" visible="true" type="Number" outputFormat="#,0E" fixed="false" headerText="Minor. forfait." textAlign="right" otherFunction="sum" totalFunction="sum" visibleCondition="SELECT.DATA == '2'">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
