001 package org.vmdb.hl7; 002 003 /** 004 * <p><Title:> Hierarchic Designator (HD) 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>The method names follow the convention established by other Element type 009 * classes. Names follow the HL7 documentation.</p> 010 * <p>See the HL7 documentation for an explanation of each component.</p> 011 * @author Michael K. Martin 012 * @version 1.0 013 */ 014 015 public class HDElement extends HL7Element { 016 private String sNm = "HD"; 017 private String sRl = "IS[ST][ID]"; 018 019 /** 020 * Construct a Hierarchic Designator Element using the default name and type constants. 021 * @param iLevel One of the constants for specifying level as FIELD, COMPONENT, or 022 * SUBCOMPONENT. Default FIELD. 023 */ 024 public HDElement( int iLevel ) { 025 super( iLevel ); 026 setName( sNm ); 027 setRule( sRl ); 028 setType( "HD" ); 029 } 030 031 /** 032 * Construct a Hierarchic Designator Element using the default name and type constants 033 * at the default level FIELD. 034 */ 035 public HDElement() { 036 super( FIELD ); 037 setName( sNm ); 038 setRule( sRl ); 039 setType( "HD" ); 040 } 041 042 public void setNamespaceId( String sNamespaceId ) { 043 HL7Element e = new SimpleElement( iLevel + 1 ); 044 e.setType( "IS" ); 045 e.setName( "HD.1" ); 046 e.setValue( sNamespaceId ); 047 try { 048 setComponent( e, 1 ); 049 } catch( MalformedFieldException mfe ) { 050 mfe.printStackTrace(); 051 } 052 } 053 054 public String getNamespaceId() { 055 HL7Element e = getComponent( 1 ); 056 if( e != null ) 057 return e.toString(); 058 else 059 return ""; 060 } 061 062 public void setUniversalId( String sUniversalId ) { 063 HL7Element e = new SimpleElement( iLevel + 1 ); 064 e.setType( "ST" ); 065 e.setName( "HD.2" ); 066 e.setValue( sUniversalId ); 067 try { 068 setComponent( e, 2 ); 069 } catch( MalformedFieldException mfe ) { 070 mfe.printStackTrace(); 071 } 072 } 073 074 public String getUniversalId() { 075 HL7Element e = getComponent( 2 ); 076 if( e != null ) 077 return e.toString(); 078 else 079 return ""; 080 } 081 082 public void setUniversalIdType( String sIdType ) { 083 HL7Element e = new SimpleElement( iLevel + 1 ); 084 e.setType( "ID" ); 085 e.setName( "HD.3" ); 086 e.setValue( sIdType ); 087 try { 088 setComponent( e, 3 ); 089 } catch( MalformedFieldException mfe ) { 090 mfe.printStackTrace(); 091 } 092 } 093 094 public String getUniversalIdType() { 095 HL7Element e = getComponent( 3 ); 096 if( e != null ) 097 return e.toString(); 098 else 099 return ""; 100 } 101 102 } // End class HDElement 103