#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Encounter {
pub id: Option<std::string::String>,
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 status: super::primitives::Code,
pub status_history: Vec<EncounterStatusHistory>,
pub class: super::coding::Coding,
pub class_history: Vec<EncounterClassHistory>,
pub r#type: Vec<super::codeable_concept::CodeableConcept>,
pub service_type: Option<super::codeable_concept::CodeableConcept>,
pub priority: Option<super::codeable_concept::CodeableConcept>,
pub subject: Option<super::reference::Reference>,
pub episode_of_care: Vec<super::reference::Reference>,
pub based_on: Vec<super::reference::Reference>,
pub participant: Vec<EncounterParticipant>,
pub appointment: Vec<super::reference::Reference>,
pub period: Option<super::period::Period>,
pub length: Option<super::duration::Duration>,
pub reason_code: Vec<super::codeable_concept::CodeableConcept>,
pub reason_reference: Vec<super::reference::Reference>,
pub diagnosis: Vec<EncounterDiagnosis>,
pub account: Vec<super::reference::Reference>,
pub hospitalization: Option<EncounterHospitalization>,
pub location: Vec<EncounterLocation>,
pub service_provider: Option<super::reference::Reference>,
pub part_of: Option<super::reference::Reference>,
}
impl super::super::codec::Json for Encounter {
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("Encounter")),
);
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
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 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.status_history.is_empty() {
let mut items = Vec::with_capacity(self.status_history.len());
for item in &self.status_history {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("statusHistory"),
super::super::codec::Value::Array(items),
);
}
object.insert(
std::string::String::from("class"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.class)?),
);
if !self.class_history.is_empty() {
let mut items = Vec::with_capacity(self.class_history.len());
for item in &self.class_history {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("classHistory"),
super::super::codec::Value::Array(items),
);
}
if !self.r#type.is_empty() {
let mut items = Vec::with_capacity(self.r#type.len());
for item in &self.r#type {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("type"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.service_type {
object.insert(
std::string::String::from("serviceType"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.priority {
object.insert(
std::string::String::from("priority"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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 !self.episode_of_care.is_empty() {
let mut items = Vec::with_capacity(self.episode_of_care.len());
for item in &self.episode_of_care {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("episodeOfCare"),
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 !self.participant.is_empty() {
let mut items = Vec::with_capacity(self.participant.len());
for item in &self.participant {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("participant"),
super::super::codec::Value::Array(items),
);
}
if !self.appointment.is_empty() {
let mut items = Vec::with_capacity(self.appointment.len());
for item in &self.appointment {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("appointment"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.period {
object.insert(
std::string::String::from("period"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.length {
object.insert(
std::string::String::from("length"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.reason_code.is_empty() {
let mut items = Vec::with_capacity(self.reason_code.len());
for item in &self.reason_code {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("reasonCode"),
super::super::codec::Value::Array(items),
);
}
if !self.reason_reference.is_empty() {
let mut items = Vec::with_capacity(self.reason_reference.len());
for item in &self.reason_reference {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("reasonReference"),
super::super::codec::Value::Array(items),
);
}
if !self.diagnosis.is_empty() {
let mut items = Vec::with_capacity(self.diagnosis.len());
for item in &self.diagnosis {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("diagnosis"),
super::super::codec::Value::Array(items),
);
}
if !self.account.is_empty() {
let mut items = Vec::with_capacity(self.account.len());
for item in &self.account {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("account"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.hospitalization {
object.insert(
std::string::String::from("hospitalization"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.location.is_empty() {
let mut items = Vec::with_capacity(self.location.len());
for item in &self.location {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("location"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.service_provider {
object.insert(
std::string::String::from("serviceProvider"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.part_of {
object.insert(
std::string::String::from("partOf"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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_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_status: Option<&super::super::codec::Value> = None;
let mut raw_status_element: Option<&super::super::codec::Value> = None;
let mut raw_status_history: Option<&super::super::codec::Value> = None;
let mut raw_class: Option<&super::super::codec::Value> = None;
let mut raw_class_history: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_service_type: Option<&super::super::codec::Value> = None;
let mut raw_priority: Option<&super::super::codec::Value> = None;
let mut raw_subject: Option<&super::super::codec::Value> = None;
let mut raw_episode_of_care: Option<&super::super::codec::Value> = None;
let mut raw_based_on: Option<&super::super::codec::Value> = None;
let mut raw_participant: Option<&super::super::codec::Value> = None;
let mut raw_appointment: Option<&super::super::codec::Value> = None;
let mut raw_period: Option<&super::super::codec::Value> = None;
let mut raw_length: Option<&super::super::codec::Value> = None;
let mut raw_reason_code: Option<&super::super::codec::Value> = None;
let mut raw_reason_reference: Option<&super::super::codec::Value> = None;
let mut raw_diagnosis: Option<&super::super::codec::Value> = None;
let mut raw_account: Option<&super::super::codec::Value> = None;
let mut raw_hospitalization: Option<&super::super::codec::Value> = None;
let mut raw_location: Option<&super::super::codec::Value> = None;
let mut raw_service_provider: Option<&super::super::codec::Value> = None;
let mut raw_part_of: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("Encounter") {
return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
}
}
"id" => {
raw_id = 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);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"statusHistory" => {
raw_status_history = Some(value);
}
"class" => {
raw_class = Some(value);
}
"classHistory" => {
raw_class_history = Some(value);
}
"type" => {
raw_type = Some(value);
}
"serviceType" => {
raw_service_type = Some(value);
}
"priority" => {
raw_priority = Some(value);
}
"subject" => {
raw_subject = Some(value);
}
"episodeOfCare" => {
raw_episode_of_care = Some(value);
}
"basedOn" => {
raw_based_on = Some(value);
}
"participant" => {
raw_participant = Some(value);
}
"appointment" => {
raw_appointment = Some(value);
}
"period" => {
raw_period = Some(value);
}
"length" => {
raw_length = Some(value);
}
"reasonCode" => {
raw_reason_code = Some(value);
}
"reasonReference" => {
raw_reason_reference = Some(value);
}
"diagnosis" => {
raw_diagnosis = Some(value);
}
"account" => {
raw_account = Some(value);
}
"hospitalization" => {
raw_hospitalization = Some(value);
}
"location" => {
raw_location = Some(value);
}
"serviceProvider" => {
raw_service_provider = Some(value);
}
"partOf" => {
raw_part_of = 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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
path,
)
})
})
.transpose()?;
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 field_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let mut field_status_history = Vec::new();
if let Some(raw) = raw_status_history {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_status_history.push(path.with_index("statusHistory", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_class = path.with("class", |path| {
let value = raw_class
.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 mut field_class_history = Vec::new();
if let Some(raw) = raw_class_history {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_class_history.push(path.with_index("classHistory", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_type = Vec::new();
if let Some(raw) = raw_type {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_type.push(path.with_index("type", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_service_type = raw_service_type
.map(|value| {
path.with("serviceType", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_priority = raw_priority
.map(|value| {
path.with("priority", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
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 mut field_episode_of_care = Vec::new();
if let Some(raw) = raw_episode_of_care {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_episode_of_care.push(path.with_index("episodeOfCare", 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 mut field_participant = Vec::new();
if let Some(raw) = raw_participant {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_participant.push(path.with_index("participant", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_appointment = Vec::new();
if let Some(raw) = raw_appointment {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_appointment.push(path.with_index("appointment", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_period = raw_period
.map(|value| {
path.with("period", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_length = raw_length
.map(|value| {
path.with("length", |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_reason_code = Vec::new();
if let Some(raw) = raw_reason_code {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_reason_code.push(path.with_index("reasonCode", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_reason_reference = Vec::new();
if let Some(raw) = raw_reason_reference {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_reason_reference.push(path.with_index("reasonReference", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_diagnosis = Vec::new();
if let Some(raw) = raw_diagnosis {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_diagnosis.push(path.with_index("diagnosis", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_account = Vec::new();
if let Some(raw) = raw_account {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_account.push(path.with_index("account", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_hospitalization = raw_hospitalization
.map(|value| {
path.with("hospitalization", |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_location = Vec::new();
if let Some(raw) = raw_location {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_location.push(path.with_index("location", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_service_provider = raw_service_provider
.map(|value| {
path.with("serviceProvider", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_part_of = raw_part_of
.map(|value| {
path.with("partOf", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
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,
status: field_status,
status_history: field_status_history,
class: field_class,
class_history: field_class_history,
r#type: field_type,
service_type: field_service_type,
priority: field_priority,
subject: field_subject,
episode_of_care: field_episode_of_care,
based_on: field_based_on,
participant: field_participant,
appointment: field_appointment,
period: field_period,
length: field_length,
reason_code: field_reason_code,
reason_reference: field_reason_reference,
diagnosis: field_diagnosis,
account: field_account,
hospitalization: field_hospitalization,
location: field_location,
service_provider: field_service_provider,
part_of: field_part_of,
})
}
}
impl serde::Serialize for Encounter {
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.implicit_rules {
super::super::codec::element_entry(&mut map, "_implicitRules", 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)?;
if !self.account.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "account", &self.account)?;
}
if !self.appointment.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "appointment", &self.appointment)?;
}
if !self.based_on.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "basedOn", &self.based_on)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "class", &self.class)?;
if !self.class_history.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"classHistory",
&self.class_history,
)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if !self.diagnosis.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "diagnosis", &self.diagnosis)?;
}
if !self.episode_of_care.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"episodeOfCare",
&self.episode_of_care,
)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(item) = &self.hospitalization {
serde::ser::SerializeMap::serialize_entry(&mut map, "hospitalization", item)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
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.language {
super::super::codec::value_entry(&mut map, "language", item)?;
}
if let Some(item) = &self.length {
serde::ser::SerializeMap::serialize_entry(&mut map, "length", item)?;
}
if !self.location.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "location", &self.location)?;
}
if let Some(item) = &self.meta {
serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.part_of {
serde::ser::SerializeMap::serialize_entry(&mut map, "partOf", item)?;
}
if !self.participant.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "participant", &self.participant)?;
}
if let Some(item) = &self.period {
serde::ser::SerializeMap::serialize_entry(&mut map, "period", item)?;
}
if let Some(item) = &self.priority {
serde::ser::SerializeMap::serialize_entry(&mut map, "priority", item)?;
}
if !self.reason_code.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "reasonCode", &self.reason_code)?;
}
if !self.reason_reference.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"reasonReference",
&self.reason_reference,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "Encounter")?;
if let Some(item) = &self.service_provider {
serde::ser::SerializeMap::serialize_entry(&mut map, "serviceProvider", item)?;
}
if let Some(item) = &self.service_type {
serde::ser::SerializeMap::serialize_entry(&mut map, "serviceType", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if !self.status_history.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"statusHistory",
&self.status_history,
)?;
}
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)?;
}
if !self.r#type.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "type", &self.r#type)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for Encounter {
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("Encounter");
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 EncounterClassHistory {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub class: super::coding::Coding,
pub period: super::period::Period,
}
impl super::super::codec::Json for EncounterClassHistory {
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("class"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.class)?),
);
object.insert(
std::string::String::from("period"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.period)?),
);
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_class: Option<&super::super::codec::Value> = None;
let mut raw_period: 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);
}
"class" => {
raw_class = Some(value);
}
"period" => {
raw_period = 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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
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_class = path.with("class", |path| {
let value = raw_class
.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_period = path.with("period", |path| {
let value = raw_period
.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,
class: field_class,
period: field_period,
})
}
}
impl serde::Serialize for EncounterClassHistory {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
serde::ser::SerializeMap::serialize_entry(&mut map, "class", &self.class)?;
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, "period", &self.period)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for EncounterClassHistory {
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("EncounterClassHistory");
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 EncounterDiagnosis {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub condition: super::reference::Reference,
pub r#use: Option<super::codeable_concept::CodeableConcept>,
pub rank: Option<super::primitives::PositiveInt>,
}
impl super::super::codec::Json for EncounterDiagnosis {
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("condition"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(
&self.condition,
)?),
);
if let Some(item) = &self.r#use {
object.insert(
std::string::String::from("use"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.rank {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("rank"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_rank"), 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_condition: Option<&super::super::codec::Value> = None;
let mut raw_use: Option<&super::super::codec::Value> = None;
let mut raw_rank: Option<&super::super::codec::Value> = None;
let mut raw_rank_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);
}
"condition" => {
raw_condition = Some(value);
}
"use" => {
raw_use = Some(value);
}
"rank" => {
raw_rank = Some(value);
}
"_rank" => {
raw_rank_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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
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_condition = path.with("condition", |path| {
let value = raw_condition
.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_use = raw_use
.map(|value| {
path.with("use", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_rank = match (raw_rank, raw_rank_element) {
(None, None) => None,
(value, element) => Some(path.with("rank", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
condition: field_condition,
r#use: field_use,
rank: field_rank,
})
}
}
impl serde::Serialize for EncounterDiagnosis {
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.rank {
super::super::codec::element_entry(&mut map, "_rank", item)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "condition", &self.condition)?;
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,
)?;
}
if let Some(item) = &self.rank {
super::super::codec::value_entry(&mut map, "rank", item)?;
}
if let Some(item) = &self.r#use {
serde::ser::SerializeMap::serialize_entry(&mut map, "use", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for EncounterDiagnosis {
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("EncounterDiagnosis");
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 EncounterHospitalization {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub pre_admission_identifier: Option<super::identifier::Identifier>,
pub origin: Option<super::reference::Reference>,
pub admit_source: Option<super::codeable_concept::CodeableConcept>,
pub re_admission: Option<super::codeable_concept::CodeableConcept>,
pub diet_preference: Vec<super::codeable_concept::CodeableConcept>,
pub special_courtesy: Vec<super::codeable_concept::CodeableConcept>,
pub special_arrangement: Vec<super::codeable_concept::CodeableConcept>,
pub destination: Option<super::reference::Reference>,
pub discharge_disposition: Option<super::codeable_concept::CodeableConcept>,
}
impl super::super::codec::Json for EncounterHospitalization {
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.pre_admission_identifier {
object.insert(
std::string::String::from("preAdmissionIdentifier"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.origin {
object.insert(
std::string::String::from("origin"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.admit_source {
object.insert(
std::string::String::from("admitSource"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.re_admission {
object.insert(
std::string::String::from("reAdmission"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.diet_preference.is_empty() {
let mut items = Vec::with_capacity(self.diet_preference.len());
for item in &self.diet_preference {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("dietPreference"),
super::super::codec::Value::Array(items),
);
}
if !self.special_courtesy.is_empty() {
let mut items = Vec::with_capacity(self.special_courtesy.len());
for item in &self.special_courtesy {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("specialCourtesy"),
super::super::codec::Value::Array(items),
);
}
if !self.special_arrangement.is_empty() {
let mut items = Vec::with_capacity(self.special_arrangement.len());
for item in &self.special_arrangement {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("specialArrangement"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.destination {
object.insert(
std::string::String::from("destination"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.discharge_disposition {
object.insert(
std::string::String::from("dischargeDisposition"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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_pre_admission_identifier: Option<&super::super::codec::Value> = None;
let mut raw_origin: Option<&super::super::codec::Value> = None;
let mut raw_admit_source: Option<&super::super::codec::Value> = None;
let mut raw_re_admission: Option<&super::super::codec::Value> = None;
let mut raw_diet_preference: Option<&super::super::codec::Value> = None;
let mut raw_special_courtesy: Option<&super::super::codec::Value> = None;
let mut raw_special_arrangement: Option<&super::super::codec::Value> = None;
let mut raw_destination: Option<&super::super::codec::Value> = None;
let mut raw_discharge_disposition: 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);
}
"preAdmissionIdentifier" => {
raw_pre_admission_identifier = Some(value);
}
"origin" => {
raw_origin = Some(value);
}
"admitSource" => {
raw_admit_source = Some(value);
}
"reAdmission" => {
raw_re_admission = Some(value);
}
"dietPreference" => {
raw_diet_preference = Some(value);
}
"specialCourtesy" => {
raw_special_courtesy = Some(value);
}
"specialArrangement" => {
raw_special_arrangement = Some(value);
}
"destination" => {
raw_destination = Some(value);
}
"dischargeDisposition" => {
raw_discharge_disposition = 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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
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_pre_admission_identifier = raw_pre_admission_identifier
.map(|value| {
path.with("preAdmissionIdentifier", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_origin = raw_origin
.map(|value| {
path.with("origin", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_admit_source = raw_admit_source
.map(|value| {
path.with("admitSource", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_re_admission = raw_re_admission
.map(|value| {
path.with("reAdmission", |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_diet_preference = Vec::new();
if let Some(raw) = raw_diet_preference {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_diet_preference.push(path.with_index("dietPreference", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_special_courtesy = Vec::new();
if let Some(raw) = raw_special_courtesy {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_special_courtesy.push(path.with_index("specialCourtesy", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_special_arrangement = Vec::new();
if let Some(raw) = raw_special_arrangement {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_special_arrangement.push(path.with_index(
"specialArrangement",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_destination = raw_destination
.map(|value| {
path.with("destination", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_discharge_disposition = raw_discharge_disposition
.map(|value| {
path.with("dischargeDisposition", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
pre_admission_identifier: field_pre_admission_identifier,
origin: field_origin,
admit_source: field_admit_source,
re_admission: field_re_admission,
diet_preference: field_diet_preference,
special_courtesy: field_special_courtesy,
special_arrangement: field_special_arrangement,
destination: field_destination,
discharge_disposition: field_discharge_disposition,
})
}
}
impl serde::Serialize for EncounterHospitalization {
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.admit_source {
serde::ser::SerializeMap::serialize_entry(&mut map, "admitSource", item)?;
}
if let Some(item) = &self.destination {
serde::ser::SerializeMap::serialize_entry(&mut map, "destination", item)?;
}
if !self.diet_preference.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"dietPreference",
&self.diet_preference,
)?;
}
if let Some(item) = &self.discharge_disposition {
serde::ser::SerializeMap::serialize_entry(&mut map, "dischargeDisposition", 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,
)?;
}
if let Some(item) = &self.origin {
serde::ser::SerializeMap::serialize_entry(&mut map, "origin", item)?;
}
if let Some(item) = &self.pre_admission_identifier {
serde::ser::SerializeMap::serialize_entry(&mut map, "preAdmissionIdentifier", item)?;
}
if let Some(item) = &self.re_admission {
serde::ser::SerializeMap::serialize_entry(&mut map, "reAdmission", item)?;
}
if !self.special_arrangement.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"specialArrangement",
&self.special_arrangement,
)?;
}
if !self.special_courtesy.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"specialCourtesy",
&self.special_courtesy,
)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for EncounterHospitalization {
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("EncounterHospitalization");
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 EncounterLocation {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub location: super::reference::Reference,
pub status: Option<super::primitives::Code>,
pub physical_type: Option<super::codeable_concept::CodeableConcept>,
pub period: Option<super::period::Period>,
}
impl super::super::codec::Json for EncounterLocation {
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("location"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.location)?),
);
if let Some(item) = &self.status {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("status"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_status"), e);
}
}
if let Some(item) = &self.physical_type {
object.insert(
std::string::String::from("physicalType"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.period {
object.insert(
std::string::String::from("period"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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_location: 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_physical_type: Option<&super::super::codec::Value> = None;
let mut raw_period: 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);
}
"location" => {
raw_location = Some(value);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"physicalType" => {
raw_physical_type = Some(value);
}
"period" => {
raw_period = 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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
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_location = path.with("location", |path| {
let value = raw_location
.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_status = match (raw_status, raw_status_element) {
(None, None) => None,
(value, element) => Some(path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_physical_type = raw_physical_type
.map(|value| {
path.with("physicalType", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_period = raw_period
.map(|value| {
path.with("period", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
location: field_location,
status: field_status,
physical_type: field_physical_type,
period: field_period,
})
}
}
impl serde::Serialize for EncounterLocation {
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.status {
super::super::codec::element_entry(&mut map, "_status", 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)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "location", &self.location)?;
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.period {
serde::ser::SerializeMap::serialize_entry(&mut map, "period", item)?;
}
if let Some(item) = &self.physical_type {
serde::ser::SerializeMap::serialize_entry(&mut map, "physicalType", item)?;
}
if let Some(item) = &self.status {
super::super::codec::value_entry(&mut map, "status", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for EncounterLocation {
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("EncounterLocation");
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 EncounterParticipant {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub r#type: Vec<super::codeable_concept::CodeableConcept>,
pub period: Option<super::period::Period>,
pub individual: Option<super::reference::Reference>,
}
impl super::super::codec::Json for EncounterParticipant {
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 !self.r#type.is_empty() {
let mut items = Vec::with_capacity(self.r#type.len());
for item in &self.r#type {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("type"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.period {
object.insert(
std::string::String::from("period"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.individual {
object.insert(
std::string::String::from("individual"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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_period: Option<&super::super::codec::Value> = None;
let mut raw_individual: 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);
}
"period" => {
raw_period = Some(value);
}
"individual" => {
raw_individual = 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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
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 mut field_type = Vec::new();
if let Some(raw) = raw_type {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_type.push(path.with_index("type", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_period = raw_period
.map(|value| {
path.with("period", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_individual = raw_individual
.map(|value| {
path.with("individual", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
r#type: field_type,
period: field_period,
individual: field_individual,
})
}
}
impl serde::Serialize for EncounterParticipant {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
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.individual {
serde::ser::SerializeMap::serialize_entry(&mut map, "individual", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.period {
serde::ser::SerializeMap::serialize_entry(&mut map, "period", item)?;
}
if !self.r#type.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "type", &self.r#type)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for EncounterParticipant {
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("EncounterParticipant");
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 EncounterStatusHistory {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub status: super::primitives::Code,
pub period: super::period::Period,
}
impl super::super::codec::Json for EncounterStatusHistory {
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(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);
}
object.insert(
std::string::String::from("period"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.period)?),
);
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_status: Option<&super::super::codec::Value> = None;
let mut raw_status_element: Option<&super::super::codec::Value> = None;
let mut raw_period: 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);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"period" => {
raw_period = 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::primitives::checked_string(
super::super::codec::expect_string(value, path)?,
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_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let field_period = path.with("period", |path| {
let value = raw_period
.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,
status: field_status,
period: field_period,
})
}
}
impl serde::Serialize for EncounterStatusHistory {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
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, "period", &self.period)?;
super::super::codec::value_entry(&mut map, "status", &self.status)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for EncounterStatusHistory {
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("EncounterStatusHistory");
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)
}
}