001    package org.vmdb.hl7;
002    
003    /**
004     * <p><Title:> Extended Composite ID with Check Digit (CX) 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 CXElement extends HL7Element {
016       private String sNm = "CX";
017       private String sRl = "ST[ST][ID][HD][IS][HD]";
018    
019       /**
020        * Construct a Composite ID 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 CXElement( int iLevel ) {
025          super( iLevel );
026          setName( sNm );
027          setRule( sRl );
028          setType( "CX" );
029       }
030    
031       /**
032        * Construct a Composite ID Element using the default name and type constants
033        * at the default level FIELD.
034        */
035       public CXElement() {
036          super( FIELD );
037          setName( sNm );
038          setRule( sRl );
039          setType( "CX" );
040       }
041    
042       public void setIdentifier( String sId ) {
043          HL7Element e = new SimpleElement( iLevel + 1 );
044          e.setType( "ST" );
045          e.setName( "CX.1" );
046          e.setValue( sId );
047          try {
048             setComponent( e, 1 );
049          } catch( MalformedFieldException mfe ) {
050             mfe.printStackTrace();
051          }
052       }
053    
054       public String getIdentifier() {
055          HL7Element e = getComponent( 1 );
056          if( e != null )
057             return e.toString();
058          else
059             return "";
060       }
061    
062       public void setCheckDigit( String sCheckDigit ) {
063          HL7Element e = new SimpleElement( iLevel + 1 );
064          e.setType( "ST" );
065          e.setName( "CX.2" );
066          e.setValue( sCheckDigit );
067          try {
068             setComponent( e, 2 );
069          } catch( MalformedFieldException mfe ) {
070             mfe.printStackTrace();
071          }
072       }
073    
074       public String getCheckDigit() {
075          HL7Element e = getComponent( 2 );
076          if( e != null )
077             return e.toString();
078          else
079             return "";
080       }
081    
082       public void setCheckDigitSystem( String sCheckDigitSystem ) {
083          HL7Element e = new SimpleElement( iLevel + 1 );
084          e.setType( "ST" );
085          e.setName( "CX.3" );
086          e.setValue( sCheckDigitSystem );
087          try {
088             setComponent( e, 3 );
089          } catch( MalformedFieldException mfe ) {
090             mfe.printStackTrace();
091          }
092       }
093    
094       public String getCheckDigitSystem() {
095          HL7Element e = getComponent( 3 );
096          if( e != null )
097             return e.toString();
098          else
099             return "";
100       }
101    
102       /**
103        * Set just the namespace id of the assigning authority.<br><br>
104        * This is a convenience method to allow simple assigner identification via
105        * one-field CX's.
106        * @param sNamespaceId String name of assigning authority
107        */
108       public void setAssigningAuthorityName( String sNamespaceId ) {
109          HDElement e = new HDElement( iLevel + 1 );
110          e.setNamespaceId( sNamespaceId );
111          e.setName( "CX.4" );
112          try {
113             setComponent( e, 4 );
114          } catch( MalformedFieldException mfe ) {
115             mfe.printStackTrace();
116          }
117       }
118    
119       /**
120        * Set the assigning authority from the individual components of an HD Element.<br><br>
121        * This is a convenience method to automatically build the HD Element required here.
122        * @param sNamespaceId String name of assigning authority
123        * @param sUniveralId String with identifier of assigning authority
124        * @param sIdType String with the identifier type of the assigner's identifier
125        */
126       public void setAssigningAuthority( String sNamespaceId,
127                                          String sUniversalId,
128                                          String sIdType ) {
129          HDElement e = new HDElement( iLevel + 1 );
130          e.setNamespaceId( sNamespaceId );
131          e.setUniversalId( sUniversalId );
132          e.setUniversalIdType( sIdType );
133          e.setName( "CX.4" );
134          try {
135             setComponent( e, 4 );
136          } catch( MalformedFieldException mfe ) {
137             mfe.printStackTrace();
138          }
139       }
140    
141       public void setAssigningAuthority( HDElement hdE ) {
142          hdE.setName( "CX.4" );
143          try {
144             setComponent( hdE, 4 );
145          } catch( MalformedFieldException mfe ) {
146             mfe.printStackTrace();
147          }
148       }
149    
150       public HDElement getAssigningAuthority() {
151          return (HDElement)getComponent( 4 );
152       }
153    
154       public String getAssigningAuthorityName() {
155          HDElement hde = (HDElement)getComponent( 4 );
156          if( hde != null )
157             return hde.getNamespaceId();
158          else
159             return "";
160       }
161    
162       public String getAssigningAuthorityId() {
163          HDElement hde = (HDElement)getComponent( 4 );
164          if( hde != null )
165             return hde.getUniversalId();
166          else
167             return "";
168       }
169    
170       public void setIdentifierTypeCode( String sIdentifierTypeCode ) {
171          HL7Element e = new SimpleElement( iLevel + 1 );
172          e.setType( "ST" );
173          e.setName( "CX.5" );
174          e.setValue( sIdentifierTypeCode );
175          try {
176             setComponent( e, 5 );
177          } catch( MalformedFieldException mfe ) {
178             mfe.printStackTrace();
179          }
180       }
181    
182       public String getIdentifierTypeCode() {
183          HL7Element e = getComponent( 5 );
184          if( e != null )
185             return e.toString();
186          else
187             return "";
188       }
189    
190       /**
191        * Set just the namespace id of the assigning facility.<br><br>
192        * This is a convenience method to allow simple assigner identification via
193        * one-field CX's.
194        * @param sNamespaceId String name of assigning facility
195        */
196       public void setAssigningFacilityName( String sNamespaceId ) {
197          HDElement e = new HDElement( iLevel + 1 );
198          e.setNamespaceId( sNamespaceId );
199          e.setName( "CX.6" );
200          try {
201             setComponent( e, 6 );
202          } catch( MalformedFieldException mfe ) {
203             mfe.printStackTrace();
204          }
205       }
206    
207       /**
208        * Set the assigning facility from the individual components of an HD Element.<br><br>
209        * This is a convenience method to automatically build the HD Element required here.
210        * @param sNamespaceId String name of assigning facility
211        * @param sUniveralId String with identifier of assigning facility
212        * @param sIdType String with the identifier type of the assigner's identifier
213        */
214       public void setAssigningFacility( String sNamespaceId,
215                                          String sUniversalId,
216                                          String sIdType ) {
217          HDElement e = new HDElement( iLevel + 1 );
218          e.setNamespaceId( sNamespaceId );
219          e.setUniversalId( sUniversalId );
220          e.setUniversalIdType( sIdType );
221          e.setName( "CX.6" );
222          try {
223             setComponent( e, 6 );
224          } catch( MalformedFieldException mfe ) {
225             mfe.printStackTrace();
226          }
227       }
228    
229       public void setAssigningFacility( HDElement hdE ) {
230          hdE.setName( "CX.6" );
231          try {
232             setComponent( hdE, 6 );
233          } catch( MalformedFieldException mfe ) {
234             mfe.printStackTrace();
235          }
236       }
237    
238       public HDElement getAssigningFacility() {
239          return (HDElement)getComponent( 6 );
240       }
241    
242       public String getAssigningFacilityName() {
243          HDElement hde = (HDElement)getComponent( 6 );
244          if( hde != null )
245             return hde.getNamespaceId();
246          else
247             return "";
248       }
249    
250       public String getAssigningFacilityId() {
251          HDElement hde = (HDElement)getComponent( 6 );
252          if( hde != null )
253             return hde.getUniversalId();
254          else
255             return "";
256       }
257    
258    }// End class CXElement