Trending
15 killed as Diphtheria spreads to Jos North is trending now How a Nigerian scientist's research on headbutting animals could unlock secrets of brain … is trending now Enzo Fernandez: Manchester City open talks with Chelsea over move for Argentina midfielder is trending now 'How lucky I was, Leo...' - Enzo Fernandez pens emotional farewell to Lionel Messi as Che… is trending now Apex Legends Strategies That Work Across Every Skill Level is trending now TECNO Latest Innovations at IFA ShowStoppers 2026 Will Include Bezelless Concept Phone an… is trending now Before FC 27: A Look Back at the Most Memorable FC 26 Tournaments is trending now Oil Prices Rise Above $90 Per Barrel Following Escalation In US-Iran Crisis is trending now Video Production Opportunity on Civil Society’s Role in Ukraine EU Accession is trending now Applications open for Community Development Grant Program (Australia) is trending now ‘Your past in Anambra was also inglorious’ — Tinubu aide tackles Obi over US court battle… is trending now Pathologists seek digital innovations to transform cancer diagnosis in West Africa is trending now 15 killed as Diphtheria spreads to Jos North is trending now How a Nigerian scientist's research on headbutting animals could unlock secrets of brain … is trending now Enzo Fernandez: Manchester City open talks with Chelsea over move for Argentina midfielder is trending now 'How lucky I was, Leo...' - Enzo Fernandez pens emotional farewell to Lionel Messi as Che… is trending now Apex Legends Strategies That Work Across Every Skill Level is trending now TECNO Latest Innovations at IFA ShowStoppers 2026 Will Include Bezelless Concept Phone an… is trending now Before FC 27: A Look Back at the Most Memorable FC 26 Tournaments is trending now Oil Prices Rise Above $90 Per Barrel Following Escalation In US-Iran Crisis is trending now Video Production Opportunity on Civil Society’s Role in Ukraine EU Accession is trending now Applications open for Community Development Grant Program (Australia) is trending now ‘Your past in Anambra was also inglorious’ — Tinubu aide tackles Obi over US court battle… is trending now Pathologists seek digital innovations to transform cancer diagnosis in West Africa is trending now
Health

The true edge cases of date/time parsing

 I'm in the process of developing a Java library to implement the V2-to-FHIR datatype conversions.  This is a core component for a V2 to FHIR converter I hope to open source at some point. I'm using HAPI V2 and HAPI FHIR because Java, and these are the best implementations in Java. Some interesting learnings:  HAPI  FHIR and HAPI V2 have overlapping acceptable input ranges.In order to provide the broadest support, I'm actually using both.  The V2 parser is easier to manage with the range of acceptable ISO-8601 date time strings, since it's easier to remove any existing punctuation from an ISO-8601 data type (the -, : and T characters that typically show up in XML and JSON time stamps), than it is to insert missing punctuation, so I go with that first with the input string normalized to the 8601 format w/o punctuation. There are a couple of wonky cases that HAPI FHIR parses but V2 doesn't.  If the hours, minutes or seconds are set to the string "-0", the strings parse in FHIR, but don't in V2.  I'm guessing someone is using parse by punctuation and that Integer.toString("-0") and getting 0 in the FHIR case. Another interesting case: calling new DateTimeType(s).getValueAsString() doesn't return the same string as the following in all cases (e.g., the "2024-06-25T-0:00:00" case).     DateTimeType original = DateTimeType(s); DateTimeType normalized = new DateTimeType(original.getValue(),    original.getPrecision());      assertEquals(original, normalized);This is because HAPI FHIR doesn't renormalize the input string if it is able to be parsed (but it probably should).  I've ensured my converter class does this renormalizing.   If a time zone isn't present, then it's assumed to be the local time zone in both HAPI V2 and HAPI FHIR.  This presents small problems in testing, but nothing insurmountable. While the value of 60 is allowed in seconds in FHIR, what HAPI FHIR actually does is role to the next minute.  Again, very edge case, as leap second events are infrequent in real life (only 27 since 1972), and even more so as detected as having impacts during code execution.  GPS aware applications have to deal with them because GPS time doesn't care about leap seconds (although your phone, which synchronizes it's time via GPS may correct for them). For what it's worth as a side note, issue # 3 above happens with other types such as IntegerType, for example, try this test:|assertEquals(new IntegerType("01").getValueAsString(),              new IntegerType(1).getValueAsString()); What I've done in my converter is after creating a value from a string, ensuring I perform any string-based construction like this: IntegerType i = new IntegerType("01");  i.setValue(i.getValue()); This ensure that I get the expected string representation.  This helps resolve issues with leading zeros or plus signs (e.g., -01, 01, +01, +2).

View original source →

Related

More from Healthcare Standards