Skip to main content

fhir_types/r6/
capability_statement.rs

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