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