Skip to main content

fhir_types/r6/
bundle.rs

1// @generated by fhir-codegen from hl7.fhir.r6.core 6.0.0-ballot5. DO NOT EDIT.
2// Change the emitter (tools/fhir-codegen) and regenerate.
3// SPDX-FileCopyrightText: Cadasto B.V.
4// SPDX-License-Identifier: Apache-2.0
5//! Contains a collection of resources
6
7/// Contains a collection of resources
8///
9/// A container for a collection of resources.
10#[derive(Debug, Clone, Default, PartialEq, Eq)]
11pub struct Bundle {
12    /// Logical id of this artifact
13    ///
14    /// The logical id of the resource, as used in the URL for the resource. Once
15    /// assigned, this value never changes.
16    pub id: Option<std::string::String>,
17    /// Metadata about the resource
18    ///
19    /// The metadata about the resource. This is content that is maintained by the
20    /// infrastructure. Changes to the content might not always be associated with
21    /// version changes to the resource.
22    pub meta: Option<super::meta::Meta>,
23    /// A set of rules under which this content was created
24    ///
25    /// A reference to a set of rules that were followed when the resource was
26    /// constructed, and which must be understood when processing the content.
27    /// Often, this is a reference to an implementation guide that defines the
28    /// special rules along with other profiles etc. For DomainResources, if more
29    /// than one implicitRules policy applies, additional policies may be conveyed
30    /// using the
31    /// \[additionalImplicitRules\](<https://build.fhir.org/ig/HL7/fhir-extensions/StructureDefinition-additionalImplicitRules.html>)
32    /// extension.
33    pub implicit_rules: Option<super::primitives::Uri>,
34    /// Language of the resource content
35    ///
36    /// The base language in which the resource is written.
37    pub language: Option<super::primitives::Code>,
38    /// Persistent identifier for the bundle
39    ///
40    /// A persistent identifier for the bundle that won't change as a bundle is
41    /// copied from server to server.
42    pub identifier: Option<super::identifier::Identifier>,
43    /// document | message | transaction | transaction-response | batch |
44    /// batch-response | history | searchset | collection |
45    /// subscription-notification
46    ///
47    /// Indicates the purpose of this bundle - how it is intended to be used.
48    pub r#type: super::primitives::Code,
49    /// When the bundle was assembled
50    ///
51    /// The date/time that the bundle was assembled - i.e. when the resources were
52    /// placed in the bundle.
53    pub timestamp: Option<super::primitives::Instant>,
54    /// Total matches across all pages
55    ///
56    /// If a set of search matches or a history, this is the (potentially estimated)
57    /// total number of entries of type 'match' across all pages in the search. It
58    /// does not include search.mode = 'include' or 'outcome' entries and it does
59    /// not provide a count of the number of entries in the Bundle.
60    pub total: Option<super::primitives::UnsignedInt>,
61    /// Links related to this Bundle
62    ///
63    /// A series of links that provide context to this bundle.
64    pub link: Vec<BundleLink>,
65    /// Entry in the bundle - will have a resource or information
66    ///
67    /// An entry in a bundle resource - will either contain a resource or
68    /// information about a resource (transactions and history only).
69    pub entry: Vec<BundleEntry>,
70    /// OperationOutcome with issues about the Bundle
71    ///
72    /// An OperationOutcome that captures issues and warnings that relate to the
73    /// construction of the Bundle and the content within it.
74    pub issues: Option<Box<super::resource::Resource>>,
75}
76
77impl super::super::codec::Json for Bundle {
78    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
79        let mut object = super::super::codec::Object::new();
80        object.insert(
81            std::string::String::from("resourceType"),
82            super::super::codec::Value::String(std::string::String::from("Bundle")),
83        );
84        if let Some(v) = &self.id {
85            object.insert(
86                std::string::String::from("id"),
87                super::super::codec::Value::String(v.clone()),
88            );
89        }
90        if let Some(item) = &self.meta {
91            object.insert(
92                std::string::String::from("meta"),
93                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
94            );
95        }
96        if let Some(item) = &self.implicit_rules {
97            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
98                object.insert(std::string::String::from("implicitRules"), v);
99            }
100            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
101                object.insert(std::string::String::from("_implicitRules"), e);
102            }
103        }
104        if let Some(item) = &self.language {
105            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
106                object.insert(std::string::String::from("language"), v);
107            }
108            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
109                object.insert(std::string::String::from("_language"), e);
110            }
111        }
112        if let Some(item) = &self.identifier {
113            object.insert(
114                std::string::String::from("identifier"),
115                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
116            );
117        }
118        if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
119            object.insert(std::string::String::from("type"), v);
120        }
121        if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
122            object.insert(std::string::String::from("_type"), e);
123        }
124        if let Some(item) = &self.timestamp {
125            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
126                object.insert(std::string::String::from("timestamp"), v);
127            }
128            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
129                object.insert(std::string::String::from("_timestamp"), e);
130            }
131        }
132        if let Some(item) = &self.total {
133            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
134                object.insert(std::string::String::from("total"), v);
135            }
136            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
137                object.insert(std::string::String::from("_total"), e);
138            }
139        }
140        if !self.link.is_empty() {
141            let mut items = Vec::with_capacity(self.link.len());
142            for item in &self.link {
143                items.push(super::super::codec::Value::Object(
144                    super::super::codec::Json::to_json(item)?,
145                ));
146            }
147            object.insert(
148                std::string::String::from("link"),
149                super::super::codec::Value::Array(items),
150            );
151        }
152        if !self.entry.is_empty() {
153            let mut items = Vec::with_capacity(self.entry.len());
154            for item in &self.entry {
155                items.push(super::super::codec::Value::Object(
156                    super::super::codec::Json::to_json(item)?,
157                ));
158            }
159            object.insert(
160                std::string::String::from("entry"),
161                super::super::codec::Value::Array(items),
162            );
163        }
164        if let Some(item) = &self.issues {
165            object.insert(
166                std::string::String::from("issues"),
167                super::super::codec::Value::Object(super::super::codec::Json::to_json(
168                    item.as_ref(),
169                )?),
170            );
171        }
172        Ok(object)
173    }
174
175    fn from_json(
176        object: &super::super::codec::Object,
177        path: &mut super::super::codec::Path,
178    ) -> Result<Self, super::super::codec::DecodeError> {
179        let mut raw_id: Option<&super::super::codec::Value> = None;
180        let mut raw_meta: Option<&super::super::codec::Value> = None;
181        let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
182        let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
183        let mut raw_language: Option<&super::super::codec::Value> = None;
184        let mut raw_language_element: Option<&super::super::codec::Value> = None;
185        let mut raw_identifier: Option<&super::super::codec::Value> = None;
186        let mut raw_type: Option<&super::super::codec::Value> = None;
187        let mut raw_type_element: Option<&super::super::codec::Value> = None;
188        let mut raw_timestamp: Option<&super::super::codec::Value> = None;
189        let mut raw_timestamp_element: Option<&super::super::codec::Value> = None;
190        let mut raw_total: Option<&super::super::codec::Value> = None;
191        let mut raw_total_element: Option<&super::super::codec::Value> = None;
192        let mut raw_link: Option<&super::super::codec::Value> = None;
193        let mut raw_entry: Option<&super::super::codec::Value> = None;
194        let mut raw_issues: Option<&super::super::codec::Value> = None;
195        for (key, value) in object {
196            match key.as_str() {
197                "resourceType" => {
198                    if value.as_str() != Some("Bundle") {
199                        return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
200                    }
201                }
202                "id" => {
203                    raw_id = Some(value);
204                }
205                "meta" => {
206                    raw_meta = Some(value);
207                }
208                "implicitRules" => {
209                    raw_implicit_rules = Some(value);
210                }
211                "_implicitRules" => {
212                    raw_implicit_rules_element = Some(value);
213                }
214                "language" => {
215                    raw_language = Some(value);
216                }
217                "_language" => {
218                    raw_language_element = Some(value);
219                }
220                "identifier" => {
221                    raw_identifier = Some(value);
222                }
223                "type" => {
224                    raw_type = Some(value);
225                }
226                "_type" => {
227                    raw_type_element = Some(value);
228                }
229                "timestamp" => {
230                    raw_timestamp = Some(value);
231                }
232                "_timestamp" => {
233                    raw_timestamp_element = Some(value);
234                }
235                "total" => {
236                    raw_total = Some(value);
237                }
238                "_total" => {
239                    raw_total_element = Some(value);
240                }
241                "link" => {
242                    raw_link = Some(value);
243                }
244                "entry" => {
245                    raw_entry = Some(value);
246                }
247                "issues" => {
248                    raw_issues = Some(value);
249                }
250                other => {
251                    return path.with(other, |path| {
252                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
253                    });
254                }
255            }
256        }
257        let field_id = raw_id
258            .map(|value| {
259                path.with("id", |path| {
260                    let value = super::super::codec::expect_single(value, path)?;
261                    super::primitives::checked_id(
262                        super::super::codec::expect_string(value, path)?,
263                        path,
264                    )
265                })
266            })
267            .transpose()?;
268        let field_meta = raw_meta
269            .map(|value| {
270                path.with("meta", |path| {
271                    super::super::codec::Json::from_json(
272                        super::super::codec::expect_object(
273                            super::super::codec::expect_single(value, path)?,
274                            path,
275                        )?,
276                        path,
277                    )
278                })
279            })
280            .transpose()?;
281        let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
282            (None, None) => None,
283            (value, element) => Some(path.with("implicitRules", |path| {
284                super::super::codec::Primitive::from_json_parts(value, element, path)
285            })?),
286        };
287        let field_language = match (raw_language, raw_language_element) {
288            (None, None) => None,
289            (value, element) => Some(path.with("language", |path| {
290                super::super::codec::Primitive::from_json_parts(value, element, path)
291            })?),
292        };
293        let field_identifier = raw_identifier
294            .map(|value| {
295                path.with("identifier", |path| {
296                    super::super::codec::Json::from_json(
297                        super::super::codec::expect_object(
298                            super::super::codec::expect_single(value, path)?,
299                            path,
300                        )?,
301                        path,
302                    )
303                })
304            })
305            .transpose()?;
306        let field_type = path.with("type", |path| {
307            super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
308        })?;
309        let field_timestamp = match (raw_timestamp, raw_timestamp_element) {
310            (None, None) => None,
311            (value, element) => Some(path.with("timestamp", |path| {
312                super::super::codec::Primitive::from_json_parts(value, element, path)
313            })?),
314        };
315        let field_total = match (raw_total, raw_total_element) {
316            (None, None) => None,
317            (value, element) => Some(path.with("total", |path| {
318                super::super::codec::Primitive::from_json_parts(value, element, path)
319            })?),
320        };
321        let mut field_link = Vec::new();
322        if let Some(raw) = raw_link {
323            for (index, value) in path
324                .with("link", |path| super::super::codec::expect_array(raw, path))?
325                .iter()
326                .enumerate()
327            {
328                field_link.push(path.with_index("link", index, |path| {
329                    super::super::codec::Json::from_json(
330                        super::super::codec::expect_object(value, path)?,
331                        path,
332                    )
333                })?);
334            }
335        }
336        let mut field_entry = Vec::new();
337        if let Some(raw) = raw_entry {
338            for (index, value) in path
339                .with("entry", |path| super::super::codec::expect_array(raw, path))?
340                .iter()
341                .enumerate()
342            {
343                field_entry.push(path.with_index("entry", index, |path| {
344                    super::super::codec::Json::from_json(
345                        super::super::codec::expect_object(value, path)?,
346                        path,
347                    )
348                })?);
349            }
350        }
351        let field_issues = raw_issues
352            .map(|value| {
353                path.with("issues", |path| {
354                    super::super::codec::Json::from_json(
355                        super::super::codec::expect_object(
356                            super::super::codec::expect_single(value, path)?,
357                            path,
358                        )?,
359                        path,
360                    )
361                    .map(Box::new)
362                })
363            })
364            .transpose()?;
365        Ok(Self {
366            id: field_id,
367            meta: field_meta,
368            implicit_rules: field_implicit_rules,
369            language: field_language,
370            identifier: field_identifier,
371            r#type: field_type,
372            timestamp: field_timestamp,
373            total: field_total,
374            link: field_link,
375            entry: field_entry,
376            issues: field_issues,
377        })
378    }
379}
380
381impl serde::Serialize for Bundle {
382    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
383        let mut map = serde::Serializer::serialize_map(serializer, None)?;
384        if let Some(item) = &self.implicit_rules {
385            super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
386        }
387        if let Some(item) = &self.language {
388            super::super::codec::element_entry(&mut map, "_language", item)?;
389        }
390        if let Some(item) = &self.timestamp {
391            super::super::codec::element_entry(&mut map, "_timestamp", item)?;
392        }
393        if let Some(item) = &self.total {
394            super::super::codec::element_entry(&mut map, "_total", item)?;
395        }
396        super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
397        if !self.entry.is_empty() {
398            serde::ser::SerializeMap::serialize_entry(&mut map, "entry", &self.entry)?;
399        }
400        if let Some(v) = &self.id {
401            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
402        }
403        if let Some(item) = &self.identifier {
404            serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", item)?;
405        }
406        if let Some(item) = &self.implicit_rules {
407            super::super::codec::value_entry(&mut map, "implicitRules", item)?;
408        }
409        if let Some(item) = &self.issues {
410            serde::ser::SerializeMap::serialize_entry(&mut map, "issues", item.as_ref())?;
411        }
412        if let Some(item) = &self.language {
413            super::super::codec::value_entry(&mut map, "language", item)?;
414        }
415        if !self.link.is_empty() {
416            serde::ser::SerializeMap::serialize_entry(&mut map, "link", &self.link)?;
417        }
418        if let Some(item) = &self.meta {
419            serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
420        }
421        serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "Bundle")?;
422        if let Some(item) = &self.timestamp {
423            super::super::codec::value_entry(&mut map, "timestamp", item)?;
424        }
425        if let Some(item) = &self.total {
426            super::super::codec::value_entry(&mut map, "total", item)?;
427        }
428        super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
429        serde::ser::SerializeMap::end(map)
430    }
431}
432
433impl<'de> serde::Deserialize<'de> for Bundle {
434    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
435        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
436        let mut path = super::super::codec::Path::root("Bundle");
437        let object =
438            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
439        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
440    }
441}
442
443/// Entry in the bundle - will have a resource or information
444///
445/// An entry in a bundle resource - will either contain a resource or
446/// information about a resource (transactions and history only).
447#[derive(Debug, Clone, Default, PartialEq, Eq)]
448pub struct BundleEntry {
449    /// Unique id for inter-element referencing
450    ///
451    /// Unique id for the element within a resource (for internal references). This
452    /// may be any string value that does not contain spaces.
453    pub id: Option<std::string::String>,
454    /// Additional content defined by implementations
455    ///
456    /// May be used to represent additional information that is not part of the
457    /// basic definition of the element. To make the use of extensions safe and
458    /// managable, there is a strict set of governance applied to the definition and
459    /// use of extensions. Though any implementer can define an extension, there is
460    /// a set of requirements that SHALL be met as part of the definition of the
461    /// extension.
462    pub extension: Vec<super::extension::Extension>,
463    /// Extensions that cannot be ignored even if unrecognized
464    ///
465    /// May be used to represent additional information that is not part of the
466    /// basic definition of the element and that modifies the understanding of the
467    /// element in which it is contained and/or the understanding of the containing
468    /// element's descendants. Usually modifier elements provide negation or
469    /// qualification. To make the use of extensions safe and managable, there is a
470    /// strict set of governance applied to the definition and use of extensions.
471    /// Though any implementer can define an extension, there is a set of
472    /// requirements that SHALL be met as part of the definition of the extension.
473    /// Applications processing a resource are required to check for modifier
474    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
475    /// on Resource or DomainResource (including cannot change the meaning of
476    /// modifierExtension itself).
477    pub modifier_extension: Vec<super::extension::Extension>,
478    /// Links related to this entry
479    ///
480    /// A series of links that provide context to this entry.
481    pub link: Vec<BundleLink>,
482    /// URI for resource (e.g. the absolute URL server address, URI for UUID/OID,
483    /// etc.)
484    ///
485    /// The Absolute URL for the resource. Except for transactions and batches, each
486    /// entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with
487    /// the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL
488    /// shall be version-independent URL consistent with the Resource.id. The
489    /// fullUrl is a version independent reference to the resource. Even when not
490    /// required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a
491    /// transaction. The fullUrl can be an arbitrary URI and is not limited to
492    /// urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value
493    /// unless: \* the Bundle is a batch or transaction request or response AND \*
494    /// the entry is \* invoking a create \* invoking or responding to an operation
495    /// where the body is not a single identified resource \* invoking or returning
496    /// the results of a search or history operation.
497    pub full_url: Option<super::primitives::Uri>,
498    /// A resource in the bundle
499    ///
500    /// The Resource for the entry. The purpose/meaning of the resource is
501    /// determined by the Bundle.type.
502    pub resource: Option<super::resource::Resource>,
503    /// Search related information
504    ///
505    /// Information about the search process that lead to the creation of this
506    /// entry.
507    pub search: Option<BundleEntrySearch>,
508    /// Additional execution information (transaction/batch/history)
509    ///
510    /// Additional information about how this entry should be processed as part of a
511    /// transaction or batch. For history, it shows how the entry was processed to
512    /// create the version contained in the entry.
513    pub request: Option<BundleEntryRequest>,
514    /// Results of execution (transaction/batch/history)
515    ///
516    /// Indicates the results of processing the corresponding 'request' entry in the
517    /// batch or transaction being responded to or what the results of an operation
518    /// where when returning history.
519    pub response: Option<BundleEntryResponse>,
520}
521
522impl super::super::codec::Json for BundleEntry {
523    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
524        let mut object = super::super::codec::Object::new();
525        if let Some(v) = &self.id {
526            object.insert(
527                std::string::String::from("id"),
528                super::super::codec::Value::String(v.clone()),
529            );
530        }
531        if !self.extension.is_empty() {
532            let mut items = Vec::with_capacity(self.extension.len());
533            for item in &self.extension {
534                items.push(super::super::codec::Value::Object(
535                    super::super::codec::Json::to_json(item)?,
536                ));
537            }
538            object.insert(
539                std::string::String::from("extension"),
540                super::super::codec::Value::Array(items),
541            );
542        }
543        if !self.modifier_extension.is_empty() {
544            let mut items = Vec::with_capacity(self.modifier_extension.len());
545            for item in &self.modifier_extension {
546                items.push(super::super::codec::Value::Object(
547                    super::super::codec::Json::to_json(item)?,
548                ));
549            }
550            object.insert(
551                std::string::String::from("modifierExtension"),
552                super::super::codec::Value::Array(items),
553            );
554        }
555        if !self.link.is_empty() {
556            let mut items = Vec::with_capacity(self.link.len());
557            for item in &self.link {
558                items.push(super::super::codec::Value::Object(
559                    super::super::codec::Json::to_json(item)?,
560                ));
561            }
562            object.insert(
563                std::string::String::from("link"),
564                super::super::codec::Value::Array(items),
565            );
566        }
567        if let Some(item) = &self.full_url {
568            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
569                object.insert(std::string::String::from("fullUrl"), v);
570            }
571            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
572                object.insert(std::string::String::from("_fullUrl"), e);
573            }
574        }
575        if let Some(item) = &self.resource {
576            object.insert(
577                std::string::String::from("resource"),
578                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
579            );
580        }
581        if let Some(item) = &self.search {
582            object.insert(
583                std::string::String::from("search"),
584                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
585            );
586        }
587        if let Some(item) = &self.request {
588            object.insert(
589                std::string::String::from("request"),
590                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
591            );
592        }
593        if let Some(item) = &self.response {
594            object.insert(
595                std::string::String::from("response"),
596                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
597            );
598        }
599        Ok(object)
600    }
601
602    fn from_json(
603        object: &super::super::codec::Object,
604        path: &mut super::super::codec::Path,
605    ) -> Result<Self, super::super::codec::DecodeError> {
606        let mut raw_id: Option<&super::super::codec::Value> = None;
607        let mut raw_extension: Option<&super::super::codec::Value> = None;
608        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
609        let mut raw_link: Option<&super::super::codec::Value> = None;
610        let mut raw_full_url: Option<&super::super::codec::Value> = None;
611        let mut raw_full_url_element: Option<&super::super::codec::Value> = None;
612        let mut raw_resource: Option<&super::super::codec::Value> = None;
613        let mut raw_search: Option<&super::super::codec::Value> = None;
614        let mut raw_request: Option<&super::super::codec::Value> = None;
615        let mut raw_response: Option<&super::super::codec::Value> = None;
616        for (key, value) in object {
617            match key.as_str() {
618                "id" => {
619                    raw_id = Some(value);
620                }
621                "extension" => {
622                    raw_extension = Some(value);
623                }
624                "modifierExtension" => {
625                    raw_modifier_extension = Some(value);
626                }
627                "link" => {
628                    raw_link = Some(value);
629                }
630                "fullUrl" => {
631                    raw_full_url = Some(value);
632                }
633                "_fullUrl" => {
634                    raw_full_url_element = Some(value);
635                }
636                "resource" => {
637                    raw_resource = Some(value);
638                }
639                "search" => {
640                    raw_search = Some(value);
641                }
642                "request" => {
643                    raw_request = Some(value);
644                }
645                "response" => {
646                    raw_response = Some(value);
647                }
648                other => {
649                    return path.with(other, |path| {
650                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
651                    });
652                }
653            }
654        }
655        let field_id = raw_id
656            .map(|value| {
657                path.with("id", |path| {
658                    let value = super::super::codec::expect_single(value, path)?;
659                    super::primitives::checked_string(
660                        super::super::codec::expect_string(value, path)?,
661                        path,
662                    )
663                })
664            })
665            .transpose()?;
666        let mut field_extension = Vec::new();
667        if let Some(raw) = raw_extension {
668            for (index, value) in path
669                .with("extension", |path| {
670                    super::super::codec::expect_array(raw, path)
671                })?
672                .iter()
673                .enumerate()
674            {
675                field_extension.push(path.with_index("extension", index, |path| {
676                    super::super::codec::Json::from_json(
677                        super::super::codec::expect_object(value, path)?,
678                        path,
679                    )
680                })?);
681            }
682        }
683        let mut field_modifier_extension = Vec::new();
684        if let Some(raw) = raw_modifier_extension {
685            for (index, value) in path
686                .with("modifierExtension", |path| {
687                    super::super::codec::expect_array(raw, path)
688                })?
689                .iter()
690                .enumerate()
691            {
692                field_modifier_extension.push(path.with_index(
693                    "modifierExtension",
694                    index,
695                    |path| {
696                        super::super::codec::Json::from_json(
697                            super::super::codec::expect_object(value, path)?,
698                            path,
699                        )
700                    },
701                )?);
702            }
703        }
704        let mut field_link = Vec::new();
705        if let Some(raw) = raw_link {
706            for (index, value) in path
707                .with("link", |path| super::super::codec::expect_array(raw, path))?
708                .iter()
709                .enumerate()
710            {
711                field_link.push(path.with_index("link", index, |path| {
712                    super::super::codec::Json::from_json(
713                        super::super::codec::expect_object(value, path)?,
714                        path,
715                    )
716                })?);
717            }
718        }
719        let field_full_url = match (raw_full_url, raw_full_url_element) {
720            (None, None) => None,
721            (value, element) => Some(path.with("fullUrl", |path| {
722                super::super::codec::Primitive::from_json_parts(value, element, path)
723            })?),
724        };
725        let field_resource = raw_resource
726            .map(|value| {
727                path.with("resource", |path| {
728                    super::super::codec::Json::from_json(
729                        super::super::codec::expect_object(
730                            super::super::codec::expect_single(value, path)?,
731                            path,
732                        )?,
733                        path,
734                    )
735                })
736            })
737            .transpose()?;
738        let field_search = raw_search
739            .map(|value| {
740                path.with("search", |path| {
741                    super::super::codec::Json::from_json(
742                        super::super::codec::expect_object(
743                            super::super::codec::expect_single(value, path)?,
744                            path,
745                        )?,
746                        path,
747                    )
748                })
749            })
750            .transpose()?;
751        let field_request = raw_request
752            .map(|value| {
753                path.with("request", |path| {
754                    super::super::codec::Json::from_json(
755                        super::super::codec::expect_object(
756                            super::super::codec::expect_single(value, path)?,
757                            path,
758                        )?,
759                        path,
760                    )
761                })
762            })
763            .transpose()?;
764        let field_response = raw_response
765            .map(|value| {
766                path.with("response", |path| {
767                    super::super::codec::Json::from_json(
768                        super::super::codec::expect_object(
769                            super::super::codec::expect_single(value, path)?,
770                            path,
771                        )?,
772                        path,
773                    )
774                })
775            })
776            .transpose()?;
777        Ok(Self {
778            id: field_id,
779            extension: field_extension,
780            modifier_extension: field_modifier_extension,
781            link: field_link,
782            full_url: field_full_url,
783            resource: field_resource,
784            search: field_search,
785            request: field_request,
786            response: field_response,
787        })
788    }
789}
790
791impl serde::Serialize for BundleEntry {
792    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
793        let mut map = serde::Serializer::serialize_map(serializer, None)?;
794        if let Some(item) = &self.full_url {
795            super::super::codec::element_entry(&mut map, "_fullUrl", item)?;
796        }
797        if !self.extension.is_empty() {
798            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
799        }
800        if let Some(item) = &self.full_url {
801            super::super::codec::value_entry(&mut map, "fullUrl", item)?;
802        }
803        if let Some(v) = &self.id {
804            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
805        }
806        if !self.link.is_empty() {
807            serde::ser::SerializeMap::serialize_entry(&mut map, "link", &self.link)?;
808        }
809        if !self.modifier_extension.is_empty() {
810            serde::ser::SerializeMap::serialize_entry(
811                &mut map,
812                "modifierExtension",
813                &self.modifier_extension,
814            )?;
815        }
816        if let Some(item) = &self.request {
817            serde::ser::SerializeMap::serialize_entry(&mut map, "request", item)?;
818        }
819        if let Some(item) = &self.resource {
820            serde::ser::SerializeMap::serialize_entry(&mut map, "resource", item)?;
821        }
822        if let Some(item) = &self.response {
823            serde::ser::SerializeMap::serialize_entry(&mut map, "response", item)?;
824        }
825        if let Some(item) = &self.search {
826            serde::ser::SerializeMap::serialize_entry(&mut map, "search", item)?;
827        }
828        serde::ser::SerializeMap::end(map)
829    }
830}
831
832impl<'de> serde::Deserialize<'de> for BundleEntry {
833    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
834        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
835        let mut path = super::super::codec::Path::root("BundleEntry");
836        let object =
837            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
838        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
839    }
840}
841
842/// Additional execution information (transaction/batch/history)
843///
844/// Additional information about how this entry should be processed as part of a
845/// transaction or batch. For history, it shows how the entry was processed to
846/// create the version contained in the entry.
847#[derive(Debug, Clone, Default, PartialEq, Eq)]
848pub struct BundleEntryRequest {
849    /// Unique id for inter-element referencing
850    ///
851    /// Unique id for the element within a resource (for internal references). This
852    /// may be any string value that does not contain spaces.
853    pub id: Option<std::string::String>,
854    /// Additional content defined by implementations
855    ///
856    /// May be used to represent additional information that is not part of the
857    /// basic definition of the element. To make the use of extensions safe and
858    /// managable, there is a strict set of governance applied to the definition and
859    /// use of extensions. Though any implementer can define an extension, there is
860    /// a set of requirements that SHALL be met as part of the definition of the
861    /// extension.
862    pub extension: Vec<super::extension::Extension>,
863    /// Extensions that cannot be ignored even if unrecognized
864    ///
865    /// May be used to represent additional information that is not part of the
866    /// basic definition of the element and that modifies the understanding of the
867    /// element in which it is contained and/or the understanding of the containing
868    /// element's descendants. Usually modifier elements provide negation or
869    /// qualification. To make the use of extensions safe and managable, there is a
870    /// strict set of governance applied to the definition and use of extensions.
871    /// Though any implementer can define an extension, there is a set of
872    /// requirements that SHALL be met as part of the definition of the extension.
873    /// Applications processing a resource are required to check for modifier
874    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
875    /// on Resource or DomainResource (including cannot change the meaning of
876    /// modifierExtension itself).
877    pub modifier_extension: Vec<super::extension::Extension>,
878    /// GET | HEAD | POST | PUT | DELETE | PATCH
879    ///
880    /// In a transaction or batch, this is the HTTP action to be executed for this
881    /// entry. In a history bundle, this indicates the HTTP action that occurred.
882    pub method: super::primitives::Code,
883    /// URL for HTTP equivalent of this entry
884    ///
885    /// The URL for this entry, relative to the root (the address to which the
886    /// request is posted).
887    pub url: super::primitives::Uri,
888    /// For managing cache validation
889    ///
890    /// If the ETag values match, return a 304 Not Modified status. See the API
891    /// documentation for \["Conditional Read"\](http.html\#cread).
892    pub if_none_match: Option<super::primitives::String>,
893    /// For managing cache currency
894    ///
895    /// Only perform the operation if the last updated date matches. See the API
896    /// documentation for \["Conditional Read"\](http.html\#cread).
897    pub if_modified_since: Option<super::primitives::Instant>,
898    /// For managing update contention
899    ///
900    /// Only perform the operation if the Etag value matches. For more information,
901    /// see the API section \["Managing Resource
902    /// Contention"\](http.html\#concurrency).
903    pub if_match: Option<super::primitives::String>,
904    /// For conditional creates
905    ///
906    /// Instruct the server not to perform the create if a specified resource
907    /// already exists. For further information, see the API documentation for
908    /// \["Conditional Create"\](http.html\#ccreate). This is just the query portion
909    /// of the URL - what follows the "?" (not including the "?").
910    pub if_none_exist: Option<super::primitives::String>,
911}
912
913impl super::super::codec::Json for BundleEntryRequest {
914    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
915        let mut object = super::super::codec::Object::new();
916        if let Some(v) = &self.id {
917            object.insert(
918                std::string::String::from("id"),
919                super::super::codec::Value::String(v.clone()),
920            );
921        }
922        if !self.extension.is_empty() {
923            let mut items = Vec::with_capacity(self.extension.len());
924            for item in &self.extension {
925                items.push(super::super::codec::Value::Object(
926                    super::super::codec::Json::to_json(item)?,
927                ));
928            }
929            object.insert(
930                std::string::String::from("extension"),
931                super::super::codec::Value::Array(items),
932            );
933        }
934        if !self.modifier_extension.is_empty() {
935            let mut items = Vec::with_capacity(self.modifier_extension.len());
936            for item in &self.modifier_extension {
937                items.push(super::super::codec::Value::Object(
938                    super::super::codec::Json::to_json(item)?,
939                ));
940            }
941            object.insert(
942                std::string::String::from("modifierExtension"),
943                super::super::codec::Value::Array(items),
944            );
945        }
946        if let Some(v) = super::super::codec::Primitive::value_json(&self.method)? {
947            object.insert(std::string::String::from("method"), v);
948        }
949        if let Some(e) = super::super::codec::Primitive::element_json(&self.method)? {
950            object.insert(std::string::String::from("_method"), e);
951        }
952        if let Some(v) = super::super::codec::Primitive::value_json(&self.url)? {
953            object.insert(std::string::String::from("url"), v);
954        }
955        if let Some(e) = super::super::codec::Primitive::element_json(&self.url)? {
956            object.insert(std::string::String::from("_url"), e);
957        }
958        if let Some(item) = &self.if_none_match {
959            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
960                object.insert(std::string::String::from("ifNoneMatch"), v);
961            }
962            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
963                object.insert(std::string::String::from("_ifNoneMatch"), e);
964            }
965        }
966        if let Some(item) = &self.if_modified_since {
967            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
968                object.insert(std::string::String::from("ifModifiedSince"), v);
969            }
970            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
971                object.insert(std::string::String::from("_ifModifiedSince"), e);
972            }
973        }
974        if let Some(item) = &self.if_match {
975            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
976                object.insert(std::string::String::from("ifMatch"), v);
977            }
978            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
979                object.insert(std::string::String::from("_ifMatch"), e);
980            }
981        }
982        if let Some(item) = &self.if_none_exist {
983            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
984                object.insert(std::string::String::from("ifNoneExist"), v);
985            }
986            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
987                object.insert(std::string::String::from("_ifNoneExist"), e);
988            }
989        }
990        Ok(object)
991    }
992
993    fn from_json(
994        object: &super::super::codec::Object,
995        path: &mut super::super::codec::Path,
996    ) -> Result<Self, super::super::codec::DecodeError> {
997        let mut raw_id: Option<&super::super::codec::Value> = None;
998        let mut raw_extension: Option<&super::super::codec::Value> = None;
999        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1000        let mut raw_method: Option<&super::super::codec::Value> = None;
1001        let mut raw_method_element: Option<&super::super::codec::Value> = None;
1002        let mut raw_url: Option<&super::super::codec::Value> = None;
1003        let mut raw_url_element: Option<&super::super::codec::Value> = None;
1004        let mut raw_if_none_match: Option<&super::super::codec::Value> = None;
1005        let mut raw_if_none_match_element: Option<&super::super::codec::Value> = None;
1006        let mut raw_if_modified_since: Option<&super::super::codec::Value> = None;
1007        let mut raw_if_modified_since_element: Option<&super::super::codec::Value> = None;
1008        let mut raw_if_match: Option<&super::super::codec::Value> = None;
1009        let mut raw_if_match_element: Option<&super::super::codec::Value> = None;
1010        let mut raw_if_none_exist: Option<&super::super::codec::Value> = None;
1011        let mut raw_if_none_exist_element: Option<&super::super::codec::Value> = None;
1012        for (key, value) in object {
1013            match key.as_str() {
1014                "id" => {
1015                    raw_id = Some(value);
1016                }
1017                "extension" => {
1018                    raw_extension = Some(value);
1019                }
1020                "modifierExtension" => {
1021                    raw_modifier_extension = Some(value);
1022                }
1023                "method" => {
1024                    raw_method = Some(value);
1025                }
1026                "_method" => {
1027                    raw_method_element = Some(value);
1028                }
1029                "url" => {
1030                    raw_url = Some(value);
1031                }
1032                "_url" => {
1033                    raw_url_element = Some(value);
1034                }
1035                "ifNoneMatch" => {
1036                    raw_if_none_match = Some(value);
1037                }
1038                "_ifNoneMatch" => {
1039                    raw_if_none_match_element = Some(value);
1040                }
1041                "ifModifiedSince" => {
1042                    raw_if_modified_since = Some(value);
1043                }
1044                "_ifModifiedSince" => {
1045                    raw_if_modified_since_element = Some(value);
1046                }
1047                "ifMatch" => {
1048                    raw_if_match = Some(value);
1049                }
1050                "_ifMatch" => {
1051                    raw_if_match_element = Some(value);
1052                }
1053                "ifNoneExist" => {
1054                    raw_if_none_exist = Some(value);
1055                }
1056                "_ifNoneExist" => {
1057                    raw_if_none_exist_element = Some(value);
1058                }
1059                other => {
1060                    return path.with(other, |path| {
1061                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1062                    });
1063                }
1064            }
1065        }
1066        let field_id = raw_id
1067            .map(|value| {
1068                path.with("id", |path| {
1069                    let value = super::super::codec::expect_single(value, path)?;
1070                    super::primitives::checked_string(
1071                        super::super::codec::expect_string(value, path)?,
1072                        path,
1073                    )
1074                })
1075            })
1076            .transpose()?;
1077        let mut field_extension = Vec::new();
1078        if let Some(raw) = raw_extension {
1079            for (index, value) in path
1080                .with("extension", |path| {
1081                    super::super::codec::expect_array(raw, path)
1082                })?
1083                .iter()
1084                .enumerate()
1085            {
1086                field_extension.push(path.with_index("extension", index, |path| {
1087                    super::super::codec::Json::from_json(
1088                        super::super::codec::expect_object(value, path)?,
1089                        path,
1090                    )
1091                })?);
1092            }
1093        }
1094        let mut field_modifier_extension = Vec::new();
1095        if let Some(raw) = raw_modifier_extension {
1096            for (index, value) in path
1097                .with("modifierExtension", |path| {
1098                    super::super::codec::expect_array(raw, path)
1099                })?
1100                .iter()
1101                .enumerate()
1102            {
1103                field_modifier_extension.push(path.with_index(
1104                    "modifierExtension",
1105                    index,
1106                    |path| {
1107                        super::super::codec::Json::from_json(
1108                            super::super::codec::expect_object(value, path)?,
1109                            path,
1110                        )
1111                    },
1112                )?);
1113            }
1114        }
1115        let field_method = path.with("method", |path| {
1116            super::super::codec::Primitive::from_json_parts(raw_method, raw_method_element, path)
1117        })?;
1118        let field_url = path.with("url", |path| {
1119            super::super::codec::Primitive::from_json_parts(raw_url, raw_url_element, path)
1120        })?;
1121        let field_if_none_match = match (raw_if_none_match, raw_if_none_match_element) {
1122            (None, None) => None,
1123            (value, element) => Some(path.with("ifNoneMatch", |path| {
1124                super::super::codec::Primitive::from_json_parts(value, element, path)
1125            })?),
1126        };
1127        let field_if_modified_since = match (raw_if_modified_since, raw_if_modified_since_element) {
1128            (None, None) => None,
1129            (value, element) => Some(path.with("ifModifiedSince", |path| {
1130                super::super::codec::Primitive::from_json_parts(value, element, path)
1131            })?),
1132        };
1133        let field_if_match = match (raw_if_match, raw_if_match_element) {
1134            (None, None) => None,
1135            (value, element) => Some(path.with("ifMatch", |path| {
1136                super::super::codec::Primitive::from_json_parts(value, element, path)
1137            })?),
1138        };
1139        let field_if_none_exist = match (raw_if_none_exist, raw_if_none_exist_element) {
1140            (None, None) => None,
1141            (value, element) => Some(path.with("ifNoneExist", |path| {
1142                super::super::codec::Primitive::from_json_parts(value, element, path)
1143            })?),
1144        };
1145        Ok(Self {
1146            id: field_id,
1147            extension: field_extension,
1148            modifier_extension: field_modifier_extension,
1149            method: field_method,
1150            url: field_url,
1151            if_none_match: field_if_none_match,
1152            if_modified_since: field_if_modified_since,
1153            if_match: field_if_match,
1154            if_none_exist: field_if_none_exist,
1155        })
1156    }
1157}
1158
1159impl serde::Serialize for BundleEntryRequest {
1160    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1161        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1162        if let Some(item) = &self.if_match {
1163            super::super::codec::element_entry(&mut map, "_ifMatch", item)?;
1164        }
1165        if let Some(item) = &self.if_modified_since {
1166            super::super::codec::element_entry(&mut map, "_ifModifiedSince", item)?;
1167        }
1168        if let Some(item) = &self.if_none_exist {
1169            super::super::codec::element_entry(&mut map, "_ifNoneExist", item)?;
1170        }
1171        if let Some(item) = &self.if_none_match {
1172            super::super::codec::element_entry(&mut map, "_ifNoneMatch", item)?;
1173        }
1174        super::super::codec::element_entry(&mut map, "_method", &self.method)?;
1175        super::super::codec::element_entry(&mut map, "_url", &self.url)?;
1176        if !self.extension.is_empty() {
1177            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1178        }
1179        if let Some(v) = &self.id {
1180            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1181        }
1182        if let Some(item) = &self.if_match {
1183            super::super::codec::value_entry(&mut map, "ifMatch", item)?;
1184        }
1185        if let Some(item) = &self.if_modified_since {
1186            super::super::codec::value_entry(&mut map, "ifModifiedSince", item)?;
1187        }
1188        if let Some(item) = &self.if_none_exist {
1189            super::super::codec::value_entry(&mut map, "ifNoneExist", item)?;
1190        }
1191        if let Some(item) = &self.if_none_match {
1192            super::super::codec::value_entry(&mut map, "ifNoneMatch", item)?;
1193        }
1194        super::super::codec::value_entry(&mut map, "method", &self.method)?;
1195        if !self.modifier_extension.is_empty() {
1196            serde::ser::SerializeMap::serialize_entry(
1197                &mut map,
1198                "modifierExtension",
1199                &self.modifier_extension,
1200            )?;
1201        }
1202        super::super::codec::value_entry(&mut map, "url", &self.url)?;
1203        serde::ser::SerializeMap::end(map)
1204    }
1205}
1206
1207impl<'de> serde::Deserialize<'de> for BundleEntryRequest {
1208    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1209        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1210        let mut path = super::super::codec::Path::root("BundleEntryRequest");
1211        let object =
1212            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1213        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1214    }
1215}
1216
1217/// Results of execution (transaction/batch/history)
1218///
1219/// Indicates the results of processing the corresponding 'request' entry in the
1220/// batch or transaction being responded to or what the results of an operation
1221/// where when returning history.
1222#[derive(Debug, Clone, Default, PartialEq, Eq)]
1223pub struct BundleEntryResponse {
1224    /// Unique id for inter-element referencing
1225    ///
1226    /// Unique id for the element within a resource (for internal references). This
1227    /// may be any string value that does not contain spaces.
1228    pub id: Option<std::string::String>,
1229    /// Additional content defined by implementations
1230    ///
1231    /// May be used to represent additional information that is not part of the
1232    /// basic definition of the element. To make the use of extensions safe and
1233    /// managable, there is a strict set of governance applied to the definition and
1234    /// use of extensions. Though any implementer can define an extension, there is
1235    /// a set of requirements that SHALL be met as part of the definition of the
1236    /// extension.
1237    pub extension: Vec<super::extension::Extension>,
1238    /// Extensions that cannot be ignored even if unrecognized
1239    ///
1240    /// May be used to represent additional information that is not part of the
1241    /// basic definition of the element and that modifies the understanding of the
1242    /// element in which it is contained and/or the understanding of the containing
1243    /// element's descendants. Usually modifier elements provide negation or
1244    /// qualification. To make the use of extensions safe and managable, there is a
1245    /// strict set of governance applied to the definition and use of extensions.
1246    /// Though any implementer can define an extension, there is a set of
1247    /// requirements that SHALL be met as part of the definition of the extension.
1248    /// Applications processing a resource are required to check for modifier
1249    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1250    /// on Resource or DomainResource (including cannot change the meaning of
1251    /// modifierExtension itself).
1252    pub modifier_extension: Vec<super::extension::Extension>,
1253    /// Status response code (text optional)
1254    ///
1255    /// The status code returned by processing this entry. The status SHALL start
1256    /// with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP
1257    /// description associated with the status code.
1258    pub status: super::primitives::String,
1259    /// The location (if the operation returns a location)
1260    ///
1261    /// The location header created by processing this operation, populated if the
1262    /// operation returns a location.
1263    pub location: Option<super::primitives::Uri>,
1264    /// The Etag for the resource (if relevant)
1265    ///
1266    /// The Etag for the resource, if the operation for the entry produced a
1267    /// versioned resource (see \[Resource Metadata and
1268    /// Versioning\](http.html\#versioning) and \[Managing Resource
1269    /// Contention\](http.html\#concurrency)).
1270    pub etag: Option<super::primitives::String>,
1271    /// Server's date time modified
1272    ///
1273    /// The date/time that the resource was modified on the server.
1274    pub last_modified: Option<super::primitives::Instant>,
1275    /// OperationOutcome with hints and warnings (for batch/transaction)
1276    ///
1277    /// An OperationOutcome containing hints and warnings produced as part of
1278    /// processing this entry in a batch or transaction.
1279    pub outcome: Option<super::resource::Resource>,
1280}
1281
1282impl super::super::codec::Json for BundleEntryResponse {
1283    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1284        let mut object = super::super::codec::Object::new();
1285        if let Some(v) = &self.id {
1286            object.insert(
1287                std::string::String::from("id"),
1288                super::super::codec::Value::String(v.clone()),
1289            );
1290        }
1291        if !self.extension.is_empty() {
1292            let mut items = Vec::with_capacity(self.extension.len());
1293            for item in &self.extension {
1294                items.push(super::super::codec::Value::Object(
1295                    super::super::codec::Json::to_json(item)?,
1296                ));
1297            }
1298            object.insert(
1299                std::string::String::from("extension"),
1300                super::super::codec::Value::Array(items),
1301            );
1302        }
1303        if !self.modifier_extension.is_empty() {
1304            let mut items = Vec::with_capacity(self.modifier_extension.len());
1305            for item in &self.modifier_extension {
1306                items.push(super::super::codec::Value::Object(
1307                    super::super::codec::Json::to_json(item)?,
1308                ));
1309            }
1310            object.insert(
1311                std::string::String::from("modifierExtension"),
1312                super::super::codec::Value::Array(items),
1313            );
1314        }
1315        if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
1316            object.insert(std::string::String::from("status"), v);
1317        }
1318        if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
1319            object.insert(std::string::String::from("_status"), e);
1320        }
1321        if let Some(item) = &self.location {
1322            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1323                object.insert(std::string::String::from("location"), v);
1324            }
1325            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1326                object.insert(std::string::String::from("_location"), e);
1327            }
1328        }
1329        if let Some(item) = &self.etag {
1330            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1331                object.insert(std::string::String::from("etag"), v);
1332            }
1333            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1334                object.insert(std::string::String::from("_etag"), e);
1335            }
1336        }
1337        if let Some(item) = &self.last_modified {
1338            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1339                object.insert(std::string::String::from("lastModified"), v);
1340            }
1341            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1342                object.insert(std::string::String::from("_lastModified"), e);
1343            }
1344        }
1345        if let Some(item) = &self.outcome {
1346            object.insert(
1347                std::string::String::from("outcome"),
1348                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
1349            );
1350        }
1351        Ok(object)
1352    }
1353
1354    fn from_json(
1355        object: &super::super::codec::Object,
1356        path: &mut super::super::codec::Path,
1357    ) -> Result<Self, super::super::codec::DecodeError> {
1358        let mut raw_id: Option<&super::super::codec::Value> = None;
1359        let mut raw_extension: Option<&super::super::codec::Value> = None;
1360        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1361        let mut raw_status: Option<&super::super::codec::Value> = None;
1362        let mut raw_status_element: Option<&super::super::codec::Value> = None;
1363        let mut raw_location: Option<&super::super::codec::Value> = None;
1364        let mut raw_location_element: Option<&super::super::codec::Value> = None;
1365        let mut raw_etag: Option<&super::super::codec::Value> = None;
1366        let mut raw_etag_element: Option<&super::super::codec::Value> = None;
1367        let mut raw_last_modified: Option<&super::super::codec::Value> = None;
1368        let mut raw_last_modified_element: Option<&super::super::codec::Value> = None;
1369        let mut raw_outcome: Option<&super::super::codec::Value> = None;
1370        for (key, value) in object {
1371            match key.as_str() {
1372                "id" => {
1373                    raw_id = Some(value);
1374                }
1375                "extension" => {
1376                    raw_extension = Some(value);
1377                }
1378                "modifierExtension" => {
1379                    raw_modifier_extension = Some(value);
1380                }
1381                "status" => {
1382                    raw_status = Some(value);
1383                }
1384                "_status" => {
1385                    raw_status_element = Some(value);
1386                }
1387                "location" => {
1388                    raw_location = Some(value);
1389                }
1390                "_location" => {
1391                    raw_location_element = Some(value);
1392                }
1393                "etag" => {
1394                    raw_etag = Some(value);
1395                }
1396                "_etag" => {
1397                    raw_etag_element = Some(value);
1398                }
1399                "lastModified" => {
1400                    raw_last_modified = Some(value);
1401                }
1402                "_lastModified" => {
1403                    raw_last_modified_element = Some(value);
1404                }
1405                "outcome" => {
1406                    raw_outcome = Some(value);
1407                }
1408                other => {
1409                    return path.with(other, |path| {
1410                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1411                    });
1412                }
1413            }
1414        }
1415        let field_id = raw_id
1416            .map(|value| {
1417                path.with("id", |path| {
1418                    let value = super::super::codec::expect_single(value, path)?;
1419                    super::primitives::checked_string(
1420                        super::super::codec::expect_string(value, path)?,
1421                        path,
1422                    )
1423                })
1424            })
1425            .transpose()?;
1426        let mut field_extension = Vec::new();
1427        if let Some(raw) = raw_extension {
1428            for (index, value) in path
1429                .with("extension", |path| {
1430                    super::super::codec::expect_array(raw, path)
1431                })?
1432                .iter()
1433                .enumerate()
1434            {
1435                field_extension.push(path.with_index("extension", index, |path| {
1436                    super::super::codec::Json::from_json(
1437                        super::super::codec::expect_object(value, path)?,
1438                        path,
1439                    )
1440                })?);
1441            }
1442        }
1443        let mut field_modifier_extension = Vec::new();
1444        if let Some(raw) = raw_modifier_extension {
1445            for (index, value) in path
1446                .with("modifierExtension", |path| {
1447                    super::super::codec::expect_array(raw, path)
1448                })?
1449                .iter()
1450                .enumerate()
1451            {
1452                field_modifier_extension.push(path.with_index(
1453                    "modifierExtension",
1454                    index,
1455                    |path| {
1456                        super::super::codec::Json::from_json(
1457                            super::super::codec::expect_object(value, path)?,
1458                            path,
1459                        )
1460                    },
1461                )?);
1462            }
1463        }
1464        let field_status = path.with("status", |path| {
1465            super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
1466        })?;
1467        let field_location = match (raw_location, raw_location_element) {
1468            (None, None) => None,
1469            (value, element) => Some(path.with("location", |path| {
1470                super::super::codec::Primitive::from_json_parts(value, element, path)
1471            })?),
1472        };
1473        let field_etag = match (raw_etag, raw_etag_element) {
1474            (None, None) => None,
1475            (value, element) => Some(path.with("etag", |path| {
1476                super::super::codec::Primitive::from_json_parts(value, element, path)
1477            })?),
1478        };
1479        let field_last_modified = match (raw_last_modified, raw_last_modified_element) {
1480            (None, None) => None,
1481            (value, element) => Some(path.with("lastModified", |path| {
1482                super::super::codec::Primitive::from_json_parts(value, element, path)
1483            })?),
1484        };
1485        let field_outcome = raw_outcome
1486            .map(|value| {
1487                path.with("outcome", |path| {
1488                    super::super::codec::Json::from_json(
1489                        super::super::codec::expect_object(
1490                            super::super::codec::expect_single(value, path)?,
1491                            path,
1492                        )?,
1493                        path,
1494                    )
1495                })
1496            })
1497            .transpose()?;
1498        Ok(Self {
1499            id: field_id,
1500            extension: field_extension,
1501            modifier_extension: field_modifier_extension,
1502            status: field_status,
1503            location: field_location,
1504            etag: field_etag,
1505            last_modified: field_last_modified,
1506            outcome: field_outcome,
1507        })
1508    }
1509}
1510
1511impl serde::Serialize for BundleEntryResponse {
1512    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1513        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1514        if let Some(item) = &self.etag {
1515            super::super::codec::element_entry(&mut map, "_etag", item)?;
1516        }
1517        if let Some(item) = &self.last_modified {
1518            super::super::codec::element_entry(&mut map, "_lastModified", item)?;
1519        }
1520        if let Some(item) = &self.location {
1521            super::super::codec::element_entry(&mut map, "_location", item)?;
1522        }
1523        super::super::codec::element_entry(&mut map, "_status", &self.status)?;
1524        if let Some(item) = &self.etag {
1525            super::super::codec::value_entry(&mut map, "etag", item)?;
1526        }
1527        if !self.extension.is_empty() {
1528            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1529        }
1530        if let Some(v) = &self.id {
1531            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1532        }
1533        if let Some(item) = &self.last_modified {
1534            super::super::codec::value_entry(&mut map, "lastModified", item)?;
1535        }
1536        if let Some(item) = &self.location {
1537            super::super::codec::value_entry(&mut map, "location", item)?;
1538        }
1539        if !self.modifier_extension.is_empty() {
1540            serde::ser::SerializeMap::serialize_entry(
1541                &mut map,
1542                "modifierExtension",
1543                &self.modifier_extension,
1544            )?;
1545        }
1546        if let Some(item) = &self.outcome {
1547            serde::ser::SerializeMap::serialize_entry(&mut map, "outcome", item)?;
1548        }
1549        super::super::codec::value_entry(&mut map, "status", &self.status)?;
1550        serde::ser::SerializeMap::end(map)
1551    }
1552}
1553
1554impl<'de> serde::Deserialize<'de> for BundleEntryResponse {
1555    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1556        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1557        let mut path = super::super::codec::Path::root("BundleEntryResponse");
1558        let object =
1559            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1560        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1561    }
1562}
1563
1564/// Search related information
1565///
1566/// Information about the search process that lead to the creation of this
1567/// entry.
1568#[derive(Debug, Clone, Default, PartialEq, Eq)]
1569pub struct BundleEntrySearch {
1570    /// Unique id for inter-element referencing
1571    ///
1572    /// Unique id for the element within a resource (for internal references). This
1573    /// may be any string value that does not contain spaces.
1574    pub id: Option<std::string::String>,
1575    /// Additional content defined by implementations
1576    ///
1577    /// May be used to represent additional information that is not part of the
1578    /// basic definition of the element. To make the use of extensions safe and
1579    /// managable, there is a strict set of governance applied to the definition and
1580    /// use of extensions. Though any implementer can define an extension, there is
1581    /// a set of requirements that SHALL be met as part of the definition of the
1582    /// extension.
1583    pub extension: Vec<super::extension::Extension>,
1584    /// Extensions that cannot be ignored even if unrecognized
1585    ///
1586    /// May be used to represent additional information that is not part of the
1587    /// basic definition of the element and that modifies the understanding of the
1588    /// element in which it is contained and/or the understanding of the containing
1589    /// element's descendants. Usually modifier elements provide negation or
1590    /// qualification. To make the use of extensions safe and managable, there is a
1591    /// strict set of governance applied to the definition and use of extensions.
1592    /// Though any implementer can define an extension, there is a set of
1593    /// requirements that SHALL be met as part of the definition of the extension.
1594    /// Applications processing a resource are required to check for modifier
1595    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1596    /// on Resource or DomainResource (including cannot change the meaning of
1597    /// modifierExtension itself).
1598    pub modifier_extension: Vec<super::extension::Extension>,
1599    /// match | include - why this is in the result set
1600    ///
1601    /// Why this entry is in the result set - whether it's included as a match or
1602    /// because of an \_include requirement, or to convey information or warning
1603    /// information about the search process.
1604    pub mode: Option<super::primitives::Code>,
1605    /// Search ranking (between 0 and 1)
1606    ///
1607    /// When searching, the server's search ranking score for the entry.
1608    pub score: Option<super::primitives::Decimal>,
1609}
1610
1611impl super::super::codec::Json for BundleEntrySearch {
1612    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1613        let mut object = super::super::codec::Object::new();
1614        if let Some(v) = &self.id {
1615            object.insert(
1616                std::string::String::from("id"),
1617                super::super::codec::Value::String(v.clone()),
1618            );
1619        }
1620        if !self.extension.is_empty() {
1621            let mut items = Vec::with_capacity(self.extension.len());
1622            for item in &self.extension {
1623                items.push(super::super::codec::Value::Object(
1624                    super::super::codec::Json::to_json(item)?,
1625                ));
1626            }
1627            object.insert(
1628                std::string::String::from("extension"),
1629                super::super::codec::Value::Array(items),
1630            );
1631        }
1632        if !self.modifier_extension.is_empty() {
1633            let mut items = Vec::with_capacity(self.modifier_extension.len());
1634            for item in &self.modifier_extension {
1635                items.push(super::super::codec::Value::Object(
1636                    super::super::codec::Json::to_json(item)?,
1637                ));
1638            }
1639            object.insert(
1640                std::string::String::from("modifierExtension"),
1641                super::super::codec::Value::Array(items),
1642            );
1643        }
1644        if let Some(item) = &self.mode {
1645            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1646                object.insert(std::string::String::from("mode"), v);
1647            }
1648            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1649                object.insert(std::string::String::from("_mode"), e);
1650            }
1651        }
1652        if let Some(item) = &self.score {
1653            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1654                object.insert(std::string::String::from("score"), v);
1655            }
1656            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1657                object.insert(std::string::String::from("_score"), e);
1658            }
1659        }
1660        Ok(object)
1661    }
1662
1663    fn from_json(
1664        object: &super::super::codec::Object,
1665        path: &mut super::super::codec::Path,
1666    ) -> Result<Self, super::super::codec::DecodeError> {
1667        let mut raw_id: Option<&super::super::codec::Value> = None;
1668        let mut raw_extension: Option<&super::super::codec::Value> = None;
1669        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1670        let mut raw_mode: Option<&super::super::codec::Value> = None;
1671        let mut raw_mode_element: Option<&super::super::codec::Value> = None;
1672        let mut raw_score: Option<&super::super::codec::Value> = None;
1673        let mut raw_score_element: Option<&super::super::codec::Value> = None;
1674        for (key, value) in object {
1675            match key.as_str() {
1676                "id" => {
1677                    raw_id = Some(value);
1678                }
1679                "extension" => {
1680                    raw_extension = Some(value);
1681                }
1682                "modifierExtension" => {
1683                    raw_modifier_extension = Some(value);
1684                }
1685                "mode" => {
1686                    raw_mode = Some(value);
1687                }
1688                "_mode" => {
1689                    raw_mode_element = Some(value);
1690                }
1691                "score" => {
1692                    raw_score = Some(value);
1693                }
1694                "_score" => {
1695                    raw_score_element = Some(value);
1696                }
1697                other => {
1698                    return path.with(other, |path| {
1699                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1700                    });
1701                }
1702            }
1703        }
1704        let field_id = raw_id
1705            .map(|value| {
1706                path.with("id", |path| {
1707                    let value = super::super::codec::expect_single(value, path)?;
1708                    super::primitives::checked_string(
1709                        super::super::codec::expect_string(value, path)?,
1710                        path,
1711                    )
1712                })
1713            })
1714            .transpose()?;
1715        let mut field_extension = Vec::new();
1716        if let Some(raw) = raw_extension {
1717            for (index, value) in path
1718                .with("extension", |path| {
1719                    super::super::codec::expect_array(raw, path)
1720                })?
1721                .iter()
1722                .enumerate()
1723            {
1724                field_extension.push(path.with_index("extension", index, |path| {
1725                    super::super::codec::Json::from_json(
1726                        super::super::codec::expect_object(value, path)?,
1727                        path,
1728                    )
1729                })?);
1730            }
1731        }
1732        let mut field_modifier_extension = Vec::new();
1733        if let Some(raw) = raw_modifier_extension {
1734            for (index, value) in path
1735                .with("modifierExtension", |path| {
1736                    super::super::codec::expect_array(raw, path)
1737                })?
1738                .iter()
1739                .enumerate()
1740            {
1741                field_modifier_extension.push(path.with_index(
1742                    "modifierExtension",
1743                    index,
1744                    |path| {
1745                        super::super::codec::Json::from_json(
1746                            super::super::codec::expect_object(value, path)?,
1747                            path,
1748                        )
1749                    },
1750                )?);
1751            }
1752        }
1753        let field_mode = match (raw_mode, raw_mode_element) {
1754            (None, None) => None,
1755            (value, element) => Some(path.with("mode", |path| {
1756                super::super::codec::Primitive::from_json_parts(value, element, path)
1757            })?),
1758        };
1759        let field_score = match (raw_score, raw_score_element) {
1760            (None, None) => None,
1761            (value, element) => Some(path.with("score", |path| {
1762                super::super::codec::Primitive::from_json_parts(value, element, path)
1763            })?),
1764        };
1765        Ok(Self {
1766            id: field_id,
1767            extension: field_extension,
1768            modifier_extension: field_modifier_extension,
1769            mode: field_mode,
1770            score: field_score,
1771        })
1772    }
1773}
1774
1775impl serde::Serialize for BundleEntrySearch {
1776    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1777        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1778        if let Some(item) = &self.mode {
1779            super::super::codec::element_entry(&mut map, "_mode", item)?;
1780        }
1781        if let Some(item) = &self.score {
1782            super::super::codec::element_entry(&mut map, "_score", item)?;
1783        }
1784        if !self.extension.is_empty() {
1785            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1786        }
1787        if let Some(v) = &self.id {
1788            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1789        }
1790        if let Some(item) = &self.mode {
1791            super::super::codec::value_entry(&mut map, "mode", item)?;
1792        }
1793        if !self.modifier_extension.is_empty() {
1794            serde::ser::SerializeMap::serialize_entry(
1795                &mut map,
1796                "modifierExtension",
1797                &self.modifier_extension,
1798            )?;
1799        }
1800        if let Some(item) = &self.score {
1801            super::super::codec::value_entry(&mut map, "score", item)?;
1802        }
1803        serde::ser::SerializeMap::end(map)
1804    }
1805}
1806
1807impl<'de> serde::Deserialize<'de> for BundleEntrySearch {
1808    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1809        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1810        let mut path = super::super::codec::Path::root("BundleEntrySearch");
1811        let object =
1812            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1813        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1814    }
1815}
1816
1817/// Links related to this Bundle
1818///
1819/// A series of links that provide context to this bundle.
1820#[derive(Debug, Clone, Default, PartialEq, Eq)]
1821pub struct BundleLink {
1822    /// Unique id for inter-element referencing
1823    ///
1824    /// Unique id for the element within a resource (for internal references). This
1825    /// may be any string value that does not contain spaces.
1826    pub id: Option<std::string::String>,
1827    /// Additional content defined by implementations
1828    ///
1829    /// May be used to represent additional information that is not part of the
1830    /// basic definition of the element. To make the use of extensions safe and
1831    /// managable, there is a strict set of governance applied to the definition and
1832    /// use of extensions. Though any implementer can define an extension, there is
1833    /// a set of requirements that SHALL be met as part of the definition of the
1834    /// extension.
1835    pub extension: Vec<super::extension::Extension>,
1836    /// Extensions that cannot be ignored even if unrecognized
1837    ///
1838    /// May be used to represent additional information that is not part of the
1839    /// basic definition of the element and that modifies the understanding of the
1840    /// element in which it is contained and/or the understanding of the containing
1841    /// element's descendants. Usually modifier elements provide negation or
1842    /// qualification. To make the use of extensions safe and managable, there is a
1843    /// strict set of governance applied to the definition and use of extensions.
1844    /// Though any implementer can define an extension, there is a set of
1845    /// requirements that SHALL be met as part of the definition of the extension.
1846    /// Applications processing a resource are required to check for modifier
1847    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1848    /// on Resource or DomainResource (including cannot change the meaning of
1849    /// modifierExtension itself).
1850    pub modifier_extension: Vec<super::extension::Extension>,
1851    /// See
1852    /// <http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1>
1853    ///
1854    /// A name which details the functional use for this link - see
1855    /// \[<http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1>\](<http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1>).
1856    pub relation: super::primitives::Code,
1857    /// Reference details for the link
1858    ///
1859    /// The reference details for the link.
1860    pub url: super::primitives::Uri,
1861}
1862
1863impl super::super::codec::Json for BundleLink {
1864    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1865        let mut object = super::super::codec::Object::new();
1866        if let Some(v) = &self.id {
1867            object.insert(
1868                std::string::String::from("id"),
1869                super::super::codec::Value::String(v.clone()),
1870            );
1871        }
1872        if !self.extension.is_empty() {
1873            let mut items = Vec::with_capacity(self.extension.len());
1874            for item in &self.extension {
1875                items.push(super::super::codec::Value::Object(
1876                    super::super::codec::Json::to_json(item)?,
1877                ));
1878            }
1879            object.insert(
1880                std::string::String::from("extension"),
1881                super::super::codec::Value::Array(items),
1882            );
1883        }
1884        if !self.modifier_extension.is_empty() {
1885            let mut items = Vec::with_capacity(self.modifier_extension.len());
1886            for item in &self.modifier_extension {
1887                items.push(super::super::codec::Value::Object(
1888                    super::super::codec::Json::to_json(item)?,
1889                ));
1890            }
1891            object.insert(
1892                std::string::String::from("modifierExtension"),
1893                super::super::codec::Value::Array(items),
1894            );
1895        }
1896        if let Some(v) = super::super::codec::Primitive::value_json(&self.relation)? {
1897            object.insert(std::string::String::from("relation"), v);
1898        }
1899        if let Some(e) = super::super::codec::Primitive::element_json(&self.relation)? {
1900            object.insert(std::string::String::from("_relation"), e);
1901        }
1902        if let Some(v) = super::super::codec::Primitive::value_json(&self.url)? {
1903            object.insert(std::string::String::from("url"), v);
1904        }
1905        if let Some(e) = super::super::codec::Primitive::element_json(&self.url)? {
1906            object.insert(std::string::String::from("_url"), e);
1907        }
1908        Ok(object)
1909    }
1910
1911    fn from_json(
1912        object: &super::super::codec::Object,
1913        path: &mut super::super::codec::Path,
1914    ) -> Result<Self, super::super::codec::DecodeError> {
1915        let mut raw_id: Option<&super::super::codec::Value> = None;
1916        let mut raw_extension: Option<&super::super::codec::Value> = None;
1917        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1918        let mut raw_relation: Option<&super::super::codec::Value> = None;
1919        let mut raw_relation_element: Option<&super::super::codec::Value> = None;
1920        let mut raw_url: Option<&super::super::codec::Value> = None;
1921        let mut raw_url_element: Option<&super::super::codec::Value> = None;
1922        for (key, value) in object {
1923            match key.as_str() {
1924                "id" => {
1925                    raw_id = Some(value);
1926                }
1927                "extension" => {
1928                    raw_extension = Some(value);
1929                }
1930                "modifierExtension" => {
1931                    raw_modifier_extension = Some(value);
1932                }
1933                "relation" => {
1934                    raw_relation = Some(value);
1935                }
1936                "_relation" => {
1937                    raw_relation_element = Some(value);
1938                }
1939                "url" => {
1940                    raw_url = Some(value);
1941                }
1942                "_url" => {
1943                    raw_url_element = Some(value);
1944                }
1945                other => {
1946                    return path.with(other, |path| {
1947                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1948                    });
1949                }
1950            }
1951        }
1952        let field_id = raw_id
1953            .map(|value| {
1954                path.with("id", |path| {
1955                    let value = super::super::codec::expect_single(value, path)?;
1956                    super::primitives::checked_string(
1957                        super::super::codec::expect_string(value, path)?,
1958                        path,
1959                    )
1960                })
1961            })
1962            .transpose()?;
1963        let mut field_extension = Vec::new();
1964        if let Some(raw) = raw_extension {
1965            for (index, value) in path
1966                .with("extension", |path| {
1967                    super::super::codec::expect_array(raw, path)
1968                })?
1969                .iter()
1970                .enumerate()
1971            {
1972                field_extension.push(path.with_index("extension", index, |path| {
1973                    super::super::codec::Json::from_json(
1974                        super::super::codec::expect_object(value, path)?,
1975                        path,
1976                    )
1977                })?);
1978            }
1979        }
1980        let mut field_modifier_extension = Vec::new();
1981        if let Some(raw) = raw_modifier_extension {
1982            for (index, value) in path
1983                .with("modifierExtension", |path| {
1984                    super::super::codec::expect_array(raw, path)
1985                })?
1986                .iter()
1987                .enumerate()
1988            {
1989                field_modifier_extension.push(path.with_index(
1990                    "modifierExtension",
1991                    index,
1992                    |path| {
1993                        super::super::codec::Json::from_json(
1994                            super::super::codec::expect_object(value, path)?,
1995                            path,
1996                        )
1997                    },
1998                )?);
1999            }
2000        }
2001        let field_relation = path.with("relation", |path| {
2002            super::super::codec::Primitive::from_json_parts(
2003                raw_relation,
2004                raw_relation_element,
2005                path,
2006            )
2007        })?;
2008        let field_url = path.with("url", |path| {
2009            super::super::codec::Primitive::from_json_parts(raw_url, raw_url_element, path)
2010        })?;
2011        Ok(Self {
2012            id: field_id,
2013            extension: field_extension,
2014            modifier_extension: field_modifier_extension,
2015            relation: field_relation,
2016            url: field_url,
2017        })
2018    }
2019}
2020
2021impl serde::Serialize for BundleLink {
2022    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2023        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2024        super::super::codec::element_entry(&mut map, "_relation", &self.relation)?;
2025        super::super::codec::element_entry(&mut map, "_url", &self.url)?;
2026        if !self.extension.is_empty() {
2027            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2028        }
2029        if let Some(v) = &self.id {
2030            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2031        }
2032        if !self.modifier_extension.is_empty() {
2033            serde::ser::SerializeMap::serialize_entry(
2034                &mut map,
2035                "modifierExtension",
2036                &self.modifier_extension,
2037            )?;
2038        }
2039        super::super::codec::value_entry(&mut map, "relation", &self.relation)?;
2040        super::super::codec::value_entry(&mut map, "url", &self.url)?;
2041        serde::ser::SerializeMap::end(map)
2042    }
2043}
2044
2045impl<'de> serde::Deserialize<'de> for BundleLink {
2046    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2047        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2048        let mut path = super::super::codec::Path::root("BundleLink");
2049        let object =
2050            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2051        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2052    }
2053}