Class FileCodeMapper
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:
<hapi.home>/codemap/pharmacy
<hapi.home>/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 <hapi.home>/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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetInterfaceCode(String interfaceName, int hl7Table, String localCode) Returns the interface code for the given local code, for use in the context of the given interface.getLocalCode(String interfaceName, int hl7Table, String interfaceCode) Returns the local code for the given interface code as it appears in the given interface.static voidTest harness.voidIf values are cached in such a way that they are not guaranteed to be current, a call to this method refreshes the values.voidthrowExceptionIfNoMatch(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
-
Constructor Details
-
FileCodeMapper
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 Details
-
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.- Specified by:
refreshCachein classCodeMapper- Throws:
HL7Exception
-
getLocalCode
public String getLocalCode(String interfaceName, int hl7Table, String interfaceCode) throws HL7Exception Returns the local code for the given interface code as it appears in the given interface.- Specified by:
getLocalCodein classCodeMapper- Throws:
HL7Exception
-
getInterfaceCode
public String getInterfaceCode(String interfaceName, int hl7Table, String localCode) throws HL7Exception Returns the interface code for the given local code, for use in the context of the given interface.- Specified by:
getInterfaceCodein classCodeMapper- Throws:
HL7Exception
-
throwExceptionIfNoMatch
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:
throwExceptionIfNoMatchin classCodeMapper
-
main
Test harness.
-