package org.ohdsi.webapi.cohortanalysis;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.ohdsi.webapi.cohortresults.PeriodType;
import org.ohdsi.webapi.source.Source;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

import static org.ohdsi.webapi.util.SecurityUtils.whitelist;

public class CohortAnalysisTask {

	private static final Logger log = LoggerFactory.getLogger(CohortAnalysisTasklet.class);

	private String jobName;

	private Source source;

	private String sourceKey;

	private int smallCellCount;

	private boolean runHeraclesHeel;

	private boolean cohortPeriodOnly;
	
	private String cdmVersion = "5";  // Default to CDM V5
	
	private List<String> visualizations;

	private List<String> cohortDefinitionIds;

	private List<String> analysisIds;

	private List<String> conditionConceptIds;

	private List<String> drugConceptIds;

	private List<String> procedureConceptIds;

	private List<String> observationConceptIds;

	private List<String> measurementConceptIds;
	
	private List<PeriodType> periods;

	private boolean rollupUtilizationVisit;

	private boolean rollupUtilizationDrug;

	public String getSourceKey() {
		return sourceKey;
	}

	public void setSourceKey(String sourceKey) {
		this.sourceKey = sourceKey;
	}

	public Source getSource() {
		return source;
	}

	public void setSource(Source source) {
		this.source = source;
	}

	/**
	 * @return the smallCellCount
	 */
	public int getSmallCellCount() {
		return smallCellCount;
	}

	/**
	 * @return the jobName
	 */
	public String getJobName() {
		return jobName;
	}

	/**
	 * @param jobName the jobName to set
	 */
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	/**
	 * @param smallCellCount the smallCellCount to set
	 */
	public void setSmallCellCount(int smallCellCount) {
		this.smallCellCount = smallCellCount;
	}

	/**
	 * @return the runHeraclesHeel
	 */
	public boolean runHeraclesHeel() {
		return runHeraclesHeel;
	}

	/**
	 * @param runHeraclesHeel the runHeraclesHeel to set
	 */
	public void setRunHeraclesHeel(boolean runHeraclesHeel) {
		this.runHeraclesHeel = runHeraclesHeel;
	}

	/**
	 * @return the cohortDefinitionId
	 */
	public List<String> getCohortDefinitionIds() {
		return cohortDefinitionIds;
	}

	/**
	 * @param cohortDefinitionIds the cohortDefinitionIds to set
	 */
	public void setCohortDefinitionIds(List<String> cohortDefinitionIds) {
		this.cohortDefinitionIds = cohortDefinitionIds;
	}

	/**
	 * @return the analysisId
	 */
	public List<String> getAnalysisIds() {
		return analysisIds;
	}

	/**
	 * @param analysisIds the analysisIds to set
	 */
	public void setAnalysisIds(List<String> analysisIds) {
		this.analysisIds = analysisIds;
	}

	/**
	 * @return the conditionConceptIds
	 */
	public List<String> getConditionConceptIds() {
		return conditionConceptIds;
	}

	/**
	 * @param conditionConceptIds the conditionConceptIds to set
	 */
	public void setConditionConceptIds(List<String> conditionConceptIds) {
		this.conditionConceptIds = conditionConceptIds;
	}

	/**
	 * @return the drugConceptIds
	 */
	public List<String> getDrugConceptIds() {
		return drugConceptIds;
	}

	/**
	 * @param drugConceptIds the drugConceptIds to set
	 */
	public void setDrugConceptIds(List<String> drugConceptIds) {
		this.drugConceptIds = drugConceptIds;
	}

	/**
	 * @return the procedureConceptIds
	 */
	public List<String> getProcedureConceptIds() {
		return procedureConceptIds;
	}

	/**
	 * @param procedureConceptIds the procedureConceptIds to set
	 */
	public void setProcedureConceptIds(List<String> procedureConceptIds) {
		this.procedureConceptIds = procedureConceptIds;
	}

	/**
	 * @return the observationConceptIds
	 */
	public List<String> getObservationConceptIds() {
		return observationConceptIds;
	}

	/**
	 * @param observationConceptIds the observationConceptIds to set
	 */
	public void setObservationConceptIds(List<String> observationConceptIds) {
		this.observationConceptIds = observationConceptIds;
	}

	/**
	 * @return the measurementConceptIds
	 */
	public List<String> getMeasurementConceptIds() {
		return measurementConceptIds;
	}

	/**
	 * @param measurementConceptIds the measurementConceptIds to set
	 */
	public void setMeasurementConceptIds(List<String> measurementConceptIds) {
		this.measurementConceptIds = measurementConceptIds;
	}

	/**
	 * @return the runHeraclesHeel
	 */
	public boolean isRunHeraclesHeel() {
		return runHeraclesHeel;
	}


	/**
	 * @return the cohortPeriodOnly
	 */
	public boolean isCohortPeriodOnly() {
		return cohortPeriodOnly;
	}

	/**
	 * @param cohortPeriodOnly the cohortPeriodOnly to set
	 */
	public void setCohortPeriodOnly(boolean cohortPeriodOnly) {
		this.cohortPeriodOnly = cohortPeriodOnly;
	}

	/**
	 * @return the cdmVersion
	 */	
	public String getCdmVersion() {
		return cdmVersion;
	}

	/**
	 * @param cdmVersion the cdmVersion to set
	 */	
	public void setCdmVersion(String cdmVersion) {
		this.cdmVersion = cdmVersion;
	}

	

	/**
	 * @return the visualizations
	 */
	public List<String> getVisualizations() {
		return visualizations;
	}

	/**
	 * @param visualizations the visualizations to set
	 */
	public void setVisualizations(List<String> visualizations) {
		this.visualizations = visualizations;
	}

	/**
	 * @return the periods
	 */
	public List<PeriodType> getPeriods() {

		return periods;
	}

	/**
	 * @param periods the periods to set
	 */
	public void setPeriods(final List<PeriodType> periods) {

		this.periods = periods;
	}

	public boolean getRollupUtilizationVisit() {

		return rollupUtilizationVisit;
	}

	public void setRollupUtilizationVisit(boolean rollupUtilizationVisit) {

		this.rollupUtilizationVisit = rollupUtilizationVisit;
	}

	public boolean getRollupUtilizationDrug() {

		return rollupUtilizationDrug;
	}

	public void setRollupUtilizationDrug(boolean rollupUtilizationDrug) {

		this.rollupUtilizationDrug = rollupUtilizationDrug;
	}

	@Override
	public String toString() {
			return String.format("jobName = %s, source = %s, smallCellCount = %d, runHeraclesHeel = %s, " +
					"cohortPeriodOnly = %s, cdmVersion = %s, visualizations = %s, cohortDefinitionIds = %s, " +
					"analysisIds = %s, conditionConceptIds = %s, drugConceptIds = %s, procedureConceptIds = %s, " +
					"observationConceptIds = %s, measurementConceptIds = %s, periods = %s",
					jobName, source, smallCellCount, runHeraclesHeel, cohortPeriodOnly, cdmVersion,
					visualizations, cohortDefinitionIds, analysisIds, conditionConceptIds, drugConceptIds,
					procedureConceptIds, observationConceptIds, measurementConceptIds, periods);

	}
}
