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.group;
009
010 import ca.uhn.hl7v2.model.v24.segment.*;
011
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.AbstractGroup;
019 import ca.uhn.hl7v2.model.GenericSegment;
020
021 /**
022 * <p>Represents a SRM_S01_PATIENT group structure (a Group object).
023 * A Group is an ordered collection of message segments that can repeat together or be optionally in/excluded together.
024 * This Group contains the following elements:
025 * </p>
026 * <ul>
027 * <li>1: PID (Patient identification) <b> </b></li>
028 * <li>2: PV1 (Patient visit) <b>optional </b></li>
029 * <li>3: PV2 (Patient visit - additional information) <b>optional </b></li>
030 * <li>4: OBX (Observation/Result) <b>optional repeating</b></li>
031 * <li>5: DG1 (Diagnosis) <b>optional repeating</b></li>
032 * </ul>
033 */
034 public class SRM_S01_PATIENT extends AbstractGroup {
035
036 /**
037 * Creates a new SRM_S01_PATIENT group
038 */
039 public SRM_S01_PATIENT(Group parent, ModelClassFactory factory) {
040 super(parent, factory);
041 init(factory);
042 }
043
044 private void init(ModelClassFactory factory) {
045 try {
046 this.add(PID.class, true, false);
047 this.add(PV1.class, false, false);
048 this.add(PV2.class, false, false);
049 this.add(OBX.class, false, true);
050 this.add(DG1.class, false, true);
051 } catch(HL7Exception e) {
052 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating SRM_S01_PATIENT - this is probably a bug in the source code generator.", e);
053 }
054 }
055
056 /**
057 * Returns "2.4"
058 */
059 public String getVersion() {
060 return "2.4";
061 }
062
063
064
065 /**
066 * Returns
067 * PID (Patient identification) - creates it if necessary
068 */
069 public PID getPID() {
070 PID ret = null;
071 try {
072 ret = (PID)this.get("PID");
073 } catch(HL7Exception e) {
074 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
075 throw new RuntimeException(e);
076 }
077 return ret;
078 }
079
080
081
082
083 /**
084 * Returns
085 * PV1 (Patient visit) - creates it if necessary
086 */
087 public PV1 getPV1() {
088 PV1 ret = null;
089 try {
090 ret = (PV1)this.get("PV1");
091 } catch(HL7Exception e) {
092 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
093 throw new RuntimeException(e);
094 }
095 return ret;
096 }
097
098
099
100
101 /**
102 * Returns
103 * PV2 (Patient visit - additional information) - creates it if necessary
104 */
105 public PV2 getPV2() {
106 PV2 ret = null;
107 try {
108 ret = (PV2)this.get("PV2");
109 } catch(HL7Exception e) {
110 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
111 throw new RuntimeException(e);
112 }
113 return ret;
114 }
115
116
117
118
119 /**
120 * Returns
121 * the first repetition of
122 * OBX (Observation/Result) - creates it if necessary
123 */
124 public OBX getOBX() {
125 OBX ret = null;
126 try {
127 ret = (OBX)this.get("OBX");
128 } catch(HL7Exception e) {
129 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
130 throw new RuntimeException(e);
131 }
132 return ret;
133 }
134
135
136 /**
137 * Returns a specific repetition of
138 * OBX (Observation/Result) - creates it if necessary
139 *
140 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
141 * @throws HL7Exception if the repetition requested is more than one
142 * greater than the number of existing repetitions.
143 */
144 public OBX getOBX(int rep) {
145 OBX ret = null;
146 try {
147 ret = (OBX)this.get("OBX", rep);
148 } catch(HL7Exception e) {
149 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
150 throw new RuntimeException(e);
151 }
152 return ret;
153 }
154
155 /**
156 * Returns the number of existing repetitions of OBX
157 */
158 public int getOBXReps() {
159 int reps = -1;
160 try {
161 reps = this.getAll("OBX").length;
162 } catch (HL7Exception e) {
163 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
164 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
165 throw new RuntimeException(message);
166 }
167 return reps;
168 }
169
170 /**
171 * Inserts a specific repetition of OBX (Observation/Result)
172 * @see AbstractGroup#insertRepetition(Structure, int)
173 */
174 public void insertOBX(OBX structure, int rep) throws HL7Exception {
175 super.insertRepetition("OBX", structure, rep);
176 }
177
178
179 /**
180 * Inserts a specific repetition of OBX (Observation/Result)
181 * @see AbstractGroup#insertRepetition(Structure, int)
182 */
183 public OBX insertOBX(int rep) throws HL7Exception {
184 return (OBX)super.insertRepetition("OBX", rep);
185 }
186
187
188 /**
189 * Removes a specific repetition of OBX (Observation/Result)
190 * @see AbstractGroup#removeRepetition(String, int)
191 */
192 public OBX removeOBX(int rep) throws HL7Exception {
193 return (OBX)super.removeRepetition("OBX", rep);
194 }
195
196
197
198 /**
199 * Returns
200 * the first repetition of
201 * DG1 (Diagnosis) - creates it if necessary
202 */
203 public DG1 getDG1() {
204 DG1 ret = null;
205 try {
206 ret = (DG1)this.get("DG1");
207 } catch(HL7Exception e) {
208 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
209 throw new RuntimeException(e);
210 }
211 return ret;
212 }
213
214
215 /**
216 * Returns a specific repetition of
217 * DG1 (Diagnosis) - creates it if necessary
218 *
219 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
220 * @throws HL7Exception if the repetition requested is more than one
221 * greater than the number of existing repetitions.
222 */
223 public DG1 getDG1(int rep) {
224 DG1 ret = null;
225 try {
226 ret = (DG1)this.get("DG1", rep);
227 } catch(HL7Exception e) {
228 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
229 throw new RuntimeException(e);
230 }
231 return ret;
232 }
233
234 /**
235 * Returns the number of existing repetitions of DG1
236 */
237 public int getDG1Reps() {
238 int reps = -1;
239 try {
240 reps = this.getAll("DG1").length;
241 } catch (HL7Exception e) {
242 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
243 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
244 throw new RuntimeException(message);
245 }
246 return reps;
247 }
248
249 /**
250 * Inserts a specific repetition of DG1 (Diagnosis)
251 * @see AbstractGroup#insertRepetition(Structure, int)
252 */
253 public void insertDG1(DG1 structure, int rep) throws HL7Exception {
254 super.insertRepetition("DG1", structure, rep);
255 }
256
257
258 /**
259 * Inserts a specific repetition of DG1 (Diagnosis)
260 * @see AbstractGroup#insertRepetition(Structure, int)
261 */
262 public DG1 insertDG1(int rep) throws HL7Exception {
263 return (DG1)super.insertRepetition("DG1", rep);
264 }
265
266
267 /**
268 * Removes a specific repetition of DG1 (Diagnosis)
269 * @see AbstractGroup#removeRepetition(String, int)
270 */
271 public DG1 removeDG1(int rep) throws HL7Exception {
272 return (DG1)super.removeRepetition("DG1", rep);
273 }
274
275
276
277 }
278