/**
 * CR.java
 * <p>
 * File generated from the datatypes::CR 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 CR.
 *
 * 
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CR", propOrder = {
	"name",
	"value",
	"inverted"
})
@XmlRootElement(name = "CR")
public class CR extends net.ihe.gazelle.hl7v3.datatypes.ANY implements java.io.Serializable {
	
	/**
	 * 
	 */
	@Serial
    private static final long serialVersionUID = 1L;

	
	/**
	 * 
	                        Specifies the manner in which the concept role value
	                        contributes to the meaning of a code phrase.  For
	                        example, if SNOMED RT defines a concept "leg", a role
	                        relation "has-laterality", and another concept "left",
	                        the concept role relation allows to add the qualifier
	                        "has-laterality: left" to a primary code "leg" to
	                        construct the meaning "left leg".  In this example
	                        "has-laterality" is .
	                     .
	 */
	@XmlElement(name = "name", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.CV name;
	/**
	 * 
	                        The concept that modifies the primary code of a code
	                        phrase through the role relation.  For example, if
	                        SNOMED RT defines a concept "leg", a role relation
	                        "has-laterality", and another concept "left", the
	                        concept role relation allows adding the qualifier
	                        "has-laterality: left" to a primary code "leg" to
	                        construct the meaning "left leg".  In this example
	                        "left" is .
	                     .
	 */
	@XmlElement(name = "value", namespace = "urn:hl7-org:v3")
	public net.ihe.gazelle.hl7v3.datatypes.CD value;
	/**
	 * 
	                     Indicates if the sense of the role name is inverted.
	                     This can be used in cases where the underlying code
	                     system defines inversion but does not provide reciprocal
	                     pairs of role names. By default, inverted is false.
	                  .
	 */
	@XmlAttribute(name = "inverted")
	public Boolean inverted;
	
	/**
	 * An attribute containing marshalled element node
	 */
	@XmlTransient
	private org.w3c.dom.Node _xmlNodePresentation;
	
	
	/**
	 * Return name.
	 * @return name : 
	                        Specifies the manner in which the concept role value
	                        contributes to the meaning of a code phrase.  For
	                        example, if SNOMED RT defines a concept "leg", a role
	                        relation "has-laterality", and another concept "left",
	                        the concept role relation allows to add the qualifier
	                        "has-laterality: left" to a primary code "leg" to
	                        construct the meaning "left leg".  In this example
	                        "has-laterality" is .
	                     
	 */
	public net.ihe.gazelle.hl7v3.datatypes.CV getName() {
	    return name;
	}
	
	/**
	 * Set a value to attribute name.
	 * @param name : 
	                        Specifies the manner in which the concept role value
	                        contributes to the meaning of a code phrase.  For
	                        example, if SNOMED RT defines a concept "leg", a role
	                        relation "has-laterality", and another concept "left",
	                        the concept role relation allows to add the qualifier
	                        "has-laterality: left" to a primary code "leg" to
	                        construct the meaning "left leg".  In this example
	                        "has-laterality" is .
	                     

	 */
	public void setName(net.ihe.gazelle.hl7v3.datatypes.CV name) {
	    this.name = name;
	}
	

	/**
	 * Return value.
	 * @return value : 
	                        The concept that modifies the primary code of a code
	                        phrase through the role relation.  For example, if
	                        SNOMED RT defines a concept "leg", a role relation
	                        "has-laterality", and another concept "left", the
	                        concept role relation allows adding the qualifier
	                        "has-laterality: left" to a primary code "leg" to
	                        construct the meaning "left leg".  In this example
	                        "left" is .
	 */
	public net.ihe.gazelle.hl7v3.datatypes.CD getValue() {
	    return value;
	}
	
	/**
	 * Set a value to attribute value.
	 * @param value : 
	                        The concept that modifies the primary code of a code
	                        phrase through the role relation.  For example, if
	                        SNOMED RT defines a concept "leg", a role relation
	                        "has-laterality", and another concept "left", the
	                        concept role relation allows adding the qualifier
	                        "has-laterality: left" to a primary code "leg" to
	                        construct the meaning "left leg".  In this example
	                        "left" is .
	 */
	public void setValue(net.ihe.gazelle.hl7v3.datatypes.CD value) {
	    this.value = value;
	}
	
	
	
	
	/**
	 * Return inverted.
	 * @return inverted : 
	                     Indicates if the sense of the role name is inverted.
	                     This can be used in cases where the underlying code
	                     system defines inversion but does not provide reciprocal
	                     pairs of role names. By default, inverted is false.
	                  
	 */
	public Boolean getInverted() {
	    return inverted;
	}
	
	/**
	 * Set a value to attribute inverted.
	 * @param inverted : 
	                     Indicates if the sense of the role name is inverted.
	                     This can be used in cases where the underlying code
	                     system defines inversion but does not provide reciprocal
	                     pairs of role names. By default, inverted is false.
     */
	public void setInverted(Boolean inverted) {
	    this.inverted = inverted;
	}
	
	
	/**
	 * Return inverted.
	 * @return inverted : 
	                     Indicates if the sense of the role name is inverted.
	                     This can be used in cases where the underlying code
	                     system defines inversion but does not provide reciprocal
	                     pairs of role names. By default, inverted is false.

	 * Generated for the use on jsf pages
	 */
	 @Deprecated
	public Boolean isInverted() {
	    return inverted;
	}
	
	
	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", "CR").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(CR cR, String _location, ConstraintValidatorModule cvm, List<net.ihe.gazelle.validation.Notification> diagnostic){
   		if (cR != null){
   			net.ihe.gazelle.hl7v3.datatypes.ANY.validateByModule(cR, _location, cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.CV.validateByModule(cR.getName(), _location + "/name", cvm, diagnostic);
			net.ihe.gazelle.hl7v3.datatypes.CD.validateByModule(cR.getValue(), _location + "/value", cvm, diagnostic);
    	}
    }

}