isValidHL7
Signature
Section titled “Signature”isValidHL7(value: string): booleanReturn true when value is an HL7 v2 DTM, or a TS with a degree of precision the digits carry, that parseHL7 reads.
- HL7 v2.5.1 2.A.22 (headed 2.A.1.22 in the hl7.eu v2.5.1 copy) defines the
DTMYYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]; 2.A.77 theTS. - True exactly when
parseHL7returns a reading: the validator calls the parser, so the two cannot disagree. - The null value
'""'(two double quote marks) is valid, because ch. 2 §2.5.3 makes it a value that clears the stored one;''is not. - A valid value is not necessarily an instant:
parseHL7reads a value at a minute or finer with no offset as"local", one at year to hour precision as"partial"(with or without an offset), and'""'as"null". - Components are read as
parseHL7reads them:^separates them (ch. 2 §2.5.4). GMT reads TS.1 as exactly a DTM and TS.2 as one code, so2024&Xis not valid (GMT’s strict-kind rule). Components after TS.2 are ignored (§2.6.2), so20240615^D^Xis valid unless one holds|,~or a C0 control character. - No public regex exists: a
DTMis valid only as a whole (calendar, clock, offset and degree of precision together), which a pattern alone cannot check. - False for a value that is not a string. Never throws.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | HL7 v2 DTM or TS string |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidHL7 } from "@northguild/gmt/healthcare/validate";
isValidHL7("20240615103000-0500") // trueSource
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.