Skip to main content

fhir_types/r5/
bundle.rs

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