/*
 * This file (AnalysisRequestBornDefect.java) is part of DebGen-WebApp  developed by ASTRID Research.
 * All rights reserved. Reproduction, modification, use or disclosure
 * to third parties without express authority is forbidden.
 *
 *  Copyright ASTRID Research, Hungary, 2010.
 *
 *  ASTRID Research
 *  Headquaters: Csapó utca 42. Debrecen H-4029 HUNGARY
 *  Phone: +36-52-533-173        Fax: +36-52-533-174
 *  Web: http://www.astrid.hu    E-mail: info@astrid.hu
 *
 * Project name: DEBGEN-Biobank-Project.
 * File last modified at 2010.02.03 21:49
 */
package hu.astrid.debgen.patientmanagement.domain.modules.requests;

import hu.astrid.xmltools.beantoxml.XmlToBeanConverter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.servlet.http.HttpServletRequest;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * Class of Born Defect Analisys Requests
 * @author inagy
 */
@Entity
public class AnalysisRequestBornDefect extends AnalysisRequest {

    private static final long serialVersionUID = 1L;
    protected String bdFamilyAnamnesis;
    protected String bdPrenatalisAnamnesis;
    protected String bdPatientAnamnesis;
    protected boolean bdCitogeneticalAnalysis;
    protected boolean bdDNAPreparation;
    protected boolean bdDNAStoredSample;
    @Temporal(TemporalType.DATE)
    protected Date bdDNAStoredSampleDate;
    protected boolean bdFish;
    protected boolean bdDiGeorge;
    protected boolean bdWilliams;
    protected boolean bdPraderWilli;
    protected boolean bdSmithMagenis;
    protected boolean bdSRY;
    protected boolean bdSubtelomericFish;
    protected boolean bdTurnerMozaicizm;
    protected boolean bdTurnerRemainingY;
    protected boolean bdMulticolorFish;
    protected boolean bdFragX;
    protected boolean bdCitogenetic;
    protected boolean bdMolecular;
    protected boolean bdFGFR2OrFGFR3;
    protected boolean bdSCE;
    protected String bdComment;
    protected String bdDoctor;

    // <editor-fold defaultstate="collapsed" desc="Getters and Setters">
    /**
     * Get the value of bdDoctor
     *
     * @return the value of bdDoctor
     */
    public String getBdDoctor() {
        return bdDoctor;
    }

    /**
     * Set the value of bdDoctor
     *
     * @param bdDoctor new value of bdDoctor
     */
    public void setBdDoctor(String bdDoctor) {
        this.bdDoctor = bdDoctor;
    }

    /**
     * Get the value of bdComment
     *
     * @return the value of bdComment
     */
    public String getBdCommentForWeb() {
        try {
            return bdComment.replaceAll("\n", "<br />");
        } catch (Exception e) {
            return bdComment;
        }
    }

    /**
     * Get the value of bdComment
     *
     * @return the value of bdComment
     */
    public String getBdComment() {
        return bdComment;
    }

    /**
     * Set the value of bdComment
     *
     * @param bdComment new value of bdComment
     */
    public void setBdComment(String bdComment) {
        this.bdComment = bdComment;
    }

    /**
     * Get the value of bdSCE
     *
     * @return the value of bdSCE
     */
    public boolean isBdSCE() {
        return bdSCE;
    }

    /**
     * Set the value of bdSCE
     *
     * @param bdSCE new value of bdSCE
     */
    public void setBdSCE(boolean bdSCE) {
        this.bdSCE = bdSCE;
    }

    /**
     * Get the value of bdFGFR2OrFGFR3
     *
     * @return the value of bdFGFR2OrFGFR3
     */
    public boolean isBdFGFR2OrFGFR3() {
        return bdFGFR2OrFGFR3;
    }

    /**
     * Set the value of bdFGFR2OrFGFR3
     *
     * @param bdFGFR2OrFGFR3 new value of bdFGFR2OrFGFR3
     */
    public void setBdFGFR2OrFGFR3(boolean bdFGFR2OrFGFR3) {
        this.bdFGFR2OrFGFR3 = bdFGFR2OrFGFR3;
    }

    /**
     * Get the value of bdMolecular
     *
     * @return the value of bdMolecular
     */
    public boolean isBdMolecular() {
        return bdMolecular;
    }

    /**
     * Set the value of bdMolecular
     *
     * @param bdMolecular new value of bdMolecular
     */
    public void setBdMolecular(boolean bdMolecular) {
        this.bdMolecular = bdMolecular;
    }

    /**
     * Get the value of bdCitogenetic
     *
     * @return the value of bdCitogenetic
     */
    public boolean isBdCitogenetic() {
        return bdCitogenetic;
    }

    /**
     * Set the value of bdCitogenetic
     *
     * @param bdCitogenetic new value of bdCitogenetic
     */
    public void setBdCitogenetic(boolean bdCitogenetic) {
        this.bdCitogenetic = bdCitogenetic;
    }

    /**
     * Get the value of bdFragX
     *
     * @return the value of bdFragX
     */
    public boolean isBdFragX() {
        return bdFragX;
    }

    /**
     * Set the value of bdFragX
     *
     * @param bdFragX new value of bdFragX
     */
    public void setBdFragX(boolean bdFragX) {
        this.bdFragX = bdFragX;
    }

    /**
     * Get the value of bdMulticolorFish
     *
     * @return the value of bdMulticolorFish
     */
    public boolean isBdMulticolorFish() {
        return bdMulticolorFish;
    }

    /**
     * Set the value of bdMulticolorFish
     *
     * @param bdMulticolorFish new value of bdMulticolorFish
     */
    public void setBdMulticolorFish(boolean bdMulticolorFish) {
        this.bdMulticolorFish = bdMulticolorFish;
    }

    /**
     * Get the value of bdTurnerRemainingY
     *
     * @return the value of bdTurnerRemainingY
     */
    public boolean isBdTurnerRemainingY() {
        return bdTurnerRemainingY;
    }

    /**
     * Set the value of bdTurnerRemainingY
     *
     * @param bdTurnerRemainingY new value of bdTurnerRemainingY
     */
    public void setBdTurnerRemainingY(boolean bdTurnerRemainingY) {
        this.bdTurnerRemainingY = bdTurnerRemainingY;
    }

    /**
     * Get the value of bdTurnerMozaicizm
     *
     * @return the value of bdTurnerMozaicizm
     */
    public boolean isBdTurnerMozaicizm() {
        return bdTurnerMozaicizm;
    }

    /**
     * Set the value of bdTurnerMozaicizm
     *
     * @param bdTurnerMozaicizm new value of bdTurnerMozaicizm
     */
    public void setBdTurnerMozaicizm(boolean bdTurnerMozaicizm) {
        this.bdTurnerMozaicizm = bdTurnerMozaicizm;
    }

    /**
     * Get the value of bdSubtelomericFish
     *
     * @return the value of bdSubtelomericFish
     */
    public boolean isBdSubtelomericFish() {
        return bdSubtelomericFish;
    }

    /**
     * Set the value of bdSubtelomericFish
     *
     * @param bdSubtelomericFish new value of bdSubtelomericFish
     */
    public void setBdSubtelomericFish(boolean bdSubtelomericFish) {
        this.bdSubtelomericFish = bdSubtelomericFish;
    }

    /**
     * Get the value of bdSRY
     *
     * @return the value of bdSRY
     */
    public boolean isBdSRY() {
        return bdSRY;
    }

    /**
     * Set the value of bdSRY
     *
     * @param bdSRY new value of bdSRY
     */
    public void setBdSRY(boolean bdSRY) {
        this.bdSRY = bdSRY;
    }

    /**
     * Get the value of bdSmithMagenis
     *
     * @return the value of bdSmithMagenis
     */
    public boolean isBdSmithMagenis() {
        return bdSmithMagenis;
    }

    /**
     * Set the value of bdSmithMagenis
     *
     * @param bdSmithMagenis new value of bdSmithMagenis
     */
    public void setBdSmithMagenis(boolean bdSmithMagenis) {
        this.bdSmithMagenis = bdSmithMagenis;
    }

    /**
     * Get the value of bdPraderWilli
     *
     * @return the value of bdPraderWilli
     */
    public boolean isBdPraderWilli() {
        return bdPraderWilli;
    }

    /**
     * Set the value of bdPraderWilli
     *
     * @param bdPraderWilli new value of bdPraderWilli
     */
    public void setBdPraderWilli(boolean bdPraderWilli) {
        this.bdPraderWilli = bdPraderWilli;
    }

    /**
     * Get the value of bdWilliams
     *
     * @return the value of bdWilliams
     */
    public boolean isBdWilliams() {
        return bdWilliams;
    }

    /**
     * Set the value of bdWilliams
     *
     * @param bdWilliams new value of bdWilliams
     */
    public void setBdWilliams(boolean bdWilliams) {
        this.bdWilliams = bdWilliams;
    }

    /**
     * Get the value of bdDiGeorge
     *
     * @return the value of bdDiGeorge
     */
    public boolean isBdDiGeorge() {
        return bdDiGeorge;
    }

    /**
     * Set the value of bdDiGeorge
     *
     * @param bdDiGeorge new value of bdDiGeorge
     */
    public void setBdDiGeorge(boolean bdDiGeorge) {
        this.bdDiGeorge = bdDiGeorge;
    }

    /**
     * Get the value of bdFish
     *
     * @return the value of bdFish
     */
    public boolean isBdFish() {
        return bdFish;
    }

    /**
     * Set the value of bdFish
     *
     * @param bdFish new value of bdFish
     */
    public void setBdFish(boolean bdFish) {
        this.bdFish = bdFish;
    }

    /**
     * Get the value of bdDNAStoredSampleDate
     *
     * @return the value of bdDNAStoredSampleDate
     */
    public Date getBdDNAStoredSampleDate() {
        return bdDNAStoredSampleDate;
    }

    /**
     * Get the value of bdDNAStoredSampleDate
     *
     * @return the value of bdDNAStoredSampleDate
     */
    public String getBdDNAStoredSampleDateForWeb() {
        if (bdDNAStoredSample) {
            try {
                return new SimpleDateFormat("yyyy. MM. dd.").format(bdDNAStoredSampleDate);
            } catch (Exception e) {
                return "";
            }
        } else {
            return null;
        }
    }

    /**
     * Set the value of bdDNAStoredSampleDate
     *
     * @param bdDNAStoredSampleDate new value of bdDNAStoredSampleDate
     */
    public void setBdDNAStoredSampleDate(Date bdDNAStoredSampleDate) {
        this.bdDNAStoredSampleDate = bdDNAStoredSampleDate;
    }

    /**
     * Get the value of bdDNAStoredSample
     *
     * @return the value of bdDNAStoredSample
     */
    public boolean isBdDNAStoredSample() {
        return bdDNAStoredSample;
    }

    /**
     * Set the value of bdDNAStoredSample
     *
     * @param bdDNAStoredSample new value of bdDNAStoredSample
     */
    public void setBdDNAStoredSample(boolean bdDNAStoredSample) {
        this.bdDNAStoredSample = bdDNAStoredSample;
    }

    /**
     * Get the value of bdDNAPreparation
     *
     * @return the value of bdDNAPreparation
     */
    public boolean isBdDNAPreparation() {
        return bdDNAPreparation;
    }

    /**
     * Set the value of bdDNAPreparation
     *
     * @param bdDNAPreparation new value of bdDNAPreparation
     */
    public void setBdDNAPreparation(boolean bdDNAPreparation) {
        this.bdDNAPreparation = bdDNAPreparation;
    }

    /**
     * Get the value of bdCitogeneticalAnalysis
     *
     * @return the value of bdCitogeneticalAnalysis
     */
    public boolean isBdCitogeneticalAnalysis() {
        return bdCitogeneticalAnalysis;
    }

    /**
     * Set the value of bdCitogeneticalAnalysis
     *
     * @param bdCitogeneticalAnalysis new value of bdCitogeneticalAnalysis
     */
    public void setBdCitogeneticalAnalysis(boolean bdCitogeneticalAnalysis) {
        this.bdCitogeneticalAnalysis = bdCitogeneticalAnalysis;
    }

    /**
     * Get the value of bdPatientAnamnesis
     *
     * @return the value of bdPatientAnamnesis
     */
    public String getBdPatientAnamnesisForWeb() {
        try {
            return bdPatientAnamnesis.replaceAll("\n", "<br />");
        } catch (Exception e) {
            return bdPatientAnamnesis;
        }
    }

    /**
     * Get the value of bdPatientAnamnesis
     *
     * @return the value of bdPatientAnamnesis
     */
    public String getBdPatientAnamnesis() {
        return bdPatientAnamnesis;
    }

    /**
     * Set the value of bdPatientAnamnesis
     *
     * @param bdPatientAnamnesis new value of bdPatientAnamnesis
     */
    public void setBdPatientAnamnesis(String bdPatientAnamnesis) {
        this.bdPatientAnamnesis = bdPatientAnamnesis;
    }

    /**
     * Get the value of bdPrenatalisAnamnesis
     *
     * @return the value of bdPrenatalisAnamnesis
     */
    public String getBdPrenatalisAnamnesisForWeb() {
        try {
            return bdPrenatalisAnamnesis.replaceAll("\n", "<br />");
        } catch (Exception e) {
            return bdPrenatalisAnamnesis;
        }
    }

    /**
     * Get the value of bdPrenatalisAnamnesis
     *
     * @return the value of bdPrenatalisAnamnesis
     */
    public String getBdPrenatalisAnamnesis() {
        return bdPrenatalisAnamnesis;
    }

    /**
     * Set the value of bdPrenatalisAnamnesis
     *
     * @param bdPrenatalisAnamnesis new value of bdPrenatalisAnamnesis
     */
    public void setBdPrenatalisAnamnesis(String bdPrenatalisAnamnesis) {
        this.bdPrenatalisAnamnesis = bdPrenatalisAnamnesis;
    }

    /**
     * Get the value of bdFamilyAnamnesis
     *
     * @return the value of bdFamilyAnamnesis
     */
    public String getBdFamilyAnamnesisForWeb() {
        try {
            return bdFamilyAnamnesis.replaceAll("\n", "<br />");
        } catch (Exception e) {
            return bdFamilyAnamnesis;
        }
    }

    /**
     * Get the value of bdFamilyAnamnesis
     *
     * @return the value of bdFamilyAnamnesis
     */
    public String getBdFamilyAnamnesis() {
        return bdFamilyAnamnesis;
    }

    /**
     * Set the value of bdFamilyAnamnesis
     *
     * @param bdFamilyAnamnesis new value of bdFamilyAnamnesis
     */
    public void setBdFamilyAnamnesis(String bdFamilyAnamnesis) {
        this.bdFamilyAnamnesis = bdFamilyAnamnesis;
    }// </editor-fold>

    @Override
    public String getType() {
        return "born";
    }

    @Override
    public void buildFromXml(Node node) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void buildFromXml(Node node, String string) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Node toXml(Document doc) throws Exception {
        return toXml(doc, "");
    }

    @Override
    public Node toXml(Document doc, String nameSpace) throws Exception {
        try {
            String prefix = nameSpace == null || nameSpace.isEmpty() ? "" : nameSpace + ":";
            Element analysis = doc.createElement(prefix + "analysis");
            analysis.setAttribute("objectType", this.objectType);
            this.setXmlCommonValues(doc, analysis);
            Element bornDefect = doc.createElement("bornDefectRequest");
            analysis.appendChild(bornDefect);
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "familyAnamnesys", this.bdFamilyAnamnesis));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "prenatalisAnamnesys", this.bdPrenatalisAnamnesis));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "patientAnamnesys", this.bdPatientAnamnesis));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citogeneticalAnalysis", this.bdCitogeneticalAnalysis ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "DNAPreparation", this.bdDNAPreparation ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "DNAStoredSample", this.bdDNAStoredSample ? "true" : "false"));
            try {
                bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "DNAStoredSampleDate", new SimpleDateFormat("yyyy. MM. dd.").format(this.bdDNAStoredSampleDate)));
            } catch (Exception ex) {
                bornDefect.appendChild(doc.createElement("DNAStoredSampleDate"));
            }
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "fish", this.bdFish ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "diGeorge", this.bdDiGeorge ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "williams", this.bdWilliams ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "praderWilli", this.bdPraderWilli ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "smithMagenis", this.bdSmithMagenis ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "SRY", this.bdSRY ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "subtelomericFish", this.bdSubtelomericFish ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "turnerMozaicizm", this.bdTurnerMozaicizm ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "turnerRemainingY", this.bdTurnerRemainingY ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "multicolorFish", this.bdMulticolorFish ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "fragX", this.bdFragX ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "fragXCitogenetic", this.bdCitogenetic ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "fragXMolecular", this.bdMolecular ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "FGFR2orFGFR3", this.bdFGFR2OrFGFR3 ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "SCE", this.bdSCE ? "true" : "false"));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "comment", this.bdComment));
            bornDefect.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "doctor", this.bdDoctor));
            analysis.appendChild(patient.toXml(doc));
            Element biobankData = doc.createElement("biobankData");
            analysis.appendChild(biobankData);
            biobankData.appendChild(this.getLabels().toXml(doc));
            setXmlMetaData(doc, biobankData);
            return analysis;
        } catch (Exception ex) {
            ex.printStackTrace();
            throw ex;
        }
    }

    @Override
    public void convert(HttpServletRequest request) throws Exception {
        super.convert(request);
        bdCitogeneticalAnalysis = false;
        bdDNAPreparation = false;
        bdDNAStoredSample = false;
        bdFish = false;
        bdDiGeorge = false;
        bdWilliams = false;
        bdPraderWilli = false;
        bdSmithMagenis = false;
        bdSRY = false;
        bdSubtelomericFish = false;
        bdTurnerMozaicizm = false;
        bdTurnerRemainingY = false;
        bdMulticolorFish = false;
        bdFragX = false;
        bdCitogenetic = false;
        bdMolecular = false;
        bdFGFR2OrFGFR3 = false;
        bdSCE = false;
        requestParser.parseRequest(AnalysisRequestBornDefect.class, this);
        if (this.createdOn == null) {
            this.createdOn = new Date();
        }
    }
}
