Skip to main content

fhir_types/r5/
capability_statement.rs

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