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.message;
009
010 import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.segment.*;
012
013 import ca.uhn.log.HapiLogFactory;
014 import ca.uhn.hl7v2.HL7Exception;
015 import ca.uhn.hl7v2.parser.ModelClassFactory;
016 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017 import ca.uhn.hl7v2.model.AbstractMessage;
018
019 /**
020 * <p>Represents a ORU_R01 message structure (see chapter 7). This structure contains the
021 * following elements: </p>
022 * <ul>
023 * <li>1: MSH (Message Header) <b> </b></li>
024 * <li>2: ORU_R01_PATIENT_RESULT (a Group object) <b> repeating</b></li>
025 * <li>3: DSC (Continuation Pointer) <b>optional </b></li>
026 * </ul>
027 */
028 public class ORU_R01 extends AbstractMessage {
029
030 /**
031 * Creates a new ORU_R01 message with DefaultModelClassFactory.
032 */
033 public ORU_R01() {
034 this(new DefaultModelClassFactory());
035 }
036
037 /**
038 * Creates a new ORU_R01 message with custom ModelClassFactory.
039 */
040 public ORU_R01(ModelClassFactory factory) {
041 super(factory);
042 init(factory);
043 }
044
045 private void init(ModelClassFactory factory) {
046 try {
047 this.add(MSH.class, true, false);
048 this.add(ORU_R01_PATIENT_RESULT.class, true, true);
049 this.add(DSC.class, false, false);
050 } catch(HL7Exception e) {
051 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ORU_R01 - this is probably a bug in the source code generator.", e);
052 }
053 }
054
055 /**
056 * Returns "2.4"
057 */
058 public String getVersion() {
059 return "2.4";
060 }
061
062
063
064 /**
065 * Returns
066 * MSH (Message Header) - creates it if necessary
067 */
068 public MSH getMSH() {
069 MSH ret = null;
070 try {
071 ret = (MSH)this.get("MSH");
072 } catch(HL7Exception e) {
073 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
074 throw new RuntimeException(e);
075 }
076 return ret;
077 }
078
079
080
081
082 /**
083 * Returns
084 * the first repetition of
085 * PATIENT_RESULT (a Group object) - creates it if necessary
086 */
087 public ORU_R01_PATIENT_RESULT getPATIENT_RESULT() {
088 ORU_R01_PATIENT_RESULT ret = null;
089 try {
090 ret = (ORU_R01_PATIENT_RESULT)this.get("PATIENT_RESULT");
091 } catch(HL7Exception e) {
092 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
093 throw new RuntimeException(e);
094 }
095 return ret;
096 }
097
098
099 /**
100 * Returns a specific repetition of
101 * PATIENT_RESULT (a Group object) - creates it if necessary
102 *
103 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
104 * @throws HL7Exception if the repetition requested is more than one
105 * greater than the number of existing repetitions.
106 */
107 public ORU_R01_PATIENT_RESULT getPATIENT_RESULT(int rep) {
108 ORU_R01_PATIENT_RESULT ret = null;
109 try {
110 ret = (ORU_R01_PATIENT_RESULT)this.get("PATIENT_RESULT", rep);
111 } catch(HL7Exception e) {
112 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
113 throw new RuntimeException(e);
114 }
115 return ret;
116 }
117
118 /**
119 * Returns the number of existing repetitions of PATIENT_RESULT
120 */
121 public int getPATIENT_RESULTReps() {
122 int reps = -1;
123 try {
124 reps = this.getAll("PATIENT_RESULT").length;
125 } catch (HL7Exception e) {
126 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
127 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
128 throw new RuntimeException(message);
129 }
130 return reps;
131 }
132
133 /**
134 * Inserts a specific repetition of PATIENT_RESULT (a Group object)
135 * @see AbstractGroup\#insertRepetition(Structure, int)
136 */
137 public void insertPATIENT_RESULT(ORU_R01_PATIENT_RESULT structure, int rep) throws HL7Exception {
138 super.insertRepetition( "PATIENT_RESULT", structure, rep);
139 }
140
141
142 /**
143 * Inserts a specific repetition of PATIENT_RESULT (a Group object)
144 * @see AbstractGroup\#insertRepetition(Structure, int)
145 */
146 public ORU_R01_PATIENT_RESULT insertPATIENT_RESULT(int rep) throws HL7Exception {
147 return (ORU_R01_PATIENT_RESULT)super.insertRepetition("PATIENT_RESULT", rep);
148 }
149
150
151 /**
152 * Removes a specific repetition of PATIENT_RESULT (a Group object)
153 * @see AbstractGroup\#removeRepetition(String, int)
154 */
155 public ORU_R01_PATIENT_RESULT removePATIENT_RESULT(int rep) throws HL7Exception {
156 return (ORU_R01_PATIENT_RESULT)super.removeRepetition("PATIENT_RESULT", rep);
157 }
158
159
160
161 /**
162 * Returns
163 * DSC (Continuation Pointer) - creates it if necessary
164 */
165 public DSC getDSC() {
166 DSC ret = null;
167 try {
168 ret = (DSC)this.get("DSC");
169 } catch(HL7Exception e) {
170 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
171 throw new RuntimeException(e);
172 }
173 return ret;
174 }
175
176
177
178
179 }
180