ca.uhn.hl7v2.model.v26.segment.AL1 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.v26.segment;
// import ca.uhn.hl7v2.model.v26.group.*;
import ca.uhn.hl7v2.model.v26.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 AL1 message segment (Patient Allergy Information).
* This segment has the following fields:
*
* - AL1-1: Set ID - AL1 (SI)
*
- AL1-2: Allergen Type Code (CWE) optional
*
- AL1-3: Allergen Code/Mnemonic/Description (CWE)
*
- AL1-4: Allergy Severity Code (CWE) optional
*
- AL1-5: Allergy Reaction Code (ST) optional repeating
*
- AL1-6: Identification Date (DT) optional
*
*/
public class AL1 extends AbstractSegment {
/**
* Creates a new AL1 segment
*/
public AL1(Group parent, ModelClassFactory factory) {
super(parent, factory);
init(factory);
}
private void init(ModelClassFactory factory) {
try {
this.add(SI.class, true, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "Set ID - AL1");
this.add(CWE.class, false, 1, 705, new Object[]{ getMessage(), new Integer(127) }, "Allergen Type Code");
this.add(CWE.class, true, 1, 705, new Object[]{ getMessage(), new Integer(0) }, "Allergen Code/Mnemonic/Description");
this.add(CWE.class, false, 1, 705, new Object[]{ getMessage(), new Integer(128) }, "Allergy Severity Code");
this.add(ST.class, false, 0, 15, new Object[]{ getMessage(), new Integer(0) }, "Allergy Reaction Code");
this.add(DT.class, false, 1, 0, new Object[]{ getMessage(), new Integer(0) }, "Identification Date");
} catch(HL7Exception e) {
HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating AL1 - this is probably a bug in the source code generator.", e);
}
}
/**
* Returns
* AL1-1: "Set ID - AL1" - creates it if necessary
*/
public SI getSetIDAL1() {
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
* AL1-1: "Set ID - AL1" - creates it if necessary
*/
public SI getAl11_SetIDAL1() {
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
* AL1-2: "Allergen Type Code" - creates it if necessary
*/
public CWE getAllergenTypeCode() {
CWE ret = null;
try {
Type t = this.getField(2, 0);
ret = (CWE)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
* AL1-2: "Allergen Type Code" - creates it if necessary
*/
public CWE getAl12_AllergenTypeCode() {
CWE ret = null;
try {
Type t = this.getField(2, 0);
ret = (CWE)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
* AL1-3: "Allergen Code/Mnemonic/Description" - creates it if necessary
*/
public CWE getAllergenCodeMnemonicDescription() {
CWE ret = null;
try {
Type t = this.getField(3, 0);
ret = (CWE)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
* AL1-3: "Allergen Code/Mnemonic/Description" - creates it if necessary
*/
public CWE getAl13_AllergenCodeMnemonicDescription() {
CWE ret = null;
try {
Type t = this.getField(3, 0);
ret = (CWE)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
* AL1-4: "Allergy Severity Code" - creates it if necessary
*/
public CWE getAllergySeverityCode() {
CWE ret = null;
try {
Type t = this.getField(4, 0);
ret = (CWE)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
* AL1-4: "Allergy Severity Code" - creates it if necessary
*/
public CWE getAl14_AllergySeverityCode() {
CWE ret = null;
try {
Type t = this.getField(4, 0);
ret = (CWE)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 Allergy Reaction Code (AL1-5).
*/
public ST[] getAllergyReactionCode() {
ST[] ret = null;
try {
Type[] t = this.getField(5);
ret = new ST[t.length];
for (int i = 0; i < ret.length; i++) {
ret[i] = (ST)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 Allergy Reaction Code (AL1-5).
* This method does not create a repetition, so if no repetitions have currently been defined or accessed,
* it will return zero.
*/
public int getAllergyReactionCodeReps() {
ST[] ret = null;
try {
Type[] t = this.getField(5);
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
* AL1-5: "Allergy Reaction Code" - creates it if necessary
*
* @param rep The repetition index (0-indexed)
*/
public ST getAllergyReactionCode(int rep) {
ST ret = null;
try {
Type t = this.getField(5, rep);
ret = (ST)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
* AL1-5: "Allergy Reaction Code" - creates it if necessary
*
* @param rep The repetition index (0-indexed)
*/
public ST getAl15_AllergyReactionCode(int rep) {
ST ret = null;
try {
Type t = this.getField(5, rep);
ret = (ST)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 Allergy Reaction Code (AL1-5).
* This method does not create a repetition, so if no repetitions have currently been defined or accessed,
* it will return zero.
*/
public int getAl15_AllergyReactionCodeReps() {
ST[] ret = null;
try {
Type[] t = this.getField(5);
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
* AL1-5: "Allergy Reaction Code" 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 ST insertAllergyReactionCode(int rep) throws HL7Exception {
return (ST) super.insertRepetition(5, rep);
}
/**
* Inserts a repetition of
* AL1-5: "Allergy Reaction Code" 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 ST insertAl15_AllergyReactionCode(int rep) throws HL7Exception {
return (ST) super.insertRepetition(5, rep);
}
/**
* Removes a repetition of
* AL1-5: "Allergy Reaction Code" 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 ST removeAllergyReactionCode(int rep) throws HL7Exception {
return (ST) super.removeRepetition(5, rep);
}
/**
* Removes a repetition of
* AL1-5: "Allergy Reaction Code" 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 ST removeAl15_AllergyReactionCode(int rep) throws HL7Exception {
return (ST) super.removeRepetition(5, rep);
}
/**
* Returns
* AL1-6: "Identification Date" - creates it if necessary
*/
public DT getIdentificationDate() {
DT ret = null;
try {
Type t = this.getField(6, 0);
ret = (DT)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
* AL1-6: "Identification Date" - creates it if necessary
*/
public DT getAl16_IdentificationDate() {
DT ret = null;
try {
Type t = this.getField(6, 0);
ret = (DT)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;
}
/** {@inheritDoc} */
protected Type createNewTypeWithoutReflection(int field) {
switch (field) {
case 0: return new SI(getMessage());
case 1: return new CWE(getMessage());
case 2: return new CWE(getMessage());
case 3: return new CWE(getMessage());
case 4: return new ST(getMessage());
case 5: return new DT(getMessage());
default: return null;
}
}
}