BizTalk Server - Converting HL7 TS or DT to System.DateTime

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server > December 2004 > Converting HL7 TS or DT to System.DateTime





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Converting HL7 TS or DT to System.DateTime
Tom

2004-12-13, 6:28 pm

I Posted this in the HL7 Group and have not gotten any reply. Please
pardon the repost:

I would like parse a HL7 TS and DT type to a System.DateTime
YYYY[MM[DD[HHMM[SS[.S[S[S[S]]]]]]]][+/-ZZZZ]

I am writing a .Net component to do this and I wanted to know if anyone
seen any C# code to do this?


I looked at the ParseExact and Parse Methods, and I don't see that it
has enough flexibility to do this.


For ParseExact, it seems that I will have to make an array of parsing
formats:


string[] l_strAParseList = {
"YYYYMMddHHmmss.ffffzzzz", "YYYYMMddHHmmss.ffffzzzz",
"YYYYMMddHHmmss.fffzzzz", "YYYYMMddHHmmss.fffzzzz",
"YYYYMMddHHmmss.ffzzzz", "YYYYMMddHHmmss.ffzzzz",
"YYYYMMddHHmmss.fzzzz", "YYYYMMddHHmmss.fzzzz",
"YYYYMMddHHmmsszzzz", "YYYYMMddHHmmsszzzz",
"YYYYMMddHHmmss.ffff", "YYYYMMddHHmmss.ffff",
"YYYYMMddHHmmss.fff", "YYYYMMddHHmmss.fff",
"YYYYMMddHHmmss.ff", "YYYYMMddHHmmss.ff",
"YYYYMMddHHmmss.f", "YYYYMMddHHmmss.f",
.... }
and so on.

My next thought was to hand parse through the string:
if (HL7Date.Lenght > 8)


{
str l_strYYYY = HL7Date.Substring(0,4);
str l_strMM = HL7Date.SubString(4,2);
str l_strdd = HL7Date.SubString(6,2);
....
DateTime l_dtHL7Date = new DateTime(l_intHL7yyyy, l_intHL7MM,
l_intHL7DD, l_intHL7HH, l_intHL7Sec, ...);
}


Any suggestions would be appreciated.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com