1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! HL7v2 message parsing in Rust.
//!
//! Parses the structure of HL7v2 messages, but does not validate the correctness
//! of the messages.
//!
//! # Examples
//!
//! ```
//! use hl7_parser::{Message, datetime::TimeStamp};
//! use std::str::FromStr;
//!
//! let message =
//! Message::parse("MSH|^~\\&|foo|bar|baz|quux|20010504094523||ADT^A01|1234|P|2.3|||").unwrap();
//! let msh = message.segment("MSH").unwrap();
//! assert_eq!(msh.field(3).unwrap().raw_value(), "foo");
//!
//! let message_time = msh.field(7).unwrap();
//! let time: TimeStamp = message_time.raw_value().parse().unwrap();
//! assert_eq!(time.year, 2001);
//! assert_eq!(time.month, Some(5));
//! assert_eq!(time.day, Some(4));
//! ```
/// Structs for representing HL7 messages.
pub use Message;
/// Structs for displaying parsed HL7 message values. Especially useful for decoding
/// escaped values.
/// Utilities for locating a cursor within an HL7 message.
/// Human-readable location queries for HL7 messages.
///
/// i.e. parsing "PID.5.1" to get the value of the first component of the fifth field
/// Functions to parse various parts of an HL7 message. Probably not useful to you
/// (use the `Message::parse` method instead).
/// Timestamp parsing and utilities to translate to and from the `chrono` and
/// `time` crates.
/// Parses an HL7 message into a structured form. Equivalent to calling `Message::parse(message)`.
/// Parses an HL7 message into a structured form, allowing lenient newlines. Equivalent to calling
/// `Message::parse_with_lenient_newlines(message, true)`.
// TODO list:
//
// - [x] Timestamp parsing
// - [x] Chrono support
// - [x] Time support
// - [x] Add lenient parsing for segment separators (e.g. allow \n or \r\n as well as \r)
// - [x] Add cursor location
// - [x] Add query functions to get fields, components, etc. by name
// - [ ] Add ability to convert parsed messages into a mutable form that can be modified and then serialized back into a hl7 message
// - [X] Add serde support
// - [x] this_error errors
// - [x] More tests
// - [x] More documentation
// - [x] More examples
// - [x] benchmarks