001 /*
002 * This class is an auto-generated source file for a HAPI
003 * HL7 v2.x standard structure class.
004 *
005 * For more information, visit: http://hl7api.sourceforge.net/
006 */
007
008 package ca.uhn.hl7v2.model.v24.segment;
009
010 // import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.datatype.*;
012 import ca.uhn.log.HapiLogFactory;
013 import ca.uhn.hl7v2.HL7Exception;
014 import ca.uhn.hl7v2.parser.ModelClassFactory;
015 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016 import ca.uhn.hl7v2.model.AbstractMessage;
017 import ca.uhn.hl7v2.model.Group;
018 import ca.uhn.hl7v2.model.Type;
019 import ca.uhn.hl7v2.model.AbstractSegment;
020 import ca.uhn.hl7v2.model.Varies;
021
022 /**
023 *<p>Represents an HL7 BLC message segment (Blood Code).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>BLC-1: Blood Product Code (CE) <b>optional </b>
027 * <li>BLC-2: Blood Amount (CQ) <b>optional </b>
028 * </ul>
029 */
030 public class BLC extends AbstractSegment {
031
032 /**
033 * Creates a new BLC segment
034 */
035 public BLC(Group parent, ModelClassFactory factory) {
036 super(parent, factory);
037 init(factory);
038 }
039
040 private void init(ModelClassFactory factory) {
041 try {
042 this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(426) }, "Blood Product Code");
043 this.add(CQ.class, false, 1, 83, new Object[]{ getMessage(), new Integer(0) }, "Blood Amount");
044 } catch(HL7Exception e) {
045 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating BLC - this is probably a bug in the source code generator.", e);
046 }
047 }
048
049
050
051 /**
052 * Returns
053 * BLC-1: "Blood Product Code" - creates it if necessary
054 */
055 public CE getBloodProductCode() {
056 CE ret = null;
057 try {
058 Type t = this.getField(1, 0);
059 ret = (CE)t;
060 } catch (ClassCastException cce) {
061 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
062 throw new RuntimeException(cce);
063 } catch (HL7Exception he) {
064 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
065 throw new RuntimeException(he);
066 }
067 return ret;
068 }
069
070
071 /**
072 * Returns
073 * BLC-1: "Blood Product Code" - creates it if necessary
074 */
075 public CE getBlc1_BloodProductCode() {
076 CE ret = null;
077 try {
078 Type t = this.getField(1, 0);
079 ret = (CE)t;
080 } catch (ClassCastException cce) {
081 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
082 throw new RuntimeException(cce);
083 } catch (HL7Exception he) {
084 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
085 throw new RuntimeException(he);
086 }
087 return ret;
088 }
089
090
091
092 /**
093 * Returns
094 * BLC-2: "Blood Amount" - creates it if necessary
095 */
096 public CQ getBloodAmount() {
097 CQ ret = null;
098 try {
099 Type t = this.getField(2, 0);
100 ret = (CQ)t;
101 } catch (ClassCastException cce) {
102 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
103 throw new RuntimeException(cce);
104 } catch (HL7Exception he) {
105 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
106 throw new RuntimeException(he);
107 }
108 return ret;
109 }
110
111
112 /**
113 * Returns
114 * BLC-2: "Blood Amount" - creates it if necessary
115 */
116 public CQ getBlc2_BloodAmount() {
117 CQ ret = null;
118 try {
119 Type t = this.getField(2, 0);
120 ret = (CQ)t;
121 } catch (ClassCastException cce) {
122 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
123 throw new RuntimeException(cce);
124 } catch (HL7Exception he) {
125 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
126 throw new RuntimeException(he);
127 }
128 return ret;
129 }
130
131
132
133
134
135 /** {@inheritDoc} */
136 protected Type createNewTypeWithoutReflection(int field) {
137 switch (field) {
138 case 0: return new CE(getMessage());
139 case 1: return new CQ(getMessage());
140 default: return null;
141 }
142 }
143
144
145 }
146