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.v27.segment; 035 036// import ca.uhn.hl7v2.model.v27.group.*; 037import ca.uhn.hl7v2.model.v27.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/** 049 *<p>Represents an HL7 ODS message segment (Dietary Orders, Supplements, and Preferences). 050 * This segment has the following fields:</p> 051 * <ul> 052 * <li>ODS-1: Type (ID) <b> </b> 053 * <li>ODS-2: Service Period (CWE) <b>optional repeating</b> 054 * <li>ODS-3: Diet, Supplement, or Preference Code (CWE) <b> repeating</b> 055 * <li>ODS-4: Text Instruction (ST) <b>optional repeating</b> 056 * </ul> 057 */ 058@SuppressWarnings("unused") 059public class ODS extends AbstractSegment { 060 061 /** 062 * Creates a new ODS segment 063 */ 064 public ODS(Group parent, ModelClassFactory factory) { 065 super(parent, factory); 066 init(factory); 067 } 068 069 private void init(ModelClassFactory factory) { 070 try { 071 this.add(ID.class, true, 1, 1, new Object[]{ getMessage(), new Integer(159) }, "Type"); 072 this.add(CWE.class, false, 10, 0, new Object[]{ getMessage() }, "Service Period"); 073 this.add(CWE.class, true, 20, 0, new Object[]{ getMessage() }, "Diet, Supplement, or Preference Code"); 074 this.add(ST.class, false, 2, 0, new Object[]{ getMessage() }, "Text Instruction"); 075 } catch(HL7Exception e) { 076 log.error("Unexpected error creating ODS - this is probably a bug in the source code generator.", e); 077 } 078 } 079 080 081 082 /** 083 * Returns 084 * ODS-1: "Type" - creates it if necessary 085 */ 086 public ID getType() { 087 ID retVal = this.getTypedField(1, 0); 088 return retVal; 089 } 090 091 /** 092 * Returns 093 * ODS-1: "Type" - creates it if necessary 094 */ 095 public ID getOds1_Type() { 096 ID retVal = this.getTypedField(1, 0); 097 return retVal; 098 } 099 100 101 /** 102 * Returns all repetitions of Service Period (ODS-2). 103 */ 104 public CWE[] getServicePeriod() { 105 CWE[] retVal = this.getTypedField(2, new CWE[0]); 106 return retVal; 107 } 108 109 110 /** 111 * Returns all repetitions of Service Period (ODS-2). 112 */ 113 public CWE[] getOds2_ServicePeriod() { 114 CWE[] retVal = this.getTypedField(2, new CWE[0]); 115 return retVal; 116 } 117 118 119 /** 120 * Returns a count of the current number of repetitions of Service Period (ODS-2). 121 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 122 * it will return zero. 123 */ 124 public int getServicePeriodReps() { 125 return this.getReps(2); 126 } 127 128 129 /** 130 * Returns a specific repetition of 131 * ODS-2: "Service Period" - creates it if necessary 132 * 133 * @param rep The repetition index (0-indexed) 134 */ 135 public CWE getServicePeriod(int rep) { 136 CWE retVal = this.getTypedField(2, rep); 137 return retVal; 138 } 139 140 /** 141 * Returns a specific repetition of 142 * ODS-2: "Service Period" - creates it if necessary 143 * 144 * @param rep The repetition index (0-indexed) 145 */ 146 public CWE getOds2_ServicePeriod(int rep) { 147 CWE retVal = this.getTypedField(2, rep); 148 return retVal; 149 } 150 151 /** 152 * Returns a count of the current number of repetitions of Service Period (ODS-2). 153 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 154 * it will return zero. 155 */ 156 public int getOds2_ServicePeriodReps() { 157 return this.getReps(2); 158 } 159 160 161 /** 162 * Inserts a repetition of 163 * ODS-2: "Service Period" at a specific index 164 * 165 * @param rep The repetition index (0-indexed) 166 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 167 */ 168 public CWE insertServicePeriod(int rep) throws HL7Exception { 169 return (CWE) super.insertRepetition(2, rep); 170 } 171 172 173 /** 174 * Inserts a repetition of 175 * ODS-2: "Service Period" at a specific index 176 * 177 * @param rep The repetition index (0-indexed) 178 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 179 */ 180 public CWE insertOds2_ServicePeriod(int rep) throws HL7Exception { 181 return (CWE) super.insertRepetition(2, rep); 182 } 183 184 185 /** 186 * Removes a repetition of 187 * ODS-2: "Service Period" at a specific index 188 * 189 * @param rep The repetition index (0-indexed) 190 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 191 */ 192 public CWE removeServicePeriod(int rep) throws HL7Exception { 193 return (CWE) super.removeRepetition(2, rep); 194 } 195 196 197 /** 198 * Removes a repetition of 199 * ODS-2: "Service Period" at a specific index 200 * 201 * @param rep The repetition index (0-indexed) 202 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 203 */ 204 public CWE removeOds2_ServicePeriod(int rep) throws HL7Exception { 205 return (CWE) super.removeRepetition(2, rep); 206 } 207 208 209 210 /** 211 * Returns all repetitions of Diet, Supplement, or Preference Code (ODS-3). 212 */ 213 public CWE[] getDietSupplementOrPreferenceCode() { 214 CWE[] retVal = this.getTypedField(3, new CWE[0]); 215 return retVal; 216 } 217 218 219 /** 220 * Returns all repetitions of Diet, Supplement, or Preference Code (ODS-3). 221 */ 222 public CWE[] getOds3_DietSupplementOrPreferenceCode() { 223 CWE[] retVal = this.getTypedField(3, new CWE[0]); 224 return retVal; 225 } 226 227 228 /** 229 * Returns a count of the current number of repetitions of Diet, Supplement, or Preference Code (ODS-3). 230 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 231 * it will return zero. 232 */ 233 public int getDietSupplementOrPreferenceCodeReps() { 234 return this.getReps(3); 235 } 236 237 238 /** 239 * Returns a specific repetition of 240 * ODS-3: "Diet, Supplement, or Preference Code" - creates it if necessary 241 * 242 * @param rep The repetition index (0-indexed) 243 */ 244 public CWE getDietSupplementOrPreferenceCode(int rep) { 245 CWE retVal = this.getTypedField(3, rep); 246 return retVal; 247 } 248 249 /** 250 * Returns a specific repetition of 251 * ODS-3: "Diet, Supplement, or Preference Code" - creates it if necessary 252 * 253 * @param rep The repetition index (0-indexed) 254 */ 255 public CWE getOds3_DietSupplementOrPreferenceCode(int rep) { 256 CWE retVal = this.getTypedField(3, rep); 257 return retVal; 258 } 259 260 /** 261 * Returns a count of the current number of repetitions of Diet, Supplement, or Preference Code (ODS-3). 262 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 263 * it will return zero. 264 */ 265 public int getOds3_DietSupplementOrPreferenceCodeReps() { 266 return this.getReps(3); 267 } 268 269 270 /** 271 * Inserts a repetition of 272 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 273 * 274 * @param rep The repetition index (0-indexed) 275 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 276 */ 277 public CWE insertDietSupplementOrPreferenceCode(int rep) throws HL7Exception { 278 return (CWE) super.insertRepetition(3, rep); 279 } 280 281 282 /** 283 * Inserts a repetition of 284 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 285 * 286 * @param rep The repetition index (0-indexed) 287 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 288 */ 289 public CWE insertOds3_DietSupplementOrPreferenceCode(int rep) throws HL7Exception { 290 return (CWE) super.insertRepetition(3, rep); 291 } 292 293 294 /** 295 * Removes a repetition of 296 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 297 * 298 * @param rep The repetition index (0-indexed) 299 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 300 */ 301 public CWE removeDietSupplementOrPreferenceCode(int rep) throws HL7Exception { 302 return (CWE) super.removeRepetition(3, rep); 303 } 304 305 306 /** 307 * Removes a repetition of 308 * ODS-3: "Diet, Supplement, or Preference Code" at a specific index 309 * 310 * @param rep The repetition index (0-indexed) 311 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 312 */ 313 public CWE removeOds3_DietSupplementOrPreferenceCode(int rep) throws HL7Exception { 314 return (CWE) super.removeRepetition(3, rep); 315 } 316 317 318 319 /** 320 * Returns all repetitions of Text Instruction (ODS-4). 321 */ 322 public ST[] getTextInstruction() { 323 ST[] retVal = this.getTypedField(4, new ST[0]); 324 return retVal; 325 } 326 327 328 /** 329 * Returns all repetitions of Text Instruction (ODS-4). 330 */ 331 public ST[] getOds4_TextInstruction() { 332 ST[] retVal = this.getTypedField(4, new ST[0]); 333 return retVal; 334 } 335 336 337 /** 338 * Returns a count of the current number of repetitions of Text Instruction (ODS-4). 339 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 340 * it will return zero. 341 */ 342 public int getTextInstructionReps() { 343 return this.getReps(4); 344 } 345 346 347 /** 348 * Returns a specific repetition of 349 * ODS-4: "Text Instruction" - creates it if necessary 350 * 351 * @param rep The repetition index (0-indexed) 352 */ 353 public ST getTextInstruction(int rep) { 354 ST retVal = this.getTypedField(4, rep); 355 return retVal; 356 } 357 358 /** 359 * Returns a specific repetition of 360 * ODS-4: "Text Instruction" - creates it if necessary 361 * 362 * @param rep The repetition index (0-indexed) 363 */ 364 public ST getOds4_TextInstruction(int rep) { 365 ST retVal = this.getTypedField(4, rep); 366 return retVal; 367 } 368 369 /** 370 * Returns a count of the current number of repetitions of Text Instruction (ODS-4). 371 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 372 * it will return zero. 373 */ 374 public int getOds4_TextInstructionReps() { 375 return this.getReps(4); 376 } 377 378 379 /** 380 * Inserts a repetition of 381 * ODS-4: "Text Instruction" at a specific index 382 * 383 * @param rep The repetition index (0-indexed) 384 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 385 */ 386 public ST insertTextInstruction(int rep) throws HL7Exception { 387 return (ST) super.insertRepetition(4, rep); 388 } 389 390 391 /** 392 * Inserts a repetition of 393 * ODS-4: "Text Instruction" at a specific index 394 * 395 * @param rep The repetition index (0-indexed) 396 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 397 */ 398 public ST insertOds4_TextInstruction(int rep) throws HL7Exception { 399 return (ST) super.insertRepetition(4, rep); 400 } 401 402 403 /** 404 * Removes a repetition of 405 * ODS-4: "Text Instruction" at a specific index 406 * 407 * @param rep The repetition index (0-indexed) 408 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 409 */ 410 public ST removeTextInstruction(int rep) throws HL7Exception { 411 return (ST) super.removeRepetition(4, rep); 412 } 413 414 415 /** 416 * Removes a repetition of 417 * ODS-4: "Text Instruction" at a specific index 418 * 419 * @param rep The repetition index (0-indexed) 420 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 421 */ 422 public ST removeOds4_TextInstruction(int rep) throws HL7Exception { 423 return (ST) super.removeRepetition(4, rep); 424 } 425 426 427 428 429 430 431 /** {@inheritDoc} */ 432 protected Type createNewTypeWithoutReflection(int field) { 433 switch (field) { 434 case 0: return new ID(getMessage(), new Integer( 159 )); 435 case 1: return new CWE(getMessage()); 436 case 2: return new CWE(getMessage()); 437 case 3: return new ST(getMessage()); 438 default: return null; 439 } 440 } 441 442 443} 444