Skip to main content

fhir_types/r4b/
bundle.rs

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