An HL7 Time Read as UTC
An HL7 Time Read as UTC
A lab system in Helsinki sends an HL7 observation time, 20240615103000, with no offset. The receiving system stores an instant.
The naive approach
// The naive approach: the digits of an HL7 time, read as UTC
const value = "20240615103000"; // OBX-14 with no offset
const iso = value.slice(0, 4) + "-" + value.slice(4, 6) + "-" + value.slice(6, 8) + "T" + value.slice(8, 10) + ":" + value.slice(10, 12) + ":" + value.slice(12, 14) + "Z";
new Date(iso).toISOString();
// "2024-06-15T10:30:00.000Z" — an instant the message never statedWatch it break
The naive approach silently produces wrong results — there is no GMT equivalent to demonstrate because the failure is not using GMT.
Why
HL7 says a time with no offset is the local time of the sender. Appending Z invents UTC. In Helsinki in June the clocks are three hours ahead of UTC, so the event happened at 07:30 UTC, three hours earlier than the stored instant. parseHL7 returns a local time and no instant, so the zone has to come from you. A value sent with an offset names an instant, and parseHL7 reads it as one.
The gmt approach
import { parseHL7 } from "@northguild/gmt/healthcare/parse";
import { resolveLocal } from "@northguild/gmt/instant/convert";
parseHL7("20240615103000");
// { kind: "local", local: "2024-06-15T10:30:00", precision: "second" }
// The lab is in Helsinki, so you say so.
resolveLocal("2024-06-15T10:30:00", "Europe/Helsinki");
// "2024-06-15T07:30:00Z"
parseHL7("20240615103000+0300");
// { kind: "instant", instant: "2024-06-15T07:30:00Z", offset: "+03:00",
// local: "2024-06-15T10:30:00", precision: "second" }Same widget, working
The widget opens on a value sent with -0500, which is an instant. Delete -0500 and it becomes
a local time with no instant, because the message no longer names a place. The full rules
are in Healthcare: Clinical Timestamps.
To read a value of your own, use the HL7 Timestamp Reader.
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.