org.openmrs.hl7
Class HL7Util

java.lang.Object
  extended by org.openmrs.hl7.HL7Util

public class HL7Util
extends java.lang.Object

HL7-related utilities

Version:
1.0

Field Summary
static java.lang.String LOCAL_TIMEZONE_OFFSET
           
 
Constructor Summary
HL7Util()
           
 
Method Summary
static java.io.File getHl7ArchivesDirectory()
          Gets the destination directory for hl7 archives.
protected static java.lang.String getTimeZoneOffset(java.lang.String fullString, java.util.Date givenDate)
          Gets the timezone string for this given fullString.
static java.util.Date parseHL7Date(java.lang.String s)
          Convenience method for parsing HL7 dates (treated just like a timestamp with only year, month, and day specified)
static java.util.Date parseHL7Time(java.lang.String s)
          Converts an HL7 time into a java.util.Date object.
static java.util.Date parseHL7Timestamp(java.lang.String s)
          Converts an HL7 timestamp into a java.util.Date object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_TIMEZONE_OFFSET

public static final java.lang.String LOCAL_TIMEZONE_OFFSET
Constructor Detail

HL7Util

public HL7Util()
Method Detail

parseHL7Timestamp

public static java.util.Date parseHL7Timestamp(java.lang.String s)
                                        throws ca.uhn.hl7v2.HL7Exception
Converts an HL7 timestamp into a java.util.Date object. HL7 timestamps can be created with varying levels of precision — e.g., just the year or just the year and month, etc. Since java.util.Date cannot store a partial value, we fill in defaults like January, 01 at midnight within the current timezone.

Parameters:
s - HL7 timestamp to be parsed
Returns:
Date object
Throws:
ca.uhn.hl7v2.HL7Exception
Expected behavior:
fail on 78, handle 1978, fail on 19784, handle 197804, fail on 197841, handle 19780411, fail on 197804116, handle 1978041106, fail on 19780411065, handle 197804110615, fail on 1978041106153, handle 19780411061538, handle 19780411061538.1, handle 19780411061538.12, handle 19780411061538.123, handle 19780411061538.1234, fail on 197804110615-5, handle 197804110615-05, handle 197804110615-0200, not flub dst with 20091225123000

getTimeZoneOffset

protected static java.lang.String getTimeZoneOffset(java.lang.String fullString,
                                                    java.util.Date givenDate)
Gets the timezone string for this given fullString. If fullString contains a + or - sign, the strings after those are considered to be the timezone.

If the fullString does not contain a timezone, the timezone is determined from the server's timezone on the "givenDate". (givenDate is needed to account for daylight savings time.)

Parameters:
fullString - the hl7 string being parsed
givenDate - the date that should be used if no timezone exists on the fullString
Returns:
a string like +0500 or -0500 for the timezone
Expected behavior:
return timezone string if exists in given string, return timezone for givenDate and not the current date

parseHL7Date

public static java.util.Date parseHL7Date(java.lang.String s)
                                   throws ca.uhn.hl7v2.HL7Exception
Convenience method for parsing HL7 dates (treated just like a timestamp with only year, month, and day specified)

Throws:
ca.uhn.hl7v2.HL7Exception
See Also:
parseHL7Timestamp(String)

parseHL7Time

public static java.util.Date parseHL7Time(java.lang.String s)
                                   throws ca.uhn.hl7v2.HL7Exception
Converts an HL7 time into a java.util.Date object. Since the java.util.Date object cannot store just the time, the date will remain at the epoch (e.g., January 1, 1970). Time more precise than microseconds is ignored.

Parameters:
s - HL7 time to be converted
Returns:
Date object set to time specified by HL7
Throws:
ca.uhn.hl7v2.HL7Exception
Expected behavior:
fail on 197804110615, handle 0615, handle 061538, handle 061538.1, handle 061538.12, handle 061538.123, handle 061538.1234, handle 061538-0300

getHl7ArchivesDirectory

public static java.io.File getHl7ArchivesDirectory()
                                            throws APIException
Gets the destination directory for hl7 archives.

Returns:
The destination directory for the hl7 in archive
Throws:
APIException

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change