<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="ACTI000101" label="Activité. Séjours facturés 'Actes'" 
	title="= 'Justificatif Rejets (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
	database="iCTI" swf="*CTI_view1" 
	softCode="iCTI_activite" 
	admProvider="r2i qsp"
	globals="ACTI_globals.XML" 
	componentsFile="ACTI_components.XML" >
	<VIEWPROPERTIES>
		<PROPERTYx dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
	</VIEWPROPERTIES>

	<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="2007-01-01" globalListProvider="DATE_DEBUT" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2007-01-31" globalListProvider="DATE_FIN" >
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_REJETS_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_SEJOURS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_SEJOURS_X">
				<select><![CDATA[		
						(SELECT 
							p_factures.sejour_id,
							p_factures.no_sejour,
							p_patients.nom || ' ' || p_patients.prenom,
							v_factures_rejets_1.no_facture,
							p_factures.date_facture,
							v_factures_rejets_1.date_rejet,
							v_factures_rejets_1.rejet_code || ' ' || v_factures_rejets_1.rejet_texte
						FROM activite.v_factures_rejets_1
							JOIN activite.p_factures ON p_factures.no_facture = v_factures_rejets_1.no_facture
							JOIN #V_SEJOURS_X# ON v_sejours_1.no_sejour = p_factures.no_sejour
							JOIN activite.p_patients ON p_patients.no_patient = v_sejours_1.no_patient
						WHERE date_rejet BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.SEJOURS_SELECT]
							[VIEW.REJETS_SELECT]
						)	
						UNION
						(SELECT 
							-9999999,
							'',
							COUNT(DISTINCT p_factures.no_sejour) || ' séjours',
							COUNT(DISTINCT p_factures.no_facture) || ' factures',
							NULL,
							NULL,
							COUNT(*)::text || ' lignes'
						FROM activite.v_factures_rejets_1
							JOIN activite.p_factures ON p_factures.no_facture = v_factures_rejets_1.no_facture
							JOIN #V_SEJOURS_X# ON v_sejours_1.no_sejour = p_factures.no_sejour
							JOIN activite.p_patients ON p_patients.no_patient = v_sejours_1.no_patient
						WHERE date_rejet BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.SEJOURS_SELECT]
							[VIEW.REJETS_SELECT]
						)	
						ORDER BY 1,3
				
				
				]]></select>
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="SEJ"/>
					<FIELD name="NOM" ifHideNames="Non autorisé"/>
					<FIELD name="FAC"/>
					<FIELD name="DFAC"/>
					<FIELD name="DREJ"/>
					<FIELD name="TXT"/>
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forRows="false">
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Détail séjour" shortLabel="Détail séjour" view="ACTI000020.XML">
				<ARG name="SEJOUR" value="ROW.SEJ"/>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Rejets" label="Rejets">
			<DATAGRID title="" total="true"  headerHeight="48" totalRowInRows="= ROW.OID == '-9999999'">
				<COLUMN dataField="SEJ" width="100" type="Char" headerText="No séjour" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="NOM" type="Char" minWidth="50" headerText="Nom" textAlign="left" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="FAC" width="100" type="Char" headerText="No facture" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="DFAC" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date facture" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DREJ" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date rejet" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="100" headerText="Rejet" textAlign="left" totalFunction="text"  totalComplement="*ROW">
				</COLUMN>
				
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
