<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000466" label="PMSI. Justificatif des rejets par RSS" title="= 'Justificatif des rejets par RSS (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ') - ' + SELECT.VERSION_GROUPAGE_LABEL" database="iCTI" swf="*CTI_view1" softCode="iCTI_pmsi" typeEts="" globals="PMSI_globals.XML" componentsFile="PMSI_components.XML" helpDokuWIkiDir="pmsi:sejours_analyse_globale:rss:chiffre_d_affaire_rss:" helpDokuWIkiFile="pmsi000038"  helpFile="iCTI_PMSI_PMSI000038.HTML">
	<VIEWPROPERTIES>
		<PROPERTYx dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Date sortie">
			<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" globalListProvider="DATE_DEBUT" printable="false">
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" globalListProvider="DATE_FIN" printable="false">
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" select="
            	
            DROP TABLE IF EXISTS w_montant_br;
            CREATE TEMP TABLE w_montant_br AS
				SELECT v_rss_1.rss_id,sum(v_rsf_detail_1.base_remboursement_sauf_transition) as base_remboursement_sauf_transition
				FROM pmsi.v_rsf_detail_1
                JOIN pmsi.v_rss_5 v_rss_1 ON v_rsf_detail_1.rss_id = v_rss_1.rss_id
                WHERE 	date_sortie &gt;= '[PERIODE]'	
                        AND date_sortie &lt;='[TOPERIODE]'
                    AND v_rss_1.traitement_epmsi in ('11','12','13','21','22','23','24','25','26')
					AND prestation_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = (SELECT oid  FROM pmsi.t_listes where code = 'CTI_GHS_SUPPL'))
					[VIEW.FILTRE_RSS_SELECT]
				group by 1;
            
				(SELECT v_rss_1.rss_id, 
                        v_rss_1.no_rss,
                        v_rss_1.no_sejour_administratif,
                        v_rss_1.finess, p_identites.nom || ' ' || p_identites.prenom,
                        ghm_code,
                        v_rss_1.ghs_code,
                        medecin_reference_rss_nom,
						date_sortie,
                        sexe,
                        age,
						duree_sejour,
                        CASE WHEN cas_code in ('90') THEN 1 ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '12' then '1' ELSE NULL END,
                        CASE WHEN v_rss_1.ghs_code ilike '9999%' OR ghm_code in ('15Z10E','28Z04Z') AND en_cours = '0' AND cas_code not in ('*','?')  THEN '1' ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '21' then '1'  ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '22' then '1' ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '24' then '1' ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '23' then '1' ELSE NULL END,
                        
                        CASE WHEN cas_code in ('90') THEN w_montant_br.base_remboursement_sauf_transition ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '12' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END,
                        CASE WHEN v_rss_1.ghs_code ilike '9999%' OR ghm_code in ('15Z10E','28Z04Z') AND en_cours = '0' AND cas_code not in ('*','?')  THEN w_montant_br.base_remboursement_sauf_transition ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '21' then w_montant_br.base_remboursement_sauf_transition  ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '22' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '24' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END,
                        CASE WHEN v_rss_1.traitement_epmsi = '23' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END
				FROM [VIEW.V_RSS_VIEW_OPTIMIZE],pmsi.p_identites,w_montant_br
				WHERE 
					v_rss_1.rss_id = p_identites.rss_id
					AND v_rss_1.rss_id = w_montant_br.rss_id
					AND date_sortie &gt;= '[PERIODE]'	AND date_sortie &lt;='[TOPERIODE]'
                    AND v_rss_1.traitement_epmsi in ('11','12','13','21','22','23','24','25','26')
					
					[VIEW.FILTRE_RSS_SELECT]
				)
				

				UNION ALL
				
				(SELECT -9999999,
                        COUNT(DISTINCT v_rss_1.no_rss),
                        '',
                        '', 
						SUM(nb_rsa)::text || ' séjours, ' || COUNT(DISTINCT patient_id)::text || ' patients' , 
						'',
                        '',
                        '',
						null,
                        '',
                        0,
                        SUM(duree_sejour),
                        SUM(CASE WHEN cas_code in ('90') THEN 1 ELSE 0 END),
                        SUM( CASE WHEN v_rss_1.traitement_epmsi = '12' then 1  ELSE 0 END)::text,
                        SUM(CASE WHEN v_rss_1.ghs_code ilike '9999%' OR ghm_code in ('15Z10E','28Z04Z') AND en_cours = '0' AND cas_code not in ('*','?')  THEN 1 ELSE 0 END)::text,
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '21' then 1 ELSE 0 END)::text,
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '22' then 1 ELSE 0 END)::text,
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '24' then 1 ELSE 0 END)::text,
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '23' then 1 ELSE 0 END)::text,
                        
                        SUM(CASE WHEN cas_code in ('90') THEN w_montant_br.base_remboursement_sauf_transition ELSE NULL END),
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '12' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END),
                        SUM(CASE WHEN v_rss_1.ghs_code ilike '9999%' OR ghm_code in ('15Z10E','28Z04Z') AND en_cours = '0' AND cas_code not in ('*','?')  THEN w_montant_br.base_remboursement_sauf_transition ELSE NULL END),
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '21' then w_montant_br.base_remboursement_sauf_transition  ELSE NULL END),
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '22' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END),
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '24' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END),
                        SUM(CASE WHEN v_rss_1.traitement_epmsi = '23' then w_montant_br.base_remboursement_sauf_transition ELSE NULL END)
                FROM [VIEW.V_RSS_VIEW_OPTIMIZE], pmsi.p_identites,w_montant_br
				WHERE 
					v_rss_1.rss_id = p_identites.rss_id
					AND v_rss_1.rss_id = w_montant_br.rss_id
					AND date_sortie &gt;= '[PERIODE]'	AND date_sortie &lt;='[TOPERIODE]'
					AND v_rss_1.traitement_epmsi in ('11','12','13','21','22','23','24','25','26')
                    
					[VIEW.FILTRE_RSS_SELECT]
				)
					
				ORDER BY 2
				">
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="RSS"/>
					<FIELD name="SEJ"/>
					<FIELD name="FIN"/>
					<FIELD name="NOM" ifHideNames="Non autorisé"/>
					<FIELD name="GHM"/>
					<FIELD name="GHS"/>
					<FIELD name="MED"/>
					<FIELD name="DATE"/>
					<FIELD name="SEX"/>
					<FIELD name="AGE"/>
					<FIELD name="NBJ"/>
					<FIELD name="CMD90"/>
					<FIELD name="NBPIE"/>
					<FIELD name="GHS9999"/>
					<FIELD name="PBCHAINAGE"/>
					<FIELD name="PBCODAGE"/>
					<FIELD name="NONFACTAM"/>
					<FIELD name="ATTDICDROI"/>					
                    
                    <FIELD name="MTCMD90"/>
					<FIELD name="MTNBPIE"/>
					<FIELD name="MTGHS9999"/>
					<FIELD name="MTPBCHAINAGE"/>
					<FIELD name="MTPBCODAGE"/>
					<FIELD name="MTNONFACTAM"/>
					<FIELD name="MTATTDICDROI"/>
				</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="Liste RSS">
			<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" frozen="left" width="60" type="Char" visible="true" headerText="Etablissement" textAlign="left" visibleCondition="ENV.CONSOLIDATION == '1'" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="RSS" frozen="left" width="60" type="Char" visible="true" headerText="N° RSS" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="SEJ" frozen="left" width="90" type="Char" visible="true" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="NOM" frozen="left" minWidth="150" type="Char" visible="true" headerText="Nom" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="SEX" width="40" type="Char" visible="true" headerText="Sexe" textAlign="right" otherFunction="text" totalFunction="text">
					<CELLSTYLE name="cellIndicator" value="femme, 12,left middle , 0xEB76B1" condition="ROW.SEX == '2'" /> 
					<CELLSTYLE name="cellIndicator" value="homme, 12,left middle , 0x75a0eb " condition="ROW.SEX == '1'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10,left middle , #FF5001 " condition="ROW.SEX == '3'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0x666666" condition="ROW.SEX != '2' &amp;&amp; ROW.SEX != '1' &amp;&amp; ROW.SEX != '3'" />
				</COLUMN>
				<COLUMN dataField="AGE" width="35" type="Number" outputFormat="#" visible="true" headerText="Age" textAlign="right" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATE" 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="NBJ" width="50" visible="true" type="Number" outputFormat="#" headerText="Durée séjour" fixed="false" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>				
                <COLUMN dataField="GHM" width="50" type="Char" visible="true" headerText="GHM" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHS" width="50" type="Char" visible="true" headerText="GHS" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="MED" width="100" type="Char" visible="true" headerText="Médecin" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>				
                <COLUMN dataField="CMD90" width="50" type="Char" visible="true" headerText="CMD 90" description="Séjours en CM 90"  textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTCMD90" width="50" type="Number" outputFormat="#E" visible="true" headerText="MT CMD 90" description="Montant des séjours en CM 90"  textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="NBPIE" width="50" type="Char" visible="true" headerText="PIE" description="Séjours en prestation inter-établissement"  textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTNBPIE" width="50" type="Number" outputFormat="#E" visible="true" headerText="MT PIE" description="Montant des séjours en prestation inter-établissement"  textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="GHS9999" width="50" type="Char" visible="true" headerText="GHS 9999" description="Séjours en GHS 9999"  textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTGHS9999" width="50" type="Number" outputFormat="#E" visible="true" headerText="MT GHS 9999" description="Montant des séjours en GHS 9999"  textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="PBCHAINAGE" width="80" type="Char" visible="true" headerText="Problème chainage" description="Séjours avec pb de chainage (hors NN, rdth et PO)" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTPBCHAINAGE" width="80" type="Number" outputFormat="#E" visible="true" headerText="MT Problème chainage" description="Montant des séjours avec pb de chainage (hors NN, rdth et PO)" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="PBCODAGE" width="80" type="Char" visible="true" headerText="problème codage" description="Séjours avec pb de codage des variables bloquantes" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTPBCODAGE" width="80" type="Number" outputFormat="#E" visible="true" headerText="MT problème codage" description="Montant des séjours avec pb de codage des variables bloquantes" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="NONFACTAM" width="80" type="Char" visible="true" headerText="Non fact. AM" description="Séjours non facturable à l'AM hors PO" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTNONFACTAM" width="80" type="Number" outputFormat="#E" visible="true" headerText="MT Non fact. AM" description="Montant des séjours non facturable à l'AM hors PO" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="ATTDICDROI" width="90" type="Char" visible="true" headerText="Att. décision droits" description="Séjours en attente de décision sur les droits du patient" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>                
                <COLUMN dataField="MTATTDICDROI" width="90" type="Number" outputFormat="#E" visible="true" headerText="MT Att. décision droits" description="Montant des séjours en attente de décision sur les droits du patient" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
