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