use openehr_term::codes as term;
use crate::engine::origin::ItemId;
use crate::engine::origin::Origin;
use crate::engine::origin::Party;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Defaults {
pub(super) composer: String,
pub(super) start_time: String,
pub(super) setting: Setting,
pub(super) language: Option<String>,
pub(super) territory: Option<String>,
origin: Option<Origin>,
pub(super) facility: Option<Party>,
pub(super) composer_id: Option<ComposerId>,
pub(super) composer_identifiers: Vec<ItemId>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ComposerId {
pub id: String,
pub namespace: String,
pub scheme: String,
}
impl Defaults {
#[must_use]
pub fn at(now: impl Into<String>) -> Self {
Self {
composer: String::from("FHIRconnect"),
start_time: now.into(),
setting: Setting {
code: String::from(term::Setting::OtherCare.code()),
value: String::from(term::Setting::OtherCare.rubric()),
},
language: None,
territory: None,
origin: None,
facility: None,
composer_id: None,
composer_identifiers: Vec::new(),
}
}
#[must_use]
pub fn with_composer(mut self, name: impl Into<String>) -> Self {
self.composer = name.into();
self
}
#[must_use]
pub fn with_setting(mut self, code: impl Into<String>, value: impl Into<String>) -> Self {
self.setting = Setting {
code: code.into(),
value: value.into(),
};
self
}
#[must_use]
pub fn with_language(mut self, code: impl Into<String>) -> Self {
self.language = Some(code.into());
self
}
#[must_use]
pub fn with_territory(mut self, code: impl Into<String>) -> Self {
self.territory = Some(code.into());
self
}
#[must_use]
pub fn with_origin(mut self, origin: Origin) -> Self {
self.origin = Some(origin);
self
}
#[must_use]
pub fn with_composer_id(mut self, id: ComposerId) -> Self {
self.composer_id = Some(id);
self
}
#[must_use]
pub fn with_composer_identifiers(mut self, identifiers: Vec<ItemId>) -> Self {
self.composer_identifiers = identifiers;
self
}
#[must_use]
pub fn with_facility(mut self, facility: Party) -> Self {
self.facility = Some(facility);
self
}
#[must_use]
pub const fn origin(&self) -> Option<&Origin> {
self.origin.as_ref()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(super) struct Setting {
pub(super) code: String,
pub(super) value: String,
}