View Javadoc
1   /*
2    * Copyright 2015 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16   package org.openehealth.ipf.commons.ihe.hl7v2.definitions.pix.v231.message;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import ca.uhn.hl7v2.HL7Exception;
22  import ca.uhn.hl7v2.model.Structure;
23  import ca.uhn.hl7v2.model.v231.segment.*;
24  import ca.uhn.hl7v2.parser.ModelClassFactory;
25  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pix.v231.group.ADT_A01_INSURANCE;
26  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pix.v231.group.ADT_A01_PROCEDURE;
27  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pix.v231.segment.ZZI;
28  import org.openehealth.ipf.modules.hl7.model.AbstractMessage;
29  
30  /**
31   * ADT_A01 message with renamed groups PROCEDURE and INSURANCE.
32   */
33  public class ADT_A01 extends AbstractMessage {
34  
35      public ADT_A01() {
36          super();
37      }
38  
39      public ADT_A01(ModelClassFactory factory) {
40          super(factory);
41      }
42  
43      @Override
44      protected Map<Class<? extends Structure>, Cardinality> structures(Map<Class<? extends Structure>, Cardinality> s) {
45          s.put(MSH.class, Cardinality.REQUIRED);
46          s.put(EVN.class, Cardinality.REQUIRED);
47          s.put(PID.class, Cardinality.REQUIRED);
48          s.put(PD1.class, Cardinality.OPTIONAL);
49          s.put(PD1.class, Cardinality.OPTIONAL);
50          s.put(NK1.class, Cardinality.OPTIONAL_REPEATING);
51          s.put(PV1.class, Cardinality.REQUIRED);
52          s.put(PV2.class, Cardinality.OPTIONAL);
53          s.put(DB1.class, Cardinality.OPTIONAL_REPEATING);
54          s.put(OBX.class, Cardinality.OPTIONAL_REPEATING);
55          s.put(AL1.class, Cardinality.OPTIONAL_REPEATING);
56          s.put(DG1.class, Cardinality.OPTIONAL_REPEATING);
57          s.put(DRG.class, Cardinality.OPTIONAL);
58          s.put(ADT_A01_PROCEDURE.class, Cardinality.OPTIONAL_REPEATING);
59          s.put(GT1.class, Cardinality.OPTIONAL_REPEATING);
60          s.put(ADT_A01_INSURANCE.class, Cardinality.OPTIONAL);
61          s.put(ACC.class, Cardinality.OPTIONAL);
62          s.put(UB1.class, Cardinality.OPTIONAL);
63          s.put(UB2.class, Cardinality.OPTIONAL);
64          s.put(ZZI.class, Cardinality.OPTIONAL);
65          return s;
66      }
67  
68      public String getVersion() {
69          return "2.3.1";
70      }
71  
72      public MSH getMSH() {
73          return getTyped(MSH.class);
74      }
75  
76      public EVN getEVN() {
77          return getTyped(EVN.class);
78      }
79  
80      public PID getPID() {
81          return getTyped(PID.class);
82      }
83  
84      public PD1 getPD1() {
85          return getTyped(PD1.class);
86      }
87  
88      public NK1 getNK1() {
89          return getTyped(NK1.class);
90      }
91  
92      public NK1 getNK1(int rep) {
93          return getTyped(rep, NK1.class);
94      }
95  
96      public int getNK1Reps() {
97          return getReps("NK1");
98      }
99  
100     public List<NK1> getNK1All() throws HL7Exception {
101         return getAllAsList(NK1.class);
102     }
103 
104     public void insertNK1(NK1 structure, int rep) throws HL7Exception {
105         insertRepetition("NK1", structure, rep);
106     }
107 
108     public NK1 insertNK1(int rep) throws HL7Exception {
109         return insertRep("NK1", rep);
110     }
111 
112     public NK1 removeNK1(int rep) throws HL7Exception {
113         return removeRep("NK1", rep);
114     }
115 
116     public PV1 getPV1() {
117         return getTyped(PV1.class);
118     }
119 
120     public PV2 getPV2() {
121         return getTyped(PV2.class);
122     }
123 
124     public DB1 getDB1() {
125         return getTyped(DB1.class);
126     }
127 
128     public DB1 getDB1(int rep) {
129         return getTyped(rep, DB1.class);
130     }
131 
132     public int getDB1Reps() {
133         return getReps("DB1");
134     }
135 
136     public List<DB1> getDB1All() throws HL7Exception {
137         return getAllAsList(DB1.class);
138     }
139 
140     public void insertDB1(DB1 structure, int rep) throws HL7Exception {
141         insertRepetition("DB1", structure, rep);
142     }
143 
144     public DB1 insertDB1(int rep) throws HL7Exception {
145         return insertRep("DB1", rep);
146     }
147 
148     public DB1 removeDB1(int rep) throws HL7Exception {
149         return removeRep("DB1", rep);
150     }
151 
152     public OBX getOBX() {
153         return getTyped(OBX.class);
154     }
155 
156     public OBX getOBX(int rep) {
157         return getTyped(rep, OBX.class);
158     }
159 
160     public int getOBXReps() {
161         return getReps("OBX");
162     }
163 
164     public List<OBX> getOBXAll() throws HL7Exception {
165         return getAllAsList(OBX.class);
166     }
167 
168     public void insertOBX(OBX structure, int rep) throws HL7Exception {
169         insertRepetition("OBX", structure, rep);
170     }
171 
172     public OBX insertOBX(int rep) throws HL7Exception {
173         return insertRep("OBX", rep);
174     }
175 
176     public OBX removeOBX(int rep) throws HL7Exception {
177         return removeRep("OBX", rep);
178     }
179 
180     public AL1 getAL1() {
181         return getTyped(AL1.class);
182     }
183 
184     public AL1 getAL1(int rep) {
185         return getTyped(rep, AL1.class);
186     }
187 
188     public int getAL1Reps() {
189         return getReps("AL1");
190     }
191 
192     public List<AL1> getAL1All() throws HL7Exception {
193         return getAllAsList(AL1.class);
194     }
195 
196     public void insertAL1(AL1 structure, int rep) throws HL7Exception {
197         insertRepetition("AL1", structure, rep);
198     }
199 
200     public AL1 insertAL1(int rep) throws HL7Exception {
201         return insertRep("AL1", rep);
202     }
203 
204     public AL1 removeAL1(int rep) throws HL7Exception {
205         return removeRep("AL1", rep);
206     }
207 
208     public DG1 getDG1() {
209         return getTyped(DG1.class);
210     }
211 
212     public DG1 getDG1(int rep) {
213         return getTyped(rep, DG1.class);
214     }
215 
216     public int getDG1Reps() {
217         return getReps("DG1");
218     }
219 
220     public List<DG1> getDG1All() throws HL7Exception {
221         return getAllAsList(DG1.class);
222     }
223 
224     public void insertDG1(DG1 structure, int rep) throws HL7Exception {
225         insertRepetition("DG1", structure, rep);
226     }
227 
228     public DG1 insertDG1(int rep) throws HL7Exception {
229         return insertRep("DG1", rep);
230     }
231 
232     public DG1 removeDG1(int rep) throws HL7Exception {
233         return removeRep("DG1", rep);
234     }
235 
236     public DRG getDRG() {
237         return getTyped(DRG.class);
238     }
239 
240     public ADT_A01_PROCEDURE getPROCEDURE() {
241         return getTyped("PROCEDURE", ADT_A01_PROCEDURE.class);
242     }
243 
244     public ADT_A01_PROCEDURE getPROCEDURE(int rep) {
245         return getTyped("PROCEDURE", rep, ADT_A01_PROCEDURE.class);
246     }
247 
248     public int getPROCEDUREReps() {
249         return getReps("PROCEDURE");
250     }
251 
252     public List<ADT_A01_PROCEDURE> getPROCEDUREAll() throws HL7Exception {
253         return getAllAsList("PROCEDURE", ADT_A01_PROCEDURE.class);
254     }
255 
256     public void insertPROCEDURE(ADT_A01_PROCEDURE structure, int rep) throws HL7Exception {
257         insertRepetition("PROCEDURE", structure, rep);
258     }
259 
260     public ADT_A01_PROCEDURE insertPROCEDURE(int rep) throws HL7Exception {
261         return insertRep("PROCEDURE", rep);
262     }
263 
264     public ADT_A01_PROCEDURE removePROCEDURE(int rep) throws HL7Exception {
265         return removeRep("PROCEDURE", rep);
266     }
267 
268     public GT1 getGT1() {
269         return getTyped(GT1.class);
270     }
271 
272     public GT1 getGT1(int rep) {
273         return getTyped(rep, GT1.class);
274     }
275 
276     public int getGT1Reps() {
277         return getReps("GT1");
278     }
279 
280     public List<GT1> getGT1All() throws HL7Exception {
281         return getAllAsList(GT1.class);
282     }
283 
284     public void insertGT1(GT1 structure, int rep) throws HL7Exception {
285         insertRepetition("GT1", structure, rep);
286     }
287 
288     public GT1 insertGT1(int rep) throws HL7Exception {
289         return insertRep("GT1", rep);
290     }
291 
292     public GT1 removeGT1(int rep) throws HL7Exception {
293         return removeRep("GT1", rep);
294     }
295 
296     public ADT_A01_INSURANCE getINSURANCE() {
297         return getTyped("INSURANCE", ADT_A01_INSURANCE.class);
298     }
299 
300     public ADT_A01_INSURANCE getINSURANCE(int rep) {
301         return getTyped("INSURANCE", rep, ADT_A01_INSURANCE.class);
302     }
303 
304     public int getIN1IN2IN3Reps() {
305         return getReps("INSURANCE");
306     }
307 
308     public List<ADT_A01_INSURANCE> getINSURANCEAll() throws HL7Exception {
309         return getAllAsList("INSURANCE", ADT_A01_INSURANCE.class);
310     }
311 
312     public void insertINSURANCE(ADT_A01_INSURANCE structure, int rep) throws HL7Exception {
313         insertRepetition("INSURANCE", structure, rep);
314     }
315 
316     public ADT_A01_INSURANCE insertINSURANCE(int rep) throws HL7Exception {
317         return insertRep("INSURANCE", rep);
318     }
319 
320     public ADT_A01_INSURANCE removeINSURANCE(int rep) throws HL7Exception {
321         return removeRep("INSURANCE", rep);
322     }
323 
324     public ACC getACC() {
325         return getTyped(ACC.class);
326     }
327 
328     public UB1 getUB1() {
329         return getTyped(UB1.class);
330     }
331 
332     public UB2 getUB2() {
333         return getTyped(UB2.class);
334     }
335 
336     private <T extends Structure> T insertRep(String name, int rep) throws HL7Exception {
337         return (T)insertRepetition(name, rep);
338     }
339 
340     private <T extends Structure> T removeRep(String name, int rep) throws HL7Exception {
341         return (T)removeRepetition(name, rep);
342     }
343 
344     private <T extends Structure> T getTyped(Class<T> clazz) {
345         return getTyped(clazz.getSimpleName(), clazz);
346     }
347 
348     private <T extends Structure> T getTyped(int rep, Class<T> clazz) {
349         return getTyped(clazz.getSimpleName(), rep, clazz);
350     }
351 
352     private <T extends Structure> List<T> getAllAsList(Class<T> clazz) throws HL7Exception {
353         return getAllAsList(clazz.getSimpleName(), clazz);
354     }
355 }