Skip to main content

fhir_types/stu3/
capability_statement.rs

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