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.message;
009
010 import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.segment.*;
012
013 import ca.uhn.log.HapiLogFactory;
014 import ca.uhn.hl7v2.HL7Exception;
015 import ca.uhn.hl7v2.parser.ModelClassFactory;
016 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017 import ca.uhn.hl7v2.model.AbstractMessage;
018
019 /**
020 * <p>Represents a OUL_R21 message structure (see chapter 7). This structure contains the
021 * following elements: </p>
022 * <ul>
023 * <li>1: MSH (Message Header) <b> </b></li>
024 * <li>2: NTE (Notes and Comments) <b>optional </b></li>
025 * <li>3: OUL_R21_PATIENT (a Group object) <b>optional </b></li>
026 * <li>4: OUL_R21_VISIT (a Group object) <b>optional </b></li>
027 * <li>5: OUL_R21_ORDER_OBSERVATION (a Group object) <b> repeating</b></li>
028 * <li>6: DSC (Continuation Pointer) <b>optional </b></li>
029 * </ul>
030 */
031 public class OUL_R21 extends AbstractMessage {
032
033 /**
034 * Creates a new OUL_R21 message with DefaultModelClassFactory.
035 */
036 public OUL_R21() {
037 this(new DefaultModelClassFactory());
038 }
039
040 /**
041 * Creates a new OUL_R21 message with custom ModelClassFactory.
042 */
043 public OUL_R21(ModelClassFactory factory) {
044 super(factory);
045 init(factory);
046 }
047
048 private void init(ModelClassFactory factory) {
049 try {
050 this.add(MSH.class, true, false);
051 this.add(NTE.class, false, false);
052 this.add(OUL_R21_PATIENT.class, false, false);
053 this.add(OUL_R21_VISIT.class, false, false);
054 this.add(OUL_R21_ORDER_OBSERVATION.class, true, true);
055 this.add(DSC.class, false, false);
056 } catch(HL7Exception e) {
057 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating OUL_R21 - this is probably a bug in the source code generator.", e);
058 }
059 }
060
061 /**
062 * Returns "2.4"
063 */
064 public String getVersion() {
065 return "2.4";
066 }
067
068
069
070 /**
071 * Returns
072 * MSH (Message Header) - creates it if necessary
073 */
074 public MSH getMSH() {
075 MSH ret = null;
076 try {
077 ret = (MSH)this.get("MSH");
078 } catch(HL7Exception e) {
079 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
080 throw new RuntimeException(e);
081 }
082 return ret;
083 }
084
085
086
087
088 /**
089 * Returns
090 * NTE (Notes and Comments) - creates it if necessary
091 */
092 public NTE getNTE() {
093 NTE ret = null;
094 try {
095 ret = (NTE)this.get("NTE");
096 } catch(HL7Exception e) {
097 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
098 throw new RuntimeException(e);
099 }
100 return ret;
101 }
102
103
104
105
106 /**
107 * Returns
108 * PATIENT (a Group object) - creates it if necessary
109 */
110 public OUL_R21_PATIENT getPATIENT() {
111 OUL_R21_PATIENT ret = null;
112 try {
113 ret = (OUL_R21_PATIENT)this.get("PATIENT");
114 } catch(HL7Exception e) {
115 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
116 throw new RuntimeException(e);
117 }
118 return ret;
119 }
120
121
122
123
124 /**
125 * Returns
126 * VISIT (a Group object) - creates it if necessary
127 */
128 public OUL_R21_VISIT getVISIT() {
129 OUL_R21_VISIT ret = null;
130 try {
131 ret = (OUL_R21_VISIT)this.get("VISIT");
132 } catch(HL7Exception e) {
133 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
134 throw new RuntimeException(e);
135 }
136 return ret;
137 }
138
139
140
141
142 /**
143 * Returns
144 * the first repetition of
145 * ORDER_OBSERVATION (a Group object) - creates it if necessary
146 */
147 public OUL_R21_ORDER_OBSERVATION getORDER_OBSERVATION() {
148 OUL_R21_ORDER_OBSERVATION ret = null;
149 try {
150 ret = (OUL_R21_ORDER_OBSERVATION)this.get("ORDER_OBSERVATION");
151 } catch(HL7Exception e) {
152 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
153 throw new RuntimeException(e);
154 }
155 return ret;
156 }
157
158
159 /**
160 * Returns a specific repetition of
161 * ORDER_OBSERVATION (a Group object) - creates it if necessary
162 *
163 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
164 * @throws HL7Exception if the repetition requested is more than one
165 * greater than the number of existing repetitions.
166 */
167 public OUL_R21_ORDER_OBSERVATION getORDER_OBSERVATION(int rep) {
168 OUL_R21_ORDER_OBSERVATION ret = null;
169 try {
170 ret = (OUL_R21_ORDER_OBSERVATION)this.get("ORDER_OBSERVATION", rep);
171 } catch(HL7Exception e) {
172 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
173 throw new RuntimeException(e);
174 }
175 return ret;
176 }
177
178 /**
179 * Returns the number of existing repetitions of ORDER_OBSERVATION
180 */
181 public int getORDER_OBSERVATIONReps() {
182 int reps = -1;
183 try {
184 reps = this.getAll("ORDER_OBSERVATION").length;
185 } catch (HL7Exception e) {
186 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
187 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
188 throw new RuntimeException(message);
189 }
190 return reps;
191 }
192
193 /**
194 * Inserts a specific repetition of ORDER_OBSERVATION (a Group object)
195 * @see AbstractGroup\#insertRepetition(Structure, int)
196 */
197 public void insertORDER_OBSERVATION(OUL_R21_ORDER_OBSERVATION structure, int rep) throws HL7Exception {
198 super.insertRepetition( "ORDER_OBSERVATION", structure, rep);
199 }
200
201
202 /**
203 * Inserts a specific repetition of ORDER_OBSERVATION (a Group object)
204 * @see AbstractGroup\#insertRepetition(Structure, int)
205 */
206 public OUL_R21_ORDER_OBSERVATION insertORDER_OBSERVATION(int rep) throws HL7Exception {
207 return (OUL_R21_ORDER_OBSERVATION)super.insertRepetition("ORDER_OBSERVATION", rep);
208 }
209
210
211 /**
212 * Removes a specific repetition of ORDER_OBSERVATION (a Group object)
213 * @see AbstractGroup\#removeRepetition(String, int)
214 */
215 public OUL_R21_ORDER_OBSERVATION removeORDER_OBSERVATION(int rep) throws HL7Exception {
216 return (OUL_R21_ORDER_OBSERVATION)super.removeRepetition("ORDER_OBSERVATION", rep);
217 }
218
219
220
221 /**
222 * Returns
223 * DSC (Continuation Pointer) - creates it if necessary
224 */
225 public DSC getDSC() {
226 DSC ret = null;
227 try {
228 ret = (DSC)this.get("DSC");
229 } catch(HL7Exception e) {
230 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
231 throw new RuntimeException(e);
232 }
233 return ret;
234 }
235
236
237
238
239 }
240