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 ADT_A61 message structure (see chapter 3). This structure contains the
021 * following elements: </p>
022 * <ul>
023 * <li>1: MSH (Message Header) <b> </b></li>
024 * <li>2: EVN (Event Type) <b> </b></li>
025 * <li>3: PID (Patient identification) <b> </b></li>
026 * <li>4: PD1 (patient additional demographic) <b>optional </b></li>
027 * <li>5: PV1 (Patient visit) <b> </b></li>
028 * <li>6: ROL (Role) <b>optional repeating</b></li>
029 * <li>7: PV2 (Patient visit - additional information) <b>optional </b></li>
030 * </ul>
031 */
032 public class ADT_A61 extends AbstractMessage {
033
034 /**
035 * Creates a new ADT_A61 message with DefaultModelClassFactory.
036 */
037 public ADT_A61() {
038 this(new DefaultModelClassFactory());
039 }
040
041 /**
042 * Creates a new ADT_A61 message with custom ModelClassFactory.
043 */
044 public ADT_A61(ModelClassFactory factory) {
045 super(factory);
046 init(factory);
047 }
048
049 private void init(ModelClassFactory factory) {
050 try {
051 this.add(MSH.class, true, false);
052 this.add(EVN.class, true, false);
053 this.add(PID.class, true, false);
054 this.add(PD1.class, false, false);
055 this.add(PV1.class, true, false);
056 this.add(ROL.class, false, true);
057 this.add(PV2.class, false, false);
058 } catch(HL7Exception e) {
059 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A61 - this is probably a bug in the source code generator.", e);
060 }
061 }
062
063 /**
064 * Returns "2.4"
065 */
066 public String getVersion() {
067 return "2.4";
068 }
069
070
071
072 /**
073 * Returns
074 * MSH (Message Header) - creates it if necessary
075 */
076 public MSH getMSH() {
077 MSH ret = null;
078 try {
079 ret = (MSH)this.get("MSH");
080 } catch(HL7Exception e) {
081 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
082 throw new RuntimeException(e);
083 }
084 return ret;
085 }
086
087
088
089
090 /**
091 * Returns
092 * EVN (Event Type) - creates it if necessary
093 */
094 public EVN getEVN() {
095 EVN ret = null;
096 try {
097 ret = (EVN)this.get("EVN");
098 } catch(HL7Exception e) {
099 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
100 throw new RuntimeException(e);
101 }
102 return ret;
103 }
104
105
106
107
108 /**
109 * Returns
110 * PID (Patient identification) - creates it if necessary
111 */
112 public PID getPID() {
113 PID ret = null;
114 try {
115 ret = (PID)this.get("PID");
116 } catch(HL7Exception e) {
117 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
118 throw new RuntimeException(e);
119 }
120 return ret;
121 }
122
123
124
125
126 /**
127 * Returns
128 * PD1 (patient additional demographic) - creates it if necessary
129 */
130 public PD1 getPD1() {
131 PD1 ret = null;
132 try {
133 ret = (PD1)this.get("PD1");
134 } catch(HL7Exception e) {
135 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
136 throw new RuntimeException(e);
137 }
138 return ret;
139 }
140
141
142
143
144 /**
145 * Returns
146 * PV1 (Patient visit) - creates it if necessary
147 */
148 public PV1 getPV1() {
149 PV1 ret = null;
150 try {
151 ret = (PV1)this.get("PV1");
152 } catch(HL7Exception e) {
153 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
154 throw new RuntimeException(e);
155 }
156 return ret;
157 }
158
159
160
161
162 /**
163 * Returns
164 * the first repetition of
165 * ROL (Role) - creates it if necessary
166 */
167 public ROL getROL() {
168 ROL ret = null;
169 try {
170 ret = (ROL)this.get("ROL");
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 /**
180 * Returns a specific repetition of
181 * ROL (Role) - creates it if necessary
182 *
183 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
184 * @throws HL7Exception if the repetition requested is more than one
185 * greater than the number of existing repetitions.
186 */
187 public ROL getROL(int rep) {
188 ROL ret = null;
189 try {
190 ret = (ROL)this.get("ROL", rep);
191 } catch(HL7Exception e) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
193 throw new RuntimeException(e);
194 }
195 return ret;
196 }
197
198 /**
199 * Returns the number of existing repetitions of ROL
200 */
201 public int getROLReps() {
202 int reps = -1;
203 try {
204 reps = this.getAll("ROL").length;
205 } catch (HL7Exception e) {
206 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
207 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
208 throw new RuntimeException(message);
209 }
210 return reps;
211 }
212
213 /**
214 * Inserts a specific repetition of ROL (Role)
215 * @see AbstractGroup\#insertRepetition(Structure, int)
216 */
217 public void insertROL(ROL structure, int rep) throws HL7Exception {
218 super.insertRepetition( "ROL", structure, rep);
219 }
220
221
222 /**
223 * Inserts a specific repetition of ROL (Role)
224 * @see AbstractGroup\#insertRepetition(Structure, int)
225 */
226 public ROL insertROL(int rep) throws HL7Exception {
227 return (ROL)super.insertRepetition("ROL", rep);
228 }
229
230
231 /**
232 * Removes a specific repetition of ROL (Role)
233 * @see AbstractGroup\#removeRepetition(String, int)
234 */
235 public ROL removeROL(int rep) throws HL7Exception {
236 return (ROL)super.removeRepetition("ROL", rep);
237 }
238
239
240
241 /**
242 * Returns
243 * PV2 (Patient visit - additional information) - creates it if necessary
244 */
245 public PV2 getPV2() {
246 PV2 ret = null;
247 try {
248 ret = (PV2)this.get("PV2");
249 } catch(HL7Exception e) {
250 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
251 throw new RuntimeException(e);
252 }
253 return ret;
254 }
255
256
257
258
259 }
260