Repository navigation
Conversation
…iNET#411) GetAsDate only accepted five ParseExact formats, so valid DTM values such as 20230211140114.0000+0800 (fractional seconds with a time zone offset, sent by Mindray V9 monitors) threw HL7Exception, as did hour, month and year precision and an offset on minute precision. Add the missing YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ] forms after the existing formats, so values that already parsed are unchanged; an offset converts to local time as the existing offset format already does.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #411.
TSComponentOne.GetAsDate()(the base ofDTMin v2.5+ and the TS first component in earlier versions) only tried fiveParseExactformats. Several valid DTM values,YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ], therefore threwHL7Exception("Could not get field as dateTime"), including the Mindray V9 value from the issue:20230211140114.0000+0800(fraction + offset)202302111401+0800,2023021114+0800,20230211+08002023021114(hour precision)202302,2023Change: the missing precisions are added as extra formats tried after the existing five, so every value that parsed before returns exactly what it did. An offset converts to local time, the same as the existing
yyyyMMddHHmmsszzzpath already does. Invalid values (5 fraction digits, odd lengths, month 13) still throw.Tests: new
DateTypeTest26with the issue's full ORU^R01 (MSH-7 and OBX-14), offset/precision cases and invalid cases. All 10 valid cases fail onmasterand pass with the change. The time-dependent assertions compare againstDateTimeOffset.LocalDateTime, and pass underTZ=America/New_York,Asia/KolkataandUTC. FullNHapi.NUnit(978 passed, 2 skipped) andNHapi.Base.NUnit(321 passed, 3 skipped) are green on net8.0, and no new StyleCop warnings.@franjom, I saw you sketched an approach here last year. Happy to fold in anything from yours, or to step aside if you had a PR in progress.