#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Measure {
pub id: Option<super::primitives::Id>,
pub meta: Option<super::meta::Meta>,
pub implicit_rules: Option<super::primitives::Uri>,
pub language: Option<super::primitives::Code>,
pub text: Option<super::narrative::Narrative>,
pub contained: Vec<super::resource::Resource>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub url: Option<super::primitives::Uri>,
pub identifier: Vec<super::identifier::Identifier>,
pub version: Option<super::primitives::String>,
pub name: Option<super::primitives::String>,
pub title: Option<super::primitives::String>,
pub status: super::primitives::Code,
pub experimental: Option<super::primitives::Boolean>,
pub date: Option<super::primitives::DateTime>,
pub publisher: Option<super::primitives::String>,
pub description: Option<super::primitives::Markdown>,
pub purpose: Option<super::primitives::Markdown>,
pub usage: Option<super::primitives::String>,
pub approval_date: Option<super::primitives::Date>,
pub last_review_date: Option<super::primitives::Date>,
pub effective_period: Option<super::period::Period>,
pub use_context: Vec<super::usage_context::UsageContext>,
pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
pub topic: Vec<super::codeable_concept::CodeableConcept>,
pub contributor: Vec<super::contributor::Contributor>,
pub contact: Vec<super::contact_detail::ContactDetail>,
pub copyright: Option<super::primitives::Markdown>,
pub related_artifact: Vec<super::related_artifact::RelatedArtifact>,
pub library: Vec<super::reference::Reference>,
pub disclaimer: Option<super::primitives::Markdown>,
pub scoring: Option<super::codeable_concept::CodeableConcept>,
pub composite_scoring: Option<super::codeable_concept::CodeableConcept>,
pub r#type: Vec<super::codeable_concept::CodeableConcept>,
pub risk_adjustment: Option<super::primitives::String>,
pub rate_aggregation: Option<super::primitives::String>,
pub rationale: Option<super::primitives::Markdown>,
pub clinical_recommendation_statement: Option<super::primitives::Markdown>,
pub improvement_notation: Option<super::primitives::String>,
pub definition: Vec<super::primitives::Markdown>,
pub guidance: Option<super::primitives::Markdown>,
pub set: Option<super::primitives::String>,
pub group: Vec<MeasureGroup>,
pub supplemental_data: Vec<MeasureSupplementalData>,
}
impl super::super::codec::Json for Measure {
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("Measure")),
);
if let Some(item) = &self.id {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("id"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_id"), e);
}
}
if let Some(item) = &self.meta {
object.insert(
std::string::String::from("meta"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.implicit_rules {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("implicitRules"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_implicitRules"), e);
}
}
if let Some(item) = &self.language {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("language"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_language"), e);
}
}
if let Some(item) = &self.text {
object.insert(
std::string::String::from("text"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.contained.is_empty() {
let mut items = Vec::with_capacity(self.contained.len());
for item in &self.contained {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("contained"),
super::super::codec::Value::Array(items),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.url {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("url"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_url"), e);
}
}
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(item) = &self.version {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("version"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_version"), e);
}
}
if let Some(item) = &self.name {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_name"), e);
}
}
if let Some(item) = &self.title {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("title"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_title"), 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.experimental {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("experimental"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_experimental"), e);
}
}
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.publisher {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("publisher"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_publisher"), 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 let Some(item) = &self.purpose {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("purpose"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_purpose"), e);
}
}
if let Some(item) = &self.usage {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("usage"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_usage"), e);
}
}
if let Some(item) = &self.approval_date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("approvalDate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_approvalDate"), e);
}
}
if let Some(item) = &self.last_review_date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("lastReviewDate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_lastReviewDate"), e);
}
}
if let Some(item) = &self.effective_period {
object.insert(
std::string::String::from("effectivePeriod"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.use_context.is_empty() {
let mut items = Vec::with_capacity(self.use_context.len());
for item in &self.use_context {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("useContext"),
super::super::codec::Value::Array(items),
);
}
if !self.jurisdiction.is_empty() {
let mut items = Vec::with_capacity(self.jurisdiction.len());
for item in &self.jurisdiction {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("jurisdiction"),
super::super::codec::Value::Array(items),
);
}
if !self.topic.is_empty() {
let mut items = Vec::with_capacity(self.topic.len());
for item in &self.topic {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("topic"),
super::super::codec::Value::Array(items),
);
}
if !self.contributor.is_empty() {
let mut items = Vec::with_capacity(self.contributor.len());
for item in &self.contributor {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("contributor"),
super::super::codec::Value::Array(items),
);
}
if !self.contact.is_empty() {
let mut items = Vec::with_capacity(self.contact.len());
for item in &self.contact {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("contact"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.copyright {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("copyright"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_copyright"), e);
}
}
if !self.related_artifact.is_empty() {
let mut items = Vec::with_capacity(self.related_artifact.len());
for item in &self.related_artifact {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("relatedArtifact"),
super::super::codec::Value::Array(items),
);
}
if !self.library.is_empty() {
let mut items = Vec::with_capacity(self.library.len());
for item in &self.library {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("library"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.disclaimer {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("disclaimer"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_disclaimer"), e);
}
}
if let Some(item) = &self.scoring {
object.insert(
std::string::String::from("scoring"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.composite_scoring {
object.insert(
std::string::String::from("compositeScoring"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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.risk_adjustment {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("riskAdjustment"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_riskAdjustment"), e);
}
}
if let Some(item) = &self.rate_aggregation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("rateAggregation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_rateAggregation"), e);
}
}
if let Some(item) = &self.rationale {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("rationale"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_rationale"), e);
}
}
if let Some(item) = &self.clinical_recommendation_statement {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(
std::string::String::from("clinicalRecommendationStatement"),
v,
);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(
std::string::String::from("_clinicalRecommendationStatement"),
e,
);
}
}
if let Some(item) = &self.improvement_notation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("improvementNotation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_improvementNotation"), e);
}
}
if !self.definition.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.definition)?;
object.insert(std::string::String::from("definition"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_definition"), elements);
}
}
if let Some(item) = &self.guidance {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("guidance"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_guidance"), e);
}
}
if let Some(item) = &self.set {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("set"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_set"), e);
}
}
if !self.group.is_empty() {
let mut items = Vec::with_capacity(self.group.len());
for item in &self.group {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("group"),
super::super::codec::Value::Array(items),
);
}
if !self.supplemental_data.is_empty() {
let mut items = Vec::with_capacity(self.supplemental_data.len());
for item in &self.supplemental_data {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("supplementalData"),
super::super::codec::Value::Array(items),
);
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_id_element: Option<&super::super::codec::Value> = None;
let mut raw_meta: Option<&super::super::codec::Value> = None;
let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
let mut raw_language: Option<&super::super::codec::Value> = None;
let mut raw_language_element: Option<&super::super::codec::Value> = None;
let mut raw_text: Option<&super::super::codec::Value> = None;
let mut raw_contained: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_url: Option<&super::super::codec::Value> = None;
let mut raw_url_element: Option<&super::super::codec::Value> = None;
let mut raw_identifier: Option<&super::super::codec::Value> = None;
let mut raw_version: Option<&super::super::codec::Value> = None;
let mut raw_version_element: Option<&super::super::codec::Value> = None;
let mut raw_name: Option<&super::super::codec::Value> = None;
let mut raw_name_element: Option<&super::super::codec::Value> = None;
let mut raw_title: Option<&super::super::codec::Value> = None;
let mut raw_title_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_experimental: Option<&super::super::codec::Value> = None;
let mut raw_experimental_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_publisher: Option<&super::super::codec::Value> = None;
let mut raw_publisher_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_purpose: Option<&super::super::codec::Value> = None;
let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
let mut raw_usage: Option<&super::super::codec::Value> = None;
let mut raw_usage_element: Option<&super::super::codec::Value> = None;
let mut raw_approval_date: Option<&super::super::codec::Value> = None;
let mut raw_approval_date_element: Option<&super::super::codec::Value> = None;
let mut raw_last_review_date: Option<&super::super::codec::Value> = None;
let mut raw_last_review_date_element: Option<&super::super::codec::Value> = None;
let mut raw_effective_period: Option<&super::super::codec::Value> = None;
let mut raw_use_context: Option<&super::super::codec::Value> = None;
let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
let mut raw_topic: Option<&super::super::codec::Value> = None;
let mut raw_contributor: Option<&super::super::codec::Value> = None;
let mut raw_contact: Option<&super::super::codec::Value> = None;
let mut raw_copyright: Option<&super::super::codec::Value> = None;
let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
let mut raw_related_artifact: Option<&super::super::codec::Value> = None;
let mut raw_library: Option<&super::super::codec::Value> = None;
let mut raw_disclaimer: Option<&super::super::codec::Value> = None;
let mut raw_disclaimer_element: Option<&super::super::codec::Value> = None;
let mut raw_scoring: Option<&super::super::codec::Value> = None;
let mut raw_composite_scoring: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_risk_adjustment: Option<&super::super::codec::Value> = None;
let mut raw_risk_adjustment_element: Option<&super::super::codec::Value> = None;
let mut raw_rate_aggregation: Option<&super::super::codec::Value> = None;
let mut raw_rate_aggregation_element: Option<&super::super::codec::Value> = None;
let mut raw_rationale: Option<&super::super::codec::Value> = None;
let mut raw_rationale_element: Option<&super::super::codec::Value> = None;
let mut raw_clinical_recommendation_statement: Option<&super::super::codec::Value> = None;
let mut raw_clinical_recommendation_statement_element: Option<&super::super::codec::Value> =
None;
let mut raw_improvement_notation: Option<&super::super::codec::Value> = None;
let mut raw_improvement_notation_element: Option<&super::super::codec::Value> = None;
let mut raw_definition: Option<&super::super::codec::Value> = None;
let mut raw_definition_element: Option<&super::super::codec::Value> = None;
let mut raw_guidance: Option<&super::super::codec::Value> = None;
let mut raw_guidance_element: Option<&super::super::codec::Value> = None;
let mut raw_set: Option<&super::super::codec::Value> = None;
let mut raw_set_element: Option<&super::super::codec::Value> = None;
let mut raw_group: Option<&super::super::codec::Value> = None;
let mut raw_supplemental_data: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("Measure") {
return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
}
}
"id" => {
raw_id = Some(value);
}
"_id" => {
raw_id_element = Some(value);
}
"meta" => {
raw_meta = Some(value);
}
"implicitRules" => {
raw_implicit_rules = Some(value);
}
"_implicitRules" => {
raw_implicit_rules_element = Some(value);
}
"language" => {
raw_language = Some(value);
}
"_language" => {
raw_language_element = Some(value);
}
"text" => {
raw_text = Some(value);
}
"contained" => {
raw_contained = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"url" => {
raw_url = Some(value);
}
"_url" => {
raw_url_element = Some(value);
}
"identifier" => {
raw_identifier = Some(value);
}
"version" => {
raw_version = Some(value);
}
"_version" => {
raw_version_element = Some(value);
}
"name" => {
raw_name = Some(value);
}
"_name" => {
raw_name_element = Some(value);
}
"title" => {
raw_title = Some(value);
}
"_title" => {
raw_title_element = Some(value);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"experimental" => {
raw_experimental = Some(value);
}
"_experimental" => {
raw_experimental_element = Some(value);
}
"date" => {
raw_date = Some(value);
}
"_date" => {
raw_date_element = Some(value);
}
"publisher" => {
raw_publisher = Some(value);
}
"_publisher" => {
raw_publisher_element = Some(value);
}
"description" => {
raw_description = Some(value);
}
"_description" => {
raw_description_element = Some(value);
}
"purpose" => {
raw_purpose = Some(value);
}
"_purpose" => {
raw_purpose_element = Some(value);
}
"usage" => {
raw_usage = Some(value);
}
"_usage" => {
raw_usage_element = Some(value);
}
"approvalDate" => {
raw_approval_date = Some(value);
}
"_approvalDate" => {
raw_approval_date_element = Some(value);
}
"lastReviewDate" => {
raw_last_review_date = Some(value);
}
"_lastReviewDate" => {
raw_last_review_date_element = Some(value);
}
"effectivePeriod" => {
raw_effective_period = Some(value);
}
"useContext" => {
raw_use_context = Some(value);
}
"jurisdiction" => {
raw_jurisdiction = Some(value);
}
"topic" => {
raw_topic = Some(value);
}
"contributor" => {
raw_contributor = Some(value);
}
"contact" => {
raw_contact = Some(value);
}
"copyright" => {
raw_copyright = Some(value);
}
"_copyright" => {
raw_copyright_element = Some(value);
}
"relatedArtifact" => {
raw_related_artifact = Some(value);
}
"library" => {
raw_library = Some(value);
}
"disclaimer" => {
raw_disclaimer = Some(value);
}
"_disclaimer" => {
raw_disclaimer_element = Some(value);
}
"scoring" => {
raw_scoring = Some(value);
}
"compositeScoring" => {
raw_composite_scoring = Some(value);
}
"type" => {
raw_type = Some(value);
}
"riskAdjustment" => {
raw_risk_adjustment = Some(value);
}
"_riskAdjustment" => {
raw_risk_adjustment_element = Some(value);
}
"rateAggregation" => {
raw_rate_aggregation = Some(value);
}
"_rateAggregation" => {
raw_rate_aggregation_element = Some(value);
}
"rationale" => {
raw_rationale = Some(value);
}
"_rationale" => {
raw_rationale_element = Some(value);
}
"clinicalRecommendationStatement" => {
raw_clinical_recommendation_statement = Some(value);
}
"_clinicalRecommendationStatement" => {
raw_clinical_recommendation_statement_element = Some(value);
}
"improvementNotation" => {
raw_improvement_notation = Some(value);
}
"_improvementNotation" => {
raw_improvement_notation_element = Some(value);
}
"definition" => {
raw_definition = Some(value);
}
"_definition" => {
raw_definition_element = Some(value);
}
"guidance" => {
raw_guidance = Some(value);
}
"_guidance" => {
raw_guidance_element = Some(value);
}
"set" => {
raw_set = Some(value);
}
"_set" => {
raw_set_element = Some(value);
}
"group" => {
raw_group = Some(value);
}
"supplementalData" => {
raw_supplemental_data = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = match (raw_id, raw_id_element) {
(None, None) => None,
(value, element) => Some(path.with("id", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_meta = raw_meta
.map(|value| {
path.with("meta", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
(None, None) => None,
(value, element) => Some(path.with("implicitRules", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_language = match (raw_language, raw_language_element) {
(None, None) => None,
(value, element) => Some(path.with("language", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_text = raw_text
.map(|value| {
path.with("text", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let mut field_contained = Vec::new();
if let Some(raw) = raw_contained {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_contained.push(path.with_index("contained", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_url = match (raw_url, raw_url_element) {
(None, None) => None,
(value, element) => Some(path.with("url", |path| {
super::super::codec::Primitive::from_json_parts(value, element, 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_version = match (raw_version, raw_version_element) {
(None, None) => None,
(value, element) => Some(path.with("version", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_name = match (raw_name, raw_name_element) {
(None, None) => None,
(value, element) => Some(path.with("name", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_title = match (raw_title, raw_title_element) {
(None, None) => None,
(value, element) => Some(path.with("title", |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_experimental = match (raw_experimental, raw_experimental_element) {
(None, None) => None,
(value, element) => Some(path.with("experimental", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
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_publisher = match (raw_publisher, raw_publisher_element) {
(None, None) => None,
(value, element) => Some(path.with("publisher", |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 field_purpose = match (raw_purpose, raw_purpose_element) {
(None, None) => None,
(value, element) => Some(path.with("purpose", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_usage = match (raw_usage, raw_usage_element) {
(None, None) => None,
(value, element) => Some(path.with("usage", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_approval_date = match (raw_approval_date, raw_approval_date_element) {
(None, None) => None,
(value, element) => Some(path.with("approvalDate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_last_review_date = match (raw_last_review_date, raw_last_review_date_element) {
(None, None) => None,
(value, element) => Some(path.with("lastReviewDate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_effective_period = raw_effective_period
.map(|value| {
path.with("effectivePeriod", |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_use_context = Vec::new();
if let Some(raw) = raw_use_context {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_use_context.push(path.with_index("useContext", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_jurisdiction = Vec::new();
if let Some(raw) = raw_jurisdiction {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_topic = Vec::new();
if let Some(raw) = raw_topic {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_topic.push(path.with_index("topic", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_contributor = Vec::new();
if let Some(raw) = raw_contributor {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_contributor.push(path.with_index("contributor", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_contact = Vec::new();
if let Some(raw) = raw_contact {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_contact.push(path.with_index("contact", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_copyright = match (raw_copyright, raw_copyright_element) {
(None, None) => None,
(value, element) => Some(path.with("copyright", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_related_artifact = Vec::new();
if let Some(raw) = raw_related_artifact {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_related_artifact.push(path.with_index("relatedArtifact", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_library = Vec::new();
if let Some(raw) = raw_library {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_library.push(path.with_index("library", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_disclaimer = match (raw_disclaimer, raw_disclaimer_element) {
(None, None) => None,
(value, element) => Some(path.with("disclaimer", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_scoring = raw_scoring
.map(|value| {
path.with("scoring", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_composite_scoring = raw_composite_scoring
.map(|value| {
path.with("compositeScoring", |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_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_risk_adjustment = match (raw_risk_adjustment, raw_risk_adjustment_element) {
(None, None) => None,
(value, element) => Some(path.with("riskAdjustment", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_rate_aggregation = match (raw_rate_aggregation, raw_rate_aggregation_element) {
(None, None) => None,
(value, element) => Some(path.with("rateAggregation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_rationale = match (raw_rationale, raw_rationale_element) {
(None, None) => None,
(value, element) => Some(path.with("rationale", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_clinical_recommendation_statement = match (
raw_clinical_recommendation_statement,
raw_clinical_recommendation_statement_element,
) {
(None, None) => None,
(value, element) => Some(path.with("clinicalRecommendationStatement", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_improvement_notation =
match (raw_improvement_notation, raw_improvement_notation_element) {
(None, None) => None,
(value, element) => Some(path.with("improvementNotation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_definition = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_definition, raw_definition_element, path)?
.into_iter()
.enumerate()
{
field_definition.push(path.with_index("definition", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let field_guidance = match (raw_guidance, raw_guidance_element) {
(None, None) => None,
(value, element) => Some(path.with("guidance", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_set = match (raw_set, raw_set_element) {
(None, None) => None,
(value, element) => Some(path.with("set", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_group = Vec::new();
if let Some(raw) = raw_group {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_group.push(path.with_index("group", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_supplemental_data = Vec::new();
if let Some(raw) = raw_supplemental_data {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_supplemental_data.push(path.with_index(
"supplementalData",
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,
url: field_url,
identifier: field_identifier,
version: field_version,
name: field_name,
title: field_title,
status: field_status,
experimental: field_experimental,
date: field_date,
publisher: field_publisher,
description: field_description,
purpose: field_purpose,
usage: field_usage,
approval_date: field_approval_date,
last_review_date: field_last_review_date,
effective_period: field_effective_period,
use_context: field_use_context,
jurisdiction: field_jurisdiction,
topic: field_topic,
contributor: field_contributor,
contact: field_contact,
copyright: field_copyright,
related_artifact: field_related_artifact,
library: field_library,
disclaimer: field_disclaimer,
scoring: field_scoring,
composite_scoring: field_composite_scoring,
r#type: field_type,
risk_adjustment: field_risk_adjustment,
rate_aggregation: field_rate_aggregation,
rationale: field_rationale,
clinical_recommendation_statement: field_clinical_recommendation_statement,
improvement_notation: field_improvement_notation,
definition: field_definition,
guidance: field_guidance,
set: field_set,
group: field_group,
supplemental_data: field_supplemental_data,
})
}
}
impl serde::Serialize for Measure {
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.approval_date {
super::super::codec::element_entry(&mut map, "_approvalDate", item)?;
}
if let Some(item) = &self.clinical_recommendation_statement {
super::super::codec::element_entry(&mut map, "_clinicalRecommendationStatement", item)?;
}
if let Some(item) = &self.copyright {
super::super::codec::element_entry(&mut map, "_copyright", item)?;
}
if let Some(item) = &self.date {
super::super::codec::element_entry(&mut map, "_date", item)?;
}
super::super::codec::element_list_entry(&mut map, "_definition", &self.definition)?;
if let Some(item) = &self.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
if let Some(item) = &self.disclaimer {
super::super::codec::element_entry(&mut map, "_disclaimer", item)?;
}
if let Some(item) = &self.experimental {
super::super::codec::element_entry(&mut map, "_experimental", item)?;
}
if let Some(item) = &self.guidance {
super::super::codec::element_entry(&mut map, "_guidance", item)?;
}
if let Some(item) = &self.id {
super::super::codec::element_entry(&mut map, "_id", item)?;
}
if let Some(item) = &self.implicit_rules {
super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
}
if let Some(item) = &self.improvement_notation {
super::super::codec::element_entry(&mut map, "_improvementNotation", item)?;
}
if let Some(item) = &self.language {
super::super::codec::element_entry(&mut map, "_language", item)?;
}
if let Some(item) = &self.last_review_date {
super::super::codec::element_entry(&mut map, "_lastReviewDate", item)?;
}
if let Some(item) = &self.name {
super::super::codec::element_entry(&mut map, "_name", item)?;
}
if let Some(item) = &self.publisher {
super::super::codec::element_entry(&mut map, "_publisher", item)?;
}
if let Some(item) = &self.purpose {
super::super::codec::element_entry(&mut map, "_purpose", item)?;
}
if let Some(item) = &self.rate_aggregation {
super::super::codec::element_entry(&mut map, "_rateAggregation", item)?;
}
if let Some(item) = &self.rationale {
super::super::codec::element_entry(&mut map, "_rationale", item)?;
}
if let Some(item) = &self.risk_adjustment {
super::super::codec::element_entry(&mut map, "_riskAdjustment", item)?;
}
if let Some(item) = &self.set {
super::super::codec::element_entry(&mut map, "_set", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.title {
super::super::codec::element_entry(&mut map, "_title", item)?;
}
if let Some(item) = &self.url {
super::super::codec::element_entry(&mut map, "_url", item)?;
}
if let Some(item) = &self.usage {
super::super::codec::element_entry(&mut map, "_usage", item)?;
}
if let Some(item) = &self.version {
super::super::codec::element_entry(&mut map, "_version", item)?;
}
if let Some(item) = &self.approval_date {
super::super::codec::value_entry(&mut map, "approvalDate", item)?;
}
if let Some(item) = &self.clinical_recommendation_statement {
super::super::codec::value_entry(&mut map, "clinicalRecommendationStatement", item)?;
}
if let Some(item) = &self.composite_scoring {
serde::ser::SerializeMap::serialize_entry(&mut map, "compositeScoring", item)?;
}
if !self.contact.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if !self.contributor.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contributor", &self.contributor)?;
}
if let Some(item) = &self.copyright {
super::super::codec::value_entry(&mut map, "copyright", item)?;
}
if let Some(item) = &self.date {
super::super::codec::value_entry(&mut map, "date", item)?;
}
super::super::codec::value_list_entry(&mut map, "definition", &self.definition)?;
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", item)?;
}
if let Some(item) = &self.disclaimer {
super::super::codec::value_entry(&mut map, "disclaimer", item)?;
}
if let Some(item) = &self.effective_period {
serde::ser::SerializeMap::serialize_entry(&mut map, "effectivePeriod", item)?;
}
if let Some(item) = &self.experimental {
super::super::codec::value_entry(&mut map, "experimental", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if !self.group.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "group", &self.group)?;
}
if let Some(item) = &self.guidance {
super::super::codec::value_entry(&mut map, "guidance", item)?;
}
if let Some(item) = &self.id {
super::super::codec::value_entry(&mut map, "id", item)?;
}
if !self.identifier.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
}
if let Some(item) = &self.implicit_rules {
super::super::codec::value_entry(&mut map, "implicitRules", item)?;
}
if let Some(item) = &self.improvement_notation {
super::super::codec::value_entry(&mut map, "improvementNotation", item)?;
}
if !self.jurisdiction.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"jurisdiction",
&self.jurisdiction,
)?;
}
if let Some(item) = &self.language {
super::super::codec::value_entry(&mut map, "language", item)?;
}
if let Some(item) = &self.last_review_date {
super::super::codec::value_entry(&mut map, "lastReviewDate", item)?;
}
if !self.library.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "library", &self.library)?;
}
if let Some(item) = &self.meta {
serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.name {
super::super::codec::value_entry(&mut map, "name", item)?;
}
if let Some(item) = &self.publisher {
super::super::codec::value_entry(&mut map, "publisher", item)?;
}
if let Some(item) = &self.purpose {
super::super::codec::value_entry(&mut map, "purpose", item)?;
}
if let Some(item) = &self.rate_aggregation {
super::super::codec::value_entry(&mut map, "rateAggregation", item)?;
}
if let Some(item) = &self.rationale {
super::super::codec::value_entry(&mut map, "rationale", item)?;
}
if !self.related_artifact.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"relatedArtifact",
&self.related_artifact,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "Measure")?;
if let Some(item) = &self.risk_adjustment {
super::super::codec::value_entry(&mut map, "riskAdjustment", item)?;
}
if let Some(item) = &self.scoring {
serde::ser::SerializeMap::serialize_entry(&mut map, "scoring", item)?;
}
if let Some(item) = &self.set {
super::super::codec::value_entry(&mut map, "set", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if !self.supplemental_data.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"supplementalData",
&self.supplemental_data,
)?;
}
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
if let Some(item) = &self.title {
super::super::codec::value_entry(&mut map, "title", item)?;
}
if !self.topic.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "topic", &self.topic)?;
}
if !self.r#type.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "type", &self.r#type)?;
}
if let Some(item) = &self.url {
super::super::codec::value_entry(&mut map, "url", item)?;
}
if let Some(item) = &self.usage {
super::super::codec::value_entry(&mut map, "usage", item)?;
}
if !self.use_context.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
}
if let Some(item) = &self.version {
super::super::codec::value_entry(&mut map, "version", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for Measure {
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("Measure");
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 MeasureGroup {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub identifier: super::identifier::Identifier,
pub name: Option<super::primitives::String>,
pub description: Option<super::primitives::String>,
pub population: Vec<MeasureGroupPopulation>,
pub stratifier: Vec<MeasureGroupStratifier>,
}
impl super::super::codec::Json for MeasureGroup {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
object.insert(
std::string::String::from("identifier"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(
&self.identifier,
)?),
);
if let Some(item) = &self.name {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_name"), 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.population.is_empty() {
let mut items = Vec::with_capacity(self.population.len());
for item in &self.population {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("population"),
super::super::codec::Value::Array(items),
);
}
if !self.stratifier.is_empty() {
let mut items = Vec::with_capacity(self.stratifier.len());
for item in &self.stratifier {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("stratifier"),
super::super::codec::Value::Array(items),
);
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_identifier: Option<&super::super::codec::Value> = None;
let mut raw_name: Option<&super::super::codec::Value> = None;
let mut raw_name_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_population: Option<&super::super::codec::Value> = None;
let mut raw_stratifier: 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);
}
"name" => {
raw_name = Some(value);
}
"_name" => {
raw_name_element = Some(value);
}
"description" => {
raw_description = Some(value);
}
"_description" => {
raw_description_element = Some(value);
}
"population" => {
raw_population = Some(value);
}
"stratifier" => {
raw_stratifier = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_identifier = path.with("identifier", |path| {
let value = raw_identifier
.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_name = match (raw_name, raw_name_element) {
(None, None) => None,
(value, element) => Some(path.with("name", |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_population = Vec::new();
if let Some(raw) = raw_population {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_population.push(path.with_index("population", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_stratifier = Vec::new();
if let Some(raw) = raw_stratifier {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_stratifier.push(path.with_index("stratifier", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
identifier: field_identifier,
name: field_name,
description: field_description,
population: field_population,
stratifier: field_stratifier,
})
}
}
impl serde::Serialize for MeasureGroup {
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.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
if let Some(item) = &self.name {
super::super::codec::element_entry(&mut map, "_name", item)?;
}
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.name {
super::super::codec::value_entry(&mut map, "name", item)?;
}
if !self.population.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "population", &self.population)?;
}
if !self.stratifier.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "stratifier", &self.stratifier)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for MeasureGroup {
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("MeasureGroup");
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 MeasureGroupPopulation {
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 code: Option<super::codeable_concept::CodeableConcept>,
pub name: Option<super::primitives::String>,
pub description: Option<super::primitives::String>,
pub criteria: super::primitives::String,
}
impl super::super::codec::Json for MeasureGroupPopulation {
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.code {
object.insert(
std::string::String::from("code"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.name {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_name"), 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 let Some(v) = super::super::codec::Primitive::value_json(&self.criteria)? {
object.insert(std::string::String::from("criteria"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.criteria)? {
object.insert(std::string::String::from("_criteria"), 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_identifier: Option<&super::super::codec::Value> = None;
let mut raw_code: Option<&super::super::codec::Value> = None;
let mut raw_name: Option<&super::super::codec::Value> = None;
let mut raw_name_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_criteria: Option<&super::super::codec::Value> = None;
let mut raw_criteria_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);
}
"code" => {
raw_code = Some(value);
}
"name" => {
raw_name = Some(value);
}
"_name" => {
raw_name_element = Some(value);
}
"description" => {
raw_description = Some(value);
}
"_description" => {
raw_description_element = Some(value);
}
"criteria" => {
raw_criteria = Some(value);
}
"_criteria" => {
raw_criteria_element = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_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_code = raw_code
.map(|value| {
path.with("code", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_name = match (raw_name, raw_name_element) {
(None, None) => None,
(value, element) => Some(path.with("name", |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 field_criteria = path.with("criteria", |path| {
super::super::codec::Primitive::from_json_parts(
raw_criteria,
raw_criteria_element,
path,
)
})?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
identifier: field_identifier,
code: field_code,
name: field_name,
description: field_description,
criteria: field_criteria,
})
}
}
impl serde::Serialize for MeasureGroupPopulation {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_criteria", &self.criteria)?;
if let Some(item) = &self.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
if let Some(item) = &self.name {
super::super::codec::element_entry(&mut map, "_name", item)?;
}
if let Some(item) = &self.code {
serde::ser::SerializeMap::serialize_entry(&mut map, "code", item)?;
}
super::super::codec::value_entry(&mut map, "criteria", &self.criteria)?;
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", 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,
)?;
}
if let Some(item) = &self.name {
super::super::codec::value_entry(&mut map, "name", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for MeasureGroupPopulation {
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("MeasureGroupPopulation");
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 MeasureGroupStratifier {
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 criteria: Option<super::primitives::String>,
pub path: Option<super::primitives::String>,
}
impl super::super::codec::Json for MeasureGroupStratifier {
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.criteria {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("criteria"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_criteria"), e);
}
}
if let Some(item) = &self.path {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("path"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_path"), 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_identifier: Option<&super::super::codec::Value> = None;
let mut raw_criteria: Option<&super::super::codec::Value> = None;
let mut raw_criteria_element: Option<&super::super::codec::Value> = None;
let mut raw_path: Option<&super::super::codec::Value> = None;
let mut raw_path_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);
}
"criteria" => {
raw_criteria = Some(value);
}
"_criteria" => {
raw_criteria_element = Some(value);
}
"path" => {
raw_path = Some(value);
}
"_path" => {
raw_path_element = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_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_criteria = match (raw_criteria, raw_criteria_element) {
(None, None) => None,
(value, element) => Some(path.with("criteria", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_path = match (raw_path, raw_path_element) {
(None, None) => None,
(value, element) => Some(path.with("path", |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,
criteria: field_criteria,
path: field_path,
})
}
}
impl serde::Serialize for MeasureGroupStratifier {
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.criteria {
super::super::codec::element_entry(&mut map, "_criteria", item)?;
}
if let Some(item) = &self.path {
super::super::codec::element_entry(&mut map, "_path", item)?;
}
if let Some(item) = &self.criteria {
super::super::codec::value_entry(&mut map, "criteria", 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,
)?;
}
if let Some(item) = &self.path {
super::super::codec::value_entry(&mut map, "path", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for MeasureGroupStratifier {
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("MeasureGroupStratifier");
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 MeasureSupplementalData {
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 usage: Vec<super::codeable_concept::CodeableConcept>,
pub criteria: Option<super::primitives::String>,
pub path: Option<super::primitives::String>,
}
impl super::super::codec::Json for MeasureSupplementalData {
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 !self.usage.is_empty() {
let mut items = Vec::with_capacity(self.usage.len());
for item in &self.usage {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("usage"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.criteria {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("criteria"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_criteria"), e);
}
}
if let Some(item) = &self.path {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("path"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_path"), 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_identifier: Option<&super::super::codec::Value> = None;
let mut raw_usage: Option<&super::super::codec::Value> = None;
let mut raw_criteria: Option<&super::super::codec::Value> = None;
let mut raw_criteria_element: Option<&super::super::codec::Value> = None;
let mut raw_path: Option<&super::super::codec::Value> = None;
let mut raw_path_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);
}
"usage" => {
raw_usage = Some(value);
}
"criteria" => {
raw_criteria = Some(value);
}
"_criteria" => {
raw_criteria_element = Some(value);
}
"path" => {
raw_path = Some(value);
}
"_path" => {
raw_path_element = Some(value);
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::super::codec::expect_string(value, path)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_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 mut field_usage = Vec::new();
if let Some(raw) = raw_usage {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_usage.push(path.with_index("usage", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_criteria = match (raw_criteria, raw_criteria_element) {
(None, None) => None,
(value, element) => Some(path.with("criteria", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_path = match (raw_path, raw_path_element) {
(None, None) => None,
(value, element) => Some(path.with("path", |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,
usage: field_usage,
criteria: field_criteria,
path: field_path,
})
}
}
impl serde::Serialize for MeasureSupplementalData {
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.criteria {
super::super::codec::element_entry(&mut map, "_criteria", item)?;
}
if let Some(item) = &self.path {
super::super::codec::element_entry(&mut map, "_path", item)?;
}
if let Some(item) = &self.criteria {
super::super::codec::value_entry(&mut map, "criteria", 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,
)?;
}
if let Some(item) = &self.path {
super::super::codec::value_entry(&mut map, "path", item)?;
}
if !self.usage.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "usage", &self.usage)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for MeasureSupplementalData {
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("MeasureSupplementalData");
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)
}
}