Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected GMTOffset when field contains date only #558

Open
stormcrow79 opened this issue Apr 26, 2024 · 1 comment
Open

Unexpected GMTOffset when field contains date only #558

stormcrow79 opened this issue Apr 26, 2024 · 1 comment

Comments

@stormcrow79
Copy link

Describe the bug
When a TS field (such as PID-7 Date/Time of Birth) contains a date and time without an offset, TSComponentOne.GMTOffset contains the placeholder -99.

When a TS field contains a date only, without time or offset, TSComponentOne.GMTOffset contains the local offset instead of the expected placeholder -99.

To Reproduce

foreach (var value in new[] { "20230603", "202306031234", "20230603+0800", "202306031234+0800" })
{
  var message = new NHapi.Model.V24.Message.ADT_A05();
  message.PID.DateTimeOfBirth.TimeOfAnEvent.Value = value;

  Console.WriteLine(message.PID.DateTimeOfBirth.TimeOfAnEvent.GMTOffset);
}

// expected -99, -99, 800, 800
// actual 800, -99, 800, 800

Expected behaviour
When a TS field contains a date only, without time or offset, TSComponentOne.GMTOffset contains the placeholder -99.

Environmental Details (please complete the following information):

  • OS: Windows 10
  • Target Framework: netstandard2.0
  • Version: 3.1.1
  • HL7 Version: 2.3.1 and 2.4

Additional context
This appears to be specific behavior in the setter for CommonTS.Value as shown below, which seems really strange. I'd expect the offset to be ignored for a date-only value, since it's only meaningful in the presence of a time.

// if the offset does not exist and a time value does not exist then
// we must provide a default offset = to the local time zone
if (timeVal == null && offsetExists == false)
{
  var defaultOffset = DataTypeUtil.LocalGMTOffset;
  tm = new CommonTM();
  tm.Offset = defaultOffset;
} // end if

// if we have a time value then make a new time object and set it to the
// input time value (as long as the time val has time + offset or just time only)
if (timeVal != null && timeValIsOffsetOnly == false)
{
  // must make sure that the time component contains both hours and minutes
  // at the very least -- must be at least 4chars in length.
  if (timeValLessOffset.Length < 4) { ... }}

  tm = new CommonTM();
  tm.Value = timeVal;
}
@milkshakeuk
Copy link
Member

@stormcrow79 I will look at this when I get the chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants