use crate::encoding::HL7Encoding;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SubComponent {
raw: String,
}
impl SubComponent {
pub fn new(raw: impl Into<String>) -> Self {
Self { raw: raw.into() }
}
pub fn raw(&self, enc: &HL7Encoding) -> Option<&str> {
if self.raw == enc.present_but_null {
None
} else {
Some(&self.raw)
}
}
pub fn value(&self, enc: &HL7Encoding) -> Option<String> {
if self.raw == enc.present_but_null {
None
} else {
Some(enc.decode(&self.raw))
}
}
pub fn set_value(&mut self, value: impl Into<String>) {
self.raw = value.into();
}
}