ca.uhn.hl7v2.util
Class FileCodeMapper

java.lang.Object
  extended by ca.uhn.hl7v2.util.CodeMapper
      extended by ca.uhn.hl7v2.util.FileCodeMapper

public class FileCodeMapper
extends CodeMapper

Implements CodeMapper using files to store code values. Files are arranged in the following directory structure. The base directory is called "codemap". This should be created under the hapi.home directory (see Home class; defaults to .). Under the base directory, there should be one directory for each interface, and each of these directories should be named after the interface. For example if you had interfaces to pharmacy and lab systems you might have the following directories:

/codemap/pharmacy
/codemap/lab

Each directory should contain two files per HL7 table, named after the table numbers as follows: "hl7nnnn.li" and "hl7nnnn.il", where nnnn is the 4 digit table number. The .il file contains maps from interface codes to local codes, and the .li file contains maps from local codes to interface codes (these unfortunately may not be symmetrical).

Each line of a file contains a single code map, with the "from" value and the "to" value separated by a tab. For example, the file /lab/HL70001.li (to map local codes to interface codes for the HL7 admnistrative sex table in your lab system interface) might contain the following line:

male&tab;M

This means that the local code "male" maps to the interface code "M".

Lines that start with "//" are treated as comments.

Author:
Bryan Tripp

Constructor Summary
FileCodeMapper()
          Creates a new instance of FileCodeMapper.
 
Method Summary
 java.lang.String getInterfaceCode(java.lang.String interfaceName, int hl7Table, java.lang.String localCode)
          Returns the interface code for the given local code, for use in the context of the given interface.
 java.lang.String getLocalCode(java.lang.String interfaceName, int hl7Table, java.lang.String interfaceCode)
          Returns the local code for the given interface code as it appears in the given interface.
static void main(java.lang.String[] args)
          Test harness.
 void refreshCache()
          If values are cached in such a way that they are not guaranteed to be current, a call to this method refreshes the values.
 void throwExceptionIfNoMatch(boolean throwException)
          Determines what happens if no matching code is found during a lookup.
 
Methods inherited from class ca.uhn.hl7v2.util.CodeMapper
getInstance, getInt, getLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCodeMapper

public FileCodeMapper()
               throws HL7Exception
Creates a new instance of FileCodeMapper. You should probably not construct a FileCodeMapper directly. Use CodeMapper.getInstance() instead ... this will ensure that only a single instance is created, which is important for performance because code maps are loaded from disk every time this constructor is called.

Throws:
HL7Exception
Method Detail

refreshCache

public void refreshCache()
                  throws HL7Exception
If values are cached in such a way that they are not guaranteed to be current, a call to this method refreshes the values.

Specified by:
refreshCache in class CodeMapper
Throws:
HL7Exception

getLocalCode

public java.lang.String getLocalCode(java.lang.String interfaceName,
                                     int hl7Table,
                                     java.lang.String interfaceCode)
                              throws HL7Exception
Returns the local code for the given interface code as it appears in the given interface.

Specified by:
getLocalCode in class CodeMapper
Throws:
HL7Exception

getInterfaceCode

public java.lang.String getInterfaceCode(java.lang.String interfaceName,
                                         int hl7Table,
                                         java.lang.String localCode)
                                  throws HL7Exception
Returns the interface code for the given local code, for use in the context of the given interface.

Specified by:
getInterfaceCode in class CodeMapper
Throws:
HL7Exception

throwExceptionIfNoMatch

public void throwExceptionIfNoMatch(boolean throwException)
Determines what happens if no matching code is found during a lookup. If set to true, an HL7Exception is thrown if there is no match. If false, null is returned. The default is false.

Specified by:
throwExceptionIfNoMatch in class CodeMapper

main

public static void main(java.lang.String[] args)
Test harness.



Copyright © 2001-2011 University Health Network. All Rights Reserved.