parseFHIR
Signature
Section titled “Signature”parseFHIR(value: string): FhirDateTime | nullReads 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.
| Precision | Form | Example |
|---|---|---|
year | YYYY | 2024 |
month | YYYY-MM | 2024-06 |
day | YYYY-MM-DD | 2024-06-15 |
second | YYYY-MM-DDThh:mm:ss±hh:mm | 2015-02-07T13:28:17-05:00 |
fraction | seconds with a decimal part | 2015-02-07T13:28:17.239+02:00 |
- Precision is kept, never padded:
2024-06is a month, not 1 June. - A time needs seconds and a zone (
Zor±hh:mm, from-14:00to+14:00).24:00is refused. Z,+00:00and-00:00all read asoffset: "+00:00"(XSD 1.0, the source of FHIR’s XML types, gives them one meaning);valuekeeps the input’s spelling. A year, month or day hasoffset: "".- A month or day that does not exist (
2023-02-29) isnull. - A second of
60is valid only on an inserted leap second (asisLeapSecond). - 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 isformatFHIR.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | - A FHIR date, dateTime or instant string. |
Returns
Section titled “Returns”The value, its precision and its offset, or null when the input is not a FHIR value.
FhirDateTime
Section titled “FhirDateTime”A FHIR date, dateTime or instant value, read as sent.
import type { FhirDateTime } from "@northguild/gmt";| Member | Type | Description |
|---|---|---|
value | string | The 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. |
offset | string | ±HH:MM (Z and -00:00 read as +00:00), or "" for a year, month or day. |
Related types
Section titled “Related types”Examples
Section titled “Examples”import { parseFHIR } from "@northguild/gmt/healthcare/parse";
parseFHIR("2024-06") // { value: "2024-06", precision: "month", offset: "" }Source
Section titled “Source”© 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.