import { Hl7DateTime, Hl7Precision } from "../types/hl7.js";
/**
 * The seven precisions of an HL7 v2 date-time, coarsest first. Every "lower or raise" test in
 * the parser and the formatter compares ranks (`hl7PrecisionRank`); nothing compares strings.
 */
export declare const HL7_PRECISIONS: readonly Hl7Precision[];
/**
 * The index of a precision in `HL7_PRECISIONS`, coarsest first.
 *
 * @param precision candidate precision
 * @returns its rank, or `-1` for anything that is not one of the seven
 *
 * @example hl7PrecisionRank("year") // 0
 * @example hl7PrecisionRank("fraction") // 6
 * @example hl7PrecisionRank("Second") // -1
 */
export declare function hl7PrecisionRank(precision: unknown): number;
/**
 * Table 0529, degree of precision (2.A.77.2): "(Y = year, L = month, D = day, H = hour,
 * M = minute, S = second)". Upper case only; `"fraction"` has no letter.
 */
export declare const HL7_DEGREE_OF_PRECISION: Readonly<Record<"Y" | "L" | "D" | "H" | "M" | "S", Hl7Precision>>;
/**
 * The precision a Table 0529 degree letter names.
 *
 * @param degree candidate degree of precision
 * @returns the precision, or `null` for anything but an own upper-case key (`"toString"` and
 * `"__proto__"` included)
 *
 * @example hl7DegreePrecision("L") // "month"
 * @example hl7DegreePrecision("l") // null
 * @example hl7DegreePrecision("toString") // null
 */
export declare function hl7DegreePrecision(degree: unknown): Hl7Precision | null;
/**
 * The HL7 null value: two U+0022 characters (ch. 2 §2.5.3, "transmitted as two double quote
 * marks (\"\"), is different from omitting an optional data field").
 */
export declare const HL7_NULL_VALUE = "\"\"";
/**
 * The `DTM` grammar of 2.A.22, anchored. Named groups: `year month day hour minute second
 * fraction sign offsetHour offsetMinute`. The longest match is 24 characters, the `DTM` maximum
 * length (2.A.22), so there is no separate length check. Shape only: the ranges and the calendar
 * of the date and time fields are Temporal's to check; a partial value's offset is checked with the
 * `utcOffset` regex and normalised with `formatUtcOffset` (parseHL7).
 */
export declare const hl7Dtm: RegExp;
/** The fields of a `DTM` that matched `hl7Dtm`, as the strings sent. */
export interface Hl7DtmFields {
  readonly year: string;
  readonly month: string | undefined;
  readonly day: string | undefined;
  readonly hour: string | undefined;
  readonly minute: string | undefined;
  readonly second: string | undefined;
  readonly fraction: string | undefined;
  readonly sign: string | undefined;
  readonly offsetHour: string | undefined;
  readonly offsetMinute: string | undefined;
  /** The finest group present: `"fraction"` when a fraction matched. */
  readonly precision: Hl7Precision;
  /** The number of fraction digits sent, `0` when none. */
  readonly fractionDigits: number;
}
/**
 * Reads a `DTM` against `hl7Dtm`. No range check here.
 *
 * @param dtm candidate `DTM` text
 * @returns the matched groups and the precision written, or `null` when it does not match
 *
 * @example readHl7Dtm("20240615103000.1234") // { year: "2024", …, precision: "fraction", fractionDigits: 4 }
 * @example readHl7Dtm("2024-0500") // { year: "2024", sign: "-", offsetHour: "05", offsetMinute: "00", precision: "year", … }
 * @example readHl7Dtm("20240615103000.12345") // null
 */
export declare function readHl7Dtm(dtm: string): Hl7DtmFields | null;
/**
 * Splits a `TS` (2.A.77: `DTM ^ degree of precision`) into its two components. A lone field
 * carries no MSH-2, so `^` separates components, the separator Figure 2-1 recommends (ch. 2
 * §2.5.4). GMT reads TS.1 as exactly a DTM and TS.2 as exactly a Table 0529 code (or empty) and
 * rejects anything else inside them, a `&` included: that is GMT's strict-kind rule. A recipient ignores components "that are present but were not expected" (ch. 2 §2.6.2),
 * and a later version adds components at the end of a data type (§2.8.1, §2.8.2), so each
 * component after TS.2 is ignored: `20240615^D^X` is `20240615^D`. An empty component is not
 * present (§2.6.2), so `20240615^` and `20240615^^D` are `20240615`.
 *
 * An ignored component is still a component of the field, so it cannot hold a field separator
 * (`|`), a repetition separator (`~`) or a C0 control (a CR ends the segment). Anything else is
 * ignored: a subcomponent (`&`, §2.8.2), an escape sequence (`\F\`, §2.7) and white space are text.
 *
 * @param value candidate `TS` text
 * @returns the two components, each `""` when not present; `null` for a value that is not a string
 * or whose components break these rules
 *
 * @example splitHl7Ts("199904011200^L") // { dtm: "199904011200", degree: "L" }
 * @example splitHl7Ts("20240615^D^X") // { dtm: "20240615", degree: "D" }
 * @example splitHl7Ts("2024&X") // null (GMT reads TS.1 as exactly a DTM)
 * @example splitHl7Ts("20240615^D^X|Y") // null (the field separator ends the field)
 */
export declare function splitHl7Ts(value: string): {
  dtm: string;
  degree: string;
} | null;
/**
 * Which form an ISO 8601 extended string is written in, for `formatHL7` and `formatFHIR`. It reads the whole string, so an
 * annotation of any kind does not match. It reads the form, never the values (Temporal checks those). Groups
 * `year month day hour minute second fraction offset`:
 * - `year` is exactly four digits, so `+010000` and `-000001` do not match.
 * - `fraction` is one to nine digits after `.` or `,` (the decimal signs `plainDateTime` accepts).
 * - `offset` follows a time only: `Z` or `±HH:MM` with the optional `:SS` and fraction Temporal
 *   writes for a sub-minute zone, so the formatter can refuse it rather than fail to match.
 * - Upper-case `T` and `Z` only.
 */
export declare const isoHl7Form: RegExp;
/**
 * The precision an `isoHl7Form` match is written at, as `readHl7Dtm` gives it for a `DTM`.
 *
 * @param match a successful `isoHl7Form.exec` result
 * @returns the finest group present and the number of fraction digits written
 *
 * @example isoHl7Precision(isoHl7Form.exec("2024-06-15T10:30") as RegExpExecArray) // { precision: "minute", fractionDigits: 0 }
 * @example isoHl7Precision(isoHl7Form.exec("2024-06-15T10:30:00,5") as RegExpExecArray) // { precision: "fraction", fractionDigits: 1 }
 */
export declare function isoHl7Precision(match: RegExpExecArray): {
  precision: Hl7Precision;
  fractionDigits: number;
};
/**
 * The core of `parseHL7` and `isValidHL7`: the structured value an HL7 v2 `DTM` or `TS` names.
 * Never throws.
 *
 * @param value an HL7 v2 `DTM`, or a `TS` with its degree of precision
 * @returns the structured value, or `null` when `value` is not one
 *
 * @example readHl7DateTime("20240710143000+0200")?.kind // "instant"
 * @example readHl7DateTime("202407")?.kind // "partial"
 * @example readHl7DateTime("not a date") // null
 */
export declare function readHl7DateTime(value: string): Hl7DateTime | null;