<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000365" 
	label="PMSI. Liste des RSS par critères" 
	title="= 'Liste des RSS avec prestations non valoriées (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ') - ' + SELECT.VERSION_GROUPAGE_LABEL" 
	database="iCTI" 
	swf="*CTI_view1" 
	typeEts="23"
	softCode="iCTI_pmsi"
	globals="PMSI_globals.XML"
	componentsFile="PMSI_components.XML">
	<VIEWPROPERTIES>
		<PROPERTY name="RULE_NON_VAL"  >
				<value><![CDATA[
						[EVAL 
						
						if ('[RULE_NON_VAL]' == '-1') {return "";}
						else { return " AND v_rsf_detail_non_valorise_1.regle_non_valorisation_id = [RULE_NON_VAL] ";}
						
					EVAL]
				]]></value>
		</PROPERTY>
		<PROPERTY name="PRESTATION_SELECT">
				<value><![CDATA[[EVAL 
						
					$subselect = '';
					
					// Prestation
					$mode = substr('[PRESTATION]',0,2);
					$oid = substr('[PRESTATION]',2);
					if ($mode == 'LS') {
						$section_id = PMSI_get_section_id('[PRESTATION]');
						$oid = PMSI_get_classe_oid('[PRESTATION]');
					}
					
					
					$subselect2 = '';
					if ($mode == 'LI') {$subselect2 = " prestation_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$subselect2 = " prestation_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'LS') {$subselect2 = " prestation_id IN (SELECT oid FROM pmsi.t_prestations WHERE $section_id = $oid)";}
					if ($mode == 'PR') {$subselect2 = " prestation_id = $oid ";}
					
					if ($subselect2 != '') {
						$subselect = "$subselect AND $subselect2 ";
					}
					
					return $subselect;
					
				EVAL]]]></value>
			</PROPERTY>
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					
					if (SELECT.RULE_NON_VAL  != '-1') {
						display = display + 'Règle de non valorisation : #B#' + SELECT.RULE_NON_VAL_LABEL;
						display = display + '#/B# ';
					}
					if (SELECT.PRESTATION != '-1') {
						display += '  Prestation : #B#' + SELECT.PRESTATION_LABEL + '#/B#';
					}
					
					if (display != '') {
					}
					return display;
					">
		<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>
		<GROUP label="Règle non valorisation">
			<FIELD name="RULE_NON_VAL" label="" UI="combo" width="500" default="-1" globalListProvider="RULE_NON_VAL" showIfNotDefault="true" />
		</GROUP>
		<GROUP label="Prestation">
			<FIELD name="PRESTATION" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="PRESTATION" showIfNotDefault="true" />
		</GROUP>
	</SELECTIONS>
		
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />

	<QUERIES>
		<QUERY label=""> 
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[
				
				(
					SELECT 
						v_rss_1.rss_id as OID,
						v_rss_1.no_rss as RSS,
						CASE WHEN patient_no_patient &gt; 0 THEN patient_no_patient ELSE 0 END as PAT,
						v_rss_1.no_sejour_administratif as SEJ,
						v_rss_1.finess as FIN,
						identite_nom || ' ' || identite_prenom as NOM,
						unite_medicale_principale_code as UMP,
						acte_principal_code as ACTEP,
						date_entree as DATE,
						date_sortie as DATS,
						v_rsf_detail_non_valorise_1.prestation_code as PRESTA,
						v_rsf_detail_non_valorise_1.coefficient as COEFF,
						v_rsf_detail_non_valorise_1.coefficient_mco as COEFF_MCO,
						v_rsf_detail_non_valorise_1.coefficient_geo as COEFF_GEO,
						v_rsf_detail_non_valorise_1.nombre as nombre,
						v_rsf_detail_non_valorise_1.prix_unitaire as PU,
						v_rsf_detail_non_valorise_1.sejour_facture as FACT,
						v_rsf_detail_non_valorise_1.regle_non_valorisation_code::text || ' - '::text || v_rsf_detail_non_valorise_1.regle_non_valorisation_texte::text as RULE
					FROM #V_RSS_X#
					JOIN pmsi.v_rsf_detail_non_valorise_1 ON v_rsf_detail_non_valorise_1.rss_id = v_rss_1.rss_id
					WHERE 1=1
						AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.RULE_NON_VAL]
						[VIEW.FILTRE_RSS_SELECT]
						[VIEW.PRESTATION_SELECT]
				)
				UNION ALL
				(
					SELECT 
						-9999999 as OID,
						COUNT(DISTINCT v_rss_1.no_rss) as RSS,
						0 as PAT,
						'' as SEJ,
						'' as FIN,
						COUNT(DISTINCT v_rss_1.no_sejour_administratif)::text || ' séjours, ' || COUNT(DISTINCT patient_id)::text || ' patients' as NOM,
						'' as UMP,
						'' as ACTEP,
						null as DATE,
						null as DATS,
						'' as PRESTA,
						0 as COEFF,
						0 as COEFF_MCO,
						0 as COEFF_GEO,
						0 as NOMBRE,
						0 as PU,
						0 as FACT,
						'' as RULE
					FROM #V_RSS_X#
					 	JOIN pmsi.v_rsf_detail_non_valorise_1 ON v_rsf_detail_non_valorise_1.rss_id = v_rss_1.rss_id
					WHERE 1=1
						AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.RULE_NON_VAL]
						[VIEW.FILTRE_RSS_SELECT]
						[VIEW.PRESTATION_SELECT]
				)
				ORDER BY 2
				;
				
				]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="RSS" />
					<FIELD name="PAT" />
					<FIELD name="SEJ" />
					<FIELD name="FIN" />
					<FIELD name="NOM"  ifHideNames="Non autorisé"/>
					<FIELD name="UMP" />
					<FIELD name="ACTEP" />
					<FIELD name="DATE" />
					<FIELD name="DATS" />
					<FIELD name="PRESTA"/>
					<FIELD name="COEFF"/>
					<FIELD name="COEFF_MCO"/>
					<FIELD name="COEFF_GEO"/>
					<FIELD name="NOMBRE"/>
					<FIELD name="PU"/>
					<FIELD name="FACT"/>
					<FIELD name="RULE"/>
				</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 dataField="FIN" width="60" type="Char" headerText="Etablissement" textAlign="left" visibleCondition="ENV.CONSOLIDATION == '1'" otherFunction="text" totalFunction="text" totalComplement="" />
				<COLUMN dataField="RSS" width="70" type="Number" outputFormat="#" headerText="N° RSS" textAlign="center" otherFunction="text" totalFunction="text" totalComplement="TOTAL" />
				<COLUMN dataField="SEJ" width="80" type="Char" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="" />
				<COLUMN dataField="NOM" minWidth="180" maxWidth="230" type="Char" headerText="Nom" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW" />
				<COLUMN dataField="DATE" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" headerText="Date entrée" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="DATS" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" headerText="Date sortie" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="UMP" width="50" type="Char" headerText="UM" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="ACTEP" width="60" type="Char" headerText="Acte P" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="PRESTA" width="70" type="Char" headerText="Prestation" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="COEFF" width="70" type="Number" outputFormat="#,0000" headerText="Coefficient" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="COEFF_MCO" width="60" type="Number" outputFormat="#,0000" headerText="Coeff MCO" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="COEFF_GEO" width="55" type="Number" outputFormat="#,0000" headerText="Coeff Géo" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="NOMBRE" width="55" type="Number" outputFormat="#,00" headerText="Nombre" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="PU" width="65" type="Number" outputFormat="#,00E" headerText="Prix unitaire" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="FACT" width="65" type="Number" outputFormat="#,00E" headerText="Montant facturé" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="RULE" width="250" type="Char" headerText="Règle CTI" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW" visibleCondition="SELECT.RULE_NON_VAL == '-1'" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
