<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000348" 
	label="PMSI. Justificatif Interventions par RSS" 
	title="= 'Justificatif Intervention par RSS (' + SELECT.QUELLEDATE_LABEL + ' : ' +  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:actes:interventions_client" helpDokuWIkiFile="pmsi000348"  helpFile="iCTI_PMSI_PMSI000348.HTML">
	
	<VIEWPROPERTIES componentName="PROPERTIES_INTERVENTIONS" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>	
	<SELECTIONS label="Paramètres de l'analyse">
		<GROUP label="Période">
			<FIELD name="QUELLEDATE" label="" UI="combo" default="1" default2="date_fin" printable="false">
				<OPTION label="Date sortie" data="1" data2="date_sortie" />
				<OPTION label="Date acte" data="2" data2="date_acte" />
			</FIELD>
			<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" default2="201401" printable="false" globalListProvider="DATE_DEBUT" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" default2="201412" printable="false" globalListProvider="DATE_FIN" />
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_INTERV_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_sejour_administratif AS admin
							,v_rss_1.no_rss AS rss
							,v_rss_1.finess AS finess
							,p_identites.nom::text || ' '::text || p_identites.prenom::text AS nom
							,no_intervention AS interv
							,count(*) AS nb_actes
							,count(CASE WHEN activite_ccam != '4' THEN acte_id ELSE null END) AS nb_actes_1
							,count(CASE WHEN activite_ccam = '4' THEN acte_id ELSE null END) AS nb_actes_4
							,sum([VIEW.ICR_FIELD]) AS icr
							,sum([VIEW.ICR_FIELD]_activite_1) AS icr_1
							,sum([VIEW.ICR_FIELD]_activite_4) AS icr_4
							,count(distinct medecin_reference_id) AS nb_exec
							,(max(array[[VIEW.ICR_FIELD]::text, medecin_reference_nom::text || ' ('::text || medecin_reference_code::text || ')'::text]))[2] AS exec_principal
							,count(distinct anesthesiste_reference_id) AS nb_anes
							,(max(array[[VIEW.ICR_FIELD]::text, anesthesiste_reference_nom::text || ' ('::text || anesthesiste_reference_code::text || ')'::text]))[2] AS anes_principal
							,min(date_acte) AS date_interv
							,array_to_string(base.cti_array_sort(array_agg(acte_code)), ', ') AS actes
						FROM	
							pmsi.v_rss_3 v_rss_1
							,pmsi.v_rss_actes_5 v_rss_actes_4
							,pmsi.p_identites
						WHERE 1=1
							AND v_rss_1.rss_id = v_rss_actes_4.rss_id
							AND v_rss_1.rss_id = p_identites.rss_id
							AND [VIEW.QUELLEDATE] BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.FILTRE_INTERV_SELECT]
							[VIEW.FILTRE_RSS_SELECT]
						GROUP BY v_rss_1.rss_id, v_rss_1.no_rss, v_rss_1.finess, v_rss_1.no_sejour_administratif, p_identites.nom , p_identites.prenom, v_rss_actes_4.no_intervention
					)
					UNION
					(
						SELECT
							-9999999 AS oid
							,''::text AS admin
							,null AS rss
							,''::text AS finess
							,COUNT(DISTINCT v_rss_1.rss_id)::text || ' RSS, ' || COUNT(DISTINCT v_rss_1.patient_id)::text || ' patients'::text AS nom
							,COUNT(DISTINCT no_intervention)::text || ' interv.'::text AS interv
							,count(*) AS nb_actes
							,count(CASE WHEN activite_ccam != '4' THEN acte_id ELSE null END) AS nb_actes_1
							,count(CASE WHEN activite_ccam = '4' THEN acte_id ELSE null END) AS nb_actes_4
							,sum([VIEW.ICR_FIELD]) AS icr
							,sum([VIEW.ICR_FIELD]_activite_1) AS icr_1
							,sum([VIEW.ICR_FIELD]_activite_4) AS icr_4
							,count(distinct medecin_reference_id) AS nb_exec
							,''::text AS exec_principal
							,count(distinct anesthesiste_reference_id) AS nb_anes
							,''::text AS anes_principal
							,null AS date_interv
							,null AS actes
						FROM	
							pmsi.v_rss_3 v_rss_1
							,pmsi.v_rss_actes_5 v_rss_actes_4
							,pmsi.p_identites
						WHERE 1=1
							AND v_rss_1.rss_id = v_rss_actes_4.rss_id
							AND v_rss_1.rss_id = p_identites.rss_id
							AND [VIEW.QUELLEDATE] BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							[VIEW.FILTRE_INTERV_SELECT]
							[VIEW.FILTRE_RSS_SELECT]
					)
					ORDER BY 3
				]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="ADMIN" />
					<FIELD name="RSS" />
					<FIELD name="FINESS" />
					<FIELD name="NOM" ifHideNames="Non autorisé" />
					<FIELD name="INTERV" />
					<FIELD name="NB_ACTES" />
					<FIELD name="NB_ACTES_1" />
					<FIELD name="NB_ACTES_4" />
					<FIELD name="ICR" />
					<FIELD name="ICR_1" />
					<FIELD name="ICR_4" />
					<FIELD name="NB_EXEC" />
					<FIELD name="EXEC_PRINCIPAL" />
					<FIELD name="NB_ANES" />
					<FIELD name="ANES_PRINCIPAL" />
					<FIELD name="DATE_INTERV" />
					<FIELD name="ACTES" />
				</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="Justificatif Interventions" label="Justificatif Interventions" >
			<DATAGRID title="" total="true" headerHeight="48"    
				totalRowInRows="= ROW.OID == '-9999999'">
				<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="60" type="Char" headerText="N° RSS" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL" /> 
				<COLUMN dataField="INTERV" width="110" type="Char" headerText="N° Intervention" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW" /> 
				<COLUMN dataField="DATE_INTERV" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" headerText="Date" textAlign="left" /> 
				<COLUMN dataField="NOM" width="160" type="Char" headerText="Patient" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW" /> 
				<COLUMN dataField="NB_EXEC" width="50" type="Number" outputFormat="#" visibleCondition="SELECT.MEDECIN == '-1' || SELECT.MEDECIN.toString().substr(0,2) == 'LI'" headerText="Nb&#xD;Exéc." textAlign="left" /> 
				<COLUMN dataField="EXEC_PRINCIPAL" width="160" type="Char" visibleCondition="SELECT.MEDECIN == '-1' || SELECT.MEDECIN.toString().substr(0,2) == 'LI'" headerText="Exécutant principal" textAlign="left" /> 
				<COLUMN dataField="NB_ANES" width="50" type="Number" outputFormat="#" visibleCondition="SELECT.ANESTHESISTE == '-1' || SELECT.ANESTHESISTE.toString().substr(0,2) == 'LI'" headerText="Nb&#xD;Anest." textAlign="left" /> 
				<COLUMN dataField="ANES_PRINCIPAL" width="160" type="Char" visibleCondition="SELECT.ANESTHESISTE == '-1' || SELECT.ANESTHESISTE.toString().substr(0,2) == 'LI'" headerText="Anesthésiste principal" textAlign="left" /> 
				<COLUMN dataField="NB_ACTES" width="50" type="Number" outputFormat="#" headerText="Nb actes" textAlign="right" /> 
				<COLUMN dataField="NB_ACTES_1" width="50" type="Number" outputFormat="#" headerText="Nb actes act. 1" textAlign="right" /> 
				<COLUMN dataField="NB_ACTES_4" width="50" type="Number" outputFormat="#" headerText="Nb actes act. 4" textAlign="right" /> 
				<COLUMN dataField="ICR" width="60" type="Number" outputFormat="#" headerText="ICR" textAlign="right" /> 
				<COLUMN dataField="ICR_1" width="60" type="Number" outputFormat="#" headerText="ICR&#xD;act. 1" textAlign="right" /> 
				<COLUMN dataField="ICR_4" width="60" type="Number" outputFormat="#" headerText="ICR&#xD;act. 4" textAlign="right" /> 
				<COLUMN dataField="ACTES" type="Char" visibleCondition="SELECT.ACTE == '-1' || SELECT.ACTE.toString().substr(0,2) == 'LI'" headerText="Codes actes" minWidth="180" textAlign="left" /> 
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
