View Javadoc
1   /*
2    * Copyright 2015 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.v231.message;
17  
18  import ca.uhn.hl7v2.HL7Exception;
19  import ca.uhn.hl7v2.model.Structure;
20  import ca.uhn.hl7v2.model.v231.segment.EVN;
21  import ca.uhn.hl7v2.model.v231.segment.MSH;
22  import ca.uhn.hl7v2.parser.ModelClassFactory;
23  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pix.v231.group.ADT_A39_PATIENT;
24  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.pix.v231.segment.ZZI;
25  import org.openehealth.ipf.modules.hl7.model.AbstractMessage;
26  
27  import java.util.List;
28  import java.util.Map;
29  
30  /**
31   * Custom ADT_A39 structure that renames the PATIENT group
32   */
33  public class ADT_A39 extends AbstractMessage {
34  
35      public ADT_A39() {
36          super();
37      }
38  
39      public ADT_A39(ModelClassFactory factory) {
40          super(factory);
41      }
42  
43      @Override
44      protected Map<Class<? extends Structure>, Cardinality> structures(Map<Class<? extends Structure>, Cardinality> s) {
45          s.put(MSH.class, Cardinality.REQUIRED);
46          s.put(EVN.class, Cardinality.REQUIRED);
47          s.put(ADT_A39_PATIENT.class, Cardinality.REQUIRED_REPEATING);
48          s.put(ZZI.class, Cardinality.OPTIONAL);
49          return s;
50      }
51  
52      public String getVersion() {
53          return "2.3.1";
54      }
55  
56      public MSH getMSH() {
57          return getTyped("MSH", MSH.class);
58      }
59  
60      public EVN getEVN() {
61          return getTyped("EVN", EVN.class);
62      }
63  
64      public ADT_A39_PATIENT getPATIENT() {
65          return this.getTyped("PATIENT", ADT_A39_PATIENT.class);
66      }
67  
68      public ADT_A39_PATIENT getPATIENT(int rep) {
69          return this.getTyped("PATIENT", rep, ADT_A39_PATIENT.class);
70      }
71  
72      public int getPATIENTReps() {
73          return this.getReps("PATIENT");
74      }
75  
76      public List<ADT_A39_PATIENT> getPATIENTAll() throws HL7Exception {
77          return this.getAllAsList("PATIENT", ADT_A39_PATIENT.class);
78      }
79  
80      public void insertPATIENT(ADT_A39_PATIENT structure, int rep) throws HL7Exception {
81          super.insertRepetition("PATIENT", structure, rep);
82      }
83  
84      public ADT_A39_PATIENT insertPATIENT(int rep) throws HL7Exception {
85          return (ADT_A39_PATIENT)super.insertRepetition("PATIENT", rep);
86      }
87  
88      public ADT_A39_PATIENT removePATIENT(int rep) throws HL7Exception {
89          return (ADT_A39_PATIENT)super.removeRepetition("PATIENT", rep);
90      }
91  }