pub struct HL7Encoding {
pub field_delimiter: char,
pub component_delimiter: char,
pub repeat_delimiter: char,
pub escape_character: char,
pub subcomponent_delimiter: char,
pub segment_delimiter: String,
pub present_but_null: String,
}Expand description
HL7 encoding/decoding rules: the field, component, repetition, escape and subcomponent delimiters plus the routines that escape and unescape values.
escape_character uses '\0' to mean “no escape character” (matching the
(char)0 sentinel from the original .NET implementation).
Fields§
§field_delimiter: charField delimiter (|, encoded as \F\).
component_delimiter: charComponent delimiter (^, encoded as \S\).
repeat_delimiter: charRepetition delimiter (~, encoded as \R\).
escape_character: charEscape character (\, encoded as \E\). '\0' means “disabled”.
subcomponent_delimiter: charSubcomponent delimiter (&, encoded as \T\).
segment_delimiter: StringSegment delimiter (defaults to \r).
present_but_null: StringString representation of a “present but null” value (defaults to "").
Implementations§
Source§impl HL7Encoding
impl HL7Encoding
Sourcepub fn all_delimiters(&self) -> String
pub fn all_delimiters(&self) -> String
All delimiter characters concatenated as they appear in MSH-2
(^~\& for the defaults). The escape character is omitted when disabled.
Sourcepub fn evaluate_delimiters(&mut self, delimiters: &str) -> Result<(), Hl7Error>
pub fn evaluate_delimiters(&mut self, delimiters: &str) -> Result<(), Hl7Error>
Sets the delimiter characters from the MSH delimiter string in the order field, component, repetition, escape, subcomponent.
When the 5th character equals the field delimiter, the escape character is treated as disabled and the 4th character becomes the subcomponent delimiter.
Sourcepub fn evaluate_segment_delimiter(
&mut self,
message: &str,
) -> Result<(), Hl7Error>
pub fn evaluate_segment_delimiter( &mut self, message: &str, ) -> Result<(), Hl7Error>
Detects and stores the segment delimiter used in message.
Sourcepub fn encode(&self, val: &str) -> String
pub fn encode(&self, val: &str) -> String
Escapes HL7 special characters in val according to the current delimiters.
Sourcepub fn encode_opt(&self, val: Option<&str>) -> String
pub fn encode_opt(&self, val: Option<&str>) -> String
Convenience for serialization: encodes Some(value) or returns the
“present but null” representation for None.
Sourcepub fn decode(&self, encoded: &str) -> String
pub fn decode(&self, encoded: &str) -> String
Decodes an escaped HL7 string back to its original characters.
Sourcepub fn decode_hex_string(hex: &str) -> String
pub fn decode_hex_string(hex: &str) -> String
Decodes a hexadecimal string (the payload of an \X..\ escape) into a
Unicode string.
Trait Implementations§
Source§impl Clone for HL7Encoding
impl Clone for HL7Encoding
Source§fn clone(&self) -> HL7Encoding
fn clone(&self) -> HL7Encoding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HL7Encoding
impl Debug for HL7Encoding
Source§impl Default for HL7Encoding
impl Default for HL7Encoding
impl Eq for HL7Encoding
Source§impl PartialEq for HL7Encoding
impl PartialEq for HL7Encoding
Source§fn eq(&self, other: &HL7Encoding) -> bool
fn eq(&self, other: &HL7Encoding) -> bool
self and other values to be equal, and is used by ==.