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 ca.uhn.hl7v2.HL7Exception;
21  import ca.uhn.hl7v2.model.Structure;
22  import ca.uhn.hl7v2.model.v25.segment.*;
23  import ca.uhn.hl7v2.parser.ModelClassFactory;
24  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pdq.v25.group.RSP_ZV2_QUERY_RESPONSE;
25  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pdq.v25.segment.QPD;
26  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pdq.v25.segment.ZZI;
27  import org.openehealth.ipf.modules.hl7.model.AbstractMessage;
28  
29  /**
30   * Represents a RSP_ZV2 message structure as described
31   * in ITI TF Vol. 2a, pp. 219-220.
32   * <p>
33   * This structure contains the following elements: </p>
34   * 0: MSH (Message Header) <br>
35   * 1: MSA (Message Acknowledgment) <br>
36   * 2: ERR (Error) <b>optional</b><br>
37   * 3: QAK (Query Acknowledgment) <br>
38   * 4: QPD (Query Parameter Definition) <br>
39   * 5: RSP_ZV2_QUERY_RESPONSE (a Group object) <b>optional repeating</b><br>
40   * 6: DSC (Continuation Pointer) <b>optional</b><br>
41   */
42  @SuppressWarnings("serial")
43  public class RSP_ZV2 extends AbstractMessage {
44  
45      /**
46       * Creates a new RSP_ZV2 Group with custom ModelClassFactory.
47       */
48      public RSP_ZV2(ModelClassFactory factory) {
49          super(factory);
50      }
51  
52      /**
53       * Creates a new RSP_ZV2 Group with DefaultModelClassFactory.
54       */
55      public RSP_ZV2() {
56          super();
57      }
58  
59      @Override
60      protected Map<Class<? extends Structure>, Cardinality> structures(
61               Map<Class<? extends Structure>, Cardinality> s) {
62          s.put(MSH.class, Cardinality.REQUIRED);
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_ZV2_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 MSA (Message Acknowledgment) - creates it if necessary
86        */
87      public MSA getMSA() {
88          return getTyped("MSA", MSA.class);
89      }
90  
91      /**
92        * Returns ERR (Error) - creates it if necessary
93        */
94      public ERR getERR() {
95          return getTyped("ERR", ERR.class);
96      }
97  
98      /**
99        * Returns QAK (Query Acknowledgment) - creates it if necessary
100       */
101     public QAK getQAK() {
102         return getTyped("QAK", QAK.class);
103     }
104 
105     /**
106       * Returns QPD (Query Parameter Definition) - creates it if necessary
107       */
108     public QPD getQPD() {
109         return getTyped("QPD", QPD.class);
110     }
111 
112     /**
113       * Returns first repetition of RSP_ZV2_QUERY_RESPONSE (a Group object) - creates it if necessary
114       */
115     public RSP_ZV2_QUERY_RESPONSE getQUERY_RESPONSE() {
116         return getTyped("QUERY_RESPONSE", RSP_ZV2_QUERY_RESPONSE.class);
117     }
118 
119     /**
120       * Returns a specific repetition of RSP_ZV2_QUERY_RESPONSE
121       * (a Group object) - creates it if necessary
122       * throws HL7Exception if the repetition requested is more than one
123       * greater than the number of existing repetitions.
124       */
125     public RSP_ZV2_QUERY_RESPONSE getQUERY_RESPONSE(int rep) {
126         return getTyped("QUERY_RESPONSE", rep, RSP_ZV2_QUERY_RESPONSE.class);
127     }
128 
129     /**
130       * Returns the number of existing repetitions of RSP_ZV2_QUERY_RESPONSE
131       */
132     public int getQUERY_RESPONSEReps() {
133         return getReps("QUERY_RESPONSE");
134     }
135 
136     /**
137      * Returns all repetitions of RSP_ZV2_QUERY_RESPONSE
138      */
139     public java.util.List<RSP_ZV2_QUERY_RESPONSE> getQUERY_RESPONSEAll() throws HL7Exception {
140         return getAllAsList("QUERY_RESPONSE", RSP_ZV2_QUERY_RESPONSE.class);
141     }
142 
143     /**
144       * Returns DSC (Continuation Pointer) - creates it if necessary
145       */
146     public DSC getDSC() {
147         return getTyped("DSC", DSC.class);
148     }
149 }