-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Noticed that according to the HL7 specification (see e.g. https://hl7-definition.caristix.com/v2/HL7v2.5/Fields/MSH.7) if the MSH.7 - Date/Time Of Message field of the message header specifies a timezone it should be used as the default timezone for the rest of the date/time fields of the message. This feature is not implemented by the library and cannot be implemented outside of it as the current implementation eagerly parses all date & date/time fields to JavaScript Date objects assuming UTC timezone if none is specified in situ in the field itself.
The following failing test cases demonstrate the issue:
it('should apply message header timestamp timezone to date fields in other segments', function() {
const msg = HL7Message.parse('MSH|^~\\&|||||201506301532.123+0300|||||2.5\r' +
'AL1|1|||||20151231\r');
const seg = msg.getSegment('AL1');
assert.deepStrictEqual(seg.IdentificationDate.value, new Date('2015-12-31T00:00:00.000+0300'));
});
it('should apply message header timestamp timezone to time fields in other segments', function() {
const msg = HL7Message.parse('MSH|^~\\&|||||201506301532.123+0300|||||2.5\r' +
'TQ1||||134523');
const seg = msg.getSegment('TQ1');
assert.deepStrictEqual(seg.ExplicitTime.value, new Date('0000-01-01T13:45:23.000+0300'));
});
it('should apply message header timestamp timezone to date time fields in other segments', function() {
const msg = HL7Message.parse('MSH|^~\\&|||||201506301532.123+0300||SIU^S12|||2.5\r' +
'SCH||||||NW^Booking appointed|||||^^20^20150830080000||||||||||||||||\r');
const seg = msg.getSegment('SCH');
assert.deepStrictEqual(seg.AppointmentTimingQuantity[0].StartDateTime.value, new Date('2015-08-30T08:30:00.000+0300'));
});Test output:
should apply message header timestamp timezone to date fields in other segments:
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected
+ 2015-12-31T00:00:00.000Z
- 2015-12-30T21:00:00.000Z
^
+ expected - actual
-[Date: 2015-12-31T00:00:00.000Z]
+[Date: 2015-12-30T21:00:00.000Z]
should apply message header timestamp timezone to time fields in other segments:
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected
+ 0000-01-01T13:45:23.000Z
- 0000-01-01T10:45:23.000Z
^
+ expected - actual
-[Date: 0000-01-01T13:45:23.000Z]
+[Date: 0000-01-01T10:45:23.000Z]
should apply message header timestamp timezone to date time fields in other segments:
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected
+ 2015-08-30T08:00:00.000Z
- 2015-08-30T05:30:00.000Z
^
+ expected - actual
-[Date: 2015-08-30T08:00:00.000Z]
+[Date: 2015-08-30T05:30:00.000Z]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels