public boolean Exclude(LinkedList<interval> testIntervals, LinkedList<Exclusion> exclusions, QueryTool query) throws ParseException, SQLException
    {
    	
    	for(Exclusion exclusion: exclusions)
    	{
    		
    		IntervalDescription desc = exclusion.intervalDescription;
			LinkedList<instant> newInstants = new LinkedList<instant>();
			LinkedList<interval> exclusionIntervals = new LinkedList<interval>();
			boolean negated = false;
			
			/*
			 * If it's negated, apply negation.
			 */
			if(desc.negated)
			{
				negated = true;
				desc.negate();
			}
			
			if(desc.type.equalsIgnoreCase("Normal"))
			{
			
				if(desc.subType.equalsIgnoreCase("Numeric"))
				{
					double value1 = 0;
					double value2 = 0;
					boolean excl1 = false;
					boolean excl2 = false;
					if(desc.valueType.equalsIgnoreCase("Equals"))
					{
						value1 = desc.value;
					}
					else if(desc.valueType.equalsIgnoreCase("Greater than"))
					{
						value1 = desc.value;
						excl1 = desc.excludeHigh;
					}
					else if(desc.valueType.equalsIgnoreCase("Lower than"))
					{
						value1 = desc.value;
						excl1 = desc.excludeLow;
					}
					else if(desc.valueType.equalsIgnoreCase("Between"))
					{
						value1 = desc.lowValue;
						excl1 = desc.excludeLow;
						value2 = desc.highValue;
						excl2 = desc.excludeHigh;
					}
					else if(desc.valueType.equalsIgnoreCase("Out"))
					{
						value1 = desc.lowValue;
						excl1 = desc.excludeLow;
						value2 = desc.highValue;
						excl2 = desc.excludeHigh;
					}
					else //Any
					{
						//No hay que asignar ningún valor por ahora, sólo está por si me falta agregar algo.
					}
					newInstants.addAll(App.setup.db.getNumericInstants(this.id, desc.itemid, desc.tableName, desc.valueType, value1, value2, excl1, excl2, desc.calculations1, desc.calculations2, negated, desc.attributes, desc));					
				}
				else if(desc.subType.equalsIgnoreCase("Categorical"))
				{
					newInstants.addAll(App.setup.db.getCategoricalInstants(this.id, desc.itemid, desc.tableName, desc.category, negated, desc.attributes, desc));
				}
			}
			else if(desc.type.equalsIgnoreCase("Window"))
			{
				/*
				 * Don't bother with negations, they will be managed in the
				 * window intervals method from Patient.
				 */
				if(desc.subType.equalsIgnoreCase("Categorical"))
				{
					newInstants.addAll(App.setup.db.getCategoricalInstants(this.id, desc.itemid, desc.tableName, "Any", false, desc.attributes, desc));
				}
				else
				{						
					newInstants.addAll(App.setup.db.getNumericInstants(this.id, desc.itemid, desc.tableName, "Any", 0, 0, false, false, desc.calculations1, desc.calculations2, false, desc.attributes, desc));	
				}
			}
			else if(desc.type.equalsIgnoreCase("Bounded"))
			{
				//System.out.println("Enters bounded.");
				LinkedList<String> tableNames = new LinkedList<String>();
				tableNames.add(desc.tableName);
				if(!desc.tableName.equalsIgnoreCase(desc.tableName2))
				{
					tableNames.add(desc.tableName2);
				}
				LinkedList<instant>[] bInst = App.setup.db.getBoundedInstants(this.id, tableNames, desc.colName1, desc.colName2, desc.attributes, desc);			
				exclusionIntervals.addAll(this.getBoundedIntervals(bInst, "Bounded", desc));
			}
			
			if(!desc.type.equalsIgnoreCase("Bounded"))
			{
				//System.out.println("Enters not bounded.");
				if(desc.type.equalsIgnoreCase("Normal"))
				{
					//p.instantsList.add(newInstants);				
					exclusionIntervals.addAll(this.getIntervals(desc, newInstants));
				}
				else if(desc.type.equalsIgnoreCase("Window"))
				{
					
					exclusionIntervals.addAll(this.GenerateWindowIntervals(newInstants, desc));
				}
			}
			
			/*
			 * We have intervals for the exclusion.
			 * Now we need it's relation with the original intervals.
			 */
			
			RelationDescription relDesc = exclusion.relationDescription;
			
			Relation rel = null;			
			if(relDesc.rel == RelationType.AFTER || relDesc.rel == RelationType.BEFORE)
			{
				if(relDesc.direction.equalsIgnoreCase("NONE"))
				{
					rel = new Relation(relDesc.rel, relDesc.min, relDesc.max);
				}
				else
				{
					rel = new Relation(relDesc.rel, relDesc.min, relDesc.max, relDesc.direction, relDesc.abs, relDesc.percent);
				}
			}
			else if(relDesc.rel == RelationType.DURING)
			{
				rel = new Relation(relDesc.rel, relDesc.startMin, relDesc.startMax, relDesc.endMin, relDesc.endMax);
			}
			else
			{
				rel = new Relation(relDesc.rel);
			}
			
			/*
			 * Now we need to test if the intervals lists satisfy the relation.
			 * If they do, then the patient should be excluded,
			 * i.e., return true (no need to test further exclusions).
			 */
			if(!query.testRelation(exclusionIntervals, testIntervals, rel).isEmpty())
			{
				return true;
			}
    	}
    	
    	return false;
    }