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_A60 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: PV1 (Patient visit) <b>optional </b></li>
027 * <li>5: PV2 (Patient visit - additional information) <b>optional </b></li>
028 * <li>6: IAM (Patient adverse reaction information - unique iden) <b>optional repeating</b></li>
029 * </ul>
030 */
031 public class ADT_A60 extends AbstractMessage {
032
033 /**
034 * Creates a new ADT_A60 message with DefaultModelClassFactory.
035 */
036 public ADT_A60() {
037 this(new DefaultModelClassFactory());
038 }
039
040 /**
041 * Creates a new ADT_A60 message with custom ModelClassFactory.
042 */
043 public ADT_A60(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(EVN.class, true, false);
052 this.add(PID.class, true, false);
053 this.add(PV1.class, false, false);
054 this.add(PV2.class, false, false);
055 this.add(IAM.class, false, true);
056 } catch(HL7Exception e) {
057 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A60 - 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 * EVN (Event Type) - creates it if necessary
091 */
092 public EVN getEVN() {
093 EVN ret = null;
094 try {
095 ret = (EVN)this.get("EVN");
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 * PID (Patient identification) - creates it if necessary
109 */
110 public PID getPID() {
111 PID ret = null;
112 try {
113 ret = (PID)this.get("PID");
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 * PV1 (Patient visit) - creates it if necessary
127 */
128 public PV1 getPV1() {
129 PV1 ret = null;
130 try {
131 ret = (PV1)this.get("PV1");
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 * PV2 (Patient visit - additional information) - creates it if necessary
145 */
146 public PV2 getPV2() {
147 PV2 ret = null;
148 try {
149 ret = (PV2)this.get("PV2");
150 } catch(HL7Exception e) {
151 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
152 throw new RuntimeException(e);
153 }
154 return ret;
155 }
156
157
158
159
160 /**
161 * Returns
162 * the first repetition of
163 * IAM (Patient adverse reaction information - unique iden) - creates it if necessary
164 */
165 public IAM getIAM() {
166 IAM ret = null;
167 try {
168 ret = (IAM)this.get("IAM");
169 } catch(HL7Exception e) {
170 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
171 throw new RuntimeException(e);
172 }
173 return ret;
174 }
175
176
177 /**
178 * Returns a specific repetition of
179 * IAM (Patient adverse reaction information - unique iden) - creates it if necessary
180 *
181 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
182 * @throws HL7Exception if the repetition requested is more than one
183 * greater than the number of existing repetitions.
184 */
185 public IAM getIAM(int rep) {
186 IAM ret = null;
187 try {
188 ret = (IAM)this.get("IAM", rep);
189 } catch(HL7Exception e) {
190 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
191 throw new RuntimeException(e);
192 }
193 return ret;
194 }
195
196 /**
197 * Returns the number of existing repetitions of IAM
198 */
199 public int getIAMReps() {
200 int reps = -1;
201 try {
202 reps = this.getAll("IAM").length;
203 } catch (HL7Exception e) {
204 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
205 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
206 throw new RuntimeException(message);
207 }
208 return reps;
209 }
210
211 /**
212 * Inserts a specific repetition of IAM (Patient adverse reaction information - unique iden)
213 * @see AbstractGroup\#insertRepetition(Structure, int)
214 */
215 public void insertIAM(IAM structure, int rep) throws HL7Exception {
216 super.insertRepetition( "IAM", structure, rep);
217 }
218
219
220 /**
221 * Inserts a specific repetition of IAM (Patient adverse reaction information - unique iden)
222 * @see AbstractGroup\#insertRepetition(Structure, int)
223 */
224 public IAM insertIAM(int rep) throws HL7Exception {
225 return (IAM)super.insertRepetition("IAM", rep);
226 }
227
228
229 /**
230 * Removes a specific repetition of IAM (Patient adverse reaction information - unique iden)
231 * @see AbstractGroup\#removeRepetition(String, int)
232 */
233 public IAM removeIAM(int rep) throws HL7Exception {
234 return (IAM)super.removeRepetition("IAM", rep);
235 }
236
237
238
239 }
240