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 BLG message segment (Billing).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>BLG-1: When to Charge (CCD) <b>optional </b>
027 * <li>BLG-2: Charge Type (ID) <b>optional </b>
028 * <li>BLG-3: Account ID (CX) <b>optional </b>
029 * </ul>
030 */
031 public class BLG extends AbstractSegment {
032
033 /**
034 * Creates a new BLG segment
035 */
036 public BLG(Group parent, ModelClassFactory factory) {
037 super(parent, factory);
038 init(factory);
039 }
040
041 private void init(ModelClassFactory factory) {
042 try {
043 this.add(CCD.class, false, 1, 40, new Object[]{ getMessage(), new Integer(100) }, "When to Charge");
044 this.add(ID.class, false, 1, 50, new Object[]{ getMessage() }, "Charge Type");
045 this.add(CX.class, false, 1, 100, new Object[]{ getMessage(), new Integer(0) }, "Account ID");
046 } catch(HL7Exception e) {
047 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating BLG - this is probably a bug in the source code generator.", e);
048 }
049 }
050
051
052
053 /**
054 * Returns
055 * BLG-1: "When to Charge" - creates it if necessary
056 */
057 public CCD getWhenToCharge() {
058 CCD ret = null;
059 try {
060 Type t = this.getField(1, 0);
061 ret = (CCD)t;
062 } catch (ClassCastException cce) {
063 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
064 throw new RuntimeException(cce);
065 } catch (HL7Exception he) {
066 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
067 throw new RuntimeException(he);
068 }
069 return ret;
070 }
071
072
073 /**
074 * Returns
075 * BLG-1: "When to Charge" - creates it if necessary
076 */
077 public CCD getBlg1_WhenToCharge() {
078 CCD ret = null;
079 try {
080 Type t = this.getField(1, 0);
081 ret = (CCD)t;
082 } catch (ClassCastException cce) {
083 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
084 throw new RuntimeException(cce);
085 } catch (HL7Exception he) {
086 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
087 throw new RuntimeException(he);
088 }
089 return ret;
090 }
091
092
093
094 /**
095 * Returns
096 * BLG-2: "Charge Type" - creates it if necessary
097 */
098 public ID getChargeType() {
099 ID ret = null;
100 try {
101 Type t = this.getField(2, 0);
102 ret = (ID)t;
103 } catch (ClassCastException cce) {
104 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
105 throw new RuntimeException(cce);
106 } catch (HL7Exception he) {
107 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
108 throw new RuntimeException(he);
109 }
110 return ret;
111 }
112
113
114 /**
115 * Returns
116 * BLG-2: "Charge Type" - creates it if necessary
117 */
118 public ID getBlg2_ChargeType() {
119 ID ret = null;
120 try {
121 Type t = this.getField(2, 0);
122 ret = (ID)t;
123 } catch (ClassCastException cce) {
124 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
125 throw new RuntimeException(cce);
126 } catch (HL7Exception he) {
127 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
128 throw new RuntimeException(he);
129 }
130 return ret;
131 }
132
133
134
135 /**
136 * Returns
137 * BLG-3: "Account ID" - creates it if necessary
138 */
139 public CX getAccountID() {
140 CX ret = null;
141 try {
142 Type t = this.getField(3, 0);
143 ret = (CX)t;
144 } catch (ClassCastException cce) {
145 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
146 throw new RuntimeException(cce);
147 } catch (HL7Exception he) {
148 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
149 throw new RuntimeException(he);
150 }
151 return ret;
152 }
153
154
155 /**
156 * Returns
157 * BLG-3: "Account ID" - creates it if necessary
158 */
159 public CX getBlg3_AccountID() {
160 CX ret = null;
161 try {
162 Type t = this.getField(3, 0);
163 ret = (CX)t;
164 } catch (ClassCastException cce) {
165 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
166 throw new RuntimeException(cce);
167 } catch (HL7Exception he) {
168 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
169 throw new RuntimeException(he);
170 }
171 return ret;
172 }
173
174
175
176
177
178 /** {@inheritDoc} */
179 protected Type createNewTypeWithoutReflection(int field) {
180 switch (field) {
181 case 0: return new CCD(getMessage());
182 case 1: return new ID(getMessage(), new Integer( 122 ));
183 case 2: return new CX(getMessage());
184 default: return null;
185 }
186 }
187
188
189 }
190