<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="ACTI000036" label="Activité. Répartition hebdomadaire Occupation"
	title="= SELECT.DATA_LABEL + ' ' + SELECT.REAPRE2 + ' par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
	database="iCTI" swf="*CTI_view1" softCode="iCTI_activite" globals="ACTI_globals.XML" componentsFile="ACTI_components.XML" 
    helpFile="iCTI_ACTI_ACTI000123.HTML"
    helpDokuWIkiDir="activite:occupation_sejours" 
    helpDokuWIkiFile="acti000123" 
>
	<VIEWPROPERTIES componentName="PROPERTIES_OCCUPATION"/>
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
		<PROPERTY name="REAPRE_SELECT">
			<value><![CDATA[
						[EVAL 
							if ('[REAPRE]' == '1') {return "";}
							if ('[REAPRE]' == '2') {return " AND est_mouvement_previsionnel = '1'";}
							return " AND est_mouvement_previsionnel <> '1'";
						EVAL]
					]]></value>
		</PROPERTY>
		<PROPERTY name="C_FACTEUR_MOYENNE">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'NJNM':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_places_1.est_ouvert = '1' AND heberge_hospitalises = '1' THEN date ELSE NULL END)";
									break;
								case 'NEXM':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_places_1.est_ouvert = '1' AND heberge_externes = '1' THEN date ELSE NULL END)";
									break;
								case 'NAMM':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_places_1.est_ouvert = '1' AND heberge_ambulatoires = '1' THEN date ELSE NULL END)";
									break;
								case 'NSEM':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_places_1.est_ouvert = '1' AND heberge_seances = '1' THEN date ELSE NULL END)";
									break;
								case 'TAU':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND v_places_1.est_ouvert = '1' THEN v_places_1.[VIEW.PLACES_FIELD] ELSE 0 END) / 100";
									break;
								default:
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_places_1.est_ouvert = '1' THEN date ELSE NULL END)";
								}

			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="T_FACTEUR_MOYENNE">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'NJNM':
									return "COUNT(DISTINCT CASE WHEN v_places_1.est_ouvert = '1' AND heberge_hospitalises = '1' THEN date ELSE NULL END)";
									break;
								case 'NEXM':
									return "COUNT(DISTINCT CASE WHEN v_places_1.est_ouvert = '1' AND heberge_externes = '1' THEN date ELSE NULL END)";
									break;
								case 'NAMM':
									return "COUNT(DISTINCT CASE WHEN v_places_1.est_ouvert = '1' AND heberge_ambulatoires = '1' THEN date ELSE NULL END)";
									break;
								case 'NSEM':
									return "COUNT(DISTINCT CASE WHEN v_places_1.est_ouvert = '1' AND heberge_seances = '1' THEN date ELSE NULL END)";
									break;
								case 'TAU':
									return "SUM(CASE WHEN v_places_1.est_ouvert = '1' THEN v_places_1.[VIEW.PLACES_FIELD] ELSE 0 END) / 100";
									break;
								default:
									return "COUNT(DISTINCT CASE WHEN v_places_1.est_ouvert = '1' THEN date ELSE NULL END)";
								}

			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DATA_SELECT">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'NED':
									return 'AND nb_entrees_directes > 0';
									break;
								case 'NEM':
									return 'AND (nb_entrees_directes > 0 OR nb_entrees_mutation_[VIEW.MUTATION_FIELD] > 0)';
									break;
								case 'NSD':
									return 'AND nb_sorties_directes > 0';
									break;
								case 'NSM':
									return 'AND (nb_sorties_directes > 0 OR nb_sorties_mutation_[VIEW.MUTATION_FIELD] > 0)';
									break;
								case 'NJN':
									return 'AND [VIEW.JOURNEES_FIELD] > 0';
									break;
								case 'NJNS':
									return 'AND nb_jour_sejour_sorti > 0';
									break;
								case 'NEX':
									return 'AND nb_externes > 0';
									break;
								case 'NAM':
									return 'AND nb_ambulatoires > 0';
									break;
								case 'NEDA':
									return 'AND (nb_entrees_directes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'NSDA':
									return 'AND (nb_sorties_directes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'NEDXA':
									return 'AND (nb_entrees_directes > 0 OR nb_externes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'NSDXA':
									return 'AND (nb_sorties_directes > 0 OR nb_externes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'NSDXBB':
									return 'AND (nb_sorties_directes > 0 OR nb_bebes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'NJNXA':
									return 'AND ([VIEW.JOURNEES_FIELD] > 0 OR nb_externes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'NEDXAS':
									return 'AND (nb_entrees_directes > 0 OR nb_externes > 0 OR nb_ambulatoires > 0 OR nb_seances > 0)';
									break;
								case 'NSDXAS':
									return 'AND (nb_sorties_directes > 0 OR nb_externes > 0 OR nb_ambulatoires > 0 OR nb_seances_dans_taux > 0)';
									break;
								case 'NSDXASSH':
									return "AND (nb_sorties_directes > 0 OR nb_externes > 0 OR nb_ambulatoires > 0 OR CASE WHEN type_sejour = '5' THEN nb_seances_dans_taux ELSE 0 END > 0)";
									break;
								case 'NJNXAS':
									return 'AND ([VIEW.JOURNEES_FIELD] > 0 OR nb_externes > 0 OR nb_ambulatoires > 0 OR nb_seances_dans_taux > 0)';
									break;
								case 'NSE':
									return "AND nb_seances > 0";
									break;
								case 'NSEDIA':
									return "AND nb_seances_dialyse > 0";
									break;
								case 'NSECHM':
									return "AND nb_seances_chimio > 0";
									break;
								case 'NSEDIV':
									return "AND nb_seances_autre > 0";
									break;
								case 'NBB':
									return "AND nb_bebes > 0";
									break;
                                case 'NBP':
									return "AND no_patient > 0";
									break;
								case 'NCP':
									return "AND [VIEW.CP_FIELD] > 0";
									break;
								case 'NJO':
									return "";
									break;
								case 'NJNM':
									return 'AND [VIEW.JOURNEES_FIELD] > 0';
									break;
								case 'NEXM':
									return 'AND nb_externes > 0';
									break;
								case 'NAMM':
									return 'AND nb_ambulatoires > 0';
									break;
								case 'NSEM':
									return "AND nb_seances > 0";
									break;
								case 'NJNXAM':
									return 'AND ([VIEW.JOURNEES_FIELD] > 0 OR nb_externes > 0 OR nb_ambulatoires > 0)';
									break;
								case 'TAU':
									return 'AND ([VIEW.JOURNEES_FIELD] > 0 OR nb_ambulatoires > 0 OR nb_seances_dans_taux > 0)';
									break;
								case 'NSHP':
									return "AND v_sejours_1.date_sortie > '[TOPERIODE]' AND v_sejours_1.code_sorti = 1";
									break;
								case 'NJNAS':
									return 'AND ([VIEW.JOURNEES_FIELD] > 0 OR nb_ambulatoires > 0 OR nb_seances_dans_taux > 0)';
									break;
								case 'NSFAC':
									return "AND v_mouvements_sejour_2.est_facture = '1'";
									break;
								case 'NSNFAC':
									return "AND v_mouvements_sejour_2.est_facture = '0'";
									break;
								case 'JRNSORFAC':
									return "AND v_mouvements_sejour_2.est_facture = '1' AND [VIEW.JOURNEES_FIELD] > 0";
									break;
								case 'JRNSORHONFAC':
									return "AND v_mouvements_sejour_2.est_facture = '1' AND ([VIEW.JOURNEES_FIELD] > 0 OR nb_ambulatoires > 0 OR nb_seances_dans_taux > 0)";
									break;
								case 'URG':
									return "AND nb_urgences > 0";
									break;
								case 'EMC':
									return 'AND equivalent_malade_complet > 0';
									break;
								default:
									return '';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="CDATA">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'NED':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_entrees_directes ELSE null END)';
									break;
								case 'NEM':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_entrees_directes + nb_entrees_mutation_[VIEW.MUTATION_FIELD] ELSE null END)';
									break;
								case 'NSD':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes ELSE null END)';
									break;
								case 'NSM':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes + nb_sorties_mutation_[VIEW.MUTATION_FIELD] ELSE null END)';
									break;
								case 'NJN':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] ELSE null END)';
									break;
								case 'NJNS':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_jour_sejour_sorti ELSE null END)';
									break;
								case 'NEX':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_externes ELSE null END)';
									break;
								case 'NAM':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_ambulatoires ELSE null END)';
									break;
								case 'NEDA':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_entrees_directes + nb_ambulatoires ELSE null END)';
									break;
								case 'NSDA':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes + nb_ambulatoires ELSE null END)';
									break;
								case 'NEDXA':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_entrees_directes + nb_externes + nb_ambulatoires ELSE null END)';
									break;
								case 'NSDXA':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes + nb_externes + nb_ambulatoires ELSE null END)';
									break;
								case 'NSDXBB':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes + nb_bebes + nb_ambulatoires ELSE null END)';
									break;
								case 'NJNXA':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] + nb_externes + nb_ambulatoires ELSE null END)';
									break;
								case 'NEDXAS':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_entrees_directes + nb_externes + nb_ambulatoires + CASE WHEN type_sejour = '5' THEN nb_seances ELSE 0 END ELSE null END)";
									break;
								case 'NSDXAS':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes + nb_externes + nb_ambulatoires + nb_seances_dans_taux ELSE null END)';
									break;
								case 'NSDXASSH':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes + nb_externes + nb_ambulatoires + CASE WHEN type_sejour = '5' THEN nb_seances_dans_taux ELSE 0 END ELSE null END)";
									break;	
								case 'NJNXAS':
									return 'SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] + nb_externes + nb_ambulatoires + nb_seances_dans_taux ELSE null END)';
									break;
								case 'NSE':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_seances ELSE null END)";
									break;
								case 'NSEDIA':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_seances_dialyse ELSE null END)";
									break;
								case 'NSECHM':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_seances_chimio ELSE null END)";
									break;
								case 'NSEDIV':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_seances_autre ELSE null END)";
									break;
								case 'NBB':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_bebes ELSE null END)";
									break;
                                case 'NBP':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN no_patient ELSE null END)";
									break;
								case 'NCP':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.CP_FIELD] ELSE null END)";
									break;
								case 'NJO':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN date ELSE null END)";
									break;
								case 'NJNM':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] ELSE null END)";
									break;
								case 'NEXM':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_externes ELSE null END)";
									break;
								case 'NAMM':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_ambulatoires ELSE null END)";
									break;
								case 'NSEM':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_seances ELSE null END)";
									break;
								case 'NJNXAM':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] + nb_externes + nb_ambulatoires ELSE null END)";
									break;
								case 'TAU':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] + nb_ambulatoires + nb_seances_dans_taux ELSE null END)";
									break;
								case 'NSHP':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN v_sejours_1.date_sortie > '[TOPERIODE]' AND v_sejours_1.code_sorti = 1 THEN v_sejours_1.no_sejour ELSE null END ELSE null END)";
									break;
								case 'NJNAS':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.JOURNEES_FIELD] + nb_ambulatoires + nb_seances_dans_taux ELSE null END)";
									break;
								case 'NAD':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_sejours_1.date_entree BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NADPRE':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_sejours_1.date_entree < '[PERIODE]' THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NSEJ':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NNONSOR':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND code_sorti = 0 THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NFULL':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND v_sejours_1.date_entree BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND v_sejours_1.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NSFAC':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND date_sortie <= '[TOPERIODE]'::date AND code_sorti = '1' AND v_mouvements_sejour_2.est_facture = '1' THEN v_sejours_1.no_sejour ELSE NULL END)";
									break;
								case 'NSNFAC':
									return "COUNT(DISTINCT CASE WHEN COLUMNCHECKSEQUENCE AND date_sortie <= '[TOPERIODE]'::date AND code_sorti = '1' AND v_mouvements_sejour_2.est_facture = '0' THEN v_sejours_1.no_sejour ELSE NULL END)";
									break;
								case 'JRNSORFAC':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND date_sortie <= '[TOPERIODE]' AND v_mouvements_sejour_2.est_facture = '1' THEN [VIEW.JOURNEES_FIELD] ELSE null END)";
									break;
								case 'JRNSORHONFAC':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE AND date_sortie <= '[TOPERIODE]' AND v_mouvements_sejour_2.est_facture = '1' THEN [VIEW.JOURNEES_FIELD] + nb_ambulatoires + nb_seances_dans_taux ELSE null END)";
									break;
								case 'DMSHES':
									return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE AND type_sejour = '1' AND nb_sorties_directes = 1 THEN duree ELSE 0 END), SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_sorties_directes ELSE null END))";
									break;
								case 'DMSHON':
									return "base.cti_division(SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN CASE WHEN type_sejour = '1' AND nb_sorties_directes = 1 THEN duree WHEN type_sejour = '2' THEN nb_ambulatoires WHEN type_sejour = '5' THEN nb_seances ELSE 0 END ELSE 0 END), SUM(CASE WHEN v_sejours_1.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND nb_sorties_directes + nb_ambulatoires + nb_seances_dans_taux > 0 THEN 1 ELSE 0 END))";
									break;
								case 'URG':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN nb_urgences ELSE 0 END)";
									break;
								case 'EMC':
									return "SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN equivalent_malade_complet ELSE 0 END)";
									break;
                                case 'GMP':
									return "base.cti_division(
                                        SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN gir_gmp_base*gir_gmp_coefficient ELSE 0 END),
                                        SUM(CASE WHEN COLUMNCHECKSEQUENCE THEN gir_gmp_base ELSE 0 END)
                                        )";
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="TDATA">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'NED':
									return 'SUM(nb_entrees_directes)';
									break;
								case 'NEM':
									return 'SUM(nb_entrees_directes + nb_entrees_mutation_[VIEW.MUTATION_FIELD])';
									break;
								case 'NSD':
									return 'SUM(nb_sorties_directes)';
									break;
								case 'NSM':
									return 'SUM(nb_sorties_directes + nb_sorties_mutation_[VIEW.MUTATION_FIELD])';
									break;
								case 'NJN':
									return 'SUM([VIEW.JOURNEES_FIELD])';
									break;
								case 'NJN':
									return 'SUM(nb_jour_sejour_sorti)';
									break;
								case 'NEX':
									return 'SUM(nb_externes)';
									break;
								case 'NAM':
									return 'SUM(nb_ambulatoires)';
									break;
								case 'NEDA':
									return 'SUM(nb_entrees_directes + nb_ambulatoires)';
									break;
								case 'NSDA':
									return 'SUM(nb_sorties_directes + nb_ambulatoires)';
									break;
								case 'NEDXA':
									return 'SUM(nb_entrees_directes + nb_externes + nb_ambulatoires)';
									break;
								case 'NSDXA':
									return 'SUM(nb_sorties_directes + nb_externes + nb_ambulatoires)';
									break;
								case 'NSDXBB':
									return 'SUM(nb_sorties_directes + nb_bebes + nb_ambulatoires)';
									break;
								case 'NJNXA':
									return 'SUM([VIEW.JOURNEES_FIELD] + nb_externes + nb_ambulatoires)';
									break;
								case 'NEDXAS':
									return "SUM(nb_entrees_directes + nb_externes + nb_ambulatoires + CASE WHEN type_sejour = '5' THEN nb_seances ELSE 0 END)";
									break;
								case 'NSDXAS':
									return 'SUM(nb_sorties_directes + nb_externes + nb_ambulatoires + nb_seances_dans_taux)';
									break;
								case 'NSDXASSH':
									return "SUM(nb_sorties_directes + nb_externes + nb_ambulatoires + CASE WHEN type_sejour = '5' THEN nb_seances_dans_taux ELSE 0 END)";
									break;	
								case 'NJNXAS':
									return 'SUM([VIEW.JOURNEES_FIELD] + nb_externes + nb_ambulatoires + nb_seances_dans_taux)';
									break;
								case 'NSE':
									return "SUM(nb_seances)";
									break;
								case 'NSEDIA':
									return "SUM(nb_seances_dialyse)";
									break;
								case 'NSECHM':
									return "SUM(nb_seances_chimio)";
									break;
								case 'NSEDIV':
									return "SUM(nb_seances_autre)";
									break;
								case 'NBB':
									return "SUM(nb_bebes)";
									break;
                                case 'NBP':
									return "COUNT(DISTINCT no_patient)";
									break;
								case 'NCP':
									return "SUM([VIEW.CP_FIELD])";
									break;
								case 'NJO':
									return "COUNT(*)";
									break;
								case 'NJNM':
									return "SUM([VIEW.JOURNEES_FIELD])";
									break;
								case 'NEXM':
									return "SUM(nb_externes)";
									break;
								case 'NAMM':
									return "SUM(nb_ambulatoires)";
									break;
								case 'NSEM':
									return "SUM(nb_ambulatoires)";
									break;
								case 'NJNXAM':
									return "SUM([VIEW.JOURNEES_FIELD] + nb_externes + nb_ambulatoires)";
									break;
								case 'TAU':
									return "SUM([VIEW.JOURNEES_FIELD] + nb_ambulatoires + nb_seances_dans_taux)";
									break;
								case 'NSHP':
									return "COUNT(DISTINCT CASE WHEN v_sejours_1.date_sortie > '[TOPERIODE]' AND v_sejours_1.code_sorti = 1 THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NJNAS':
									return "SUM([VIEW.JOURNEES_FIELD] + nb_ambulatoires + nb_seances_dans_taux)";
									break;
								case 'NAD':
									return "COUNT(DISTINCT CASE WHEN v_sejours_1.date_entree BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NADPRE':
									return "COUNT(DISTINCT CASE WHEN v_sejours_1.date_entree < '[PERIODE]' THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NSEJ':
									return "COUNT(DISTINCT v_sejours_1.no_sejour)";
									break;
								case 'NNONSOR':
									return "COUNT(DISTINCT CASE WHEN code_sorti = 0 THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NFULL':
									return "COUNT(DISTINCT CASE WHEN v_sejours_1.date_entree BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND v_sejours_1.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN v_sejours_1.no_sejour ELSE null END)";
									break;
								case 'NSFAC':
									return "COUNT(DISTINCT CASE WHEN date_sortie <= '[TOPERIODE]'::date AND code_sorti = '1' AND v_mouvements_sejour_2.est_facture = '1' THEN v_sejours_1.no_sejour ELSE NULL END)";
									break;
								case 'NSNFAC':
									return "COUNT(DISTINCT CASE WHEN date_sortie <= '[TOPERIODE]'::date AND code_sorti = '1' AND v_mouvements_sejour_2.est_facture = '0' THEN v_sejours_1.no_sejour ELSE NULL END)";
									break;
								case 'JRNSORFAC':
									return "SUM(CASE WHEN date_sortie <= '[TOPERIODE]' AND v_mouvements_sejour_2.est_facture = '1' THEN [VIEW.JOURNEES_FIELD] ELSE null END)";
									break;
								case 'JRNSORHONFAC':
									return "SUM(CASE WHEN date_sortie <= '[TOPERIODE]' AND v_mouvements_sejour_2.est_facture = '1' THEN [VIEW.JOURNEES_FIELD] + nb_ambulatoires + nb_seances_dans_taux ELSE null END)";
									break;
								case 'DMSHES':
									return "base.cti_division(SUM(CASE WHEN type_sejour = '1' AND nb_sorties_directes = 1 THEN duree ELSE 0 END), SUM(nb_sorties_directes))";
									break;
								case 'DMSHON':
									return "base.cti_division(SUM(CASE WHEN type_sejour = '1' AND nb_sorties_directes = 1 THEN duree WHEN type_sejour = '2' THEN nb_ambulatoires WHEN type_sejour = '5' THEN nb_seances ELSE 0 END), SUM(CASE WHEN v_sejours_1.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND nb_sorties_directes + nb_ambulatoires + nb_seances_dans_taux > 0 THEN 1 ELSE 0 END))";
									break;
								case 'URG':
									return "SUM(nb_urgences)";
									break;
								case 'EMC':
									return "SUM(equivalent_malade_complet)";
									break;
                                case 'GMP':
									return "base.cti_division(
                                        SUM(gir_gmp_base*gir_gmp_coefficient),
                                        SUM(gir_gmp_base)
                                        )";
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="ORDERBY">
			<value><![CDATA[[EVAL 
					
					$groupbys = array(
										'[GROUPBY]', 
										'[GROUPBY_2]', 
										'[GROUPBY_3]',
										substr('[GROUBY]', 0, 6), 
										substr('[GROUBY_2]', 0, 6), 
										substr('[GROUBY_3]', 0, 6)
									);
					$exceptions = array('ANNEE', 'TRIM', 'MOIS', 'JOUR', 'NUMEROTRIM', 'NUMEROMOIS', 'NUMEROJOUR');
					
					$result = array_intersect($groupbys, $exceptions);
					
					if (count($result) > 0) {
						return "DEFAULT";
					}
					else {
						return "indicateurs[2]";
					}
					
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="GROUPBY_DATE">
			<value>
				<![CDATA[
				[EVAL 	
					switch ('[GROUPBY]') {
						case 'ANNEE' :			$s = 'JOURS'; 		break;
						case 'TRIM' :			$s = 'JOURS';		break;
						case 'MOIS' :			$s = 'JOURS';		break;
						case 'NUMEROMOIS' :		$s = 'JOURS';		break;
						case 'NUMEROTRIM' :		$s = 'JOURS';		break;
						case 'SEMAINEWE' :		$s = 'JOURS';		break;
						case 'SEMAINEANNE' :	$s = 'JOURS';		break;
						case 'NUMEROJOUR' :		$s = 'JOURS';		break;
						case 'JOURS' :			$s = 'JOURS';		break;
						case 'JOUR' :			$s = 'JOURS';		break;
						
				
						default :				
								{$s = 'JOURS';			break;}
						
					}
					return $s;
				EVAL]
				]]>
			</value>
		</PROPERTY>
	</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="" UI="combo" tree="true" width="200" default="2009-01-01" globalListProvider="DATE_DEBUT" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2009-01-31" globalListProvider="DATE_FIN" >
			</FIELD>
		</GROUP>
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" UI="combo" width="300" default="SER" tree="true">
				<OPTION label="OCCUPATION_GROUPBY" data="" globalListProvider="OCCUPATION_GROUPBY"/>
			</FIELD>
			<FIELD name="GROUPBY_TAB" width="100" label="Présentation" UI="combo" default="AUTO" visible="= SELECT.GROUPBY_2 != '-1' ">
				<OPTION label="Automatique" data="AUTO"/>
				<OPTION label="Arbre" data="TREE"/>
				<OPTION label="Onglet" data="TAB"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_2" label="" UI="combo" width="300" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1" treeLevel="1"/>
				<OPTION label="OCCUPATION_GROUPBY" data="" globalListProvider="OCCUPATION_GROUPBY"/>
			</FIELD>
		</GROUP>
		<GROUP>
			<FIELD name="DATA" label="Données" UI="combo" width="300" default="NED" default2="0" tree="true">
				<OPTION label="Options" data="" globalListProvider="DATA_OCCUPATION" />
			</FIELD>
			<FIELD name="REAPRE" label="" UI="combo" default="0" visible="= ENV.OPTADM_PREVUS == '1'" showIfNotDefault="true">
				<OPTION data="0" label="Prévus exclus" data2=""/>
				<OPTION data="1" label="Prévus inclus" data2="(Réalisation et Prévisions)"/>
				<OPTION data="2" label="Uniquement prévus" data2="(Prévisions)"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
	
	<SELECTIONS componentName="DAYS_SELECTIONS" />
	
	<SELECTIONS label="Modes de calcul" displayText="= var display:String = '';
						display = display + 'Modes de calcul : #B#' + SELECT.QPLACES_LABEL + '. ' + VIEW.OPTADM_DAYOUT + '. ' + SELECT.QJMUT_LABEL  + '#/B#';
						
						return display;
						">
		<GROUP label="Modes">
			<FIELD name="QPLACES" label="" width="200" UI="combo" default="OUV">
				<OPTION data="OUV" label="Lits et box ouverts"/>
				<OPTION data="THEO" label="Lits et box théoriques"/>
			</FIELD>
			<FIELD name="QJMUT" label="" UI="combo" default="f">
				<OPTION data="d" label="Si mutation, journée affectée à la premiere localisation"/>
				<OPTION data="f" label="Si mutation, journée affectée à la dernière localisation"/>
				<OPTION data="12" label="Si mutation, journée affectée à la localisation occupée à 12h"/>
				<OPTION data="prorata" label="Si mutation, journée affectée au prorata du temps passé"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_OCCUPATION_SOUSSELECTIONS"/>
	<SELECTIONS componentName="FILTRES_MOUVEMENTS_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_SEJOURS_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_PATIENTS_SELECTIONS" />
	<SELECTIONS componentName="FILTRES_PASSAGES_SELECTIONS" />

	<QUERIES>
		<QUERY label="">
			<SQL>
				<select><![CDATA[		
					
					
					CTIPREPAR_TREE
						WORKTABLE{temp.acti000036_places}
						GROUPBY1{[VIEW.GROUPBY_PLACES_OID_FIELD],, [VIEW.GROUPBY_PLACES_COD_FIELD],, [VIEW.GROUPBY_PLACES_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{[VIEW.GROUPBY_2_PLACES_OID_FIELD],, [VIEW.GROUPBY_2_PLACES_COD_FIELD],, [VIEW.GROUPBY_2_PLACES_TXT_FIELD]}
						COLUMNBYOID{
							EXTRACT(DOW FROM date),, 
							CASE WHEN EXTRACT(DOW FROM date) = 0 THEN 7 ELSE EXTRACT(DOW FROM date) END,, 
							CASE WHEN EXTRACT(DOW FROM date) = 0 THEN 7 ELSE EXTRACT(DOW FROM date) END,, 
							1 ,, 7}
					INDICATORS{
						SUM(CASE WHEN date = '[VIEW.TOPERIODE]' THEN v_places_1.nb_lits_theoriques ELSE 0 END),,
						[VIEW.T_FACTEUR_MOYENNE]
					}
					INDICATORS_COLUMNS{
						[VIEW.C_FACTEUR_MOYENNE],,
						}
					FROM activite.v_places_1
					WHERE 
						date BETWEEN '[VIEW.PERIODE]' AND '[VIEW.TOPERIODE]'
						[VIEW.ETAGE_PLACES_SELECT]
						[VIEW.JOURS_SELECT]

				]]></select>
			</SQL>
			<SQL optimizer="V_SEJOURS_X" optimizer2="V_MOUVEMENTS_SEJOUR_X">
				<select><![CDATA[		

					CTISELECT_TREE
						WORKTABLE{acti000036}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
						SIGNIFDATA{[VIEW.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
						COLUMNBYOID{
							EXTRACT(DOW FROM date),, 
							CASE WHEN EXTRACT(DOW FROM date) = 0 THEN 7 ELSE EXTRACT(DOW FROM date) END,, 
							CASE 
								WHEN EXTRACT(DOW FROM date) = 0 THEN 'Dimanche' 
								WHEN EXTRACT(DOW FROM date) = 1 THEN 'Lundi' 
								WHEN EXTRACT(DOW FROM date) = 2 THEN 'Mardi' 
								WHEN EXTRACT(DOW FROM date) = 3 THEN 'Mercredi' 
								WHEN EXTRACT(DOW FROM date) = 4 THEN 'Jeudi' 
								WHEN EXTRACT(DOW FROM date) = 5 THEN 'Vendredi' 
								WHEN EXTRACT(DOW FROM date) = 6 THEN 'Samedi' 
								ELSE EXTRACT(DOW FROM date)::text END,, 
							1 ,, 7}
						INDICATORS{
							0,,
							[VIEW.TDATA]}	
						INDICATORS_COLUMNS{[VIEW.CDATA]}
						ORDERBY{[VIEW.ORDERBY],, DESC}
					FROM #V_SEJOURS_X#
					JOIN #V_MOUVEMENTS_SEJOUR_X# ON v_mouvements_sejour_2.no_sejour = v_sejours_1.no_sejour 
					WHERE 
						date BETWEEN '[VIEW.PERIODE]' AND '[VIEW.TOPERIODE]'
						[VIEW.SEJOURS_SELECT] [VIEW.PATIENTS_SELECT]
						[VIEW.MOUVEMENTS_SELECT] [VIEW.REAPRE_SELECT]
						[VIEW.DATA_SELECT] [VIEW.JOURS_SELECT] [VIEW.PASSAGES_SELECT]
						AND v_sejours_1.type_sejour <> '9'
						
						
					AFTER{
					
						UPDATE acti000036 SET 
							indicateurs[1] = acti000036_places.indicateurs[1]
							[EVAL 
							if ('[DATA]' == 'TAU' || '[DATA]' == 'NJNM' || '[DATA]' == 'NEXM' || '[DATA]' == 'NAMM' || '[DATA]' == 'NJNXAM'  ) {
								return ",
								indicateurs[2] = base.cti_division(acti000036.indicateurs[2] , acti000036_places.indicateurs[2]) ,
								indicateurs[3] = base.cti_division(acti000036.indicateurs[3] , acti000036_places.indicateurs[3]) ,
								indicateurs[4] = base.cti_division(acti000036.indicateurs[4] , acti000036_places.indicateurs[4]) ,
								indicateurs[5] = base.cti_division(acti000036.indicateurs[5] , acti000036_places.indicateurs[5]) ,
								indicateurs[6] = base.cti_division(acti000036.indicateurs[6] , acti000036_places.indicateurs[6]) ,
								indicateurs[7] = base.cti_division(acti000036.indicateurs[7] , acti000036_places.indicateurs[7]) ,
								indicateurs[8] = base.cti_division(acti000036.indicateurs[8] , acti000036_places.indicateurs[8]) ,
								indicateurs[9] = base.cti_division(acti000036.indicateurs[9] , acti000036_places.indicateurs[9]) ,
								indicateurs[10] = base.cti_division(acti000036.indicateurs[10] , acti000036_places.indicateurs[10])";
							}
							if ('[DATA]' == 'NJO') {
								return ",
								indicateurs[2] = acti000036_places.indicateurs[2] ,
								indicateurs[3] = acti000036_places.indicateurs[3] ,
								indicateurs[4] = acti000036_places.indicateurs[4] ,
								indicateurs[5] = acti000036_places.indicateurs[5] ,
								indicateurs[6] = acti000036_places.indicateurs[6] ,
								indicateurs[7] = acti000036_places.indicateurs[7] ,
								indicateurs[8] = acti000036_places.indicateurs[8] ,
								indicateurs[9] = acti000036_places.indicateurs[9] ,
								indicateurs[10] = acti000036_places.indicateurs[10]";
							}

							EVAL]
						FROM temp.acti000036_places
						WHERE 
							(acti000036_places.oidt = acti000036.oidt OR acti000036_places.oidt = -111) AND
							(acti000036_places.oid1 = acti000036.oid1 OR acti000036_places.oid1 = -111) AND
							(acti000036_places.oid2 = acti000036.oid2 OR acti000036_places.oid2 = -111)
						
					}

				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="SORT"/>
					<FIELD name="LIT"/>
					<FIELD name="N"/>
					<FIELD name="N1"/>
					<FIELD name="N2"/>
					<FIELD name="N3"/>
					<FIELD name="N4"/>
					<FIELD name="N5"/>
					<FIELD name="N6"/>
					<FIELD name="N7"/>
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL>
				<select><![CDATA[ 
					
						SELECT 
							'TOPERIODE', 
							to_char(COALESCE(MAX(date),'[TOPERIODE]'::date), 'YYYY-MM-DD')
						FROM 
							activite.p_mouvements_sejour 
						WHERE 
							date BETWEEN '[PERIODE]' AND '[TOPERIODE]' [VIEW.REAPRE_SELECT]
					UNION 
						SELECT 
							'PERIODE_ENHANCED_2',
							CASE WHEN '[PERIODE]' = '[TOPERIODE]' THEN ' = ' || '''' || to_char(COALESCE(MIN(date),'[PERIODE]'::date), 'YYYY-MM-DD') || '''::date'
								ELSE ' BETWEEN ''' || to_char(COALESCE(MIN(date),'[PERIODE]'::date), 'YYYY-MM-DD') || '''::date AND ''' || to_char(COALESCE(MAX(date),'[TOPERIODE]'::date), 'YYYY-MM-DD') || '''::date'
							END
						FROM 
							activite.p_mouvements_sejour 
						WHERE 
							date BETWEEN '[PERIODE]' AND '[TOPERIODE]' [VIEW.REAPRE_SELECT]
					UNION ALL
						SELECT 'ANA_CROI_PERIODE', to_char(greatest(	date_trunc('year', '[TOPERIODE]'::date) - INTERVAL  '3 year', 
														(SELECT date_trunc('year', min(date_comptable)) FROM activite.p_chiffrier_comptable)
													)::date, 'YYYY-MM-DD')
					UNION ALL
						SELECT 'ANA_CROI_TOPERIODE', 	to_char(
									least(	date_trunc('year', '[TOPERIODE]'::date) - interval '1 day' + interval '1 year',
												'[TOPERIODE]'::date)
									, 'YYYY-MM-DD')
					UNION ALL
						SELECT 'COMP_PERIODE', to_char(
									greatest(	date_trunc('year', '[TOPERIODE]'::date),
												date_trunc('month', '[PERIODE]'::date))
									, 'YYYY-MM-DD')
					UNION ALL
						SELECT 'COMP_PERIODE_D', to_char(
									greatest(	date_trunc('year', '[TOPERIODE]'::date) - interval '1 year',
												date_trunc('month', '[PERIODE]'::date) - interval '1 year')
									, 'YYYY-MM-DD')
					UNION ALL
						SELECT 'COMP_TOPERIODE_D', 	to_char(
									least(	date_trunc('year', '[TOPERIODE]'::date) - interval '1 day',
												'[TOPERIODE]'::date - interval '1 year')
									, 'YYYY-MM-DD')
					UNION ALL
						SELECT	
							'PLACESREF_GROUPBY',
							CASE 	WHEN t_divers.valeur = 'SER' THEN 'service'::text
									WHEN t_divers.valeur = 'UF' THEN  'uf'::text
									ELSE 'etage'::text
							END
						FROM activite.t_divers WHERE code = 'PLACESREF'
					UNION ALL
						SELECT	
							'PLACESREF_TEXT',
							CASE 	WHEN t_divers.valeur = 'SER' THEN 'Service'::text
									WHEN t_divers.valeur = 'UF' THEN  'Unité Fonctionnelle'::text
									ELSE 'Etage'::text
							END
						FROM activite.t_divers WHERE code = 'PLACESREF'
					UNION ALL
						SELECT	
							'PLACESREF',valeur
						FROM activite.t_divers WHERE code = 'PLACESREF'
						
				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
		</QUERY>		
        <QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL select="
				SELECT 'TOPERIODE', COALESCE(MAX(date),'[TOPERIODE]') 
				FROM activite.p_mouvements_sejour 
				WHERE date BETWEEN '[PERIODE]' AND '[TOPERIODE]' 
					[VIEW.REAPRE_SELECT]
				UNION 
				SELECT 'PERIODE', COALESCE(MIN(date),'[PERIODE]') 
				FROM activite.p_mouvements_sejour 
				WHERE date BETWEEN '[PERIODE]' AND '[TOPERIODE]' 
					[VIEW.REAPRE_SELECT]
				">
				<FIELDS>
					<FIELD name="name"/>
					<FIELD name="value"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Dernier mois/année" shortLabel="Dernier mois/année"    view="ACTI000056.XML" rowContext="false" buttonType="VIEWLINKPOPUP">
				<VIEWITEM label="Dernier mois" shortLabel="Dernier mois"  view="ACTI000056.XML" rowContext="false" enabled="true" buttonType="COMPARATIF" >
					<ARG name="ALIAS_PERIODE" value="return '-1';" />
					<ARG name="PERIODE" value="return SELECT.TOPERIODE.substr(0,8)+'01';"/>
					<ARG name="TOPERIODE" value=" return SELECT.TOPERIODE;"/>
					<ARG name="GROUPBY" value="return VIEW.GROUPBY_DATE;"/>
					<ARG name="GROUPBY_2" value="return SELECT.GROUPBY;" />
					<ARG name="GROUPBY_3" value="return SELECT.GROUPBY_2;" />
					<ARG name="LGROUPBY" value="return SELECT.GROUPBY;" />
					<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;" />
					<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;" />
					<ARG name="DATA1" value="'NSEJ'" />
					<ARG name="DATA2" value="'NSD'" />
					<ARG name="DATA3" value="'NJN'" />
					<ARG name="DATA4" value="'NAM';"/>
					<ARG name="DATA5" value="'NJNAS';"/>	
					<ARG name="TYPE_COMPARAISON" value="'2'" />
					<ARG name="GROUPBY_TAB" value="return 'TAB';" />
				</VIEWITEM>	
				<VIEWITEM label="&#8721; dernier mois" data="2" shortLabel="&#8721; dernier  mois"  view="ACTI000182.XML" enabled="true" rowContext="false" buttonType="COMPARATIF" >
					<ARG name="ALIAS_PERIODE" value="return '-1';" />
					<ARG name="PERIODE" value="return SELECT.TOPERIODE.substr(0,8)+'01';"/>
					<ARG name="DATA1" value="'NSEJ'" />
					<ARG name="DATA2" value="'NSD'" />
					<ARG name="DATA3" value="'NJN'" />
					<ARG name="GROUPBY" value="return 'JOURS';"/>
					<ARG name="GROUPBY_2" value="return '-1';" />
					<ARG name="GROUPBY_3" value="return '-1';" />
					<ARG name="LGROUPBY" value="return SELECT.GROUPBY;" />
					<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;" />
					<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;" />
					<ARG name="TYPE_COMPARAISON" value="return '2';" />
				</VIEWITEM>
				<VIEWITEM  label="Dernière année" data="2" shortLabel="derniere  année"  view="ACTI000056.XML" enabled="true" rowContext="false" buttonType="COMPARATIF" >
					<ARG name="ALIAS_PERIODE" value="return '-1';" />
					<ARG name="PERIODE" value="return SELECT.TOPERIODE.substr(0,4)+'-01-01';"/>
					<ARG name="TOPERIODE" value=" return SELECT.TOPERIODE;"/>
					<ARG name="GROUPBY" value="return VIEW.GROUPBY_DATE;"/>
					<ARG name="GROUPBY_2" value="return SELECT.GROUPBY;" />
					<ARG name="GROUPBY_3" value="return SELECT.GROUPBY_2;" />
					<ARG name="LGROUPBY" value="return SELECT.GROUPBY;" />
					<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;" />
					<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;" />
					<ARG name="DATA1" value="'NSEJ'" />
					<ARG name="DATA2" value="'NSD'" />
					<ARG name="DATA3" value="'NJN'" />
					<ARG name="DATA4" value="'NAM';"/>
					<ARG name="DATA5" value="'NJNAS';"/>	
					<ARG name="TYPE_COMPARAISON" value="'2'" />
					<ARG name="GROUPBY_TAB" value="return 'TAB';" />
				</VIEWITEM>	
				<VIEWITEM label="&#8721; dernière Année" shortLabel="&#8721; derniere année"  view="ACTI000182.XML" rowContext="false" enabled="true" buttonType="COMPARATIF">
					<ARG name="ALIAS_PERIODE" value="return '-1';" />
					<ARG name="PERIODE_D" value="return VIEW.COMP_PERIODE_D;" />
					<ARG name="TOPERIODE_D" value="return VIEW.COMP_TOPERIODE_D;" />
					<ARG name="PERIODE" value="return SELECT.TOPERIODE.substr(0,4)+'-01-01';" />
					<ARG name="TOPERIODE" value=" return SELECT.TOPERIODE;" />
					<ARG name="GROUPBY" value="return 'NUMEROMOIS';"/>
					<ARG name="GROUPBY_2" value="return '-1';"/>
					<ARG name="GROUPBY_3" value="return '-1';"/>
					<ARG name="LGROUPBY" value="return SELECT.GROUPBY;" />
					<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;" />
					<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;" />
					<ARG name="DATA1" value="'NSEJ'" />
					<ARG name="DATA2" value="'NSD'" />
					<ARG name="DATA3" value="'NJN'" />
					<ARG name="TYPE_COMPARAISON" value="'2'" />
				</VIEWITEM>	
			</VIEWLINK>
			<VIEWLINK label="Comparatif" shortLabel="Comparatif"  view="ACTI000056.XML" rowContext="false" enabled="true" buttonType="COMPARATIF" >
					<ARG name="PERIODE" value="return VIEW.COMP_PERIODE;" />
					<ARG name="PERIODE_D" value="return VIEW.COMP_PERIODE_D;" />
					<ARG name="TOPERIODE_D" value="return VIEW.COMP_TOPERIODE_D;" />
					<ARG name="DATA1" value="'NSD'" />
					<ARG name="DATA2" value="'NJN'" />
					<ARG name="DATA3" value="'TAU'" />
					<ARG name="TYPE_COMPARAISON" value="'S'" />
			</VIEWLINK>			
			<VIEWLINK label="Comparatif mensuel" shortLabel="Comp. mensuel"  view="ACTI000169.XML" rowContext="false" enabled="true" buttonType="COMPARATIF" >
					<ARG name="PERIODE" value="return SELECT.TOPERIODE.substr(0,4)+'-01-01';" />
					<ARG name="DATA1" value="'NSD'" />
					<ARG name="DATA2" value="'NJN'" />
					<ARG name="DATA3" value="'TAU'" />
					<ARG name="TYPE_COMPARAISON" value="'2'" />
			</VIEWLINK>
			<VIEWLINK label="Evolution comparative" shortLabel="Evol. comparative"   rowContext="false" buttonType="VIEWLINK_EVO_COMP" >			
				<VIEWITEM label="Standard" shortLabel="Evolution comparative" view="ACTI000173.XML" rowContext="false" enabled="true" buttonType="VIEWLINK_EVO_COMP">
					<ARG name="GROUPBY" value="return SELECT.GROUPBY;" />
					<ARG name="GROUPBY_2" value="return 'NUMEROMOIS';" />
					<ARG name="DATA1" value="'NSEJ'" />
					<ARG name="DATA2" value="'NSD'" />
					<ARG name="DATA3" value="'NJN'" />
					<ARG name="DATA4" value="'NAM';"/>
					<ARG name="DATA5" value="'NJNAS';"/>				
					<ARG name="DATA6"   value="return '0';" />
					<ARG name="DATA7"   value="return '0';" />
					<ARG name="DATA8"   value="return '0';" />
					<ARG name="DATA9"   value="return '0';"/>
					<ARG name="DATA10" 	value="return '0';"/>			
					<ARG name="DATA011" value="return '0';" />
					<ARG name="DATA012" value="return '0';" />
					<ARG name="DATA013" value="return '0';" />
					<ARG name="DATA014" value="return '0';"/>
					<ARG name="DATA015" value="return '0';"/>
					<ARG name="LGROUPBY" value="return SELECT.GROUPBY;"/>
					<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;"/>
					<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;"/>
					<ARG name="GROUPBY_TAB" value="return 'TAB';" />
					<ARG name="TYPE_COMPARAISON" value="'2'" />
				</VIEWITEM>	
				<VIEWITEM label="Détaillée" shortLabel="Evolution comparative" view="ACTI000173.XML" rowContext="false" enabled="true" buttonType="COMPARATIF">
					<ARG name="GROUPBY" value="return SELECT.GROUPBY;" />
					<ARG name="GROUPBY_2" value="return 'NUMEROMOIS';" />
					<ARG name="DATA1" value="'NSEJ'" />
					<ARG name="DATA2" value="'NSD'" />
					<ARG name="DATA3" value="'NJN'" />
					<ARG name="DATA4" value="'NAM';"/>
					<ARG name="DATA5" value="'NJNAS';"/>					
					<ARG name="DATA6" value="'NSE'" />
					<ARG name="DATA7" value="'NEX'" />
					<ARG name="DATA8" value="'EMC'" />
					<ARG name="DATA9" value="'DMSHES';"/>
					<ARG name="DATA10" value="'DMSHON';"/>					
					<ARG name="DATA011" value="return '0';" />
					<ARG name="DATA012" value="return '0';" />
					<ARG name="DATA013" value="return '0';" />
					<ARG name="DATA014" value="return '0';"/>
					<ARG name="DATA015" value="return '0';"/>
					<ARG name="LGROUPBY" value="return SELECT.GROUPBY;"/>
					<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;"/>
					<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;"/>
					<ARG name="GROUPBY_TAB" value="return 'TAB';" />
					<ARG name="TYPE_COMPARAISON" value="'2'" />
				</VIEWITEM>	
			</VIEWLINK>	
			<VIEWLINK label="Evolution" shortLabel="Evolution" view="ACTI000054.XML" rowContext="false" enabled="true" buttonType="EVOLUTION" componentName="PERIODICITE_VIEWLINK" component2Name="OCC_BASE_VIEWLINK" >
			</VIEWLINK>
			<VIEWLINK label="Répartition hebdomadaire" shortLabel="Répartition hebdo" view="ACTI000036.XML" rowContext="false" enabled="true" buttonType="EVOLUTION" componentName="OCC_BASE_VIEWLINK">
				<ARG name="DATA" value="'NSD'" />
			</VIEWLINK>
			<VIEWLINK label="Analyse croisée" shortLabel="Analyse croisée" view="ACTI000072.XML" enabled="true" rowContext="false" buttonType="ANALYSE_CROISEE" componentName="OCC_BASE_VIEWLINK" >
				<ARG name="PERIODE" value="return VIEW.ANA_CROI_PERIODE;" />
				<ARG name="TOPERIODE" value="return VIEW.ANA_CROI_TOPERIODE;" />
				<ARG name="COLUMNBY" value="'NUMEROMOIS'" />
				<ARG name="GROUPBY" value="'ANNEE'" />
				<ARG name="GROUPBY_2" value="if (SELECT.GROUPBY == 'ANNEE' || SELECT.GROUPBY == 'JOUR') {return 'SER';} else {return SELECT.GROUPBY;}" />
				<ARG name="LGROUPBY" value="return SELECT.GROUPBY;"/>
				<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;"/>
				<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;"/>				
				<ARG name="GROUPBY_TAB" value="'TAB'" />
				<ARG name="COLUMNBYCOUNT" value="'12'" />
			</VIEWLINK>
			<VIEWLINK label="Analyse" shortLabel="Analyse" view="ACTI000123.XML" enabled="true" rowContext="false" buttonType="ANALYSE" >
				<ARG name="ALIAS_PERIODE" value="return '-1'" />
				<ARG name="GROUPBY" value="return SELECT.GROUPBY;" />
				<ARG name="GROUPBY_2" value="reurn SELECT.GROUPBY_2" />
				<ARG name="GROUPBY_2" value="reurn SELECT.GROUPBY_3" />
				<ARG name="GROUPBY_TAB" value="return 'TAB';" />
				<ARG name="LGROUPBY" value="return SELECT.GROUPBY;"/>
				<ARG name="LGROUPBY_2" value="return SELECT.GROUPBY_2;"/>
				<ARG name="LGROUPBY_3" value="return SELECT.GROUPBY_3;"/>
			</VIEWLINK>	
			<VIEWLINK label="Liste des séjours" shortLabel="Séjours" view="ACTI000052.XML" componentName="OCC_BASE_VIEWLINK" component3Name="STANDARD_BASE_VIEWLINK">
				<ARG name="DATA" value="if (COLUMN.NAME == 'ENT') {return 'ENT'}
										if (COLUMN.NAME == 'ENTM') {return 'ENT'}
										if (COLUMN.NAME == 'SOR') {return 'SOR'}
										if (COLUMN.NAME == 'SORM') {return 'SOR'}
										if (COLUMN.NAME == 'JRN') {return 'JRN'}
										if (COLUMN.NAME == 'JRNM') {return 'JRN'}
										if (COLUMN.NAME == 'NCP') {return 'CP'}
										if (COLUMN.NAME == 'EXT') {return 'EXT'}
										if (COLUMN.NAME == 'EXTM') {return 'EXT'}
										if (COLUMN.NAME == 'AMB') {return 'AMB'}
										if (COLUMN.NAME == 'AMBM') {return 'AMB'}
										if (COLUMN.NAME == 'URG') {return 'URG'}
										if (COLUMN.NAME == 'URGM') {return 'URG'}
										if (COLUMN.NAME == 'BB') {return 'BB'}
										if (COLUMN.NAME == 'BBM') {return 'BB'}
										if (COLUMN.NAME == 'SEA') {return 'SEA'}
										if (COLUMN.NAME == 'SEAM') {return 'SEA'}
										
										return '-1'"/>
				<ARG name="LUN"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N1') { return '1';}
						else { return '0';}
					}
					
				]]></value></ARG>
				
				<ARG name="MAR"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N2') { return '2';}
						else { return '0';}
					}
					
				]]></value></ARG>
				
				<ARG name="MER"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N3') { return '3';}
						else { return '0';}
					}
					
				]]></value></ARG>
				
				<ARG name="JEU"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N4') { return '4';}
						else { return '0';}
					}
					
				]]></value></ARG>
				
				<ARG name="VEN"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N5') { return '5';}
						else { return '0';}
					}
					
				]]></value></ARG>
				
				<ARG name="SAM"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N6') { return '6';}
						else { return '0';}
					}
					
				]]></value></ARG>
				
				<ARG name="DIM"><value><![CDATA[ 
					
					if (COLUMN.NAME == 'N1' || COLUMN.NAME == 'N2' || COLUMN.NAME == 'N3' || COLUMN.NAME == 'N4' || COLUMN.NAME == 'N5' || COLUMN.NAME == 'N6' || COLUMN.NAME == 'N7') {
						if (COLUMN.NAME == 'N7') { return '7';}
						else { return '0';}
					}
					
				]]></value></ARG>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Répartition dans la semaine" label="Répartition dans la semaine" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
			<CHART title="Evolution hebdomadaire" type="columnChart" serieIsCategory="true" fromTotal="true" >
				<CATEGORY field="TXT" type="Char" displayName="Total"/>
				<SERIE field="N1" displayName="VIEW.COLH1" displayNameCalc="true" visibleCondition="VIEW.COLH1 != null &amp;&amp; SELECT.LUN == '1'"/>
				<SERIE field="N2" displayName="VIEW.COLH2" displayNameCalc="true" visibleCondition="VIEW.COLH2 != null &amp;&amp; SELECT.MAR == '2'"/>
				<SERIE field="N3" displayName="VIEW.COLH3" displayNameCalc="true" visibleCondition="VIEW.COLH3 != null &amp;&amp; SELECT.MER == '3'"/>
				<SERIE field="N4" displayName="VIEW.COLH4" displayNameCalc="true" visibleCondition="VIEW.COLH4 != null &amp;&amp; SELECT.JEU == '4'"/>
				<SERIE field="N5" displayName="VIEW.COLH5" displayNameCalc="true" visibleCondition="VIEW.COLH5 != null &amp;&amp; SELECT.VEN == '5'"/>
				<SERIE field="N6" displayName="VIEW.COLH6" displayNameCalc="true" visibleCondition="VIEW.COLH6 != null &amp;&amp; SELECT.SAM == '6'"/>
				<SERIE field="N7" displayName="VIEW.COLH7" displayNameCalc="true" visibleCondition="VIEW.COLH7 != null &amp;&amp; SELECT.DIM == '7'"/>
			</CHART>
			<CHART title="Comparatif (10 premiers) " type="pieChart" maxItems="10" maxItemsSortOn="N" maxItemsSortSeq="D" sortField="N" sortSeq="D" condition="Number(ROW.LVL) == 1"
				visibleCondition="SELECT.GROUPBY != 'ANNEE' &amp;&amp; SELECT.GROUPBY != 'TRIM' &amp;&amp; SELECT.GROUPBY != 'MOIS' &amp;&amp; SELECT.GROUPBY != 'JOUR' &amp;&amp; SELECT.GROUPBY != 'NUMEROTRIM' &amp;&amp; SELECT.GROUPBY != 'NUMEROMOIS' &amp;&amp; SELECT.GROUPBY != 'NUMEROJOUR'">
				<CATEGORY field="TXT" type="Char"/>
				<SERIE field="N" displayName="SELECT.DATA_LABEL" displayNameCalc="true"/>
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="36" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'" 
						sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'">
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="70" type="Char" visible="true" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="150" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="Autres">
				</COLUMN>
				<COLUMN dataField="LIT" type="Number" width="45" outputFormat="0" visible="true" headerText="Places" textAlign="right" totalFunction="text" otherFunction="text" otherComplement="">
				</COLUMN>
				<COLUMN dataField="N" width="80" visible="true" type="Number" outputFormat="= SELECT.DATA2" headerText="Total" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="N_P" type="Number" headerText="% / Total" width="40" outputFormat="0%" textAlign="right" visibleCondition="SELECT.DATA != 'TAU' " totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.N / TOTALROW.N * 100"/>
				</COLUMN>
				<COLUMN dataField="N1" width="80" visibleCondition="VIEW.COLH1 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH1" columnData="= VIEW.COLI1" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N2" width="80" visibleCondition="VIEW.COLH2 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH2" columnData="= VIEW.COLI2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N3" width="80" visibleCondition="VIEW.COLH3 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH3" columnData="= VIEW.COLI3" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N4" width="80" visibleCondition="VIEW.COLH4 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH4" columnData="= VIEW.COLI4" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N5" width="80" visibleCondition="VIEW.COLH5 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH5" columnData="= VIEW.COLI5" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N6" width="80" visibleCondition="VIEW.COLH6 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH6" columnData="= VIEW.COLI6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N7" width="80" visibleCondition="VIEW.COLH7 != null" type="Number" outputFormat="= SELECT.DATA2" fixed="false" selectable="true" headerText="VIEW.COLH7" columnData="= VIEW.COLI7" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
