#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Observation {
pub id: Option<super::primitives::Id>,
pub meta: Option<super::meta::Meta>,
pub implicit_rules: Option<super::primitives::Uri>,
pub language: Option<super::primitives::Code>,
pub text: Option<super::narrative::Narrative>,
pub contained: Vec<super::resource::Resource>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub identifier: Vec<super::identifier::Identifier>,
pub based_on: Vec<super::reference::Reference>,
pub status: super::primitives::Code,
pub category: Vec<super::codeable_concept::CodeableConcept>,
pub code: super::codeable_concept::CodeableConcept,
pub subject: Option<super::reference::Reference>,
pub context: Option<super::reference::Reference>,
pub effective: Option<ObservationEffective>,
pub issued: Option<super::primitives::Instant>,
pub performer: Vec<super::reference::Reference>,
pub value: Option<ObservationValue>,
pub data_absent_reason: Option<super::codeable_concept::CodeableConcept>,
pub interpretation: Option<super::codeable_concept::CodeableConcept>,
pub comment: Option<super::primitives::String>,
pub body_site: Option<super::codeable_concept::CodeableConcept>,
pub method: Option<super::codeable_concept::CodeableConcept>,
pub specimen: Option<super::reference::Reference>,
pub device: Option<super::reference::Reference>,
pub reference_range: Vec<ObservationReferenceRange>,
pub related: Vec<ObservationRelated>,
pub component: Vec<ObservationComponent>,
}
impl super::super::codec::Json for Observation {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
object.insert(
std::string::String::from("resourceType"),
super::super::codec::Value::String(std::string::String::from("Observation")),
);
if let Some(item) = &self.id {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("id"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_id"), e);
}
}
if let Some(item) = &self.meta {
object.insert(
std::string::String::from("meta"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.implicit_rules {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("implicitRules"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_implicitRules"), e);
}
}
if let Some(item) = &self.language {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("language"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_language"), e);
}
}
if let Some(item) = &self.text {
object.insert(
std::string::String::from("text"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.contained.is_empty() {
let mut items = Vec::with_capacity(self.contained.len());
for item in &self.contained {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("contained"),
super::super::codec::Value::Array(items),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
if !self.identifier.is_empty() {
let mut items = Vec::with_capacity(self.identifier.len());
for item in &self.identifier {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("identifier"),
super::super::codec::Value::Array(items),
);
}
if !self.based_on.is_empty() {
let mut items = Vec::with_capacity(self.based_on.len());
for item in &self.based_on {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("basedOn"),
super::super::codec::Value::Array(items),
);
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
object.insert(std::string::String::from("status"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
object.insert(std::string::String::from("_status"), e);
}
if !self.category.is_empty() {
let mut items = Vec::with_capacity(self.category.len());
for item in &self.category {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("category"),
super::super::codec::Value::Array(items),
);
}
object.insert(
std::string::String::from("code"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.code)?),
);
if let Some(item) = &self.subject {
object.insert(
std::string::String::from("subject"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.context {
object.insert(
std::string::String::from("context"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.effective {
let (suffix, value, element) = item.to_json_parts()?;
if let Some(value) = value {
object.insert(format!("effective{suffix}"), value);
}
if let Some(element) = element {
object.insert(format!("_effective{suffix}"), element);
}
}
if let Some(item) = &self.issued {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("issued"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_issued"), e);
}
}
if !self.performer.is_empty() {
let mut items = Vec::with_capacity(self.performer.len());
for item in &self.performer {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("performer"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.value {
let (suffix, value, element) = item.to_json_parts()?;
if let Some(value) = value {
object.insert(format!("value{suffix}"), value);
}
if let Some(element) = element {
object.insert(format!("_value{suffix}"), element);
}
}
if let Some(item) = &self.data_absent_reason {
object.insert(
std::string::String::from("dataAbsentReason"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.interpretation {
object.insert(
std::string::String::from("interpretation"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.comment {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("comment"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_comment"), e);
}
}
if let Some(item) = &self.body_site {
object.insert(
std::string::String::from("bodySite"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.method {
object.insert(
std::string::String::from("method"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.specimen {
object.insert(
std::string::String::from("specimen"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.device {
object.insert(
std::string::String::from("device"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.reference_range.is_empty() {
let mut items = Vec::with_capacity(self.reference_range.len());
for item in &self.reference_range {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("referenceRange"),
super::super::codec::Value::Array(items),
);
}
if !self.related.is_empty() {
let mut items = Vec::with_capacity(self.related.len());
for item in &self.related {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("related"),
super::super::codec::Value::Array(items),
);
}
if !self.component.is_empty() {
let mut items = Vec::with_capacity(self.component.len());
for item in &self.component {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("component"),
super::super::codec::Value::Array(items),
);
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_id_element: Option<&super::super::codec::Value> = None;
let mut raw_meta: Option<&super::super::codec::Value> = None;
let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
let mut raw_language: Option<&super::super::codec::Value> = None;
let mut raw_language_element: Option<&super::super::codec::Value> = None;
let mut raw_text: Option<&super::super::codec::Value> = None;
let mut raw_contained: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_identifier: Option<&super::super::codec::Value> = None;
let mut raw_based_on: Option<&super::super::codec::Value> = None;
let mut raw_status: Option<&super::super::codec::Value> = None;
let mut raw_status_element: Option<&super::super::codec::Value> = None;
let mut raw_category: Option<&super::super::codec::Value> = None;
let mut raw_code: Option<&super::super::codec::Value> = None;
let mut raw_subject: Option<&super::super::codec::Value> = None;
let mut raw_context: Option<&super::super::codec::Value> = None;
let mut raw_effective = super::super::codec::ChoiceSlot::default();
let mut raw_issued: Option<&super::super::codec::Value> = None;
let mut raw_issued_element: Option<&super::super::codec::Value> = None;
let mut raw_performer: Option<&super::super::codec::Value> = None;
let mut raw_value = super::super::codec::ChoiceSlot::default();
let mut raw_data_absent_reason: Option<&super::super::codec::Value> = None;
let mut raw_interpretation: Option<&super::super::codec::Value> = None;
let mut raw_comment: Option<&super::super::codec::Value> = None;
let mut raw_comment_element: Option<&super::super::codec::Value> = None;
let mut raw_body_site: Option<&super::super::codec::Value> = None;
let mut raw_method: Option<&super::super::codec::Value> = None;
let mut raw_specimen: Option<&super::super::codec::Value> = None;
let mut raw_device: Option<&super::super::codec::Value> = None;
let mut raw_reference_range: Option<&super::super::codec::Value> = None;
let mut raw_related: Option<&super::super::codec::Value> = None;
let mut raw_component: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("Observation") {
return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
}
}
"id" => {
raw_id = Some(value);
}
"_id" => {
raw_id_element = Some(value);
}
"meta" => {
raw_meta = Some(value);
}
"implicitRules" => {
raw_implicit_rules = Some(value);
}
"_implicitRules" => {
raw_implicit_rules_element = Some(value);
}
"language" => {
raw_language = Some(value);
}
"_language" => {
raw_language_element = Some(value);
}
"text" => {
raw_text = Some(value);
}
"contained" => {
raw_contained = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"identifier" => {
raw_identifier = Some(value);
}
"basedOn" => {
raw_based_on = Some(value);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"category" => {
raw_category = Some(value);
}
"code" => {
raw_code = Some(value);
}
"subject" => {
raw_subject = Some(value);
}
"context" => {
raw_context = Some(value);
}
"effectiveDateTime" => {
raw_effective.value("DateTime", value, path)?;
}
"_effectiveDateTime" => {
raw_effective.element("DateTime", value, path)?;
}
"effectivePeriod" => {
raw_effective.value("Period", value, path)?;
}
"_effectivePeriod" => {
raw_effective.element("Period", value, path)?;
}
"issued" => {
raw_issued = Some(value);
}
"_issued" => {
raw_issued_element = Some(value);
}
"performer" => {
raw_performer = Some(value);
}
"valueQuantity" => {
raw_value.value("Quantity", value, path)?;
}
"_valueQuantity" => {
raw_value.element("Quantity", value, path)?;
}
"valueCodeableConcept" => {
raw_value.value("CodeableConcept", value, path)?;
}
"_valueCodeableConcept" => {
raw_value.element("CodeableConcept", value, path)?;
}
"valueString" => {
raw_value.value("String", value, path)?;
}
"_valueString" => {
raw_value.element("String", value, path)?;
}
"valueBoolean" => {
raw_value.value("Boolean", value, path)?;
}
"_valueBoolean" => {
raw_value.element("Boolean", value, path)?;
}
"valueRange" => {
raw_value.value("Range", value, path)?;
}
"_valueRange" => {
raw_value.element("Range", value, path)?;
}
"valueRatio" => {
raw_value.value("Ratio", value, path)?;
}
"_valueRatio" => {
raw_value.element("Ratio", value, path)?;
}
"valueSampledData" => {
raw_value.value("SampledData", value, path)?;
}
"_valueSampledData" => {
raw_value.element("SampledData", value, path)?;
}
"valueAttachment" => {
raw_value.value("Attachment", value, path)?;
}
"_valueAttachment" => {
raw_value.element("Attachment", value, path)?;
}
"valueTime" => {
raw_value.value("Time", value, path)?;
}
"_valueTime" => {
raw_value.element("Time", value, path)?;
}
"valueDateTime" => {
raw_value.value("DateTime", value, path)?;
}
"_valueDateTime" => {
raw_value.element("DateTime", value, path)?;
}
"valuePeriod" => {
raw_value.value("Period", value, path)?;
}
"_valuePeriod" => {
raw_value.element("Period", value, path)?;
}
"dataAbsentReason" => {
raw_data_absent_reason = Some(value);
}
"interpretation" => {
raw_interpretation = Some(value);
}
"comment" => {
raw_comment = Some(value);
}
"_comment" => {
raw_comment_element = Some(value);
}
"bodySite" => {
raw_body_site = Some(value);
}
"method" => {
raw_method = Some(value);
}
"specimen" => {
raw_specimen = Some(value);
}
"device" => {
raw_device = Some(value);
}
"referenceRange" => {
raw_reference_range = Some(value);
}
"related" => {
raw_related = Some(value);
}
"component" => {
raw_component = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = match (raw_id, raw_id_element) {
(None, None) => None,
(value, element) => Some(path.with("id", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_meta = raw_meta
.map(|value| {
path.with("meta", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
(None, None) => None,
(value, element) => Some(path.with("implicitRules", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_language = match (raw_language, raw_language_element) {
(None, None) => None,
(value, element) => Some(path.with("language", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_text = raw_text
.map(|value| {
path.with("text", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let mut field_contained = Vec::new();
if let Some(raw) = raw_contained {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_contained.push(path.with_index("contained", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let mut field_identifier = Vec::new();
if let Some(raw) = raw_identifier {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_identifier.push(path.with_index("identifier", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_based_on = Vec::new();
if let Some(raw) = raw_based_on {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_based_on.push(path.with_index("basedOn", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let mut field_category = Vec::new();
if let Some(raw) = raw_category {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_category.push(path.with_index("category", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_code = path.with("code", |path| {
let value = raw_code
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
let field_subject = raw_subject
.map(|value| {
path.with("subject", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_context = raw_context
.map(|value| {
path.with("context", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_effective = match raw_effective.suffix {
None => None,
Some(suffix) => Some(path.with("effective", |path| {
ObservationEffective::from_json_parts(
suffix,
raw_effective.value,
raw_effective.element,
path,
)
})?),
};
let field_issued = match (raw_issued, raw_issued_element) {
(None, None) => None,
(value, element) => Some(path.with("issued", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_performer = Vec::new();
if let Some(raw) = raw_performer {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_performer.push(path.with_index("performer", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_value = match raw_value.suffix {
None => None,
Some(suffix) => Some(path.with("value", |path| {
ObservationValue::from_json_parts(suffix, raw_value.value, raw_value.element, path)
})?),
};
let field_data_absent_reason = raw_data_absent_reason
.map(|value| {
path.with("dataAbsentReason", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_interpretation = raw_interpretation
.map(|value| {
path.with("interpretation", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_comment = match (raw_comment, raw_comment_element) {
(None, None) => None,
(value, element) => Some(path.with("comment", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_body_site = raw_body_site
.map(|value| {
path.with("bodySite", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_method = raw_method
.map(|value| {
path.with("method", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_specimen = raw_specimen
.map(|value| {
path.with("specimen", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_device = raw_device
.map(|value| {
path.with("device", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let mut field_reference_range = Vec::new();
if let Some(raw) = raw_reference_range {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_reference_range.push(path.with_index("referenceRange", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_related = Vec::new();
if let Some(raw) = raw_related {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_related.push(path.with_index("related", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_component = Vec::new();
if let Some(raw) = raw_component {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_component.push(path.with_index("component", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
Ok(Self {
id: field_id,
meta: field_meta,
implicit_rules: field_implicit_rules,
language: field_language,
text: field_text,
contained: field_contained,
extension: field_extension,
modifier_extension: field_modifier_extension,
identifier: field_identifier,
based_on: field_based_on,
status: field_status,
category: field_category,
code: field_code,
subject: field_subject,
context: field_context,
effective: field_effective,
issued: field_issued,
performer: field_performer,
value: field_value,
data_absent_reason: field_data_absent_reason,
interpretation: field_interpretation,
comment: field_comment,
body_site: field_body_site,
method: field_method,
specimen: field_specimen,
device: field_device,
reference_range: field_reference_range,
related: field_related,
component: field_component,
})
}
}
impl serde::Serialize for Observation {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
if let Some(item) = &self.comment {
super::super::codec::element_entry(&mut map, "_comment", item)?;
}
if let Some(ObservationEffective::DateTime(inner)) = &self.effective {
super::super::codec::element_entry(&mut map, "_effectiveDateTime", inner)?;
}
if let Some(item) = &self.id {
super::super::codec::element_entry(&mut map, "_id", item)?;
}
if let Some(item) = &self.implicit_rules {
super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
}
if let Some(item) = &self.issued {
super::super::codec::element_entry(&mut map, "_issued", item)?;
}
if let Some(item) = &self.language {
super::super::codec::element_entry(&mut map, "_language", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
match &self.value {
Some(ObservationValue::Boolean(inner)) => {
super::super::codec::element_entry(&mut map, "_valueBoolean", inner)?;
}
Some(ObservationValue::DateTime(inner)) => {
super::super::codec::element_entry(&mut map, "_valueDateTime", inner)?;
}
Some(ObservationValue::String(inner)) => {
super::super::codec::element_entry(&mut map, "_valueString", inner)?;
}
Some(ObservationValue::Time(inner)) => {
super::super::codec::element_entry(&mut map, "_valueTime", inner)?;
}
_ => {}
}
if !self.based_on.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "basedOn", &self.based_on)?;
}
if let Some(item) = &self.body_site {
serde::ser::SerializeMap::serialize_entry(&mut map, "bodySite", item)?;
}
if !self.category.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "category", &self.category)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "code", &self.code)?;
if let Some(item) = &self.comment {
super::super::codec::value_entry(&mut map, "comment", item)?;
}
if !self.component.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "component", &self.component)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if let Some(item) = &self.context {
serde::ser::SerializeMap::serialize_entry(&mut map, "context", item)?;
}
if let Some(item) = &self.data_absent_reason {
serde::ser::SerializeMap::serialize_entry(&mut map, "dataAbsentReason", item)?;
}
if let Some(item) = &self.device {
serde::ser::SerializeMap::serialize_entry(&mut map, "device", item)?;
}
match &self.effective {
Some(ObservationEffective::DateTime(inner)) => {
super::super::codec::value_entry(&mut map, "effectiveDateTime", inner)?;
}
Some(ObservationEffective::Period(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"effectivePeriod",
inner.as_ref(),
)?;
}
None => {}
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(item) = &self.id {
super::super::codec::value_entry(&mut map, "id", item)?;
}
if !self.identifier.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
}
if let Some(item) = &self.implicit_rules {
super::super::codec::value_entry(&mut map, "implicitRules", item)?;
}
if let Some(item) = &self.interpretation {
serde::ser::SerializeMap::serialize_entry(&mut map, "interpretation", item)?;
}
if let Some(item) = &self.issued {
super::super::codec::value_entry(&mut map, "issued", item)?;
}
if let Some(item) = &self.language {
super::super::codec::value_entry(&mut map, "language", item)?;
}
if let Some(item) = &self.meta {
serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
}
if let Some(item) = &self.method {
serde::ser::SerializeMap::serialize_entry(&mut map, "method", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if !self.performer.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "performer", &self.performer)?;
}
if !self.reference_range.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"referenceRange",
&self.reference_range,
)?;
}
if !self.related.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "related", &self.related)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "Observation")?;
if let Some(item) = &self.specimen {
serde::ser::SerializeMap::serialize_entry(&mut map, "specimen", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if let Some(item) = &self.subject {
serde::ser::SerializeMap::serialize_entry(&mut map, "subject", item)?;
}
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
match &self.value {
Some(ObservationValue::Attachment(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueAttachment",
inner.as_ref(),
)?;
}
Some(ObservationValue::Boolean(inner)) => {
super::super::codec::value_entry(&mut map, "valueBoolean", inner)?;
}
Some(ObservationValue::CodeableConcept(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueCodeableConcept",
inner.as_ref(),
)?;
}
Some(ObservationValue::DateTime(inner)) => {
super::super::codec::value_entry(&mut map, "valueDateTime", inner)?;
}
Some(ObservationValue::Period(inner)) => {
serde::ser::SerializeMap::serialize_entry(&mut map, "valuePeriod", inner.as_ref())?;
}
Some(ObservationValue::Quantity(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueQuantity",
inner.as_ref(),
)?;
}
Some(ObservationValue::Range(inner)) => {
serde::ser::SerializeMap::serialize_entry(&mut map, "valueRange", inner.as_ref())?;
}
Some(ObservationValue::Ratio(inner)) => {
serde::ser::SerializeMap::serialize_entry(&mut map, "valueRatio", inner.as_ref())?;
}
Some(ObservationValue::SampledData(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueSampledData",
inner.as_ref(),
)?;
}
Some(ObservationValue::String(inner)) => {
super::super::codec::value_entry(&mut map, "valueString", inner)?;
}
Some(ObservationValue::Time(inner)) => {
super::super::codec::value_entry(&mut map, "valueTime", inner)?;
}
None => {}
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for Observation {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
let mut path = super::super::codec::Path::root("Observation");
let object =
super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ObservationComponent {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub code: super::codeable_concept::CodeableConcept,
pub value: Option<ObservationComponentValue>,
pub data_absent_reason: Option<super::codeable_concept::CodeableConcept>,
pub interpretation: Option<super::codeable_concept::CodeableConcept>,
pub reference_range: Vec<ObservationReferenceRange>,
}
impl super::super::codec::Json for ObservationComponent {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
object.insert(
std::string::String::from("code"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.code)?),
);
if let Some(item) = &self.value {
let (suffix, value, element) = item.to_json_parts()?;
if let Some(value) = value {
object.insert(format!("value{suffix}"), value);
}
if let Some(element) = element {
object.insert(format!("_value{suffix}"), element);
}
}
if let Some(item) = &self.data_absent_reason {
object.insert(
std::string::String::from("dataAbsentReason"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.interpretation {
object.insert(
std::string::String::from("interpretation"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.reference_range.is_empty() {
let mut items = Vec::with_capacity(self.reference_range.len());
for item in &self.reference_range {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("referenceRange"),
super::super::codec::Value::Array(items),
);
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_code: Option<&super::super::codec::Value> = None;
let mut raw_value = super::super::codec::ChoiceSlot::default();
let mut raw_data_absent_reason: Option<&super::super::codec::Value> = None;
let mut raw_interpretation: Option<&super::super::codec::Value> = None;
let mut raw_reference_range: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"code" => {
raw_code = Some(value);
}
"valueQuantity" => {
raw_value.value("Quantity", value, path)?;
}
"_valueQuantity" => {
raw_value.element("Quantity", value, path)?;
}
"valueCodeableConcept" => {
raw_value.value("CodeableConcept", value, path)?;
}
"_valueCodeableConcept" => {
raw_value.element("CodeableConcept", value, path)?;
}
"valueString" => {
raw_value.value("String", value, path)?;
}
"_valueString" => {
raw_value.element("String", value, path)?;
}
"valueRange" => {
raw_value.value("Range", value, path)?;
}
"_valueRange" => {
raw_value.element("Range", value, path)?;
}
"valueRatio" => {
raw_value.value("Ratio", value, path)?;
}
"_valueRatio" => {
raw_value.element("Ratio", value, path)?;
}
"valueSampledData" => {
raw_value.value("SampledData", value, path)?;
}
"_valueSampledData" => {
raw_value.element("SampledData", value, path)?;
}
"valueAttachment" => {
raw_value.value("Attachment", value, path)?;
}
"_valueAttachment" => {
raw_value.element("Attachment", value, path)?;
}
"valueTime" => {
raw_value.value("Time", value, path)?;
}
"_valueTime" => {
raw_value.element("Time", value, path)?;
}
"valueDateTime" => {
raw_value.value("DateTime", value, path)?;
}
"_valueDateTime" => {
raw_value.element("DateTime", value, path)?;
}
"valuePeriod" => {
raw_value.value("Period", value, path)?;
}
"_valuePeriod" => {
raw_value.element("Period", value, path)?;
}
"dataAbsentReason" => {
raw_data_absent_reason = Some(value);
}
"interpretation" => {
raw_interpretation = Some(value);
}
"referenceRange" => {
raw_reference_range = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_code = path.with("code", |path| {
let value = raw_code
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
let field_value = match raw_value.suffix {
None => None,
Some(suffix) => Some(path.with("value", |path| {
ObservationComponentValue::from_json_parts(
suffix,
raw_value.value,
raw_value.element,
path,
)
})?),
};
let field_data_absent_reason = raw_data_absent_reason
.map(|value| {
path.with("dataAbsentReason", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_interpretation = raw_interpretation
.map(|value| {
path.with("interpretation", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let mut field_reference_range = Vec::new();
if let Some(raw) = raw_reference_range {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_reference_range.push(path.with_index("referenceRange", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
code: field_code,
value: field_value,
data_absent_reason: field_data_absent_reason,
interpretation: field_interpretation,
reference_range: field_reference_range,
})
}
}
impl serde::Serialize for ObservationComponent {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
match &self.value {
Some(ObservationComponentValue::DateTime(inner)) => {
super::super::codec::element_entry(&mut map, "_valueDateTime", inner)?;
}
Some(ObservationComponentValue::String(inner)) => {
super::super::codec::element_entry(&mut map, "_valueString", inner)?;
}
Some(ObservationComponentValue::Time(inner)) => {
super::super::codec::element_entry(&mut map, "_valueTime", inner)?;
}
_ => {}
}
serde::ser::SerializeMap::serialize_entry(&mut map, "code", &self.code)?;
if let Some(item) = &self.data_absent_reason {
serde::ser::SerializeMap::serialize_entry(&mut map, "dataAbsentReason", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
if let Some(item) = &self.interpretation {
serde::ser::SerializeMap::serialize_entry(&mut map, "interpretation", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if !self.reference_range.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"referenceRange",
&self.reference_range,
)?;
}
match &self.value {
Some(ObservationComponentValue::Attachment(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueAttachment",
inner.as_ref(),
)?;
}
Some(ObservationComponentValue::CodeableConcept(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueCodeableConcept",
inner.as_ref(),
)?;
}
Some(ObservationComponentValue::DateTime(inner)) => {
super::super::codec::value_entry(&mut map, "valueDateTime", inner)?;
}
Some(ObservationComponentValue::Period(inner)) => {
serde::ser::SerializeMap::serialize_entry(&mut map, "valuePeriod", inner.as_ref())?;
}
Some(ObservationComponentValue::Quantity(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueQuantity",
inner.as_ref(),
)?;
}
Some(ObservationComponentValue::Range(inner)) => {
serde::ser::SerializeMap::serialize_entry(&mut map, "valueRange", inner.as_ref())?;
}
Some(ObservationComponentValue::Ratio(inner)) => {
serde::ser::SerializeMap::serialize_entry(&mut map, "valueRatio", inner.as_ref())?;
}
Some(ObservationComponentValue::SampledData(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"valueSampledData",
inner.as_ref(),
)?;
}
Some(ObservationComponentValue::String(inner)) => {
super::super::codec::value_entry(&mut map, "valueString", inner)?;
}
Some(ObservationComponentValue::Time(inner)) => {
super::super::codec::value_entry(&mut map, "valueTime", inner)?;
}
None => {}
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for ObservationComponent {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
let mut path = super::super::codec::Path::root("ObservationComponent");
let object =
super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ObservationComponentValue {
Quantity(Box<super::quantity::Quantity>),
CodeableConcept(Box<super::codeable_concept::CodeableConcept>),
String(super::primitives::String),
Range(Box<super::range::Range>),
Ratio(Box<super::ratio::Ratio>),
SampledData(Box<super::sampled_data::SampledData>),
Attachment(Box<super::attachment::Attachment>),
Time(super::primitives::Time),
DateTime(super::primitives::DateTime),
Period(Box<super::period::Period>),
}
impl ObservationComponentValue {
pub fn to_json_parts(
&self,
) -> Result<
(
&'static str,
Option<super::super::codec::Value>,
Option<super::super::codec::Value>,
),
super::super::codec::EncodeError,
> {
match self {
Self::Quantity(inner) => Ok((
"Quantity",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::CodeableConcept(inner) => Ok((
"CodeableConcept",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::String(inner) => Ok((
"String",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Range(inner) => Ok((
"Range",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::Ratio(inner) => Ok((
"Ratio",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::SampledData(inner) => Ok((
"SampledData",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::Attachment(inner) => Ok((
"Attachment",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::Time(inner) => Ok((
"Time",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::DateTime(inner) => Ok((
"DateTime",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Period(inner) => Ok((
"Period",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
}
}
pub fn from_json_parts(
suffix: &str,
value: Option<&super::super::codec::Value>,
element: Option<&super::super::codec::Value>,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
match suffix {
"Quantity" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Quantity(Box::new(inner)))
}
"CodeableConcept" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::CodeableConcept(Box::new(inner)))
}
"String" => Ok(Self::String(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Range" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Range(Box::new(inner)))
}
"Ratio" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Ratio(Box::new(inner)))
}
"SampledData" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::SampledData(Box::new(inner)))
}
"Attachment" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Attachment(Box::new(inner)))
}
"Time" => Ok(Self::Time(super::super::codec::Primitive::from_json_parts(
value, element, path,
)?)),
"DateTime" => Ok(Self::DateTime(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Period" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Period(Box::new(inner)))
}
_ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ObservationEffective {
DateTime(super::primitives::DateTime),
Period(Box<super::period::Period>),
}
impl ObservationEffective {
pub fn to_json_parts(
&self,
) -> Result<
(
&'static str,
Option<super::super::codec::Value>,
Option<super::super::codec::Value>,
),
super::super::codec::EncodeError,
> {
match self {
Self::DateTime(inner) => Ok((
"DateTime",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Period(inner) => Ok((
"Period",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
}
}
pub fn from_json_parts(
suffix: &str,
value: Option<&super::super::codec::Value>,
element: Option<&super::super::codec::Value>,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
match suffix {
"DateTime" => Ok(Self::DateTime(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Period" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Period(Box::new(inner)))
}
_ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ObservationReferenceRange {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub low: Option<super::quantity::Quantity>,
pub high: Option<super::quantity::Quantity>,
pub r#type: Option<super::codeable_concept::CodeableConcept>,
pub applies_to: Vec<super::codeable_concept::CodeableConcept>,
pub age: Option<super::range::Range>,
pub text: Option<super::primitives::String>,
}
impl super::super::codec::Json for ObservationReferenceRange {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.low {
object.insert(
std::string::String::from("low"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.high {
object.insert(
std::string::String::from("high"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.r#type {
object.insert(
std::string::String::from("type"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.applies_to.is_empty() {
let mut items = Vec::with_capacity(self.applies_to.len());
for item in &self.applies_to {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("appliesTo"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.age {
object.insert(
std::string::String::from("age"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.text {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("text"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_text"), e);
}
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_low: Option<&super::super::codec::Value> = None;
let mut raw_high: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_applies_to: Option<&super::super::codec::Value> = None;
let mut raw_age: Option<&super::super::codec::Value> = None;
let mut raw_text: Option<&super::super::codec::Value> = None;
let mut raw_text_element: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"low" => {
raw_low = Some(value);
}
"high" => {
raw_high = Some(value);
}
"type" => {
raw_type = Some(value);
}
"appliesTo" => {
raw_applies_to = Some(value);
}
"age" => {
raw_age = Some(value);
}
"text" => {
raw_text = Some(value);
}
"_text" => {
raw_text_element = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_low = raw_low
.map(|value| {
path.with("low", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_high = raw_high
.map(|value| {
path.with("high", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_type = raw_type
.map(|value| {
path.with("type", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let mut field_applies_to = Vec::new();
if let Some(raw) = raw_applies_to {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_applies_to.push(path.with_index("appliesTo", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_age = raw_age
.map(|value| {
path.with("age", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_text = match (raw_text, raw_text_element) {
(None, None) => None,
(value, element) => Some(path.with("text", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
low: field_low,
high: field_high,
r#type: field_type,
applies_to: field_applies_to,
age: field_age,
text: field_text,
})
}
}
impl serde::Serialize for ObservationReferenceRange {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
if let Some(item) = &self.text {
super::super::codec::element_entry(&mut map, "_text", item)?;
}
if let Some(item) = &self.age {
serde::ser::SerializeMap::serialize_entry(&mut map, "age", item)?;
}
if !self.applies_to.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "appliesTo", &self.applies_to)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(item) = &self.high {
serde::ser::SerializeMap::serialize_entry(&mut map, "high", item)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
if let Some(item) = &self.low {
serde::ser::SerializeMap::serialize_entry(&mut map, "low", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.text {
super::super::codec::value_entry(&mut map, "text", item)?;
}
if let Some(item) = &self.r#type {
serde::ser::SerializeMap::serialize_entry(&mut map, "type", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for ObservationReferenceRange {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
let mut path = super::super::codec::Path::root("ObservationReferenceRange");
let object =
super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ObservationRelated {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub r#type: Option<super::primitives::Code>,
pub target: super::reference::Reference,
}
impl super::super::codec::Json for ObservationRelated {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.r#type {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("type"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_type"), e);
}
}
object.insert(
std::string::String::from("target"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.target)?),
);
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_type_element: Option<&super::super::codec::Value> = None;
let mut raw_target: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"type" => {
raw_type = Some(value);
}
"_type" => {
raw_type_element = Some(value);
}
"target" => {
raw_target = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_type = match (raw_type, raw_type_element) {
(None, None) => None,
(value, element) => Some(path.with("type", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_target = path.with("target", |path| {
let value = raw_target
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
r#type: field_type,
target: field_target,
})
}
}
impl serde::Serialize for ObservationRelated {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
if let Some(item) = &self.r#type {
super::super::codec::element_entry(&mut map, "_type", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "target", &self.target)?;
if let Some(item) = &self.r#type {
super::super::codec::value_entry(&mut map, "type", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for ObservationRelated {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
let mut path = super::super::codec::Path::root("ObservationRelated");
let object =
super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ObservationValue {
Quantity(Box<super::quantity::Quantity>),
CodeableConcept(Box<super::codeable_concept::CodeableConcept>),
String(super::primitives::String),
Boolean(super::primitives::Boolean),
Range(Box<super::range::Range>),
Ratio(Box<super::ratio::Ratio>),
SampledData(Box<super::sampled_data::SampledData>),
Attachment(Box<super::attachment::Attachment>),
Time(super::primitives::Time),
DateTime(super::primitives::DateTime),
Period(Box<super::period::Period>),
}
impl ObservationValue {
pub fn to_json_parts(
&self,
) -> Result<
(
&'static str,
Option<super::super::codec::Value>,
Option<super::super::codec::Value>,
),
super::super::codec::EncodeError,
> {
match self {
Self::Quantity(inner) => Ok((
"Quantity",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::CodeableConcept(inner) => Ok((
"CodeableConcept",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::String(inner) => Ok((
"String",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Boolean(inner) => Ok((
"Boolean",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Range(inner) => Ok((
"Range",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::Ratio(inner) => Ok((
"Ratio",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::SampledData(inner) => Ok((
"SampledData",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::Attachment(inner) => Ok((
"Attachment",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::Time(inner) => Ok((
"Time",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::DateTime(inner) => Ok((
"DateTime",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Period(inner) => Ok((
"Period",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
}
}
pub fn from_json_parts(
suffix: &str,
value: Option<&super::super::codec::Value>,
element: Option<&super::super::codec::Value>,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
match suffix {
"Quantity" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Quantity(Box::new(inner)))
}
"CodeableConcept" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::CodeableConcept(Box::new(inner)))
}
"String" => Ok(Self::String(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Boolean" => Ok(Self::Boolean(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Range" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Range(Box::new(inner)))
}
"Ratio" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Ratio(Box::new(inner)))
}
"SampledData" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::SampledData(Box::new(inner)))
}
"Attachment" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Attachment(Box::new(inner)))
}
"Time" => Ok(Self::Time(super::super::codec::Primitive::from_json_parts(
value, element, path,
)?)),
"DateTime" => Ok(Self::DateTime(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Period" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Period(Box::new(inner)))
}
_ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
}
}
}