/**
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations under
* the License.
*
* The Original Code is OpenELIS code.
*
* Copyright (C) The Minnesota Department of Health.  All Rights Reserved.
*/
package us.mn.state.health.lims.result.valueholder;

import us.mn.state.health.lims.analysis.valueholder.Analysis;
import us.mn.state.health.lims.analyte.valueholder.Analyte;
import us.mn.state.health.lims.common.valueholder.EnumValueItemImpl;
import us.mn.state.health.lims.testresult.valueholder.TestResult;
import us.mn.state.health.lims.common.valueholder.ValueHolder;
import us.mn.state.health.lims.common.valueholder.ValueHolderInterface;

public class Result extends EnumValueItemImpl {


	private static final long serialVersionUID = 1L;

	private String id;
	private ValueHolderInterface analysis;
	private String analysisId;
	private ValueHolderInterface analyte;
	private String analyteId;
	private ValueHolderInterface testResult;
	private String testResultId;
	private String sortOrder;
	private String isReportable;
	private String resultType;
	private String value;
	private Double minNormal;
	private Double maxNormal;
    private int significantDigits;
	private ValueHolder parentResult;
    private int grouping;

	public Result() {
		super();
		analysis = new ValueHolder();
		analyte = new ValueHolder();
		testResult = new ValueHolder();
		parentResult = new ValueHolder();
	}

	// ANALYSIS
	public Analysis getAnalysis() {
		return (Analysis) this.analysis.getValue();
	}

	public void setAnalysis(ValueHolderInterface analysis) {
		this.analysis = analysis;
	}

	public void setAnalysis(Analysis analysis) {
		this.analysis.setValue(analysis);
	}

	protected ValueHolderInterface getAnalysisHolder() {
		return this.analysis;
	}

	protected void setAnalysisHolder(ValueHolderInterface analysis) {
		this.analysis = analysis;
	}

	// ANALYTE
	public Analyte getAnalyte() {
		return (Analyte) this.analyte.getValue();
	}

	public void setAnalyte(ValueHolderInterface analyte) {
		this.analyte = analyte;
	}

	public void setAnalyte(Analyte analyte) {
		this.analyte.setValue(analyte);
	}

	protected ValueHolderInterface getAnalyteHolder() {
		return this.analyte;
	}

	protected void setAnalyteHolder(ValueHolderInterface analyte) {
		this.analyte = analyte;
	}

	public String getIsReportable() {
		return isReportable;
	}

	public void setIsReportable(String isReportable) {
		this.isReportable = isReportable;
	}

	public String getResultType() {
		return resultType;
	}

	public void setResultType(String resultType) {
		this.resultType = resultType;
	}

	public String getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(String sortOrder) {
		this.sortOrder = sortOrder;
	}

	// TEST_RESULT
	public TestResult getTestResult() {
		return (TestResult) this.testResult.getValue();
	}

	public void setTestResult(ValueHolderInterface testResult) {
		this.testResult = testResult;
	}

	public void setTestResult(TestResult testResult) {
		this.testResult.setValue(testResult);
	}

	protected ValueHolderInterface getTestResultHolder() {
		return this.testResult;
	}

	protected void setTestResultHolder(ValueHolderInterface testResult) {
		this.testResult = testResult;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return this.id;
	}

	public String getAnalysisId() {
		return analysisId;
	}

	public void setAnalysisId(String analysisId) {
		this.analysisId = analysisId;
	}

	public String getAnalyteId() {
		if( analyteId == null){
			if( getAnalyte() != null){
				analyteId = getAnalyte().getId();
			}
		}
		return analyteId;
	}

	public void setAnalyteId(String analyteId) {
		this.analyteId = analyteId;
	}

	public String getTestResultId() {
		if( testResultId == null){
			if( getTestResult() != null){
				testResultId = getTestResult().getId();
			}
		}
		return testResultId;
	}

	public void setTestResultId(String testResultId) {
		this.testResultId = testResultId;
	}

	public Double getMinNormal() {
		return minNormal;
	}

	public void setMinNormal(Double minNormal) {
		this.minNormal = minNormal;
	}

	public Double getMaxNormal() {
		return maxNormal;
	}

	public void setMaxNormal(Double maxNormal) {
		this.maxNormal = maxNormal;
	}

    public int getSignificantDigits(){
        return significantDigits;
    }

    public void setSignificantDigits( int significantDigits ){
        this.significantDigits = significantDigits;
    }

    public Result getParentResult() {
		return (Result)parentResult.getValue();
	}

	public void setParentResult(Result parentResult) {
		this.parentResult.setValue( parentResult );
	}

    public int getGrouping(){
        return grouping;
    }

    public void setGrouping( int grouping ){
        this.grouping = grouping;
    }
}
