Skip to main content

fhir_types/r4b/
capability_statement.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//! A statement of system capabilities
6
7/// A statement of system capabilities
8///
9/// A Capability Statement documents a set of capabilities (behaviors) of a FHIR
10/// Server for a particular version of FHIR that may be used as a statement of
11/// actual server functionality or a statement of required or desired server
12/// implementation.
13#[derive(Debug, Clone, Default, PartialEq, Eq)]
14pub struct CapabilityStatement {
15    /// Logical id of this artifact
16    ///
17    /// The logical id of the resource, as used in the URL for the resource. Once
18    /// assigned, this value never changes.
19    pub id: Option<std::string::String>,
20    /// Metadata about the resource
21    ///
22    /// The metadata about the resource. This is content that is maintained by the
23    /// infrastructure. Changes to the content might not always be associated with
24    /// version changes to the resource.
25    pub meta: Option<super::meta::Meta>,
26    /// A set of rules under which this content was created
27    ///
28    /// A reference to a set of rules that were followed when the resource was
29    /// constructed, and which must be understood when processing the content.
30    /// Often, this is a reference to an implementation guide that defines the
31    /// special rules along with other profiles etc.
32    pub implicit_rules: Option<super::primitives::Uri>,
33    /// Language of the resource content
34    ///
35    /// The base language in which the resource is written.
36    pub language: Option<super::primitives::Code>,
37    /// Text summary of the resource, for human interpretation
38    ///
39    /// A human-readable narrative that contains a summary of the resource and can
40    /// be used to represent the content of the resource to a human. The narrative
41    /// need not encode all the structured data, but is required to contain
42    /// sufficient detail to make it "clinically safe" for a human to just read the
43    /// narrative. Resource definitions may define what content should be
44    /// represented in the narrative to ensure clinical safety.
45    pub text: Option<super::narrative::Narrative>,
46    /// Contained, inline Resources
47    ///
48    /// These resources do not have an independent existence apart from the resource
49    /// that contains them - they cannot be identified independently, and nor can
50    /// they have their own independent transaction scope.
51    pub contained: Vec<super::resource::Resource>,
52    /// Additional content defined by implementations
53    ///
54    /// May be used to represent additional information that is not part of the
55    /// basic definition of the resource. To make the use of extensions safe and
56    /// manageable, there is a strict set of governance applied to the definition
57    /// and use of extensions. Though any implementer can define an extension, there
58    /// is a set of requirements that SHALL be met as part of the definition of the
59    /// extension.
60    pub extension: Vec<super::extension::Extension>,
61    /// Extensions that cannot be ignored
62    ///
63    /// May be used to represent additional information that is not part of the
64    /// basic definition of the resource and that modifies the understanding of the
65    /// element that contains it and/or the understanding of the containing
66    /// element's descendants. Usually modifier elements provide negation or
67    /// qualification. To make the use of extensions safe and manageable, there is a
68    /// strict set of governance applied to the definition and use of extensions.
69    /// Though any implementer is allowed to define an extension, there is a set of
70    /// requirements that SHALL be met as part of the definition of the extension.
71    /// Applications processing a resource are required to check for modifier
72    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
73    /// on Resource or DomainResource (including cannot change the meaning of
74    /// modifierExtension itself).
75    pub modifier_extension: Vec<super::extension::Extension>,
76    /// Canonical identifier for this capability statement, represented as a URI
77    /// (globally unique)
78    ///
79    /// An absolute URI that is used to identify this capability statement when it
80    /// is referenced in a specification, model, design or an instance; also called
81    /// its canonical identifier. This SHOULD be globally unique and SHOULD be a
82    /// literal address at which at which an authoritative instance of this
83    /// capability statement is (or will be) published. This URL can be the target
84    /// of a canonical reference. It SHALL remain the same when the capability
85    /// statement is stored on different servers.
86    pub url: Option<super::primitives::Uri>,
87    /// Business version of the capability statement
88    ///
89    /// The identifier that is used to identify this version of the capability
90    /// statement when it is referenced in a specification, model, design or
91    /// instance. This is an arbitrary value managed by the capability statement
92    /// author and is not expected to be globally unique. For example, it might be a
93    /// timestamp (e.g. yyyymmdd) if a managed version is not available. There is
94    /// also no expectation that versions can be placed in a lexicographical
95    /// sequence.
96    pub version: Option<super::primitives::String>,
97    /// Name for this capability statement (computer friendly)
98    ///
99    /// A natural language name identifying the capability statement. This name
100    /// should be usable as an identifier for the module by machine processing
101    /// applications such as code generation.
102    pub name: Option<super::primitives::String>,
103    /// Name for this capability statement (human friendly)
104    ///
105    /// A short, descriptive, user-friendly title for the capability statement.
106    pub title: Option<super::primitives::String>,
107    /// draft | active | retired | unknown
108    ///
109    /// The status of this capability statement. Enables tracking the life-cycle of
110    /// the content.
111    pub status: super::primitives::Code,
112    /// For testing purposes, not real usage
113    ///
114    /// A Boolean value to indicate that this capability statement is authored for
115    /// testing purposes (or education/evaluation/marketing) and is not intended to
116    /// be used for genuine usage.
117    pub experimental: Option<super::primitives::Boolean>,
118    /// Date last changed
119    ///
120    /// The date (and optionally time) when the capability statement was published.
121    /// The date must change when the business version changes and it must change if
122    /// the status code changes. In addition, it should change when the substantive
123    /// content of the capability statement changes.
124    pub date: super::primitives::DateTime,
125    /// Name of the publisher (organization or individual)
126    ///
127    /// The name of the organization or individual that published the capability
128    /// statement.
129    pub publisher: Option<super::primitives::String>,
130    /// Contact details for the publisher
131    ///
132    /// Contact details to assist a user in finding and communicating with the
133    /// publisher.
134    pub contact: Vec<super::contact_detail::ContactDetail>,
135    /// Natural language description of the capability statement
136    ///
137    /// A free text natural language description of the capability statement from a
138    /// consumer's perspective. Typically, this is used when the capability
139    /// statement describes a desired rather than an actual solution, for example as
140    /// a formal expression of requirements as part of an RFP.
141    pub description: Option<super::primitives::Markdown>,
142    /// The context that the content is intended to support
143    ///
144    /// The content was developed with a focus and intent of supporting the contexts
145    /// that are listed. These contexts may be general categories (gender, age, ...)
146    /// or may be references to specific programs (insurance plans, studies, ...)
147    /// and may be used to assist with indexing and searching for appropriate
148    /// capability statement instances.
149    pub use_context: Vec<super::usage_context::UsageContext>,
150    /// Intended jurisdiction for capability statement (if applicable)
151    ///
152    /// A legal or geographic region in which the capability statement is intended
153    /// to be used.
154    pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
155    /// Why this capability statement is defined
156    ///
157    /// Explanation of why this capability statement is needed and why it has been
158    /// designed as it has.
159    pub purpose: Option<super::primitives::Markdown>,
160    /// Use and/or publishing restrictions
161    ///
162    /// A copyright statement relating to the capability statement and/or its
163    /// contents. Copyright statements are generally legal restrictions on the use
164    /// and publishing of the capability statement.
165    pub copyright: Option<super::primitives::Markdown>,
166    /// instance | capability | requirements
167    ///
168    /// The way that this statement is intended to be used, to describe an actual
169    /// running instance of software, a particular product (kind, not instance of
170    /// software) or a class of implementation (e.g. a desired purchase).
171    pub kind: super::primitives::Code,
172    /// Canonical URL of another capability statement this implements
173    ///
174    /// Reference to a canonical URL of another CapabilityStatement that this
175    /// software implements. This capability statement is a published API
176    /// description that corresponds to a business service. The server may actually
177    /// implement a subset of the capability statement it claims to implement, so
178    /// the capability statement must specify the full capability details.
179    pub instantiates: Vec<super::primitives::Canonical>,
180    /// Canonical URL of another capability statement this adds to
181    ///
182    /// Reference to a canonical URL of another CapabilityStatement that this
183    /// software adds to. The capability statement automatically includes everything
184    /// in the other statement, and it is not duplicated, though the server may
185    /// repeat the same resources, interactions and operations to add additional
186    /// details to them.
187    pub imports: Vec<super::primitives::Canonical>,
188    /// Software that is covered by this capability statement
189    ///
190    /// Software that is covered by this capability statement. It is used when the
191    /// capability statement describes the capabilities of a particular software
192    /// version, independent of an installation.
193    pub software: Option<CapabilityStatementSoftware>,
194    /// If this describes a specific instance
195    ///
196    /// Identifies a specific implementation instance that is described by the
197    /// capability statement - i.e. a particular installation, rather than the
198    /// capabilities of a software program.
199    pub implementation: Option<CapabilityStatementImplementation>,
200    /// FHIR Version the system supports
201    ///
202    /// The version of the FHIR specification that this CapabilityStatement
203    /// describes (which SHALL be the same as the FHIR version of the
204    /// CapabilityStatement itself). There is no default value.
205    pub fhir_version: super::primitives::Code,
206    /// formats supported (xml | json | ttl | mime type)
207    ///
208    /// A list of the formats supported by this implementation using their content
209    /// types.
210    pub format: Vec<super::primitives::Code>,
211    /// Patch formats supported
212    ///
213    /// A list of the patch formats supported by this implementation using their
214    /// content types.
215    pub patch_format: Vec<super::primitives::Code>,
216    /// Implementation guides supported
217    ///
218    /// A list of implementation guides that the server does (or should) support in
219    /// their entirety.
220    pub implementation_guide: Vec<super::primitives::Canonical>,
221    /// If the endpoint is a RESTful one
222    ///
223    /// A definition of the restful capabilities of the solution, if any.
224    pub rest: Vec<CapabilityStatementRest>,
225    /// If messaging is supported
226    ///
227    /// A description of the messaging capabilities of the solution.
228    pub messaging: Vec<CapabilityStatementMessaging>,
229    /// Document definition
230    ///
231    /// A document definition.
232    pub document: Vec<CapabilityStatementDocument>,
233}
234
235impl super::super::codec::Json for CapabilityStatement {
236    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
237        let mut object = super::super::codec::Object::new();
238        object.insert(
239            std::string::String::from("resourceType"),
240            super::super::codec::Value::String(std::string::String::from("CapabilityStatement")),
241        );
242        if let Some(v) = &self.id {
243            object.insert(
244                std::string::String::from("id"),
245                super::super::codec::Value::String(v.clone()),
246            );
247        }
248        if let Some(item) = &self.meta {
249            object.insert(
250                std::string::String::from("meta"),
251                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
252            );
253        }
254        if let Some(item) = &self.implicit_rules {
255            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
256                object.insert(std::string::String::from("implicitRules"), v);
257            }
258            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
259                object.insert(std::string::String::from("_implicitRules"), e);
260            }
261        }
262        if let Some(item) = &self.language {
263            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
264                object.insert(std::string::String::from("language"), v);
265            }
266            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
267                object.insert(std::string::String::from("_language"), e);
268            }
269        }
270        if let Some(item) = &self.text {
271            object.insert(
272                std::string::String::from("text"),
273                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
274            );
275        }
276        if !self.contained.is_empty() {
277            let mut items = Vec::with_capacity(self.contained.len());
278            for item in &self.contained {
279                items.push(super::super::codec::Value::Object(
280                    super::super::codec::Json::to_json(item)?,
281                ));
282            }
283            object.insert(
284                std::string::String::from("contained"),
285                super::super::codec::Value::Array(items),
286            );
287        }
288        if !self.extension.is_empty() {
289            let mut items = Vec::with_capacity(self.extension.len());
290            for item in &self.extension {
291                items.push(super::super::codec::Value::Object(
292                    super::super::codec::Json::to_json(item)?,
293                ));
294            }
295            object.insert(
296                std::string::String::from("extension"),
297                super::super::codec::Value::Array(items),
298            );
299        }
300        if !self.modifier_extension.is_empty() {
301            let mut items = Vec::with_capacity(self.modifier_extension.len());
302            for item in &self.modifier_extension {
303                items.push(super::super::codec::Value::Object(
304                    super::super::codec::Json::to_json(item)?,
305                ));
306            }
307            object.insert(
308                std::string::String::from("modifierExtension"),
309                super::super::codec::Value::Array(items),
310            );
311        }
312        if let Some(item) = &self.url {
313            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
314                object.insert(std::string::String::from("url"), v);
315            }
316            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
317                object.insert(std::string::String::from("_url"), e);
318            }
319        }
320        if let Some(item) = &self.version {
321            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
322                object.insert(std::string::String::from("version"), v);
323            }
324            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
325                object.insert(std::string::String::from("_version"), e);
326            }
327        }
328        if let Some(item) = &self.name {
329            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
330                object.insert(std::string::String::from("name"), v);
331            }
332            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
333                object.insert(std::string::String::from("_name"), e);
334            }
335        }
336        if let Some(item) = &self.title {
337            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
338                object.insert(std::string::String::from("title"), v);
339            }
340            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
341                object.insert(std::string::String::from("_title"), e);
342            }
343        }
344        if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
345            object.insert(std::string::String::from("status"), v);
346        }
347        if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
348            object.insert(std::string::String::from("_status"), e);
349        }
350        if let Some(item) = &self.experimental {
351            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
352                object.insert(std::string::String::from("experimental"), v);
353            }
354            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
355                object.insert(std::string::String::from("_experimental"), e);
356            }
357        }
358        if let Some(v) = super::super::codec::Primitive::value_json(&self.date)? {
359            object.insert(std::string::String::from("date"), v);
360        }
361        if let Some(e) = super::super::codec::Primitive::element_json(&self.date)? {
362            object.insert(std::string::String::from("_date"), e);
363        }
364        if let Some(item) = &self.publisher {
365            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
366                object.insert(std::string::String::from("publisher"), v);
367            }
368            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
369                object.insert(std::string::String::from("_publisher"), e);
370            }
371        }
372        if !self.contact.is_empty() {
373            let mut items = Vec::with_capacity(self.contact.len());
374            for item in &self.contact {
375                items.push(super::super::codec::Value::Object(
376                    super::super::codec::Json::to_json(item)?,
377                ));
378            }
379            object.insert(
380                std::string::String::from("contact"),
381                super::super::codec::Value::Array(items),
382            );
383        }
384        if let Some(item) = &self.description {
385            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
386                object.insert(std::string::String::from("description"), v);
387            }
388            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
389                object.insert(std::string::String::from("_description"), e);
390            }
391        }
392        if !self.use_context.is_empty() {
393            let mut items = Vec::with_capacity(self.use_context.len());
394            for item in &self.use_context {
395                items.push(super::super::codec::Value::Object(
396                    super::super::codec::Json::to_json(item)?,
397                ));
398            }
399            object.insert(
400                std::string::String::from("useContext"),
401                super::super::codec::Value::Array(items),
402            );
403        }
404        if !self.jurisdiction.is_empty() {
405            let mut items = Vec::with_capacity(self.jurisdiction.len());
406            for item in &self.jurisdiction {
407                items.push(super::super::codec::Value::Object(
408                    super::super::codec::Json::to_json(item)?,
409                ));
410            }
411            object.insert(
412                std::string::String::from("jurisdiction"),
413                super::super::codec::Value::Array(items),
414            );
415        }
416        if let Some(item) = &self.purpose {
417            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
418                object.insert(std::string::String::from("purpose"), v);
419            }
420            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
421                object.insert(std::string::String::from("_purpose"), e);
422            }
423        }
424        if let Some(item) = &self.copyright {
425            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
426                object.insert(std::string::String::from("copyright"), v);
427            }
428            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
429                object.insert(std::string::String::from("_copyright"), e);
430            }
431        }
432        if let Some(v) = super::super::codec::Primitive::value_json(&self.kind)? {
433            object.insert(std::string::String::from("kind"), v);
434        }
435        if let Some(e) = super::super::codec::Primitive::element_json(&self.kind)? {
436            object.insert(std::string::String::from("_kind"), e);
437        }
438        if !self.instantiates.is_empty() {
439            let (values, elements) = super::super::codec::primitive_arrays(&self.instantiates)?;
440            if let Some(values) = values {
441                object.insert(std::string::String::from("instantiates"), values);
442            }
443            if let Some(elements) = elements {
444                object.insert(std::string::String::from("_instantiates"), elements);
445            }
446        }
447        if !self.imports.is_empty() {
448            let (values, elements) = super::super::codec::primitive_arrays(&self.imports)?;
449            if let Some(values) = values {
450                object.insert(std::string::String::from("imports"), values);
451            }
452            if let Some(elements) = elements {
453                object.insert(std::string::String::from("_imports"), elements);
454            }
455        }
456        if let Some(item) = &self.software {
457            object.insert(
458                std::string::String::from("software"),
459                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
460            );
461        }
462        if let Some(item) = &self.implementation {
463            object.insert(
464                std::string::String::from("implementation"),
465                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
466            );
467        }
468        if let Some(v) = super::super::codec::Primitive::value_json(&self.fhir_version)? {
469            object.insert(std::string::String::from("fhirVersion"), v);
470        }
471        if let Some(e) = super::super::codec::Primitive::element_json(&self.fhir_version)? {
472            object.insert(std::string::String::from("_fhirVersion"), e);
473        }
474        if !self.format.is_empty() {
475            let (values, elements) = super::super::codec::primitive_arrays(&self.format)?;
476            if let Some(values) = values {
477                object.insert(std::string::String::from("format"), values);
478            }
479            if let Some(elements) = elements {
480                object.insert(std::string::String::from("_format"), elements);
481            }
482        }
483        if !self.patch_format.is_empty() {
484            let (values, elements) = super::super::codec::primitive_arrays(&self.patch_format)?;
485            if let Some(values) = values {
486                object.insert(std::string::String::from("patchFormat"), values);
487            }
488            if let Some(elements) = elements {
489                object.insert(std::string::String::from("_patchFormat"), elements);
490            }
491        }
492        if !self.implementation_guide.is_empty() {
493            let (values, elements) =
494                super::super::codec::primitive_arrays(&self.implementation_guide)?;
495            if let Some(values) = values {
496                object.insert(std::string::String::from("implementationGuide"), values);
497            }
498            if let Some(elements) = elements {
499                object.insert(std::string::String::from("_implementationGuide"), elements);
500            }
501        }
502        if !self.rest.is_empty() {
503            let mut items = Vec::with_capacity(self.rest.len());
504            for item in &self.rest {
505                items.push(super::super::codec::Value::Object(
506                    super::super::codec::Json::to_json(item)?,
507                ));
508            }
509            object.insert(
510                std::string::String::from("rest"),
511                super::super::codec::Value::Array(items),
512            );
513        }
514        if !self.messaging.is_empty() {
515            let mut items = Vec::with_capacity(self.messaging.len());
516            for item in &self.messaging {
517                items.push(super::super::codec::Value::Object(
518                    super::super::codec::Json::to_json(item)?,
519                ));
520            }
521            object.insert(
522                std::string::String::from("messaging"),
523                super::super::codec::Value::Array(items),
524            );
525        }
526        if !self.document.is_empty() {
527            let mut items = Vec::with_capacity(self.document.len());
528            for item in &self.document {
529                items.push(super::super::codec::Value::Object(
530                    super::super::codec::Json::to_json(item)?,
531                ));
532            }
533            object.insert(
534                std::string::String::from("document"),
535                super::super::codec::Value::Array(items),
536            );
537        }
538        Ok(object)
539    }
540
541    fn from_json(
542        object: &super::super::codec::Object,
543        path: &mut super::super::codec::Path,
544    ) -> Result<Self, super::super::codec::DecodeError> {
545        let mut raw_id: Option<&super::super::codec::Value> = None;
546        let mut raw_meta: Option<&super::super::codec::Value> = None;
547        let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
548        let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
549        let mut raw_language: Option<&super::super::codec::Value> = None;
550        let mut raw_language_element: Option<&super::super::codec::Value> = None;
551        let mut raw_text: Option<&super::super::codec::Value> = None;
552        let mut raw_contained: Option<&super::super::codec::Value> = None;
553        let mut raw_extension: Option<&super::super::codec::Value> = None;
554        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
555        let mut raw_url: Option<&super::super::codec::Value> = None;
556        let mut raw_url_element: Option<&super::super::codec::Value> = None;
557        let mut raw_version: Option<&super::super::codec::Value> = None;
558        let mut raw_version_element: Option<&super::super::codec::Value> = None;
559        let mut raw_name: Option<&super::super::codec::Value> = None;
560        let mut raw_name_element: Option<&super::super::codec::Value> = None;
561        let mut raw_title: Option<&super::super::codec::Value> = None;
562        let mut raw_title_element: Option<&super::super::codec::Value> = None;
563        let mut raw_status: Option<&super::super::codec::Value> = None;
564        let mut raw_status_element: Option<&super::super::codec::Value> = None;
565        let mut raw_experimental: Option<&super::super::codec::Value> = None;
566        let mut raw_experimental_element: Option<&super::super::codec::Value> = None;
567        let mut raw_date: Option<&super::super::codec::Value> = None;
568        let mut raw_date_element: Option<&super::super::codec::Value> = None;
569        let mut raw_publisher: Option<&super::super::codec::Value> = None;
570        let mut raw_publisher_element: Option<&super::super::codec::Value> = None;
571        let mut raw_contact: Option<&super::super::codec::Value> = None;
572        let mut raw_description: Option<&super::super::codec::Value> = None;
573        let mut raw_description_element: Option<&super::super::codec::Value> = None;
574        let mut raw_use_context: Option<&super::super::codec::Value> = None;
575        let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
576        let mut raw_purpose: Option<&super::super::codec::Value> = None;
577        let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
578        let mut raw_copyright: Option<&super::super::codec::Value> = None;
579        let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
580        let mut raw_kind: Option<&super::super::codec::Value> = None;
581        let mut raw_kind_element: Option<&super::super::codec::Value> = None;
582        let mut raw_instantiates: Option<&super::super::codec::Value> = None;
583        let mut raw_instantiates_element: Option<&super::super::codec::Value> = None;
584        let mut raw_imports: Option<&super::super::codec::Value> = None;
585        let mut raw_imports_element: Option<&super::super::codec::Value> = None;
586        let mut raw_software: Option<&super::super::codec::Value> = None;
587        let mut raw_implementation: Option<&super::super::codec::Value> = None;
588        let mut raw_fhir_version: Option<&super::super::codec::Value> = None;
589        let mut raw_fhir_version_element: Option<&super::super::codec::Value> = None;
590        let mut raw_format: Option<&super::super::codec::Value> = None;
591        let mut raw_format_element: Option<&super::super::codec::Value> = None;
592        let mut raw_patch_format: Option<&super::super::codec::Value> = None;
593        let mut raw_patch_format_element: Option<&super::super::codec::Value> = None;
594        let mut raw_implementation_guide: Option<&super::super::codec::Value> = None;
595        let mut raw_implementation_guide_element: Option<&super::super::codec::Value> = None;
596        let mut raw_rest: Option<&super::super::codec::Value> = None;
597        let mut raw_messaging: Option<&super::super::codec::Value> = None;
598        let mut raw_document: Option<&super::super::codec::Value> = None;
599        for (key, value) in object {
600            match key.as_str() {
601                "resourceType" => {
602                    if value.as_str() != Some("CapabilityStatement") {
603                        return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
604                    }
605                }
606                "id" => {
607                    raw_id = Some(value);
608                }
609                "meta" => {
610                    raw_meta = Some(value);
611                }
612                "implicitRules" => {
613                    raw_implicit_rules = Some(value);
614                }
615                "_implicitRules" => {
616                    raw_implicit_rules_element = Some(value);
617                }
618                "language" => {
619                    raw_language = Some(value);
620                }
621                "_language" => {
622                    raw_language_element = Some(value);
623                }
624                "text" => {
625                    raw_text = Some(value);
626                }
627                "contained" => {
628                    raw_contained = Some(value);
629                }
630                "extension" => {
631                    raw_extension = Some(value);
632                }
633                "modifierExtension" => {
634                    raw_modifier_extension = Some(value);
635                }
636                "url" => {
637                    raw_url = Some(value);
638                }
639                "_url" => {
640                    raw_url_element = Some(value);
641                }
642                "version" => {
643                    raw_version = Some(value);
644                }
645                "_version" => {
646                    raw_version_element = Some(value);
647                }
648                "name" => {
649                    raw_name = Some(value);
650                }
651                "_name" => {
652                    raw_name_element = Some(value);
653                }
654                "title" => {
655                    raw_title = Some(value);
656                }
657                "_title" => {
658                    raw_title_element = Some(value);
659                }
660                "status" => {
661                    raw_status = Some(value);
662                }
663                "_status" => {
664                    raw_status_element = Some(value);
665                }
666                "experimental" => {
667                    raw_experimental = Some(value);
668                }
669                "_experimental" => {
670                    raw_experimental_element = Some(value);
671                }
672                "date" => {
673                    raw_date = Some(value);
674                }
675                "_date" => {
676                    raw_date_element = Some(value);
677                }
678                "publisher" => {
679                    raw_publisher = Some(value);
680                }
681                "_publisher" => {
682                    raw_publisher_element = Some(value);
683                }
684                "contact" => {
685                    raw_contact = Some(value);
686                }
687                "description" => {
688                    raw_description = Some(value);
689                }
690                "_description" => {
691                    raw_description_element = Some(value);
692                }
693                "useContext" => {
694                    raw_use_context = Some(value);
695                }
696                "jurisdiction" => {
697                    raw_jurisdiction = Some(value);
698                }
699                "purpose" => {
700                    raw_purpose = Some(value);
701                }
702                "_purpose" => {
703                    raw_purpose_element = Some(value);
704                }
705                "copyright" => {
706                    raw_copyright = Some(value);
707                }
708                "_copyright" => {
709                    raw_copyright_element = Some(value);
710                }
711                "kind" => {
712                    raw_kind = Some(value);
713                }
714                "_kind" => {
715                    raw_kind_element = Some(value);
716                }
717                "instantiates" => {
718                    raw_instantiates = Some(value);
719                }
720                "_instantiates" => {
721                    raw_instantiates_element = Some(value);
722                }
723                "imports" => {
724                    raw_imports = Some(value);
725                }
726                "_imports" => {
727                    raw_imports_element = Some(value);
728                }
729                "software" => {
730                    raw_software = Some(value);
731                }
732                "implementation" => {
733                    raw_implementation = Some(value);
734                }
735                "fhirVersion" => {
736                    raw_fhir_version = Some(value);
737                }
738                "_fhirVersion" => {
739                    raw_fhir_version_element = Some(value);
740                }
741                "format" => {
742                    raw_format = Some(value);
743                }
744                "_format" => {
745                    raw_format_element = Some(value);
746                }
747                "patchFormat" => {
748                    raw_patch_format = Some(value);
749                }
750                "_patchFormat" => {
751                    raw_patch_format_element = Some(value);
752                }
753                "implementationGuide" => {
754                    raw_implementation_guide = Some(value);
755                }
756                "_implementationGuide" => {
757                    raw_implementation_guide_element = Some(value);
758                }
759                "rest" => {
760                    raw_rest = Some(value);
761                }
762                "messaging" => {
763                    raw_messaging = Some(value);
764                }
765                "document" => {
766                    raw_document = Some(value);
767                }
768                other => {
769                    return path.with(other, |path| {
770                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
771                    });
772                }
773            }
774        }
775        let field_id = raw_id
776            .map(|value| {
777                path.with("id", |path| {
778                    let value = super::super::codec::expect_single(value, path)?;
779                    super::primitives::checked_id(
780                        super::super::codec::expect_string(value, path)?,
781                        path,
782                    )
783                })
784            })
785            .transpose()?;
786        let field_meta = raw_meta
787            .map(|value| {
788                path.with("meta", |path| {
789                    super::super::codec::Json::from_json(
790                        super::super::codec::expect_object(
791                            super::super::codec::expect_single(value, path)?,
792                            path,
793                        )?,
794                        path,
795                    )
796                })
797            })
798            .transpose()?;
799        let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
800            (None, None) => None,
801            (value, element) => Some(path.with("implicitRules", |path| {
802                super::super::codec::Primitive::from_json_parts(value, element, path)
803            })?),
804        };
805        let field_language = match (raw_language, raw_language_element) {
806            (None, None) => None,
807            (value, element) => Some(path.with("language", |path| {
808                super::super::codec::Primitive::from_json_parts(value, element, path)
809            })?),
810        };
811        let field_text = raw_text
812            .map(|value| {
813                path.with("text", |path| {
814                    super::super::codec::Json::from_json(
815                        super::super::codec::expect_object(
816                            super::super::codec::expect_single(value, path)?,
817                            path,
818                        )?,
819                        path,
820                    )
821                })
822            })
823            .transpose()?;
824        let mut field_contained = Vec::new();
825        if let Some(raw) = raw_contained {
826            for (index, value) in path
827                .with("contained", |path| {
828                    super::super::codec::expect_array(raw, path)
829                })?
830                .iter()
831                .enumerate()
832            {
833                field_contained.push(path.with_index("contained", index, |path| {
834                    super::super::codec::Json::from_json(
835                        super::super::codec::expect_object(value, path)?,
836                        path,
837                    )
838                })?);
839            }
840        }
841        let mut field_extension = Vec::new();
842        if let Some(raw) = raw_extension {
843            for (index, value) in path
844                .with("extension", |path| {
845                    super::super::codec::expect_array(raw, path)
846                })?
847                .iter()
848                .enumerate()
849            {
850                field_extension.push(path.with_index("extension", index, |path| {
851                    super::super::codec::Json::from_json(
852                        super::super::codec::expect_object(value, path)?,
853                        path,
854                    )
855                })?);
856            }
857        }
858        let mut field_modifier_extension = Vec::new();
859        if let Some(raw) = raw_modifier_extension {
860            for (index, value) in path
861                .with("modifierExtension", |path| {
862                    super::super::codec::expect_array(raw, path)
863                })?
864                .iter()
865                .enumerate()
866            {
867                field_modifier_extension.push(path.with_index(
868                    "modifierExtension",
869                    index,
870                    |path| {
871                        super::super::codec::Json::from_json(
872                            super::super::codec::expect_object(value, path)?,
873                            path,
874                        )
875                    },
876                )?);
877            }
878        }
879        let field_url = match (raw_url, raw_url_element) {
880            (None, None) => None,
881            (value, element) => Some(path.with("url", |path| {
882                super::super::codec::Primitive::from_json_parts(value, element, path)
883            })?),
884        };
885        let field_version = match (raw_version, raw_version_element) {
886            (None, None) => None,
887            (value, element) => Some(path.with("version", |path| {
888                super::super::codec::Primitive::from_json_parts(value, element, path)
889            })?),
890        };
891        let field_name = match (raw_name, raw_name_element) {
892            (None, None) => None,
893            (value, element) => Some(path.with("name", |path| {
894                super::super::codec::Primitive::from_json_parts(value, element, path)
895            })?),
896        };
897        let field_title = match (raw_title, raw_title_element) {
898            (None, None) => None,
899            (value, element) => Some(path.with("title", |path| {
900                super::super::codec::Primitive::from_json_parts(value, element, path)
901            })?),
902        };
903        let field_status = path.with("status", |path| {
904            super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
905        })?;
906        let field_experimental = match (raw_experimental, raw_experimental_element) {
907            (None, None) => None,
908            (value, element) => Some(path.with("experimental", |path| {
909                super::super::codec::Primitive::from_json_parts(value, element, path)
910            })?),
911        };
912        let field_date = path.with("date", |path| {
913            super::super::codec::Primitive::from_json_parts(raw_date, raw_date_element, path)
914        })?;
915        let field_publisher = match (raw_publisher, raw_publisher_element) {
916            (None, None) => None,
917            (value, element) => Some(path.with("publisher", |path| {
918                super::super::codec::Primitive::from_json_parts(value, element, path)
919            })?),
920        };
921        let mut field_contact = Vec::new();
922        if let Some(raw) = raw_contact {
923            for (index, value) in path
924                .with("contact", |path| {
925                    super::super::codec::expect_array(raw, path)
926                })?
927                .iter()
928                .enumerate()
929            {
930                field_contact.push(path.with_index("contact", index, |path| {
931                    super::super::codec::Json::from_json(
932                        super::super::codec::expect_object(value, path)?,
933                        path,
934                    )
935                })?);
936            }
937        }
938        let field_description = match (raw_description, raw_description_element) {
939            (None, None) => None,
940            (value, element) => Some(path.with("description", |path| {
941                super::super::codec::Primitive::from_json_parts(value, element, path)
942            })?),
943        };
944        let mut field_use_context = Vec::new();
945        if let Some(raw) = raw_use_context {
946            for (index, value) in path
947                .with("useContext", |path| {
948                    super::super::codec::expect_array(raw, path)
949                })?
950                .iter()
951                .enumerate()
952            {
953                field_use_context.push(path.with_index("useContext", index, |path| {
954                    super::super::codec::Json::from_json(
955                        super::super::codec::expect_object(value, path)?,
956                        path,
957                    )
958                })?);
959            }
960        }
961        let mut field_jurisdiction = Vec::new();
962        if let Some(raw) = raw_jurisdiction {
963            for (index, value) in path
964                .with("jurisdiction", |path| {
965                    super::super::codec::expect_array(raw, path)
966                })?
967                .iter()
968                .enumerate()
969            {
970                field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
971                    super::super::codec::Json::from_json(
972                        super::super::codec::expect_object(value, path)?,
973                        path,
974                    )
975                })?);
976            }
977        }
978        let field_purpose = match (raw_purpose, raw_purpose_element) {
979            (None, None) => None,
980            (value, element) => Some(path.with("purpose", |path| {
981                super::super::codec::Primitive::from_json_parts(value, element, path)
982            })?),
983        };
984        let field_copyright = match (raw_copyright, raw_copyright_element) {
985            (None, None) => None,
986            (value, element) => Some(path.with("copyright", |path| {
987                super::super::codec::Primitive::from_json_parts(value, element, path)
988            })?),
989        };
990        let field_kind = path.with("kind", |path| {
991            super::super::codec::Primitive::from_json_parts(raw_kind, raw_kind_element, path)
992        })?;
993        let mut field_instantiates = Vec::new();
994        for (index, (value, element)) in path
995            .with("instantiates", |path| {
996                super::super::codec::pair_arrays(raw_instantiates, raw_instantiates_element, path)
997            })?
998            .into_iter()
999            .enumerate()
1000        {
1001            field_instantiates.push(path.with_index("instantiates", index, |path| {
1002                super::super::codec::Primitive::from_json_parts(value, element, path)
1003            })?);
1004        }
1005        let mut field_imports = Vec::new();
1006        for (index, (value, element)) in path
1007            .with("imports", |path| {
1008                super::super::codec::pair_arrays(raw_imports, raw_imports_element, path)
1009            })?
1010            .into_iter()
1011            .enumerate()
1012        {
1013            field_imports.push(path.with_index("imports", index, |path| {
1014                super::super::codec::Primitive::from_json_parts(value, element, path)
1015            })?);
1016        }
1017        let field_software = raw_software
1018            .map(|value| {
1019                path.with("software", |path| {
1020                    super::super::codec::Json::from_json(
1021                        super::super::codec::expect_object(
1022                            super::super::codec::expect_single(value, path)?,
1023                            path,
1024                        )?,
1025                        path,
1026                    )
1027                })
1028            })
1029            .transpose()?;
1030        let field_implementation = raw_implementation
1031            .map(|value| {
1032                path.with("implementation", |path| {
1033                    super::super::codec::Json::from_json(
1034                        super::super::codec::expect_object(
1035                            super::super::codec::expect_single(value, path)?,
1036                            path,
1037                        )?,
1038                        path,
1039                    )
1040                })
1041            })
1042            .transpose()?;
1043        let field_fhir_version = path.with("fhirVersion", |path| {
1044            super::super::codec::Primitive::from_json_parts(
1045                raw_fhir_version,
1046                raw_fhir_version_element,
1047                path,
1048            )
1049        })?;
1050        let mut field_format = Vec::new();
1051        for (index, (value, element)) in path
1052            .with("format", |path| {
1053                super::super::codec::pair_arrays(raw_format, raw_format_element, path)
1054            })?
1055            .into_iter()
1056            .enumerate()
1057        {
1058            field_format.push(path.with_index("format", index, |path| {
1059                super::super::codec::Primitive::from_json_parts(value, element, path)
1060            })?);
1061        }
1062        if field_format.is_empty() && !path.is_lenient() {
1063            return path.with("format", |path| {
1064                Err(path.error(super::super::codec::DecodeErrorKind::MissingProperty))
1065            });
1066        }
1067        let mut field_patch_format = Vec::new();
1068        for (index, (value, element)) in path
1069            .with("patchFormat", |path| {
1070                super::super::codec::pair_arrays(raw_patch_format, raw_patch_format_element, path)
1071            })?
1072            .into_iter()
1073            .enumerate()
1074        {
1075            field_patch_format.push(path.with_index("patchFormat", index, |path| {
1076                super::super::codec::Primitive::from_json_parts(value, element, path)
1077            })?);
1078        }
1079        let mut field_implementation_guide = Vec::new();
1080        for (index, (value, element)) in path
1081            .with("implementationGuide", |path| {
1082                super::super::codec::pair_arrays(
1083                    raw_implementation_guide,
1084                    raw_implementation_guide_element,
1085                    path,
1086                )
1087            })?
1088            .into_iter()
1089            .enumerate()
1090        {
1091            field_implementation_guide.push(path.with_index(
1092                "implementationGuide",
1093                index,
1094                |path| super::super::codec::Primitive::from_json_parts(value, element, path),
1095            )?);
1096        }
1097        let mut field_rest = Vec::new();
1098        if let Some(raw) = raw_rest {
1099            for (index, value) in path
1100                .with("rest", |path| super::super::codec::expect_array(raw, path))?
1101                .iter()
1102                .enumerate()
1103            {
1104                field_rest.push(path.with_index("rest", index, |path| {
1105                    super::super::codec::Json::from_json(
1106                        super::super::codec::expect_object(value, path)?,
1107                        path,
1108                    )
1109                })?);
1110            }
1111        }
1112        let mut field_messaging = Vec::new();
1113        if let Some(raw) = raw_messaging {
1114            for (index, value) in path
1115                .with("messaging", |path| {
1116                    super::super::codec::expect_array(raw, path)
1117                })?
1118                .iter()
1119                .enumerate()
1120            {
1121                field_messaging.push(path.with_index("messaging", index, |path| {
1122                    super::super::codec::Json::from_json(
1123                        super::super::codec::expect_object(value, path)?,
1124                        path,
1125                    )
1126                })?);
1127            }
1128        }
1129        let mut field_document = Vec::new();
1130        if let Some(raw) = raw_document {
1131            for (index, value) in path
1132                .with("document", |path| {
1133                    super::super::codec::expect_array(raw, path)
1134                })?
1135                .iter()
1136                .enumerate()
1137            {
1138                field_document.push(path.with_index("document", index, |path| {
1139                    super::super::codec::Json::from_json(
1140                        super::super::codec::expect_object(value, path)?,
1141                        path,
1142                    )
1143                })?);
1144            }
1145        }
1146        Ok(Self {
1147            id: field_id,
1148            meta: field_meta,
1149            implicit_rules: field_implicit_rules,
1150            language: field_language,
1151            text: field_text,
1152            contained: field_contained,
1153            extension: field_extension,
1154            modifier_extension: field_modifier_extension,
1155            url: field_url,
1156            version: field_version,
1157            name: field_name,
1158            title: field_title,
1159            status: field_status,
1160            experimental: field_experimental,
1161            date: field_date,
1162            publisher: field_publisher,
1163            contact: field_contact,
1164            description: field_description,
1165            use_context: field_use_context,
1166            jurisdiction: field_jurisdiction,
1167            purpose: field_purpose,
1168            copyright: field_copyright,
1169            kind: field_kind,
1170            instantiates: field_instantiates,
1171            imports: field_imports,
1172            software: field_software,
1173            implementation: field_implementation,
1174            fhir_version: field_fhir_version,
1175            format: field_format,
1176            patch_format: field_patch_format,
1177            implementation_guide: field_implementation_guide,
1178            rest: field_rest,
1179            messaging: field_messaging,
1180            document: field_document,
1181        })
1182    }
1183}
1184
1185impl serde::Serialize for CapabilityStatement {
1186    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1187        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1188        if let Some(item) = &self.copyright {
1189            super::super::codec::element_entry(&mut map, "_copyright", item)?;
1190        }
1191        super::super::codec::element_entry(&mut map, "_date", &self.date)?;
1192        if let Some(item) = &self.description {
1193            super::super::codec::element_entry(&mut map, "_description", item)?;
1194        }
1195        if let Some(item) = &self.experimental {
1196            super::super::codec::element_entry(&mut map, "_experimental", item)?;
1197        }
1198        super::super::codec::element_entry(&mut map, "_fhirVersion", &self.fhir_version)?;
1199        super::super::codec::element_list_entry(&mut map, "_format", &self.format)?;
1200        super::super::codec::element_list_entry(
1201            &mut map,
1202            "_implementationGuide",
1203            &self.implementation_guide,
1204        )?;
1205        if let Some(item) = &self.implicit_rules {
1206            super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
1207        }
1208        super::super::codec::element_list_entry(&mut map, "_imports", &self.imports)?;
1209        super::super::codec::element_list_entry(&mut map, "_instantiates", &self.instantiates)?;
1210        super::super::codec::element_entry(&mut map, "_kind", &self.kind)?;
1211        if let Some(item) = &self.language {
1212            super::super::codec::element_entry(&mut map, "_language", item)?;
1213        }
1214        if let Some(item) = &self.name {
1215            super::super::codec::element_entry(&mut map, "_name", item)?;
1216        }
1217        super::super::codec::element_list_entry(&mut map, "_patchFormat", &self.patch_format)?;
1218        if let Some(item) = &self.publisher {
1219            super::super::codec::element_entry(&mut map, "_publisher", item)?;
1220        }
1221        if let Some(item) = &self.purpose {
1222            super::super::codec::element_entry(&mut map, "_purpose", item)?;
1223        }
1224        super::super::codec::element_entry(&mut map, "_status", &self.status)?;
1225        if let Some(item) = &self.title {
1226            super::super::codec::element_entry(&mut map, "_title", item)?;
1227        }
1228        if let Some(item) = &self.url {
1229            super::super::codec::element_entry(&mut map, "_url", item)?;
1230        }
1231        if let Some(item) = &self.version {
1232            super::super::codec::element_entry(&mut map, "_version", item)?;
1233        }
1234        if !self.contact.is_empty() {
1235            serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
1236        }
1237        if !self.contained.is_empty() {
1238            serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
1239        }
1240        if let Some(item) = &self.copyright {
1241            super::super::codec::value_entry(&mut map, "copyright", item)?;
1242        }
1243        super::super::codec::value_entry(&mut map, "date", &self.date)?;
1244        if let Some(item) = &self.description {
1245            super::super::codec::value_entry(&mut map, "description", item)?;
1246        }
1247        if !self.document.is_empty() {
1248            serde::ser::SerializeMap::serialize_entry(&mut map, "document", &self.document)?;
1249        }
1250        if let Some(item) = &self.experimental {
1251            super::super::codec::value_entry(&mut map, "experimental", item)?;
1252        }
1253        if !self.extension.is_empty() {
1254            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1255        }
1256        super::super::codec::value_entry(&mut map, "fhirVersion", &self.fhir_version)?;
1257        super::super::codec::value_list_entry(&mut map, "format", &self.format)?;
1258        if let Some(v) = &self.id {
1259            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1260        }
1261        if let Some(item) = &self.implementation {
1262            serde::ser::SerializeMap::serialize_entry(&mut map, "implementation", item)?;
1263        }
1264        super::super::codec::value_list_entry(
1265            &mut map,
1266            "implementationGuide",
1267            &self.implementation_guide,
1268        )?;
1269        if let Some(item) = &self.implicit_rules {
1270            super::super::codec::value_entry(&mut map, "implicitRules", item)?;
1271        }
1272        super::super::codec::value_list_entry(&mut map, "imports", &self.imports)?;
1273        super::super::codec::value_list_entry(&mut map, "instantiates", &self.instantiates)?;
1274        if !self.jurisdiction.is_empty() {
1275            serde::ser::SerializeMap::serialize_entry(
1276                &mut map,
1277                "jurisdiction",
1278                &self.jurisdiction,
1279            )?;
1280        }
1281        super::super::codec::value_entry(&mut map, "kind", &self.kind)?;
1282        if let Some(item) = &self.language {
1283            super::super::codec::value_entry(&mut map, "language", item)?;
1284        }
1285        if !self.messaging.is_empty() {
1286            serde::ser::SerializeMap::serialize_entry(&mut map, "messaging", &self.messaging)?;
1287        }
1288        if let Some(item) = &self.meta {
1289            serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
1290        }
1291        if !self.modifier_extension.is_empty() {
1292            serde::ser::SerializeMap::serialize_entry(
1293                &mut map,
1294                "modifierExtension",
1295                &self.modifier_extension,
1296            )?;
1297        }
1298        if let Some(item) = &self.name {
1299            super::super::codec::value_entry(&mut map, "name", item)?;
1300        }
1301        super::super::codec::value_list_entry(&mut map, "patchFormat", &self.patch_format)?;
1302        if let Some(item) = &self.publisher {
1303            super::super::codec::value_entry(&mut map, "publisher", item)?;
1304        }
1305        if let Some(item) = &self.purpose {
1306            super::super::codec::value_entry(&mut map, "purpose", item)?;
1307        }
1308        serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "CapabilityStatement")?;
1309        if !self.rest.is_empty() {
1310            serde::ser::SerializeMap::serialize_entry(&mut map, "rest", &self.rest)?;
1311        }
1312        if let Some(item) = &self.software {
1313            serde::ser::SerializeMap::serialize_entry(&mut map, "software", item)?;
1314        }
1315        super::super::codec::value_entry(&mut map, "status", &self.status)?;
1316        if let Some(item) = &self.text {
1317            serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
1318        }
1319        if let Some(item) = &self.title {
1320            super::super::codec::value_entry(&mut map, "title", item)?;
1321        }
1322        if let Some(item) = &self.url {
1323            super::super::codec::value_entry(&mut map, "url", item)?;
1324        }
1325        if !self.use_context.is_empty() {
1326            serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
1327        }
1328        if let Some(item) = &self.version {
1329            super::super::codec::value_entry(&mut map, "version", item)?;
1330        }
1331        serde::ser::SerializeMap::end(map)
1332    }
1333}
1334
1335impl<'de> serde::Deserialize<'de> for CapabilityStatement {
1336    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1337        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1338        let mut path = super::super::codec::Path::root("CapabilityStatement");
1339        let object =
1340            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1341        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1342    }
1343}
1344
1345/// Document definition
1346///
1347/// A document definition.
1348#[derive(Debug, Clone, Default, PartialEq, Eq)]
1349pub struct CapabilityStatementDocument {
1350    /// Unique id for inter-element referencing
1351    ///
1352    /// Unique id for the element within a resource (for internal references). This
1353    /// may be any string value that does not contain spaces.
1354    pub id: Option<std::string::String>,
1355    /// Additional content defined by implementations
1356    ///
1357    /// May be used to represent additional information that is not part of the
1358    /// basic definition of the element. To make the use of extensions safe and
1359    /// manageable, there is a strict set of governance applied to the definition
1360    /// and use of extensions. Though any implementer can define an extension, there
1361    /// is a set of requirements that SHALL be met as part of the definition of the
1362    /// extension.
1363    pub extension: Vec<super::extension::Extension>,
1364    /// Extensions that cannot be ignored even if unrecognized
1365    ///
1366    /// May be used to represent additional information that is not part of the
1367    /// basic definition of the element and that modifies the understanding of the
1368    /// element in which it is contained and/or the understanding of the containing
1369    /// element's descendants. Usually modifier elements provide negation or
1370    /// qualification. To make the use of extensions safe and manageable, there is a
1371    /// strict set of governance applied to the definition and use of extensions.
1372    /// Though any implementer can define an extension, there is a set of
1373    /// requirements that SHALL be met as part of the definition of the extension.
1374    /// Applications processing a resource are required to check for modifier
1375    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1376    /// on Resource or DomainResource (including cannot change the meaning of
1377    /// modifierExtension itself).
1378    pub modifier_extension: Vec<super::extension::Extension>,
1379    /// producer | consumer
1380    ///
1381    /// Mode of this document declaration - whether an application is a producer or
1382    /// consumer.
1383    pub mode: super::primitives::Code,
1384    /// Description of document support
1385    ///
1386    /// A description of how the application supports or uses the specified document
1387    /// profile. For example, when documents are created, what action is taken with
1388    /// consumed documents, etc.
1389    pub documentation: Option<super::primitives::Markdown>,
1390    /// Constraint on the resources used in the document
1391    ///
1392    /// A profile on the document Bundle that constrains which resources are
1393    /// present, and their contents.
1394    pub profile: super::primitives::Canonical,
1395}
1396
1397impl super::super::codec::Json for CapabilityStatementDocument {
1398    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1399        let mut object = super::super::codec::Object::new();
1400        if let Some(v) = &self.id {
1401            object.insert(
1402                std::string::String::from("id"),
1403                super::super::codec::Value::String(v.clone()),
1404            );
1405        }
1406        if !self.extension.is_empty() {
1407            let mut items = Vec::with_capacity(self.extension.len());
1408            for item in &self.extension {
1409                items.push(super::super::codec::Value::Object(
1410                    super::super::codec::Json::to_json(item)?,
1411                ));
1412            }
1413            object.insert(
1414                std::string::String::from("extension"),
1415                super::super::codec::Value::Array(items),
1416            );
1417        }
1418        if !self.modifier_extension.is_empty() {
1419            let mut items = Vec::with_capacity(self.modifier_extension.len());
1420            for item in &self.modifier_extension {
1421                items.push(super::super::codec::Value::Object(
1422                    super::super::codec::Json::to_json(item)?,
1423                ));
1424            }
1425            object.insert(
1426                std::string::String::from("modifierExtension"),
1427                super::super::codec::Value::Array(items),
1428            );
1429        }
1430        if let Some(v) = super::super::codec::Primitive::value_json(&self.mode)? {
1431            object.insert(std::string::String::from("mode"), v);
1432        }
1433        if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
1434            object.insert(std::string::String::from("_mode"), e);
1435        }
1436        if let Some(item) = &self.documentation {
1437            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1438                object.insert(std::string::String::from("documentation"), v);
1439            }
1440            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1441                object.insert(std::string::String::from("_documentation"), e);
1442            }
1443        }
1444        if let Some(v) = super::super::codec::Primitive::value_json(&self.profile)? {
1445            object.insert(std::string::String::from("profile"), v);
1446        }
1447        if let Some(e) = super::super::codec::Primitive::element_json(&self.profile)? {
1448            object.insert(std::string::String::from("_profile"), e);
1449        }
1450        Ok(object)
1451    }
1452
1453    fn from_json(
1454        object: &super::super::codec::Object,
1455        path: &mut super::super::codec::Path,
1456    ) -> Result<Self, super::super::codec::DecodeError> {
1457        let mut raw_id: Option<&super::super::codec::Value> = None;
1458        let mut raw_extension: Option<&super::super::codec::Value> = None;
1459        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1460        let mut raw_mode: Option<&super::super::codec::Value> = None;
1461        let mut raw_mode_element: Option<&super::super::codec::Value> = None;
1462        let mut raw_documentation: Option<&super::super::codec::Value> = None;
1463        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
1464        let mut raw_profile: Option<&super::super::codec::Value> = None;
1465        let mut raw_profile_element: Option<&super::super::codec::Value> = None;
1466        for (key, value) in object {
1467            match key.as_str() {
1468                "id" => {
1469                    raw_id = Some(value);
1470                }
1471                "extension" => {
1472                    raw_extension = Some(value);
1473                }
1474                "modifierExtension" => {
1475                    raw_modifier_extension = Some(value);
1476                }
1477                "mode" => {
1478                    raw_mode = Some(value);
1479                }
1480                "_mode" => {
1481                    raw_mode_element = Some(value);
1482                }
1483                "documentation" => {
1484                    raw_documentation = Some(value);
1485                }
1486                "_documentation" => {
1487                    raw_documentation_element = Some(value);
1488                }
1489                "profile" => {
1490                    raw_profile = Some(value);
1491                }
1492                "_profile" => {
1493                    raw_profile_element = Some(value);
1494                }
1495                other => {
1496                    return path.with(other, |path| {
1497                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1498                    });
1499                }
1500            }
1501        }
1502        let field_id = raw_id
1503            .map(|value| {
1504                path.with("id", |path| {
1505                    let value = super::super::codec::expect_single(value, path)?;
1506                    super::primitives::checked_string(
1507                        super::super::codec::expect_string(value, path)?,
1508                        path,
1509                    )
1510                })
1511            })
1512            .transpose()?;
1513        let mut field_extension = Vec::new();
1514        if let Some(raw) = raw_extension {
1515            for (index, value) in path
1516                .with("extension", |path| {
1517                    super::super::codec::expect_array(raw, path)
1518                })?
1519                .iter()
1520                .enumerate()
1521            {
1522                field_extension.push(path.with_index("extension", index, |path| {
1523                    super::super::codec::Json::from_json(
1524                        super::super::codec::expect_object(value, path)?,
1525                        path,
1526                    )
1527                })?);
1528            }
1529        }
1530        let mut field_modifier_extension = Vec::new();
1531        if let Some(raw) = raw_modifier_extension {
1532            for (index, value) in path
1533                .with("modifierExtension", |path| {
1534                    super::super::codec::expect_array(raw, path)
1535                })?
1536                .iter()
1537                .enumerate()
1538            {
1539                field_modifier_extension.push(path.with_index(
1540                    "modifierExtension",
1541                    index,
1542                    |path| {
1543                        super::super::codec::Json::from_json(
1544                            super::super::codec::expect_object(value, path)?,
1545                            path,
1546                        )
1547                    },
1548                )?);
1549            }
1550        }
1551        let field_mode = path.with("mode", |path| {
1552            super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
1553        })?;
1554        let field_documentation = match (raw_documentation, raw_documentation_element) {
1555            (None, None) => None,
1556            (value, element) => Some(path.with("documentation", |path| {
1557                super::super::codec::Primitive::from_json_parts(value, element, path)
1558            })?),
1559        };
1560        let field_profile = path.with("profile", |path| {
1561            super::super::codec::Primitive::from_json_parts(raw_profile, raw_profile_element, path)
1562        })?;
1563        Ok(Self {
1564            id: field_id,
1565            extension: field_extension,
1566            modifier_extension: field_modifier_extension,
1567            mode: field_mode,
1568            documentation: field_documentation,
1569            profile: field_profile,
1570        })
1571    }
1572}
1573
1574impl serde::Serialize for CapabilityStatementDocument {
1575    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1576        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1577        if let Some(item) = &self.documentation {
1578            super::super::codec::element_entry(&mut map, "_documentation", item)?;
1579        }
1580        super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
1581        super::super::codec::element_entry(&mut map, "_profile", &self.profile)?;
1582        if let Some(item) = &self.documentation {
1583            super::super::codec::value_entry(&mut map, "documentation", item)?;
1584        }
1585        if !self.extension.is_empty() {
1586            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1587        }
1588        if let Some(v) = &self.id {
1589            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1590        }
1591        super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
1592        if !self.modifier_extension.is_empty() {
1593            serde::ser::SerializeMap::serialize_entry(
1594                &mut map,
1595                "modifierExtension",
1596                &self.modifier_extension,
1597            )?;
1598        }
1599        super::super::codec::value_entry(&mut map, "profile", &self.profile)?;
1600        serde::ser::SerializeMap::end(map)
1601    }
1602}
1603
1604impl<'de> serde::Deserialize<'de> for CapabilityStatementDocument {
1605    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1606        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1607        let mut path = super::super::codec::Path::root("CapabilityStatementDocument");
1608        let object =
1609            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1610        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1611    }
1612}
1613
1614/// If this describes a specific instance
1615///
1616/// Identifies a specific implementation instance that is described by the
1617/// capability statement - i.e. a particular installation, rather than the
1618/// capabilities of a software program.
1619#[derive(Debug, Clone, Default, PartialEq, Eq)]
1620pub struct CapabilityStatementImplementation {
1621    /// Unique id for inter-element referencing
1622    ///
1623    /// Unique id for the element within a resource (for internal references). This
1624    /// may be any string value that does not contain spaces.
1625    pub id: Option<std::string::String>,
1626    /// Additional content defined by implementations
1627    ///
1628    /// May be used to represent additional information that is not part of the
1629    /// basic definition of the element. To make the use of extensions safe and
1630    /// manageable, there is a strict set of governance applied to the definition
1631    /// and use of extensions. Though any implementer can define an extension, there
1632    /// is a set of requirements that SHALL be met as part of the definition of the
1633    /// extension.
1634    pub extension: Vec<super::extension::Extension>,
1635    /// Extensions that cannot be ignored even if unrecognized
1636    ///
1637    /// May be used to represent additional information that is not part of the
1638    /// basic definition of the element and that modifies the understanding of the
1639    /// element in which it is contained and/or the understanding of the containing
1640    /// element's descendants. Usually modifier elements provide negation or
1641    /// qualification. To make the use of extensions safe and manageable, there is a
1642    /// strict set of governance applied to the definition and use of extensions.
1643    /// Though any implementer can define an extension, there is a set of
1644    /// requirements that SHALL be met as part of the definition of the extension.
1645    /// Applications processing a resource are required to check for modifier
1646    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1647    /// on Resource or DomainResource (including cannot change the meaning of
1648    /// modifierExtension itself).
1649    pub modifier_extension: Vec<super::extension::Extension>,
1650    /// Describes this specific instance
1651    ///
1652    /// Information about the specific installation that this capability statement
1653    /// relates to.
1654    pub description: super::primitives::String,
1655    /// Base URL for the installation
1656    ///
1657    /// An absolute base URL for the implementation. This forms the base for REST
1658    /// interfaces as well as the mailbox and document interfaces.
1659    pub url: Option<super::primitives::Url>,
1660    /// Organization that manages the data
1661    ///
1662    /// The organization responsible for the management of the instance and
1663    /// oversight of the data on the server at the specified URL.
1664    pub custodian: Option<super::reference::Reference>,
1665}
1666
1667impl super::super::codec::Json for CapabilityStatementImplementation {
1668    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1669        let mut object = super::super::codec::Object::new();
1670        if let Some(v) = &self.id {
1671            object.insert(
1672                std::string::String::from("id"),
1673                super::super::codec::Value::String(v.clone()),
1674            );
1675        }
1676        if !self.extension.is_empty() {
1677            let mut items = Vec::with_capacity(self.extension.len());
1678            for item in &self.extension {
1679                items.push(super::super::codec::Value::Object(
1680                    super::super::codec::Json::to_json(item)?,
1681                ));
1682            }
1683            object.insert(
1684                std::string::String::from("extension"),
1685                super::super::codec::Value::Array(items),
1686            );
1687        }
1688        if !self.modifier_extension.is_empty() {
1689            let mut items = Vec::with_capacity(self.modifier_extension.len());
1690            for item in &self.modifier_extension {
1691                items.push(super::super::codec::Value::Object(
1692                    super::super::codec::Json::to_json(item)?,
1693                ));
1694            }
1695            object.insert(
1696                std::string::String::from("modifierExtension"),
1697                super::super::codec::Value::Array(items),
1698            );
1699        }
1700        if let Some(v) = super::super::codec::Primitive::value_json(&self.description)? {
1701            object.insert(std::string::String::from("description"), v);
1702        }
1703        if let Some(e) = super::super::codec::Primitive::element_json(&self.description)? {
1704            object.insert(std::string::String::from("_description"), e);
1705        }
1706        if let Some(item) = &self.url {
1707            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1708                object.insert(std::string::String::from("url"), v);
1709            }
1710            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1711                object.insert(std::string::String::from("_url"), e);
1712            }
1713        }
1714        if let Some(item) = &self.custodian {
1715            object.insert(
1716                std::string::String::from("custodian"),
1717                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
1718            );
1719        }
1720        Ok(object)
1721    }
1722
1723    fn from_json(
1724        object: &super::super::codec::Object,
1725        path: &mut super::super::codec::Path,
1726    ) -> Result<Self, super::super::codec::DecodeError> {
1727        let mut raw_id: Option<&super::super::codec::Value> = None;
1728        let mut raw_extension: Option<&super::super::codec::Value> = None;
1729        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1730        let mut raw_description: Option<&super::super::codec::Value> = None;
1731        let mut raw_description_element: Option<&super::super::codec::Value> = None;
1732        let mut raw_url: Option<&super::super::codec::Value> = None;
1733        let mut raw_url_element: Option<&super::super::codec::Value> = None;
1734        let mut raw_custodian: Option<&super::super::codec::Value> = None;
1735        for (key, value) in object {
1736            match key.as_str() {
1737                "id" => {
1738                    raw_id = Some(value);
1739                }
1740                "extension" => {
1741                    raw_extension = Some(value);
1742                }
1743                "modifierExtension" => {
1744                    raw_modifier_extension = Some(value);
1745                }
1746                "description" => {
1747                    raw_description = Some(value);
1748                }
1749                "_description" => {
1750                    raw_description_element = Some(value);
1751                }
1752                "url" => {
1753                    raw_url = Some(value);
1754                }
1755                "_url" => {
1756                    raw_url_element = Some(value);
1757                }
1758                "custodian" => {
1759                    raw_custodian = Some(value);
1760                }
1761                other => {
1762                    return path.with(other, |path| {
1763                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1764                    });
1765                }
1766            }
1767        }
1768        let field_id = raw_id
1769            .map(|value| {
1770                path.with("id", |path| {
1771                    let value = super::super::codec::expect_single(value, path)?;
1772                    super::primitives::checked_string(
1773                        super::super::codec::expect_string(value, path)?,
1774                        path,
1775                    )
1776                })
1777            })
1778            .transpose()?;
1779        let mut field_extension = Vec::new();
1780        if let Some(raw) = raw_extension {
1781            for (index, value) in path
1782                .with("extension", |path| {
1783                    super::super::codec::expect_array(raw, path)
1784                })?
1785                .iter()
1786                .enumerate()
1787            {
1788                field_extension.push(path.with_index("extension", index, |path| {
1789                    super::super::codec::Json::from_json(
1790                        super::super::codec::expect_object(value, path)?,
1791                        path,
1792                    )
1793                })?);
1794            }
1795        }
1796        let mut field_modifier_extension = Vec::new();
1797        if let Some(raw) = raw_modifier_extension {
1798            for (index, value) in path
1799                .with("modifierExtension", |path| {
1800                    super::super::codec::expect_array(raw, path)
1801                })?
1802                .iter()
1803                .enumerate()
1804            {
1805                field_modifier_extension.push(path.with_index(
1806                    "modifierExtension",
1807                    index,
1808                    |path| {
1809                        super::super::codec::Json::from_json(
1810                            super::super::codec::expect_object(value, path)?,
1811                            path,
1812                        )
1813                    },
1814                )?);
1815            }
1816        }
1817        let field_description = path.with("description", |path| {
1818            super::super::codec::Primitive::from_json_parts(
1819                raw_description,
1820                raw_description_element,
1821                path,
1822            )
1823        })?;
1824        let field_url = match (raw_url, raw_url_element) {
1825            (None, None) => None,
1826            (value, element) => Some(path.with("url", |path| {
1827                super::super::codec::Primitive::from_json_parts(value, element, path)
1828            })?),
1829        };
1830        let field_custodian = raw_custodian
1831            .map(|value| {
1832                path.with("custodian", |path| {
1833                    super::super::codec::Json::from_json(
1834                        super::super::codec::expect_object(
1835                            super::super::codec::expect_single(value, path)?,
1836                            path,
1837                        )?,
1838                        path,
1839                    )
1840                })
1841            })
1842            .transpose()?;
1843        Ok(Self {
1844            id: field_id,
1845            extension: field_extension,
1846            modifier_extension: field_modifier_extension,
1847            description: field_description,
1848            url: field_url,
1849            custodian: field_custodian,
1850        })
1851    }
1852}
1853
1854impl serde::Serialize for CapabilityStatementImplementation {
1855    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1856        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1857        super::super::codec::element_entry(&mut map, "_description", &self.description)?;
1858        if let Some(item) = &self.url {
1859            super::super::codec::element_entry(&mut map, "_url", item)?;
1860        }
1861        if let Some(item) = &self.custodian {
1862            serde::ser::SerializeMap::serialize_entry(&mut map, "custodian", item)?;
1863        }
1864        super::super::codec::value_entry(&mut map, "description", &self.description)?;
1865        if !self.extension.is_empty() {
1866            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1867        }
1868        if let Some(v) = &self.id {
1869            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1870        }
1871        if !self.modifier_extension.is_empty() {
1872            serde::ser::SerializeMap::serialize_entry(
1873                &mut map,
1874                "modifierExtension",
1875                &self.modifier_extension,
1876            )?;
1877        }
1878        if let Some(item) = &self.url {
1879            super::super::codec::value_entry(&mut map, "url", item)?;
1880        }
1881        serde::ser::SerializeMap::end(map)
1882    }
1883}
1884
1885impl<'de> serde::Deserialize<'de> for CapabilityStatementImplementation {
1886    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1887        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1888        let mut path = super::super::codec::Path::root("CapabilityStatementImplementation");
1889        let object =
1890            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1891        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1892    }
1893}
1894
1895/// If messaging is supported
1896///
1897/// A description of the messaging capabilities of the solution.
1898#[derive(Debug, Clone, Default, PartialEq, Eq)]
1899pub struct CapabilityStatementMessaging {
1900    /// Unique id for inter-element referencing
1901    ///
1902    /// Unique id for the element within a resource (for internal references). This
1903    /// may be any string value that does not contain spaces.
1904    pub id: Option<std::string::String>,
1905    /// Additional content defined by implementations
1906    ///
1907    /// May be used to represent additional information that is not part of the
1908    /// basic definition of the element. To make the use of extensions safe and
1909    /// manageable, there is a strict set of governance applied to the definition
1910    /// and use of extensions. Though any implementer can define an extension, there
1911    /// is a set of requirements that SHALL be met as part of the definition of the
1912    /// extension.
1913    pub extension: Vec<super::extension::Extension>,
1914    /// Extensions that cannot be ignored even if unrecognized
1915    ///
1916    /// May be used to represent additional information that is not part of the
1917    /// basic definition of the element and that modifies the understanding of the
1918    /// element in which it is contained and/or the understanding of the containing
1919    /// element's descendants. Usually modifier elements provide negation or
1920    /// qualification. To make the use of extensions safe and manageable, there is a
1921    /// strict set of governance applied to the definition and use of extensions.
1922    /// Though any implementer can define an extension, there is a set of
1923    /// requirements that SHALL be met as part of the definition of the extension.
1924    /// Applications processing a resource are required to check for modifier
1925    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1926    /// on Resource or DomainResource (including cannot change the meaning of
1927    /// modifierExtension itself).
1928    pub modifier_extension: Vec<super::extension::Extension>,
1929    /// Where messages should be sent
1930    ///
1931    /// An endpoint (network accessible address) to which messages and/or replies
1932    /// are to be sent.
1933    pub endpoint: Vec<CapabilityStatementMessagingEndpoint>,
1934    /// Reliable Message Cache Length (min)
1935    ///
1936    /// Length if the receiver's reliable messaging cache in minutes (if a receiver)
1937    /// or how long the cache length on the receiver should be (if a sender).
1938    pub reliable_cache: Option<super::primitives::UnsignedInt>,
1939    /// Messaging interface behavior details
1940    ///
1941    /// Documentation about the system's messaging capabilities for this endpoint
1942    /// not otherwise documented by the capability statement. For example, the
1943    /// process for becoming an authorized messaging exchange partner.
1944    pub documentation: Option<super::primitives::Markdown>,
1945    /// Messages supported by this system
1946    ///
1947    /// References to message definitions for messages this system can send or
1948    /// receive.
1949    pub supported_message: Vec<CapabilityStatementMessagingSupportedMessage>,
1950}
1951
1952impl super::super::codec::Json for CapabilityStatementMessaging {
1953    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1954        let mut object = super::super::codec::Object::new();
1955        if let Some(v) = &self.id {
1956            object.insert(
1957                std::string::String::from("id"),
1958                super::super::codec::Value::String(v.clone()),
1959            );
1960        }
1961        if !self.extension.is_empty() {
1962            let mut items = Vec::with_capacity(self.extension.len());
1963            for item in &self.extension {
1964                items.push(super::super::codec::Value::Object(
1965                    super::super::codec::Json::to_json(item)?,
1966                ));
1967            }
1968            object.insert(
1969                std::string::String::from("extension"),
1970                super::super::codec::Value::Array(items),
1971            );
1972        }
1973        if !self.modifier_extension.is_empty() {
1974            let mut items = Vec::with_capacity(self.modifier_extension.len());
1975            for item in &self.modifier_extension {
1976                items.push(super::super::codec::Value::Object(
1977                    super::super::codec::Json::to_json(item)?,
1978                ));
1979            }
1980            object.insert(
1981                std::string::String::from("modifierExtension"),
1982                super::super::codec::Value::Array(items),
1983            );
1984        }
1985        if !self.endpoint.is_empty() {
1986            let mut items = Vec::with_capacity(self.endpoint.len());
1987            for item in &self.endpoint {
1988                items.push(super::super::codec::Value::Object(
1989                    super::super::codec::Json::to_json(item)?,
1990                ));
1991            }
1992            object.insert(
1993                std::string::String::from("endpoint"),
1994                super::super::codec::Value::Array(items),
1995            );
1996        }
1997        if let Some(item) = &self.reliable_cache {
1998            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1999                object.insert(std::string::String::from("reliableCache"), v);
2000            }
2001            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2002                object.insert(std::string::String::from("_reliableCache"), e);
2003            }
2004        }
2005        if let Some(item) = &self.documentation {
2006            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2007                object.insert(std::string::String::from("documentation"), v);
2008            }
2009            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2010                object.insert(std::string::String::from("_documentation"), e);
2011            }
2012        }
2013        if !self.supported_message.is_empty() {
2014            let mut items = Vec::with_capacity(self.supported_message.len());
2015            for item in &self.supported_message {
2016                items.push(super::super::codec::Value::Object(
2017                    super::super::codec::Json::to_json(item)?,
2018                ));
2019            }
2020            object.insert(
2021                std::string::String::from("supportedMessage"),
2022                super::super::codec::Value::Array(items),
2023            );
2024        }
2025        Ok(object)
2026    }
2027
2028    fn from_json(
2029        object: &super::super::codec::Object,
2030        path: &mut super::super::codec::Path,
2031    ) -> Result<Self, super::super::codec::DecodeError> {
2032        let mut raw_id: Option<&super::super::codec::Value> = None;
2033        let mut raw_extension: Option<&super::super::codec::Value> = None;
2034        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2035        let mut raw_endpoint: Option<&super::super::codec::Value> = None;
2036        let mut raw_reliable_cache: Option<&super::super::codec::Value> = None;
2037        let mut raw_reliable_cache_element: Option<&super::super::codec::Value> = None;
2038        let mut raw_documentation: Option<&super::super::codec::Value> = None;
2039        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
2040        let mut raw_supported_message: Option<&super::super::codec::Value> = None;
2041        for (key, value) in object {
2042            match key.as_str() {
2043                "id" => {
2044                    raw_id = Some(value);
2045                }
2046                "extension" => {
2047                    raw_extension = Some(value);
2048                }
2049                "modifierExtension" => {
2050                    raw_modifier_extension = Some(value);
2051                }
2052                "endpoint" => {
2053                    raw_endpoint = Some(value);
2054                }
2055                "reliableCache" => {
2056                    raw_reliable_cache = Some(value);
2057                }
2058                "_reliableCache" => {
2059                    raw_reliable_cache_element = Some(value);
2060                }
2061                "documentation" => {
2062                    raw_documentation = Some(value);
2063                }
2064                "_documentation" => {
2065                    raw_documentation_element = Some(value);
2066                }
2067                "supportedMessage" => {
2068                    raw_supported_message = Some(value);
2069                }
2070                other => {
2071                    return path.with(other, |path| {
2072                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2073                    });
2074                }
2075            }
2076        }
2077        let field_id = raw_id
2078            .map(|value| {
2079                path.with("id", |path| {
2080                    let value = super::super::codec::expect_single(value, path)?;
2081                    super::primitives::checked_string(
2082                        super::super::codec::expect_string(value, path)?,
2083                        path,
2084                    )
2085                })
2086            })
2087            .transpose()?;
2088        let mut field_extension = Vec::new();
2089        if let Some(raw) = raw_extension {
2090            for (index, value) in path
2091                .with("extension", |path| {
2092                    super::super::codec::expect_array(raw, path)
2093                })?
2094                .iter()
2095                .enumerate()
2096            {
2097                field_extension.push(path.with_index("extension", index, |path| {
2098                    super::super::codec::Json::from_json(
2099                        super::super::codec::expect_object(value, path)?,
2100                        path,
2101                    )
2102                })?);
2103            }
2104        }
2105        let mut field_modifier_extension = Vec::new();
2106        if let Some(raw) = raw_modifier_extension {
2107            for (index, value) in path
2108                .with("modifierExtension", |path| {
2109                    super::super::codec::expect_array(raw, path)
2110                })?
2111                .iter()
2112                .enumerate()
2113            {
2114                field_modifier_extension.push(path.with_index(
2115                    "modifierExtension",
2116                    index,
2117                    |path| {
2118                        super::super::codec::Json::from_json(
2119                            super::super::codec::expect_object(value, path)?,
2120                            path,
2121                        )
2122                    },
2123                )?);
2124            }
2125        }
2126        let mut field_endpoint = Vec::new();
2127        if let Some(raw) = raw_endpoint {
2128            for (index, value) in path
2129                .with("endpoint", |path| {
2130                    super::super::codec::expect_array(raw, path)
2131                })?
2132                .iter()
2133                .enumerate()
2134            {
2135                field_endpoint.push(path.with_index("endpoint", index, |path| {
2136                    super::super::codec::Json::from_json(
2137                        super::super::codec::expect_object(value, path)?,
2138                        path,
2139                    )
2140                })?);
2141            }
2142        }
2143        let field_reliable_cache = match (raw_reliable_cache, raw_reliable_cache_element) {
2144            (None, None) => None,
2145            (value, element) => Some(path.with("reliableCache", |path| {
2146                super::super::codec::Primitive::from_json_parts(value, element, path)
2147            })?),
2148        };
2149        let field_documentation = match (raw_documentation, raw_documentation_element) {
2150            (None, None) => None,
2151            (value, element) => Some(path.with("documentation", |path| {
2152                super::super::codec::Primitive::from_json_parts(value, element, path)
2153            })?),
2154        };
2155        let mut field_supported_message = Vec::new();
2156        if let Some(raw) = raw_supported_message {
2157            for (index, value) in path
2158                .with("supportedMessage", |path| {
2159                    super::super::codec::expect_array(raw, path)
2160                })?
2161                .iter()
2162                .enumerate()
2163            {
2164                field_supported_message.push(path.with_index(
2165                    "supportedMessage",
2166                    index,
2167                    |path| {
2168                        super::super::codec::Json::from_json(
2169                            super::super::codec::expect_object(value, path)?,
2170                            path,
2171                        )
2172                    },
2173                )?);
2174            }
2175        }
2176        Ok(Self {
2177            id: field_id,
2178            extension: field_extension,
2179            modifier_extension: field_modifier_extension,
2180            endpoint: field_endpoint,
2181            reliable_cache: field_reliable_cache,
2182            documentation: field_documentation,
2183            supported_message: field_supported_message,
2184        })
2185    }
2186}
2187
2188impl serde::Serialize for CapabilityStatementMessaging {
2189    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2190        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2191        if let Some(item) = &self.documentation {
2192            super::super::codec::element_entry(&mut map, "_documentation", item)?;
2193        }
2194        if let Some(item) = &self.reliable_cache {
2195            super::super::codec::element_entry(&mut map, "_reliableCache", item)?;
2196        }
2197        if let Some(item) = &self.documentation {
2198            super::super::codec::value_entry(&mut map, "documentation", item)?;
2199        }
2200        if !self.endpoint.is_empty() {
2201            serde::ser::SerializeMap::serialize_entry(&mut map, "endpoint", &self.endpoint)?;
2202        }
2203        if !self.extension.is_empty() {
2204            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2205        }
2206        if let Some(v) = &self.id {
2207            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2208        }
2209        if !self.modifier_extension.is_empty() {
2210            serde::ser::SerializeMap::serialize_entry(
2211                &mut map,
2212                "modifierExtension",
2213                &self.modifier_extension,
2214            )?;
2215        }
2216        if let Some(item) = &self.reliable_cache {
2217            super::super::codec::value_entry(&mut map, "reliableCache", item)?;
2218        }
2219        if !self.supported_message.is_empty() {
2220            serde::ser::SerializeMap::serialize_entry(
2221                &mut map,
2222                "supportedMessage",
2223                &self.supported_message,
2224            )?;
2225        }
2226        serde::ser::SerializeMap::end(map)
2227    }
2228}
2229
2230impl<'de> serde::Deserialize<'de> for CapabilityStatementMessaging {
2231    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2232        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2233        let mut path = super::super::codec::Path::root("CapabilityStatementMessaging");
2234        let object =
2235            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2236        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2237    }
2238}
2239
2240/// Where messages should be sent
2241///
2242/// An endpoint (network accessible address) to which messages and/or replies
2243/// are to be sent.
2244#[derive(Debug, Clone, Default, PartialEq, Eq)]
2245pub struct CapabilityStatementMessagingEndpoint {
2246    /// Unique id for inter-element referencing
2247    ///
2248    /// Unique id for the element within a resource (for internal references). This
2249    /// may be any string value that does not contain spaces.
2250    pub id: Option<std::string::String>,
2251    /// Additional content defined by implementations
2252    ///
2253    /// May be used to represent additional information that is not part of the
2254    /// basic definition of the element. To make the use of extensions safe and
2255    /// manageable, there is a strict set of governance applied to the definition
2256    /// and use of extensions. Though any implementer can define an extension, there
2257    /// is a set of requirements that SHALL be met as part of the definition of the
2258    /// extension.
2259    pub extension: Vec<super::extension::Extension>,
2260    /// Extensions that cannot be ignored even if unrecognized
2261    ///
2262    /// May be used to represent additional information that is not part of the
2263    /// basic definition of the element and that modifies the understanding of the
2264    /// element in which it is contained and/or the understanding of the containing
2265    /// element's descendants. Usually modifier elements provide negation or
2266    /// qualification. To make the use of extensions safe and manageable, there is a
2267    /// strict set of governance applied to the definition and use of extensions.
2268    /// Though any implementer can define an extension, there is a set of
2269    /// requirements that SHALL be met as part of the definition of the extension.
2270    /// Applications processing a resource are required to check for modifier
2271    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2272    /// on Resource or DomainResource (including cannot change the meaning of
2273    /// modifierExtension itself).
2274    pub modifier_extension: Vec<super::extension::Extension>,
2275    /// http | ftp | mllp +
2276    ///
2277    /// A list of the messaging transport protocol(s) identifiers, supported by this
2278    /// endpoint.
2279    pub protocol: super::coding::Coding,
2280    /// Network address or identifier of the end-point
2281    ///
2282    /// The network address of the endpoint. For solutions that do not use network
2283    /// addresses for routing, it can be just an identifier.
2284    pub address: super::primitives::Url,
2285}
2286
2287impl super::super::codec::Json for CapabilityStatementMessagingEndpoint {
2288    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2289        let mut object = super::super::codec::Object::new();
2290        if let Some(v) = &self.id {
2291            object.insert(
2292                std::string::String::from("id"),
2293                super::super::codec::Value::String(v.clone()),
2294            );
2295        }
2296        if !self.extension.is_empty() {
2297            let mut items = Vec::with_capacity(self.extension.len());
2298            for item in &self.extension {
2299                items.push(super::super::codec::Value::Object(
2300                    super::super::codec::Json::to_json(item)?,
2301                ));
2302            }
2303            object.insert(
2304                std::string::String::from("extension"),
2305                super::super::codec::Value::Array(items),
2306            );
2307        }
2308        if !self.modifier_extension.is_empty() {
2309            let mut items = Vec::with_capacity(self.modifier_extension.len());
2310            for item in &self.modifier_extension {
2311                items.push(super::super::codec::Value::Object(
2312                    super::super::codec::Json::to_json(item)?,
2313                ));
2314            }
2315            object.insert(
2316                std::string::String::from("modifierExtension"),
2317                super::super::codec::Value::Array(items),
2318            );
2319        }
2320        object.insert(
2321            std::string::String::from("protocol"),
2322            super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.protocol)?),
2323        );
2324        if let Some(v) = super::super::codec::Primitive::value_json(&self.address)? {
2325            object.insert(std::string::String::from("address"), v);
2326        }
2327        if let Some(e) = super::super::codec::Primitive::element_json(&self.address)? {
2328            object.insert(std::string::String::from("_address"), e);
2329        }
2330        Ok(object)
2331    }
2332
2333    fn from_json(
2334        object: &super::super::codec::Object,
2335        path: &mut super::super::codec::Path,
2336    ) -> Result<Self, super::super::codec::DecodeError> {
2337        let mut raw_id: Option<&super::super::codec::Value> = None;
2338        let mut raw_extension: Option<&super::super::codec::Value> = None;
2339        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2340        let mut raw_protocol: Option<&super::super::codec::Value> = None;
2341        let mut raw_address: Option<&super::super::codec::Value> = None;
2342        let mut raw_address_element: Option<&super::super::codec::Value> = None;
2343        for (key, value) in object {
2344            match key.as_str() {
2345                "id" => {
2346                    raw_id = Some(value);
2347                }
2348                "extension" => {
2349                    raw_extension = Some(value);
2350                }
2351                "modifierExtension" => {
2352                    raw_modifier_extension = Some(value);
2353                }
2354                "protocol" => {
2355                    raw_protocol = Some(value);
2356                }
2357                "address" => {
2358                    raw_address = Some(value);
2359                }
2360                "_address" => {
2361                    raw_address_element = Some(value);
2362                }
2363                other => {
2364                    return path.with(other, |path| {
2365                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2366                    });
2367                }
2368            }
2369        }
2370        let field_id = raw_id
2371            .map(|value| {
2372                path.with("id", |path| {
2373                    let value = super::super::codec::expect_single(value, path)?;
2374                    super::primitives::checked_string(
2375                        super::super::codec::expect_string(value, path)?,
2376                        path,
2377                    )
2378                })
2379            })
2380            .transpose()?;
2381        let mut field_extension = Vec::new();
2382        if let Some(raw) = raw_extension {
2383            for (index, value) in path
2384                .with("extension", |path| {
2385                    super::super::codec::expect_array(raw, path)
2386                })?
2387                .iter()
2388                .enumerate()
2389            {
2390                field_extension.push(path.with_index("extension", index, |path| {
2391                    super::super::codec::Json::from_json(
2392                        super::super::codec::expect_object(value, path)?,
2393                        path,
2394                    )
2395                })?);
2396            }
2397        }
2398        let mut field_modifier_extension = Vec::new();
2399        if let Some(raw) = raw_modifier_extension {
2400            for (index, value) in path
2401                .with("modifierExtension", |path| {
2402                    super::super::codec::expect_array(raw, path)
2403                })?
2404                .iter()
2405                .enumerate()
2406            {
2407                field_modifier_extension.push(path.with_index(
2408                    "modifierExtension",
2409                    index,
2410                    |path| {
2411                        super::super::codec::Json::from_json(
2412                            super::super::codec::expect_object(value, path)?,
2413                            path,
2414                        )
2415                    },
2416                )?);
2417            }
2418        }
2419        let field_protocol = path.with("protocol", |path| {
2420            let value = raw_protocol
2421                .ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
2422            super::super::codec::Json::from_json(
2423                super::super::codec::expect_object(
2424                    super::super::codec::expect_single(value, path)?,
2425                    path,
2426                )?,
2427                path,
2428            )
2429        })?;
2430        let field_address = path.with("address", |path| {
2431            super::super::codec::Primitive::from_json_parts(raw_address, raw_address_element, path)
2432        })?;
2433        Ok(Self {
2434            id: field_id,
2435            extension: field_extension,
2436            modifier_extension: field_modifier_extension,
2437            protocol: field_protocol,
2438            address: field_address,
2439        })
2440    }
2441}
2442
2443impl serde::Serialize for CapabilityStatementMessagingEndpoint {
2444    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2445        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2446        super::super::codec::element_entry(&mut map, "_address", &self.address)?;
2447        super::super::codec::value_entry(&mut map, "address", &self.address)?;
2448        if !self.extension.is_empty() {
2449            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2450        }
2451        if let Some(v) = &self.id {
2452            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2453        }
2454        if !self.modifier_extension.is_empty() {
2455            serde::ser::SerializeMap::serialize_entry(
2456                &mut map,
2457                "modifierExtension",
2458                &self.modifier_extension,
2459            )?;
2460        }
2461        serde::ser::SerializeMap::serialize_entry(&mut map, "protocol", &self.protocol)?;
2462        serde::ser::SerializeMap::end(map)
2463    }
2464}
2465
2466impl<'de> serde::Deserialize<'de> for CapabilityStatementMessagingEndpoint {
2467    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2468        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2469        let mut path = super::super::codec::Path::root("CapabilityStatementMessagingEndpoint");
2470        let object =
2471            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2472        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2473    }
2474}
2475
2476/// Messages supported by this system
2477///
2478/// References to message definitions for messages this system can send or
2479/// receive.
2480#[derive(Debug, Clone, Default, PartialEq, Eq)]
2481pub struct CapabilityStatementMessagingSupportedMessage {
2482    /// Unique id for inter-element referencing
2483    ///
2484    /// Unique id for the element within a resource (for internal references). This
2485    /// may be any string value that does not contain spaces.
2486    pub id: Option<std::string::String>,
2487    /// Additional content defined by implementations
2488    ///
2489    /// May be used to represent additional information that is not part of the
2490    /// basic definition of the element. To make the use of extensions safe and
2491    /// manageable, there is a strict set of governance applied to the definition
2492    /// and use of extensions. Though any implementer can define an extension, there
2493    /// is a set of requirements that SHALL be met as part of the definition of the
2494    /// extension.
2495    pub extension: Vec<super::extension::Extension>,
2496    /// Extensions that cannot be ignored even if unrecognized
2497    ///
2498    /// May be used to represent additional information that is not part of the
2499    /// basic definition of the element and that modifies the understanding of the
2500    /// element in which it is contained and/or the understanding of the containing
2501    /// element's descendants. Usually modifier elements provide negation or
2502    /// qualification. To make the use of extensions safe and manageable, there is a
2503    /// strict set of governance applied to the definition and use of extensions.
2504    /// Though any implementer can define an extension, there is a set of
2505    /// requirements that SHALL be met as part of the definition of the extension.
2506    /// Applications processing a resource are required to check for modifier
2507    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2508    /// on Resource or DomainResource (including cannot change the meaning of
2509    /// modifierExtension itself).
2510    pub modifier_extension: Vec<super::extension::Extension>,
2511    /// sender | receiver
2512    ///
2513    /// The mode of this event declaration - whether application is sender or
2514    /// receiver.
2515    pub mode: super::primitives::Code,
2516    /// Message supported by this system
2517    ///
2518    /// Points to a message definition that identifies the messaging event, message
2519    /// structure, allowed responses, etc.
2520    pub definition: super::primitives::Canonical,
2521}
2522
2523impl super::super::codec::Json for CapabilityStatementMessagingSupportedMessage {
2524    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2525        let mut object = super::super::codec::Object::new();
2526        if let Some(v) = &self.id {
2527            object.insert(
2528                std::string::String::from("id"),
2529                super::super::codec::Value::String(v.clone()),
2530            );
2531        }
2532        if !self.extension.is_empty() {
2533            let mut items = Vec::with_capacity(self.extension.len());
2534            for item in &self.extension {
2535                items.push(super::super::codec::Value::Object(
2536                    super::super::codec::Json::to_json(item)?,
2537                ));
2538            }
2539            object.insert(
2540                std::string::String::from("extension"),
2541                super::super::codec::Value::Array(items),
2542            );
2543        }
2544        if !self.modifier_extension.is_empty() {
2545            let mut items = Vec::with_capacity(self.modifier_extension.len());
2546            for item in &self.modifier_extension {
2547                items.push(super::super::codec::Value::Object(
2548                    super::super::codec::Json::to_json(item)?,
2549                ));
2550            }
2551            object.insert(
2552                std::string::String::from("modifierExtension"),
2553                super::super::codec::Value::Array(items),
2554            );
2555        }
2556        if let Some(v) = super::super::codec::Primitive::value_json(&self.mode)? {
2557            object.insert(std::string::String::from("mode"), v);
2558        }
2559        if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
2560            object.insert(std::string::String::from("_mode"), e);
2561        }
2562        if let Some(v) = super::super::codec::Primitive::value_json(&self.definition)? {
2563            object.insert(std::string::String::from("definition"), v);
2564        }
2565        if let Some(e) = super::super::codec::Primitive::element_json(&self.definition)? {
2566            object.insert(std::string::String::from("_definition"), e);
2567        }
2568        Ok(object)
2569    }
2570
2571    fn from_json(
2572        object: &super::super::codec::Object,
2573        path: &mut super::super::codec::Path,
2574    ) -> Result<Self, super::super::codec::DecodeError> {
2575        let mut raw_id: Option<&super::super::codec::Value> = None;
2576        let mut raw_extension: Option<&super::super::codec::Value> = None;
2577        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2578        let mut raw_mode: Option<&super::super::codec::Value> = None;
2579        let mut raw_mode_element: Option<&super::super::codec::Value> = None;
2580        let mut raw_definition: Option<&super::super::codec::Value> = None;
2581        let mut raw_definition_element: Option<&super::super::codec::Value> = None;
2582        for (key, value) in object {
2583            match key.as_str() {
2584                "id" => {
2585                    raw_id = Some(value);
2586                }
2587                "extension" => {
2588                    raw_extension = Some(value);
2589                }
2590                "modifierExtension" => {
2591                    raw_modifier_extension = Some(value);
2592                }
2593                "mode" => {
2594                    raw_mode = Some(value);
2595                }
2596                "_mode" => {
2597                    raw_mode_element = Some(value);
2598                }
2599                "definition" => {
2600                    raw_definition = Some(value);
2601                }
2602                "_definition" => {
2603                    raw_definition_element = Some(value);
2604                }
2605                other => {
2606                    return path.with(other, |path| {
2607                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2608                    });
2609                }
2610            }
2611        }
2612        let field_id = raw_id
2613            .map(|value| {
2614                path.with("id", |path| {
2615                    let value = super::super::codec::expect_single(value, path)?;
2616                    super::primitives::checked_string(
2617                        super::super::codec::expect_string(value, path)?,
2618                        path,
2619                    )
2620                })
2621            })
2622            .transpose()?;
2623        let mut field_extension = Vec::new();
2624        if let Some(raw) = raw_extension {
2625            for (index, value) in path
2626                .with("extension", |path| {
2627                    super::super::codec::expect_array(raw, path)
2628                })?
2629                .iter()
2630                .enumerate()
2631            {
2632                field_extension.push(path.with_index("extension", index, |path| {
2633                    super::super::codec::Json::from_json(
2634                        super::super::codec::expect_object(value, path)?,
2635                        path,
2636                    )
2637                })?);
2638            }
2639        }
2640        let mut field_modifier_extension = Vec::new();
2641        if let Some(raw) = raw_modifier_extension {
2642            for (index, value) in path
2643                .with("modifierExtension", |path| {
2644                    super::super::codec::expect_array(raw, path)
2645                })?
2646                .iter()
2647                .enumerate()
2648            {
2649                field_modifier_extension.push(path.with_index(
2650                    "modifierExtension",
2651                    index,
2652                    |path| {
2653                        super::super::codec::Json::from_json(
2654                            super::super::codec::expect_object(value, path)?,
2655                            path,
2656                        )
2657                    },
2658                )?);
2659            }
2660        }
2661        let field_mode = path.with("mode", |path| {
2662            super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
2663        })?;
2664        let field_definition = path.with("definition", |path| {
2665            super::super::codec::Primitive::from_json_parts(
2666                raw_definition,
2667                raw_definition_element,
2668                path,
2669            )
2670        })?;
2671        Ok(Self {
2672            id: field_id,
2673            extension: field_extension,
2674            modifier_extension: field_modifier_extension,
2675            mode: field_mode,
2676            definition: field_definition,
2677        })
2678    }
2679}
2680
2681impl serde::Serialize for CapabilityStatementMessagingSupportedMessage {
2682    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2683        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2684        super::super::codec::element_entry(&mut map, "_definition", &self.definition)?;
2685        super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
2686        super::super::codec::value_entry(&mut map, "definition", &self.definition)?;
2687        if !self.extension.is_empty() {
2688            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2689        }
2690        if let Some(v) = &self.id {
2691            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2692        }
2693        super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
2694        if !self.modifier_extension.is_empty() {
2695            serde::ser::SerializeMap::serialize_entry(
2696                &mut map,
2697                "modifierExtension",
2698                &self.modifier_extension,
2699            )?;
2700        }
2701        serde::ser::SerializeMap::end(map)
2702    }
2703}
2704
2705impl<'de> serde::Deserialize<'de> for CapabilityStatementMessagingSupportedMessage {
2706    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2707        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2708        let mut path =
2709            super::super::codec::Path::root("CapabilityStatementMessagingSupportedMessage");
2710        let object =
2711            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2712        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2713    }
2714}
2715
2716/// If the endpoint is a RESTful one
2717///
2718/// A definition of the restful capabilities of the solution, if any.
2719#[derive(Debug, Clone, Default, PartialEq, Eq)]
2720pub struct CapabilityStatementRest {
2721    /// Unique id for inter-element referencing
2722    ///
2723    /// Unique id for the element within a resource (for internal references). This
2724    /// may be any string value that does not contain spaces.
2725    pub id: Option<std::string::String>,
2726    /// Additional content defined by implementations
2727    ///
2728    /// May be used to represent additional information that is not part of the
2729    /// basic definition of the element. To make the use of extensions safe and
2730    /// manageable, there is a strict set of governance applied to the definition
2731    /// and use of extensions. Though any implementer can define an extension, there
2732    /// is a set of requirements that SHALL be met as part of the definition of the
2733    /// extension.
2734    pub extension: Vec<super::extension::Extension>,
2735    /// Extensions that cannot be ignored even if unrecognized
2736    ///
2737    /// May be used to represent additional information that is not part of the
2738    /// basic definition of the element and that modifies the understanding of the
2739    /// element in which it is contained and/or the understanding of the containing
2740    /// element's descendants. Usually modifier elements provide negation or
2741    /// qualification. To make the use of extensions safe and manageable, there is a
2742    /// strict set of governance applied to the definition and use of extensions.
2743    /// Though any implementer can define an extension, there is a set of
2744    /// requirements that SHALL be met as part of the definition of the extension.
2745    /// Applications processing a resource are required to check for modifier
2746    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2747    /// on Resource or DomainResource (including cannot change the meaning of
2748    /// modifierExtension itself).
2749    pub modifier_extension: Vec<super::extension::Extension>,
2750    /// client | server
2751    ///
2752    /// Identifies whether this portion of the statement is describing the ability
2753    /// to initiate or receive restful operations.
2754    pub mode: super::primitives::Code,
2755    /// General description of implementation
2756    ///
2757    /// Information about the system's restful capabilities that apply across all
2758    /// applications, such as security.
2759    pub documentation: Option<super::primitives::Markdown>,
2760    /// Information about security of implementation
2761    ///
2762    /// Information about security implementation from an interface perspective -
2763    /// what a client needs to know.
2764    pub security: Option<CapabilityStatementRestSecurity>,
2765    /// Resource served on the REST interface
2766    ///
2767    /// A specification of the restful capabilities of the solution for a specific
2768    /// resource type.
2769    pub resource: Vec<CapabilityStatementRestResource>,
2770    /// What operations are supported?
2771    ///
2772    /// A specification of restful operations supported by the system.
2773    pub interaction: Vec<CapabilityStatementRestInteraction>,
2774    /// Search parameters for searching all resources
2775    ///
2776    /// Search parameters that are supported for searching all resources for
2777    /// implementations to support and/or make use of - either references to ones
2778    /// defined in the specification, or additional ones defined for/by the
2779    /// implementation.
2780    pub search_param: Vec<CapabilityStatementRestResourceSearchParam>,
2781    /// Definition of a system level operation
2782    ///
2783    /// Definition of an operation or a named query together with its parameters and
2784    /// their meaning and type.
2785    pub operation: Vec<CapabilityStatementRestResourceOperation>,
2786    /// Compartments served/used by system
2787    ///
2788    /// An absolute URI which is a reference to the definition of a compartment that
2789    /// the system supports. The reference is to a CompartmentDefinition resource by
2790    /// its canonical URL .
2791    pub compartment: Vec<super::primitives::Canonical>,
2792}
2793
2794impl super::super::codec::Json for CapabilityStatementRest {
2795    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2796        let mut object = super::super::codec::Object::new();
2797        if let Some(v) = &self.id {
2798            object.insert(
2799                std::string::String::from("id"),
2800                super::super::codec::Value::String(v.clone()),
2801            );
2802        }
2803        if !self.extension.is_empty() {
2804            let mut items = Vec::with_capacity(self.extension.len());
2805            for item in &self.extension {
2806                items.push(super::super::codec::Value::Object(
2807                    super::super::codec::Json::to_json(item)?,
2808                ));
2809            }
2810            object.insert(
2811                std::string::String::from("extension"),
2812                super::super::codec::Value::Array(items),
2813            );
2814        }
2815        if !self.modifier_extension.is_empty() {
2816            let mut items = Vec::with_capacity(self.modifier_extension.len());
2817            for item in &self.modifier_extension {
2818                items.push(super::super::codec::Value::Object(
2819                    super::super::codec::Json::to_json(item)?,
2820                ));
2821            }
2822            object.insert(
2823                std::string::String::from("modifierExtension"),
2824                super::super::codec::Value::Array(items),
2825            );
2826        }
2827        if let Some(v) = super::super::codec::Primitive::value_json(&self.mode)? {
2828            object.insert(std::string::String::from("mode"), v);
2829        }
2830        if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
2831            object.insert(std::string::String::from("_mode"), e);
2832        }
2833        if let Some(item) = &self.documentation {
2834            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2835                object.insert(std::string::String::from("documentation"), v);
2836            }
2837            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2838                object.insert(std::string::String::from("_documentation"), e);
2839            }
2840        }
2841        if let Some(item) = &self.security {
2842            object.insert(
2843                std::string::String::from("security"),
2844                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
2845            );
2846        }
2847        if !self.resource.is_empty() {
2848            let mut items = Vec::with_capacity(self.resource.len());
2849            for item in &self.resource {
2850                items.push(super::super::codec::Value::Object(
2851                    super::super::codec::Json::to_json(item)?,
2852                ));
2853            }
2854            object.insert(
2855                std::string::String::from("resource"),
2856                super::super::codec::Value::Array(items),
2857            );
2858        }
2859        if !self.interaction.is_empty() {
2860            let mut items = Vec::with_capacity(self.interaction.len());
2861            for item in &self.interaction {
2862                items.push(super::super::codec::Value::Object(
2863                    super::super::codec::Json::to_json(item)?,
2864                ));
2865            }
2866            object.insert(
2867                std::string::String::from("interaction"),
2868                super::super::codec::Value::Array(items),
2869            );
2870        }
2871        if !self.search_param.is_empty() {
2872            let mut items = Vec::with_capacity(self.search_param.len());
2873            for item in &self.search_param {
2874                items.push(super::super::codec::Value::Object(
2875                    super::super::codec::Json::to_json(item)?,
2876                ));
2877            }
2878            object.insert(
2879                std::string::String::from("searchParam"),
2880                super::super::codec::Value::Array(items),
2881            );
2882        }
2883        if !self.operation.is_empty() {
2884            let mut items = Vec::with_capacity(self.operation.len());
2885            for item in &self.operation {
2886                items.push(super::super::codec::Value::Object(
2887                    super::super::codec::Json::to_json(item)?,
2888                ));
2889            }
2890            object.insert(
2891                std::string::String::from("operation"),
2892                super::super::codec::Value::Array(items),
2893            );
2894        }
2895        if !self.compartment.is_empty() {
2896            let (values, elements) = super::super::codec::primitive_arrays(&self.compartment)?;
2897            if let Some(values) = values {
2898                object.insert(std::string::String::from("compartment"), values);
2899            }
2900            if let Some(elements) = elements {
2901                object.insert(std::string::String::from("_compartment"), elements);
2902            }
2903        }
2904        Ok(object)
2905    }
2906
2907    fn from_json(
2908        object: &super::super::codec::Object,
2909        path: &mut super::super::codec::Path,
2910    ) -> Result<Self, super::super::codec::DecodeError> {
2911        let mut raw_id: Option<&super::super::codec::Value> = None;
2912        let mut raw_extension: Option<&super::super::codec::Value> = None;
2913        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2914        let mut raw_mode: Option<&super::super::codec::Value> = None;
2915        let mut raw_mode_element: Option<&super::super::codec::Value> = None;
2916        let mut raw_documentation: Option<&super::super::codec::Value> = None;
2917        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
2918        let mut raw_security: Option<&super::super::codec::Value> = None;
2919        let mut raw_resource: Option<&super::super::codec::Value> = None;
2920        let mut raw_interaction: Option<&super::super::codec::Value> = None;
2921        let mut raw_search_param: Option<&super::super::codec::Value> = None;
2922        let mut raw_operation: Option<&super::super::codec::Value> = None;
2923        let mut raw_compartment: Option<&super::super::codec::Value> = None;
2924        let mut raw_compartment_element: Option<&super::super::codec::Value> = None;
2925        for (key, value) in object {
2926            match key.as_str() {
2927                "id" => {
2928                    raw_id = Some(value);
2929                }
2930                "extension" => {
2931                    raw_extension = Some(value);
2932                }
2933                "modifierExtension" => {
2934                    raw_modifier_extension = Some(value);
2935                }
2936                "mode" => {
2937                    raw_mode = Some(value);
2938                }
2939                "_mode" => {
2940                    raw_mode_element = Some(value);
2941                }
2942                "documentation" => {
2943                    raw_documentation = Some(value);
2944                }
2945                "_documentation" => {
2946                    raw_documentation_element = Some(value);
2947                }
2948                "security" => {
2949                    raw_security = Some(value);
2950                }
2951                "resource" => {
2952                    raw_resource = Some(value);
2953                }
2954                "interaction" => {
2955                    raw_interaction = Some(value);
2956                }
2957                "searchParam" => {
2958                    raw_search_param = Some(value);
2959                }
2960                "operation" => {
2961                    raw_operation = Some(value);
2962                }
2963                "compartment" => {
2964                    raw_compartment = Some(value);
2965                }
2966                "_compartment" => {
2967                    raw_compartment_element = Some(value);
2968                }
2969                other => {
2970                    return path.with(other, |path| {
2971                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2972                    });
2973                }
2974            }
2975        }
2976        let field_id = raw_id
2977            .map(|value| {
2978                path.with("id", |path| {
2979                    let value = super::super::codec::expect_single(value, path)?;
2980                    super::primitives::checked_string(
2981                        super::super::codec::expect_string(value, path)?,
2982                        path,
2983                    )
2984                })
2985            })
2986            .transpose()?;
2987        let mut field_extension = Vec::new();
2988        if let Some(raw) = raw_extension {
2989            for (index, value) in path
2990                .with("extension", |path| {
2991                    super::super::codec::expect_array(raw, path)
2992                })?
2993                .iter()
2994                .enumerate()
2995            {
2996                field_extension.push(path.with_index("extension", index, |path| {
2997                    super::super::codec::Json::from_json(
2998                        super::super::codec::expect_object(value, path)?,
2999                        path,
3000                    )
3001                })?);
3002            }
3003        }
3004        let mut field_modifier_extension = Vec::new();
3005        if let Some(raw) = raw_modifier_extension {
3006            for (index, value) in path
3007                .with("modifierExtension", |path| {
3008                    super::super::codec::expect_array(raw, path)
3009                })?
3010                .iter()
3011                .enumerate()
3012            {
3013                field_modifier_extension.push(path.with_index(
3014                    "modifierExtension",
3015                    index,
3016                    |path| {
3017                        super::super::codec::Json::from_json(
3018                            super::super::codec::expect_object(value, path)?,
3019                            path,
3020                        )
3021                    },
3022                )?);
3023            }
3024        }
3025        let field_mode = path.with("mode", |path| {
3026            super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
3027        })?;
3028        let field_documentation = match (raw_documentation, raw_documentation_element) {
3029            (None, None) => None,
3030            (value, element) => Some(path.with("documentation", |path| {
3031                super::super::codec::Primitive::from_json_parts(value, element, path)
3032            })?),
3033        };
3034        let field_security = raw_security
3035            .map(|value| {
3036                path.with("security", |path| {
3037                    super::super::codec::Json::from_json(
3038                        super::super::codec::expect_object(
3039                            super::super::codec::expect_single(value, path)?,
3040                            path,
3041                        )?,
3042                        path,
3043                    )
3044                })
3045            })
3046            .transpose()?;
3047        let mut field_resource = Vec::new();
3048        if let Some(raw) = raw_resource {
3049            for (index, value) in path
3050                .with("resource", |path| {
3051                    super::super::codec::expect_array(raw, path)
3052                })?
3053                .iter()
3054                .enumerate()
3055            {
3056                field_resource.push(path.with_index("resource", index, |path| {
3057                    super::super::codec::Json::from_json(
3058                        super::super::codec::expect_object(value, path)?,
3059                        path,
3060                    )
3061                })?);
3062            }
3063        }
3064        let mut field_interaction = Vec::new();
3065        if let Some(raw) = raw_interaction {
3066            for (index, value) in path
3067                .with("interaction", |path| {
3068                    super::super::codec::expect_array(raw, path)
3069                })?
3070                .iter()
3071                .enumerate()
3072            {
3073                field_interaction.push(path.with_index("interaction", index, |path| {
3074                    super::super::codec::Json::from_json(
3075                        super::super::codec::expect_object(value, path)?,
3076                        path,
3077                    )
3078                })?);
3079            }
3080        }
3081        let mut field_search_param = Vec::new();
3082        if let Some(raw) = raw_search_param {
3083            for (index, value) in path
3084                .with("searchParam", |path| {
3085                    super::super::codec::expect_array(raw, path)
3086                })?
3087                .iter()
3088                .enumerate()
3089            {
3090                field_search_param.push(path.with_index("searchParam", index, |path| {
3091                    super::super::codec::Json::from_json(
3092                        super::super::codec::expect_object(value, path)?,
3093                        path,
3094                    )
3095                })?);
3096            }
3097        }
3098        let mut field_operation = Vec::new();
3099        if let Some(raw) = raw_operation {
3100            for (index, value) in path
3101                .with("operation", |path| {
3102                    super::super::codec::expect_array(raw, path)
3103                })?
3104                .iter()
3105                .enumerate()
3106            {
3107                field_operation.push(path.with_index("operation", index, |path| {
3108                    super::super::codec::Json::from_json(
3109                        super::super::codec::expect_object(value, path)?,
3110                        path,
3111                    )
3112                })?);
3113            }
3114        }
3115        let mut field_compartment = Vec::new();
3116        for (index, (value, element)) in path
3117            .with("compartment", |path| {
3118                super::super::codec::pair_arrays(raw_compartment, raw_compartment_element, path)
3119            })?
3120            .into_iter()
3121            .enumerate()
3122        {
3123            field_compartment.push(path.with_index("compartment", index, |path| {
3124                super::super::codec::Primitive::from_json_parts(value, element, path)
3125            })?);
3126        }
3127        Ok(Self {
3128            id: field_id,
3129            extension: field_extension,
3130            modifier_extension: field_modifier_extension,
3131            mode: field_mode,
3132            documentation: field_documentation,
3133            security: field_security,
3134            resource: field_resource,
3135            interaction: field_interaction,
3136            search_param: field_search_param,
3137            operation: field_operation,
3138            compartment: field_compartment,
3139        })
3140    }
3141}
3142
3143impl serde::Serialize for CapabilityStatementRest {
3144    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3145        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3146        super::super::codec::element_list_entry(&mut map, "_compartment", &self.compartment)?;
3147        if let Some(item) = &self.documentation {
3148            super::super::codec::element_entry(&mut map, "_documentation", item)?;
3149        }
3150        super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
3151        super::super::codec::value_list_entry(&mut map, "compartment", &self.compartment)?;
3152        if let Some(item) = &self.documentation {
3153            super::super::codec::value_entry(&mut map, "documentation", item)?;
3154        }
3155        if !self.extension.is_empty() {
3156            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3157        }
3158        if let Some(v) = &self.id {
3159            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3160        }
3161        if !self.interaction.is_empty() {
3162            serde::ser::SerializeMap::serialize_entry(&mut map, "interaction", &self.interaction)?;
3163        }
3164        super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
3165        if !self.modifier_extension.is_empty() {
3166            serde::ser::SerializeMap::serialize_entry(
3167                &mut map,
3168                "modifierExtension",
3169                &self.modifier_extension,
3170            )?;
3171        }
3172        if !self.operation.is_empty() {
3173            serde::ser::SerializeMap::serialize_entry(&mut map, "operation", &self.operation)?;
3174        }
3175        if !self.resource.is_empty() {
3176            serde::ser::SerializeMap::serialize_entry(&mut map, "resource", &self.resource)?;
3177        }
3178        if !self.search_param.is_empty() {
3179            serde::ser::SerializeMap::serialize_entry(&mut map, "searchParam", &self.search_param)?;
3180        }
3181        if let Some(item) = &self.security {
3182            serde::ser::SerializeMap::serialize_entry(&mut map, "security", item)?;
3183        }
3184        serde::ser::SerializeMap::end(map)
3185    }
3186}
3187
3188impl<'de> serde::Deserialize<'de> for CapabilityStatementRest {
3189    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3190        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3191        let mut path = super::super::codec::Path::root("CapabilityStatementRest");
3192        let object =
3193            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3194        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3195    }
3196}
3197
3198/// What operations are supported?
3199///
3200/// A specification of restful operations supported by the system.
3201#[derive(Debug, Clone, Default, PartialEq, Eq)]
3202pub struct CapabilityStatementRestInteraction {
3203    /// Unique id for inter-element referencing
3204    ///
3205    /// Unique id for the element within a resource (for internal references). This
3206    /// may be any string value that does not contain spaces.
3207    pub id: Option<std::string::String>,
3208    /// Additional content defined by implementations
3209    ///
3210    /// May be used to represent additional information that is not part of the
3211    /// basic definition of the element. To make the use of extensions safe and
3212    /// manageable, there is a strict set of governance applied to the definition
3213    /// and use of extensions. Though any implementer can define an extension, there
3214    /// is a set of requirements that SHALL be met as part of the definition of the
3215    /// extension.
3216    pub extension: Vec<super::extension::Extension>,
3217    /// Extensions that cannot be ignored even if unrecognized
3218    ///
3219    /// May be used to represent additional information that is not part of the
3220    /// basic definition of the element and that modifies the understanding of the
3221    /// element in which it is contained and/or the understanding of the containing
3222    /// element's descendants. Usually modifier elements provide negation or
3223    /// qualification. To make the use of extensions safe and manageable, there is a
3224    /// strict set of governance applied to the definition and use of extensions.
3225    /// Though any implementer can define an extension, there is a set of
3226    /// requirements that SHALL be met as part of the definition of the extension.
3227    /// Applications processing a resource are required to check for modifier
3228    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3229    /// on Resource or DomainResource (including cannot change the meaning of
3230    /// modifierExtension itself).
3231    pub modifier_extension: Vec<super::extension::Extension>,
3232    /// transaction | batch | search-system | history-system
3233    ///
3234    /// A coded identifier of the operation, supported by the system.
3235    pub code: super::primitives::Code,
3236    /// Anything special about operation behavior
3237    ///
3238    /// Guidance specific to the implementation of this operation, such as
3239    /// limitations on the kind of transactions allowed, or information about system
3240    /// wide search is implemented.
3241    pub documentation: Option<super::primitives::Markdown>,
3242}
3243
3244impl super::super::codec::Json for CapabilityStatementRestInteraction {
3245    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3246        let mut object = super::super::codec::Object::new();
3247        if let Some(v) = &self.id {
3248            object.insert(
3249                std::string::String::from("id"),
3250                super::super::codec::Value::String(v.clone()),
3251            );
3252        }
3253        if !self.extension.is_empty() {
3254            let mut items = Vec::with_capacity(self.extension.len());
3255            for item in &self.extension {
3256                items.push(super::super::codec::Value::Object(
3257                    super::super::codec::Json::to_json(item)?,
3258                ));
3259            }
3260            object.insert(
3261                std::string::String::from("extension"),
3262                super::super::codec::Value::Array(items),
3263            );
3264        }
3265        if !self.modifier_extension.is_empty() {
3266            let mut items = Vec::with_capacity(self.modifier_extension.len());
3267            for item in &self.modifier_extension {
3268                items.push(super::super::codec::Value::Object(
3269                    super::super::codec::Json::to_json(item)?,
3270                ));
3271            }
3272            object.insert(
3273                std::string::String::from("modifierExtension"),
3274                super::super::codec::Value::Array(items),
3275            );
3276        }
3277        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
3278            object.insert(std::string::String::from("code"), v);
3279        }
3280        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
3281            object.insert(std::string::String::from("_code"), e);
3282        }
3283        if let Some(item) = &self.documentation {
3284            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3285                object.insert(std::string::String::from("documentation"), v);
3286            }
3287            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3288                object.insert(std::string::String::from("_documentation"), e);
3289            }
3290        }
3291        Ok(object)
3292    }
3293
3294    fn from_json(
3295        object: &super::super::codec::Object,
3296        path: &mut super::super::codec::Path,
3297    ) -> Result<Self, super::super::codec::DecodeError> {
3298        let mut raw_id: Option<&super::super::codec::Value> = None;
3299        let mut raw_extension: Option<&super::super::codec::Value> = None;
3300        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3301        let mut raw_code: Option<&super::super::codec::Value> = None;
3302        let mut raw_code_element: Option<&super::super::codec::Value> = None;
3303        let mut raw_documentation: Option<&super::super::codec::Value> = None;
3304        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
3305        for (key, value) in object {
3306            match key.as_str() {
3307                "id" => {
3308                    raw_id = Some(value);
3309                }
3310                "extension" => {
3311                    raw_extension = Some(value);
3312                }
3313                "modifierExtension" => {
3314                    raw_modifier_extension = Some(value);
3315                }
3316                "code" => {
3317                    raw_code = Some(value);
3318                }
3319                "_code" => {
3320                    raw_code_element = Some(value);
3321                }
3322                "documentation" => {
3323                    raw_documentation = Some(value);
3324                }
3325                "_documentation" => {
3326                    raw_documentation_element = Some(value);
3327                }
3328                other => {
3329                    return path.with(other, |path| {
3330                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3331                    });
3332                }
3333            }
3334        }
3335        let field_id = raw_id
3336            .map(|value| {
3337                path.with("id", |path| {
3338                    let value = super::super::codec::expect_single(value, path)?;
3339                    super::primitives::checked_string(
3340                        super::super::codec::expect_string(value, path)?,
3341                        path,
3342                    )
3343                })
3344            })
3345            .transpose()?;
3346        let mut field_extension = Vec::new();
3347        if let Some(raw) = raw_extension {
3348            for (index, value) in path
3349                .with("extension", |path| {
3350                    super::super::codec::expect_array(raw, path)
3351                })?
3352                .iter()
3353                .enumerate()
3354            {
3355                field_extension.push(path.with_index("extension", index, |path| {
3356                    super::super::codec::Json::from_json(
3357                        super::super::codec::expect_object(value, path)?,
3358                        path,
3359                    )
3360                })?);
3361            }
3362        }
3363        let mut field_modifier_extension = Vec::new();
3364        if let Some(raw) = raw_modifier_extension {
3365            for (index, value) in path
3366                .with("modifierExtension", |path| {
3367                    super::super::codec::expect_array(raw, path)
3368                })?
3369                .iter()
3370                .enumerate()
3371            {
3372                field_modifier_extension.push(path.with_index(
3373                    "modifierExtension",
3374                    index,
3375                    |path| {
3376                        super::super::codec::Json::from_json(
3377                            super::super::codec::expect_object(value, path)?,
3378                            path,
3379                        )
3380                    },
3381                )?);
3382            }
3383        }
3384        let field_code = path.with("code", |path| {
3385            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
3386        })?;
3387        let field_documentation = match (raw_documentation, raw_documentation_element) {
3388            (None, None) => None,
3389            (value, element) => Some(path.with("documentation", |path| {
3390                super::super::codec::Primitive::from_json_parts(value, element, path)
3391            })?),
3392        };
3393        Ok(Self {
3394            id: field_id,
3395            extension: field_extension,
3396            modifier_extension: field_modifier_extension,
3397            code: field_code,
3398            documentation: field_documentation,
3399        })
3400    }
3401}
3402
3403impl serde::Serialize for CapabilityStatementRestInteraction {
3404    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3405        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3406        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
3407        if let Some(item) = &self.documentation {
3408            super::super::codec::element_entry(&mut map, "_documentation", item)?;
3409        }
3410        super::super::codec::value_entry(&mut map, "code", &self.code)?;
3411        if let Some(item) = &self.documentation {
3412            super::super::codec::value_entry(&mut map, "documentation", item)?;
3413        }
3414        if !self.extension.is_empty() {
3415            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3416        }
3417        if let Some(v) = &self.id {
3418            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3419        }
3420        if !self.modifier_extension.is_empty() {
3421            serde::ser::SerializeMap::serialize_entry(
3422                &mut map,
3423                "modifierExtension",
3424                &self.modifier_extension,
3425            )?;
3426        }
3427        serde::ser::SerializeMap::end(map)
3428    }
3429}
3430
3431impl<'de> serde::Deserialize<'de> for CapabilityStatementRestInteraction {
3432    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3433        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3434        let mut path = super::super::codec::Path::root("CapabilityStatementRestInteraction");
3435        let object =
3436            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3437        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3438    }
3439}
3440
3441/// Resource served on the REST interface
3442///
3443/// A specification of the restful capabilities of the solution for a specific
3444/// resource type.
3445#[derive(Debug, Clone, Default, PartialEq, Eq)]
3446pub struct CapabilityStatementRestResource {
3447    /// Unique id for inter-element referencing
3448    ///
3449    /// Unique id for the element within a resource (for internal references). This
3450    /// may be any string value that does not contain spaces.
3451    pub id: Option<std::string::String>,
3452    /// Additional content defined by implementations
3453    ///
3454    /// May be used to represent additional information that is not part of the
3455    /// basic definition of the element. To make the use of extensions safe and
3456    /// manageable, there is a strict set of governance applied to the definition
3457    /// and use of extensions. Though any implementer can define an extension, there
3458    /// is a set of requirements that SHALL be met as part of the definition of the
3459    /// extension.
3460    pub extension: Vec<super::extension::Extension>,
3461    /// Extensions that cannot be ignored even if unrecognized
3462    ///
3463    /// May be used to represent additional information that is not part of the
3464    /// basic definition of the element and that modifies the understanding of the
3465    /// element in which it is contained and/or the understanding of the containing
3466    /// element's descendants. Usually modifier elements provide negation or
3467    /// qualification. To make the use of extensions safe and manageable, there is a
3468    /// strict set of governance applied to the definition and use of extensions.
3469    /// Though any implementer can define an extension, there is a set of
3470    /// requirements that SHALL be met as part of the definition of the extension.
3471    /// Applications processing a resource are required to check for modifier
3472    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3473    /// on Resource or DomainResource (including cannot change the meaning of
3474    /// modifierExtension itself).
3475    pub modifier_extension: Vec<super::extension::Extension>,
3476    /// A resource type that is supported
3477    ///
3478    /// A type of resource exposed via the restful interface.
3479    pub r#type: super::primitives::Code,
3480    /// Base System profile for all uses of resource
3481    ///
3482    /// A specification of the profile that describes the solution's overall support
3483    /// for the resource, including any constraints on cardinality, bindings,
3484    /// lengths or other limitations. See further discussion in \[Using
3485    /// Profiles\](profiling.html\#profile-uses).
3486    pub profile: Option<super::primitives::Canonical>,
3487    /// Profiles for use cases supported
3488    ///
3489    /// A list of profiles that represent different use cases supported by the
3490    /// system. For a server, "supported by the system" means the system
3491    /// hosts/produces a set of resources that are conformant to a particular
3492    /// profile, and allows clients that use its services to search using this
3493    /// profile and to find appropriate data. For a client, it means the system will
3494    /// search by this profile and process data according to the guidance implicit
3495    /// in the profile. See further discussion in \[Using
3496    /// Profiles\](profiling.html\#profile-uses).
3497    pub supported_profile: Vec<super::primitives::Canonical>,
3498    /// Additional information about the use of the resource type
3499    ///
3500    /// Additional information about the resource type used by the system.
3501    pub documentation: Option<super::primitives::Markdown>,
3502    /// What operations are supported?
3503    ///
3504    /// Identifies a restful operation supported by the solution.
3505    pub interaction: Vec<CapabilityStatementRestResourceInteraction>,
3506    /// no-version | versioned | versioned-update
3507    ///
3508    /// This field is set to no-version to specify that the system does not support
3509    /// (server) or use (client) versioning for this resource type. If this has some
3510    /// other value, the server must at least correctly track and populate the
3511    /// versionId meta-property on resources. If the value is 'versioned-update',
3512    /// then the server supports all the versioning features, including using e-tags
3513    /// for version integrity in the API.
3514    pub versioning: Option<super::primitives::Code>,
3515    /// Whether vRead can return past versions
3516    ///
3517    /// A flag for whether the server is able to return past versions as part of the
3518    /// vRead operation.
3519    pub read_history: Option<super::primitives::Boolean>,
3520    /// If update can commit to a new identity
3521    ///
3522    /// A flag to indicate that the server allows or needs to allow the client to
3523    /// create new identities on the server (that is, the client PUTs to a location
3524    /// where there is no existing resource). Allowing this operation means that the
3525    /// server allows the client to create new identities on the server.
3526    pub update_create: Option<super::primitives::Boolean>,
3527    /// If allows/uses conditional create
3528    ///
3529    /// A flag that indicates that the server supports conditional create.
3530    pub conditional_create: Option<super::primitives::Boolean>,
3531    /// not-supported | modified-since | not-match | full-support
3532    ///
3533    /// A code that indicates how the server supports conditional read.
3534    pub conditional_read: Option<super::primitives::Code>,
3535    /// If allows/uses conditional update
3536    ///
3537    /// A flag that indicates that the server supports conditional update.
3538    pub conditional_update: Option<super::primitives::Boolean>,
3539    /// not-supported | single | multiple - how conditional delete is supported
3540    ///
3541    /// A code that indicates how the server supports conditional delete.
3542    pub conditional_delete: Option<super::primitives::Code>,
3543    /// literal | logical | resolves | enforced | local
3544    ///
3545    /// A set of flags that defines how references are supported.
3546    pub reference_policy: Vec<super::primitives::Code>,
3547    /// \_include values supported by the server
3548    ///
3549    /// A list of \_include values supported by the server.
3550    pub search_include: Vec<super::primitives::String>,
3551    /// \_revinclude values supported by the server
3552    ///
3553    /// A list of \_revinclude (reverse include) values supported by the server.
3554    pub search_rev_include: Vec<super::primitives::String>,
3555    /// Search parameters supported by implementation
3556    ///
3557    /// Search parameters for implementations to support and/or make use of - either
3558    /// references to ones defined in the specification, or additional ones defined
3559    /// for/by the implementation.
3560    pub search_param: Vec<CapabilityStatementRestResourceSearchParam>,
3561    /// Definition of a resource operation
3562    ///
3563    /// Definition of an operation or a named query together with its parameters and
3564    /// their meaning and type. Consult the definition of the operation for details
3565    /// about how to invoke the operation, and the parameters.
3566    pub operation: Vec<CapabilityStatementRestResourceOperation>,
3567}
3568
3569impl super::super::codec::Json for CapabilityStatementRestResource {
3570    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3571        let mut object = super::super::codec::Object::new();
3572        if let Some(v) = &self.id {
3573            object.insert(
3574                std::string::String::from("id"),
3575                super::super::codec::Value::String(v.clone()),
3576            );
3577        }
3578        if !self.extension.is_empty() {
3579            let mut items = Vec::with_capacity(self.extension.len());
3580            for item in &self.extension {
3581                items.push(super::super::codec::Value::Object(
3582                    super::super::codec::Json::to_json(item)?,
3583                ));
3584            }
3585            object.insert(
3586                std::string::String::from("extension"),
3587                super::super::codec::Value::Array(items),
3588            );
3589        }
3590        if !self.modifier_extension.is_empty() {
3591            let mut items = Vec::with_capacity(self.modifier_extension.len());
3592            for item in &self.modifier_extension {
3593                items.push(super::super::codec::Value::Object(
3594                    super::super::codec::Json::to_json(item)?,
3595                ));
3596            }
3597            object.insert(
3598                std::string::String::from("modifierExtension"),
3599                super::super::codec::Value::Array(items),
3600            );
3601        }
3602        if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
3603            object.insert(std::string::String::from("type"), v);
3604        }
3605        if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
3606            object.insert(std::string::String::from("_type"), e);
3607        }
3608        if let Some(item) = &self.profile {
3609            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3610                object.insert(std::string::String::from("profile"), v);
3611            }
3612            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3613                object.insert(std::string::String::from("_profile"), e);
3614            }
3615        }
3616        if !self.supported_profile.is_empty() {
3617            let (values, elements) =
3618                super::super::codec::primitive_arrays(&self.supported_profile)?;
3619            if let Some(values) = values {
3620                object.insert(std::string::String::from("supportedProfile"), values);
3621            }
3622            if let Some(elements) = elements {
3623                object.insert(std::string::String::from("_supportedProfile"), elements);
3624            }
3625        }
3626        if let Some(item) = &self.documentation {
3627            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3628                object.insert(std::string::String::from("documentation"), v);
3629            }
3630            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3631                object.insert(std::string::String::from("_documentation"), e);
3632            }
3633        }
3634        if !self.interaction.is_empty() {
3635            let mut items = Vec::with_capacity(self.interaction.len());
3636            for item in &self.interaction {
3637                items.push(super::super::codec::Value::Object(
3638                    super::super::codec::Json::to_json(item)?,
3639                ));
3640            }
3641            object.insert(
3642                std::string::String::from("interaction"),
3643                super::super::codec::Value::Array(items),
3644            );
3645        }
3646        if let Some(item) = &self.versioning {
3647            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3648                object.insert(std::string::String::from("versioning"), v);
3649            }
3650            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3651                object.insert(std::string::String::from("_versioning"), e);
3652            }
3653        }
3654        if let Some(item) = &self.read_history {
3655            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3656                object.insert(std::string::String::from("readHistory"), v);
3657            }
3658            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3659                object.insert(std::string::String::from("_readHistory"), e);
3660            }
3661        }
3662        if let Some(item) = &self.update_create {
3663            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3664                object.insert(std::string::String::from("updateCreate"), v);
3665            }
3666            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3667                object.insert(std::string::String::from("_updateCreate"), e);
3668            }
3669        }
3670        if let Some(item) = &self.conditional_create {
3671            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3672                object.insert(std::string::String::from("conditionalCreate"), v);
3673            }
3674            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3675                object.insert(std::string::String::from("_conditionalCreate"), e);
3676            }
3677        }
3678        if let Some(item) = &self.conditional_read {
3679            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3680                object.insert(std::string::String::from("conditionalRead"), v);
3681            }
3682            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3683                object.insert(std::string::String::from("_conditionalRead"), e);
3684            }
3685        }
3686        if let Some(item) = &self.conditional_update {
3687            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3688                object.insert(std::string::String::from("conditionalUpdate"), v);
3689            }
3690            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3691                object.insert(std::string::String::from("_conditionalUpdate"), e);
3692            }
3693        }
3694        if let Some(item) = &self.conditional_delete {
3695            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3696                object.insert(std::string::String::from("conditionalDelete"), v);
3697            }
3698            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3699                object.insert(std::string::String::from("_conditionalDelete"), e);
3700            }
3701        }
3702        if !self.reference_policy.is_empty() {
3703            let (values, elements) = super::super::codec::primitive_arrays(&self.reference_policy)?;
3704            if let Some(values) = values {
3705                object.insert(std::string::String::from("referencePolicy"), values);
3706            }
3707            if let Some(elements) = elements {
3708                object.insert(std::string::String::from("_referencePolicy"), elements);
3709            }
3710        }
3711        if !self.search_include.is_empty() {
3712            let (values, elements) = super::super::codec::primitive_arrays(&self.search_include)?;
3713            if let Some(values) = values {
3714                object.insert(std::string::String::from("searchInclude"), values);
3715            }
3716            if let Some(elements) = elements {
3717                object.insert(std::string::String::from("_searchInclude"), elements);
3718            }
3719        }
3720        if !self.search_rev_include.is_empty() {
3721            let (values, elements) =
3722                super::super::codec::primitive_arrays(&self.search_rev_include)?;
3723            if let Some(values) = values {
3724                object.insert(std::string::String::from("searchRevInclude"), values);
3725            }
3726            if let Some(elements) = elements {
3727                object.insert(std::string::String::from("_searchRevInclude"), elements);
3728            }
3729        }
3730        if !self.search_param.is_empty() {
3731            let mut items = Vec::with_capacity(self.search_param.len());
3732            for item in &self.search_param {
3733                items.push(super::super::codec::Value::Object(
3734                    super::super::codec::Json::to_json(item)?,
3735                ));
3736            }
3737            object.insert(
3738                std::string::String::from("searchParam"),
3739                super::super::codec::Value::Array(items),
3740            );
3741        }
3742        if !self.operation.is_empty() {
3743            let mut items = Vec::with_capacity(self.operation.len());
3744            for item in &self.operation {
3745                items.push(super::super::codec::Value::Object(
3746                    super::super::codec::Json::to_json(item)?,
3747                ));
3748            }
3749            object.insert(
3750                std::string::String::from("operation"),
3751                super::super::codec::Value::Array(items),
3752            );
3753        }
3754        Ok(object)
3755    }
3756
3757    fn from_json(
3758        object: &super::super::codec::Object,
3759        path: &mut super::super::codec::Path,
3760    ) -> Result<Self, super::super::codec::DecodeError> {
3761        let mut raw_id: Option<&super::super::codec::Value> = None;
3762        let mut raw_extension: Option<&super::super::codec::Value> = None;
3763        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3764        let mut raw_type: Option<&super::super::codec::Value> = None;
3765        let mut raw_type_element: Option<&super::super::codec::Value> = None;
3766        let mut raw_profile: Option<&super::super::codec::Value> = None;
3767        let mut raw_profile_element: Option<&super::super::codec::Value> = None;
3768        let mut raw_supported_profile: Option<&super::super::codec::Value> = None;
3769        let mut raw_supported_profile_element: Option<&super::super::codec::Value> = None;
3770        let mut raw_documentation: Option<&super::super::codec::Value> = None;
3771        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
3772        let mut raw_interaction: Option<&super::super::codec::Value> = None;
3773        let mut raw_versioning: Option<&super::super::codec::Value> = None;
3774        let mut raw_versioning_element: Option<&super::super::codec::Value> = None;
3775        let mut raw_read_history: Option<&super::super::codec::Value> = None;
3776        let mut raw_read_history_element: Option<&super::super::codec::Value> = None;
3777        let mut raw_update_create: Option<&super::super::codec::Value> = None;
3778        let mut raw_update_create_element: Option<&super::super::codec::Value> = None;
3779        let mut raw_conditional_create: Option<&super::super::codec::Value> = None;
3780        let mut raw_conditional_create_element: Option<&super::super::codec::Value> = None;
3781        let mut raw_conditional_read: Option<&super::super::codec::Value> = None;
3782        let mut raw_conditional_read_element: Option<&super::super::codec::Value> = None;
3783        let mut raw_conditional_update: Option<&super::super::codec::Value> = None;
3784        let mut raw_conditional_update_element: Option<&super::super::codec::Value> = None;
3785        let mut raw_conditional_delete: Option<&super::super::codec::Value> = None;
3786        let mut raw_conditional_delete_element: Option<&super::super::codec::Value> = None;
3787        let mut raw_reference_policy: Option<&super::super::codec::Value> = None;
3788        let mut raw_reference_policy_element: Option<&super::super::codec::Value> = None;
3789        let mut raw_search_include: Option<&super::super::codec::Value> = None;
3790        let mut raw_search_include_element: Option<&super::super::codec::Value> = None;
3791        let mut raw_search_rev_include: Option<&super::super::codec::Value> = None;
3792        let mut raw_search_rev_include_element: Option<&super::super::codec::Value> = None;
3793        let mut raw_search_param: Option<&super::super::codec::Value> = None;
3794        let mut raw_operation: Option<&super::super::codec::Value> = None;
3795        for (key, value) in object {
3796            match key.as_str() {
3797                "id" => {
3798                    raw_id = Some(value);
3799                }
3800                "extension" => {
3801                    raw_extension = Some(value);
3802                }
3803                "modifierExtension" => {
3804                    raw_modifier_extension = Some(value);
3805                }
3806                "type" => {
3807                    raw_type = Some(value);
3808                }
3809                "_type" => {
3810                    raw_type_element = Some(value);
3811                }
3812                "profile" => {
3813                    raw_profile = Some(value);
3814                }
3815                "_profile" => {
3816                    raw_profile_element = Some(value);
3817                }
3818                "supportedProfile" => {
3819                    raw_supported_profile = Some(value);
3820                }
3821                "_supportedProfile" => {
3822                    raw_supported_profile_element = Some(value);
3823                }
3824                "documentation" => {
3825                    raw_documentation = Some(value);
3826                }
3827                "_documentation" => {
3828                    raw_documentation_element = Some(value);
3829                }
3830                "interaction" => {
3831                    raw_interaction = Some(value);
3832                }
3833                "versioning" => {
3834                    raw_versioning = Some(value);
3835                }
3836                "_versioning" => {
3837                    raw_versioning_element = Some(value);
3838                }
3839                "readHistory" => {
3840                    raw_read_history = Some(value);
3841                }
3842                "_readHistory" => {
3843                    raw_read_history_element = Some(value);
3844                }
3845                "updateCreate" => {
3846                    raw_update_create = Some(value);
3847                }
3848                "_updateCreate" => {
3849                    raw_update_create_element = Some(value);
3850                }
3851                "conditionalCreate" => {
3852                    raw_conditional_create = Some(value);
3853                }
3854                "_conditionalCreate" => {
3855                    raw_conditional_create_element = Some(value);
3856                }
3857                "conditionalRead" => {
3858                    raw_conditional_read = Some(value);
3859                }
3860                "_conditionalRead" => {
3861                    raw_conditional_read_element = Some(value);
3862                }
3863                "conditionalUpdate" => {
3864                    raw_conditional_update = Some(value);
3865                }
3866                "_conditionalUpdate" => {
3867                    raw_conditional_update_element = Some(value);
3868                }
3869                "conditionalDelete" => {
3870                    raw_conditional_delete = Some(value);
3871                }
3872                "_conditionalDelete" => {
3873                    raw_conditional_delete_element = Some(value);
3874                }
3875                "referencePolicy" => {
3876                    raw_reference_policy = Some(value);
3877                }
3878                "_referencePolicy" => {
3879                    raw_reference_policy_element = Some(value);
3880                }
3881                "searchInclude" => {
3882                    raw_search_include = Some(value);
3883                }
3884                "_searchInclude" => {
3885                    raw_search_include_element = Some(value);
3886                }
3887                "searchRevInclude" => {
3888                    raw_search_rev_include = Some(value);
3889                }
3890                "_searchRevInclude" => {
3891                    raw_search_rev_include_element = Some(value);
3892                }
3893                "searchParam" => {
3894                    raw_search_param = Some(value);
3895                }
3896                "operation" => {
3897                    raw_operation = Some(value);
3898                }
3899                other => {
3900                    return path.with(other, |path| {
3901                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3902                    });
3903                }
3904            }
3905        }
3906        let field_id = raw_id
3907            .map(|value| {
3908                path.with("id", |path| {
3909                    let value = super::super::codec::expect_single(value, path)?;
3910                    super::primitives::checked_string(
3911                        super::super::codec::expect_string(value, path)?,
3912                        path,
3913                    )
3914                })
3915            })
3916            .transpose()?;
3917        let mut field_extension = Vec::new();
3918        if let Some(raw) = raw_extension {
3919            for (index, value) in path
3920                .with("extension", |path| {
3921                    super::super::codec::expect_array(raw, path)
3922                })?
3923                .iter()
3924                .enumerate()
3925            {
3926                field_extension.push(path.with_index("extension", index, |path| {
3927                    super::super::codec::Json::from_json(
3928                        super::super::codec::expect_object(value, path)?,
3929                        path,
3930                    )
3931                })?);
3932            }
3933        }
3934        let mut field_modifier_extension = Vec::new();
3935        if let Some(raw) = raw_modifier_extension {
3936            for (index, value) in path
3937                .with("modifierExtension", |path| {
3938                    super::super::codec::expect_array(raw, path)
3939                })?
3940                .iter()
3941                .enumerate()
3942            {
3943                field_modifier_extension.push(path.with_index(
3944                    "modifierExtension",
3945                    index,
3946                    |path| {
3947                        super::super::codec::Json::from_json(
3948                            super::super::codec::expect_object(value, path)?,
3949                            path,
3950                        )
3951                    },
3952                )?);
3953            }
3954        }
3955        let field_type = path.with("type", |path| {
3956            super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
3957        })?;
3958        let field_profile = match (raw_profile, raw_profile_element) {
3959            (None, None) => None,
3960            (value, element) => Some(path.with("profile", |path| {
3961                super::super::codec::Primitive::from_json_parts(value, element, path)
3962            })?),
3963        };
3964        let mut field_supported_profile = Vec::new();
3965        for (index, (value, element)) in path
3966            .with("supportedProfile", |path| {
3967                super::super::codec::pair_arrays(
3968                    raw_supported_profile,
3969                    raw_supported_profile_element,
3970                    path,
3971                )
3972            })?
3973            .into_iter()
3974            .enumerate()
3975        {
3976            field_supported_profile.push(path.with_index("supportedProfile", index, |path| {
3977                super::super::codec::Primitive::from_json_parts(value, element, path)
3978            })?);
3979        }
3980        let field_documentation = match (raw_documentation, raw_documentation_element) {
3981            (None, None) => None,
3982            (value, element) => Some(path.with("documentation", |path| {
3983                super::super::codec::Primitive::from_json_parts(value, element, path)
3984            })?),
3985        };
3986        let mut field_interaction = Vec::new();
3987        if let Some(raw) = raw_interaction {
3988            for (index, value) in path
3989                .with("interaction", |path| {
3990                    super::super::codec::expect_array(raw, path)
3991                })?
3992                .iter()
3993                .enumerate()
3994            {
3995                field_interaction.push(path.with_index("interaction", index, |path| {
3996                    super::super::codec::Json::from_json(
3997                        super::super::codec::expect_object(value, path)?,
3998                        path,
3999                    )
4000                })?);
4001            }
4002        }
4003        let field_versioning = match (raw_versioning, raw_versioning_element) {
4004            (None, None) => None,
4005            (value, element) => Some(path.with("versioning", |path| {
4006                super::super::codec::Primitive::from_json_parts(value, element, path)
4007            })?),
4008        };
4009        let field_read_history = match (raw_read_history, raw_read_history_element) {
4010            (None, None) => None,
4011            (value, element) => Some(path.with("readHistory", |path| {
4012                super::super::codec::Primitive::from_json_parts(value, element, path)
4013            })?),
4014        };
4015        let field_update_create = match (raw_update_create, raw_update_create_element) {
4016            (None, None) => None,
4017            (value, element) => Some(path.with("updateCreate", |path| {
4018                super::super::codec::Primitive::from_json_parts(value, element, path)
4019            })?),
4020        };
4021        let field_conditional_create =
4022            match (raw_conditional_create, raw_conditional_create_element) {
4023                (None, None) => None,
4024                (value, element) => Some(path.with("conditionalCreate", |path| {
4025                    super::super::codec::Primitive::from_json_parts(value, element, path)
4026                })?),
4027            };
4028        let field_conditional_read = match (raw_conditional_read, raw_conditional_read_element) {
4029            (None, None) => None,
4030            (value, element) => Some(path.with("conditionalRead", |path| {
4031                super::super::codec::Primitive::from_json_parts(value, element, path)
4032            })?),
4033        };
4034        let field_conditional_update =
4035            match (raw_conditional_update, raw_conditional_update_element) {
4036                (None, None) => None,
4037                (value, element) => Some(path.with("conditionalUpdate", |path| {
4038                    super::super::codec::Primitive::from_json_parts(value, element, path)
4039                })?),
4040            };
4041        let field_conditional_delete =
4042            match (raw_conditional_delete, raw_conditional_delete_element) {
4043                (None, None) => None,
4044                (value, element) => Some(path.with("conditionalDelete", |path| {
4045                    super::super::codec::Primitive::from_json_parts(value, element, path)
4046                })?),
4047            };
4048        let mut field_reference_policy = Vec::new();
4049        for (index, (value, element)) in path
4050            .with("referencePolicy", |path| {
4051                super::super::codec::pair_arrays(
4052                    raw_reference_policy,
4053                    raw_reference_policy_element,
4054                    path,
4055                )
4056            })?
4057            .into_iter()
4058            .enumerate()
4059        {
4060            field_reference_policy.push(path.with_index("referencePolicy", index, |path| {
4061                super::super::codec::Primitive::from_json_parts(value, element, path)
4062            })?);
4063        }
4064        let mut field_search_include = Vec::new();
4065        for (index, (value, element)) in path
4066            .with("searchInclude", |path| {
4067                super::super::codec::pair_arrays(
4068                    raw_search_include,
4069                    raw_search_include_element,
4070                    path,
4071                )
4072            })?
4073            .into_iter()
4074            .enumerate()
4075        {
4076            field_search_include.push(path.with_index("searchInclude", index, |path| {
4077                super::super::codec::Primitive::from_json_parts(value, element, path)
4078            })?);
4079        }
4080        let mut field_search_rev_include = Vec::new();
4081        for (index, (value, element)) in path
4082            .with("searchRevInclude", |path| {
4083                super::super::codec::pair_arrays(
4084                    raw_search_rev_include,
4085                    raw_search_rev_include_element,
4086                    path,
4087                )
4088            })?
4089            .into_iter()
4090            .enumerate()
4091        {
4092            field_search_rev_include.push(path.with_index("searchRevInclude", index, |path| {
4093                super::super::codec::Primitive::from_json_parts(value, element, path)
4094            })?);
4095        }
4096        let mut field_search_param = Vec::new();
4097        if let Some(raw) = raw_search_param {
4098            for (index, value) in path
4099                .with("searchParam", |path| {
4100                    super::super::codec::expect_array(raw, path)
4101                })?
4102                .iter()
4103                .enumerate()
4104            {
4105                field_search_param.push(path.with_index("searchParam", index, |path| {
4106                    super::super::codec::Json::from_json(
4107                        super::super::codec::expect_object(value, path)?,
4108                        path,
4109                    )
4110                })?);
4111            }
4112        }
4113        let mut field_operation = Vec::new();
4114        if let Some(raw) = raw_operation {
4115            for (index, value) in path
4116                .with("operation", |path| {
4117                    super::super::codec::expect_array(raw, path)
4118                })?
4119                .iter()
4120                .enumerate()
4121            {
4122                field_operation.push(path.with_index("operation", index, |path| {
4123                    super::super::codec::Json::from_json(
4124                        super::super::codec::expect_object(value, path)?,
4125                        path,
4126                    )
4127                })?);
4128            }
4129        }
4130        Ok(Self {
4131            id: field_id,
4132            extension: field_extension,
4133            modifier_extension: field_modifier_extension,
4134            r#type: field_type,
4135            profile: field_profile,
4136            supported_profile: field_supported_profile,
4137            documentation: field_documentation,
4138            interaction: field_interaction,
4139            versioning: field_versioning,
4140            read_history: field_read_history,
4141            update_create: field_update_create,
4142            conditional_create: field_conditional_create,
4143            conditional_read: field_conditional_read,
4144            conditional_update: field_conditional_update,
4145            conditional_delete: field_conditional_delete,
4146            reference_policy: field_reference_policy,
4147            search_include: field_search_include,
4148            search_rev_include: field_search_rev_include,
4149            search_param: field_search_param,
4150            operation: field_operation,
4151        })
4152    }
4153}
4154
4155impl serde::Serialize for CapabilityStatementRestResource {
4156    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4157        let mut map = serde::Serializer::serialize_map(serializer, None)?;
4158        if let Some(item) = &self.conditional_create {
4159            super::super::codec::element_entry(&mut map, "_conditionalCreate", item)?;
4160        }
4161        if let Some(item) = &self.conditional_delete {
4162            super::super::codec::element_entry(&mut map, "_conditionalDelete", item)?;
4163        }
4164        if let Some(item) = &self.conditional_read {
4165            super::super::codec::element_entry(&mut map, "_conditionalRead", item)?;
4166        }
4167        if let Some(item) = &self.conditional_update {
4168            super::super::codec::element_entry(&mut map, "_conditionalUpdate", item)?;
4169        }
4170        if let Some(item) = &self.documentation {
4171            super::super::codec::element_entry(&mut map, "_documentation", item)?;
4172        }
4173        if let Some(item) = &self.profile {
4174            super::super::codec::element_entry(&mut map, "_profile", item)?;
4175        }
4176        if let Some(item) = &self.read_history {
4177            super::super::codec::element_entry(&mut map, "_readHistory", item)?;
4178        }
4179        super::super::codec::element_list_entry(
4180            &mut map,
4181            "_referencePolicy",
4182            &self.reference_policy,
4183        )?;
4184        super::super::codec::element_list_entry(&mut map, "_searchInclude", &self.search_include)?;
4185        super::super::codec::element_list_entry(
4186            &mut map,
4187            "_searchRevInclude",
4188            &self.search_rev_include,
4189        )?;
4190        super::super::codec::element_list_entry(
4191            &mut map,
4192            "_supportedProfile",
4193            &self.supported_profile,
4194        )?;
4195        super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
4196        if let Some(item) = &self.update_create {
4197            super::super::codec::element_entry(&mut map, "_updateCreate", item)?;
4198        }
4199        if let Some(item) = &self.versioning {
4200            super::super::codec::element_entry(&mut map, "_versioning", item)?;
4201        }
4202        if let Some(item) = &self.conditional_create {
4203            super::super::codec::value_entry(&mut map, "conditionalCreate", item)?;
4204        }
4205        if let Some(item) = &self.conditional_delete {
4206            super::super::codec::value_entry(&mut map, "conditionalDelete", item)?;
4207        }
4208        if let Some(item) = &self.conditional_read {
4209            super::super::codec::value_entry(&mut map, "conditionalRead", item)?;
4210        }
4211        if let Some(item) = &self.conditional_update {
4212            super::super::codec::value_entry(&mut map, "conditionalUpdate", item)?;
4213        }
4214        if let Some(item) = &self.documentation {
4215            super::super::codec::value_entry(&mut map, "documentation", item)?;
4216        }
4217        if !self.extension.is_empty() {
4218            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
4219        }
4220        if let Some(v) = &self.id {
4221            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
4222        }
4223        if !self.interaction.is_empty() {
4224            serde::ser::SerializeMap::serialize_entry(&mut map, "interaction", &self.interaction)?;
4225        }
4226        if !self.modifier_extension.is_empty() {
4227            serde::ser::SerializeMap::serialize_entry(
4228                &mut map,
4229                "modifierExtension",
4230                &self.modifier_extension,
4231            )?;
4232        }
4233        if !self.operation.is_empty() {
4234            serde::ser::SerializeMap::serialize_entry(&mut map, "operation", &self.operation)?;
4235        }
4236        if let Some(item) = &self.profile {
4237            super::super::codec::value_entry(&mut map, "profile", item)?;
4238        }
4239        if let Some(item) = &self.read_history {
4240            super::super::codec::value_entry(&mut map, "readHistory", item)?;
4241        }
4242        super::super::codec::value_list_entry(&mut map, "referencePolicy", &self.reference_policy)?;
4243        super::super::codec::value_list_entry(&mut map, "searchInclude", &self.search_include)?;
4244        if !self.search_param.is_empty() {
4245            serde::ser::SerializeMap::serialize_entry(&mut map, "searchParam", &self.search_param)?;
4246        }
4247        super::super::codec::value_list_entry(
4248            &mut map,
4249            "searchRevInclude",
4250            &self.search_rev_include,
4251        )?;
4252        super::super::codec::value_list_entry(
4253            &mut map,
4254            "supportedProfile",
4255            &self.supported_profile,
4256        )?;
4257        super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
4258        if let Some(item) = &self.update_create {
4259            super::super::codec::value_entry(&mut map, "updateCreate", item)?;
4260        }
4261        if let Some(item) = &self.versioning {
4262            super::super::codec::value_entry(&mut map, "versioning", item)?;
4263        }
4264        serde::ser::SerializeMap::end(map)
4265    }
4266}
4267
4268impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResource {
4269    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4270        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
4271        let mut path = super::super::codec::Path::root("CapabilityStatementRestResource");
4272        let object =
4273            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
4274        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
4275    }
4276}
4277
4278/// What operations are supported?
4279///
4280/// Identifies a restful operation supported by the solution.
4281#[derive(Debug, Clone, Default, PartialEq, Eq)]
4282pub struct CapabilityStatementRestResourceInteraction {
4283    /// Unique id for inter-element referencing
4284    ///
4285    /// Unique id for the element within a resource (for internal references). This
4286    /// may be any string value that does not contain spaces.
4287    pub id: Option<std::string::String>,
4288    /// Additional content defined by implementations
4289    ///
4290    /// May be used to represent additional information that is not part of the
4291    /// basic definition of the element. To make the use of extensions safe and
4292    /// manageable, there is a strict set of governance applied to the definition
4293    /// and use of extensions. Though any implementer can define an extension, there
4294    /// is a set of requirements that SHALL be met as part of the definition of the
4295    /// extension.
4296    pub extension: Vec<super::extension::Extension>,
4297    /// Extensions that cannot be ignored even if unrecognized
4298    ///
4299    /// May be used to represent additional information that is not part of the
4300    /// basic definition of the element and that modifies the understanding of the
4301    /// element in which it is contained and/or the understanding of the containing
4302    /// element's descendants. Usually modifier elements provide negation or
4303    /// qualification. To make the use of extensions safe and manageable, there is a
4304    /// strict set of governance applied to the definition and use of extensions.
4305    /// Though any implementer can define an extension, there is a set of
4306    /// requirements that SHALL be met as part of the definition of the extension.
4307    /// Applications processing a resource are required to check for modifier
4308    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
4309    /// on Resource or DomainResource (including cannot change the meaning of
4310    /// modifierExtension itself).
4311    pub modifier_extension: Vec<super::extension::Extension>,
4312    /// read | vread | update | patch | delete | history-instance | history-type |
4313    /// create | search-type
4314    ///
4315    /// Coded identifier of the operation, supported by the system resource.
4316    pub code: super::primitives::Code,
4317    /// Anything special about operation behavior
4318    ///
4319    /// Guidance specific to the implementation of this operation, such as 'delete
4320    /// is a logical delete' or 'updates are only allowed with version id' or
4321    /// 'creates permitted from pre-authorized certificates only'.
4322    pub documentation: Option<super::primitives::Markdown>,
4323}
4324
4325impl super::super::codec::Json for CapabilityStatementRestResourceInteraction {
4326    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
4327        let mut object = super::super::codec::Object::new();
4328        if let Some(v) = &self.id {
4329            object.insert(
4330                std::string::String::from("id"),
4331                super::super::codec::Value::String(v.clone()),
4332            );
4333        }
4334        if !self.extension.is_empty() {
4335            let mut items = Vec::with_capacity(self.extension.len());
4336            for item in &self.extension {
4337                items.push(super::super::codec::Value::Object(
4338                    super::super::codec::Json::to_json(item)?,
4339                ));
4340            }
4341            object.insert(
4342                std::string::String::from("extension"),
4343                super::super::codec::Value::Array(items),
4344            );
4345        }
4346        if !self.modifier_extension.is_empty() {
4347            let mut items = Vec::with_capacity(self.modifier_extension.len());
4348            for item in &self.modifier_extension {
4349                items.push(super::super::codec::Value::Object(
4350                    super::super::codec::Json::to_json(item)?,
4351                ));
4352            }
4353            object.insert(
4354                std::string::String::from("modifierExtension"),
4355                super::super::codec::Value::Array(items),
4356            );
4357        }
4358        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
4359            object.insert(std::string::String::from("code"), v);
4360        }
4361        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
4362            object.insert(std::string::String::from("_code"), e);
4363        }
4364        if let Some(item) = &self.documentation {
4365            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4366                object.insert(std::string::String::from("documentation"), v);
4367            }
4368            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4369                object.insert(std::string::String::from("_documentation"), e);
4370            }
4371        }
4372        Ok(object)
4373    }
4374
4375    fn from_json(
4376        object: &super::super::codec::Object,
4377        path: &mut super::super::codec::Path,
4378    ) -> Result<Self, super::super::codec::DecodeError> {
4379        let mut raw_id: Option<&super::super::codec::Value> = None;
4380        let mut raw_extension: Option<&super::super::codec::Value> = None;
4381        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
4382        let mut raw_code: Option<&super::super::codec::Value> = None;
4383        let mut raw_code_element: Option<&super::super::codec::Value> = None;
4384        let mut raw_documentation: Option<&super::super::codec::Value> = None;
4385        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
4386        for (key, value) in object {
4387            match key.as_str() {
4388                "id" => {
4389                    raw_id = Some(value);
4390                }
4391                "extension" => {
4392                    raw_extension = Some(value);
4393                }
4394                "modifierExtension" => {
4395                    raw_modifier_extension = Some(value);
4396                }
4397                "code" => {
4398                    raw_code = Some(value);
4399                }
4400                "_code" => {
4401                    raw_code_element = Some(value);
4402                }
4403                "documentation" => {
4404                    raw_documentation = Some(value);
4405                }
4406                "_documentation" => {
4407                    raw_documentation_element = Some(value);
4408                }
4409                other => {
4410                    return path.with(other, |path| {
4411                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
4412                    });
4413                }
4414            }
4415        }
4416        let field_id = raw_id
4417            .map(|value| {
4418                path.with("id", |path| {
4419                    let value = super::super::codec::expect_single(value, path)?;
4420                    super::primitives::checked_string(
4421                        super::super::codec::expect_string(value, path)?,
4422                        path,
4423                    )
4424                })
4425            })
4426            .transpose()?;
4427        let mut field_extension = Vec::new();
4428        if let Some(raw) = raw_extension {
4429            for (index, value) in path
4430                .with("extension", |path| {
4431                    super::super::codec::expect_array(raw, path)
4432                })?
4433                .iter()
4434                .enumerate()
4435            {
4436                field_extension.push(path.with_index("extension", index, |path| {
4437                    super::super::codec::Json::from_json(
4438                        super::super::codec::expect_object(value, path)?,
4439                        path,
4440                    )
4441                })?);
4442            }
4443        }
4444        let mut field_modifier_extension = Vec::new();
4445        if let Some(raw) = raw_modifier_extension {
4446            for (index, value) in path
4447                .with("modifierExtension", |path| {
4448                    super::super::codec::expect_array(raw, path)
4449                })?
4450                .iter()
4451                .enumerate()
4452            {
4453                field_modifier_extension.push(path.with_index(
4454                    "modifierExtension",
4455                    index,
4456                    |path| {
4457                        super::super::codec::Json::from_json(
4458                            super::super::codec::expect_object(value, path)?,
4459                            path,
4460                        )
4461                    },
4462                )?);
4463            }
4464        }
4465        let field_code = path.with("code", |path| {
4466            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
4467        })?;
4468        let field_documentation = match (raw_documentation, raw_documentation_element) {
4469            (None, None) => None,
4470            (value, element) => Some(path.with("documentation", |path| {
4471                super::super::codec::Primitive::from_json_parts(value, element, path)
4472            })?),
4473        };
4474        Ok(Self {
4475            id: field_id,
4476            extension: field_extension,
4477            modifier_extension: field_modifier_extension,
4478            code: field_code,
4479            documentation: field_documentation,
4480        })
4481    }
4482}
4483
4484impl serde::Serialize for CapabilityStatementRestResourceInteraction {
4485    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4486        let mut map = serde::Serializer::serialize_map(serializer, None)?;
4487        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
4488        if let Some(item) = &self.documentation {
4489            super::super::codec::element_entry(&mut map, "_documentation", item)?;
4490        }
4491        super::super::codec::value_entry(&mut map, "code", &self.code)?;
4492        if let Some(item) = &self.documentation {
4493            super::super::codec::value_entry(&mut map, "documentation", item)?;
4494        }
4495        if !self.extension.is_empty() {
4496            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
4497        }
4498        if let Some(v) = &self.id {
4499            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
4500        }
4501        if !self.modifier_extension.is_empty() {
4502            serde::ser::SerializeMap::serialize_entry(
4503                &mut map,
4504                "modifierExtension",
4505                &self.modifier_extension,
4506            )?;
4507        }
4508        serde::ser::SerializeMap::end(map)
4509    }
4510}
4511
4512impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResourceInteraction {
4513    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4514        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
4515        let mut path =
4516            super::super::codec::Path::root("CapabilityStatementRestResourceInteraction");
4517        let object =
4518            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
4519        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
4520    }
4521}
4522
4523/// Definition of a resource operation
4524///
4525/// Definition of an operation or a named query together with its parameters and
4526/// their meaning and type. Consult the definition of the operation for details
4527/// about how to invoke the operation, and the parameters.
4528#[derive(Debug, Clone, Default, PartialEq, Eq)]
4529pub struct CapabilityStatementRestResourceOperation {
4530    /// Unique id for inter-element referencing
4531    ///
4532    /// Unique id for the element within a resource (for internal references). This
4533    /// may be any string value that does not contain spaces.
4534    pub id: Option<std::string::String>,
4535    /// Additional content defined by implementations
4536    ///
4537    /// May be used to represent additional information that is not part of the
4538    /// basic definition of the element. To make the use of extensions safe and
4539    /// manageable, there is a strict set of governance applied to the definition
4540    /// and use of extensions. Though any implementer can define an extension, there
4541    /// is a set of requirements that SHALL be met as part of the definition of the
4542    /// extension.
4543    pub extension: Vec<super::extension::Extension>,
4544    /// Extensions that cannot be ignored even if unrecognized
4545    ///
4546    /// May be used to represent additional information that is not part of the
4547    /// basic definition of the element and that modifies the understanding of the
4548    /// element in which it is contained and/or the understanding of the containing
4549    /// element's descendants. Usually modifier elements provide negation or
4550    /// qualification. To make the use of extensions safe and manageable, there is a
4551    /// strict set of governance applied to the definition and use of extensions.
4552    /// Though any implementer can define an extension, there is a set of
4553    /// requirements that SHALL be met as part of the definition of the extension.
4554    /// Applications processing a resource are required to check for modifier
4555    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
4556    /// on Resource or DomainResource (including cannot change the meaning of
4557    /// modifierExtension itself).
4558    pub modifier_extension: Vec<super::extension::Extension>,
4559    /// Name by which the operation/query is invoked
4560    ///
4561    /// The name of the operation or query. For an operation, this is the name
4562    /// prefixed with $ and used in the URL. For a query, this is the name used in
4563    /// the \_query parameter when the query is called.
4564    pub name: super::primitives::String,
4565    /// The defined operation/query
4566    ///
4567    /// Where the formal definition can be found. If a server references the base
4568    /// definition of an Operation (i.e. from the specification itself such as
4569    /// \`\`\`<http://hl7.org/fhir/OperationDefinition/ValueSet-expand>\`\`\`), that
4570    /// means it supports the full capabilities of the operation - e.g. both GET and
4571    /// POST invocation. If it only supports a subset, it must define its own custom
4572    /// \[OperationDefinition\](operationdefinition.html\#) with a 'base' of the
4573    /// original OperationDefinition. The custom definition would describe the
4574    /// specific subset of functionality supported.
4575    pub definition: super::primitives::Canonical,
4576    /// Specific details about operation behavior
4577    ///
4578    /// Documentation that describes anything special about the operation behavior,
4579    /// possibly detailing different behavior for system, type and instance-level
4580    /// invocation of the operation.
4581    pub documentation: Option<super::primitives::Markdown>,
4582}
4583
4584impl super::super::codec::Json for CapabilityStatementRestResourceOperation {
4585    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
4586        let mut object = super::super::codec::Object::new();
4587        if let Some(v) = &self.id {
4588            object.insert(
4589                std::string::String::from("id"),
4590                super::super::codec::Value::String(v.clone()),
4591            );
4592        }
4593        if !self.extension.is_empty() {
4594            let mut items = Vec::with_capacity(self.extension.len());
4595            for item in &self.extension {
4596                items.push(super::super::codec::Value::Object(
4597                    super::super::codec::Json::to_json(item)?,
4598                ));
4599            }
4600            object.insert(
4601                std::string::String::from("extension"),
4602                super::super::codec::Value::Array(items),
4603            );
4604        }
4605        if !self.modifier_extension.is_empty() {
4606            let mut items = Vec::with_capacity(self.modifier_extension.len());
4607            for item in &self.modifier_extension {
4608                items.push(super::super::codec::Value::Object(
4609                    super::super::codec::Json::to_json(item)?,
4610                ));
4611            }
4612            object.insert(
4613                std::string::String::from("modifierExtension"),
4614                super::super::codec::Value::Array(items),
4615            );
4616        }
4617        if let Some(v) = super::super::codec::Primitive::value_json(&self.name)? {
4618            object.insert(std::string::String::from("name"), v);
4619        }
4620        if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
4621            object.insert(std::string::String::from("_name"), e);
4622        }
4623        if let Some(v) = super::super::codec::Primitive::value_json(&self.definition)? {
4624            object.insert(std::string::String::from("definition"), v);
4625        }
4626        if let Some(e) = super::super::codec::Primitive::element_json(&self.definition)? {
4627            object.insert(std::string::String::from("_definition"), e);
4628        }
4629        if let Some(item) = &self.documentation {
4630            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4631                object.insert(std::string::String::from("documentation"), v);
4632            }
4633            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4634                object.insert(std::string::String::from("_documentation"), e);
4635            }
4636        }
4637        Ok(object)
4638    }
4639
4640    fn from_json(
4641        object: &super::super::codec::Object,
4642        path: &mut super::super::codec::Path,
4643    ) -> Result<Self, super::super::codec::DecodeError> {
4644        let mut raw_id: Option<&super::super::codec::Value> = None;
4645        let mut raw_extension: Option<&super::super::codec::Value> = None;
4646        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
4647        let mut raw_name: Option<&super::super::codec::Value> = None;
4648        let mut raw_name_element: Option<&super::super::codec::Value> = None;
4649        let mut raw_definition: Option<&super::super::codec::Value> = None;
4650        let mut raw_definition_element: Option<&super::super::codec::Value> = None;
4651        let mut raw_documentation: Option<&super::super::codec::Value> = None;
4652        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
4653        for (key, value) in object {
4654            match key.as_str() {
4655                "id" => {
4656                    raw_id = Some(value);
4657                }
4658                "extension" => {
4659                    raw_extension = Some(value);
4660                }
4661                "modifierExtension" => {
4662                    raw_modifier_extension = Some(value);
4663                }
4664                "name" => {
4665                    raw_name = Some(value);
4666                }
4667                "_name" => {
4668                    raw_name_element = Some(value);
4669                }
4670                "definition" => {
4671                    raw_definition = Some(value);
4672                }
4673                "_definition" => {
4674                    raw_definition_element = Some(value);
4675                }
4676                "documentation" => {
4677                    raw_documentation = Some(value);
4678                }
4679                "_documentation" => {
4680                    raw_documentation_element = Some(value);
4681                }
4682                other => {
4683                    return path.with(other, |path| {
4684                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
4685                    });
4686                }
4687            }
4688        }
4689        let field_id = raw_id
4690            .map(|value| {
4691                path.with("id", |path| {
4692                    let value = super::super::codec::expect_single(value, path)?;
4693                    super::primitives::checked_string(
4694                        super::super::codec::expect_string(value, path)?,
4695                        path,
4696                    )
4697                })
4698            })
4699            .transpose()?;
4700        let mut field_extension = Vec::new();
4701        if let Some(raw) = raw_extension {
4702            for (index, value) in path
4703                .with("extension", |path| {
4704                    super::super::codec::expect_array(raw, path)
4705                })?
4706                .iter()
4707                .enumerate()
4708            {
4709                field_extension.push(path.with_index("extension", index, |path| {
4710                    super::super::codec::Json::from_json(
4711                        super::super::codec::expect_object(value, path)?,
4712                        path,
4713                    )
4714                })?);
4715            }
4716        }
4717        let mut field_modifier_extension = Vec::new();
4718        if let Some(raw) = raw_modifier_extension {
4719            for (index, value) in path
4720                .with("modifierExtension", |path| {
4721                    super::super::codec::expect_array(raw, path)
4722                })?
4723                .iter()
4724                .enumerate()
4725            {
4726                field_modifier_extension.push(path.with_index(
4727                    "modifierExtension",
4728                    index,
4729                    |path| {
4730                        super::super::codec::Json::from_json(
4731                            super::super::codec::expect_object(value, path)?,
4732                            path,
4733                        )
4734                    },
4735                )?);
4736            }
4737        }
4738        let field_name = path.with("name", |path| {
4739            super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
4740        })?;
4741        let field_definition = path.with("definition", |path| {
4742            super::super::codec::Primitive::from_json_parts(
4743                raw_definition,
4744                raw_definition_element,
4745                path,
4746            )
4747        })?;
4748        let field_documentation = match (raw_documentation, raw_documentation_element) {
4749            (None, None) => None,
4750            (value, element) => Some(path.with("documentation", |path| {
4751                super::super::codec::Primitive::from_json_parts(value, element, path)
4752            })?),
4753        };
4754        Ok(Self {
4755            id: field_id,
4756            extension: field_extension,
4757            modifier_extension: field_modifier_extension,
4758            name: field_name,
4759            definition: field_definition,
4760            documentation: field_documentation,
4761        })
4762    }
4763}
4764
4765impl serde::Serialize for CapabilityStatementRestResourceOperation {
4766    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4767        let mut map = serde::Serializer::serialize_map(serializer, None)?;
4768        super::super::codec::element_entry(&mut map, "_definition", &self.definition)?;
4769        if let Some(item) = &self.documentation {
4770            super::super::codec::element_entry(&mut map, "_documentation", item)?;
4771        }
4772        super::super::codec::element_entry(&mut map, "_name", &self.name)?;
4773        super::super::codec::value_entry(&mut map, "definition", &self.definition)?;
4774        if let Some(item) = &self.documentation {
4775            super::super::codec::value_entry(&mut map, "documentation", item)?;
4776        }
4777        if !self.extension.is_empty() {
4778            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
4779        }
4780        if let Some(v) = &self.id {
4781            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
4782        }
4783        if !self.modifier_extension.is_empty() {
4784            serde::ser::SerializeMap::serialize_entry(
4785                &mut map,
4786                "modifierExtension",
4787                &self.modifier_extension,
4788            )?;
4789        }
4790        super::super::codec::value_entry(&mut map, "name", &self.name)?;
4791        serde::ser::SerializeMap::end(map)
4792    }
4793}
4794
4795impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResourceOperation {
4796    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4797        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
4798        let mut path = super::super::codec::Path::root("CapabilityStatementRestResourceOperation");
4799        let object =
4800            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
4801        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
4802    }
4803}
4804
4805/// Search parameters supported by implementation
4806///
4807/// Search parameters for implementations to support and/or make use of - either
4808/// references to ones defined in the specification, or additional ones defined
4809/// for/by the implementation.
4810#[derive(Debug, Clone, Default, PartialEq, Eq)]
4811pub struct CapabilityStatementRestResourceSearchParam {
4812    /// Unique id for inter-element referencing
4813    ///
4814    /// Unique id for the element within a resource (for internal references). This
4815    /// may be any string value that does not contain spaces.
4816    pub id: Option<std::string::String>,
4817    /// Additional content defined by implementations
4818    ///
4819    /// May be used to represent additional information that is not part of the
4820    /// basic definition of the element. To make the use of extensions safe and
4821    /// manageable, there is a strict set of governance applied to the definition
4822    /// and use of extensions. Though any implementer can define an extension, there
4823    /// is a set of requirements that SHALL be met as part of the definition of the
4824    /// extension.
4825    pub extension: Vec<super::extension::Extension>,
4826    /// Extensions that cannot be ignored even if unrecognized
4827    ///
4828    /// May be used to represent additional information that is not part of the
4829    /// basic definition of the element and that modifies the understanding of the
4830    /// element in which it is contained and/or the understanding of the containing
4831    /// element's descendants. Usually modifier elements provide negation or
4832    /// qualification. To make the use of extensions safe and manageable, there is a
4833    /// strict set of governance applied to the definition and use of extensions.
4834    /// Though any implementer can define an extension, there is a set of
4835    /// requirements that SHALL be met as part of the definition of the extension.
4836    /// Applications processing a resource are required to check for modifier
4837    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
4838    /// on Resource or DomainResource (including cannot change the meaning of
4839    /// modifierExtension itself).
4840    pub modifier_extension: Vec<super::extension::Extension>,
4841    /// Name of search parameter
4842    ///
4843    /// The name of the search parameter used in the interface.
4844    pub name: super::primitives::String,
4845    /// Source of definition for parameter
4846    ///
4847    /// An absolute URI that is a formal reference to where this parameter was first
4848    /// defined, so that a client can be confident of the meaning of the search
4849    /// parameter (a reference to
4850    /// \[SearchParameter.url\](searchparameter-definitions.html\#SearchParameter.url)).
4851    /// This element SHALL be populated if the search parameter refers to a
4852    /// SearchParameter defined by the FHIR core specification or externally defined
4853    /// IGs.
4854    pub definition: Option<super::primitives::Canonical>,
4855    /// number | date | string | token | reference | composite | quantity | uri |
4856    /// special
4857    ///
4858    /// The type of value a search parameter refers to, and how the content is
4859    /// interpreted.
4860    pub r#type: super::primitives::Code,
4861    /// Server-specific usage
4862    ///
4863    /// This allows documentation of any distinct behaviors about how the search
4864    /// parameter is used. For example, text matching algorithms.
4865    pub documentation: Option<super::primitives::Markdown>,
4866}
4867
4868impl super::super::codec::Json for CapabilityStatementRestResourceSearchParam {
4869    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
4870        let mut object = super::super::codec::Object::new();
4871        if let Some(v) = &self.id {
4872            object.insert(
4873                std::string::String::from("id"),
4874                super::super::codec::Value::String(v.clone()),
4875            );
4876        }
4877        if !self.extension.is_empty() {
4878            let mut items = Vec::with_capacity(self.extension.len());
4879            for item in &self.extension {
4880                items.push(super::super::codec::Value::Object(
4881                    super::super::codec::Json::to_json(item)?,
4882                ));
4883            }
4884            object.insert(
4885                std::string::String::from("extension"),
4886                super::super::codec::Value::Array(items),
4887            );
4888        }
4889        if !self.modifier_extension.is_empty() {
4890            let mut items = Vec::with_capacity(self.modifier_extension.len());
4891            for item in &self.modifier_extension {
4892                items.push(super::super::codec::Value::Object(
4893                    super::super::codec::Json::to_json(item)?,
4894                ));
4895            }
4896            object.insert(
4897                std::string::String::from("modifierExtension"),
4898                super::super::codec::Value::Array(items),
4899            );
4900        }
4901        if let Some(v) = super::super::codec::Primitive::value_json(&self.name)? {
4902            object.insert(std::string::String::from("name"), v);
4903        }
4904        if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
4905            object.insert(std::string::String::from("_name"), e);
4906        }
4907        if let Some(item) = &self.definition {
4908            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4909                object.insert(std::string::String::from("definition"), v);
4910            }
4911            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4912                object.insert(std::string::String::from("_definition"), e);
4913            }
4914        }
4915        if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
4916            object.insert(std::string::String::from("type"), v);
4917        }
4918        if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
4919            object.insert(std::string::String::from("_type"), e);
4920        }
4921        if let Some(item) = &self.documentation {
4922            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4923                object.insert(std::string::String::from("documentation"), v);
4924            }
4925            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4926                object.insert(std::string::String::from("_documentation"), e);
4927            }
4928        }
4929        Ok(object)
4930    }
4931
4932    fn from_json(
4933        object: &super::super::codec::Object,
4934        path: &mut super::super::codec::Path,
4935    ) -> Result<Self, super::super::codec::DecodeError> {
4936        let mut raw_id: Option<&super::super::codec::Value> = None;
4937        let mut raw_extension: Option<&super::super::codec::Value> = None;
4938        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
4939        let mut raw_name: Option<&super::super::codec::Value> = None;
4940        let mut raw_name_element: Option<&super::super::codec::Value> = None;
4941        let mut raw_definition: Option<&super::super::codec::Value> = None;
4942        let mut raw_definition_element: Option<&super::super::codec::Value> = None;
4943        let mut raw_type: Option<&super::super::codec::Value> = None;
4944        let mut raw_type_element: Option<&super::super::codec::Value> = None;
4945        let mut raw_documentation: Option<&super::super::codec::Value> = None;
4946        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
4947        for (key, value) in object {
4948            match key.as_str() {
4949                "id" => {
4950                    raw_id = Some(value);
4951                }
4952                "extension" => {
4953                    raw_extension = Some(value);
4954                }
4955                "modifierExtension" => {
4956                    raw_modifier_extension = Some(value);
4957                }
4958                "name" => {
4959                    raw_name = Some(value);
4960                }
4961                "_name" => {
4962                    raw_name_element = Some(value);
4963                }
4964                "definition" => {
4965                    raw_definition = Some(value);
4966                }
4967                "_definition" => {
4968                    raw_definition_element = Some(value);
4969                }
4970                "type" => {
4971                    raw_type = Some(value);
4972                }
4973                "_type" => {
4974                    raw_type_element = Some(value);
4975                }
4976                "documentation" => {
4977                    raw_documentation = Some(value);
4978                }
4979                "_documentation" => {
4980                    raw_documentation_element = Some(value);
4981                }
4982                other => {
4983                    return path.with(other, |path| {
4984                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
4985                    });
4986                }
4987            }
4988        }
4989        let field_id = raw_id
4990            .map(|value| {
4991                path.with("id", |path| {
4992                    let value = super::super::codec::expect_single(value, path)?;
4993                    super::primitives::checked_string(
4994                        super::super::codec::expect_string(value, path)?,
4995                        path,
4996                    )
4997                })
4998            })
4999            .transpose()?;
5000        let mut field_extension = Vec::new();
5001        if let Some(raw) = raw_extension {
5002            for (index, value) in path
5003                .with("extension", |path| {
5004                    super::super::codec::expect_array(raw, path)
5005                })?
5006                .iter()
5007                .enumerate()
5008            {
5009                field_extension.push(path.with_index("extension", index, |path| {
5010                    super::super::codec::Json::from_json(
5011                        super::super::codec::expect_object(value, path)?,
5012                        path,
5013                    )
5014                })?);
5015            }
5016        }
5017        let mut field_modifier_extension = Vec::new();
5018        if let Some(raw) = raw_modifier_extension {
5019            for (index, value) in path
5020                .with("modifierExtension", |path| {
5021                    super::super::codec::expect_array(raw, path)
5022                })?
5023                .iter()
5024                .enumerate()
5025            {
5026                field_modifier_extension.push(path.with_index(
5027                    "modifierExtension",
5028                    index,
5029                    |path| {
5030                        super::super::codec::Json::from_json(
5031                            super::super::codec::expect_object(value, path)?,
5032                            path,
5033                        )
5034                    },
5035                )?);
5036            }
5037        }
5038        let field_name = path.with("name", |path| {
5039            super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
5040        })?;
5041        let field_definition = match (raw_definition, raw_definition_element) {
5042            (None, None) => None,
5043            (value, element) => Some(path.with("definition", |path| {
5044                super::super::codec::Primitive::from_json_parts(value, element, path)
5045            })?),
5046        };
5047        let field_type = path.with("type", |path| {
5048            super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
5049        })?;
5050        let field_documentation = match (raw_documentation, raw_documentation_element) {
5051            (None, None) => None,
5052            (value, element) => Some(path.with("documentation", |path| {
5053                super::super::codec::Primitive::from_json_parts(value, element, path)
5054            })?),
5055        };
5056        Ok(Self {
5057            id: field_id,
5058            extension: field_extension,
5059            modifier_extension: field_modifier_extension,
5060            name: field_name,
5061            definition: field_definition,
5062            r#type: field_type,
5063            documentation: field_documentation,
5064        })
5065    }
5066}
5067
5068impl serde::Serialize for CapabilityStatementRestResourceSearchParam {
5069    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5070        let mut map = serde::Serializer::serialize_map(serializer, None)?;
5071        if let Some(item) = &self.definition {
5072            super::super::codec::element_entry(&mut map, "_definition", item)?;
5073        }
5074        if let Some(item) = &self.documentation {
5075            super::super::codec::element_entry(&mut map, "_documentation", item)?;
5076        }
5077        super::super::codec::element_entry(&mut map, "_name", &self.name)?;
5078        super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
5079        if let Some(item) = &self.definition {
5080            super::super::codec::value_entry(&mut map, "definition", item)?;
5081        }
5082        if let Some(item) = &self.documentation {
5083            super::super::codec::value_entry(&mut map, "documentation", item)?;
5084        }
5085        if !self.extension.is_empty() {
5086            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
5087        }
5088        if let Some(v) = &self.id {
5089            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
5090        }
5091        if !self.modifier_extension.is_empty() {
5092            serde::ser::SerializeMap::serialize_entry(
5093                &mut map,
5094                "modifierExtension",
5095                &self.modifier_extension,
5096            )?;
5097        }
5098        super::super::codec::value_entry(&mut map, "name", &self.name)?;
5099        super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
5100        serde::ser::SerializeMap::end(map)
5101    }
5102}
5103
5104impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResourceSearchParam {
5105    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5106        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
5107        let mut path =
5108            super::super::codec::Path::root("CapabilityStatementRestResourceSearchParam");
5109        let object =
5110            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
5111        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
5112    }
5113}
5114
5115/// Information about security of implementation
5116///
5117/// Information about security implementation from an interface perspective -
5118/// what a client needs to know.
5119#[derive(Debug, Clone, Default, PartialEq, Eq)]
5120pub struct CapabilityStatementRestSecurity {
5121    /// Unique id for inter-element referencing
5122    ///
5123    /// Unique id for the element within a resource (for internal references). This
5124    /// may be any string value that does not contain spaces.
5125    pub id: Option<std::string::String>,
5126    /// Additional content defined by implementations
5127    ///
5128    /// May be used to represent additional information that is not part of the
5129    /// basic definition of the element. To make the use of extensions safe and
5130    /// manageable, there is a strict set of governance applied to the definition
5131    /// and use of extensions. Though any implementer can define an extension, there
5132    /// is a set of requirements that SHALL be met as part of the definition of the
5133    /// extension.
5134    pub extension: Vec<super::extension::Extension>,
5135    /// Extensions that cannot be ignored even if unrecognized
5136    ///
5137    /// May be used to represent additional information that is not part of the
5138    /// basic definition of the element and that modifies the understanding of the
5139    /// element in which it is contained and/or the understanding of the containing
5140    /// element's descendants. Usually modifier elements provide negation or
5141    /// qualification. To make the use of extensions safe and manageable, there is a
5142    /// strict set of governance applied to the definition and use of extensions.
5143    /// Though any implementer can define an extension, there is a set of
5144    /// requirements that SHALL be met as part of the definition of the extension.
5145    /// Applications processing a resource are required to check for modifier
5146    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
5147    /// on Resource or DomainResource (including cannot change the meaning of
5148    /// modifierExtension itself).
5149    pub modifier_extension: Vec<super::extension::Extension>,
5150    /// Adds CORS Headers (<http://enable-cors.org/>)
5151    ///
5152    /// Server adds CORS headers when responding to requests - this enables
5153    /// Javascript applications to use the server.
5154    pub cors: Option<super::primitives::Boolean>,
5155    /// OAuth | SMART-on-FHIR | NTLM | Basic | Kerberos | Certificates
5156    ///
5157    /// Types of security services that are supported/required by the system.
5158    pub service: Vec<super::codeable_concept::CodeableConcept>,
5159    /// General description of how security works.
5160    pub description: Option<super::primitives::Markdown>,
5161}
5162
5163impl super::super::codec::Json for CapabilityStatementRestSecurity {
5164    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
5165        let mut object = super::super::codec::Object::new();
5166        if let Some(v) = &self.id {
5167            object.insert(
5168                std::string::String::from("id"),
5169                super::super::codec::Value::String(v.clone()),
5170            );
5171        }
5172        if !self.extension.is_empty() {
5173            let mut items = Vec::with_capacity(self.extension.len());
5174            for item in &self.extension {
5175                items.push(super::super::codec::Value::Object(
5176                    super::super::codec::Json::to_json(item)?,
5177                ));
5178            }
5179            object.insert(
5180                std::string::String::from("extension"),
5181                super::super::codec::Value::Array(items),
5182            );
5183        }
5184        if !self.modifier_extension.is_empty() {
5185            let mut items = Vec::with_capacity(self.modifier_extension.len());
5186            for item in &self.modifier_extension {
5187                items.push(super::super::codec::Value::Object(
5188                    super::super::codec::Json::to_json(item)?,
5189                ));
5190            }
5191            object.insert(
5192                std::string::String::from("modifierExtension"),
5193                super::super::codec::Value::Array(items),
5194            );
5195        }
5196        if let Some(item) = &self.cors {
5197            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
5198                object.insert(std::string::String::from("cors"), v);
5199            }
5200            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
5201                object.insert(std::string::String::from("_cors"), e);
5202            }
5203        }
5204        if !self.service.is_empty() {
5205            let mut items = Vec::with_capacity(self.service.len());
5206            for item in &self.service {
5207                items.push(super::super::codec::Value::Object(
5208                    super::super::codec::Json::to_json(item)?,
5209                ));
5210            }
5211            object.insert(
5212                std::string::String::from("service"),
5213                super::super::codec::Value::Array(items),
5214            );
5215        }
5216        if let Some(item) = &self.description {
5217            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
5218                object.insert(std::string::String::from("description"), v);
5219            }
5220            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
5221                object.insert(std::string::String::from("_description"), e);
5222            }
5223        }
5224        Ok(object)
5225    }
5226
5227    fn from_json(
5228        object: &super::super::codec::Object,
5229        path: &mut super::super::codec::Path,
5230    ) -> Result<Self, super::super::codec::DecodeError> {
5231        let mut raw_id: Option<&super::super::codec::Value> = None;
5232        let mut raw_extension: Option<&super::super::codec::Value> = None;
5233        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
5234        let mut raw_cors: Option<&super::super::codec::Value> = None;
5235        let mut raw_cors_element: Option<&super::super::codec::Value> = None;
5236        let mut raw_service: Option<&super::super::codec::Value> = None;
5237        let mut raw_description: Option<&super::super::codec::Value> = None;
5238        let mut raw_description_element: Option<&super::super::codec::Value> = None;
5239        for (key, value) in object {
5240            match key.as_str() {
5241                "id" => {
5242                    raw_id = Some(value);
5243                }
5244                "extension" => {
5245                    raw_extension = Some(value);
5246                }
5247                "modifierExtension" => {
5248                    raw_modifier_extension = Some(value);
5249                }
5250                "cors" => {
5251                    raw_cors = Some(value);
5252                }
5253                "_cors" => {
5254                    raw_cors_element = Some(value);
5255                }
5256                "service" => {
5257                    raw_service = Some(value);
5258                }
5259                "description" => {
5260                    raw_description = Some(value);
5261                }
5262                "_description" => {
5263                    raw_description_element = Some(value);
5264                }
5265                other => {
5266                    return path.with(other, |path| {
5267                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
5268                    });
5269                }
5270            }
5271        }
5272        let field_id = raw_id
5273            .map(|value| {
5274                path.with("id", |path| {
5275                    let value = super::super::codec::expect_single(value, path)?;
5276                    super::primitives::checked_string(
5277                        super::super::codec::expect_string(value, path)?,
5278                        path,
5279                    )
5280                })
5281            })
5282            .transpose()?;
5283        let mut field_extension = Vec::new();
5284        if let Some(raw) = raw_extension {
5285            for (index, value) in path
5286                .with("extension", |path| {
5287                    super::super::codec::expect_array(raw, path)
5288                })?
5289                .iter()
5290                .enumerate()
5291            {
5292                field_extension.push(path.with_index("extension", index, |path| {
5293                    super::super::codec::Json::from_json(
5294                        super::super::codec::expect_object(value, path)?,
5295                        path,
5296                    )
5297                })?);
5298            }
5299        }
5300        let mut field_modifier_extension = Vec::new();
5301        if let Some(raw) = raw_modifier_extension {
5302            for (index, value) in path
5303                .with("modifierExtension", |path| {
5304                    super::super::codec::expect_array(raw, path)
5305                })?
5306                .iter()
5307                .enumerate()
5308            {
5309                field_modifier_extension.push(path.with_index(
5310                    "modifierExtension",
5311                    index,
5312                    |path| {
5313                        super::super::codec::Json::from_json(
5314                            super::super::codec::expect_object(value, path)?,
5315                            path,
5316                        )
5317                    },
5318                )?);
5319            }
5320        }
5321        let field_cors = match (raw_cors, raw_cors_element) {
5322            (None, None) => None,
5323            (value, element) => Some(path.with("cors", |path| {
5324                super::super::codec::Primitive::from_json_parts(value, element, path)
5325            })?),
5326        };
5327        let mut field_service = Vec::new();
5328        if let Some(raw) = raw_service {
5329            for (index, value) in path
5330                .with("service", |path| {
5331                    super::super::codec::expect_array(raw, path)
5332                })?
5333                .iter()
5334                .enumerate()
5335            {
5336                field_service.push(path.with_index("service", index, |path| {
5337                    super::super::codec::Json::from_json(
5338                        super::super::codec::expect_object(value, path)?,
5339                        path,
5340                    )
5341                })?);
5342            }
5343        }
5344        let field_description = match (raw_description, raw_description_element) {
5345            (None, None) => None,
5346            (value, element) => Some(path.with("description", |path| {
5347                super::super::codec::Primitive::from_json_parts(value, element, path)
5348            })?),
5349        };
5350        Ok(Self {
5351            id: field_id,
5352            extension: field_extension,
5353            modifier_extension: field_modifier_extension,
5354            cors: field_cors,
5355            service: field_service,
5356            description: field_description,
5357        })
5358    }
5359}
5360
5361impl serde::Serialize for CapabilityStatementRestSecurity {
5362    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5363        let mut map = serde::Serializer::serialize_map(serializer, None)?;
5364        if let Some(item) = &self.cors {
5365            super::super::codec::element_entry(&mut map, "_cors", item)?;
5366        }
5367        if let Some(item) = &self.description {
5368            super::super::codec::element_entry(&mut map, "_description", item)?;
5369        }
5370        if let Some(item) = &self.cors {
5371            super::super::codec::value_entry(&mut map, "cors", item)?;
5372        }
5373        if let Some(item) = &self.description {
5374            super::super::codec::value_entry(&mut map, "description", item)?;
5375        }
5376        if !self.extension.is_empty() {
5377            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
5378        }
5379        if let Some(v) = &self.id {
5380            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
5381        }
5382        if !self.modifier_extension.is_empty() {
5383            serde::ser::SerializeMap::serialize_entry(
5384                &mut map,
5385                "modifierExtension",
5386                &self.modifier_extension,
5387            )?;
5388        }
5389        if !self.service.is_empty() {
5390            serde::ser::SerializeMap::serialize_entry(&mut map, "service", &self.service)?;
5391        }
5392        serde::ser::SerializeMap::end(map)
5393    }
5394}
5395
5396impl<'de> serde::Deserialize<'de> for CapabilityStatementRestSecurity {
5397    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5398        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
5399        let mut path = super::super::codec::Path::root("CapabilityStatementRestSecurity");
5400        let object =
5401            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
5402        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
5403    }
5404}
5405
5406/// Software that is covered by this capability statement
5407///
5408/// Software that is covered by this capability statement. It is used when the
5409/// capability statement describes the capabilities of a particular software
5410/// version, independent of an installation.
5411#[derive(Debug, Clone, Default, PartialEq, Eq)]
5412pub struct CapabilityStatementSoftware {
5413    /// Unique id for inter-element referencing
5414    ///
5415    /// Unique id for the element within a resource (for internal references). This
5416    /// may be any string value that does not contain spaces.
5417    pub id: Option<std::string::String>,
5418    /// Additional content defined by implementations
5419    ///
5420    /// May be used to represent additional information that is not part of the
5421    /// basic definition of the element. To make the use of extensions safe and
5422    /// manageable, there is a strict set of governance applied to the definition
5423    /// and use of extensions. Though any implementer can define an extension, there
5424    /// is a set of requirements that SHALL be met as part of the definition of the
5425    /// extension.
5426    pub extension: Vec<super::extension::Extension>,
5427    /// Extensions that cannot be ignored even if unrecognized
5428    ///
5429    /// May be used to represent additional information that is not part of the
5430    /// basic definition of the element and that modifies the understanding of the
5431    /// element in which it is contained and/or the understanding of the containing
5432    /// element's descendants. Usually modifier elements provide negation or
5433    /// qualification. To make the use of extensions safe and manageable, there is a
5434    /// strict set of governance applied to the definition and use of extensions.
5435    /// Though any implementer can define an extension, there is a set of
5436    /// requirements that SHALL be met as part of the definition of the extension.
5437    /// Applications processing a resource are required to check for modifier
5438    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
5439    /// on Resource or DomainResource (including cannot change the meaning of
5440    /// modifierExtension itself).
5441    pub modifier_extension: Vec<super::extension::Extension>,
5442    /// A name the software is known by
5443    ///
5444    /// Name the software is known by.
5445    pub name: super::primitives::String,
5446    /// Version covered by this statement
5447    ///
5448    /// The version identifier for the software covered by this statement.
5449    pub version: Option<super::primitives::String>,
5450    /// Date this version was released
5451    ///
5452    /// Date this version of the software was released.
5453    pub release_date: Option<super::primitives::DateTime>,
5454}
5455
5456impl super::super::codec::Json for CapabilityStatementSoftware {
5457    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
5458        let mut object = super::super::codec::Object::new();
5459        if let Some(v) = &self.id {
5460            object.insert(
5461                std::string::String::from("id"),
5462                super::super::codec::Value::String(v.clone()),
5463            );
5464        }
5465        if !self.extension.is_empty() {
5466            let mut items = Vec::with_capacity(self.extension.len());
5467            for item in &self.extension {
5468                items.push(super::super::codec::Value::Object(
5469                    super::super::codec::Json::to_json(item)?,
5470                ));
5471            }
5472            object.insert(
5473                std::string::String::from("extension"),
5474                super::super::codec::Value::Array(items),
5475            );
5476        }
5477        if !self.modifier_extension.is_empty() {
5478            let mut items = Vec::with_capacity(self.modifier_extension.len());
5479            for item in &self.modifier_extension {
5480                items.push(super::super::codec::Value::Object(
5481                    super::super::codec::Json::to_json(item)?,
5482                ));
5483            }
5484            object.insert(
5485                std::string::String::from("modifierExtension"),
5486                super::super::codec::Value::Array(items),
5487            );
5488        }
5489        if let Some(v) = super::super::codec::Primitive::value_json(&self.name)? {
5490            object.insert(std::string::String::from("name"), v);
5491        }
5492        if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
5493            object.insert(std::string::String::from("_name"), e);
5494        }
5495        if let Some(item) = &self.version {
5496            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
5497                object.insert(std::string::String::from("version"), v);
5498            }
5499            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
5500                object.insert(std::string::String::from("_version"), e);
5501            }
5502        }
5503        if let Some(item) = &self.release_date {
5504            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
5505                object.insert(std::string::String::from("releaseDate"), v);
5506            }
5507            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
5508                object.insert(std::string::String::from("_releaseDate"), e);
5509            }
5510        }
5511        Ok(object)
5512    }
5513
5514    fn from_json(
5515        object: &super::super::codec::Object,
5516        path: &mut super::super::codec::Path,
5517    ) -> Result<Self, super::super::codec::DecodeError> {
5518        let mut raw_id: Option<&super::super::codec::Value> = None;
5519        let mut raw_extension: Option<&super::super::codec::Value> = None;
5520        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
5521        let mut raw_name: Option<&super::super::codec::Value> = None;
5522        let mut raw_name_element: Option<&super::super::codec::Value> = None;
5523        let mut raw_version: Option<&super::super::codec::Value> = None;
5524        let mut raw_version_element: Option<&super::super::codec::Value> = None;
5525        let mut raw_release_date: Option<&super::super::codec::Value> = None;
5526        let mut raw_release_date_element: Option<&super::super::codec::Value> = None;
5527        for (key, value) in object {
5528            match key.as_str() {
5529                "id" => {
5530                    raw_id = Some(value);
5531                }
5532                "extension" => {
5533                    raw_extension = Some(value);
5534                }
5535                "modifierExtension" => {
5536                    raw_modifier_extension = Some(value);
5537                }
5538                "name" => {
5539                    raw_name = Some(value);
5540                }
5541                "_name" => {
5542                    raw_name_element = Some(value);
5543                }
5544                "version" => {
5545                    raw_version = Some(value);
5546                }
5547                "_version" => {
5548                    raw_version_element = Some(value);
5549                }
5550                "releaseDate" => {
5551                    raw_release_date = Some(value);
5552                }
5553                "_releaseDate" => {
5554                    raw_release_date_element = Some(value);
5555                }
5556                other => {
5557                    return path.with(other, |path| {
5558                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
5559                    });
5560                }
5561            }
5562        }
5563        let field_id = raw_id
5564            .map(|value| {
5565                path.with("id", |path| {
5566                    let value = super::super::codec::expect_single(value, path)?;
5567                    super::primitives::checked_string(
5568                        super::super::codec::expect_string(value, path)?,
5569                        path,
5570                    )
5571                })
5572            })
5573            .transpose()?;
5574        let mut field_extension = Vec::new();
5575        if let Some(raw) = raw_extension {
5576            for (index, value) in path
5577                .with("extension", |path| {
5578                    super::super::codec::expect_array(raw, path)
5579                })?
5580                .iter()
5581                .enumerate()
5582            {
5583                field_extension.push(path.with_index("extension", index, |path| {
5584                    super::super::codec::Json::from_json(
5585                        super::super::codec::expect_object(value, path)?,
5586                        path,
5587                    )
5588                })?);
5589            }
5590        }
5591        let mut field_modifier_extension = Vec::new();
5592        if let Some(raw) = raw_modifier_extension {
5593            for (index, value) in path
5594                .with("modifierExtension", |path| {
5595                    super::super::codec::expect_array(raw, path)
5596                })?
5597                .iter()
5598                .enumerate()
5599            {
5600                field_modifier_extension.push(path.with_index(
5601                    "modifierExtension",
5602                    index,
5603                    |path| {
5604                        super::super::codec::Json::from_json(
5605                            super::super::codec::expect_object(value, path)?,
5606                            path,
5607                        )
5608                    },
5609                )?);
5610            }
5611        }
5612        let field_name = path.with("name", |path| {
5613            super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
5614        })?;
5615        let field_version = match (raw_version, raw_version_element) {
5616            (None, None) => None,
5617            (value, element) => Some(path.with("version", |path| {
5618                super::super::codec::Primitive::from_json_parts(value, element, path)
5619            })?),
5620        };
5621        let field_release_date = match (raw_release_date, raw_release_date_element) {
5622            (None, None) => None,
5623            (value, element) => Some(path.with("releaseDate", |path| {
5624                super::super::codec::Primitive::from_json_parts(value, element, path)
5625            })?),
5626        };
5627        Ok(Self {
5628            id: field_id,
5629            extension: field_extension,
5630            modifier_extension: field_modifier_extension,
5631            name: field_name,
5632            version: field_version,
5633            release_date: field_release_date,
5634        })
5635    }
5636}
5637
5638impl serde::Serialize for CapabilityStatementSoftware {
5639    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5640        let mut map = serde::Serializer::serialize_map(serializer, None)?;
5641        super::super::codec::element_entry(&mut map, "_name", &self.name)?;
5642        if let Some(item) = &self.release_date {
5643            super::super::codec::element_entry(&mut map, "_releaseDate", item)?;
5644        }
5645        if let Some(item) = &self.version {
5646            super::super::codec::element_entry(&mut map, "_version", item)?;
5647        }
5648        if !self.extension.is_empty() {
5649            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
5650        }
5651        if let Some(v) = &self.id {
5652            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
5653        }
5654        if !self.modifier_extension.is_empty() {
5655            serde::ser::SerializeMap::serialize_entry(
5656                &mut map,
5657                "modifierExtension",
5658                &self.modifier_extension,
5659            )?;
5660        }
5661        super::super::codec::value_entry(&mut map, "name", &self.name)?;
5662        if let Some(item) = &self.release_date {
5663            super::super::codec::value_entry(&mut map, "releaseDate", item)?;
5664        }
5665        if let Some(item) = &self.version {
5666            super::super::codec::value_entry(&mut map, "version", item)?;
5667        }
5668        serde::ser::SerializeMap::end(map)
5669    }
5670}
5671
5672impl<'de> serde::Deserialize<'de> for CapabilityStatementSoftware {
5673    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5674        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
5675        let mut path = super::super::codec::Path::root("CapabilityStatementSoftware");
5676        let object =
5677            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
5678        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
5679    }
5680}