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 * The contents of this file are subject to the Mozilla Public License Version 1.1 008 * (the "License"); you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 010 * Software distributed under the License is distributed on an "AS IS" basis, 011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 012 * specific language governing rights and limitations under the License. 013 * 014 * The Original Code is "[file_name]". Description: 015 * "[one_line_description]" 016 * 017 * The Initial Developer of the Original Code is University Health Network. Copyright (C) 018 * 2012. All Rights Reserved. 019 * 020 * Contributor(s): ______________________________________. 021 * 022 * Alternatively, the contents of this file may be used under the terms of the 023 * GNU General Public License (the "GPL"), in which case the provisions of the GPL are 024 * applicable instead of those above. If you wish to allow use of your version of this 025 * file only under the terms of the GPL and not to allow others to use your version 026 * of this file under the MPL, indicate your decision by deleting the provisions above 027 * and replace them with the notice and other provisions required by the GPL License. 028 * If you do not delete the provisions above, a recipient may use your version of 029 * this file under either the MPL or the GPL. 030 * 031 */ 032 033 034package ca.uhn.hl7v2.model.v22.segment; 035 036// import ca.uhn.hl7v2.model.v22.group.*; 037import ca.uhn.hl7v2.model.v22.datatype.*; 038import ca.uhn.hl7v2.HL7Exception; 039import ca.uhn.hl7v2.parser.ModelClassFactory; 040import ca.uhn.hl7v2.parser.DefaultModelClassFactory; 041import ca.uhn.hl7v2.model.AbstractMessage; 042import ca.uhn.hl7v2.model.Group; 043import ca.uhn.hl7v2.model.Type; 044import ca.uhn.hl7v2.model.AbstractSegment; 045import ca.uhn.hl7v2.model.Varies; 046 047/** 048 *<p>Represents an HL7 ODS message segment (DIETARY ORDERS, SUPPLEMENTS, and PREFERENCES). 049 * This segment has the following fields:</p> 050 * <ul> 051 * <li>ODS-1: Type (ID) <b> </b> 052 * <li>ODS-2: Service Period (CE) <b>optional repeating</b> 053 * <li>ODS-3: Diet, Supplement, or Preference Code (CE) <b> repeating</b> 054 * <li>ODS-4: Text Instruction (ST) <b>optional repeating</b> 055 * </ul> 056 */ 057@SuppressWarnings("unused") 058public class ODS extends AbstractSegment { 059 060 /** 061 * Creates a new ODS segment 062 */ 063 public ODS(Group parent, ModelClassFactory factory) { 064 super(parent, factory); 065 init(factory); 066 } 067 068 private void init(ModelClassFactory factory) { 069 try { 070 this.add(ID.class, true, 1, 1, new Object[]{ getMessage(), new Integer(159) }, "Type"); 071 this.add(CE.class, false, 10, 60, new Object[]{ getMessage() }, "Service Period"); 072 this.add(CE.class, true, 20, 60, new Object[]{ getMessage() }, "Diet, Supplement, or Preference Code"); 073 this.add(ST.class, false, 2, 80, new Object[]{ getMessage() }, "Text Instruction"); 074 } catch(HL7Exception e) { 075 log.error("Unexpected error creating ODS - this is probably a bug in the source code generator.", e); 076 } 077 } 078 079 080 081 /** 082 * Returns 083 * ODS-1: "Type" - creates it if necessary 084 */ 085 public ID getType() { 086 ID retVal = this.getTypedField(1, 0); 087 return retVal; 088 } 089 090 /** 091 * Returns 092 * ODS-1: "Type" - creates it if necessary 093 */ 094 public ID getOds1_Type() { 095 ID retVal = this.getTypedField(1, 0); 096 return retVal; 097 } 098 099 100 /** 101 * Returns all repetitions of Service Period (ODS-2). 102 */ 103 public CE[] getServicePeriod() { 104 CE[] retVal = this.getTypedField(2, new CE[0]); 105 return retVal; 106 } 107 108 109 /** 110 * Returns all repetitions of Service Period (ODS-2). 111 */ 112 public CE[] getOds2_ServicePeriod() { 113 CE[] retVal = this.getTypedField(2, new CE[0]); 114 return retVal; 115 } 116 117 118 /** 119 * Returns a count of the current number of repetitions of Service Period (ODS-2). 120 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 121 * it will return zero. 122 */ 123 public int getServicePeriodReps() { 124 return this.getReps(2); 125 } 126 127 128 /** 129 * Returns a specific repetition of 130 * ODS-2: "Service Period" - creates it if necessary 131 * 132 * @param rep The repetition index (0-indexed) 133 */ 134 public CE getServicePeriod(int rep) { 135 CE retVal = this.getTypedField(2, rep); 136 return retVal; 137 } 138 139 /** 140 * Returns a specific repetition of 141 * ODS-2: "Service Period" - creates it if necessary 142 * 143 * @param rep The repetition index (0-indexed) 144 */ 145 public CE getOds2_ServicePeriod(int rep) { 146 CE retVal = this.getTypedField(2, rep); 147 return retVal; 148 } 149 150 /** 151 * Returns a count of the current number of repetitions of Service Period (ODS-2). 152 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 153 * it will return zero. 154 */ 155 public int getOds2_ServicePeriodReps() { 156 return this.getReps(2); 157 } 158 159 160 /** 161 * Inserts a repetition of 162 * ODS-2: "Service Period" at a specific index 163 * 164 * @param rep The repetition index (0-indexed) 165 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 166 */ 167 public CE insertServicePeriod(int rep) throws HL7Exception { 168 return (CE) super.insertRepetition(2, rep); 169 } 170 171 172 /** 173 * Inserts a repetition of 174 * ODS-2: "Service Period" at a specific index 175 * 176 * @param rep The repetition index (0-indexed) 177 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 178 */ 179 public CE insertOds2_ServicePeriod(int rep) throws HL7Exception { 180 return (CE) super.insertRepetition(2, rep); 181 } 182 183 184 /** 185 * Removes a repetition of 186 * ODS-2: "Service Period" at a specific index 187 * 188 * @param rep The repetition index (0-indexed) 189 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 190 */ 191 public CE removeServicePeriod(int rep) throws HL7Exception { 192 return (CE) super.removeRepetition(2, rep); 193 } 194 195 196 /** 197 * Removes a repetition of 198 * ODS-2: "Service Period" at a specific index 199 * 200 * @param rep The repetition index (0-indexed) 201 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 202 */ 203 public CE removeOds2_ServicePeriod(int rep) throws HL7Exception { 204 return (CE) super.removeRepetition(2, rep); 205 } 206 207 208 209 /** 210 * Returns all repetitions of Diet, Supplement, or Preference Code (ODS-3). 211 */ 212 public CE[] getDietSupplementOrPreferenceCode() { 213 CE[] retVal = this.getTypedField(3, new CE[0]); 214 return retVal; 215 } 216 217 218 /** 219 * Returns all repetitions of Diet, Supplement, or Preference Code (ODS-3). 220 */ 221 public CE[] getOds3_DietSupplementOrPreferenceCode() { 222 CE[] retVal = this.getTypedField(3, new CE[0]); 223 return retVal; 224 } 225 226 227 /** 228 * Returns a count of the current number of repetitions of Diet, Supplement, or Preference Code (ODS-3). 229 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 230 * it will return zero. 231 */ 232 public int getDietSupplementOrPreferenceCodeReps() { 233 return this.getReps(3); 234 } 235 236 237 /** 238 * Returns a specific repetition of 239 * ODS-3: "Diet, Supplement, or Preference Code" - creates it if necessary 240 * 241 * @param rep The repetition index (0-indexed) 242 */ 243 public CE getDietSupplementOrPreferenceCode(int rep) { 244 CE retVal = this.getTypedField(3, rep); 245 return retVal; 246 } 247 248 /** 249 * Returns a specific repetition of 250 * ODS-3: "Diet, Supplement, or Preference Code" - creates it if necessary 251 * 252 * @param rep The repetition index (0-indexed) 253 */ 254 public CE getOds3_DietSupplementOrPreferenceCode(int rep) { 255 CE retVal = this.getTypedField(3, rep); 256 return retVal; 257 } 258 259 /** 260 * Returns a count of the current number of repetitions of Diet, Supplement, or Preference Code (ODS-3). 261 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 262 * it will return zero. 263 */ 264 public int getOds3_DietSupplementOrPreferenceCodeReps() { 265 return this.getReps(3); 266 } 267 268 269 /** 270 * Inserts a repetition of 271 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 272 * 273 * @param rep The repetition index (0-indexed) 274 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 275 */ 276 public CE insertDietSupplementOrPreferenceCode(int rep) throws HL7Exception { 277 return (CE) super.insertRepetition(3, rep); 278 } 279 280 281 /** 282 * Inserts a repetition of 283 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 284 * 285 * @param rep The repetition index (0-indexed) 286 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 287 */ 288 public CE insertOds3_DietSupplementOrPreferenceCode(int rep) throws HL7Exception { 289 return (CE) super.insertRepetition(3, rep); 290 } 291 292 293 /** 294 * Removes a repetition of 295 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 296 * 297 * @param rep The repetition index (0-indexed) 298 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 299 */ 300 public CE removeDietSupplementOrPreferenceCode(int rep) throws HL7Exception { 301 return (CE) super.removeRepetition(3, rep); 302 } 303 304 305 /** 306 * Removes a repetition of 307 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 308 * 309 * @param rep The repetition index (0-indexed) 310 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 311 */ 312 public CE removeOds3_DietSupplementOrPreferenceCode(int rep) throws HL7Exception { 313 return (CE) super.removeRepetition(3, rep); 314 } 315 316 317 318 /** 319 * Returns all repetitions of Text Instruction (ODS-4). 320 */ 321 public ST[] getTextInstruction() { 322 ST[] retVal = this.getTypedField(4, new ST[0]); 323 return retVal; 324 } 325 326 327 /** 328 * Returns all repetitions of Text Instruction (ODS-4). 329 */ 330 public ST[] getOds4_TextInstruction() { 331 ST[] retVal = this.getTypedField(4, new ST[0]); 332 return retVal; 333 } 334 335 336 /** 337 * Returns a count of the current number of repetitions of Text Instruction (ODS-4). 338 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 339 * it will return zero. 340 */ 341 public int getTextInstructionReps() { 342 return this.getReps(4); 343 } 344 345 346 /** 347 * Returns a specific repetition of 348 * ODS-4: "Text Instruction" - creates it if necessary 349 * 350 * @param rep The repetition index (0-indexed) 351 */ 352 public ST getTextInstruction(int rep) { 353 ST retVal = this.getTypedField(4, rep); 354 return retVal; 355 } 356 357 /** 358 * Returns a specific repetition of 359 * ODS-4: "Text Instruction" - creates it if necessary 360 * 361 * @param rep The repetition index (0-indexed) 362 */ 363 public ST getOds4_TextInstruction(int rep) { 364 ST retVal = this.getTypedField(4, rep); 365 return retVal; 366 } 367 368 /** 369 * Returns a count of the current number of repetitions of Text Instruction (ODS-4). 370 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 371 * it will return zero. 372 */ 373 public int getOds4_TextInstructionReps() { 374 return this.getReps(4); 375 } 376 377 378 /** 379 * Inserts a repetition of 380 * ODS-4: "Text Instruction" at a specific index 381 * 382 * @param rep The repetition index (0-indexed) 383 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 384 */ 385 public ST insertTextInstruction(int rep) throws HL7Exception { 386 return (ST) super.insertRepetition(4, rep); 387 } 388 389 390 /** 391 * Inserts a repetition of 392 * ODS-4: "Text Instruction" at a specific index 393 * 394 * @param rep The repetition index (0-indexed) 395 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 396 */ 397 public ST insertOds4_TextInstruction(int rep) throws HL7Exception { 398 return (ST) super.insertRepetition(4, rep); 399 } 400 401 402 /** 403 * Removes a repetition of 404 * ODS-4: "Text Instruction" at a specific index 405 * 406 * @param rep The repetition index (0-indexed) 407 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 408 */ 409 public ST removeTextInstruction(int rep) throws HL7Exception { 410 return (ST) super.removeRepetition(4, rep); 411 } 412 413 414 /** 415 * Removes a repetition of 416 * ODS-4: "Text Instruction" at a specific index 417 * 418 * @param rep The repetition index (0-indexed) 419 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 420 */ 421 public ST removeOds4_TextInstruction(int rep) throws HL7Exception { 422 return (ST) super.removeRepetition(4, rep); 423 } 424 425 426 427 428 429 430 /** {@inheritDoc} */ 431 protected Type createNewTypeWithoutReflection(int field) { 432 switch (field) { 433 case 0: return new ID(getMessage(), new Integer( 159 )); 434 case 1: return new CE(getMessage()); 435 case 2: return new CE(getMessage()); 436 case 3: return new ST(getMessage()); 437 default: return null; 438 } 439 } 440 441 442} 443