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

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 MCAIMT900001UV01DetectedIssueEvent.
 *
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MCAI_MT900001UV01.DetectedIssueEvent", propOrder = { "realmCode", "typeId", "templateId", "id",
		"code", "text", "value", "mitigatedBy", "triggerFor", "classCode", "moodCode", "nullFlavor" })
@XmlRootElement(name = "MCAI_MT900001UV01.DetectedIssueEvent")
public class MCAIMT900001UV01DetectedIssueEvent 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", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.datatypes.II> id;
	@XmlElement(name = "code", required = true, namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.CD code;
	@XmlElement(name = "text", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.ED text;
	@XmlElement(name = "value", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.ANY value;
	@XmlElement(name = "mitigatedBy", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf> mitigatedBy;
	@XmlElement(name = "triggerFor", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires> triggerFor;
	@XmlAttribute(name = "classCode", required = true)
	public net.ihe.gazelle.hl7v3.voc.ActClass classCode;
	@XmlAttribute(name = "moodCode", required = true)
	public net.ihe.gazelle.hl7v3.voc.ActMood moodCode;
	@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.
	 * 
	 * @param 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.
	 * 
	 * @param 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.
	 * 
	 * @param 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 List<net.ihe.gazelle.hl7v3.datatypes.II> getId() {
		if (id == null) {
			id = new ArrayList<>();
		}
		return id;
	}

	/**
	 * Set a value to attribute id.
	 * 
	 * @param id
	 *            .
	 */
	public void setId(List<net.ihe.gazelle.hl7v3.datatypes.II> id) {
		this.id = id;
	}

	/**
	 * Add a id to the id collection.
	 * 
	 * @param id_elt
	 *            Element to add.
	 */
	public void addId(net.ihe.gazelle.hl7v3.datatypes.II id_elt) {
		this.id.add(id_elt);
	}

	/**
	 * Remove a id to the id collection.
	 * 
	 * @param id_elt
	 *            Element to remove
	 */
	public void removeId(net.ihe.gazelle.hl7v3.datatypes.II id_elt) {
		this.id.remove(id_elt);
	}

	/**
	 * Return code.
	 * 
	 * @return code
	 */
	public net.ihe.gazelle.hl7v3.datatypes.CD getCode() {
		return code;
	}

	/**
	 * Set a value to attribute code.
	 * 
	 * @param code
	 *            .
	 */
	public void setCode(net.ihe.gazelle.hl7v3.datatypes.CD code) {
		this.code = code;
	}

	/**
	 * Return text.
	 * 
	 * @return text
	 */
	public net.ihe.gazelle.hl7v3.datatypes.ED getText() {
		return text;
	}

	/**
	 * Set a value to attribute text.
	 * 
	 * @param text
	 *            .
	 */
	public void setText(net.ihe.gazelle.hl7v3.datatypes.ED text) {
		this.text = text;
	}

	/**
	 * Return value.
	 * 
	 * @return value
	 */
	public net.ihe.gazelle.hl7v3.datatypes.ANY getValue() {
		return value;
	}

	/**
	 * Set a value to attribute value.
	 * 
	 * @param value
	 *            .
	 */
	public void setValue(net.ihe.gazelle.hl7v3.datatypes.ANY value) {
		this.value = value;
	}

	/**
	 * Return mitigatedBy.
	 * 
	 * @return mitigatedBy
	 */
	public List<net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf> getMitigatedBy() {
		if (mitigatedBy == null) {
			mitigatedBy = new ArrayList<>();
		}
		return mitigatedBy;
	}

	/**
	 * Set a value to attribute mitigatedBy.
	 * 
	 * @param mitigatedBy
	 *            .
	 */
	public void setMitigatedBy(List<net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf> mitigatedBy) {
		this.mitigatedBy = mitigatedBy;
	}

	/**
	 * Add a mitigatedBy to the mitigatedBy collection.
	 * 
	 * @param mitigatedBy_elt
	 *            Element to add.
	 */
	public void addMitigatedBy(net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf mitigatedBy_elt) {
		if (this.mitigatedBy == null) {
			this.mitigatedBy = new ArrayList<>();
		}
		this.mitigatedBy.add(mitigatedBy_elt);
	}

	/**
	 * Remove a mitigatedBy to the mitigatedBy collection.
	 * 
	 * @param mitigatedBy_elt
	 *            Element to remove
	 */
	public void removeMitigatedBy(net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf mitigatedBy_elt) {
		if (this.mitigatedBy != null) {
			this.mitigatedBy.remove(mitigatedBy_elt);
		}
	}

	/**
	 * Return triggerFor.
	 * 
	 * @return triggerFor
	 */
	public List<net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires> getTriggerFor() {
		if (triggerFor == null) {
			triggerFor = new ArrayList<>();
		}
		return triggerFor;
	}

	/**
	 * Set a value to attribute triggerFor.
	 * 
	 * @param triggerFor
	 *            .
	 */
	public void setTriggerFor(List<net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires> triggerFor) {
		this.triggerFor = triggerFor;
	}

	/**
	 * Add a triggerFor to the triggerFor collection.
	 * 
	 * @param triggerFor_elt
	 *            Element to add.
	 */
	public void addTriggerFor(net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires triggerFor_elt) {
		this.getTriggerFor().add(triggerFor_elt);
	}

	/**
	 * Remove a triggerFor to the triggerFor collection.
	 * 
	 * @param triggerFor_elt
	 *            Element to remove
	 */
	public void removeTriggerFor(net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires triggerFor_elt) {
		this.getTriggerFor().remove(triggerFor_elt);
	}

	/**
	 * Return classCode.
	 * 
	 * @return classCode
	 */
	public net.ihe.gazelle.hl7v3.voc.ActClass getClassCode() {
		return classCode;
	}

	/**
	 * Set a value to attribute classCode.
	 * 
	 * @param classCode
	 *            .
	 */
	public void setClassCode(net.ihe.gazelle.hl7v3.voc.ActClass classCode) {
		this.classCode = classCode;
	}

	/**
	 * Return moodCode.
	 * 
	 * @return moodCode
	 */
	public net.ihe.gazelle.hl7v3.voc.ActMood getMoodCode() {
		return moodCode;
	}

	/**
	 * Set a value to attribute moodCode.
	 * 
	 * @param moodCode
	 *            .
	 */
	public void setMoodCode(net.ihe.gazelle.hl7v3.voc.ActMood moodCode) {
		this.moodCode = moodCode;
	}

	/**
	 * Return nullFlavor.
	 * 
	 * @return nullFlavor
	 */
	public net.ihe.gazelle.hl7v3.voc.NullFlavor getNullFlavor() {
		return nullFlavor;
	}

	/**
	 * Set a value to attribute nullFlavor.
	 * 
	 * @param 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.mcaimt900001UV01");
				Marshaller m = jc.createMarshaller();
				m.marshal(this, doc);
				_xmlNodePresentation = doc.getElementsByTagNameNS("urn:hl7-org:v3",
						"MCAI_MT900001UV01.DetectedIssueEvent").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(MCAIMT900001UV01DetectedIssueEvent mCAIMT900001UV01DetectedIssueEvent,
			String _location, ConstraintValidatorModule cvm, List<net.ihe.gazelle.validation.Notification> diagnostic) {
		if (mCAIMT900001UV01DetectedIssueEvent != null) {
			cvm.validate(mCAIMT900001UV01DetectedIssueEvent, _location, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.datatypes.CS realmCode : mCAIMT900001UV01DetectedIssueEvent.getRealmCode()) {
					net.ihe.gazelle.hl7v3.datatypes.CS.validateByModule(realmCode, _location + "/realmCode[" + i + "]",
							cvm, diagnostic);
					i++;
				}
			}

			net.ihe.gazelle.hl7v3.datatypes.II.validateByModule(mCAIMT900001UV01DetectedIssueEvent.getTypeId(),
					_location + "/typeId", cvm, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.datatypes.II templateId : mCAIMT900001UV01DetectedIssueEvent.getTemplateId()) {
					net.ihe.gazelle.hl7v3.datatypes.II.validateByModule(templateId, _location + "/templateId[" + i
							+ "]", cvm, diagnostic);
					i++;
				}
			}

			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.datatypes.II id : mCAIMT900001UV01DetectedIssueEvent.getId()) {
					net.ihe.gazelle.hl7v3.datatypes.II.validateByModule(id, _location + "/id[" + i + "]", cvm,
							diagnostic);
					i++;
				}
			}

			net.ihe.gazelle.hl7v3.datatypes.CD.validateByModule(mCAIMT900001UV01DetectedIssueEvent.getCode(), _location
					+ "/code", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.ED.validateByModule(mCAIMT900001UV01DetectedIssueEvent.getText(), _location
					+ "/text", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.ANY.validateByModule(mCAIMT900001UV01DetectedIssueEvent.getValue(),
					_location + "/value", cvm, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf mitigatedBy : mCAIMT900001UV01DetectedIssueEvent
						.getMitigatedBy()) {
					net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01SourceOf.validateByModule(mitigatedBy,
							_location + "/mitigatedBy[" + i + "]", cvm, diagnostic);
					i++;
				}
			}

			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires triggerFor : mCAIMT900001UV01DetectedIssueEvent
						.getTriggerFor()) {
					net.ihe.gazelle.hl7v3.mcaimt900001UV01.MCAIMT900001UV01Requires.validateByModule(triggerFor,
							_location + "/triggerFor[" + i + "]", cvm, diagnostic);
					i++;
				}
			}

		}
	}

}