<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000258" 
	label="PMSI. Liste des RSS par critères" 
	title="= 'Liste des RSS avec erreurs de groupage (' + 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">
	
	<VIEWPROPERTIES>
		<PROPERTY name="NO_RSS_SELECT" >
				<value><![CDATA[
						[EVAL 
						if ('[NO_RSS]' == '') {return "";}
						
						return "
							AND v_rss_1.no_rss 
							= ANY (
								string_to_array(
									regexp_replace(
											trim(
												regexp_replace('[NO_RSS]', '[^0-9]', ' ', 'g')
											)
											, ' +', ' ', 'g'
										)
										, ' '
									)
								)";							
					EVAL]
				]]></value>
		</PROPERTY>
		<PROPERTY name="NO_SEJOUR_SELECT" >
				<value><![CDATA[
						[EVAL 
						if ('[NO_SEJOUR]' == '') {return "";}
						
						return "
                            AND trim(regexp_replace( v_rss_1.no_sejour_administratif  , '[^0-9]', ' '))
							= ANY (
								string_to_array(
									regexp_replace(
											trim(
												regexp_replace('[NO_SEJOUR]', '[^0-9]', ' ', 'g')
											)
											, ' +', ' ', 'g'
										)
										, ' '
									)
								)";							
					EVAL]
				]]></value>
		</PROPERTY>
		<PROPERTY name="NOM_SELECT"  >
				<value><![CDATA[
						[EVAL 
						if ('[NOM]' == '') {return "";}
						
						return "
							AND identite_nom || ' ' || identite_nom_naissance || ' ' || identite_prenom 
							ILIKE ALL (
								string_to_array(		
									'%' ||
									regexp_replace(
											regexp_replace(
													trim('[NOM]')
													, ' +', ' ', 'g'
											)
									, ' ', '% %', 'g'
									)
									|| '%'

								, ' '
								)
							)";							
					EVAL]
				]]></value>
		</PROPERTY>
		<PROPERTY name="ERR_GROUP"  >
				<value><![CDATA[
						[EVAL 
						
						if ('[ERR_GROUP]' == '-1') {return "";}
						else { return " AND v_rss_leg_1.code_retour_groupeur_id = [ERR_GROUP] ";}
						
					EVAL]
				]]></value>
		</PROPERTY>
		<PROPERTYx dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					
					if (SELECT.NO_RSS  != '') {
						display = display + 'N° RSS : #B#' + SELECT.NO_RSS;
						display = display + '#/B# ';
					}
					if (SELECT.NOM  != '') {
						display = display + 'Nom : #B#' + SELECT.NOM;
						display = display + '#/B# ';
					}
					if (SELECT.ERR_GROUP  != '-1') {
						display = display + 'Erreur de groupage : #B#' + SELECT.ERR_GROUP_LABEL;
						display = display + '#/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="N° de RSS">
			<FIELD name="NO_RSS" label="" UI="textArea" width="550" height="70" default="" showIfNotDefault="true" />
		</GROUP>
		<GROUP label="N° de séjour administratif">
			<FIELD name="NO_SEJOUR" label="" UI="textArea" width="550" height="70" default="" showIfNotDefault="true" />
		</GROUP>
		<GROUP label="Ou Nom">
			<FIELD name="NOM" label="" UI="text" width="200" default="" showIfNotDefault="true">
			</FIELD>
		</GROUP>
		<GROUP label="Erreur groupage">
			<FIELD name="ERR_GROUP" label="" UI="combo" width="500" default="-1" globalListProvider="ERR_GROUP" 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,
						ghm_code as GHM,
						diagnostic_principal_code as DIAGP,
						diagnostic_relie_code as DIAGR,
						unite_medicale_principale_code as UMP,
						acte_principal_code as ACTEP,
						date_entree as DATE,
						date_sortie as DATS,
						mode_entree as MODE,
						mode_sortie as MODS,
						provenance as PROV,
						destination as DEST,
						sexe_texte_court as SEX,
						age as AGE,
						v_rss_1.date_naissance as DATN,
						code_postal as CODP,
						nb_rsa as NRSA,
						nb_rum as NRUM,
						duree_sejour as NBJ,
						nb_seances as NSEA,
						poids_bebe as PBB,
						age_gestationnel as AGEST, 
						confirmation_codage as CONFIRM, 
						CASE WHEN date_dernieres_regles != '2099-12-31' THEN date_dernieres_regles ELSE null END as DDR,
						nombre_erreur_groupeur AS NBERR,
						v_rss_leg_1.code_retour_groupeur_code as CODE_RETOUR
					FROM #V_RSS_X#
					WHERE 1=1
						AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.NO_RSS_SELECT]
						[VIEW.NO_SEJOUR_SELECT]
						[VIEW.NOM_SELECT]
						[VIEW.ERR_GROUP]
						[VIEW.FILTRE_RSS_SELECT]
						AND v_rss_leg_1.nombre_erreur_groupeur IS DISTINCT FROM NULL
				)
				UNION ALL
				(
					SELECT 
						-9999999 as OID,
						COUNT(DISTINCT v_rss_1.no_rss) as RSS,
						0 as PAT,
						'' as SEJ,
						'' as FIN,
						SUM(nb_rsa)::text || ' séjours, ' || COUNT(DISTINCT patient_id)::text || ' patients' as NOM,
						'' as GHM,
						'' as DIAGP,
						'' as DIAGR,
						'' as UMP,
						'' as ACTEP,
						null as DATE,
						null as DATS,
						'' as MODE,
						'' as MODS,
						'' as PROV,
						'' as DEST,
						'' as SEX,
						0 as AGE,
						null as DATN,
						'' as CODP,
						SUM(nb_rsa) as NRSA,
						SUM(nb_rum) as NRUM,
						SUM(duree_sejour) as NBJ,
						SUM(nb_seances) as NSEA,
						null as PBB,
						null as AGEST,
						'' as CONFIRM,
						null as DDR,
						sum(nombre_erreur_groupeur) AS NBERR,
						'' as CODE_RETOUR
					FROM #V_RSS_X#
					WHERE 1=1
						AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.NO_RSS_SELECT]
						[VIEW.NO_SEJOUR_SELECT]
						[VIEW.NOM_SELECT]
						[VIEW.ERR_GROUP]
						[VIEW.FILTRE_RSS_SELECT]
						AND v_rss_leg_1.nombre_erreur_groupeur IS DISTINCT FROM NULL
						
				)
				ORDER BY 2
				;
				
				]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="RSS" />
					<FIELD name="PAT" />
					<FIELD name="SEJ" />
					<FIELD name="FIN" />
					<FIELD name="NOM"  ifHteames="Non autorisé"/>
					<FIELD name="GHM" />
					<FIELD name="DIAGP" />
					<FIELD name="DIAGR" />
					<FIELD name="UMP" />
					<FIELD name="ACTEP" />
					<FIELD name="DATE" />
					<FIELD name="DATS" />
					<FIELD name="MODE" />
					<FIELD name="MODS" />
					<FIELD name="PROV" />
					<FIELD name="DEST" />
					<FIELD name="SEX" />
					<FIELD name="AGE" />
					<FIELD name="DATN"  ifHideNames="Non autorisé"/>
					<FIELD name="CODP" />
					<FIELD name="NRSA"/>
					<FIELD name="NRUM"/>
					<FIELD name="NBJ"/>
					<FIELD name="NSEA"/>
					<FIELD name="PBB"/>
					<FIELD name="AGEST"/>
					<FIELD name="CONFIRM"/>
					<FIELD name="DDR"/>
					<FIELD name="NBERR"/>
					<FIELD name="CODE_RETOUR"/>
				</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>
			
			<VIEWLINKx label="Créer un extrait de base" shortLabel="Extrait de base" view="PMSI000055.XML" rowContext="false">

			</VIEWLINKx>


		</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" width="60" type="Char" visible="true" headerText="Etablissement" textAlign="left" visibleCondition="ENV.CONSOLIDATION == '1'" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="RSS" width="70" type="Number" visible="true" outputFormat="#" headerText="N° RSS" textAlign="center" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="SEJ" width="80" type="Char" visible="true" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="NBERR" width="50" type="Char" visible="true" outputFormat="#" headerText="Nb Err Group" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="NOM" minWidth="180" maxWidth="230" type="Char" visible="true" headerText="Nom" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="CODE_RETOUR" width="55" type="Char" visible="true" headerText="Code erreur" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="SEX" width="40" type="Char" visible="true" headerText="Sexe" fixed="false" textAlign="right" otherFunction="text" totalFunction="text">
					<CELLSTYLE name="cellIndicator" value="femme, 12,left middle , 0xEB76B1" condition="ROW.SEX == 'F'" /> 
					<CELLSTYLE name="cellIndicator" value="homme, 12,left middle , 0x75a0eb " condition="ROW.SEX == 'M'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10,left middle , #FF5001 " condition="ROW.SEX == 'I'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0x666666" condition="ROW.SEX != 'F' &amp;&amp; ROW.SEX != 'M' &amp;&amp; ROW.SEX != 'I'" />
				</COLUMN>
				<COLUMN dataField="DATN" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" fixed="false" headerText="Date naissance" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="AGE" width="40" type="Number" outputFormat="#" fixed="false" visible="true" headerText="Age" textAlign="right" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CODP" width="45" type="Char" outputFormat="#" fixed="false" visible="true" headerText="Code postal" textAlign="right" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATE" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" fixed="false" headerText="Date entrée" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATS" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" fixed="false" headerText="Date sortie" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="NBJ" width="50" visible="true" type="Char" headerText="Durée séjour" fixed="false" textAlign="left" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="MODE" width="45" type="Char" visible="true" fixed="false" headerText="Mode entrée" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="PROV" width="45" type="Char" visible="true" fixed="false" headerText="Prov" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="MODS" width="45" type="Char" visible="true" fixed="false" headerText="Mode sortie" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DEST" width="45" type="Char" visible="true" fixed="false" headerText="Dest" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHM" width="55" type="Char" visible="true" fixed="false" headerText="GHM" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="UMP" width="50" type="Char" visible="true" fixed="false" headerText="UM" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DIAGP" width="50" type="Char" fixed="false" visible="true" headerText="Diag P" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DIAGR" width="50" type="Char" fixed="false" visible="true" headerText="Diag R" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="ACTEP" width="60" type="Char" fixed="false" visible="true" headerText="Acte P" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CONFIRM" width="50" type="Char" headerText="Confirm Codage" fixed="false" textAlign="left" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="NRSA" width="50" visible="false" type="Number" outputFormat="#" fixed="false" headerText="Nb séjours" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="NRUM" width="35" visible="true" type="Number" outputFormat="#" fixed="false" headerText="Nb RUM" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="NSEA" width="50" visible="true" type="Number" outputFormat="#" headerText="Nb séances" fixed="false" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="PBB" width="50" visible="true" type="Number" outputFormat="#" headerText="Poids bébé" fixed="false" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="AGEST" width="40" type="Number" outputFormat="#" fixed="false" visible="true" headerText="Age gestationnel" textAlign="right" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DDR" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" fixed="false" headerText="Date dern. règles" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
