001 package org.vmdb.hl7; 002 003 /** 004 * <p><Title:> Composite Message Type Element. </p> 005 * <p>Description: HL7 Network Connectivity For VMDB. </p> 006 * <p>Copyright: Copyright (c) 2002-2003. </p> 007 * <p>Company: Veterinary Medical Database (VMDB). </p> 008 * <p>Note: This element is only used in MSH to identify the specific message. 009 * As such it will probably <i>only</i> be used in implementation of classes 010 * that override HL7Message to implement specific message types. 011 * @author Michael K. Martin 012 * @version 1.0 013 */ 014 015 public class MSGElement extends HL7Element { 016 private String sNm = "MSG"; 017 private String sRl = "ST ST[ST]"; 018 019 /** 020 * Construct a composite message type element using the default name and type constants 021 * at the default level FIELD. 022 */ 023 public MSGElement() { 024 super( FIELD ); 025 setName( sNm ); 026 setRule( sRl ); 027 setType( "MSG" ); 028 } 029 030 /** 031 * Set the general type of the message. 032 * @param sMsgType String with message type abbreviation such as "ORU" or "ACK" 033 */ 034 public void setMsgType( String sMsgType ) { 035 HL7Element e = new SimpleElement( iLevel + 1 ); 036 e.setType( "ST" ); 037 e.setName( "MSG.1" ); 038 e.setValue( sMsgType ); 039 try { 040 setComponent( e, 1 ); 041 } catch( MalformedFieldException mfe ) { 042 mfe.printStackTrace(); 043 } 044 } 045 046 /** 047 * Get the general type of the message. 048 * @return String with message type abbreviation such as "ORU" or "ACK" 049 */ 050 public String getMsgType() { 051 HL7Element e = getComponent( 1 ); 052 if( e != null ) 053 return e.toString(); 054 else 055 return ""; 056 } 057 058 /** 059 * Set the event type that triggers the message. 060 * @param sEventType String with event type abbreviation such as "R01" 061 */ 062 public void setEventType( String sEventType ) { 063 HL7Element e = new SimpleElement( iLevel + 1 ); 064 e.setType( "ST" ); 065 e.setName( "MSG.2" ); 066 e.setValue( sEventType ); 067 try { 068 setComponent( e, 2 ); 069 } catch( MalformedFieldException mfe ) { 070 mfe.printStackTrace(); 071 } 072 } 073 074 /** 075 * Get the event type that triggers the message. 076 * @return String with event type abbreviation such as "R01" 077 */ 078 public String getEventType() { 079 HL7Element e = getComponent( 2 ); 080 if( e != null ) 081 return e.toString(); 082 else 083 return ""; 084 } 085 086 /** 087 * Set the structure code of the message. 088 * @param sMsgVersion String with message structure 089 */ 090 public void setMsgStructure( String sMsgStructure ) { 091 HL7Element e = new SimpleElement( iLevel + 1 ); 092 e.setType( "ST" ); 093 e.setName( "MSG.3" ); 094 e.setValue( sMsgStructure ); 095 try { 096 setComponent( e, 3 ); 097 } catch( MalformedFieldException mfe ) { 098 mfe.printStackTrace(); 099 } 100 } 101 102 /** 103 * Get the structure code of the message. 104 * @return String with message structure code 105 */ 106 public String getMsgStructure() { 107 HL7Element e = getComponent( 2 ); 108 if( e != null ) 109 return e.toString(); 110 else 111 return ""; 112 } 113 114 } // End class MSG Element