View Javadoc
1   /*
2    * Copyright 2016 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  
17  package org.openehealth.ipf.commons.ihe.hl7v2.definitions.xpid.v25.message;
18  
19  import ca.uhn.hl7v2.HL7Exception;
20  import ca.uhn.hl7v2.model.Structure;
21  import ca.uhn.hl7v2.model.v25.group.ADT_A43_PATIENT;
22  import ca.uhn.hl7v2.model.v25.segment.EVN;
23  import ca.uhn.hl7v2.model.v25.segment.MSH;
24  import ca.uhn.hl7v2.model.v25.segment.SFT;
25  import ca.uhn.hl7v2.parser.ModelClassFactory;
26  import org.openehealth.ipf.commons.ihe.hl7v2.definitions.xpid.v25.segment.ZZI;
27  import org.openehealth.ipf.modules.hl7.model.AbstractMessage;
28  
29  import java.util.List;
30  import java.util.Map;
31  
32  /**
33   * Custom ADT_A39 structure that renames the PATIENT group
34   */
35  public class ADT_A43 extends AbstractMessage {
36  
37      public ADT_A43() {
38          super();
39      }
40  
41      public ADT_A43(ModelClassFactory factory) {
42          super(factory);
43      }
44  
45      @Override
46      protected Map<Class<? extends Structure>, Cardinality> structures(Map<Class<? extends Structure>, Cardinality> s) {
47          s.put(MSH.class, Cardinality.REQUIRED);
48          s.put(SFT.class, Cardinality.OPTIONAL_REPEATING);
49          s.put(EVN.class, Cardinality.REQUIRED);
50          s.put(ADT_A43_PATIENT.class, Cardinality.REQUIRED_REPEATING);
51          s.put(ZZI.class, Cardinality.OPTIONAL);
52          return s;
53      }
54  
55      public String getVersion() {
56          return "2.5";
57      }
58  
59      public MSH getMSH() {
60          return getTyped("MSH", MSH.class);
61      }
62  
63      public EVN getEVN() {
64          return getTyped("EVN", EVN.class);
65      }
66  
67      /**
68       * Returns a specific repetition of SFT
69       * (Software Segment) - creates it if necessary
70       * throws HL7Exception if the repetition requested is more than one
71       * greater than the number of existing repetitions.
72       */
73      public SFT getSFT(int rep) {
74          return getTyped("SFT", rep, SFT.class);
75      }
76  
77      /**
78       * Returns the number of existing repetitions of SFT
79       */
80      public int getSFTReps() {
81          return getReps("SFT");
82      }
83  
84      /**
85       * Returns all repetitions of SFT
86       */
87      public java.util.List<SFT> getSFTAll() throws HL7Exception {
88          return getAllAsList("SFT", SFT.class);
89      }
90  
91      public ADT_A43_PATIENT getPATIENT() {
92          return this.getTyped("PATIENT", ADT_A43_PATIENT.class);
93      }
94  
95      public ADT_A43_PATIENT getPATIENT(int rep) {
96          return this.getTyped("PATIENT", rep, ADT_A43_PATIENT.class);
97      }
98  
99      public int getPATIENTReps() {
100         return this.getReps("PATIENT");
101     }
102 
103     public List<ADT_A43_PATIENT> getPATIENTAll() throws HL7Exception {
104         return this.getAllAsList("PATIENT", ADT_A43_PATIENT.class);
105     }
106 
107     public void insertPATIENT(ADT_A43_PATIENT structure, int rep) throws HL7Exception {
108         super.insertRepetition("PATIENT", structure, rep);
109     }
110 
111     public ADT_A43_PATIENT insertPATIENT(int rep) throws HL7Exception {
112         return (ADT_A43_PATIENT)super.insertRepetition("PATIENT", rep);
113     }
114 
115     public ADT_A43_PATIENT removePATIENT(int rep) throws HL7Exception {
116         return (ADT_A43_PATIENT)super.removeRepetition("PATIENT", rep);
117     }
118 }