Skip to content

parseFHIR

  • Timestamps in HL7 and FHIR clinical data: a precision set by what is sent, and a time with no offset, which HL7 reads as local time and FHIR refuses.
parseFHIR(value: string): FhirDateTime | null

Reads a FHIR R4 date, dateTime or instant string (R4 Datatypes §2.24.0.1) as it is written, and returns what it states: the input, its precision and its offset.

PrecisionFormExample
yearYYYY2024
monthYYYY-MM2024-06
dayYYYY-MM-DD2024-06-15
secondYYYY-MM-DDThh:mm:ss±hh:mm2015-02-07T13:28:17-05:00
fractionseconds with a decimal part2015-02-07T13:28:17.239+02:00
  • Precision is kept, never padded: 2024-06 is a month, not 1 June.
  • A time needs seconds and a zone (Z or ±hh:mm, from -14:00 to +14:00). 24:00 is refused.
  • Z, +00:00 and -00:00 all read as offset: "+00:00" (XSD 1.0, the source of FHIR’s XML types, gives them one meaning); value keeps the input’s spelling. A year, month or day has offset: "".
  • A month or day that does not exist (2023-02-29) is null.
  • A second of 60 is valid only on an inserted leap second (as isLeapSecond).
  • A fraction is at most nine digits. R4’s pattern allows any length, but Temporal holds nanoseconds and a value GMT cannot hold is not called valid (XSD 1.0 lets a processor set such a limit if it documents it).
  • Disambiguation: none. Every time FHIR carries has an offset, so there is no wall time to resolve. The matching validator is isValidFHIR, and the writer is formatFHIR.
ParameterTypeDescription
valuestring- A FHIR date, dateTime or instant string.

The value, its precision and its offset, or null when the input is not a FHIR value.

A FHIR date, dateTime or instant value, read as sent.

import type { FhirDateTime } from "@northguild/gmt";
MemberTypeDescription
valuestringThe input, unchanged: nothing is padded and the offset is spelled as sent.
precision"year" | "month" | "day" | "second" | "fraction" (FhirPrecision)The finest field the value writes.
offsetstring±HH:MM (Z and -00:00 read as +00:00), or "" for a year, month or day.
import { parseFHIR } from "@northguild/gmt/healthcare/parse";
parseFHIR("2024-06") // { value: "2024-06", precision: "month", offset: "" }
output 

healthcare/parse/parseFHIR.ts

© 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.