// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java
// public interface ConceptDrugDatabaseInterface {
// 
// 	/*
// 	 * get name of file that will contain the prediction matrix generated by
// 	 * algorithm
// 	 */
// 	public String getMatrixFileName();
// 
// 	/*
// 	 * Method to get all the medical records containing encounterId(integer that
// 	 * represent an id for prescriptions written for a patient),
// 	 * ConceptId(integer that represent a diagnosis/diseases/observation for
// 	 * patient has been treated), DrugId(integer representing a drug that was
// 	 * written in the prescription)
// 	 */
// 	public LinkedList<EncounterIdConceptDrug> getData();
// 
// 	/*
// 	 * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId,
// 	 * and feature related to medical records like age of patient, location of doctor/patient etc.
// 	 */
// 	
// 	public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids);
// 
// 	/*
// 	 * Method to get the list of conceptId and concept_name for given list of conceptId(integer)
// 	 */
// 	
// 	public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of Drugs for given drugIds(integers)
// 	 */
// 	public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of all conceptId and concept_words
// 	 */
// 	public LinkedList<ConceptWordModel> getConceptWords();
// }
// 
// Path: src/com/learningmodule/association/conceptdrug/model/ConceptNameModel.java
// public class ConceptNameModel {
// 
// 	private String conceptId;
// 	private String conceptName;
// 
// 	public ConceptNameModel(String conceptId, String conceptName) {
// 		super();
// 		this.conceptId = conceptId;
// 		this.conceptName = conceptName;
// 	}
// 
// 	public String getConceptId() {
// 		return conceptId;
// 	}
// 
// 	public void setConceptId(String conceptId) {
// 		this.conceptId = conceptId;
// 	}
// 
// 	public String getConceptName() {
// 		return conceptName;
// 	}
// 
// 	public void setConceptName(String conceptName) {
// 		this.conceptName = conceptName;
// 	}
// }
// 
// Path: src/com/learningmodule/association/conceptdrug/model/ConceptDrugPredictionResult.java
// public class ConceptDrugPredictionResult implements PredictionResult {
// 	// contains drug info
// 	private AbstractDrugModel drug;
// 
// 	// confidence related to the drug and query
// 	private double confidence;
// 
// 	// concepts names for the concepts, drug related to
// 	private LinkedList<String> tags;
// 
// 	// conceptsId of concepts drug realted to
// 	private HashSet<String> conceptIds;
// 
// 	public ConceptDrugPredictionResult(String drug, double confidence) {
// 		this.drug = new DrugModel(drug);
// 		this.confidence = confidence;
// 		this.conceptIds = new HashSet<String>();
// 		this.tags = new LinkedList<String>();
// 	}
// 
// 	public AbstractDrugModel getDrug() {
// 		return drug;
// 	}
// 	
// 	@Override
// 	public Object getValue() {
// 		return drug;
// 	}
// 
// 	public void setDrug(AbstractDrugModel drug) {
// 		this.drug = drug;
// 	}
// 
// 	@Override
// 	public double getConfidence() {
// 		return confidence;
// 	}
// 
// 	public void setConfidence(double confidence) {
// 		this.confidence = confidence;
// 	}
// 
// 	public LinkedList<String> getTags() {
// 		return tags;
// 	}
// 
// 	/*
// 	 * method to add a tag for drug result
// 	 */
// 	public void addTags(String tag) {
// 		this.tags.add(tag);
// 	}
// 
// 	public HashSet<String> getConceptIds() {
// 		return conceptIds;
// 	}
// 
// 	/*
// 	 * method to add concept Ids related to the drug result
// 	 */
// 	public void addConceptId(String conceptId) {
// 		this.conceptIds.add(conceptId);
// 	}
// 
// 	public boolean hasConcept(String conceptId) {
// 		return conceptIds.contains(conceptId);
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "PredictionResults [drug=" + drug.toString() + ", confidence=" + confidence + "]";
// 	}
// }


import java.util.LinkedList;
import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface;
import com.learningmodule.association.conceptdrug.model.ConceptNameModel;
import com.learningmodule.association.conceptdrug.model.ConceptDrugPredictionResult;
package com.learningmodule.association.conceptdrug.predictionmodule;



/*
 * class that fetch the concept name from database interface and add names to tag in results
 */

public class ConceptNameDatabaseOperation {

	// method to get the list of tags for each drug result
	public static LinkedList<ConceptDrugPredictionResult> getTags(
			LinkedList<ConceptDrugPredictionResult> results,
			ConceptDrugDatabaseInterface learningDataInterface) {

		// get the list of conceptId and conceptNames from database Interface
		LinkedList<ConceptNameModel> concepts = learningDataInterface
				.getConceptIdNameByConceptIds(getIds(results));

		// loop adds the concepts names to tags in results
		for (ConceptNameModel concept : concepts) {
			for (ConceptDrugPredictionResult result : results) {
				if (result.hasConcept(concept.getConceptId())) {
					// add the concept name is concept Id is related to drug
					result.addTags(concept.getConceptName());
				}
			}
		}
		return results;
	}

	/*
	 * method to get the string that has to be put in SQL query which has all
	 * conceptId separated by comma
	 */
	private static LinkedList<String> getIds(LinkedList<ConceptDrugPredictionResult> results) {
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java
// public interface ConceptDrugDatabaseInterface {
// 
// 	/*
// 	 * get name of file that will contain the prediction matrix generated by
// 	 * algorithm
// 	 */
// 	public String getMatrixFileName();
// 
// 	/*
// 	 * Method to get all the medical records containing encounterId(integer that
// 	 * represent an id for prescriptions written for a patient),
// 	 * ConceptId(integer that represent a diagnosis/diseases/observation for
// 	 * patient has been treated), DrugId(integer representing a drug that was
// 	 * written in the prescription)
// 	 */
// 	public LinkedList<EncounterIdConceptDrug> getData();
// 
// 	/*
// 	 * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId,
// 	 * and feature related to medical records like age of patient, location of doctor/patient etc.
// 	 */
// 	
// 	public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids);
// 
// 	/*
// 	 * Method to get the list of conceptId and concept_name for given list of conceptId(integer)
// 	 */
// 	
// 	public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of Drugs for given drugIds(integers)
// 	 */
// 	public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of all conceptId and concept_words
// 	 */
// 	public LinkedList<ConceptWordModel> getConceptWords();
// }
// 
// Path: src/com/learningmodule/association/conceptdrug/model/ConceptNameModel.java
// public class ConceptNameModel {
// 
// 	private String conceptId;
// 	private String conceptName;
// 
// 	public ConceptNameModel(String conceptId, String conceptName) {
// 		super();
// 		this.conceptId = conceptId;
// 		this.conceptName = conceptName;
// 	}
// 
// 	public String getConceptId() {
// 		return conceptId;
// 	}
// 
// 	public void setConceptId(String conceptId) {
// 		this.conceptId = conceptId;
// 	}
// 
// 	public String getConceptName() {
// 		return conceptName;
// 	}
// 
// 	public void setConceptName(String conceptName) {
// 		this.conceptName = conceptName;
// 	}
// }
// 
// Path: src/com/learningmodule/association/conceptdrug/model/ConceptDrugPredictionResult.java
// public class ConceptDrugPredictionResult implements PredictionResult {
// 	// contains drug info
// 	private AbstractDrugModel drug;
// 
// 	// confidence related to the drug and query
// 	private double confidence;
// 
// 	// concepts names for the concepts, drug related to
// 	private LinkedList<String> tags;
// 
// 	// conceptsId of concepts drug realted to
// 	private HashSet<String> conceptIds;
// 
// 	public ConceptDrugPredictionResult(String drug, double confidence) {
// 		this.drug = new DrugModel(drug);
// 		this.confidence = confidence;
// 		this.conceptIds = new HashSet<String>();
// 		this.tags = new LinkedList<String>();
// 	}
// 
// 	public AbstractDrugModel getDrug() {
// 		return drug;
// 	}
// 	
// 	@Override
// 	public Object getValue() {
// 		return drug;
// 	}
// 
// 	public void setDrug(AbstractDrugModel drug) {
// 		this.drug = drug;
// 	}
// 
// 	@Override
// 	public double getConfidence() {
// 		return confidence;
// 	}
// 
// 	public void setConfidence(double confidence) {
// 		this.confidence = confidence;
// 	}
// 
// 	public LinkedList<String> getTags() {
// 		return tags;
// 	}
// 
// 	/*
// 	 * method to add a tag for drug result
// 	 */
// 	public void addTags(String tag) {
// 		this.tags.add(tag);
// 	}
// 
// 	public HashSet<String> getConceptIds() {
// 		return conceptIds;
// 	}
// 
// 	/*
// 	 * method to add concept Ids related to the drug result
// 	 */
// 	public void addConceptId(String conceptId) {
// 		this.conceptIds.add(conceptId);
// 	}
// 
// 	public boolean hasConcept(String conceptId) {
// 		return conceptIds.contains(conceptId);
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "PredictionResults [drug=" + drug.toString() + ", confidence=" + confidence + "]";
// 	}
// }


// Path: src/com/learningmodule/association/conceptdrug/predictionmodule/ConceptNameDatabaseOperation.java
import java.util.LinkedList;
import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface;
import com.learningmodule.association.conceptdrug.model.ConceptNameModel;
import com.learningmodule.association.conceptdrug.model.ConceptDrugPredictionResult;

package com.learningmodule.association.conceptdrug.predictionmodule;



/*
 * class that fetch the concept name from database interface and add names to tag in results
 */

public class ConceptNameDatabaseOperation {

	// method to get the list of tags for each drug result
	public static LinkedList<ConceptDrugPredictionResult> getTags(
			LinkedList<ConceptDrugPredictionResult> results,
			ConceptDrugDatabaseInterface learningDataInterface) {

		// get the list of conceptId and conceptNames from database Interface
		LinkedList<ConceptNameModel> concepts = learningDataInterface
				.getConceptIdNameByConceptIds(getIds(results));

		// loop adds the concepts names to tags in results
		for (ConceptNameModel concept : concepts) {
			for (ConceptDrugPredictionResult result : results) {
				if (result.hasConcept(concept.getConceptId())) {
					// add the concept name is concept Id is related to drug
					result.addTags(concept.getConceptName());
				}
			}
		}
		return results;
	}

	/*
	 * method to get the string that has to be put in SQL query which has all
	 * conceptId separated by comma
	 */
	private static LinkedList<String> getIds(LinkedList<ConceptDrugPredictionResult> results) {
		LinkedList<String> ids = new LinkedList<String>();