org.openhealthexchange.openpixpdq.ihe.impl_v2.hl7
Class HL7v231

java.lang.Object
  extended by org.openhealthexchange.openpixpdq.ihe.impl_v2.hl7.HL7v231

public class HL7v231
extends java.lang.Object

The utility class for HL7 v2.3.1 messages.

Version:
1.0 - Nov 22, 2005
Author:
Jim Firby

Constructor Summary
HL7v231()
           
 
Method Summary
static java.util.Date buildDateFromInts(int year, int month, int day, int hour, int minute, int second, int tz, boolean useTz)
          Constructs a Date object from a set of date/time integer values.
static java.lang.String formatDate(java.util.Date date)
          Formats a date according to the HL7 v2.3.1 spec.
static java.lang.String formatDate(java.util.Date date, java.lang.String formatString)
          Formats a date according to the HL7 v2.3.1 spec unless a custom format string is supplied, then use that.
static java.lang.String formatDateTime(java.util.Date date)
          Formats a date/time according to the HL7 v2.3.1 spec.
static java.lang.String formatDateTime(java.util.Date date, java.lang.String formatString)
          Formats a date/time according to the HL7 v2.3.1 spec unless a custom format string is supplied, then use that.
static java.lang.String formatPhoneNumber(java.lang.String country, java.lang.String area, java.lang.String number, java.lang.String extension, java.lang.String note)
          Formats a phone number into the HL7 v2.3.1 spec.
static java.lang.String getErrorString(java.lang.String code)
          Creates a human-readable string our of an HL7 error code.
static java.util.Date parseDate(java.lang.String theDate)
          Parses an HL7 v2.3.1 date string into a Date object.
static java.util.Date parseDateTime(java.lang.String theDate)
          Parses an HL7 v2.3.1 date/time string into a Java Date object.
static java.util.Date parseDateTimeGMT(java.lang.String theDate)
          Parses an HL7 v2.3.1 date/time string into a Java Date object.
static void parsePhoneNumber(com.misyshealthcare.connect.base.demographicdata.PhoneNumber phone, java.lang.String theNumber)
          Parses an HL7 v2.3.1 style formatted phone number into a PhoneNumber object.
static void populateERR(ca.uhn.hl7v2.model.v231.segment.ERR err, java.lang.String segmentId, java.lang.String sequence, java.lang.String fieldPosition, java.lang.String fieldRepetition, java.lang.String componentNumber, java.lang.String hl7ErrorCode, java.lang.String hl7ErrorText)
          Populates ERR segment.
static void populateMSA(ca.uhn.hl7v2.model.v231.segment.MSA msa, java.lang.String acknowledgmentCode, java.lang.String messageControlId)
          Populates MSA segment, used by, for example, PIX Query response
static void populateMSH(ca.uhn.hl7v2.model.v231.segment.MSH msh, java.lang.String type, java.lang.String event, java.lang.String id, com.misyshealthcare.connect.net.Identifier sendingApplication, com.misyshealthcare.connect.net.Identifier sendingFacility, com.misyshealthcare.connect.net.Identifier receivingApplication, com.misyshealthcare.connect.net.Identifier receivingFacility)
          Populates an HL7 v2.3.1 MSH segment according to the IHE standard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HL7v231

public HL7v231()
Method Detail

populateMSH

public static void populateMSH(ca.uhn.hl7v2.model.v231.segment.MSH msh,
                               java.lang.String type,
                               java.lang.String event,
                               java.lang.String id,
                               com.misyshealthcare.connect.net.Identifier sendingApplication,
                               com.misyshealthcare.connect.net.Identifier sendingFacility,
                               com.misyshealthcare.connect.net.Identifier receivingApplication,
                               com.misyshealthcare.connect.net.Identifier receivingFacility)
                        throws ca.uhn.hl7v2.model.DataTypeException,
                               IheConfigurationException
Populates an HL7 v2.3.1 MSH segment according to the IHE standard

Parameters:
msh - The MSH segment
type - The type of message the segment belongs to
event - The event that triggered this message
id - The message control ID for this message
sendingApplication - The sending application
sendingFacility - The sending facility
receivingApplication - The receiving application
receivingFacility - The receiving facility
Throws:
ca.uhn.hl7v2.model.DataTypeException - When supplied data is inappropriate
IheConfigurationException - When the connection to which this will be sent if not configured properly

formatDateTime

public static java.lang.String formatDateTime(java.util.Date date)
Formats a date/time according to the HL7 v2.3.1 spec.

Parameters:
date - The date/time to format
Returns:
The formatted data/time as a string

formatDateTime

public static java.lang.String formatDateTime(java.util.Date date,
                                              java.lang.String formatString)
Formats a date/time according to the HL7 v2.3.1 spec unless a custom format string is supplied, then use that.

Parameters:
date - The date/time to format
formatString - A custom format string, or NULL for the default
Returns:
The formatted data as a string

parseDateTime

public static java.util.Date parseDateTime(java.lang.String theDate)
Parses an HL7 v2.3.1 date/time string into a Java Date object.

Parameters:
theDate - The date/time string to parse
Returns:
The parsed Date

parseDateTimeGMT

public static java.util.Date parseDateTimeGMT(java.lang.String theDate)
Parses an HL7 v2.3.1 date/time string into a Java Date object. Use GMT as the default timezone if one is not supplied in the string.

Parameters:
theDate - The date/time string to parse
Returns:
The parsed Date

formatDate

public static java.lang.String formatDate(java.util.Date date)
Formats a date according to the HL7 v2.3.1 spec.

Parameters:
date - The date to format
Returns:
The formatted data as a string

formatDate

public static java.lang.String formatDate(java.util.Date date,
                                          java.lang.String formatString)
Formats a date according to the HL7 v2.3.1 spec unless a custom format string is supplied, then use that.

Parameters:
date - The date to format
formatString - A custom format string, or NULL for the default
Returns:
The formatted data as a string

parseDate

public static java.util.Date parseDate(java.lang.String theDate)
Parses an HL7 v2.3.1 date string into a Date object.

Parameters:
theDate - The date string to parse
Returns:
The parsed Date object

buildDateFromInts

public static java.util.Date buildDateFromInts(int year,
                                               int month,
                                               int day,
                                               int hour,
                                               int minute,
                                               int second,
                                               int tz,
                                               boolean useTz)
Constructs a Date object from a set of date/time integer values. This auxiliary function is used in some unittests and in some of the HL7v25 code.

Parameters:
year - The year for the Date
month - The month (January = 1)
day - The day of the month
hour - The hour of the day (0-23)
minute - The minutes
second - The seconds
tz - The timezone offset as an integer
useTz - True if the timezone offset should be used when encoding the time, False to use the local timezone
Returns:
The Date object built using these parameters

formatPhoneNumber

public static java.lang.String formatPhoneNumber(java.lang.String country,
                                                 java.lang.String area,
                                                 java.lang.String number,
                                                 java.lang.String extension,
                                                 java.lang.String note)
Formats a phone number into the HL7 v2.3.1 spec.

Parameters:
country - The country code
area - The area code
number - The number
extension - The extension
note - Any note text
Returns:
A formatted North American phone number string

parsePhoneNumber

public static void parsePhoneNumber(com.misyshealthcare.connect.base.demographicdata.PhoneNumber phone,
                                    java.lang.String theNumber)
Parses an HL7 v2.3.1 style formatted phone number into a PhoneNumber object.

Parameters:
phone - The phone number object to populate from the string
theNumber - The phone number string to be parsed

getErrorString

public static java.lang.String getErrorString(java.lang.String code)
Creates a human-readable string our of an HL7 error code.

Parameters:
code - The error code
Returns:
The error string

populateMSA

public static void populateMSA(ca.uhn.hl7v2.model.v231.segment.MSA msa,
                               java.lang.String acknowledgmentCode,
                               java.lang.String messageControlId)
                        throws ca.uhn.hl7v2.model.DataTypeException
Populates MSA segment, used by, for example, PIX Query response

Parameters:
msa - The Message Acknowledgment segment
acknowledgmentCode - The two letter of acknowledgment code
messageControlId - The message control Id
Throws:
ca.uhn.hl7v2.model.DataTypeException - When MSA segment values cannot be set

populateERR

public static void populateERR(ca.uhn.hl7v2.model.v231.segment.ERR err,
                               java.lang.String segmentId,
                               java.lang.String sequence,
                               java.lang.String fieldPosition,
                               java.lang.String fieldRepetition,
                               java.lang.String componentNumber,
                               java.lang.String hl7ErrorCode,
                               java.lang.String hl7ErrorText)
                        throws ca.uhn.hl7v2.model.DataTypeException,
                               ca.uhn.hl7v2.HL7Exception
Populates ERR segment.

Parameters:
err - The ERR segment to be populated
segmentId - The id of the segment that caused the error
sequence - The sequence of the segment
fieldPosition - The field position where the error is
fieldRepetition - The repetition of the error field
componentNumber - The component number in the error field
hl7ErrorCode - The HL7 error code
hl7ErrorText - The HL7 error text
Throws:
ca.uhn.hl7v2.model.DataTypeException - When ERR segment values cannot be set.
ca.uhn.hl7v2.HL7Exception - When HL7 related issue happens