<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000271" 
	label="Pointage erreur Expert" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_pmsi" 
	softOption="iCTI_expert"
	globals="PMSI_globals.XML" 
	componentsFile="PMSI_components.XML">
	
	<CACHE cachable="false" />
	<title><![CDATA[= 
			var title:String = ''
				
				title = SELECT.RSS_NOM;
			
			return title;
		]]></title>
	<VIEWPROPERTIES>
	
		<PROPERTY name="EXPERT_CONTROLE_UPDATE_SELECT">
			<value><![CDATA[[EVAL 
				
				$mode = substr('[EXPERT_CONTROLE]',0,2);
				$oid = substr('[EXPERT_CONTROLE]',2);
				if ($mode == 'LS') {
                    $section_id = PMSI_get_section_id('[EXPERT_CONTROLE]');
                    $oid = PMSI_get_classe_oid('[EXPERT_CONTROLE]');
				}
				$subselect = '';
				
				if ($mode == 'LI') {$subselect = " AND controle_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'SL') {$subselect = " AND controle_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'LS') {$subselect = " AND controle_id IN (SELECT oid FROM pmsi.t_expert_controle WHERE $section_id = $oid)";}
				if ($mode == 'C*') {$subselect = " AND controle_id IN (SELECT oid FROM pmsi.t_expert_controle WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
				if ($mode == 'DT') {$subselect = " AND controle_id = $oid ";}
				
				
				return "$subselect";
				
			EVAL]]]></value>
		</PROPERTY>
		
		<PROPERTY name="EXPERT_CONTROLE_SELECT">
			<value><![CDATA[[EVAL 
				
				$mode = substr('[EXPERT_CONTROLE]',0,2);
				$oid = substr('[EXPERT_CONTROLE]',2);
				if ($mode == 'LS') {
                    $section_id = PMSI_get_section_id('[EXPERT_CONTROLE]');
                    $oid = PMSI_get_classe_oid('[EXPERT_CONTROLE]');
				}
				$subselect = '';
				
				if ($mode == 'LI') {$subselect = " AND expert_controle_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'SL') {$subselect = " AND expert_controle_id NOT IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'LS') {$subselect = " AND expert_controle_id IN (SELECT oid FROM pmsi.t_expert_controle WHERE $section_id = $oid)";}
				if ($mode == 'C*') {$subselect = " AND expert_controle_id IN (SELECT oid FROM pmsi.t_expert_controle WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
				if ($mode == 'DT') {$subselect = " AND expert_controle_id = $oid ";}
				
				
				return "$subselect";
				
			EVAL]]]></value>
		</PROPERTY>
	
		<PROPERTY name="RSS_ID_SELECT" >
				<value><![CDATA[
						[EVAL 
						if ('[RSS_ID]' == '') {return "-9999999";}
						
						return "
							AND v_expert_rss_controle_1.rss_id 
							= ANY (
								string_to_array(
									regexp_replace(
											trim(
												regexp_replace('[RSS_ID]', '[^0-9]', ' ', 'g')
											)
											, ' +', ' ', 'g'
										)
										, ' '
									)
								)";							
					EVAL]
				]]></value>
		</PROPERTY>
		
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres">
	
		<GROUP label="N° de RSS">
			<FIELD name="RSS_ID" label="" UI="textArea" width="100" height="20" default="" visible="false" />
		</GROUP>
		
		<GROUP label="Nom">
			<FIELD name="RSS_NOM" label="" UI="textArea" width="550" height="20" default="" visible="false"  />
		</GROUP>
		
		<GROUP label="Controle Expert">
			<FIELD name="EXPERT_CONTROLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="EXC" showIfNotDefault="true"
				 visible="false">
			</FIELD>
		</GROUP>
		
		<GROUP label="Option">
			<FIELD name="VAL_ACTION" label="" UI="text" width="200" default="I"  >
				<OPTION label="Ignorer cette anomalie" data="I"/>
				<OPTION label="Pointer comme corrigée" data="T"/>
				<OPTION label="Remettre en service" data=""/>
			</FIELD>
		</GROUP>
		
		<GROUP label="Periode">
			<FIELD name="PERIODE" label="" UI="text" width="550" height="20" default="" visible="false"  />
			<FIELD name="TOPERIODE" label="" UI="text" width="550" height="20" default="" visible="false"  />
		</GROUP>
	</SELECTIONS>
	
	<QUERIES>
		<QUERY> 
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[
				
							UPDATE pmsi.p_expert_rss_controle v_expert_rss_controle_1
							SET etat = CASE WHEN '[VAL_ACTION]' IN ('', 'I', 'T') THEN '[VAL_ACTION]' ELSE etat END,
								date_correction = CASE WHEN '[VAL_ACTION]' IN ('I', 'T') THEN date(now()) ELSE '20991231' END
							WHERE 1=1 
								[VIEW.RSS_ID_SELECT]
								[VIEW.EXPERT_CONTROLE_UPDATE_SELECT];
							
							SELECT 
								v_rss_1.rss_id,
								v_rss_1.no_rss,
								p_identites.nom || ' ' || p_identites.prenom,
								date_entree,
								date_sortie,
								ghm_code,
								v_expert_rss_controle_1.date_signalement,
								v_expert_rss_controle_1.etat_texte,
								v_expert_rss_controle_1.expert_controle_code,
								v_expert_rss_controle_1.expert_controle_id,
								v_expert_rss_controle_1.expert_controle_texte,
								v_expert_rss_controle_1.expert_controle_gravite_texte,
								v_expert_rss_controle_1.code_justificatif
							FROM pmsi.v_expert_rss_controle_1 
								JOIN #V_RSS_X# ON v_expert_rss_controle_1 .rss_id = v_rss_1.rss_id
								JOIN pmsi.p_identites ON v_rss_1.rss_id = p_identites.rss_id 
							WHERE 1=1
								[VIEW.RSS_ID_SELECT]
								[VIEW.EXPERT_CONTROLE_SELECT]
						
							ORDER BY 2
						;
							
					]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="RSS" />
					<FIELD name="NOM"  ifHideNames="Non autorisé"/>
					<FIELD name="DATE" />
					<FIELD name="DATS" />
					<FIELD name="GHM" />
					<FIELD name="CXD"/>
					<FIELD name="CXE"/>
					<FIELD name="CXC"/>
					<FIELD name="CXI"/>
					<FIELD name="CXT"/>
					<FIELD name="CXG"/>
					<FIELD name="CXJ"/>
				</FIELDS>
			</SQL>
			
			
		</QUERY>
	
	</QUERIES>
	
	<CALCFIELDS>
	</CALCFIELDS>
	
	<PRESENTATION>
	
		<VIEWLINKS>
			<VIEWLINK label="Retour à la liste" shortLabel="Retour à la liste" view="PMSI000236.XML" rowContext="false">
				<ARG name="_FORCE_UPDATE" value="return new Date().getMilliseconds().toString()" />
				<ARG name="ALIAS_PERIODE" value="-1" />
			</VIEWLINK>
		</VIEWLINKS>

		
		<ONGLET excelLabel="Pointage" label="Pointage" queryNumber="0">
				
			<DATAGRID title="" total="true" key="RSS" headerHeight="36"  rowHeight="48"
				totalRowInRows="= ROW.OID == '-9999999'"
			>
				<ROWSTYLE name="rowHeight" value="48" />
				<ROWSTYLE name="fontSize" value="11" />
				<FOOTERROWSTYLE name="fontSize" value="11" />
				<COLUMN dataField="OID"
					type="Char"
					visible="false">
				</COLUMN>
				<COLUMN dataField="CXI"
					type="Char"
					visible="false">
				</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="NOM"
					minWidth="100"
					maxWidth="200"
					type="Char"
					visible="true"
					headerText="Nom" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="*ROW">
				</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="GHM"
					width="55"
					type="Char"
					visible="true"
					fixed="false"
					headerText="GHM" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CXD"
					width="60"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					visible="true"
					fixed="false"
					headerText="Date signalement" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CXE"
					width="60"
					type="Char"
					visible="true"
					headerText="Etat" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXG"
					width="60"
					type="Char"
					visible="true"
					headerText="Gravité" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXC"
					width="100"
					type="Char"
					visible="true"
					outputFormat="#"
					headerText="Code Controle" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXT"
					minWidth="200"
					type="Char"
					visible="true"
					headerText="Texte Controle" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXJ"
					width="100"
					type="Char"
					visible="true"
					headerText="Justificatif Controle" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
			</DATAGRID>
		
		</ONGLET>
		
		
		
				
	</PRESENTATION>
	
</VUE>

			
