|
Sun Message Library for HL7 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.stc.hl7.dataUtils.HL7UtilityFunctions
public class HL7UtilityFunctions
Utility functions for use on HL7 data. Based on the Monk Library Functions. Below is a table mapping the Java methods found in this class to the original Monk Library functions.
| Constructor Summary | |
|---|---|
HL7UtilityFunctions()
|
|
| Method Summary | |
|---|---|
java.lang.String |
calcSurfaceBSA(java.lang.String height,
java.lang.String weight)
Calculates the surface area of a human body in square meters, based on an individual's height, in centimeters, and weight, in kilograms. |
java.lang.String |
calcSurfaceGG(java.lang.String height,
java.lang.String weight)
Calculates the surface area of a human body using the Gehan-George formula. |
java.lang.String |
centimeterToInch(java.lang.String centimeter)
Converts a number from centimeters to inches. |
java.lang.String |
degCToDegF(java.lang.String celcius)
Converts a temperature from Celsius to Fahrenheit. |
java.lang.String |
degFToDegC(java.lang.String fahrenheit)
Converts a temperature from Fahrenheit to Celsius. |
int |
diffTwoDates(java.lang.String date1,
java.lang.String date2)
Determines the number of days between two standard dates. |
java.lang.String |
get2SSN(java.lang.String ssn)
Parses the specified social security number and returns the second group of digits. |
java.lang.String |
get3SSN(java.lang.String ssn)
Parses the specified social security number and returns the first group of digits. |
java.lang.String |
get4SSN(java.lang.String ssn)
Parses the specified social security number and returns the third group of digits. |
java.lang.String |
getApartment(java.lang.String address)
Returns the apartment information from a string formatted as ADDRESS, APARTMENT, that is, everything after the comma. |
java.lang.String |
getCity(java.lang.String address)
Returns the city field from the string formatted as CITY, STATE ZIP. |
java.lang.String |
getFirstName(java.lang.String name)
Returns the first name in a string formatted as "LAST, FIRST MIDDLE"; that is everything after the first comma and before the next space. |
java.lang.String |
getLastName(java.lang.String name)
Returns the last name in a string formatted as "LAST, FIRST MIDDLE"; that is everything before the comma. |
java.lang.String |
getMiddleName(java.lang.String name)
Returns the middle name in a string formatted as "LAST, FIRST MIDDLE"; that is everything following the space after the first name. |
java.lang.String |
getState(java.lang.String address)
Returns the state field from the string formatted as CITY, STATE ZIP. |
java.lang.String |
getStreetAddress(java.lang.String address)
Returns the address from a string formatted as ADDRESS, APARTMENT, that is everything before the comma. |
java.lang.String |
getTimeStamp(java.lang.String format)
SYNOPSIS: Returns the system time of the host machine in the form of format. |
java.lang.String |
getZipCode(java.lang.String address)
Returns the zip code field from the string formatted as CITY, STATE ZIP. |
java.lang.String |
inchToCentimeter(java.lang.String inch)
Converts a number from inches to centimeters. |
boolean |
isLeapYear(java.lang.String year)
Determines if the year represents a leap year. |
boolean |
isValidDate(java.lang.String date)
This function will verify the date for being valid. |
boolean |
isValidJulianDate(java.lang.String date)
Determines if the seven-digit date provided in the call is a valid Julian date. |
boolean |
isValidPhoneNumber(java.lang.String number)
Tests the supplied number to determine if it is a valid phone number A valid phone number is a string of the form NN (NNN) NNN-NNNN, where the first two groups of characters (country code and area code) are both optional, and there can be any number of spaces between the three character groups. |
boolean |
isValidSSN(java.lang.String ssn)
Tests the supplied number to determine if it is a valid social security number. |
boolean |
isValidTimeStamp(java.lang.String timestamp)
Tests the supplied number to determine if it is a valid timestamp. |
java.lang.String |
julianToStandardDate(java.lang.String julian)
Converts a Julian date to a standard date in the form YYYYMDD. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
ounceToGram(java.lang.String ounce)
Converts a number which represents weight in ounces to grams. |
java.lang.String |
ounceToPound(java.lang.String ounce)
Converts a weight in ounces to pounds. |
java.lang.String |
poundToOunce(java.lang.String pound)
Converts a number expressed as weight in pounds number and converts this number from pounds to ounces. |
java.lang.String |
standardToJulianDate(java.lang.String std)
Converts a standard date, in the format YYYYMMDD, to a Julian date. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HL7UtilityFunctions()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
public java.lang.String calcSurfaceBSA(java.lang.String height,
java.lang.String weight)
throws java.lang.NumberFormatException
Example
calcSurfaceBSA(144.0, 100) => 2.0708812096829
height - Height of the individual in centimeters.weight - Weight of the individual in kilograms.
String - Returns the calculated body surface area in square meters.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String calcSurfaceGG(java.lang.String height,
java.lang.String weight)
throws java.lang.NumberFormatException
Example
calcSurfaceGG(12, 12) => 0.24113634200082
height - Height of the individual in centimeters.weight - Weight of the individual in kilograms.
String - Returns the calculated body surface area in square meters.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String centimeterToInch(java.lang.String centimeter)
throws java.lang.NumberFormatException
Examples centimeterToInch(2.54) => 1.0 centimeterToInch(5.08) => 2.0
centimeter - Number of centimeters.
String - Returns the number of inches resulting from the conversion.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String degCToDegF(java.lang.String celcius)
throws java.lang.NumberFormatException
Examples degCToDegF(100) => 212.0 degCToDegF(0.0) => 32.0
celcius - Degrees in Celcius.
String - Returns a number representing the temperature, in Fahrenheit, resulting from the conversion.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String degFToDegC(java.lang.String fahrenheit)
throws java.lang.NumberFormatException
Examples degFToDegC(212.0) => 100.0 degFToDegC(32.0) => 0.0
fahrenheit - Temperature in degrees Fahrenheit.
String - Returns a number representing the temperature, in degrees Celsius, resulting from the conversion.
NumberFormatException
java.lang.NumberFormatException
public int diffTwoDates(java.lang.String date1,
java.lang.String date2)
throws java.lang.Exception
Examples
diffTwoDates("19960602", "19960225") => 98
diffTwoDates("19960101", "19970101") => -366
date1 - First date in format YYYYMMDD.date2 - Second date in format YYYYMMDD.
int - Indicates the number of days between the two user-specified standard dates. The result may be positive or negative.
Exception
java.lang.Exceptionpublic java.lang.String get2SSN(java.lang.String ssn)
Example
get2SSN("123-45-6789") > "45"
ssn - Social security number. A valid ssn string consists of nine digits with
a hyphen following the third and fifth digits.
String - Returns the second group of digits in a social security number.
public java.lang.String get3SSN(java.lang.String ssn)
Example
get3SSN("123-45-6789") => "123"
ssn - Social security number. A valid ssn string consists of nine digits with
a hyphen following the third and fifth digits.
String - Returns the first group of digits in a social security number.
public java.lang.String get4SSN(java.lang.String ssn)
Example
get4SSN("123-45-6789") => "6789"
ssn - Social security number. A valid ssn string consists of nine
digits with a hyphen following the third and fifth digits.
String - Returns the third group of digits in a social security number.
public java.lang.String getApartment(java.lang.String address)
Examples
getApartment("12 Main St., Apt. 22") => "Apt. 22"
getApartment("345 Main St., #7") => "#7"
getApartment("345 Elm Ave. #7") => "null"
address - Street address.
String - Returns a string containing the apartment information from a string formatted as
ADDRESS, APARTMENT, that is, everything after the comma.
public java.lang.String getCity(java.lang.String address)
Examples
getCity("Arcadia, CA 91066") => "Arcadia"
getCity("North Hills CA 91324") => NULL
address - Address formatted as CITY, STATE ZIP.
String - Returns a string containing the city field from the string formatted as
CITY, STATE ZIP. Null if no city can be found.
public java.lang.String getFirstName(java.lang.String name)
Example
(getFirstName( "Astor, John Jacob") => "John"
name - Personal name.
String - Returns the first name in a string formatted as LAST, FIRST
MIDDLE; that is, everything after the first comma and before the next space.
Null if no first name can be found.
public java.lang.String getLastName(java.lang.String name)
Example
getLastName( "Astor, John Jacob") => "Astor"
name - Personal name.
String - Returns the last name in a string formatted as
"LAST, FIRST MIDDLE"; that is, everything before the comma.
Null if no last name could be found.
public java.lang.String getMiddleName(java.lang.String name)
Example
getMiddleName("Astor, John Jacob") => "Jacob"
name - Personal name.
String - Returns the middle name in a string formatted as "LAST, FIRST
MIDDLE"; that is, everything after the space. Null if no middle name is found.
public java.lang.String getState(java.lang.String address)
Examples
getState("Arcadia, CA 91066") => "CA"
getState("North Hills CA 91324") => NULL
address - Address in the form CITY, STATE, ZIP.
String - Returns the state field from the string formatted as
CITY, STATE ZIP. Null if no state is found.
public java.lang.String getStreetAddress(java.lang.String address)
Examples
getStreetAddress("12 Main St., Apt. 22") => "12 Main St."
getStreetAddress("345 Elm Ave., #7") => "345 Elm Ave."
getStreetAddress("345 Elm Ave. #7") => "345 Elm Ave. #7"
address - Street address.
String - Returns the street address from the supplied string, that is, everything
before the first comma. If the string does not contain a comma, the function returns.
the entire string.
public java.lang.String getTimeStamp(java.lang.String format)
throws java.lang.IllegalArgumentException
Letter Date or Time Component Presentation Examples G Era designator Text AD y Year Year 1996; 96 M Month in year Month July; Jul; 07 w Week in year Number 27 W Week in month Number 2 D Day in year Number 189 d Day in month Number 10 F Day of week in month Number 2 E Day in week Text Tuesday; Tue a Am/pm marker Text PM H Hour in day (0-23) Number 0 k Hour in day (1-24) Number 24 K Hour in am/pm (0-11) Number 0 h Hour in am/pm (1-12) Number 12 m Minute in hour Number 30 s Second in minute Number 55 S Millisecond Number 978 z Time zone General time zone Pacific Standard Time; PST; GMT-08:00 Z Time zone RFC 822 time zone -0800
Examples
For
getTimeStamp("yyyy.MM.dd G 'at' HH:mm:ss z") => "2004.02.24 AD at 16:39:34 PST"
getTimeStamp("EEE, MMM d, ''yy") => "Tue, Feb 24, '04"
getTimeStamp("h:mm a") => "4:39PM"
getTimeStamp("xyzzy") => EXCEPTION [Illegal pattern character 'x']
format - The specification of the output format. The syntax for the format
instruction is documented in Format Specification on page 34.
String - Returns the system time of the host machine.
IllegalArgumentException
java.lang.IllegalArgumentExceptionSimpleDateFormatpublic java.lang.String getZipCode(java.lang.String address)
Example
getZipCode("Arcadia, CA 91066") => "91066"
address - Address in the form CITY, STATE, ZIP.
String - Returns the zip code field from the supplied string formatted as
CITY, STATE ZIP. NULL if zipcode does not exist.
public java.lang.String inchToCentimeter(java.lang.String inch)
throws java.lang.NumberFormatException
Examples
inchToCentimeter(10.0) => 25.4
inchToCentimeter(39.4) => 100.076
inch - Number of inches.
String - Returns a number representing the number of centimeters resulting from the conversion.
NumberFormatException
java.lang.NumberFormatExceptionpublic boolean isLeapYear(java.lang.String year)
Examples
isLeapYear(1990) => false
isLeapYear(1996) => true
year - A four-digit integer representing a year.
Boolean - Returns true if the integer does represent a leap year; otherwise, returns true.
public boolean isValidDate(java.lang.String date)
Examples
isValidDate("19960322") => true
isValidDate("19893800") => false
isValidDate("000415") => true
isValidDate("010229") => false
date - Valid date in the form YYYYMMDD.
Boolean - Returns true for a valid formatted date, otherwise false.
public boolean isValidJulianDate(java.lang.String date)
Examples
isValidJulianDate("2444239") => true
isValidJulianDate("244239") => false
date - Seven-digit Julian date.
Boolean - Returns true if the string is a valid Julian date; otherwise, returns a false.
public boolean isValidPhoneNumber(java.lang.String number)
Examples
isValidPhoneNumber("44(326)323-5909") => true
isValidPhoneNumber("(818)445-7000") => true
isValidPhoneNumber("123-45-6789") => false
isValidPhoneNumber("91066") => false
number - Number to test.
Boolean - true if the supplied number is a phone number. Otherwise, it returns false.
public boolean isValidSSN(java.lang.String ssn)
throws java.util.regex.PatternSyntaxException
Examples
isValidSSN("123-45-6789") => true
isValidSSN("91066") => false
ssn - The Social Security Number to test.
Boolean - Returns true if the supplied number is a social security number. Otherwise, it returns false.
java.util.regex.PatternSyntaxExceptionpublic boolean isValidTimeStamp(java.lang.String timestamp)
Examples
isValidTimeStamp("1234") => true
isValidTimeStamp("134532") => true
isValidTimeStamp("2560") => false
timestamp - valid timestamp (HHMM or HHMMSS or HHMMSSD or HHMMSSDD).
Boolean - Returns true if S is a valid timestamp (HHMM or HHMMSS or HHMMSSD or HHMMSSDD)
Returns false if not a valid timestamp.
public java.lang.String julianToStandardDate(java.lang.String julian)
throws java.lang.Exception
See also http://aa.usno.navy.mil/faq/docs/JD_Formula.html
o Years are positive or negative numbers. o Julian day number 0 corresponds to 11/24/4713 BC in the Gregorian Calendar. o These calculations are only valid in the Gregorian Calendar. o julianToStandardDate is only valid with Julian dates corresponding to 03/01/4900 BC and onward (-68569 Julian).Examples julianToStandardDate("2451449") => "19990927" julianToStandardDate("2436078") => "19570827"
julian - Julian date.
String - A standard date in the form YYYYMMDD. null if date is not supported.
java.lang.Exception
public java.lang.String ounceToGram(java.lang.String ounce)
throws java.lang.NumberFormatException
Examples
ounceToGram(0.035) => .99225
ounceToGram(1.0) => 28.35
ounce - Weight in ounces.
String - Returns a number representing weight in grams resulting from the conversion.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String ounceToPound(java.lang.String ounce)
throws java.lang.NumberFormatException
Examples
ounceToPound(32) => 2.0
ounceToPound(100) => 6.25
ounce - Weight in ounces.
String - Returns a number representing the weight in pounds resulting from the conversion.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String poundToOunce(java.lang.String pound)
throws java.lang.NumberFormatException
Examples
poundToOunce(2.0) => 32.0
poundToOunce(6.25) => 100.0
pound - Weight in pounds.
String - Returns a number representing the weight in ounces resulting from the conversion.
NumberFormatException
java.lang.NumberFormatException
public java.lang.String standardToJulianDate(java.lang.String std)
throws java.lang.Exception
See also http://aa.usno.navy.mil/faq/docs/JD_Formula.html
o Years are positive or negative numbers. o Julian day number 0 corresponds to 11/24/4713 BC in the Gregorian Calendar. o These calculations are only valid in the Gregorian Calendar. o standardToJulianDate is only valid with standard date of 03/01/4800 BC and onward.Examples standardToJulianDate("19480115") => "2432556" standardToJulianDate("18980215") => "2414336"
std - A standard date in the form YYYYMMDD.
String - Returns the Julian date. null if date is not supported.
Exception
java.lang.Exception
|
Sun Message Library for HL7 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||