ca.uhn.hl7v2.model.v21.segment.NTE Maven / Gradle / Ivy
/*
* This class is an auto-generated source file for a HAPI
* HL7 v2.x standard structure class.
*
* For more information, visit: http://hl7api.sourceforge.net/
*/
package ca.uhn.hl7v2.model.v21.segment;
// import ca.uhn.hl7v2.model.v21.group.*;
import ca.uhn.hl7v2.model.v21.datatype.*;
import ca.uhn.log.HapiLogFactory;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.parser.ModelClassFactory;
import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
import ca.uhn.hl7v2.model.AbstractMessage;
import ca.uhn.hl7v2.model.Group;
import ca.uhn.hl7v2.model.Type;
import ca.uhn.hl7v2.model.AbstractSegment;
import ca.uhn.hl7v2.model.Varies;
/**
*Represents an HL7 NTE message segment (NOTES AND COMMENTS).
* This segment has the following fields:
*
* - NTE-1: SET ID - NOTES AND COMMENTS (SI) optional
*
- NTE-2: SOURCE OF COMMENT (ID) optional
*
- NTE-3: COMMENT (TX) repeating
*
*/
public class NTE extends AbstractSegment {
/**
* Creates a new NTE segment
*/
public NTE(Group parent, ModelClassFactory factory) {
super(parent, factory);
init(factory);
}
private void init(ModelClassFactory factory) {
try {
this.add(SI.class, false, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "SET ID - NOTES AND COMMENTS");
this.add(ID.class, false, 1, 8, new Object[]{ getMessage() }, "SOURCE OF COMMENT");
this.add(TX.class, true, 0, 120, new Object[]{ getMessage(), new Integer(0) }, "COMMENT");
} catch(HL7Exception e) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating NTE - this is probably a bug in the source code generator.", e);
}
}
/**
* Returns
* NTE-1: "SET ID - NOTES AND COMMENTS" - creates it if necessary
*/
public SI getSETIDNOTESANDCOMMENTS() {
SI ret = null;
try {
Type t = this.getField(1, 0);
ret = (SI)t;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns
* NTE-1: "SET ID - NOTES AND COMMENTS" - creates it if necessary
*/
public SI getNte1_SETIDNOTESANDCOMMENTS() {
SI ret = null;
try {
Type t = this.getField(1, 0);
ret = (SI)t;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns
* NTE-2: "SOURCE OF COMMENT" - creates it if necessary
*/
public ID getSOURCEOFCOMMENT() {
ID ret = null;
try {
Type t = this.getField(2, 0);
ret = (ID)t;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns
* NTE-2: "SOURCE OF COMMENT" - creates it if necessary
*/
public ID getNte2_SOURCEOFCOMMENT() {
ID ret = null;
try {
Type t = this.getField(2, 0);
ret = (ID)t;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns all repetitions of COMMENT (NTE-3).
*/
public TX[] getCOMMENT() {
TX[] ret = null;
try {
Type[] t = this.getField(3);
ret = new TX[t.length];
for (int i = 0; i < ret.length; i++) {
ret[i] = (TX)t[i];
}
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns a count of the current number of repetitions of COMMENT (NTE-3).
* This method does not create a repetition, so if no repetitions have currently been defined or accessed,
* it will return zero.
*/
public int getCOMMENTReps() {
TX[] ret = null;
try {
Type[] t = this.getField(3);
return t.length;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
}
/**
* Returns a specific repetition of
* NTE-3: "COMMENT" - creates it if necessary
*
* @param rep The repetition index (0-indexed)
*/
public TX getCOMMENT(int rep) {
TX ret = null;
try {
Type t = this.getField(3, rep);
ret = (TX)t;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns a specific repetition of
* NTE-3: "COMMENT" - creates it if necessary
*
* @param rep The repetition index (0-indexed)
*/
public TX getNte3_COMMENT(int rep) {
TX ret = null;
try {
Type t = this.getField(3, rep);
ret = (TX)t;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
return ret;
}
/**
* Returns a count of the current number of repetitions of COMMENT (NTE-3).
* This method does not create a repetition, so if no repetitions have currently been defined or accessed,
* it will return zero.
*/
public int getNte3_COMMENTReps() {
TX[] ret = null;
try {
Type[] t = this.getField(3);
return t.length;
} catch (ClassCastException cce) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
throw new RuntimeException(cce);
} catch (HL7Exception he) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
throw new RuntimeException(he);
}
}
/**
* Inserts a repetition of
* NTE-3: "COMMENT" at a specific index
*
* @param rep The repetition index (0-indexed)
* @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
*/
public TX insertCOMMENT(int rep) throws HL7Exception {
return (TX) super.insertRepetition(3, rep);
}
/**
* Inserts a repetition of
* NTE-3: "COMMENT" at a specific index
*
* @param rep The repetition index (0-indexed)
* @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
*/
public TX insertNte3_COMMENT(int rep) throws HL7Exception {
return (TX) super.insertRepetition(3, rep);
}
/**
* Removes a repetition of
* NTE-3: "COMMENT" at a specific index
*
* @param rep The repetition index (0-indexed)
* @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
*/
public TX removeCOMMENT(int rep) throws HL7Exception {
return (TX) super.removeRepetition(3, rep);
}
/**
* Removes a repetition of
* NTE-3: "COMMENT" at a specific index
*
* @param rep The repetition index (0-indexed)
* @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
*/
public TX removeNte3_COMMENT(int rep) throws HL7Exception {
return (TX) super.removeRepetition(3, rep);
}
/** {@inheritDoc} */
protected Type createNewTypeWithoutReflection(int field) {
switch (field) {
case 0: return new SI(getMessage());
case 1: return new ID(getMessage(), new Integer( 105 ));
case 2: return new TX(getMessage());
default: return null;
}
}
}