/**
 * COCTMT080000UVSpecimen.java
 * <p>
 * File generated from the coctmt080000UV::COCTMT080000UVSpecimen uml Class
 * Generated by IHE - europe, gazelle team
 */
package net.ihe.gazelle.hl7v3.coctmt080000UV;

import java.io.Serial;
import java.util.ArrayList;
import java.util.List;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import net.ihe.gazelle.gen.common.ConstraintValidatorModule;

import org.w3c.dom.Document;
import org.w3c.dom.Node;


/**
 * Description of the class COCTMT080000UVSpecimen.
 *
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "COCT_MT080000UV.Specimen", propOrder = {
	"realmCode",
	"typeId",
	"templateId",
	"id",
	"code",
	"specimenNatural",
	"specimenManufactured",
	"specimenNonPersonLivingSubject",
	"specimenPerson",
	"sourceNatural",
	"sourceManufactured",
	"sourceNonPersonLivingSubject",
	"sourcePerson",
	"subjectOf1",
	"subjectOf2",
	"productOf",
	"classCode",
	"nullFlavor"
})
@XmlRootElement(name = "COCT_MT080000UV.Specimen")
public class COCTMT080000UVSpecimen implements java.io.Serializable {
	
	/**
	 * 
	 */
	@Serial
    private static final long serialVersionUID = 1L;

	
	@XmlElement(name = "realmCode", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.datatypes.CS> realmCode;
	@XmlElement(name = "typeId", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.II typeId;
	@XmlElement(name = "templateId", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.datatypes.II> templateId;
	@XmlElement(name = "id", required = true, namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.II id;
	@XmlElement(name = "code", required = true, namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.CE code;
	@XmlElement(name = "specimenNatural", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural specimenNatural;
	@XmlElement(name = "specimenManufactured", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured specimenManufactured;
	@XmlElement(name = "specimenNonPersonLivingSubject", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject specimenNonPersonLivingSubject;
	@XmlElement(name = "specimenPerson", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson specimenPerson;
	@XmlElement(name = "sourceNatural", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural sourceNatural;
	@XmlElement(name = "sourceManufactured", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured sourceManufactured;
	@XmlElement(name = "sourceNonPersonLivingSubject", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject sourceNonPersonLivingSubject;
	@XmlElement(name = "sourcePerson", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson sourcePerson;
	@XmlElement(name = "subjectOf1", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4> subjectOf1;
	@XmlElement(name = "subjectOf2", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3> subjectOf2;
	@XmlElement(name = "productOf", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVProduct productOf;
	@XmlAttribute(name = "classCode", required = true)
	public net.ihe.gazelle.hl7v3.voc.RoleClassSpecimen classCode;
	@XmlAttribute(name = "nullFlavor")
	public net.ihe.gazelle.hl7v3.voc.NullFlavor nullFlavor;
	
	/**
	 * An attribute containing marshalled element node
	 */
	@XmlTransient
	private org.w3c.dom.Node _xmlNodePresentation;
	
	
	/**
	 * Return realmCode.
	 * @return realmCode
	 */
	public List<net.ihe.gazelle.hl7v3.datatypes.CS> getRealmCode() {
		if (realmCode == null) {
	        realmCode = new ArrayList<>();
	    }
	    return realmCode;
	}
	
	/**
	 * Set a value to attribute realmCode.
     */
	public void setRealmCode(List<net.ihe.gazelle.hl7v3.datatypes.CS> realmCode) {
	    this.realmCode = realmCode;
	}
	
	
	
	/**
	 * Add a realmCode to the realmCode collection.
	 * @param realmCode_elt Element to add.
	 */
	public void addRealmCode(net.ihe.gazelle.hl7v3.datatypes.CS realmCode_elt) {
	    this.realmCode.add(realmCode_elt);
	}
	
	/**
	 * Remove a realmCode to the realmCode collection.
	 * @param realmCode_elt Element to remove
	 */
	public void removeRealmCode(net.ihe.gazelle.hl7v3.datatypes.CS realmCode_elt) {
	    this.realmCode.remove(realmCode_elt);
	}
	
	/**
	 * Return typeId.
	 * @return typeId
	 */
	public net.ihe.gazelle.hl7v3.datatypes.II getTypeId() {
	    return typeId;
	}
	
	/**
	 * Set a value to attribute typeId.
     */
	public void setTypeId(net.ihe.gazelle.hl7v3.datatypes.II typeId) {
	    this.typeId = typeId;
	}
	
	
	
	
	/**
	 * Return templateId.
	 * @return templateId
	 */
	public List<net.ihe.gazelle.hl7v3.datatypes.II> getTemplateId() {
		if (templateId == null) {
	        templateId = new ArrayList<>();
	    }
	    return templateId;
	}
	
	/**
	 * Set a value to attribute templateId.
     */
	public void setTemplateId(List<net.ihe.gazelle.hl7v3.datatypes.II> templateId) {
	    this.templateId = templateId;
	}
	
	
	
	/**
	 * Add a templateId to the templateId collection.
	 * @param templateId_elt Element to add.
	 */
	public void addTemplateId(net.ihe.gazelle.hl7v3.datatypes.II templateId_elt) {
	    this.templateId.add(templateId_elt);
	}
	
	/**
	 * Remove a templateId to the templateId collection.
	 * @param templateId_elt Element to remove
	 */
	public void removeTemplateId(net.ihe.gazelle.hl7v3.datatypes.II templateId_elt) {
	    this.templateId.remove(templateId_elt);
	}
	
	/**
	 * Return id.
	 * @return id
	 */
	public net.ihe.gazelle.hl7v3.datatypes.II getId() {
	    return id;
	}
	
	/**
	 * Set a value to attribute id.
     */
	public void setId(net.ihe.gazelle.hl7v3.datatypes.II id) {
	    this.id = id;
	}
	
	
	
	
	/**
	 * Return code.
	 * @return code
	 */
	public net.ihe.gazelle.hl7v3.datatypes.CE getCode() {
	    return code;
	}
	
	/**
	 * Set a value to attribute code.
     */
	public void setCode(net.ihe.gazelle.hl7v3.datatypes.CE code) {
	    this.code = code;
	}
	
	
	
	
	/**
	 * Return specimenNatural.
	 * @return specimenNatural
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural getSpecimenNatural() {
	    return specimenNatural;
	}
	
	/**
	 * Set a value to attribute specimenNatural.
     */
	public void setSpecimenNatural(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural specimenNatural) {
	    this.specimenNatural = specimenNatural;
	}
	
	
	
	
	/**
	 * Return specimenManufactured.
	 * @return specimenManufactured
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured getSpecimenManufactured() {
	    return specimenManufactured;
	}
	
	/**
	 * Set a value to attribute specimenManufactured.
     */
	public void setSpecimenManufactured(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured specimenManufactured) {
	    this.specimenManufactured = specimenManufactured;
	}
	
	
	
	
	/**
	 * Return specimenNonPersonLivingSubject.
	 * @return specimenNonPersonLivingSubject
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject getSpecimenNonPersonLivingSubject() {
	    return specimenNonPersonLivingSubject;
	}
	
	/**
	 * Set a value to attribute specimenNonPersonLivingSubject.
     */
	public void setSpecimenNonPersonLivingSubject(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject specimenNonPersonLivingSubject) {
	    this.specimenNonPersonLivingSubject = specimenNonPersonLivingSubject;
	}
	
	
	
	
	/**
	 * Return specimenPerson.
	 * @return specimenPerson
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson getSpecimenPerson() {
	    return specimenPerson;
	}
	
	/**
	 * Set a value to attribute specimenPerson.
     */
	public void setSpecimenPerson(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson specimenPerson) {
	    this.specimenPerson = specimenPerson;
	}
	
	
	
	
	/**
	 * Return sourceNatural.
	 * @return sourceNatural
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural getSourceNatural() {
	    return sourceNatural;
	}
	
	/**
	 * Set a value to attribute sourceNatural.
     */
	public void setSourceNatural(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural sourceNatural) {
	    this.sourceNatural = sourceNatural;
	}
	
	
	
	
	/**
	 * Return sourceManufactured.
	 * @return sourceManufactured
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured getSourceManufactured() {
	    return sourceManufactured;
	}
	
	/**
	 * Set a value to attribute sourceManufactured.
     */
	public void setSourceManufactured(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured sourceManufactured) {
	    this.sourceManufactured = sourceManufactured;
	}
	
	
	
	
	/**
	 * Return sourceNonPersonLivingSubject.
	 * @return sourceNonPersonLivingSubject
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject getSourceNonPersonLivingSubject() {
	    return sourceNonPersonLivingSubject;
	}
	
	/**
	 * Set a value to attribute sourceNonPersonLivingSubject.
     */
	public void setSourceNonPersonLivingSubject(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject sourceNonPersonLivingSubject) {
	    this.sourceNonPersonLivingSubject = sourceNonPersonLivingSubject;
	}
	
	
	
	
	/**
	 * Return sourcePerson.
	 * @return sourcePerson
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson getSourcePerson() {
	    return sourcePerson;
	}
	
	/**
	 * Set a value to attribute sourcePerson.
     */
	public void setSourcePerson(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson sourcePerson) {
	    this.sourcePerson = sourcePerson;
	}
	
	
	
	
	/**
	 * Return subjectOf1.
	 * @return subjectOf1
	 */
	public List<net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4> getSubjectOf1() {
		if (subjectOf1 == null) {
	        subjectOf1 = new ArrayList<>();
	    }
	    return subjectOf1;
	}
	
	/**
	 * Set a value to attribute subjectOf1.
     */
	public void setSubjectOf1(List<net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4> subjectOf1) {
	    this.subjectOf1 = subjectOf1;
	}
	
	
	
	/**
	 * Add a subjectOf1 to the subjectOf1 collection.
	 * @param subjectOf1_elt Element to add.
	 */
	public void addSubjectOf1(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4 subjectOf1_elt) {
	    this.subjectOf1.add(subjectOf1_elt);
	}
	
	/**
	 * Remove a subjectOf1 to the subjectOf1 collection.
	 * @param subjectOf1_elt Element to remove
	 */
	public void removeSubjectOf1(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4 subjectOf1_elt) {
	    this.subjectOf1.remove(subjectOf1_elt);
	}
	
	/**
	 * Return subjectOf2.
	 * @return subjectOf2
	 */
	public List<net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3> getSubjectOf2() {
		if (subjectOf2 == null) {
	        subjectOf2 = new ArrayList<>();
	    }
	    return subjectOf2;
	}
	
	/**
	 * Set a value to attribute subjectOf2.
     */
	public void setSubjectOf2(List<net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3> subjectOf2) {
	    this.subjectOf2 = subjectOf2;
	}
	
	
	
	/**
	 * Add a subjectOf2 to the subjectOf2 collection.
	 * @param subjectOf2_elt Element to add.
	 */
	public void addSubjectOf2(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3 subjectOf2_elt) {
	    this.subjectOf2.add(subjectOf2_elt);
	}
	
	/**
	 * Remove a subjectOf2 to the subjectOf2 collection.
	 * @param subjectOf2_elt Element to remove
	 */
	public void removeSubjectOf2(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3 subjectOf2_elt) {
	    this.subjectOf2.remove(subjectOf2_elt);
	}
	
	/**
	 * Return productOf.
	 * @return productOf
	 */
	public net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVProduct getProductOf() {
	    return productOf;
	}
	
	/**
	 * Set a value to attribute productOf.
     */
	public void setProductOf(net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVProduct productOf) {
	    this.productOf = productOf;
	}
	
	
	
	
	/**
	 * Return classCode.
	 * @return classCode
	 */
	public net.ihe.gazelle.hl7v3.voc.RoleClassSpecimen getClassCode() {
	    return classCode;
	}
	
	/**
	 * Set a value to attribute classCode.
     */
	public void setClassCode(net.ihe.gazelle.hl7v3.voc.RoleClassSpecimen classCode) {
	    this.classCode = classCode;
	}
	
	
	
	
	/**
	 * Return nullFlavor.
	 * @return nullFlavor
	 */
	public net.ihe.gazelle.hl7v3.voc.NullFlavor getNullFlavor() {
	    return nullFlavor;
	}
	
	/**
	 * Set a value to attribute nullFlavor.
     */
	public void setNullFlavor(net.ihe.gazelle.hl7v3.voc.NullFlavor nullFlavor) {
	    this.nullFlavor = nullFlavor;
	}
	
	
	
	
	
	public Node get_xmlNodePresentation() {
		if (_xmlNodePresentation == null){
				JAXBContext jc;
				DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
				dbf.setNamespaceAware(true);
				DocumentBuilder db = null;
				Document doc = null;
				try {
					db = dbf.newDocumentBuilder();
					doc = db.newDocument();
				} catch (ParserConfigurationException ignored) {}
				try {
					jc = JAXBContext.newInstance("net.ihe.gazelle.hl7v3.coctmt080000UV");
					Marshaller m = jc.createMarshaller();
					m.marshal(this, doc);
					_xmlNodePresentation = doc.getElementsByTagNameNS("urn:hl7-org:v3", "COCT_MT080000UV.Specimen").item(0);
				} catch (JAXBException e) {
					try{
						db = dbf.newDocumentBuilder();
						_xmlNodePresentation = db.newDocument();
					}
					catch(Exception ignored){}
				}
			}
			return _xmlNodePresentation;
	}
	
	public void set_xmlNodePresentation(Node _xmlNodePresentation) {
		this._xmlNodePresentation = _xmlNodePresentation;
	}
	
	
	

	
	/**
     * validate by a module of validation
     * 
     */
   public static void validateByModule(COCTMT080000UVSpecimen cOCTMT080000UVSpecimen, String _location, ConstraintValidatorModule cvm, List<net.ihe.gazelle.validation.Notification> diagnostic){
   		if (cOCTMT080000UVSpecimen != null){
   			cvm.validate(cOCTMT080000UVSpecimen, _location, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.datatypes.CS realmCode: cOCTMT080000UVSpecimen.getRealmCode()){
					net.ihe.gazelle.hl7v3.datatypes.CS.validateByModule(realmCode, _location + "/realmCode[" + i + "]", cvm, diagnostic);
					i++;
				}
			}
			
			net.ihe.gazelle.hl7v3.datatypes.II.validateByModule(cOCTMT080000UVSpecimen.getTypeId(), _location + "/typeId", cvm, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.datatypes.II templateId: cOCTMT080000UVSpecimen.getTemplateId()){
					net.ihe.gazelle.hl7v3.datatypes.II.validateByModule(templateId, _location + "/templateId[" + i + "]", cvm, diagnostic);
					i++;
				}
			}
			
			net.ihe.gazelle.hl7v3.datatypes.II.validateByModule(cOCTMT080000UVSpecimen.getId(), _location + "/id", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.CE.validateByModule(cOCTMT080000UVSpecimen.getCode(), _location + "/code", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural.validateByModule(cOCTMT080000UVSpecimen.getSpecimenNatural(), _location + "/specimenNatural", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured.validateByModule(cOCTMT080000UVSpecimen.getSpecimenManufactured(), _location + "/specimenManufactured", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject.validateByModule(cOCTMT080000UVSpecimen.getSpecimenNonPersonLivingSubject(), _location + "/specimenNonPersonLivingSubject", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson.validateByModule(cOCTMT080000UVSpecimen.getSpecimenPerson(), _location + "/specimenPerson", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNatural.validateByModule(cOCTMT080000UVSpecimen.getSourceNatural(), _location + "/sourceNatural", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVManufactured.validateByModule(cOCTMT080000UVSpecimen.getSourceManufactured(), _location + "/sourceManufactured", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVNonPersonLivingSubject.validateByModule(cOCTMT080000UVSpecimen.getSourceNonPersonLivingSubject(), _location + "/sourceNonPersonLivingSubject", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVPerson.validateByModule(cOCTMT080000UVSpecimen.getSourcePerson(), _location + "/sourcePerson", cvm, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4 subjectOf1: cOCTMT080000UVSpecimen.getSubjectOf1()){
					net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject4.validateByModule(subjectOf1, _location + "/subjectOf1[" + i + "]", cvm, diagnostic);
					i++;
				}
			}
			
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3 subjectOf2: cOCTMT080000UVSpecimen.getSubjectOf2()){
					net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVSubject3.validateByModule(subjectOf2, _location + "/subjectOf2[" + i + "]", cvm, diagnostic);
					i++;
				}
			}
			
			net.ihe.gazelle.hl7v3.coctmt080000UV.COCTMT080000UVProduct.validateByModule(cOCTMT080000UVSpecimen.getProductOf(), _location + "/productOf", cvm, diagnostic);
    	}
    }

}