#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Appointment {
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 cancelation_reason: Option<super::codeable_concept::CodeableConcept>,
pub service_category: Vec<super::codeable_concept::CodeableConcept>,
pub service_type: Vec<super::codeable_concept::CodeableConcept>,
pub specialty: Vec<super::codeable_concept::CodeableConcept>,
pub appointment_type: Option<super::codeable_concept::CodeableConcept>,
pub reason_code: Vec<super::codeable_concept::CodeableConcept>,
pub reason_reference: Vec<super::reference::Reference>,
pub priority: Option<super::primitives::UnsignedInt>,
pub description: Option<super::primitives::String>,
pub supporting_information: Vec<super::reference::Reference>,
pub start: Option<super::primitives::Instant>,
pub end: Option<super::primitives::Instant>,
pub minutes_duration: Option<super::primitives::PositiveInt>,
pub slot: Vec<super::reference::Reference>,
pub created: Option<super::primitives::DateTime>,
pub comment: Option<super::primitives::String>,
pub patient_instruction: Option<super::primitives::String>,
pub based_on: Vec<super::reference::Reference>,
pub participant: Vec<AppointmentParticipant>,
pub requested_period: Vec<super::period::Period>,
}
impl super::super::codec::Json for Appointment {
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("Appointment")),
);
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 let Some(item) = &self.cancelation_reason {
object.insert(
std::string::String::from("cancelationReason"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.service_category.is_empty() {
let mut items = Vec::with_capacity(self.service_category.len());
for item in &self.service_category {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("serviceCategory"),
super::super::codec::Value::Array(items),
);
}
if !self.service_type.is_empty() {
let mut items = Vec::with_capacity(self.service_type.len());
for item in &self.service_type {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("serviceType"),
super::super::codec::Value::Array(items),
);
}
if !self.specialty.is_empty() {
let mut items = Vec::with_capacity(self.specialty.len());
for item in &self.specialty {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("specialty"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.appointment_type {
object.insert(
std::string::String::from("appointmentType"),
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 let Some(item) = &self.priority {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("priority"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_priority"), e);
}
}
if let Some(item) = &self.description {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("description"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_description"), e);
}
}
if !self.supporting_information.is_empty() {
let mut items = Vec::with_capacity(self.supporting_information.len());
for item in &self.supporting_information {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("supportingInformation"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.start {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("start"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_start"), e);
}
}
if let Some(item) = &self.end {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("end"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_end"), e);
}
}
if let Some(item) = &self.minutes_duration {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("minutesDuration"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_minutesDuration"), e);
}
}
if !self.slot.is_empty() {
let mut items = Vec::with_capacity(self.slot.len());
for item in &self.slot {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("slot"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.created {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("created"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_created"), e);
}
}
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.patient_instruction {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("patientInstruction"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_patientInstruction"), e);
}
}
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.requested_period.is_empty() {
let mut items = Vec::with_capacity(self.requested_period.len());
for item in &self.requested_period {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("requestedPeriod"),
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_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_cancelation_reason: Option<&super::super::codec::Value> = None;
let mut raw_service_category: Option<&super::super::codec::Value> = None;
let mut raw_service_type: Option<&super::super::codec::Value> = None;
let mut raw_specialty: Option<&super::super::codec::Value> = None;
let mut raw_appointment_type: 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_priority: Option<&super::super::codec::Value> = None;
let mut raw_priority_element: Option<&super::super::codec::Value> = None;
let mut raw_description: Option<&super::super::codec::Value> = None;
let mut raw_description_element: Option<&super::super::codec::Value> = None;
let mut raw_supporting_information: Option<&super::super::codec::Value> = None;
let mut raw_start: Option<&super::super::codec::Value> = None;
let mut raw_start_element: Option<&super::super::codec::Value> = None;
let mut raw_end: Option<&super::super::codec::Value> = None;
let mut raw_end_element: Option<&super::super::codec::Value> = None;
let mut raw_minutes_duration: Option<&super::super::codec::Value> = None;
let mut raw_minutes_duration_element: Option<&super::super::codec::Value> = None;
let mut raw_slot: Option<&super::super::codec::Value> = None;
let mut raw_created: Option<&super::super::codec::Value> = None;
let mut raw_created_element: 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_patient_instruction: Option<&super::super::codec::Value> = None;
let mut raw_patient_instruction_element: 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_requested_period: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("Appointment") {
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);
}
"cancelationReason" => {
raw_cancelation_reason = Some(value);
}
"serviceCategory" => {
raw_service_category = Some(value);
}
"serviceType" => {
raw_service_type = Some(value);
}
"specialty" => {
raw_specialty = Some(value);
}
"appointmentType" => {
raw_appointment_type = Some(value);
}
"reasonCode" => {
raw_reason_code = Some(value);
}
"reasonReference" => {
raw_reason_reference = Some(value);
}
"priority" => {
raw_priority = Some(value);
}
"_priority" => {
raw_priority_element = Some(value);
}
"description" => {
raw_description = Some(value);
}
"_description" => {
raw_description_element = Some(value);
}
"supportingInformation" => {
raw_supporting_information = Some(value);
}
"start" => {
raw_start = Some(value);
}
"_start" => {
raw_start_element = Some(value);
}
"end" => {
raw_end = Some(value);
}
"_end" => {
raw_end_element = Some(value);
}
"minutesDuration" => {
raw_minutes_duration = Some(value);
}
"_minutesDuration" => {
raw_minutes_duration_element = Some(value);
}
"slot" => {
raw_slot = Some(value);
}
"created" => {
raw_created = Some(value);
}
"_created" => {
raw_created_element = Some(value);
}
"comment" => {
raw_comment = Some(value);
}
"_comment" => {
raw_comment_element = Some(value);
}
"patientInstruction" => {
raw_patient_instruction = Some(value);
}
"_patientInstruction" => {
raw_patient_instruction_element = Some(value);
}
"basedOn" => {
raw_based_on = Some(value);
}
"participant" => {
raw_participant = Some(value);
}
"requestedPeriod" => {
raw_requested_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::super::codec::expect_string(value, 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 field_cancelation_reason = raw_cancelation_reason
.map(|value| {
path.with("cancelationReason", |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_service_category = Vec::new();
if let Some(raw) = raw_service_category {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_service_category.push(path.with_index("serviceCategory", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_service_type = Vec::new();
if let Some(raw) = raw_service_type {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_service_type.push(path.with_index("serviceType", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_specialty = Vec::new();
if let Some(raw) = raw_specialty {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_specialty.push(path.with_index("specialty", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_appointment_type = raw_appointment_type
.map(|value| {
path.with("appointmentType", |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 field_priority = match (raw_priority, raw_priority_element) {
(None, None) => None,
(value, element) => Some(path.with("priority", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_description = match (raw_description, raw_description_element) {
(None, None) => None,
(value, element) => Some(path.with("description", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_supporting_information = Vec::new();
if let Some(raw) = raw_supporting_information {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_supporting_information.push(path.with_index(
"supportingInformation",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_start = match (raw_start, raw_start_element) {
(None, None) => None,
(value, element) => Some(path.with("start", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_end = match (raw_end, raw_end_element) {
(None, None) => None,
(value, element) => Some(path.with("end", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_minutes_duration = match (raw_minutes_duration, raw_minutes_duration_element) {
(None, None) => None,
(value, element) => Some(path.with("minutesDuration", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_slot = Vec::new();
if let Some(raw) = raw_slot {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_slot.push(path.with_index("slot", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_created = match (raw_created, raw_created_element) {
(None, None) => None,
(value, element) => Some(path.with("created", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
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_patient_instruction =
match (raw_patient_instruction, raw_patient_instruction_element) {
(None, None) => None,
(value, element) => Some(path.with("patientInstruction", |path| {
super::super::codec::Primitive::from_json_parts(value, element, 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_requested_period = Vec::new();
if let Some(raw) = raw_requested_period {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_requested_period.push(path.with_index("requestedPeriod", 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,
status: field_status,
cancelation_reason: field_cancelation_reason,
service_category: field_service_category,
service_type: field_service_type,
specialty: field_specialty,
appointment_type: field_appointment_type,
reason_code: field_reason_code,
reason_reference: field_reason_reference,
priority: field_priority,
description: field_description,
supporting_information: field_supporting_information,
start: field_start,
end: field_end,
minutes_duration: field_minutes_duration,
slot: field_slot,
created: field_created,
comment: field_comment,
patient_instruction: field_patient_instruction,
based_on: field_based_on,
participant: field_participant,
requested_period: field_requested_period,
})
}
}
impl serde::Serialize for Appointment {
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(item) = &self.created {
super::super::codec::element_entry(&mut map, "_created", item)?;
}
if let Some(item) = &self.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
if let Some(item) = &self.end {
super::super::codec::element_entry(&mut map, "_end", item)?;
}
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)?;
}
if let Some(item) = &self.minutes_duration {
super::super::codec::element_entry(&mut map, "_minutesDuration", item)?;
}
if let Some(item) = &self.patient_instruction {
super::super::codec::element_entry(&mut map, "_patientInstruction", item)?;
}
if let Some(item) = &self.priority {
super::super::codec::element_entry(&mut map, "_priority", item)?;
}
if let Some(item) = &self.start {
super::super::codec::element_entry(&mut map, "_start", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.appointment_type {
serde::ser::SerializeMap::serialize_entry(&mut map, "appointmentType", item)?;
}
if !self.based_on.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "basedOn", &self.based_on)?;
}
if let Some(item) = &self.cancelation_reason {
serde::ser::SerializeMap::serialize_entry(&mut map, "cancelationReason", item)?;
}
if let Some(item) = &self.comment {
super::super::codec::value_entry(&mut map, "comment", item)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if let Some(item) = &self.created {
super::super::codec::value_entry(&mut map, "created", item)?;
}
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", item)?;
}
if let Some(item) = &self.end {
super::super::codec::value_entry(&mut map, "end", 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.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.meta {
serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
}
if let Some(item) = &self.minutes_duration {
super::super::codec::value_entry(&mut map, "minutesDuration", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if !self.participant.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "participant", &self.participant)?;
}
if let Some(item) = &self.patient_instruction {
super::super::codec::value_entry(&mut map, "patientInstruction", item)?;
}
if let Some(item) = &self.priority {
super::super::codec::value_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,
)?;
}
if !self.requested_period.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"requestedPeriod",
&self.requested_period,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "Appointment")?;
if !self.service_category.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"serviceCategory",
&self.service_category,
)?;
}
if !self.service_type.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "serviceType", &self.service_type)?;
}
if !self.slot.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "slot", &self.slot)?;
}
if !self.specialty.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "specialty", &self.specialty)?;
}
if let Some(item) = &self.start {
super::super::codec::value_entry(&mut map, "start", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if !self.supporting_information.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"supportingInformation",
&self.supporting_information,
)?;
}
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for Appointment {
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("Appointment");
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 AppointmentParticipant {
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 actor: Option<super::reference::Reference>,
pub required: Option<super::primitives::Code>,
pub status: super::primitives::Code,
pub period: Option<super::period::Period>,
}
impl super::super::codec::Json for AppointmentParticipant {
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.actor {
object.insert(
std::string::String::from("actor"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.required {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("required"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_required"), e);
}
}
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 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_type: Option<&super::super::codec::Value> = None;
let mut raw_actor: Option<&super::super::codec::Value> = None;
let mut raw_required: Option<&super::super::codec::Value> = None;
let mut raw_required_element: 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);
}
"type" => {
raw_type = Some(value);
}
"actor" => {
raw_actor = Some(value);
}
"required" => {
raw_required = Some(value);
}
"_required" => {
raw_required_element = 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::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 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_actor = raw_actor
.map(|value| {
path.with("actor", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_required = match (raw_required, raw_required_element) {
(None, None) => None,
(value, element) => Some(path.with("required", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, 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()?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
r#type: field_type,
actor: field_actor,
required: field_required,
status: field_status,
period: field_period,
})
}
}
impl serde::Serialize for AppointmentParticipant {
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.required {
super::super::codec::element_entry(&mut map, "_required", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.actor {
serde::ser::SerializeMap::serialize_entry(&mut map, "actor", 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.period {
serde::ser::SerializeMap::serialize_entry(&mut map, "period", item)?;
}
if let Some(item) = &self.required {
super::super::codec::value_entry(&mut map, "required", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
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 AppointmentParticipant {
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("AppointmentParticipant");
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)
}
}