<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000026" label="PMSI. Justificatif prestations par RSS" title="= 'Justificatif prestations 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:sejour_analyse_detaillee:prestations" helpDokuWIkiFile="pmsi000025"  helpFile="iCTI_PMSI_PMSI000026.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_PRESTATIONS" />
	<SELECTIONS label="Paramètres de l'analyse">
		<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 name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" printable="false" globalListProvider="DATE_FIN" />
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_PRESTATIONS_SELECTIONS" />
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[ 
					
					(SELECT 
						v_rss_1.rss_id, 
						v_rss_1.no_rss, 
						v_rss_1.no_sejour_administratif, 
						v_rss_1.finess, 
						identite_nom::text || ' '::text || identite_prenom::text, 
						MIN(date_debut), 
						prestation_code, 
						prestation_texte,
						SUM(nombre), 
						SUM(nombre_coefficient), 
						CASE WHEN '[LAMDA]' &lt;&gt; '2' THEN prix_unitaire ELSE 0 END, 
						SUM(v_rsf_detail_1.base_remboursement), 
						SUM(case when v_rss_1.traitement_epmsi IN ('30','31','32','33') THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END),
                        MAX(v_rsf_detail_1.taux_remboursement) as taux_remboursement,
						SUM(case when v_rss_1.traitement_epmsi IN ('30','31','32','33') AND fides_detail IS DISTINCT FROM 1 THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END),
						SUM(case when v_rss_1.traitement_epmsi IN ('30','31','32','33') AND fides_detail = 1 THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END),
                        SUM(case when activite_urgence = '1' THEN 1 ELSE 0 END)
                        
					FROM #V_RSS_X#
						JOIN pmsi.v_rsf_detail_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id 
					WHERE 
					    date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
					
						[VIEW.PRESTATION_SELECT]
						[VIEW.FILTRE_RSS_SELECT]
					GROUP BY 1,2,3,4,5,7,8,11
					)
					
					UNION ALL
					
					(SELECT 
						-9999999, 
						0, 
						'', 
						'', 
						COUNT(DISTINCT v_rss_1.rss_id)::text || ' séjours, '::text || COUNT(DISTINCT v_rss_1.patient_id)::text || ' patients'::text , 
						null, 
						'', 
						COUNT(DISTINCT v_rsf_detail_1.prestation_id)::text || ' codes'::text,
						SUM(nombre), 
						SUM(nombre_coefficient), 
						0,
						SUM(v_rsf_detail_1.base_remboursement), 
						SUM(case when v_rss_1.traitement_epmsi IN ('30','31','32','33') THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END),
                        null,
						SUM(case when v_rss_1.traitement_epmsi IN ('30','31','32','33') AND fides_detail IS DISTINCT FROM 1 THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END),
						SUM(case when v_rss_1.traitement_epmsi IN ('30','31','32','33') AND fides_detail = 1 THEN v_rsf_detail_1.sejour_remboursable ELSE 0 END),
                        sum (case when activite_urgence = '1' THEN 1 ELSE 0 END)
					FROM #V_RSS_X#
						JOIN pmsi.v_rsf_detail_1 ON v_rss_1.rss_id = v_rsf_detail_1.rss_id 
					WHERE 
					    date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
					
						[VIEW.PRESTATION_SELECT]
						[VIEW.FILTRE_RSS_SELECT]
					)
						
					ORDER BY 2
				]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="RSS" />
					<FIELD name="SEJ" />
					<FIELD name="FIN" />
					<FIELD name="NOM" ifHideNames="Non autorisé" />
					<FIELD name="DAT" />
					<FIELD name="COD" />
					<FIELD name="TXT" />
					<FIELD name="NB" />
					<FIELD name="QU" />
					<FIELD name="PU" />
					<FIELD name="MF" />
					<FIELD name="MR" />
					<FIELD name="TXR" />
					<FIELD name="MRNFID" />
					<FIELD name="MRFID" />
					<FIELD name="ACT_URG" />
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
		</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="Justificatif par RSS" label="Justificatif par RSS">
			<DATAGRID title="" total="true" showOthers="false" key="RSS" headerHeight="54" totalRowInRows="= ROW.OID == '-9999999'">
				<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="SEJ" width="90" type="Char" visible="true" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="NOM" minWidth="150" type="Char" visible="true" headerText="Nom" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="COD" type="Char" visibleCondition="SELECT.PRESTATION == '-1' || SELECT.PRESTATION.toString().substr(0,2) == 'LI'" headerText="Code" width="60" textAlign="left" />
				<COLUMN dataField="TXT" type="Char" visibleCondition="SELECT.PRESTATION == '-1' || SELECT.PRESTATION.toString().substr(0,2) == 'LI'" headerText="Texte prestation" minWidth="100" textAlign="left" totalFunction="text" totalComplement="*ROW" />
				<COLUMN dataField="DAT" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date" width="80" textAlign="left" />
				<COLUMN dataField="NB" type="Number" visible="true" outputFormat="#" headerText="Nombre" width="75" textAlign="left" totalFunction="sum" />
				<COLUMN dataField="QU" type="Number" visible="true" outputFormat="#,00" headerText="Quantité" width="75" textAlign="left" totalFunction="sum"
					description="Produit du nombre de prestations par leurs coefficients" />
				<COLUMN dataField="PU" type="Number" visibleCondition="SELECT.LAMDA != '2'" outputFormat="#,00E" headerText="Prix unitaire" width="80" />
				<COLUMN dataField="ACT_URG" type="Number" visible="true" outputFormat="#" headerText="Activité urgence" width="100"  totalFunction="sum" />
				<COLUMN dataField="MF" type="Number" visible="true" outputFormat="#,00E" headerText="Montant facturé" width="100"  totalFunction="sum" />
				<COLUMN dataField="TXR" type="Number" visible="true" outputFormat="#%" headerText="Taux Remb." width="60"  totalFunction="sum" />
				<COLUMN dataField="MR" type="Number" visible="true" outputFormat="#,00E" headerText="Montant remboursable" width="100"  totalFunction="sum" />
				<COLUMN dataField="MRNFID" type="Number" visibleCondition="ENV.TYPEETS == '2' || ENV.TYPEETS == '3'" outputFormat="#,00E" headerText="Montant remboursable Hors FIDES" width="100"  totalFunction="sum" />
				<COLUMN dataField="MRFID" type="Number" visibleCondition="ENV.TYPEETS == '2' || ENV.TYPEETS == '3'" outputFormat="#,00E" headerText="Montant remboursable FIDES" width="100"  totalFunction="sum" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
