001 /*
002 * This class is an auto-generated source file for a HAPI
003 * HL7 v2.x standard structure class.
004 *
005 * For more information, visit: http://hl7api.sourceforge.net/
006 */
007
008 package ca.uhn.hl7v2.model.v24.group;
009
010 import ca.uhn.hl7v2.model.v24.segment.*;
011
012 import ca.uhn.log.HapiLogFactory;
013 import ca.uhn.hl7v2.HL7Exception;
014 import ca.uhn.hl7v2.parser.ModelClassFactory;
015 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016 import ca.uhn.hl7v2.model.AbstractMessage;
017 import ca.uhn.hl7v2.model.Group;
018 import ca.uhn.hl7v2.model.AbstractGroup;
019 import ca.uhn.hl7v2.model.GenericSegment;
020
021 /**
022 * <p>Represents a DFT_P03_COMMON_ORDER group structure (a Group object).
023 * A Group is an ordered collection of message segments that can repeat together or be optionally in/excluded together.
024 * This Group contains the following elements:
025 * </p>
026 * <ul>
027 * <li>1: ORC (Common Order) <b>optional </b></li>
028 * <li>2: DFT_P03_ORDER (a Group object) <b>optional </b></li>
029 * <li>3: DFT_P03_OBSERVATION (a Group object) <b>optional repeating</b></li>
030 * </ul>
031 */
032 public class DFT_P03_COMMON_ORDER extends AbstractGroup {
033
034 /**
035 * Creates a new DFT_P03_COMMON_ORDER group
036 */
037 public DFT_P03_COMMON_ORDER(Group parent, ModelClassFactory factory) {
038 super(parent, factory);
039 init(factory);
040 }
041
042 private void init(ModelClassFactory factory) {
043 try {
044 this.add(ORC.class, false, false);
045 this.add(DFT_P03_ORDER.class, false, false);
046 this.add(DFT_P03_OBSERVATION.class, false, true);
047 } catch(HL7Exception e) {
048 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating DFT_P03_COMMON_ORDER - this is probably a bug in the source code generator.", e);
049 }
050 }
051
052 /**
053 * Returns "2.4"
054 */
055 public String getVersion() {
056 return "2.4";
057 }
058
059
060
061 /**
062 * Returns
063 * ORC (Common Order) - creates it if necessary
064 */
065 public ORC getORC() {
066 ORC ret = null;
067 try {
068 ret = (ORC)this.get("ORC");
069 } catch(HL7Exception e) {
070 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
071 throw new RuntimeException(e);
072 }
073 return ret;
074 }
075
076
077
078
079 /**
080 * Returns
081 * ORDER (a Group object) - creates it if necessary
082 */
083 public DFT_P03_ORDER getORDER() {
084 DFT_P03_ORDER ret = null;
085 try {
086 ret = (DFT_P03_ORDER)this.get("ORDER");
087 } catch(HL7Exception e) {
088 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
089 throw new RuntimeException(e);
090 }
091 return ret;
092 }
093
094
095
096
097 /**
098 * Returns
099 * the first repetition of
100 * OBSERVATION (a Group object) - creates it if necessary
101 */
102 public DFT_P03_OBSERVATION getOBSERVATION() {
103 DFT_P03_OBSERVATION ret = null;
104 try {
105 ret = (DFT_P03_OBSERVATION)this.get("OBSERVATION");
106 } catch(HL7Exception e) {
107 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
108 throw new RuntimeException(e);
109 }
110 return ret;
111 }
112
113
114 /**
115 * Returns a specific repetition of
116 * OBSERVATION (a Group object) - creates it if necessary
117 *
118 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
119 * @throws HL7Exception if the repetition requested is more than one
120 * greater than the number of existing repetitions.
121 */
122 public DFT_P03_OBSERVATION getOBSERVATION(int rep) {
123 DFT_P03_OBSERVATION ret = null;
124 try {
125 ret = (DFT_P03_OBSERVATION)this.get("OBSERVATION", rep);
126 } catch(HL7Exception e) {
127 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
128 throw new RuntimeException(e);
129 }
130 return ret;
131 }
132
133 /**
134 * Returns the number of existing repetitions of OBSERVATION
135 */
136 public int getOBSERVATIONReps() {
137 int reps = -1;
138 try {
139 reps = this.getAll("OBSERVATION").length;
140 } catch (HL7Exception e) {
141 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
142 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
143 throw new RuntimeException(message);
144 }
145 return reps;
146 }
147
148 /**
149 * Inserts a specific repetition of OBSERVATION (a Group object)
150 * @see AbstractGroup#insertRepetition(Structure, int)
151 */
152 public void insertOBSERVATION(DFT_P03_OBSERVATION structure, int rep) throws HL7Exception {
153 super.insertRepetition("OBSERVATION", structure, rep);
154 }
155
156
157 /**
158 * Inserts a specific repetition of OBSERVATION (a Group object)
159 * @see AbstractGroup#insertRepetition(Structure, int)
160 */
161 public DFT_P03_OBSERVATION insertOBSERVATION(int rep) throws HL7Exception {
162 return (DFT_P03_OBSERVATION)super.insertRepetition("OBSERVATION", rep);
163 }
164
165
166 /**
167 * Removes a specific repetition of OBSERVATION (a Group object)
168 * @see AbstractGroup#removeRepetition(String, int)
169 */
170 public DFT_P03_OBSERVATION removeOBSERVATION(int rep) throws HL7Exception {
171 return (DFT_P03_OBSERVATION)super.removeRepetition("OBSERVATION", rep);
172 }
173
174
175
176 }
177