The HL7DateConverter class is another very simple object. There is one instance of this class you can find in every CHS_Message object and that is the MessageDate in the MSH shortcut properties.
This class implements the COREException class for your convenience.
In HL7 date and datetime values are always native strings formatted with only numerals and no formatting. Example A date of birth of February 14, 1969 will be formatted as "19690214". The values can also be complex as in the Message Date (MSH 7.1) value which might be formatted down to the Second or Millisecond and also include a Time Zone offset (the difference between your System.DateTime.Now and Greenwich mean time).
You can use the HL7DateConverter class to either read a date or datetime string value from your HL7 messages OR you can feed the object a DateTime value and retrieve a correctly formatted HL7 date or datetime string value.
To determine IF the object has worked correctly check the HL7DateConverter.Converted property.
Public Properties:
Property Name |
Data Type |
Converted |
bool (read only) - Will indicate whether a date conversion operation was successful. |
DateValue |
DateTime (read only) - Will be the DateTime value if Converted is true or DateTime.MinValue if not. |
HL7DateString |
string (read only) - Will be DateValue.ToString("yyyyMMdd") if Converted is true or an empty string if not. |
HL7DateTimeString |
string (read only) - Will be DateValue.ToString("yyyyMMddHHmmss") + Time Zone Offset if Converted is true or an empty string if not. |
HL7DateTimeStringNoTZ |
string (read only) - Will be DateValue.ToString("yyyyMMddHHmmss") if Converted is true or an empty string if not. |
HL7LongDateString |
string (read only) - Will be DateValue.ToString("yyyyMMddHHmmssfff") + Time Zone Offset if Converted is true or an empty string if not. |
HL7LongDateStringNoTZ |
string (read only) - Will be DateValue.ToString("yyyyMMddHHmmssfff") if Converted is true or an empty string if not. |
Public Methods:
Method |
Return Value |
Convert(DateTime value) |
bool- Pass a valid DateTime in value and it creates all of the string properties and Converted will be set to true. |
Convert(string value) |
bool- Pass a string with a value HL7 formatted date or date time string and it will carve out DateValue and create the string properties. If successful Converted will be set to true. |
