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.segment;
17  
18  import ca.uhn.hl7v2.HL7Exception;
19  import ca.uhn.hl7v2.model.AbstractSegment;
20  import ca.uhn.hl7v2.model.Group;
21  import ca.uhn.hl7v2.model.Message;
22  import ca.uhn.hl7v2.model.Type;
23  import ca.uhn.hl7v2.model.v25.datatype.*;
24  import ca.uhn.hl7v2.parser.ModelClassFactory;
25  import org.openehealth.ipf.modules.hl7.HL7v2Exception;
26  
27  
28  /**
29   * <p>Represents an HL7 QPD message segment used in IHE PDQ.
30   * The fields contained in this segment:</p>
31   * <ul>
32   * <li>QPD-1: Message Query Name (CE) </li>
33   * <li>QPD-2: Query Tag (ST)</li>
34   * <li>QPD-3: Query Input Parameter List (QIP)</li>
35   * <li>QPD-4: Parameters for Fuzzy Search (NM)</li>
36   * <li>QPD-5: Algorithm Name</li>
37   * <li>QPD-6. Algorithm Version</li>
38   * <li>QPD-7: Algorithm Description</li>
39   * <li>QPD-8: What Domains Returned (CX)</li>
40   * </ul>
41   */
42  @SuppressWarnings("serial")
43  public class QPD extends AbstractSegment {
44  
45      /**
46       * Creates a QPD (Query Parameter Definition) segment object
47       * which belongs to the given message
48       */
49      public QPD(Group parentGroup, ModelClassFactory modelFactory) {
50          super(parentGroup, modelFactory);
51          Message msg = getMessage();
52          try {
53              add(CE.class, true, 1, 250, new Object[]{msg}, "Message Query Name");
54              add(ST.class, true, 1, 32, new Object[]{msg}, "Query Tag");
55              add(QIP.class, true, 0, 256, new Object[]{msg}, "Demographics Fields");
56              add(NM.class, false, 1, 16, new Object[]{msg}, "Search Confidence Threshold");
57              add(ST.class, false, 1, 199, new Object[]{msg}, "Algorithm Name");
58              add(ST.class, false, 1, 199, new Object[]{msg}, "Algorithm Version");
59              add(ST.class, false, 1, 199, new Object[]{msg}, "Algorithm Description");
60              add(CX.class, false, 0, 256, new Object[]{msg}, "What domains returned");
61          } catch (HL7Exception e) {
62              throw new HL7v2Exception(e);
63          }
64      }
65  
66      /**
67       * Returns Message Query Name (QPD-1).
68       */
69      public CE getMessageQueryName() {
70          return getTypedField(1, 0);
71      }
72  
73      /**
74       * Returns Message Query Name (QPD-1).
75       */
76      public CE getQpd1_MessageQueryName() {
77          return getTypedField(1, 0);
78      }
79  
80      /**
81       * Returns Query Tag (QPD-2).
82       */
83      public ST getQueryTag() {
84          return getTypedField(2, 0);
85      }
86  
87      /**
88       * Returns Query Tag (QPD-2).
89       */
90      public ST getQpd2_QueryTag() {
91          return getTypedField(2, 0);
92      }
93  
94      /**
95       * Returns a specific repetition of Demographics Fields (QPD-3).
96       */
97      public QIP getDemographicsFields(int rep) {
98          return getTypedField(3, rep);
99      }
100 
101     /**
102      * Returns a specific repetition of Demographics Fields (QPD-3).
103      */
104     public QIP getQpd3_DemographicsFields(int rep) {
105         return getTypedField(3, rep);
106     }
107 
108     /**
109      * Returns Demographics Fields (QPD-3).
110      */
111     public QIP[] getDemographicsFields() {
112         return getTypedField(3, new QIP[0]);
113     }
114 
115     /**
116      * Returns Demographics Fields (QPD-3).
117      */
118     public QIP[] getQpd3_DemographicsFields() {
119         return getTypedField(3, new QIP[0]);
120     }
121 
122     /**
123      * Returns count of Demographics Fields (QPD-3).
124      */
125     public int getDemographicsFieldsReps() {
126         return getReps(3);
127     }
128 
129     /**
130      * Returns count of Demographics Fields (QPD-3).
131      */
132     public int getQpd3_DemographicsFieldsReps() {
133         return getReps(3);
134     }
135 
136     /**
137      * Inserts a repetition of Demographics Fields (QPD-3).
138      */
139     public QIP insertDemographicsFieldsReps(int rep) throws HL7Exception {
140         return (QIP) super.insertRepetition(3, rep);
141     }
142 
143     /**
144      * Inserts a repetition of Demographics Fields (QPD-3).
145      */
146     public QIP insertQpd3_DemographicsFieldsReps(int rep) throws HL7Exception {
147         return (QIP) super.insertRepetition(3, rep);
148     }
149 
150     /**
151      * Removes a repetition of Demographics Fields (QPD-3).
152      */
153     public QIP removeDemographicsFieldsReps(int rep) throws HL7Exception {
154         return (QIP) super.removeRepetition(3, rep);
155     }
156 
157     /**
158      * Removes a repetition of Demographics Fields (QPD-3).
159      */
160     public QIP removeQpd3_DemographicsFieldsReps(int rep) throws HL7Exception {
161         return (QIP) super.removeRepetition(3, rep);
162     }
163 
164     /**
165      * Returns Search Confidence Threshold (QPD-4).
166      */
167     public NM getSearchConfidenceThreshold() {
168         return getTypedField(4, 0);
169     }
170 
171     /**
172      * Returns Search Confidence Threshold (QPD-4).
173      */
174     public NM getQpd4_SearchConfidenceThreshold() {
175         return getTypedField(4, 0);
176     }
177 
178     /**
179      * Returns Algorithm Name (QPD-5).
180      */
181     public ST getAlgorithmName() {
182         return getTypedField(5, 0);
183     }
184 
185     /**
186      * Returns Algorithm Name (QPD-5).
187      */
188     public ST getQpd5_AlgorithmName() {
189         return getTypedField(5, 0);
190     }
191 
192     /**
193      * Returns Algorithm Version (QPD-6).
194      */
195     public ST getAlgorithmVersion() {
196         return getTypedField(6, 0);
197     }
198 
199     /**
200      * Returns Algorithm Version (QPD-6).
201      */
202     public ST getQpd6_AlgorithmVersion() {
203         return getTypedField(6, 0);
204     }
205 
206     /**
207      * Returns Algorithm Description (QPD-7).
208      */
209     public ST AlgorithmDescription() {
210         return getTypedField(7, 0);
211     }
212 
213     /**
214      * Returns Algorithm Description (QPD-7).
215      */
216     public ST getQpd7_AlgorithmDescription() {
217         return getTypedField(7, 0);
218     }
219 
220 
221     /**
222      * Returns a specific repetition of What Domains to be returned (QPD-8).
223      */
224     public CX getWhatDomainsReturned(int rep) {
225         return getTypedField(8, rep);
226     }
227 
228     /**
229      * Returns a specific repetition of What Domains to be returned (QPD-8).
230      */
231     public CX getQpd8_WhatDomainsReturned(int rep) {
232         return getTypedField(8, rep);
233     }
234 
235     /**
236      * Returns What Domains to be returned (QPD-8).
237      */
238     public CX[] getWhatDomainsReturned() {
239         return getTypedField(8, new CX[0]);
240     }
241 
242     /**
243      * Returns What Domains to be returned (QPD-8).
244      */
245     public CX[] getQpd8_WhatDomainsReturned() {
246         return getTypedField(8, new CX[0]);
247     }
248 
249     /**
250      * Returns count of What Domains to be returned (QPD-8).
251      */
252     public int getWhatDomainsReturnedReps() {
253         return getReps(8);
254     }
255 
256     /**
257      * Returns count of What Domains to be returned (QPD-8).
258      */
259     public int getQpd8_WhatDomainsReturnedReps() {
260         return getReps(8);
261     }
262 
263     /**
264      * Inserts a repetition of What Domains to be returned (QPD-8).
265      */
266     public CX insertWhatDomainsReturnedReps(int rep) throws HL7Exception {
267         return (CX) super.insertRepetition(8, rep);
268     }
269 
270     /**
271      * Inserts a repetition of What Domains to be returned (QPD-8).
272      */
273     public CX insertQpd8_WhatDomainsReturnedReps(int rep) throws HL7Exception {
274         return (CX) super.insertRepetition(8, rep);
275     }
276 
277     /**
278      * Removes a repetition of What Domains to be returned (QPD-8).
279      */
280     public CX removeWhatDomainsReturnedReps(int rep) throws HL7Exception {
281         return (CX) super.removeRepetition(8, rep);
282     }
283 
284     /**
285      * Removes a repetition of What Domains to be returned (QPD-8).
286      */
287     public CX removeQpd8_WhatDomainsReturnedReps(int rep) throws HL7Exception {
288         return (CX) super.removeRepetition(8, rep);
289     }
290 
291 
292     /**
293      * {@inheritDoc}
294      */
295     protected Type createNewTypeWithoutReflection(int field) {
296         switch (field) {
297             case 0:
298                 return new CE(getMessage());
299             case 1:
300                 return new ST(getMessage());
301             case 2:
302                 return new QIP(getMessage());
303             case 3:
304                 return new NM(getMessage());
305             case 4:
306                 return new ST(getMessage());
307             case 5:
308                 return new ST(getMessage());
309             case 6:
310                 return new ST(getMessage());
311             case 7:
312                 return new CX(getMessage());
313             default:
314                 return null;
315         }
316     }
317 
318 }