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.v231.segment; 035 036// import ca.uhn.hl7v2.model.v231.group.*; 037import ca.uhn.hl7v2.model.v231.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 MSH message segment (MSH - message header segment). 049 * This segment has the following fields:</p> 050 * <ul> 051 * <li>MSH-1: Field Separator (ST) <b> </b> 052 * <li>MSH-2: Encoding Characters (ST) <b> </b> 053 * <li>MSH-3: Sending Application (HD) <b>optional </b> 054 * <li>MSH-4: Sending Facility (HD) <b>optional </b> 055 * <li>MSH-5: Receiving Application (HD) <b>optional </b> 056 * <li>MSH-6: Receiving Facility (HD) <b>optional </b> 057 * <li>MSH-7: Date/Time Of Message (TS) <b>optional </b> 058 * <li>MSH-8: Security (ST) <b>optional </b> 059 * <li>MSH-9: Message Type (MSG) <b> </b> 060 * <li>MSH-10: Message Control ID (ST) <b> </b> 061 * <li>MSH-11: Processing ID (PT) <b> </b> 062 * <li>MSH-12: Version ID (VID) <b> </b> 063 * <li>MSH-13: Sequence Number (NM) <b>optional </b> 064 * <li>MSH-14: Continuation Pointer (ST) <b>optional </b> 065 * <li>MSH-15: Accept Acknowledgment Type (ID) <b>optional </b> 066 * <li>MSH-16: Application Acknowledgment Type (ID) <b>optional </b> 067 * <li>MSH-17: Country Code (ID) <b>optional </b> 068 * <li>MSH-18: Character Set (ID) <b>optional repeating</b> 069 * <li>MSH-19: Principal Language Of Message (CE) <b>optional </b> 070 * <li>MSH-20: Alternate Character Set Handling Scheme (ID) <b>optional </b> 071 * </ul> 072 */ 073@SuppressWarnings("unused") 074public class MSH extends AbstractSegment { 075 076 /** 077 * Creates a new MSH segment 078 */ 079 public MSH(Group parent, ModelClassFactory factory) { 080 super(parent, factory); 081 init(factory); 082 } 083 084 private void init(ModelClassFactory factory) { 085 try { 086 this.add(ST.class, true, 1, 1, new Object[]{ getMessage() }, "Field Separator"); 087 this.add(ST.class, true, 1, 4, new Object[]{ getMessage() }, "Encoding Characters"); 088 this.add(HD.class, false, 1, 180, new Object[]{ getMessage() }, "Sending Application"); 089 this.add(HD.class, false, 1, 180, new Object[]{ getMessage() }, "Sending Facility"); 090 this.add(HD.class, false, 1, 180, new Object[]{ getMessage() }, "Receiving Application"); 091 this.add(HD.class, false, 1, 180, new Object[]{ getMessage() }, "Receiving Facility"); 092 this.add(TS.class, false, 1, 26, new Object[]{ getMessage() }, "Date/Time Of Message"); 093 this.add(ST.class, false, 1, 40, new Object[]{ getMessage() }, "Security"); 094 this.add(MSG.class, true, 1, 7, new Object[]{ getMessage() }, "Message Type"); 095 this.add(ST.class, true, 1, 20, new Object[]{ getMessage() }, "Message Control ID"); 096 this.add(PT.class, true, 1, 3, new Object[]{ getMessage() }, "Processing ID"); 097 this.add(VID.class, true, 1, 60, new Object[]{ getMessage() }, "Version ID"); 098 this.add(NM.class, false, 1, 15, new Object[]{ getMessage() }, "Sequence Number"); 099 this.add(ST.class, false, 1, 180, new Object[]{ getMessage() }, "Continuation Pointer"); 100 this.add(ID.class, false, 1, 2, new Object[]{ getMessage(), new Integer(155) }, "Accept Acknowledgment Type"); 101 this.add(ID.class, false, 1, 2, new Object[]{ getMessage(), new Integer(155) }, "Application Acknowledgment Type"); 102 this.add(ID.class, false, 1, 2, new Object[]{ getMessage(), new Integer(0) }, "Country Code"); 103 this.add(ID.class, false, 0, 16, new Object[]{ getMessage(), new Integer(211) }, "Character Set"); 104 this.add(CE.class, false, 1, 60, new Object[]{ getMessage() }, "Principal Language Of Message"); 105 this.add(ID.class, false, 1, 20, new Object[]{ getMessage(), new Integer(356) }, "Alternate Character Set Handling Scheme"); 106 } catch(HL7Exception e) { 107 log.error("Unexpected error creating MSH - this is probably a bug in the source code generator.", e); 108 } 109 } 110 111 112 113 /** 114 * Returns 115 * MSH-1: "Field Separator" - creates it if necessary 116 */ 117 public ST getFieldSeparator() { 118 ST retVal = this.getTypedField(1, 0); 119 return retVal; 120 } 121 122 /** 123 * Returns 124 * MSH-1: "Field Separator" - creates it if necessary 125 */ 126 public ST getMsh1_FieldSeparator() { 127 ST retVal = this.getTypedField(1, 0); 128 return retVal; 129 } 130 131 132 133 /** 134 * Returns 135 * MSH-2: "Encoding Characters" - creates it if necessary 136 */ 137 public ST getEncodingCharacters() { 138 ST retVal = this.getTypedField(2, 0); 139 return retVal; 140 } 141 142 /** 143 * Returns 144 * MSH-2: "Encoding Characters" - creates it if necessary 145 */ 146 public ST getMsh2_EncodingCharacters() { 147 ST retVal = this.getTypedField(2, 0); 148 return retVal; 149 } 150 151 152 153 /** 154 * Returns 155 * MSH-3: "Sending Application" - creates it if necessary 156 */ 157 public HD getSendingApplication() { 158 HD retVal = this.getTypedField(3, 0); 159 return retVal; 160 } 161 162 /** 163 * Returns 164 * MSH-3: "Sending Application" - creates it if necessary 165 */ 166 public HD getMsh3_SendingApplication() { 167 HD retVal = this.getTypedField(3, 0); 168 return retVal; 169 } 170 171 172 173 /** 174 * Returns 175 * MSH-4: "Sending Facility" - creates it if necessary 176 */ 177 public HD getSendingFacility() { 178 HD retVal = this.getTypedField(4, 0); 179 return retVal; 180 } 181 182 /** 183 * Returns 184 * MSH-4: "Sending Facility" - creates it if necessary 185 */ 186 public HD getMsh4_SendingFacility() { 187 HD retVal = this.getTypedField(4, 0); 188 return retVal; 189 } 190 191 192 193 /** 194 * Returns 195 * MSH-5: "Receiving Application" - creates it if necessary 196 */ 197 public HD getReceivingApplication() { 198 HD retVal = this.getTypedField(5, 0); 199 return retVal; 200 } 201 202 /** 203 * Returns 204 * MSH-5: "Receiving Application" - creates it if necessary 205 */ 206 public HD getMsh5_ReceivingApplication() { 207 HD retVal = this.getTypedField(5, 0); 208 return retVal; 209 } 210 211 212 213 /** 214 * Returns 215 * MSH-6: "Receiving Facility" - creates it if necessary 216 */ 217 public HD getReceivingFacility() { 218 HD retVal = this.getTypedField(6, 0); 219 return retVal; 220 } 221 222 /** 223 * Returns 224 * MSH-6: "Receiving Facility" - creates it if necessary 225 */ 226 public HD getMsh6_ReceivingFacility() { 227 HD retVal = this.getTypedField(6, 0); 228 return retVal; 229 } 230 231 232 233 /** 234 * Returns 235 * MSH-7: "Date/Time Of Message" - creates it if necessary 236 */ 237 public TS getDateTimeOfMessage() { 238 TS retVal = this.getTypedField(7, 0); 239 return retVal; 240 } 241 242 /** 243 * Returns 244 * MSH-7: "Date/Time Of Message" - creates it if necessary 245 */ 246 public TS getMsh7_DateTimeOfMessage() { 247 TS retVal = this.getTypedField(7, 0); 248 return retVal; 249 } 250 251 252 253 /** 254 * Returns 255 * MSH-8: "Security" - creates it if necessary 256 */ 257 public ST getSecurity() { 258 ST retVal = this.getTypedField(8, 0); 259 return retVal; 260 } 261 262 /** 263 * Returns 264 * MSH-8: "Security" - creates it if necessary 265 */ 266 public ST getMsh8_Security() { 267 ST retVal = this.getTypedField(8, 0); 268 return retVal; 269 } 270 271 272 273 /** 274 * Returns 275 * MSH-9: "Message Type" - creates it if necessary 276 */ 277 public MSG getMessageType() { 278 MSG retVal = this.getTypedField(9, 0); 279 return retVal; 280 } 281 282 /** 283 * Returns 284 * MSH-9: "Message Type" - creates it if necessary 285 */ 286 public MSG getMsh9_MessageType() { 287 MSG retVal = this.getTypedField(9, 0); 288 return retVal; 289 } 290 291 292 293 /** 294 * Returns 295 * MSH-10: "Message Control ID" - creates it if necessary 296 */ 297 public ST getMessageControlID() { 298 ST retVal = this.getTypedField(10, 0); 299 return retVal; 300 } 301 302 /** 303 * Returns 304 * MSH-10: "Message Control ID" - creates it if necessary 305 */ 306 public ST getMsh10_MessageControlID() { 307 ST retVal = this.getTypedField(10, 0); 308 return retVal; 309 } 310 311 312 313 /** 314 * Returns 315 * MSH-11: "Processing ID" - creates it if necessary 316 */ 317 public PT getProcessingID() { 318 PT retVal = this.getTypedField(11, 0); 319 return retVal; 320 } 321 322 /** 323 * Returns 324 * MSH-11: "Processing ID" - creates it if necessary 325 */ 326 public PT getMsh11_ProcessingID() { 327 PT retVal = this.getTypedField(11, 0); 328 return retVal; 329 } 330 331 332 333 /** 334 * Returns 335 * MSH-12: "Version ID" - creates it if necessary 336 */ 337 public VID getVersionID() { 338 VID retVal = this.getTypedField(12, 0); 339 return retVal; 340 } 341 342 /** 343 * Returns 344 * MSH-12: "Version ID" - creates it if necessary 345 */ 346 public VID getMsh12_VersionID() { 347 VID retVal = this.getTypedField(12, 0); 348 return retVal; 349 } 350 351 352 353 /** 354 * Returns 355 * MSH-13: "Sequence Number" - creates it if necessary 356 */ 357 public NM getSequenceNumber() { 358 NM retVal = this.getTypedField(13, 0); 359 return retVal; 360 } 361 362 /** 363 * Returns 364 * MSH-13: "Sequence Number" - creates it if necessary 365 */ 366 public NM getMsh13_SequenceNumber() { 367 NM retVal = this.getTypedField(13, 0); 368 return retVal; 369 } 370 371 372 373 /** 374 * Returns 375 * MSH-14: "Continuation Pointer" - creates it if necessary 376 */ 377 public ST getContinuationPointer() { 378 ST retVal = this.getTypedField(14, 0); 379 return retVal; 380 } 381 382 /** 383 * Returns 384 * MSH-14: "Continuation Pointer" - creates it if necessary 385 */ 386 public ST getMsh14_ContinuationPointer() { 387 ST retVal = this.getTypedField(14, 0); 388 return retVal; 389 } 390 391 392 393 /** 394 * Returns 395 * MSH-15: "Accept Acknowledgment Type" - creates it if necessary 396 */ 397 public ID getAcceptAcknowledgmentType() { 398 ID retVal = this.getTypedField(15, 0); 399 return retVal; 400 } 401 402 /** 403 * Returns 404 * MSH-15: "Accept Acknowledgment Type" - creates it if necessary 405 */ 406 public ID getMsh15_AcceptAcknowledgmentType() { 407 ID retVal = this.getTypedField(15, 0); 408 return retVal; 409 } 410 411 412 413 /** 414 * Returns 415 * MSH-16: "Application Acknowledgment Type" - creates it if necessary 416 */ 417 public ID getApplicationAcknowledgmentType() { 418 ID retVal = this.getTypedField(16, 0); 419 return retVal; 420 } 421 422 /** 423 * Returns 424 * MSH-16: "Application Acknowledgment Type" - creates it if necessary 425 */ 426 public ID getMsh16_ApplicationAcknowledgmentType() { 427 ID retVal = this.getTypedField(16, 0); 428 return retVal; 429 } 430 431 432 433 /** 434 * Returns 435 * MSH-17: "Country Code" - creates it if necessary 436 */ 437 public ID getCountryCode() { 438 ID retVal = this.getTypedField(17, 0); 439 return retVal; 440 } 441 442 /** 443 * Returns 444 * MSH-17: "Country Code" - creates it if necessary 445 */ 446 public ID getMsh17_CountryCode() { 447 ID retVal = this.getTypedField(17, 0); 448 return retVal; 449 } 450 451 452 /** 453 * Returns all repetitions of Character Set (MSH-18). 454 */ 455 public ID[] getCharacterSet() { 456 ID[] retVal = this.getTypedField(18, new ID[0]); 457 return retVal; 458 } 459 460 461 /** 462 * Returns all repetitions of Character Set (MSH-18). 463 */ 464 public ID[] getMsh18_CharacterSet() { 465 ID[] retVal = this.getTypedField(18, new ID[0]); 466 return retVal; 467 } 468 469 470 /** 471 * Returns a count of the current number of repetitions of Character Set (MSH-18). 472 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 473 * it will return zero. 474 */ 475 public int getCharacterSetReps() { 476 return this.getReps(18); 477 } 478 479 480 /** 481 * Returns a specific repetition of 482 * MSH-18: "Character Set" - creates it if necessary 483 * 484 * @param rep The repetition index (0-indexed) 485 */ 486 public ID getCharacterSet(int rep) { 487 ID retVal = this.getTypedField(18, rep); 488 return retVal; 489 } 490 491 /** 492 * Returns a specific repetition of 493 * MSH-18: "Character Set" - creates it if necessary 494 * 495 * @param rep The repetition index (0-indexed) 496 */ 497 public ID getMsh18_CharacterSet(int rep) { 498 ID retVal = this.getTypedField(18, rep); 499 return retVal; 500 } 501 502 /** 503 * Returns a count of the current number of repetitions of Character Set (MSH-18). 504 * This method does not create a repetition, so if no repetitions have currently been defined or accessed, 505 * it will return zero. 506 */ 507 public int getMsh18_CharacterSetReps() { 508 return this.getReps(18); 509 } 510 511 512 /** 513 * Inserts a repetition of 514 * MSH-18: "Character Set" at a specific index 515 * 516 * @param rep The repetition index (0-indexed) 517 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 518 */ 519 public ID insertCharacterSet(int rep) throws HL7Exception { 520 return (ID) super.insertRepetition(18, rep); 521 } 522 523 524 /** 525 * Inserts a repetition of 526 * MSH-18: "Character Set" at a specific index 527 * 528 * @param rep The repetition index (0-indexed) 529 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 530 */ 531 public ID insertMsh18_CharacterSet(int rep) throws HL7Exception { 532 return (ID) super.insertRepetition(18, rep); 533 } 534 535 536 /** 537 * Removes a repetition of 538 * MSH-18: "Character Set" at a specific index 539 * 540 * @param rep The repetition index (0-indexed) 541 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 542 */ 543 public ID removeCharacterSet(int rep) throws HL7Exception { 544 return (ID) super.removeRepetition(18, rep); 545 } 546 547 548 /** 549 * Removes a repetition of 550 * MSH-18: "Character Set" at a specific index 551 * 552 * @param rep The repetition index (0-indexed) 553 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) 554 */ 555 public ID removeMsh18_CharacterSet(int rep) throws HL7Exception { 556 return (ID) super.removeRepetition(18, rep); 557 } 558 559 560 561 562 /** 563 * Returns 564 * MSH-19: "Principal Language Of Message" - creates it if necessary 565 */ 566 public CE getPrincipalLanguageOfMessage() { 567 CE retVal = this.getTypedField(19, 0); 568 return retVal; 569 } 570 571 /** 572 * Returns 573 * MSH-19: "Principal Language Of Message" - creates it if necessary 574 */ 575 public CE getMsh19_PrincipalLanguageOfMessage() { 576 CE retVal = this.getTypedField(19, 0); 577 return retVal; 578 } 579 580 581 582 /** 583 * Returns 584 * MSH-20: "Alternate Character Set Handling Scheme" - creates it if necessary 585 */ 586 public ID getAlternateCharacterSetHandlingScheme() { 587 ID retVal = this.getTypedField(20, 0); 588 return retVal; 589 } 590 591 /** 592 * Returns 593 * MSH-20: "Alternate Character Set Handling Scheme" - creates it if necessary 594 */ 595 public ID getMsh20_AlternateCharacterSetHandlingScheme() { 596 ID retVal = this.getTypedField(20, 0); 597 return retVal; 598 } 599 600 601 602 603 604 /** {@inheritDoc} */ 605 protected Type createNewTypeWithoutReflection(int field) { 606 switch (field) { 607 case 0: return new ST(getMessage()); 608 case 1: return new ST(getMessage()); 609 case 2: return new HD(getMessage()); 610 case 3: return new HD(getMessage()); 611 case 4: return new HD(getMessage()); 612 case 5: return new HD(getMessage()); 613 case 6: return new TS(getMessage()); 614 case 7: return new ST(getMessage()); 615 case 8: return new MSG(getMessage()); 616 case 9: return new ST(getMessage()); 617 case 10: return new PT(getMessage()); 618 case 11: return new VID(getMessage()); 619 case 12: return new NM(getMessage()); 620 case 13: return new ST(getMessage()); 621 case 14: return new ID(getMessage(), new Integer( 155 )); 622 case 15: return new ID(getMessage(), new Integer( 155 )); 623 case 16: return new ID(getMessage(), new Integer( 0 )); 624 case 17: return new ID(getMessage(), new Integer( 211 )); 625 case 18: return new CE(getMessage()); 626 case 19: return new ID(getMessage(), new Integer( 356 )); 627 default: return null; 628 } 629 } 630 631 632} 633