#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![warn(clippy::unwrap_used, clippy::expect_used)]
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
mod error;
mod input;
pub mod limits;
pub mod map;
pub mod pn;
pub mod uid;
pub mod write;
pub use error::MwlError;
pub use input::{Input, LengthPolicy, Options, UidPolicy};
pub use map::worklist_item;
pub use uid::{GeneratedFrom, StudyUidOrigin};
pub use write::to_bytes;
use dicom_core::Tag;
use dicom_object::InMemDicomObject;
#[derive(Debug, Clone)]
pub struct WorklistItem {
pub dataset: InMemDicomObject,
pub study_uid: StudyUid,
pub warnings: Vec<Warning>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StudyUid {
pub value: String,
pub origin: StudyUidOrigin,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Warning {
Truncated {
tag: Tag,
max: usize,
actual: usize,
},
MissingType1 {
tag: Tag,
substituted: Option<String>,
},
SexMappedToOther {
hl7: String,
},
NameComponentsReordered,
StudyUidGenerated(GeneratedFrom),
StationAeDefaulted(String),
CharacterSetAssumed {
msh18: Option<String>,
used: String,
},
ModalityTranslated {
from: String,
to: String,
},
}
impl std::fmt::Display for Warning {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Warning::Truncated { tag, max, actual } => write!(
f,
"{tag} truncated from {actual} to {max} characters (VR length limit)"
),
Warning::MissingType1 {
tag,
substituted: Some(s),
} => write!(f, "{tag} is Type 1 but absent from the order; {s} was used"),
Warning::MissingType1 {
tag,
substituted: None,
} => write!(f, "{tag} is Type 1 but absent from the order"),
Warning::SexMappedToOther { hl7 } => write!(
f,
"PID-8 {hl7:?} has no DICOM equivalent; Patient's Sex left empty"
),
Warning::NameComponentsReordered => write!(
f,
"name prefix and suffix moved: HL7 XPN and DICOM PN order them differently"
),
Warning::StudyUidGenerated(from) => write!(
f,
"the order carried no Study Instance UID; one was generated {from}. \
The entry goes to the modality with a UID the RIS does not know."
),
Warning::StationAeDefaulted(ae) => write!(
f,
"no Scheduled Station AE Title in the message (IPC-9); {ae:?} was assumed"
),
Warning::CharacterSetAssumed { msh18, used } => match msh18 {
Some(m) => write!(
f,
"MSH-18 {m:?} is not a known character set; {used} assumed"
),
None => write!(f, "MSH-18 absent; {used} assumed"),
},
Warning::ModalityTranslated { from, to } => write!(
f,
"OBR-24 {from:?} (HL7 table 0074) translated to modality {to}"
),
}
}
}