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.pix.v25.segment;
17  
18  import org.openehealth.ipf.modules.hl7.HL7v2Exception;
19  
20  import ca.uhn.hl7v2.HL7Exception;
21  import ca.uhn.hl7v2.model.AbstractSegment;
22  import ca.uhn.hl7v2.model.Group;
23  import ca.uhn.hl7v2.model.Message;
24  import ca.uhn.hl7v2.model.Type;
25  import ca.uhn.hl7v2.model.v25.datatype.CE;
26  import ca.uhn.hl7v2.model.v25.datatype.CX;
27  import ca.uhn.hl7v2.model.v25.datatype.ST;
28  import ca.uhn.hl7v2.parser.ModelClassFactory;
29  
30  
31  
32  /**
33   * <p>Represents an HL7 QPD message segment.
34   * The fields contained in this segment:</p><p>
35   * QPD-1: Message Query Name (CE)<br>
36   * QPD-2: Query Tag (ST)<br>
37   * QPD-3: PIX Query parameter<br>
38   * QPD-4: What domains returned
39    */
40  @SuppressWarnings("serial")
41  public class QPD extends AbstractSegment {
42  
43      /**
44       * Creates a QPD (Query Parameter Definition) segment object
45       * which belongs to the given message
46       */
47      public QPD(Group parentGroup, ModelClassFactory modelFactory) {
48          super(parentGroup, modelFactory);
49          Message msg = getMessage();
50          try {
51          	add(CE.class, true, 1, 250, new Object[]{msg}, "Message Query Name");
52              add(ST.class, true, 1, 32, new Object[]{msg}, "Query Tag");
53              add(CX.class, true, 1, 256, new Object[]{msg}, "Person Identifier");
54              add(CX.class, false, 0, 256, new Object[]{msg}, "What domains returned");
55          } catch (HL7Exception e) {
56              throw new HL7v2Exception(e);
57          }
58      }
59  
60      /**
61       * Returns Message Query Name (QPD-1).
62       */
63      public CE getMessageQueryName() {
64          return getTypedField(1, 0);
65      }
66  
67      /**
68       * Returns Message Query Name (QPD-1).
69       */
70      public CE getQpd1_MessageQueryName() {
71          return getTypedField(1, 0);
72      }
73  
74      /**
75       * Returns Query Tag (QPD-2).
76       */
77      public ST getQueryTag() {
78          return getTypedField(2, 0);
79      }
80  
81      /**
82       * Returns Query Tag (QPD-2).
83       */
84      public ST getQpd2_QueryTag() {
85          return getTypedField(2, 0);
86      }
87  
88      /**
89       * Returns Person identifier (QPD-3).
90       */
91      public CX getPersonIdentifier() {
92          return getTypedField(3, 0);
93      }
94  
95      /**
96       * Returns Person identifier (QPD-3).
97       */
98      public CX getQpd3_PersonIdentifier() {
99          return getTypedField(3, 0);
100     }
101 
102     /**
103      * Returns What Domains to be returned (QPD-4).
104      */
105     public CX getWhatDomainsReturned(int rep) {
106         return getTypedField(4, rep);
107     }
108 
109     /**
110      * Returns What Domains to be returned (QPD-4).
111      */
112     public CX getQpd4_WhatDomainsReturned(int rep) {
113         return getTypedField(4, rep);
114     }
115 
116     /**
117      * Returns What Domains to be returned (QPD-4).
118      */
119     public CX[] getWhatDomainsReturned() {
120         return getTypedField(4, new CX[0]);
121     }
122 
123     /** {@inheritDoc} */
124     protected Type createNewTypeWithoutReflection(int field) {
125         switch (field) {
126             case 0: return new CE(getMessage());
127             case 1: return new ST(getMessage());
128             case 2: return new CX(getMessage());
129             case 3: return new CX(getMessage());
130             default: return null;
131         }
132     }
133 
134 }