View Javadoc
1   /*
2    * Copyright 2009 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.pdq.v25.message;
17  
18  import java.util.Map;
19  
20  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pdq.v25.segment.QPD;
21  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pdq.v25.segment.ZZI;
22  import org.openehealth.ipf.modules.hl7.model.AbstractMessage;
23  
24  import ca.uhn.hl7v2.HL7Exception;
25  import ca.uhn.hl7v2.model.Structure;
26  import ca.uhn.hl7v2.model.v25.group.RSP_K21_QUERY_RESPONSE;
27  import ca.uhn.hl7v2.model.v25.segment.DSC;
28  import ca.uhn.hl7v2.model.v25.segment.ERR;
29  import ca.uhn.hl7v2.model.v25.segment.MSA;
30  import ca.uhn.hl7v2.model.v25.segment.MSH;
31  import ca.uhn.hl7v2.model.v25.segment.QAK;
32  import ca.uhn.hl7v2.model.v25.segment.SFT;
33  import ca.uhn.hl7v2.parser.ModelClassFactory;
34  
35  /**
36   * Adds a custom QPD segment instead of the standard one
37   * coming from v25 hapi package
38   *
39   * @see ca.uhn.hl7v2.model.v25.message.RSP_K21
40   * @see org.openehealth.ipf.commons.ihe.hl7v2.definitions.pdq.v25.segment.QPD
41   */
42  @SuppressWarnings("serial")
43  public class RSP_K21 extends AbstractMessage {
44  
45      /**
46       * Creates a new RSP_K21 Group with custom ModelClassFactory.
47       */
48      public RSP_K21(ModelClassFactory factory) {
49      }
50  
51      /**
52       * Creates a new RSP_K21 Group with DefaultModelClassFactory.
53       */
54      public RSP_K21() {
55          super();
56      }
57  
58      @Override
59      protected Map<Class<? extends Structure>, Cardinality> structures(
60              Map<Class<? extends Structure>, Cardinality> s) {
61          s.put(MSH.class, Cardinality.REQUIRED);
62          s.put(SFT.class, Cardinality.OPTIONAL_REPEATING);
63          s.put(MSA.class, Cardinality.REQUIRED);
64          s.put(ERR.class, Cardinality.OPTIONAL);
65          s.put(QAK.class, Cardinality.REQUIRED);
66          s.put(QPD.class, Cardinality.REQUIRED);
67          s.put(RSP_K21_QUERY_RESPONSE.class, Cardinality.OPTIONAL_REPEATING);
68          s.put(DSC.class, Cardinality.OPTIONAL);
69          s.put(ZZI.class, Cardinality.OPTIONAL);
70          return s;
71      }
72  
73      public String getVersion() {
74          return "2.5";
75      }
76  
77      /**
78       * Returns MSH (Message Header) - creates it if necessary
79       */
80      public MSH getMSH() {
81          return getTyped("MSH", MSH.class);
82      }
83  
84      /**
85       * Returns first repetition of SFT (Software Segment) - creates it if
86       * necessary
87       */
88      public SFT getSFT() {
89          return getTyped("SFT", SFT.class);
90      }
91  
92      /**
93       * Returns a specific repetition of SFT (Software Segment) - creates it if
94       * necessary throws HL7Exception if the repetition requested is more than
95       * one greater than the number of existing repetitions.
96       */
97      public SFT getSFT(int rep) throws HL7Exception {
98          return getTyped("STF", rep, SFT.class);
99      }
100 
101     /**
102      * Returns the number of existing repetitions of SFT
103      */
104     public int getSFTReps() {
105         return getReps("SFT");
106     }
107 
108     /**
109      * Returns all repetitions of SFT
110      */
111     public java.util.List<SFT> getSFTAll() throws HL7Exception {
112         return getAllAsList("SFT", SFT.class);
113     }
114 
115     /**
116      * Returns MSA (Message Acknowledgment) - creates it if necessary
117      */
118     public MSA getMSA() {
119         return getTyped("MSA", MSA.class);
120     }
121 
122     /**
123      * Returns ERR (Error) - creates it if necessary
124      */
125     public ERR getERR() {
126         return getTyped("ERR", ERR.class);
127     }
128 
129     /**
130      * Returns QAK (Query Acknowledgment) - creates it if necessary
131      */
132     public QAK getQAK() {
133         return getTyped("QAK", QAK.class);
134     }
135 
136     /**
137      * Returns QPD (Query Parameter Definition) - creates it if necessary
138      */
139     public QPD getQPD() {
140         return getTyped("QPD", QPD.class);
141     }
142 
143     /**
144      * Returns first repetition of RSP_K21_QUERY_RESPONSE (a Group object) -
145      * creates it if necessary
146      */
147     public RSP_K21_QUERY_RESPONSE getQUERY_RESPONSE() {
148         return getTyped("QUERY_RESPONSE", 0, RSP_K21_QUERY_RESPONSE.class);
149     }
150 
151     /**
152      * Returns a specific repetition of RSP_K21_QUERY_RESPONSE (a Group object)
153      * - creates it if necessary throws HL7Exception if the repetition requested
154      * is more than one greater than the number of existing repetitions.
155      */
156     public RSP_K21_QUERY_RESPONSE getQUERY_RESPONSE(int rep)
157             throws HL7Exception {
158         return getTyped("QUERY_RESPONSE", rep, RSP_K21_QUERY_RESPONSE.class);
159     }
160 
161     /**
162      * Returns the number of existing repetitions of RSP_K21_QUERY_RESPONSE
163      */
164     public int getQUERY_RESPONSEReps() {
165         return getReps("QUERY_RESPONSE");
166     }
167 
168     /**
169      * Returns all repetitions of RSP_K21_QUERY_RESPONSE
170      */
171     public java.util.List<RSP_K21_QUERY_RESPONSE> getQUERY_RESPONSEAll() throws HL7Exception {
172         return getAllAsList("QUERY_RESPONSE", RSP_K21_QUERY_RESPONSE.class);
173     }
174 
175     /**
176      * Returns DSC (Continuation Pointer) - creates it if necessary
177      */
178     public DSC getDSC() {
179         return getTyped("DSC", DSC.class);
180     }
181 
182 }