anchor.diff:  		//no time period entered
   		else if (!kWord.equals("") && kTime1.equals("")
   				|| kTime2.equals("")) {
  -			out.println("Records matching keyword(s): " + kWord);
  -			String[] wordList = kWord.split(" ");
  -
  -			for (int i = 0; i < wordList.length; i++) {
  -				sql = sql + class_id + "r.DIAGNOSIS ='" + wordList[i]
  -						+ "' or p.LAST_NAME = '" + wordList[i]
  -						+ "' or p.first_name = '" + wordList[i]
  -						+ "'or r.DESCRIPTION like '%" + wordList[i] + "%'";
  +		out.println("Records matching keyword(s): " + kWord);
  +		sql = sql + ", ";
  +		String[] wordList = kWord.split(" ");
  +		int count_score = 0;
  +		for (int i = 0; i < wordList.length; i++) {
  +			sql = sql + "6*score("+ Integer.toString(count_score+3) +")+6*score("+ Integer.toString(count_score+4) +")+3*score("+ Integer.toString(count_score+1) +")+score("+ Integer.toString(count_score+2)+") ";
  +							
  +			if (i != wordList.length - 1)
  +				sql = sql + "+ ";
  +		}
  +		sql = sql + " as rank ";
  +
  +		sql = sql + "from radiology_record r FULL JOIN persons p ON r.patient_id = p.person_id where ";
  +			//String[] wordList = kWord.split(" ");
  +			int count_contains = 0;
  +			for (int i = 0; i < wordList.length; i++) {
  +				sql = sql + class_id + "contains(r.diagnosis, '" + wordList[i] + "', "+ Integer.toString(count_contains+1) +") > 0 OR contains(r.description, '" + wordList[i] + "', "+ Integer.toString(count_contains+2) +") > 0 OR contains(p.first_name, '" + wordList[i] + "', "+ Integer.toString(count_contains+3) +") > 0 OR contains(p.last_name, '" + wordList[i] + "', "+ Integer.toString(count_contains+4) +") > 0 ";
   				if (i != wordList.length - 1)
   					sql = sql + "OR ";
  +				count_contains += 4;
   			}
   			sql = sql + "ORDER BY " + SQLOrder;
   
  
positive.code: 		} else if (request.getParameter("SEARCHTYPE").equals(
  				"recentLast")) {
  			SQLOrder = "r.test_date ASC";
  		} else if (request.getParameter("SEARCHTYPE")
  				.equals("relevant")) {
  			//SQLOrder = ...
  			//SQL order by  Rank(record_id) = 6*frequency(patient_name) + 3*frequency(diagnosis) + frequency(description)
  		}
  	} else {
  
negative.code: 
  		//both entered
  		if (kWord != "" && kTime1 != "" && kTime2 != "") {
  		sql = sql + ", ";
  		String[] wordList = kWord.split(" ");
  		int count_score = 0;
  		for (int i = 0; i < wordList.length; i++) {
  			sql = sql + "6*score("+ Integer.toString(count_score+3) +")+6*score("+ Integer.toString(count_score+4) +")+3*score("+ Integer.toString(count_score+1) +")+score("+ Integer.toString(count_score+2)+") ";
  							
  			if (i != wordList.length - 1)
  				sql = sql + "+ ";
  		}
  		sql = sql + "as rank ";
  
  		sql = sql + "from radiology_record r FULL JOIN persons p ON r.patient_id = p.person_id where ";
  
  			out.println("Records for keyword(s): " + kWord
  					+ " between dates " + kTime1 + " and " + kTime2);
  			//String[] wordList = kWord.split(" ");
  
  			sql = sql + "r.test_date between to_date('" + kTime1
  					+ "', 'DD/MM/YYYY') AND to_date('" + kTime2
  					+ "', 'DD/MM/YYYY') AND ";
  
  			int count_contains = 0;
  			for (int i = 0; i < wordList.length; i++) {
  				sql = sql + class_id + "r.DIAGNOSIS ='" + wordList[i]
  						+ "' or p.LAST_NAME = '" + wordList[i]
  