#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PaymentReconciliation {
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 r#type: super::codeable_concept::CodeableConcept,
pub status: super::primitives::Code,
pub status_reason: Option<super::primitives::String>,
pub kind: Option<super::codeable_concept::CodeableConcept>,
pub period: Option<super::period::Period>,
pub created: super::primitives::DateTime,
pub enterer: Option<super::reference::Reference>,
pub issuer_type: Option<super::codeable_concept::CodeableConcept>,
pub payment_issuer: Option<super::reference::Reference>,
pub request: Option<super::reference::Reference>,
pub requestor: Option<super::reference::Reference>,
pub outcome: Option<super::primitives::Code>,
pub disposition: Option<super::primitives::String>,
pub date: super::primitives::Date,
pub location: Option<super::reference::Reference>,
pub method: Option<super::codeable_concept::CodeableConcept>,
pub card_brand: Option<super::primitives::String>,
pub account_number: Option<super::primitives::String>,
pub expiration_date: Option<super::primitives::Date>,
pub processor: Option<super::primitives::String>,
pub reference_number: Option<super::primitives::String>,
pub authorization: Option<super::primitives::String>,
pub tendered_amount: Option<super::money::Money>,
pub returned_amount: Option<super::money::Money>,
pub amount: Option<super::money::Money>,
pub payment_identifier: Option<super::identifier::Identifier>,
pub allocation: Vec<PaymentReconciliationAllocation>,
pub form_code: Option<super::codeable_concept::CodeableConcept>,
pub process_note: Vec<PaymentReconciliationProcessNote>,
}
impl super::super::codec::Json for PaymentReconciliation {
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("PaymentReconciliation")),
);
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),
);
}
object.insert(
std::string::String::from("type"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.r#type)?),
);
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.status_reason {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("statusReason"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_statusReason"), e);
}
}
if let Some(item) = &self.kind {
object.insert(
std::string::String::from("kind"),
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)?),
);
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.created)? {
object.insert(std::string::String::from("created"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.created)? {
object.insert(std::string::String::from("_created"), e);
}
if let Some(item) = &self.enterer {
object.insert(
std::string::String::from("enterer"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.issuer_type {
object.insert(
std::string::String::from("issuerType"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.payment_issuer {
object.insert(
std::string::String::from("paymentIssuer"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.request {
object.insert(
std::string::String::from("request"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.requestor {
object.insert(
std::string::String::from("requestor"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.outcome {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("outcome"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_outcome"), e);
}
}
if let Some(item) = &self.disposition {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("disposition"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_disposition"), e);
}
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.date)? {
object.insert(std::string::String::from("date"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.date)? {
object.insert(std::string::String::from("_date"), e);
}
if let Some(item) = &self.location {
object.insert(
std::string::String::from("location"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.method {
object.insert(
std::string::String::from("method"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.card_brand {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("cardBrand"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_cardBrand"), e);
}
}
if let Some(item) = &self.account_number {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("accountNumber"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_accountNumber"), e);
}
}
if let Some(item) = &self.expiration_date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("expirationDate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_expirationDate"), e);
}
}
if let Some(item) = &self.processor {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("processor"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_processor"), e);
}
}
if let Some(item) = &self.reference_number {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("referenceNumber"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_referenceNumber"), e);
}
}
if let Some(item) = &self.authorization {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("authorization"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_authorization"), e);
}
}
if let Some(item) = &self.tendered_amount {
object.insert(
std::string::String::from("tenderedAmount"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.returned_amount {
object.insert(
std::string::String::from("returnedAmount"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.amount {
object.insert(
std::string::String::from("amount"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.payment_identifier {
object.insert(
std::string::String::from("paymentIdentifier"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.allocation.is_empty() {
let mut items = Vec::with_capacity(self.allocation.len());
for item in &self.allocation {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("allocation"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.form_code {
object.insert(
std::string::String::from("formCode"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.process_note.is_empty() {
let mut items = Vec::with_capacity(self.process_note.len());
for item in &self.process_note {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("processNote"),
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_type: 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_reason: Option<&super::super::codec::Value> = None;
let mut raw_status_reason_element: Option<&super::super::codec::Value> = None;
let mut raw_kind: Option<&super::super::codec::Value> = None;
let mut raw_period: 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_enterer: Option<&super::super::codec::Value> = None;
let mut raw_issuer_type: Option<&super::super::codec::Value> = None;
let mut raw_payment_issuer: Option<&super::super::codec::Value> = None;
let mut raw_request: Option<&super::super::codec::Value> = None;
let mut raw_requestor: Option<&super::super::codec::Value> = None;
let mut raw_outcome: Option<&super::super::codec::Value> = None;
let mut raw_outcome_element: Option<&super::super::codec::Value> = None;
let mut raw_disposition: Option<&super::super::codec::Value> = None;
let mut raw_disposition_element: Option<&super::super::codec::Value> = None;
let mut raw_date: Option<&super::super::codec::Value> = None;
let mut raw_date_element: Option<&super::super::codec::Value> = None;
let mut raw_location: Option<&super::super::codec::Value> = None;
let mut raw_method: Option<&super::super::codec::Value> = None;
let mut raw_card_brand: Option<&super::super::codec::Value> = None;
let mut raw_card_brand_element: Option<&super::super::codec::Value> = None;
let mut raw_account_number: Option<&super::super::codec::Value> = None;
let mut raw_account_number_element: Option<&super::super::codec::Value> = None;
let mut raw_expiration_date: Option<&super::super::codec::Value> = None;
let mut raw_expiration_date_element: Option<&super::super::codec::Value> = None;
let mut raw_processor: Option<&super::super::codec::Value> = None;
let mut raw_processor_element: Option<&super::super::codec::Value> = None;
let mut raw_reference_number: Option<&super::super::codec::Value> = None;
let mut raw_reference_number_element: Option<&super::super::codec::Value> = None;
let mut raw_authorization: Option<&super::super::codec::Value> = None;
let mut raw_authorization_element: Option<&super::super::codec::Value> = None;
let mut raw_tendered_amount: Option<&super::super::codec::Value> = None;
let mut raw_returned_amount: Option<&super::super::codec::Value> = None;
let mut raw_amount: Option<&super::super::codec::Value> = None;
let mut raw_payment_identifier: Option<&super::super::codec::Value> = None;
let mut raw_allocation: Option<&super::super::codec::Value> = None;
let mut raw_form_code: Option<&super::super::codec::Value> = None;
let mut raw_process_note: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("PaymentReconciliation") {
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);
}
"type" => {
raw_type = Some(value);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"statusReason" => {
raw_status_reason = Some(value);
}
"_statusReason" => {
raw_status_reason_element = Some(value);
}
"kind" => {
raw_kind = Some(value);
}
"period" => {
raw_period = Some(value);
}
"created" => {
raw_created = Some(value);
}
"_created" => {
raw_created_element = Some(value);
}
"enterer" => {
raw_enterer = Some(value);
}
"issuerType" => {
raw_issuer_type = Some(value);
}
"paymentIssuer" => {
raw_payment_issuer = Some(value);
}
"request" => {
raw_request = Some(value);
}
"requestor" => {
raw_requestor = Some(value);
}
"outcome" => {
raw_outcome = Some(value);
}
"_outcome" => {
raw_outcome_element = Some(value);
}
"disposition" => {
raw_disposition = Some(value);
}
"_disposition" => {
raw_disposition_element = Some(value);
}
"date" => {
raw_date = Some(value);
}
"_date" => {
raw_date_element = Some(value);
}
"location" => {
raw_location = Some(value);
}
"method" => {
raw_method = Some(value);
}
"cardBrand" => {
raw_card_brand = Some(value);
}
"_cardBrand" => {
raw_card_brand_element = Some(value);
}
"accountNumber" => {
raw_account_number = Some(value);
}
"_accountNumber" => {
raw_account_number_element = Some(value);
}
"expirationDate" => {
raw_expiration_date = Some(value);
}
"_expirationDate" => {
raw_expiration_date_element = Some(value);
}
"processor" => {
raw_processor = Some(value);
}
"_processor" => {
raw_processor_element = Some(value);
}
"referenceNumber" => {
raw_reference_number = Some(value);
}
"_referenceNumber" => {
raw_reference_number_element = Some(value);
}
"authorization" => {
raw_authorization = Some(value);
}
"_authorization" => {
raw_authorization_element = Some(value);
}
"tenderedAmount" => {
raw_tendered_amount = Some(value);
}
"returnedAmount" => {
raw_returned_amount = Some(value);
}
"amount" => {
raw_amount = Some(value);
}
"paymentIdentifier" => {
raw_payment_identifier = Some(value);
}
"allocation" => {
raw_allocation = Some(value);
}
"formCode" => {
raw_form_code = Some(value);
}
"processNote" => {
raw_process_note = 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_id(
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 path
.with("contained", |path| {
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 path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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 path
.with("identifier", |path| {
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_type = path.with("type", |path| {
let value = raw_type
.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 = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let field_status_reason = match (raw_status_reason, raw_status_reason_element) {
(None, None) => None,
(value, element) => Some(path.with("statusReason", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_kind = raw_kind
.map(|value| {
path.with("kind", |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()?;
let field_created = path.with("created", |path| {
super::super::codec::Primitive::from_json_parts(raw_created, raw_created_element, path)
})?;
let field_enterer = raw_enterer
.map(|value| {
path.with("enterer", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_issuer_type = raw_issuer_type
.map(|value| {
path.with("issuerType", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_payment_issuer = raw_payment_issuer
.map(|value| {
path.with("paymentIssuer", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_request = raw_request
.map(|value| {
path.with("request", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_requestor = raw_requestor
.map(|value| {
path.with("requestor", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_outcome = match (raw_outcome, raw_outcome_element) {
(None, None) => None,
(value, element) => Some(path.with("outcome", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_disposition = match (raw_disposition, raw_disposition_element) {
(None, None) => None,
(value, element) => Some(path.with("disposition", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_date = path.with("date", |path| {
super::super::codec::Primitive::from_json_parts(raw_date, raw_date_element, path)
})?;
let field_location = raw_location
.map(|value| {
path.with("location", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_method = raw_method
.map(|value| {
path.with("method", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_card_brand = match (raw_card_brand, raw_card_brand_element) {
(None, None) => None,
(value, element) => Some(path.with("cardBrand", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_account_number = match (raw_account_number, raw_account_number_element) {
(None, None) => None,
(value, element) => Some(path.with("accountNumber", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_expiration_date = match (raw_expiration_date, raw_expiration_date_element) {
(None, None) => None,
(value, element) => Some(path.with("expirationDate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_processor = match (raw_processor, raw_processor_element) {
(None, None) => None,
(value, element) => Some(path.with("processor", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_reference_number = match (raw_reference_number, raw_reference_number_element) {
(None, None) => None,
(value, element) => Some(path.with("referenceNumber", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_authorization = match (raw_authorization, raw_authorization_element) {
(None, None) => None,
(value, element) => Some(path.with("authorization", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_tendered_amount = raw_tendered_amount
.map(|value| {
path.with("tenderedAmount", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_returned_amount = raw_returned_amount
.map(|value| {
path.with("returnedAmount", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_amount = raw_amount
.map(|value| {
path.with("amount", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_payment_identifier = raw_payment_identifier
.map(|value| {
path.with("paymentIdentifier", |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_allocation = Vec::new();
if let Some(raw) = raw_allocation {
for (index, value) in path
.with("allocation", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_allocation.push(path.with_index("allocation", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_form_code = raw_form_code
.map(|value| {
path.with("formCode", |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_process_note = Vec::new();
if let Some(raw) = raw_process_note {
for (index, value) in path
.with("processNote", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_process_note.push(path.with_index("processNote", 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,
r#type: field_type,
status: field_status,
status_reason: field_status_reason,
kind: field_kind,
period: field_period,
created: field_created,
enterer: field_enterer,
issuer_type: field_issuer_type,
payment_issuer: field_payment_issuer,
request: field_request,
requestor: field_requestor,
outcome: field_outcome,
disposition: field_disposition,
date: field_date,
location: field_location,
method: field_method,
card_brand: field_card_brand,
account_number: field_account_number,
expiration_date: field_expiration_date,
processor: field_processor,
reference_number: field_reference_number,
authorization: field_authorization,
tendered_amount: field_tendered_amount,
returned_amount: field_returned_amount,
amount: field_amount,
payment_identifier: field_payment_identifier,
allocation: field_allocation,
form_code: field_form_code,
process_note: field_process_note,
})
}
}
impl serde::Serialize for PaymentReconciliation {
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.account_number {
super::super::codec::element_entry(&mut map, "_accountNumber", item)?;
}
if let Some(item) = &self.authorization {
super::super::codec::element_entry(&mut map, "_authorization", item)?;
}
if let Some(item) = &self.card_brand {
super::super::codec::element_entry(&mut map, "_cardBrand", item)?;
}
super::super::codec::element_entry(&mut map, "_created", &self.created)?;
super::super::codec::element_entry(&mut map, "_date", &self.date)?;
if let Some(item) = &self.disposition {
super::super::codec::element_entry(&mut map, "_disposition", item)?;
}
if let Some(item) = &self.expiration_date {
super::super::codec::element_entry(&mut map, "_expirationDate", 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.outcome {
super::super::codec::element_entry(&mut map, "_outcome", item)?;
}
if let Some(item) = &self.processor {
super::super::codec::element_entry(&mut map, "_processor", item)?;
}
if let Some(item) = &self.reference_number {
super::super::codec::element_entry(&mut map, "_referenceNumber", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.status_reason {
super::super::codec::element_entry(&mut map, "_statusReason", item)?;
}
if let Some(item) = &self.account_number {
super::super::codec::value_entry(&mut map, "accountNumber", item)?;
}
if !self.allocation.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "allocation", &self.allocation)?;
}
if let Some(item) = &self.amount {
serde::ser::SerializeMap::serialize_entry(&mut map, "amount", item)?;
}
if let Some(item) = &self.authorization {
super::super::codec::value_entry(&mut map, "authorization", item)?;
}
if let Some(item) = &self.card_brand {
super::super::codec::value_entry(&mut map, "cardBrand", item)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
super::super::codec::value_entry(&mut map, "created", &self.created)?;
super::super::codec::value_entry(&mut map, "date", &self.date)?;
if let Some(item) = &self.disposition {
super::super::codec::value_entry(&mut map, "disposition", item)?;
}
if let Some(item) = &self.enterer {
serde::ser::SerializeMap::serialize_entry(&mut map, "enterer", item)?;
}
if let Some(item) = &self.expiration_date {
super::super::codec::value_entry(&mut map, "expirationDate", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(item) = &self.form_code {
serde::ser::SerializeMap::serialize_entry(&mut map, "formCode", 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.issuer_type {
serde::ser::SerializeMap::serialize_entry(&mut map, "issuerType", item)?;
}
if let Some(item) = &self.kind {
serde::ser::SerializeMap::serialize_entry(&mut map, "kind", item)?;
}
if let Some(item) = &self.language {
super::super::codec::value_entry(&mut map, "language", item)?;
}
if let Some(item) = &self.location {
serde::ser::SerializeMap::serialize_entry(&mut map, "location", item)?;
}
if let Some(item) = &self.meta {
serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
}
if let Some(item) = &self.method {
serde::ser::SerializeMap::serialize_entry(&mut map, "method", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.outcome {
super::super::codec::value_entry(&mut map, "outcome", item)?;
}
if let Some(item) = &self.payment_identifier {
serde::ser::SerializeMap::serialize_entry(&mut map, "paymentIdentifier", item)?;
}
if let Some(item) = &self.payment_issuer {
serde::ser::SerializeMap::serialize_entry(&mut map, "paymentIssuer", item)?;
}
if let Some(item) = &self.period {
serde::ser::SerializeMap::serialize_entry(&mut map, "period", item)?;
}
if !self.process_note.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "processNote", &self.process_note)?;
}
if let Some(item) = &self.processor {
super::super::codec::value_entry(&mut map, "processor", item)?;
}
if let Some(item) = &self.reference_number {
super::super::codec::value_entry(&mut map, "referenceNumber", item)?;
}
if let Some(item) = &self.request {
serde::ser::SerializeMap::serialize_entry(&mut map, "request", item)?;
}
if let Some(item) = &self.requestor {
serde::ser::SerializeMap::serialize_entry(&mut map, "requestor", item)?;
}
serde::ser::SerializeMap::serialize_entry(
&mut map,
"resourceType",
"PaymentReconciliation",
)?;
if let Some(item) = &self.returned_amount {
serde::ser::SerializeMap::serialize_entry(&mut map, "returnedAmount", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if let Some(item) = &self.status_reason {
super::super::codec::value_entry(&mut map, "statusReason", item)?;
}
if let Some(item) = &self.tendered_amount {
serde::ser::SerializeMap::serialize_entry(&mut map, "tenderedAmount", item)?;
}
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "type", &self.r#type)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for PaymentReconciliation {
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("PaymentReconciliation");
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 PaymentReconciliationAllocation {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub identifier: Option<super::identifier::Identifier>,
pub predecessor: Option<super::identifier::Identifier>,
pub target: Option<super::reference::Reference>,
pub target_item: Option<PaymentReconciliationAllocationTargetItem>,
pub characteristics: Option<super::reference::Reference>,
pub encounter: Option<super::reference::Reference>,
pub account: Option<super::reference::Reference>,
pub r#type: Option<super::codeable_concept::CodeableConcept>,
pub submitter: Option<super::reference::Reference>,
pub response: Option<super::reference::Reference>,
pub date: Option<super::primitives::Date>,
pub responsible: Option<super::reference::Reference>,
pub payee: Option<super::reference::Reference>,
pub amount: Option<super::money::Money>,
pub note_number: Vec<super::primitives::PositiveInt>,
}
impl super::super::codec::Json for PaymentReconciliationAllocation {
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.identifier {
object.insert(
std::string::String::from("identifier"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.predecessor {
object.insert(
std::string::String::from("predecessor"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.target {
object.insert(
std::string::String::from("target"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.target_item {
let (suffix, value, element) = item.to_json_parts()?;
if let Some(value) = value {
object.insert(format!("targetItem{suffix}"), value);
}
if let Some(element) = element {
object.insert(format!("_targetItem{suffix}"), element);
}
}
if let Some(item) = &self.characteristics {
object.insert(
std::string::String::from("characteristics"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.encounter {
object.insert(
std::string::String::from("encounter"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.account {
object.insert(
std::string::String::from("account"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.r#type {
object.insert(
std::string::String::from("type"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.submitter {
object.insert(
std::string::String::from("submitter"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.response {
object.insert(
std::string::String::from("response"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("date"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_date"), e);
}
}
if let Some(item) = &self.responsible {
object.insert(
std::string::String::from("responsible"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.payee {
object.insert(
std::string::String::from("payee"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.amount {
object.insert(
std::string::String::from("amount"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.note_number.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.note_number)?;
if let Some(values) = values {
object.insert(std::string::String::from("noteNumber"), values);
}
if let Some(elements) = elements {
object.insert(std::string::String::from("_noteNumber"), elements);
}
}
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_identifier: Option<&super::super::codec::Value> = None;
let mut raw_predecessor: Option<&super::super::codec::Value> = None;
let mut raw_target: Option<&super::super::codec::Value> = None;
let mut raw_target_item = super::super::codec::ChoiceSlot::default();
let mut raw_characteristics: Option<&super::super::codec::Value> = None;
let mut raw_encounter: Option<&super::super::codec::Value> = None;
let mut raw_account: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_submitter: Option<&super::super::codec::Value> = None;
let mut raw_response: Option<&super::super::codec::Value> = None;
let mut raw_date: Option<&super::super::codec::Value> = None;
let mut raw_date_element: Option<&super::super::codec::Value> = None;
let mut raw_responsible: Option<&super::super::codec::Value> = None;
let mut raw_payee: Option<&super::super::codec::Value> = None;
let mut raw_amount: Option<&super::super::codec::Value> = None;
let mut raw_note_number: Option<&super::super::codec::Value> = None;
let mut raw_note_number_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);
}
"identifier" => {
raw_identifier = Some(value);
}
"predecessor" => {
raw_predecessor = Some(value);
}
"target" => {
raw_target = Some(value);
}
"targetItemString" => {
raw_target_item.value("String", value, path)?;
}
"_targetItemString" => {
raw_target_item.element("String", value, path)?;
}
"targetItemIdentifier" => {
raw_target_item.value("Identifier", value, path)?;
}
"_targetItemIdentifier" => {
raw_target_item.element("Identifier", value, path)?;
}
"targetItemPositiveInt" => {
raw_target_item.value("PositiveInt", value, path)?;
}
"_targetItemPositiveInt" => {
raw_target_item.element("PositiveInt", value, path)?;
}
"characteristics" => {
raw_characteristics = Some(value);
}
"encounter" => {
raw_encounter = Some(value);
}
"account" => {
raw_account = Some(value);
}
"type" => {
raw_type = Some(value);
}
"submitter" => {
raw_submitter = Some(value);
}
"response" => {
raw_response = Some(value);
}
"date" => {
raw_date = Some(value);
}
"_date" => {
raw_date_element = Some(value);
}
"responsible" => {
raw_responsible = Some(value);
}
"payee" => {
raw_payee = Some(value);
}
"amount" => {
raw_amount = Some(value);
}
"noteNumber" => {
raw_note_number = Some(value);
}
"_noteNumber" => {
raw_note_number_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 path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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_identifier = raw_identifier
.map(|value| {
path.with("identifier", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_predecessor = raw_predecessor
.map(|value| {
path.with("predecessor", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_target = raw_target
.map(|value| {
path.with("target", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_target_item = match raw_target_item.suffix {
None => None,
Some(suffix) => Some(path.with("targetItem", |path| {
PaymentReconciliationAllocationTargetItem::from_json_parts(
suffix,
raw_target_item.value,
raw_target_item.element,
path,
)
})?),
};
let field_characteristics = raw_characteristics
.map(|value| {
path.with("characteristics", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_encounter = raw_encounter
.map(|value| {
path.with("encounter", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_account = raw_account
.map(|value| {
path.with("account", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_type = raw_type
.map(|value| {
path.with("type", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_submitter = raw_submitter
.map(|value| {
path.with("submitter", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_response = raw_response
.map(|value| {
path.with("response", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_date = match (raw_date, raw_date_element) {
(None, None) => None,
(value, element) => Some(path.with("date", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_responsible = raw_responsible
.map(|value| {
path.with("responsible", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_payee = raw_payee
.map(|value| {
path.with("payee", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_amount = raw_amount
.map(|value| {
path.with("amount", |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_note_number = Vec::new();
for (index, (value, element)) in path
.with("noteNumber", |path| {
super::super::codec::pair_arrays(raw_note_number, raw_note_number_element, path)
})?
.into_iter()
.enumerate()
{
field_note_number.push(path.with_index("noteNumber", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
identifier: field_identifier,
predecessor: field_predecessor,
target: field_target,
target_item: field_target_item,
characteristics: field_characteristics,
encounter: field_encounter,
account: field_account,
r#type: field_type,
submitter: field_submitter,
response: field_response,
date: field_date,
responsible: field_responsible,
payee: field_payee,
amount: field_amount,
note_number: field_note_number,
})
}
}
impl serde::Serialize for PaymentReconciliationAllocation {
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.date {
super::super::codec::element_entry(&mut map, "_date", item)?;
}
super::super::codec::element_list_entry(&mut map, "_noteNumber", &self.note_number)?;
match &self.target_item {
Some(PaymentReconciliationAllocationTargetItem::PositiveInt(inner)) => {
super::super::codec::element_entry(&mut map, "_targetItemPositiveInt", inner)?;
}
Some(PaymentReconciliationAllocationTargetItem::String(inner)) => {
super::super::codec::element_entry(&mut map, "_targetItemString", inner)?;
}
_ => {}
}
if let Some(item) = &self.account {
serde::ser::SerializeMap::serialize_entry(&mut map, "account", item)?;
}
if let Some(item) = &self.amount {
serde::ser::SerializeMap::serialize_entry(&mut map, "amount", item)?;
}
if let Some(item) = &self.characteristics {
serde::ser::SerializeMap::serialize_entry(&mut map, "characteristics", item)?;
}
if let Some(item) = &self.date {
super::super::codec::value_entry(&mut map, "date", item)?;
}
if let Some(item) = &self.encounter {
serde::ser::SerializeMap::serialize_entry(&mut map, "encounter", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
if let Some(item) = &self.identifier {
serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
super::super::codec::value_list_entry(&mut map, "noteNumber", &self.note_number)?;
if let Some(item) = &self.payee {
serde::ser::SerializeMap::serialize_entry(&mut map, "payee", item)?;
}
if let Some(item) = &self.predecessor {
serde::ser::SerializeMap::serialize_entry(&mut map, "predecessor", item)?;
}
if let Some(item) = &self.response {
serde::ser::SerializeMap::serialize_entry(&mut map, "response", item)?;
}
if let Some(item) = &self.responsible {
serde::ser::SerializeMap::serialize_entry(&mut map, "responsible", item)?;
}
if let Some(item) = &self.submitter {
serde::ser::SerializeMap::serialize_entry(&mut map, "submitter", item)?;
}
if let Some(item) = &self.target {
serde::ser::SerializeMap::serialize_entry(&mut map, "target", item)?;
}
match &self.target_item {
Some(PaymentReconciliationAllocationTargetItem::Identifier(inner)) => {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"targetItemIdentifier",
inner.as_ref(),
)?;
}
Some(PaymentReconciliationAllocationTargetItem::PositiveInt(inner)) => {
super::super::codec::value_entry(&mut map, "targetItemPositiveInt", inner)?;
}
Some(PaymentReconciliationAllocationTargetItem::String(inner)) => {
super::super::codec::value_entry(&mut map, "targetItemString", inner)?;
}
None => {}
}
if let Some(item) = &self.r#type {
serde::ser::SerializeMap::serialize_entry(&mut map, "type", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for PaymentReconciliationAllocation {
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("PaymentReconciliationAllocation");
let object =
super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PaymentReconciliationAllocationTargetItem {
String(super::primitives::String),
Identifier(Box<super::identifier::Identifier>),
PositiveInt(super::primitives::PositiveInt),
}
impl PaymentReconciliationAllocationTargetItem {
pub fn to_json_parts(
&self,
) -> Result<
(
&'static str,
Option<super::super::codec::Value>,
Option<super::super::codec::Value>,
),
super::super::codec::EncodeError,
> {
match self {
Self::String(inner) => Ok((
"String",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::Identifier(inner) => Ok((
"Identifier",
Some(super::super::codec::Value::Object(
super::super::codec::Json::to_json(inner.as_ref())?,
)),
None,
)),
Self::PositiveInt(inner) => Ok((
"PositiveInt",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
}
}
pub fn from_json_parts(
suffix: &str,
value: Option<&super::super::codec::Value>,
element: Option<&super::super::codec::Value>,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
match suffix {
"String" => Ok(Self::String(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"Identifier" => {
if element.is_some() {
return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
expected: "no underscore form for a complex type",
}));
}
let value = value.ok_or_else(|| {
path.error(super::super::codec::DecodeErrorKind::MissingProperty)
})?;
let inner = super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)?;
Ok(Self::Identifier(Box::new(inner)))
}
"PositiveInt" => Ok(Self::PositiveInt(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
_ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PaymentReconciliationProcessNote {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub class: Option<super::codeable_concept::CodeableConcept>,
pub number: Option<super::primitives::PositiveInt>,
pub r#type: Option<super::primitives::Code>,
pub text: Option<super::primitives::Markdown>,
}
impl super::super::codec::Json for PaymentReconciliationProcessNote {
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.class {
object.insert(
std::string::String::from("class"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.number {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("number"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_number"), e);
}
}
if let Some(item) = &self.r#type {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("type"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_type"), e);
}
}
if let Some(item) = &self.text {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("text"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_text"), e);
}
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_class: Option<&super::super::codec::Value> = None;
let mut raw_number: Option<&super::super::codec::Value> = None;
let mut raw_number_element: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_type_element: Option<&super::super::codec::Value> = None;
let mut raw_text: Option<&super::super::codec::Value> = None;
let mut raw_text_element: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"class" => {
raw_class = Some(value);
}
"number" => {
raw_number = Some(value);
}
"_number" => {
raw_number_element = Some(value);
}
"type" => {
raw_type = Some(value);
}
"_type" => {
raw_type_element = Some(value);
}
"text" => {
raw_text = Some(value);
}
"_text" => {
raw_text_element = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::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 path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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 = raw_class
.map(|value| {
path.with("class", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_number = match (raw_number, raw_number_element) {
(None, None) => None,
(value, element) => Some(path.with("number", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_type = match (raw_type, raw_type_element) {
(None, None) => None,
(value, element) => Some(path.with("type", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_text = match (raw_text, raw_text_element) {
(None, None) => None,
(value, element) => Some(path.with("text", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
class: field_class,
number: field_number,
r#type: field_type,
text: field_text,
})
}
}
impl serde::Serialize for PaymentReconciliationProcessNote {
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.number {
super::super::codec::element_entry(&mut map, "_number", item)?;
}
if let Some(item) = &self.text {
super::super::codec::element_entry(&mut map, "_text", item)?;
}
if let Some(item) = &self.r#type {
super::super::codec::element_entry(&mut map, "_type", item)?;
}
if let Some(item) = &self.class {
serde::ser::SerializeMap::serialize_entry(&mut map, "class", 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.number {
super::super::codec::value_entry(&mut map, "number", item)?;
}
if let Some(item) = &self.text {
super::super::codec::value_entry(&mut map, "text", item)?;
}
if let Some(item) = &self.r#type {
super::super::codec::value_entry(&mut map, "type", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for PaymentReconciliationProcessNote {
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("PaymentReconciliationProcessNote");
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)
}
}