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

// End of user code
import java.io.Serial;
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 PIVLTS.
 *
 * 
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PIVL_TS", propOrder = {
	"phase",
	"period",
	"alignment",
	"institutionSpecified"
})
@XmlRootElement(name = "PIVL_TS")
public class PIVLTS extends net.ihe.gazelle.hl7v3.datatypes.SXCMTS implements java.io.Serializable {
	
	/**
	 * 
	 */
	@Serial
    private static final long serialVersionUID = 1L;

	
	/**
	 * 
	                        A prototype of the repeating interval specifying the
	                        duration of each occurrence and anchors the periodic
	                        interval sequence at a certain point in time.
	                     .
	 */
	@XmlElement(name = "phase", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.IVLTS phase;
	/**
	 * 
	                        A time duration specifying a reciprocal measure of
	                        the frequency at which the periodic interval repeats.
	                     .
	 */
	@XmlElement(name = "period", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.PQ period;
	/**
	 * 
	                     Specifies if and how the repetitions are aligned to
	                     the cycles of the underlying calendar (e.g., to
	                     distinguish every 30 days from "the 5th of every
	                     month".) A non-aligned periodic interval recurs
	                     independently from the calendar. An aligned periodic
	                     interval is synchronized with the calendar.
	                  .
	 */
	@XmlAttribute(name = "alignment")
	public net.ihe.gazelle.hl7v3.voc.CalendarCycle alignment;
	/**
	 * 
	                     Indicates whether the exact timing is up to the party
	                     executing the schedule (e.g., to distinguish "every 8
	                     hours" from "3 times a day".)
	                  .
	 */
	@XmlAttribute(name = "institutionSpecified")
	public Boolean institutionSpecified;
	
	/**
	 * An attribute containing marshalled element node
	 */
	@XmlTransient
	private org.w3c.dom.Node _xmlNodePresentation;
	
	
	/**
	 * Return phase.
	 * @return phase : 
	                        A prototype of the repeating interval specifying the
	                        duration of each occurrence and anchors the periodic
	                        interval sequence at a certain point in time.
	 */
	public net.ihe.gazelle.hl7v3.datatypes.IVLTS getPhase() {
	    return phase;
	}
	
	/**
	 * Set a value to attribute phase.
	 * @param phase : 
	                        A prototype of the repeating interval specifying the
	                        duration of each occurrence and anchors the periodic
	                        interval sequence at a certain point in time.

	 */
	public void setPhase(net.ihe.gazelle.hl7v3.datatypes.IVLTS phase) {
	    this.phase = phase;
	}
	
	
	
	
	/**
	 * Return period.
	 * @return period : 
	                        A time duration specifying a reciprocal measure of
	                        the frequency at which the periodic interval repeats.

	 */
	public net.ihe.gazelle.hl7v3.datatypes.PQ getPeriod() {
	    return period;
	}
	
	/**
	 * Set a value to attribute period.
	 * @param period : 
	                        A time duration specifying a reciprocal measure of
	                        the frequency at which the periodic interval repeats.
	 */
	public void setPeriod(net.ihe.gazelle.hl7v3.datatypes.PQ period) {
	    this.period = period;
	}
	
	
	
	
	/**
	 * Return alignment.
	 * @return alignment : 
	                     Specifies if and how the repetitions are aligned to
	                     the cycles of the underlying calendar (e.g., to
	                     distinguish every 30 days from "the 5th of every
	                     month".) A non-aligned periodic interval recurs
	                     independently from the calendar. An aligned periodic
	                     interval is synchronized with the calendar.
	 */
	public net.ihe.gazelle.hl7v3.voc.CalendarCycle getAlignment() {
	    return alignment;
	}
	
	/**
	 * Set a value to attribute alignment.
	 * @param alignment : 
	                     Specifies if and how the repetitions are aligned to
	                     the cycles of the underlying calendar (e.g., to
	                     distinguish every 30 days from "the 5th of every
	                     month".) A non-aligned periodic interval recurs
	                     independently from the calendar. An aligned periodic
	                     interval is synchronized with the calendar.
	 */
	public void setAlignment(net.ihe.gazelle.hl7v3.voc.CalendarCycle alignment) {
	    this.alignment = alignment;
	}
	
	
	
	
	/**
	 * Return institutionSpecified.
	 * @return institutionSpecified : 
	                     Indicates whether the exact timing is up to the party
	                     executing the schedule (e.g., to distinguish "every 8
	                     hours" from "3 times a day".)
	 */
	public Boolean getInstitutionSpecified() {
	    return institutionSpecified;
	}
	
	/**
	 * Set a value to attribute institutionSpecified.
	 * @param institutionSpecified : 
	                     Indicates whether the exact timing is up to the party
	                     executing the schedule (e.g., to distinguish "every 8
	                     hours" from "3 times a day".)
	 */
	public void setInstitutionSpecified(Boolean institutionSpecified) {
	    this.institutionSpecified = institutionSpecified;
	}
	
	
	/**
	 * Return institutionSpecified.
	 * @return institutionSpecified : 
	                     Indicates whether the exact timing is up to the party
	                     executing the schedule (e.g., to distinguish "every 8
	                     hours" from "3 times a day".)
	 * Generated for the use on jsf pages
	 */
	 @Deprecated
	public Boolean isInstitutionSpecified() {
	    return institutionSpecified;
	}
	
	
	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.datatypes");
					Marshaller m = jc.createMarshaller();
					m.marshal(this, doc);
					_xmlNodePresentation = doc.getElementsByTagNameNS("urn:hl7-org:v3", "PIVL_TS").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(PIVLTS pIVLTS, String _location, ConstraintValidatorModule cvm, List<net.ihe.gazelle.validation.Notification> diagnostic){
   		if (pIVLTS != null){
   			net.ihe.gazelle.hl7v3.datatypes.SXCMTS.validateByModule(pIVLTS, _location, cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.IVLTS.validateByModule(pIVLTS.getPhase(), _location + "/phase", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.PQ.validateByModule(pIVLTS.getPeriod(), _location + "/period", cvm, diagnostic);
    	}
    }

}