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