Skip to main content

fhir_types/r5/
terminology_capabilities.rs

1// @generated by fhir-codegen from hl7.fhir.r5.core 5.0.0. DO NOT EDIT.
2// Change the emitter (tools/fhir-codegen) and regenerate.
3// SPDX-FileCopyrightText: Cadasto B.V.
4// SPDX-License-Identifier: Apache-2.0
5//! A statement of system capabilities
6
7/// A statement of system capabilities
8///
9/// A TerminologyCapabilities resource documents a set of capabilities
10/// (behaviors) of a FHIR Terminology Server that may be used as a statement of
11/// actual server functionality or a statement of required or desired server
12/// implementation.
13#[derive(Debug, Clone, Default, PartialEq, Eq)]
14pub struct TerminologyCapabilities {
15    /// Logical id of this artifact
16    ///
17    /// The logical id of the resource, as used in the URL for the resource. Once
18    /// assigned, this value never changes.
19    pub id: Option<std::string::String>,
20    /// Metadata about the resource
21    ///
22    /// The metadata about the resource. This is content that is maintained by the
23    /// infrastructure. Changes to the content might not always be associated with
24    /// version changes to the resource.
25    pub meta: Option<super::meta::Meta>,
26    /// A set of rules under which this content was created
27    ///
28    /// A reference to a set of rules that were followed when the resource was
29    /// constructed, and which must be understood when processing the content.
30    /// Often, this is a reference to an implementation guide that defines the
31    /// special rules along with other profiles etc.
32    pub implicit_rules: Option<super::primitives::Uri>,
33    /// Language of the resource content
34    ///
35    /// The base language in which the resource is written.
36    pub language: Option<super::primitives::Code>,
37    /// Text summary of the resource, for human interpretation
38    ///
39    /// A human-readable narrative that contains a summary of the resource and can
40    /// be used to represent the content of the resource to a human. The narrative
41    /// need not encode all the structured data, but is required to contain
42    /// sufficient detail to make it "clinically safe" for a human to just read the
43    /// narrative. Resource definitions may define what content should be
44    /// represented in the narrative to ensure clinical safety.
45    pub text: Option<super::narrative::Narrative>,
46    /// Contained, inline Resources
47    ///
48    /// These resources do not have an independent existence apart from the resource
49    /// that contains them - they cannot be identified independently, nor can they
50    /// have their own independent transaction scope. This is allowed to be a
51    /// Parameters resource if and only if it is referenced by a resource that
52    /// provides context/meaning.
53    pub contained: Vec<super::resource::Resource>,
54    /// Additional content defined by implementations
55    ///
56    /// May be used to represent additional information that is not part of the
57    /// basic definition of the resource. To make the use of extensions safe and
58    /// managable, there is a strict set of governance applied to the definition and
59    /// use of extensions. Though any implementer can define an extension, there is
60    /// a set of requirements that SHALL be met as part of the definition of the
61    /// extension.
62    pub extension: Vec<super::extension::Extension>,
63    /// Extensions that cannot be ignored
64    ///
65    /// May be used to represent additional information that is not part of the
66    /// basic definition of the resource and that modifies the understanding of the
67    /// element that contains it and/or the understanding of the containing
68    /// element's descendants. Usually modifier elements provide negation or
69    /// qualification. To make the use of extensions safe and managable, there is a
70    /// strict set of governance applied to the definition and use of extensions.
71    /// Though any implementer is allowed to define an extension, there is a set of
72    /// requirements that SHALL be met as part of the definition of the extension.
73    /// Applications processing a resource are required to check for modifier
74    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
75    /// on Resource or DomainResource (including cannot change the meaning of
76    /// modifierExtension itself).
77    pub modifier_extension: Vec<super::extension::Extension>,
78    /// Canonical identifier for this terminology capabilities, represented as a URI
79    /// (globally unique)
80    ///
81    /// An absolute URI that is used to identify this terminology capabilities when
82    /// it is referenced in a specification, model, design or an instance; also
83    /// called its canonical identifier. This SHOULD be globally unique and SHOULD
84    /// be a literal address at which an authoritative instance of this terminology
85    /// capabilities is (or will be) published. This URL can be the target of a
86    /// canonical reference. It SHALL remain the same when the terminology
87    /// capabilities is stored on different servers.
88    pub url: Option<super::primitives::Uri>,
89    /// Additional identifier for the terminology capabilities
90    ///
91    /// A formal identifier that is used to identify this terminology capabilities
92    /// when it is represented in other formats, or referenced in a specification,
93    /// model, design or an instance.
94    pub identifier: Vec<super::identifier::Identifier>,
95    /// Business version of the terminology capabilities
96    ///
97    /// The identifier that is used to identify this version of the terminology
98    /// capabilities when it is referenced in a specification, model, design or
99    /// instance. This is an arbitrary value managed by the terminology capabilities
100    /// author and is not expected to be globally unique. For example, it might be a
101    /// timestamp (e.g. yyyymmdd) if a managed version is not available. There is
102    /// also no expectation that versions can be placed in a lexicographical
103    /// sequence.
104    pub version: Option<super::primitives::String>,
105    /// How to compare versions
106    ///
107    /// Indicates the mechanism used to compare versions to determine which is more
108    /// current.
109    pub version_algorithm: Option<TerminologyCapabilitiesVersionAlgorithm>,
110    /// Name for this terminology capabilities (computer friendly)
111    ///
112    /// A natural language name identifying the terminology capabilities. This name
113    /// should be usable as an identifier for the module by machine processing
114    /// applications such as code generation.
115    pub name: Option<super::primitives::String>,
116    /// Name for this terminology capabilities (human friendly)
117    ///
118    /// A short, descriptive, user-friendly title for the terminology capabilities.
119    pub title: Option<super::primitives::String>,
120    /// draft | active | retired | unknown
121    ///
122    /// The status of this terminology capabilities. Enables tracking the life-cycle
123    /// of the content.
124    pub status: super::primitives::Code,
125    /// For testing purposes, not real usage
126    ///
127    /// A Boolean value to indicate that this terminology capabilities is authored
128    /// for testing purposes (or education/evaluation/marketing) and is not intended
129    /// to be used for genuine usage.
130    pub experimental: Option<super::primitives::Boolean>,
131    /// Date last changed
132    ///
133    /// The date (and optionally time) when the terminology capabilities was last
134    /// significantly changed. The date must change when the business version
135    /// changes and it must change if the status code changes. In addition, it
136    /// should change when the substantive content of the terminology capabilities
137    /// changes.
138    pub date: super::primitives::DateTime,
139    /// Name of the publisher/steward (organization or individual)
140    ///
141    /// The name of the organization or individual responsible for the release and
142    /// ongoing maintenance of the terminology capabilities.
143    pub publisher: Option<super::primitives::String>,
144    /// Contact details for the publisher
145    ///
146    /// Contact details to assist a user in finding and communicating with the
147    /// publisher.
148    pub contact: Vec<super::contact_detail::ContactDetail>,
149    /// Natural language description of the terminology capabilities
150    ///
151    /// A free text natural language description of the terminology capabilities
152    /// from a consumer's perspective. Typically, this is used when the capability
153    /// statement describes a desired rather than an actual solution, for example as
154    /// a formal expression of requirements as part of an RFP.
155    pub description: Option<super::primitives::Markdown>,
156    /// The context that the content is intended to support
157    ///
158    /// The content was developed with a focus and intent of supporting the contexts
159    /// that are listed. These contexts may be general categories (gender, age, ...)
160    /// or may be references to specific programs (insurance plans, studies, ...)
161    /// and may be used to assist with indexing and searching for appropriate
162    /// terminology capabilities instances.
163    pub use_context: Vec<super::usage_context::UsageContext>,
164    /// Intended jurisdiction for terminology capabilities (if applicable)
165    ///
166    /// A legal or geographic region in which the terminology capabilities is
167    /// intended to be used.
168    pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
169    /// Why this terminology capabilities is defined
170    ///
171    /// Explanation of why this terminology capabilities is needed and why it has
172    /// been designed as it has.
173    pub purpose: Option<super::primitives::Markdown>,
174    /// Use and/or publishing restrictions
175    ///
176    /// A copyright statement relating to the terminology capabilities and/or its
177    /// contents. Copyright statements are generally legal restrictions on the use
178    /// and publishing of the terminology capabilities.
179    pub copyright: Option<super::primitives::Markdown>,
180    /// Copyright holder and year(s)
181    ///
182    /// A short string (\<50 characters), suitable for inclusion in a page footer
183    /// that identifies the copyright holder, effective period, and optionally
184    /// whether rights are resctricted. (e.g. 'All rights reserved', 'Some rights
185    /// reserved').
186    pub copyright_label: Option<super::primitives::String>,
187    /// instance | capability | requirements
188    ///
189    /// The way that this statement is intended to be used, to describe an actual
190    /// running instance of software, a particular product (kind, not instance of
191    /// software) or a class of implementation (e.g. a desired purchase).
192    pub kind: super::primitives::Code,
193    /// Software that is covered by this terminology capability statement
194    ///
195    /// Software that is covered by this terminology capability statement. It is
196    /// used when the statement describes the capabilities of a particular software
197    /// version, independent of an installation.
198    pub software: Option<TerminologyCapabilitiesSoftware>,
199    /// If this describes a specific instance
200    ///
201    /// Identifies a specific implementation instance that is described by the
202    /// terminology capability statement - i.e. a particular installation, rather
203    /// than the capabilities of a software program.
204    pub implementation: Option<TerminologyCapabilitiesImplementation>,
205    /// Whether lockedDate is supported
206    ///
207    /// Whether the server supports lockedDate.
208    pub locked_date: Option<super::primitives::Boolean>,
209    /// A code system supported by the server
210    ///
211    /// Identifies a code system that is supported by the server. If there is a no
212    /// code system URL, then this declares the general assumptions a client can
213    /// make about support for any CodeSystem resource.
214    pub code_system: Vec<TerminologyCapabilitiesCodeSystem>,
215    /// Information about the \[ValueSet/$expand\](valueset-operation-expand.html)
216    /// operation.
217    pub expansion: Option<TerminologyCapabilitiesExpansion>,
218    /// in-compose | in-expansion | in-compose-or-expansion
219    ///
220    /// The degree to which the server supports the code search parameter on
221    /// ValueSet, if it is supported.
222    pub code_search: Option<super::primitives::Code>,
223    /// Information about the
224    /// \[ValueSet/$validate-code\](valueset-operation-validate-code.html)
225    /// operation.
226    pub validate_code: Option<TerminologyCapabilitiesValidateCode>,
227    /// Information about the
228    /// \[ConceptMap/$translate\](conceptmap-operation-translate.html) operation.
229    pub translation: Option<TerminologyCapabilitiesTranslation>,
230    /// Information about the
231    /// \[ConceptMap/$closure\](conceptmap-operation-closure.html) operation
232    ///
233    /// Whether the $closure operation is supported.
234    pub closure: Option<TerminologyCapabilitiesClosure>,
235}
236
237impl super::super::codec::Json for TerminologyCapabilities {
238    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
239        let mut object = super::super::codec::Object::new();
240        object.insert(
241            std::string::String::from("resourceType"),
242            super::super::codec::Value::String(std::string::String::from(
243                "TerminologyCapabilities",
244            )),
245        );
246        if let Some(v) = &self.id {
247            object.insert(
248                std::string::String::from("id"),
249                super::super::codec::Value::String(v.clone()),
250            );
251        }
252        if let Some(item) = &self.meta {
253            object.insert(
254                std::string::String::from("meta"),
255                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
256            );
257        }
258        if let Some(item) = &self.implicit_rules {
259            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
260                object.insert(std::string::String::from("implicitRules"), v);
261            }
262            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
263                object.insert(std::string::String::from("_implicitRules"), e);
264            }
265        }
266        if let Some(item) = &self.language {
267            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
268                object.insert(std::string::String::from("language"), v);
269            }
270            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
271                object.insert(std::string::String::from("_language"), e);
272            }
273        }
274        if let Some(item) = &self.text {
275            object.insert(
276                std::string::String::from("text"),
277                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
278            );
279        }
280        if !self.contained.is_empty() {
281            let mut items = Vec::with_capacity(self.contained.len());
282            for item in &self.contained {
283                items.push(super::super::codec::Value::Object(
284                    super::super::codec::Json::to_json(item)?,
285                ));
286            }
287            object.insert(
288                std::string::String::from("contained"),
289                super::super::codec::Value::Array(items),
290            );
291        }
292        if !self.extension.is_empty() {
293            let mut items = Vec::with_capacity(self.extension.len());
294            for item in &self.extension {
295                items.push(super::super::codec::Value::Object(
296                    super::super::codec::Json::to_json(item)?,
297                ));
298            }
299            object.insert(
300                std::string::String::from("extension"),
301                super::super::codec::Value::Array(items),
302            );
303        }
304        if !self.modifier_extension.is_empty() {
305            let mut items = Vec::with_capacity(self.modifier_extension.len());
306            for item in &self.modifier_extension {
307                items.push(super::super::codec::Value::Object(
308                    super::super::codec::Json::to_json(item)?,
309                ));
310            }
311            object.insert(
312                std::string::String::from("modifierExtension"),
313                super::super::codec::Value::Array(items),
314            );
315        }
316        if let Some(item) = &self.url {
317            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
318                object.insert(std::string::String::from("url"), v);
319            }
320            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
321                object.insert(std::string::String::from("_url"), e);
322            }
323        }
324        if !self.identifier.is_empty() {
325            let mut items = Vec::with_capacity(self.identifier.len());
326            for item in &self.identifier {
327                items.push(super::super::codec::Value::Object(
328                    super::super::codec::Json::to_json(item)?,
329                ));
330            }
331            object.insert(
332                std::string::String::from("identifier"),
333                super::super::codec::Value::Array(items),
334            );
335        }
336        if let Some(item) = &self.version {
337            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
338                object.insert(std::string::String::from("version"), v);
339            }
340            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
341                object.insert(std::string::String::from("_version"), e);
342            }
343        }
344        if let Some(item) = &self.version_algorithm {
345            let (suffix, value, element) = item.to_json_parts()?;
346            if let Some(value) = value {
347                object.insert(format!("versionAlgorithm{suffix}"), value);
348            }
349            if let Some(element) = element {
350                object.insert(format!("_versionAlgorithm{suffix}"), element);
351            }
352        }
353        if let Some(item) = &self.name {
354            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
355                object.insert(std::string::String::from("name"), v);
356            }
357            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
358                object.insert(std::string::String::from("_name"), e);
359            }
360        }
361        if let Some(item) = &self.title {
362            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
363                object.insert(std::string::String::from("title"), v);
364            }
365            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
366                object.insert(std::string::String::from("_title"), e);
367            }
368        }
369        if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
370            object.insert(std::string::String::from("status"), v);
371        }
372        if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
373            object.insert(std::string::String::from("_status"), e);
374        }
375        if let Some(item) = &self.experimental {
376            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
377                object.insert(std::string::String::from("experimental"), v);
378            }
379            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
380                object.insert(std::string::String::from("_experimental"), e);
381            }
382        }
383        if let Some(v) = super::super::codec::Primitive::value_json(&self.date)? {
384            object.insert(std::string::String::from("date"), v);
385        }
386        if let Some(e) = super::super::codec::Primitive::element_json(&self.date)? {
387            object.insert(std::string::String::from("_date"), e);
388        }
389        if let Some(item) = &self.publisher {
390            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
391                object.insert(std::string::String::from("publisher"), v);
392            }
393            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
394                object.insert(std::string::String::from("_publisher"), e);
395            }
396        }
397        if !self.contact.is_empty() {
398            let mut items = Vec::with_capacity(self.contact.len());
399            for item in &self.contact {
400                items.push(super::super::codec::Value::Object(
401                    super::super::codec::Json::to_json(item)?,
402                ));
403            }
404            object.insert(
405                std::string::String::from("contact"),
406                super::super::codec::Value::Array(items),
407            );
408        }
409        if let Some(item) = &self.description {
410            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
411                object.insert(std::string::String::from("description"), v);
412            }
413            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
414                object.insert(std::string::String::from("_description"), e);
415            }
416        }
417        if !self.use_context.is_empty() {
418            let mut items = Vec::with_capacity(self.use_context.len());
419            for item in &self.use_context {
420                items.push(super::super::codec::Value::Object(
421                    super::super::codec::Json::to_json(item)?,
422                ));
423            }
424            object.insert(
425                std::string::String::from("useContext"),
426                super::super::codec::Value::Array(items),
427            );
428        }
429        if !self.jurisdiction.is_empty() {
430            let mut items = Vec::with_capacity(self.jurisdiction.len());
431            for item in &self.jurisdiction {
432                items.push(super::super::codec::Value::Object(
433                    super::super::codec::Json::to_json(item)?,
434                ));
435            }
436            object.insert(
437                std::string::String::from("jurisdiction"),
438                super::super::codec::Value::Array(items),
439            );
440        }
441        if let Some(item) = &self.purpose {
442            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
443                object.insert(std::string::String::from("purpose"), v);
444            }
445            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
446                object.insert(std::string::String::from("_purpose"), e);
447            }
448        }
449        if let Some(item) = &self.copyright {
450            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
451                object.insert(std::string::String::from("copyright"), v);
452            }
453            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
454                object.insert(std::string::String::from("_copyright"), e);
455            }
456        }
457        if let Some(item) = &self.copyright_label {
458            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
459                object.insert(std::string::String::from("copyrightLabel"), v);
460            }
461            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
462                object.insert(std::string::String::from("_copyrightLabel"), e);
463            }
464        }
465        if let Some(v) = super::super::codec::Primitive::value_json(&self.kind)? {
466            object.insert(std::string::String::from("kind"), v);
467        }
468        if let Some(e) = super::super::codec::Primitive::element_json(&self.kind)? {
469            object.insert(std::string::String::from("_kind"), e);
470        }
471        if let Some(item) = &self.software {
472            object.insert(
473                std::string::String::from("software"),
474                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
475            );
476        }
477        if let Some(item) = &self.implementation {
478            object.insert(
479                std::string::String::from("implementation"),
480                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
481            );
482        }
483        if let Some(item) = &self.locked_date {
484            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
485                object.insert(std::string::String::from("lockedDate"), v);
486            }
487            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
488                object.insert(std::string::String::from("_lockedDate"), e);
489            }
490        }
491        if !self.code_system.is_empty() {
492            let mut items = Vec::with_capacity(self.code_system.len());
493            for item in &self.code_system {
494                items.push(super::super::codec::Value::Object(
495                    super::super::codec::Json::to_json(item)?,
496                ));
497            }
498            object.insert(
499                std::string::String::from("codeSystem"),
500                super::super::codec::Value::Array(items),
501            );
502        }
503        if let Some(item) = &self.expansion {
504            object.insert(
505                std::string::String::from("expansion"),
506                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
507            );
508        }
509        if let Some(item) = &self.code_search {
510            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
511                object.insert(std::string::String::from("codeSearch"), v);
512            }
513            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
514                object.insert(std::string::String::from("_codeSearch"), e);
515            }
516        }
517        if let Some(item) = &self.validate_code {
518            object.insert(
519                std::string::String::from("validateCode"),
520                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
521            );
522        }
523        if let Some(item) = &self.translation {
524            object.insert(
525                std::string::String::from("translation"),
526                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
527            );
528        }
529        if let Some(item) = &self.closure {
530            object.insert(
531                std::string::String::from("closure"),
532                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
533            );
534        }
535        Ok(object)
536    }
537
538    fn from_json(
539        object: &super::super::codec::Object,
540        path: &mut super::super::codec::Path,
541    ) -> Result<Self, super::super::codec::DecodeError> {
542        let mut raw_id: Option<&super::super::codec::Value> = None;
543        let mut raw_meta: Option<&super::super::codec::Value> = None;
544        let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
545        let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
546        let mut raw_language: Option<&super::super::codec::Value> = None;
547        let mut raw_language_element: Option<&super::super::codec::Value> = None;
548        let mut raw_text: Option<&super::super::codec::Value> = None;
549        let mut raw_contained: Option<&super::super::codec::Value> = None;
550        let mut raw_extension: Option<&super::super::codec::Value> = None;
551        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
552        let mut raw_url: Option<&super::super::codec::Value> = None;
553        let mut raw_url_element: Option<&super::super::codec::Value> = None;
554        let mut raw_identifier: Option<&super::super::codec::Value> = None;
555        let mut raw_version: Option<&super::super::codec::Value> = None;
556        let mut raw_version_element: Option<&super::super::codec::Value> = None;
557        let mut raw_version_algorithm = super::super::codec::ChoiceSlot::default();
558        let mut raw_name: Option<&super::super::codec::Value> = None;
559        let mut raw_name_element: Option<&super::super::codec::Value> = None;
560        let mut raw_title: Option<&super::super::codec::Value> = None;
561        let mut raw_title_element: Option<&super::super::codec::Value> = None;
562        let mut raw_status: Option<&super::super::codec::Value> = None;
563        let mut raw_status_element: Option<&super::super::codec::Value> = None;
564        let mut raw_experimental: Option<&super::super::codec::Value> = None;
565        let mut raw_experimental_element: Option<&super::super::codec::Value> = None;
566        let mut raw_date: Option<&super::super::codec::Value> = None;
567        let mut raw_date_element: Option<&super::super::codec::Value> = None;
568        let mut raw_publisher: Option<&super::super::codec::Value> = None;
569        let mut raw_publisher_element: Option<&super::super::codec::Value> = None;
570        let mut raw_contact: Option<&super::super::codec::Value> = None;
571        let mut raw_description: Option<&super::super::codec::Value> = None;
572        let mut raw_description_element: Option<&super::super::codec::Value> = None;
573        let mut raw_use_context: Option<&super::super::codec::Value> = None;
574        let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
575        let mut raw_purpose: Option<&super::super::codec::Value> = None;
576        let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
577        let mut raw_copyright: Option<&super::super::codec::Value> = None;
578        let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
579        let mut raw_copyright_label: Option<&super::super::codec::Value> = None;
580        let mut raw_copyright_label_element: Option<&super::super::codec::Value> = None;
581        let mut raw_kind: Option<&super::super::codec::Value> = None;
582        let mut raw_kind_element: Option<&super::super::codec::Value> = None;
583        let mut raw_software: Option<&super::super::codec::Value> = None;
584        let mut raw_implementation: Option<&super::super::codec::Value> = None;
585        let mut raw_locked_date: Option<&super::super::codec::Value> = None;
586        let mut raw_locked_date_element: Option<&super::super::codec::Value> = None;
587        let mut raw_code_system: Option<&super::super::codec::Value> = None;
588        let mut raw_expansion: Option<&super::super::codec::Value> = None;
589        let mut raw_code_search: Option<&super::super::codec::Value> = None;
590        let mut raw_code_search_element: Option<&super::super::codec::Value> = None;
591        let mut raw_validate_code: Option<&super::super::codec::Value> = None;
592        let mut raw_translation: Option<&super::super::codec::Value> = None;
593        let mut raw_closure: Option<&super::super::codec::Value> = None;
594        for (key, value) in object {
595            match key.as_str() {
596                "resourceType" => {
597                    if value.as_str() != Some("TerminologyCapabilities") {
598                        return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
599                    }
600                }
601                "id" => {
602                    raw_id = Some(value);
603                }
604                "meta" => {
605                    raw_meta = Some(value);
606                }
607                "implicitRules" => {
608                    raw_implicit_rules = Some(value);
609                }
610                "_implicitRules" => {
611                    raw_implicit_rules_element = Some(value);
612                }
613                "language" => {
614                    raw_language = Some(value);
615                }
616                "_language" => {
617                    raw_language_element = Some(value);
618                }
619                "text" => {
620                    raw_text = Some(value);
621                }
622                "contained" => {
623                    raw_contained = Some(value);
624                }
625                "extension" => {
626                    raw_extension = Some(value);
627                }
628                "modifierExtension" => {
629                    raw_modifier_extension = Some(value);
630                }
631                "url" => {
632                    raw_url = Some(value);
633                }
634                "_url" => {
635                    raw_url_element = Some(value);
636                }
637                "identifier" => {
638                    raw_identifier = Some(value);
639                }
640                "version" => {
641                    raw_version = Some(value);
642                }
643                "_version" => {
644                    raw_version_element = Some(value);
645                }
646                "versionAlgorithmString" => {
647                    raw_version_algorithm.value("String", value, path)?;
648                }
649                "_versionAlgorithmString" => {
650                    raw_version_algorithm.element("String", value, path)?;
651                }
652                "versionAlgorithmCoding" => {
653                    raw_version_algorithm.value("Coding", value, path)?;
654                }
655                "_versionAlgorithmCoding" => {
656                    raw_version_algorithm.element("Coding", value, path)?;
657                }
658                "name" => {
659                    raw_name = Some(value);
660                }
661                "_name" => {
662                    raw_name_element = Some(value);
663                }
664                "title" => {
665                    raw_title = Some(value);
666                }
667                "_title" => {
668                    raw_title_element = Some(value);
669                }
670                "status" => {
671                    raw_status = Some(value);
672                }
673                "_status" => {
674                    raw_status_element = Some(value);
675                }
676                "experimental" => {
677                    raw_experimental = Some(value);
678                }
679                "_experimental" => {
680                    raw_experimental_element = Some(value);
681                }
682                "date" => {
683                    raw_date = Some(value);
684                }
685                "_date" => {
686                    raw_date_element = Some(value);
687                }
688                "publisher" => {
689                    raw_publisher = Some(value);
690                }
691                "_publisher" => {
692                    raw_publisher_element = Some(value);
693                }
694                "contact" => {
695                    raw_contact = Some(value);
696                }
697                "description" => {
698                    raw_description = Some(value);
699                }
700                "_description" => {
701                    raw_description_element = Some(value);
702                }
703                "useContext" => {
704                    raw_use_context = Some(value);
705                }
706                "jurisdiction" => {
707                    raw_jurisdiction = Some(value);
708                }
709                "purpose" => {
710                    raw_purpose = Some(value);
711                }
712                "_purpose" => {
713                    raw_purpose_element = Some(value);
714                }
715                "copyright" => {
716                    raw_copyright = Some(value);
717                }
718                "_copyright" => {
719                    raw_copyright_element = Some(value);
720                }
721                "copyrightLabel" => {
722                    raw_copyright_label = Some(value);
723                }
724                "_copyrightLabel" => {
725                    raw_copyright_label_element = Some(value);
726                }
727                "kind" => {
728                    raw_kind = Some(value);
729                }
730                "_kind" => {
731                    raw_kind_element = Some(value);
732                }
733                "software" => {
734                    raw_software = Some(value);
735                }
736                "implementation" => {
737                    raw_implementation = Some(value);
738                }
739                "lockedDate" => {
740                    raw_locked_date = Some(value);
741                }
742                "_lockedDate" => {
743                    raw_locked_date_element = Some(value);
744                }
745                "codeSystem" => {
746                    raw_code_system = Some(value);
747                }
748                "expansion" => {
749                    raw_expansion = Some(value);
750                }
751                "codeSearch" => {
752                    raw_code_search = Some(value);
753                }
754                "_codeSearch" => {
755                    raw_code_search_element = Some(value);
756                }
757                "validateCode" => {
758                    raw_validate_code = Some(value);
759                }
760                "translation" => {
761                    raw_translation = Some(value);
762                }
763                "closure" => {
764                    raw_closure = Some(value);
765                }
766                other => {
767                    return path.with(other, |path| {
768                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
769                    });
770                }
771            }
772        }
773        let field_id = raw_id
774            .map(|value| {
775                path.with("id", |path| {
776                    let value = super::super::codec::expect_single(value, path)?;
777                    super::primitives::checked_id(
778                        super::super::codec::expect_string(value, path)?,
779                        path,
780                    )
781                })
782            })
783            .transpose()?;
784        let field_meta = raw_meta
785            .map(|value| {
786                path.with("meta", |path| {
787                    super::super::codec::Json::from_json(
788                        super::super::codec::expect_object(
789                            super::super::codec::expect_single(value, path)?,
790                            path,
791                        )?,
792                        path,
793                    )
794                })
795            })
796            .transpose()?;
797        let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
798            (None, None) => None,
799            (value, element) => Some(path.with("implicitRules", |path| {
800                super::super::codec::Primitive::from_json_parts(value, element, path)
801            })?),
802        };
803        let field_language = match (raw_language, raw_language_element) {
804            (None, None) => None,
805            (value, element) => Some(path.with("language", |path| {
806                super::super::codec::Primitive::from_json_parts(value, element, path)
807            })?),
808        };
809        let field_text = raw_text
810            .map(|value| {
811                path.with("text", |path| {
812                    super::super::codec::Json::from_json(
813                        super::super::codec::expect_object(
814                            super::super::codec::expect_single(value, path)?,
815                            path,
816                        )?,
817                        path,
818                    )
819                })
820            })
821            .transpose()?;
822        let mut field_contained = Vec::new();
823        if let Some(raw) = raw_contained {
824            for (index, value) in path
825                .with("contained", |path| {
826                    super::super::codec::expect_array(raw, path)
827                })?
828                .iter()
829                .enumerate()
830            {
831                field_contained.push(path.with_index("contained", index, |path| {
832                    super::super::codec::Json::from_json(
833                        super::super::codec::expect_object(value, path)?,
834                        path,
835                    )
836                })?);
837            }
838        }
839        let mut field_extension = Vec::new();
840        if let Some(raw) = raw_extension {
841            for (index, value) in path
842                .with("extension", |path| {
843                    super::super::codec::expect_array(raw, path)
844                })?
845                .iter()
846                .enumerate()
847            {
848                field_extension.push(path.with_index("extension", index, |path| {
849                    super::super::codec::Json::from_json(
850                        super::super::codec::expect_object(value, path)?,
851                        path,
852                    )
853                })?);
854            }
855        }
856        let mut field_modifier_extension = Vec::new();
857        if let Some(raw) = raw_modifier_extension {
858            for (index, value) in path
859                .with("modifierExtension", |path| {
860                    super::super::codec::expect_array(raw, path)
861                })?
862                .iter()
863                .enumerate()
864            {
865                field_modifier_extension.push(path.with_index(
866                    "modifierExtension",
867                    index,
868                    |path| {
869                        super::super::codec::Json::from_json(
870                            super::super::codec::expect_object(value, path)?,
871                            path,
872                        )
873                    },
874                )?);
875            }
876        }
877        let field_url = match (raw_url, raw_url_element) {
878            (None, None) => None,
879            (value, element) => Some(path.with("url", |path| {
880                super::super::codec::Primitive::from_json_parts(value, element, path)
881            })?),
882        };
883        let mut field_identifier = Vec::new();
884        if let Some(raw) = raw_identifier {
885            for (index, value) in path
886                .with("identifier", |path| {
887                    super::super::codec::expect_array(raw, path)
888                })?
889                .iter()
890                .enumerate()
891            {
892                field_identifier.push(path.with_index("identifier", index, |path| {
893                    super::super::codec::Json::from_json(
894                        super::super::codec::expect_object(value, path)?,
895                        path,
896                    )
897                })?);
898            }
899        }
900        let field_version = match (raw_version, raw_version_element) {
901            (None, None) => None,
902            (value, element) => Some(path.with("version", |path| {
903                super::super::codec::Primitive::from_json_parts(value, element, path)
904            })?),
905        };
906        let field_version_algorithm = match raw_version_algorithm.suffix {
907            None => None,
908            Some(suffix) => Some(path.with("versionAlgorithm", |path| {
909                TerminologyCapabilitiesVersionAlgorithm::from_json_parts(
910                    suffix,
911                    raw_version_algorithm.value,
912                    raw_version_algorithm.element,
913                    path,
914                )
915            })?),
916        };
917        let field_name = match (raw_name, raw_name_element) {
918            (None, None) => None,
919            (value, element) => Some(path.with("name", |path| {
920                super::super::codec::Primitive::from_json_parts(value, element, path)
921            })?),
922        };
923        let field_title = match (raw_title, raw_title_element) {
924            (None, None) => None,
925            (value, element) => Some(path.with("title", |path| {
926                super::super::codec::Primitive::from_json_parts(value, element, path)
927            })?),
928        };
929        let field_status = path.with("status", |path| {
930            super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
931        })?;
932        let field_experimental = match (raw_experimental, raw_experimental_element) {
933            (None, None) => None,
934            (value, element) => Some(path.with("experimental", |path| {
935                super::super::codec::Primitive::from_json_parts(value, element, path)
936            })?),
937        };
938        let field_date = path.with("date", |path| {
939            super::super::codec::Primitive::from_json_parts(raw_date, raw_date_element, path)
940        })?;
941        let field_publisher = match (raw_publisher, raw_publisher_element) {
942            (None, None) => None,
943            (value, element) => Some(path.with("publisher", |path| {
944                super::super::codec::Primitive::from_json_parts(value, element, path)
945            })?),
946        };
947        let mut field_contact = Vec::new();
948        if let Some(raw) = raw_contact {
949            for (index, value) in path
950                .with("contact", |path| {
951                    super::super::codec::expect_array(raw, path)
952                })?
953                .iter()
954                .enumerate()
955            {
956                field_contact.push(path.with_index("contact", index, |path| {
957                    super::super::codec::Json::from_json(
958                        super::super::codec::expect_object(value, path)?,
959                        path,
960                    )
961                })?);
962            }
963        }
964        let field_description = match (raw_description, raw_description_element) {
965            (None, None) => None,
966            (value, element) => Some(path.with("description", |path| {
967                super::super::codec::Primitive::from_json_parts(value, element, path)
968            })?),
969        };
970        let mut field_use_context = Vec::new();
971        if let Some(raw) = raw_use_context {
972            for (index, value) in path
973                .with("useContext", |path| {
974                    super::super::codec::expect_array(raw, path)
975                })?
976                .iter()
977                .enumerate()
978            {
979                field_use_context.push(path.with_index("useContext", index, |path| {
980                    super::super::codec::Json::from_json(
981                        super::super::codec::expect_object(value, path)?,
982                        path,
983                    )
984                })?);
985            }
986        }
987        let mut field_jurisdiction = Vec::new();
988        if let Some(raw) = raw_jurisdiction {
989            for (index, value) in path
990                .with("jurisdiction", |path| {
991                    super::super::codec::expect_array(raw, path)
992                })?
993                .iter()
994                .enumerate()
995            {
996                field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
997                    super::super::codec::Json::from_json(
998                        super::super::codec::expect_object(value, path)?,
999                        path,
1000                    )
1001                })?);
1002            }
1003        }
1004        let field_purpose = match (raw_purpose, raw_purpose_element) {
1005            (None, None) => None,
1006            (value, element) => Some(path.with("purpose", |path| {
1007                super::super::codec::Primitive::from_json_parts(value, element, path)
1008            })?),
1009        };
1010        let field_copyright = match (raw_copyright, raw_copyright_element) {
1011            (None, None) => None,
1012            (value, element) => Some(path.with("copyright", |path| {
1013                super::super::codec::Primitive::from_json_parts(value, element, path)
1014            })?),
1015        };
1016        let field_copyright_label = match (raw_copyright_label, raw_copyright_label_element) {
1017            (None, None) => None,
1018            (value, element) => Some(path.with("copyrightLabel", |path| {
1019                super::super::codec::Primitive::from_json_parts(value, element, path)
1020            })?),
1021        };
1022        let field_kind = path.with("kind", |path| {
1023            super::super::codec::Primitive::from_json_parts(raw_kind, raw_kind_element, path)
1024        })?;
1025        let field_software = raw_software
1026            .map(|value| {
1027                path.with("software", |path| {
1028                    super::super::codec::Json::from_json(
1029                        super::super::codec::expect_object(
1030                            super::super::codec::expect_single(value, path)?,
1031                            path,
1032                        )?,
1033                        path,
1034                    )
1035                })
1036            })
1037            .transpose()?;
1038        let field_implementation = raw_implementation
1039            .map(|value| {
1040                path.with("implementation", |path| {
1041                    super::super::codec::Json::from_json(
1042                        super::super::codec::expect_object(
1043                            super::super::codec::expect_single(value, path)?,
1044                            path,
1045                        )?,
1046                        path,
1047                    )
1048                })
1049            })
1050            .transpose()?;
1051        let field_locked_date = match (raw_locked_date, raw_locked_date_element) {
1052            (None, None) => None,
1053            (value, element) => Some(path.with("lockedDate", |path| {
1054                super::super::codec::Primitive::from_json_parts(value, element, path)
1055            })?),
1056        };
1057        let mut field_code_system = Vec::new();
1058        if let Some(raw) = raw_code_system {
1059            for (index, value) in path
1060                .with("codeSystem", |path| {
1061                    super::super::codec::expect_array(raw, path)
1062                })?
1063                .iter()
1064                .enumerate()
1065            {
1066                field_code_system.push(path.with_index("codeSystem", index, |path| {
1067                    super::super::codec::Json::from_json(
1068                        super::super::codec::expect_object(value, path)?,
1069                        path,
1070                    )
1071                })?);
1072            }
1073        }
1074        let field_expansion = raw_expansion
1075            .map(|value| {
1076                path.with("expansion", |path| {
1077                    super::super::codec::Json::from_json(
1078                        super::super::codec::expect_object(
1079                            super::super::codec::expect_single(value, path)?,
1080                            path,
1081                        )?,
1082                        path,
1083                    )
1084                })
1085            })
1086            .transpose()?;
1087        let field_code_search = match (raw_code_search, raw_code_search_element) {
1088            (None, None) => None,
1089            (value, element) => Some(path.with("codeSearch", |path| {
1090                super::super::codec::Primitive::from_json_parts(value, element, path)
1091            })?),
1092        };
1093        let field_validate_code = raw_validate_code
1094            .map(|value| {
1095                path.with("validateCode", |path| {
1096                    super::super::codec::Json::from_json(
1097                        super::super::codec::expect_object(
1098                            super::super::codec::expect_single(value, path)?,
1099                            path,
1100                        )?,
1101                        path,
1102                    )
1103                })
1104            })
1105            .transpose()?;
1106        let field_translation = raw_translation
1107            .map(|value| {
1108                path.with("translation", |path| {
1109                    super::super::codec::Json::from_json(
1110                        super::super::codec::expect_object(
1111                            super::super::codec::expect_single(value, path)?,
1112                            path,
1113                        )?,
1114                        path,
1115                    )
1116                })
1117            })
1118            .transpose()?;
1119        let field_closure = raw_closure
1120            .map(|value| {
1121                path.with("closure", |path| {
1122                    super::super::codec::Json::from_json(
1123                        super::super::codec::expect_object(
1124                            super::super::codec::expect_single(value, path)?,
1125                            path,
1126                        )?,
1127                        path,
1128                    )
1129                })
1130            })
1131            .transpose()?;
1132        Ok(Self {
1133            id: field_id,
1134            meta: field_meta,
1135            implicit_rules: field_implicit_rules,
1136            language: field_language,
1137            text: field_text,
1138            contained: field_contained,
1139            extension: field_extension,
1140            modifier_extension: field_modifier_extension,
1141            url: field_url,
1142            identifier: field_identifier,
1143            version: field_version,
1144            version_algorithm: field_version_algorithm,
1145            name: field_name,
1146            title: field_title,
1147            status: field_status,
1148            experimental: field_experimental,
1149            date: field_date,
1150            publisher: field_publisher,
1151            contact: field_contact,
1152            description: field_description,
1153            use_context: field_use_context,
1154            jurisdiction: field_jurisdiction,
1155            purpose: field_purpose,
1156            copyright: field_copyright,
1157            copyright_label: field_copyright_label,
1158            kind: field_kind,
1159            software: field_software,
1160            implementation: field_implementation,
1161            locked_date: field_locked_date,
1162            code_system: field_code_system,
1163            expansion: field_expansion,
1164            code_search: field_code_search,
1165            validate_code: field_validate_code,
1166            translation: field_translation,
1167            closure: field_closure,
1168        })
1169    }
1170}
1171
1172impl serde::Serialize for TerminologyCapabilities {
1173    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1174        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1175        if let Some(item) = &self.code_search {
1176            super::super::codec::element_entry(&mut map, "_codeSearch", item)?;
1177        }
1178        if let Some(item) = &self.copyright {
1179            super::super::codec::element_entry(&mut map, "_copyright", item)?;
1180        }
1181        if let Some(item) = &self.copyright_label {
1182            super::super::codec::element_entry(&mut map, "_copyrightLabel", item)?;
1183        }
1184        super::super::codec::element_entry(&mut map, "_date", &self.date)?;
1185        if let Some(item) = &self.description {
1186            super::super::codec::element_entry(&mut map, "_description", item)?;
1187        }
1188        if let Some(item) = &self.experimental {
1189            super::super::codec::element_entry(&mut map, "_experimental", item)?;
1190        }
1191        if let Some(item) = &self.implicit_rules {
1192            super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
1193        }
1194        super::super::codec::element_entry(&mut map, "_kind", &self.kind)?;
1195        if let Some(item) = &self.language {
1196            super::super::codec::element_entry(&mut map, "_language", item)?;
1197        }
1198        if let Some(item) = &self.locked_date {
1199            super::super::codec::element_entry(&mut map, "_lockedDate", item)?;
1200        }
1201        if let Some(item) = &self.name {
1202            super::super::codec::element_entry(&mut map, "_name", item)?;
1203        }
1204        if let Some(item) = &self.publisher {
1205            super::super::codec::element_entry(&mut map, "_publisher", item)?;
1206        }
1207        if let Some(item) = &self.purpose {
1208            super::super::codec::element_entry(&mut map, "_purpose", item)?;
1209        }
1210        super::super::codec::element_entry(&mut map, "_status", &self.status)?;
1211        if let Some(item) = &self.title {
1212            super::super::codec::element_entry(&mut map, "_title", item)?;
1213        }
1214        if let Some(item) = &self.url {
1215            super::super::codec::element_entry(&mut map, "_url", item)?;
1216        }
1217        if let Some(item) = &self.version {
1218            super::super::codec::element_entry(&mut map, "_version", item)?;
1219        }
1220        if let Some(TerminologyCapabilitiesVersionAlgorithm::String(inner)) =
1221            &self.version_algorithm
1222        {
1223            super::super::codec::element_entry(&mut map, "_versionAlgorithmString", inner)?;
1224        }
1225        if let Some(item) = &self.closure {
1226            serde::ser::SerializeMap::serialize_entry(&mut map, "closure", item)?;
1227        }
1228        if let Some(item) = &self.code_search {
1229            super::super::codec::value_entry(&mut map, "codeSearch", item)?;
1230        }
1231        if !self.code_system.is_empty() {
1232            serde::ser::SerializeMap::serialize_entry(&mut map, "codeSystem", &self.code_system)?;
1233        }
1234        if !self.contact.is_empty() {
1235            serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
1236        }
1237        if !self.contained.is_empty() {
1238            serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
1239        }
1240        if let Some(item) = &self.copyright {
1241            super::super::codec::value_entry(&mut map, "copyright", item)?;
1242        }
1243        if let Some(item) = &self.copyright_label {
1244            super::super::codec::value_entry(&mut map, "copyrightLabel", item)?;
1245        }
1246        super::super::codec::value_entry(&mut map, "date", &self.date)?;
1247        if let Some(item) = &self.description {
1248            super::super::codec::value_entry(&mut map, "description", item)?;
1249        }
1250        if let Some(item) = &self.expansion {
1251            serde::ser::SerializeMap::serialize_entry(&mut map, "expansion", item)?;
1252        }
1253        if let Some(item) = &self.experimental {
1254            super::super::codec::value_entry(&mut map, "experimental", item)?;
1255        }
1256        if !self.extension.is_empty() {
1257            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1258        }
1259        if let Some(v) = &self.id {
1260            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1261        }
1262        if !self.identifier.is_empty() {
1263            serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
1264        }
1265        if let Some(item) = &self.implementation {
1266            serde::ser::SerializeMap::serialize_entry(&mut map, "implementation", item)?;
1267        }
1268        if let Some(item) = &self.implicit_rules {
1269            super::super::codec::value_entry(&mut map, "implicitRules", item)?;
1270        }
1271        if !self.jurisdiction.is_empty() {
1272            serde::ser::SerializeMap::serialize_entry(
1273                &mut map,
1274                "jurisdiction",
1275                &self.jurisdiction,
1276            )?;
1277        }
1278        super::super::codec::value_entry(&mut map, "kind", &self.kind)?;
1279        if let Some(item) = &self.language {
1280            super::super::codec::value_entry(&mut map, "language", item)?;
1281        }
1282        if let Some(item) = &self.locked_date {
1283            super::super::codec::value_entry(&mut map, "lockedDate", item)?;
1284        }
1285        if let Some(item) = &self.meta {
1286            serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
1287        }
1288        if !self.modifier_extension.is_empty() {
1289            serde::ser::SerializeMap::serialize_entry(
1290                &mut map,
1291                "modifierExtension",
1292                &self.modifier_extension,
1293            )?;
1294        }
1295        if let Some(item) = &self.name {
1296            super::super::codec::value_entry(&mut map, "name", item)?;
1297        }
1298        if let Some(item) = &self.publisher {
1299            super::super::codec::value_entry(&mut map, "publisher", item)?;
1300        }
1301        if let Some(item) = &self.purpose {
1302            super::super::codec::value_entry(&mut map, "purpose", item)?;
1303        }
1304        serde::ser::SerializeMap::serialize_entry(
1305            &mut map,
1306            "resourceType",
1307            "TerminologyCapabilities",
1308        )?;
1309        if let Some(item) = &self.software {
1310            serde::ser::SerializeMap::serialize_entry(&mut map, "software", item)?;
1311        }
1312        super::super::codec::value_entry(&mut map, "status", &self.status)?;
1313        if let Some(item) = &self.text {
1314            serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
1315        }
1316        if let Some(item) = &self.title {
1317            super::super::codec::value_entry(&mut map, "title", item)?;
1318        }
1319        if let Some(item) = &self.translation {
1320            serde::ser::SerializeMap::serialize_entry(&mut map, "translation", item)?;
1321        }
1322        if let Some(item) = &self.url {
1323            super::super::codec::value_entry(&mut map, "url", item)?;
1324        }
1325        if !self.use_context.is_empty() {
1326            serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
1327        }
1328        if let Some(item) = &self.validate_code {
1329            serde::ser::SerializeMap::serialize_entry(&mut map, "validateCode", item)?;
1330        }
1331        if let Some(item) = &self.version {
1332            super::super::codec::value_entry(&mut map, "version", item)?;
1333        }
1334        match &self.version_algorithm {
1335            Some(TerminologyCapabilitiesVersionAlgorithm::Coding(inner)) => {
1336                serde::ser::SerializeMap::serialize_entry(
1337                    &mut map,
1338                    "versionAlgorithmCoding",
1339                    inner.as_ref(),
1340                )?;
1341            }
1342            Some(TerminologyCapabilitiesVersionAlgorithm::String(inner)) => {
1343                super::super::codec::value_entry(&mut map, "versionAlgorithmString", inner)?;
1344            }
1345            None => {}
1346        }
1347        serde::ser::SerializeMap::end(map)
1348    }
1349}
1350
1351impl<'de> serde::Deserialize<'de> for TerminologyCapabilities {
1352    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1353        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1354        let mut path = super::super::codec::Path::root("TerminologyCapabilities");
1355        let object =
1356            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1357        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1358    }
1359}
1360
1361/// Information about the
1362/// \[ConceptMap/$closure\](conceptmap-operation-closure.html) operation
1363///
1364/// Whether the $closure operation is supported.
1365#[derive(Debug, Clone, Default, PartialEq, Eq)]
1366pub struct TerminologyCapabilitiesClosure {
1367    /// Unique id for inter-element referencing
1368    ///
1369    /// Unique id for the element within a resource (for internal references). This
1370    /// may be any string value that does not contain spaces.
1371    pub id: Option<std::string::String>,
1372    /// Additional content defined by implementations
1373    ///
1374    /// May be used to represent additional information that is not part of the
1375    /// basic definition of the element. To make the use of extensions safe and
1376    /// managable, there is a strict set of governance applied to the definition and
1377    /// use of extensions. Though any implementer can define an extension, there is
1378    /// a set of requirements that SHALL be met as part of the definition of the
1379    /// extension.
1380    pub extension: Vec<super::extension::Extension>,
1381    /// Extensions that cannot be ignored even if unrecognized
1382    ///
1383    /// May be used to represent additional information that is not part of the
1384    /// basic definition of the element and that modifies the understanding of the
1385    /// element in which it is contained and/or the understanding of the containing
1386    /// element's descendants. Usually modifier elements provide negation or
1387    /// qualification. To make the use of extensions safe and managable, there is a
1388    /// strict set of governance applied to the definition and use of extensions.
1389    /// Though any implementer can define an extension, there is a set of
1390    /// requirements that SHALL be met as part of the definition of the extension.
1391    /// Applications processing a resource are required to check for modifier
1392    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1393    /// on Resource or DomainResource (including cannot change the meaning of
1394    /// modifierExtension itself).
1395    pub modifier_extension: Vec<super::extension::Extension>,
1396    /// If cross-system closure is supported.
1397    pub translation: Option<super::primitives::Boolean>,
1398}
1399
1400impl super::super::codec::Json for TerminologyCapabilitiesClosure {
1401    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1402        let mut object = super::super::codec::Object::new();
1403        if let Some(v) = &self.id {
1404            object.insert(
1405                std::string::String::from("id"),
1406                super::super::codec::Value::String(v.clone()),
1407            );
1408        }
1409        if !self.extension.is_empty() {
1410            let mut items = Vec::with_capacity(self.extension.len());
1411            for item in &self.extension {
1412                items.push(super::super::codec::Value::Object(
1413                    super::super::codec::Json::to_json(item)?,
1414                ));
1415            }
1416            object.insert(
1417                std::string::String::from("extension"),
1418                super::super::codec::Value::Array(items),
1419            );
1420        }
1421        if !self.modifier_extension.is_empty() {
1422            let mut items = Vec::with_capacity(self.modifier_extension.len());
1423            for item in &self.modifier_extension {
1424                items.push(super::super::codec::Value::Object(
1425                    super::super::codec::Json::to_json(item)?,
1426                ));
1427            }
1428            object.insert(
1429                std::string::String::from("modifierExtension"),
1430                super::super::codec::Value::Array(items),
1431            );
1432        }
1433        if let Some(item) = &self.translation {
1434            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1435                object.insert(std::string::String::from("translation"), v);
1436            }
1437            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1438                object.insert(std::string::String::from("_translation"), e);
1439            }
1440        }
1441        Ok(object)
1442    }
1443
1444    fn from_json(
1445        object: &super::super::codec::Object,
1446        path: &mut super::super::codec::Path,
1447    ) -> Result<Self, super::super::codec::DecodeError> {
1448        let mut raw_id: Option<&super::super::codec::Value> = None;
1449        let mut raw_extension: Option<&super::super::codec::Value> = None;
1450        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1451        let mut raw_translation: Option<&super::super::codec::Value> = None;
1452        let mut raw_translation_element: Option<&super::super::codec::Value> = None;
1453        for (key, value) in object {
1454            match key.as_str() {
1455                "id" => {
1456                    raw_id = Some(value);
1457                }
1458                "extension" => {
1459                    raw_extension = Some(value);
1460                }
1461                "modifierExtension" => {
1462                    raw_modifier_extension = Some(value);
1463                }
1464                "translation" => {
1465                    raw_translation = Some(value);
1466                }
1467                "_translation" => {
1468                    raw_translation_element = Some(value);
1469                }
1470                other => {
1471                    return path.with(other, |path| {
1472                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1473                    });
1474                }
1475            }
1476        }
1477        let field_id = raw_id
1478            .map(|value| {
1479                path.with("id", |path| {
1480                    let value = super::super::codec::expect_single(value, path)?;
1481                    super::primitives::checked_string(
1482                        super::super::codec::expect_string(value, path)?,
1483                        path,
1484                    )
1485                })
1486            })
1487            .transpose()?;
1488        let mut field_extension = Vec::new();
1489        if let Some(raw) = raw_extension {
1490            for (index, value) in path
1491                .with("extension", |path| {
1492                    super::super::codec::expect_array(raw, path)
1493                })?
1494                .iter()
1495                .enumerate()
1496            {
1497                field_extension.push(path.with_index("extension", index, |path| {
1498                    super::super::codec::Json::from_json(
1499                        super::super::codec::expect_object(value, path)?,
1500                        path,
1501                    )
1502                })?);
1503            }
1504        }
1505        let mut field_modifier_extension = Vec::new();
1506        if let Some(raw) = raw_modifier_extension {
1507            for (index, value) in path
1508                .with("modifierExtension", |path| {
1509                    super::super::codec::expect_array(raw, path)
1510                })?
1511                .iter()
1512                .enumerate()
1513            {
1514                field_modifier_extension.push(path.with_index(
1515                    "modifierExtension",
1516                    index,
1517                    |path| {
1518                        super::super::codec::Json::from_json(
1519                            super::super::codec::expect_object(value, path)?,
1520                            path,
1521                        )
1522                    },
1523                )?);
1524            }
1525        }
1526        let field_translation = match (raw_translation, raw_translation_element) {
1527            (None, None) => None,
1528            (value, element) => Some(path.with("translation", |path| {
1529                super::super::codec::Primitive::from_json_parts(value, element, path)
1530            })?),
1531        };
1532        Ok(Self {
1533            id: field_id,
1534            extension: field_extension,
1535            modifier_extension: field_modifier_extension,
1536            translation: field_translation,
1537        })
1538    }
1539}
1540
1541impl serde::Serialize for TerminologyCapabilitiesClosure {
1542    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1543        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1544        if let Some(item) = &self.translation {
1545            super::super::codec::element_entry(&mut map, "_translation", item)?;
1546        }
1547        if !self.extension.is_empty() {
1548            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1549        }
1550        if let Some(v) = &self.id {
1551            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1552        }
1553        if !self.modifier_extension.is_empty() {
1554            serde::ser::SerializeMap::serialize_entry(
1555                &mut map,
1556                "modifierExtension",
1557                &self.modifier_extension,
1558            )?;
1559        }
1560        if let Some(item) = &self.translation {
1561            super::super::codec::value_entry(&mut map, "translation", item)?;
1562        }
1563        serde::ser::SerializeMap::end(map)
1564    }
1565}
1566
1567impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesClosure {
1568    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1569        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1570        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesClosure");
1571        let object =
1572            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1573        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1574    }
1575}
1576
1577/// A code system supported by the server
1578///
1579/// Identifies a code system that is supported by the server. If there is a no
1580/// code system URL, then this declares the general assumptions a client can
1581/// make about support for any CodeSystem resource.
1582#[derive(Debug, Clone, Default, PartialEq, Eq)]
1583pub struct TerminologyCapabilitiesCodeSystem {
1584    /// Unique id for inter-element referencing
1585    ///
1586    /// Unique id for the element within a resource (for internal references). This
1587    /// may be any string value that does not contain spaces.
1588    pub id: Option<std::string::String>,
1589    /// Additional content defined by implementations
1590    ///
1591    /// May be used to represent additional information that is not part of the
1592    /// basic definition of the element. To make the use of extensions safe and
1593    /// managable, there is a strict set of governance applied to the definition and
1594    /// use of extensions. Though any implementer can define an extension, there is
1595    /// a set of requirements that SHALL be met as part of the definition of the
1596    /// extension.
1597    pub extension: Vec<super::extension::Extension>,
1598    /// Extensions that cannot be ignored even if unrecognized
1599    ///
1600    /// May be used to represent additional information that is not part of the
1601    /// basic definition of the element and that modifies the understanding of the
1602    /// element in which it is contained and/or the understanding of the containing
1603    /// element's descendants. Usually modifier elements provide negation or
1604    /// qualification. To make the use of extensions safe and managable, there is a
1605    /// strict set of governance applied to the definition and use of extensions.
1606    /// Though any implementer can define an extension, there is a set of
1607    /// requirements that SHALL be met as part of the definition of the extension.
1608    /// Applications processing a resource are required to check for modifier
1609    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1610    /// on Resource or DomainResource (including cannot change the meaning of
1611    /// modifierExtension itself).
1612    pub modifier_extension: Vec<super::extension::Extension>,
1613    /// Canonical identifier for the code system, represented as a URI.
1614    pub uri: Option<super::primitives::Canonical>,
1615    /// Version of Code System supported
1616    ///
1617    /// For the code system, a list of versions that are supported by the server.
1618    pub version: Vec<TerminologyCapabilitiesCodeSystemVersion>,
1619    /// not-present | example | fragment | complete | supplement
1620    ///
1621    /// The extent of the content of the code system (the concepts and codes it
1622    /// defines) are represented in this resource instance.
1623    pub content: super::primitives::Code,
1624    /// Whether subsumption is supported
1625    ///
1626    /// True if subsumption is supported for this version of the code system.
1627    pub subsumption: Option<super::primitives::Boolean>,
1628}
1629
1630impl super::super::codec::Json for TerminologyCapabilitiesCodeSystem {
1631    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1632        let mut object = super::super::codec::Object::new();
1633        if let Some(v) = &self.id {
1634            object.insert(
1635                std::string::String::from("id"),
1636                super::super::codec::Value::String(v.clone()),
1637            );
1638        }
1639        if !self.extension.is_empty() {
1640            let mut items = Vec::with_capacity(self.extension.len());
1641            for item in &self.extension {
1642                items.push(super::super::codec::Value::Object(
1643                    super::super::codec::Json::to_json(item)?,
1644                ));
1645            }
1646            object.insert(
1647                std::string::String::from("extension"),
1648                super::super::codec::Value::Array(items),
1649            );
1650        }
1651        if !self.modifier_extension.is_empty() {
1652            let mut items = Vec::with_capacity(self.modifier_extension.len());
1653            for item in &self.modifier_extension {
1654                items.push(super::super::codec::Value::Object(
1655                    super::super::codec::Json::to_json(item)?,
1656                ));
1657            }
1658            object.insert(
1659                std::string::String::from("modifierExtension"),
1660                super::super::codec::Value::Array(items),
1661            );
1662        }
1663        if let Some(item) = &self.uri {
1664            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1665                object.insert(std::string::String::from("uri"), v);
1666            }
1667            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1668                object.insert(std::string::String::from("_uri"), e);
1669            }
1670        }
1671        if !self.version.is_empty() {
1672            let mut items = Vec::with_capacity(self.version.len());
1673            for item in &self.version {
1674                items.push(super::super::codec::Value::Object(
1675                    super::super::codec::Json::to_json(item)?,
1676                ));
1677            }
1678            object.insert(
1679                std::string::String::from("version"),
1680                super::super::codec::Value::Array(items),
1681            );
1682        }
1683        if let Some(v) = super::super::codec::Primitive::value_json(&self.content)? {
1684            object.insert(std::string::String::from("content"), v);
1685        }
1686        if let Some(e) = super::super::codec::Primitive::element_json(&self.content)? {
1687            object.insert(std::string::String::from("_content"), e);
1688        }
1689        if let Some(item) = &self.subsumption {
1690            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1691                object.insert(std::string::String::from("subsumption"), v);
1692            }
1693            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1694                object.insert(std::string::String::from("_subsumption"), e);
1695            }
1696        }
1697        Ok(object)
1698    }
1699
1700    fn from_json(
1701        object: &super::super::codec::Object,
1702        path: &mut super::super::codec::Path,
1703    ) -> Result<Self, super::super::codec::DecodeError> {
1704        let mut raw_id: Option<&super::super::codec::Value> = None;
1705        let mut raw_extension: Option<&super::super::codec::Value> = None;
1706        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1707        let mut raw_uri: Option<&super::super::codec::Value> = None;
1708        let mut raw_uri_element: Option<&super::super::codec::Value> = None;
1709        let mut raw_version: Option<&super::super::codec::Value> = None;
1710        let mut raw_content: Option<&super::super::codec::Value> = None;
1711        let mut raw_content_element: Option<&super::super::codec::Value> = None;
1712        let mut raw_subsumption: Option<&super::super::codec::Value> = None;
1713        let mut raw_subsumption_element: Option<&super::super::codec::Value> = None;
1714        for (key, value) in object {
1715            match key.as_str() {
1716                "id" => {
1717                    raw_id = Some(value);
1718                }
1719                "extension" => {
1720                    raw_extension = Some(value);
1721                }
1722                "modifierExtension" => {
1723                    raw_modifier_extension = Some(value);
1724                }
1725                "uri" => {
1726                    raw_uri = Some(value);
1727                }
1728                "_uri" => {
1729                    raw_uri_element = Some(value);
1730                }
1731                "version" => {
1732                    raw_version = Some(value);
1733                }
1734                "content" => {
1735                    raw_content = Some(value);
1736                }
1737                "_content" => {
1738                    raw_content_element = Some(value);
1739                }
1740                "subsumption" => {
1741                    raw_subsumption = Some(value);
1742                }
1743                "_subsumption" => {
1744                    raw_subsumption_element = Some(value);
1745                }
1746                other => {
1747                    return path.with(other, |path| {
1748                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1749                    });
1750                }
1751            }
1752        }
1753        let field_id = raw_id
1754            .map(|value| {
1755                path.with("id", |path| {
1756                    let value = super::super::codec::expect_single(value, path)?;
1757                    super::primitives::checked_string(
1758                        super::super::codec::expect_string(value, path)?,
1759                        path,
1760                    )
1761                })
1762            })
1763            .transpose()?;
1764        let mut field_extension = Vec::new();
1765        if let Some(raw) = raw_extension {
1766            for (index, value) in path
1767                .with("extension", |path| {
1768                    super::super::codec::expect_array(raw, path)
1769                })?
1770                .iter()
1771                .enumerate()
1772            {
1773                field_extension.push(path.with_index("extension", index, |path| {
1774                    super::super::codec::Json::from_json(
1775                        super::super::codec::expect_object(value, path)?,
1776                        path,
1777                    )
1778                })?);
1779            }
1780        }
1781        let mut field_modifier_extension = Vec::new();
1782        if let Some(raw) = raw_modifier_extension {
1783            for (index, value) in path
1784                .with("modifierExtension", |path| {
1785                    super::super::codec::expect_array(raw, path)
1786                })?
1787                .iter()
1788                .enumerate()
1789            {
1790                field_modifier_extension.push(path.with_index(
1791                    "modifierExtension",
1792                    index,
1793                    |path| {
1794                        super::super::codec::Json::from_json(
1795                            super::super::codec::expect_object(value, path)?,
1796                            path,
1797                        )
1798                    },
1799                )?);
1800            }
1801        }
1802        let field_uri = match (raw_uri, raw_uri_element) {
1803            (None, None) => None,
1804            (value, element) => Some(path.with("uri", |path| {
1805                super::super::codec::Primitive::from_json_parts(value, element, path)
1806            })?),
1807        };
1808        let mut field_version = Vec::new();
1809        if let Some(raw) = raw_version {
1810            for (index, value) in path
1811                .with("version", |path| {
1812                    super::super::codec::expect_array(raw, path)
1813                })?
1814                .iter()
1815                .enumerate()
1816            {
1817                field_version.push(path.with_index("version", index, |path| {
1818                    super::super::codec::Json::from_json(
1819                        super::super::codec::expect_object(value, path)?,
1820                        path,
1821                    )
1822                })?);
1823            }
1824        }
1825        let field_content = path.with("content", |path| {
1826            super::super::codec::Primitive::from_json_parts(raw_content, raw_content_element, path)
1827        })?;
1828        let field_subsumption = match (raw_subsumption, raw_subsumption_element) {
1829            (None, None) => None,
1830            (value, element) => Some(path.with("subsumption", |path| {
1831                super::super::codec::Primitive::from_json_parts(value, element, path)
1832            })?),
1833        };
1834        Ok(Self {
1835            id: field_id,
1836            extension: field_extension,
1837            modifier_extension: field_modifier_extension,
1838            uri: field_uri,
1839            version: field_version,
1840            content: field_content,
1841            subsumption: field_subsumption,
1842        })
1843    }
1844}
1845
1846impl serde::Serialize for TerminologyCapabilitiesCodeSystem {
1847    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1848        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1849        super::super::codec::element_entry(&mut map, "_content", &self.content)?;
1850        if let Some(item) = &self.subsumption {
1851            super::super::codec::element_entry(&mut map, "_subsumption", item)?;
1852        }
1853        if let Some(item) = &self.uri {
1854            super::super::codec::element_entry(&mut map, "_uri", item)?;
1855        }
1856        super::super::codec::value_entry(&mut map, "content", &self.content)?;
1857        if !self.extension.is_empty() {
1858            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1859        }
1860        if let Some(v) = &self.id {
1861            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1862        }
1863        if !self.modifier_extension.is_empty() {
1864            serde::ser::SerializeMap::serialize_entry(
1865                &mut map,
1866                "modifierExtension",
1867                &self.modifier_extension,
1868            )?;
1869        }
1870        if let Some(item) = &self.subsumption {
1871            super::super::codec::value_entry(&mut map, "subsumption", item)?;
1872        }
1873        if let Some(item) = &self.uri {
1874            super::super::codec::value_entry(&mut map, "uri", item)?;
1875        }
1876        if !self.version.is_empty() {
1877            serde::ser::SerializeMap::serialize_entry(&mut map, "version", &self.version)?;
1878        }
1879        serde::ser::SerializeMap::end(map)
1880    }
1881}
1882
1883impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesCodeSystem {
1884    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1885        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1886        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesCodeSystem");
1887        let object =
1888            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1889        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1890    }
1891}
1892
1893/// Version of Code System supported
1894///
1895/// For the code system, a list of versions that are supported by the server.
1896#[derive(Debug, Clone, Default, PartialEq, Eq)]
1897pub struct TerminologyCapabilitiesCodeSystemVersion {
1898    /// Unique id for inter-element referencing
1899    ///
1900    /// Unique id for the element within a resource (for internal references). This
1901    /// may be any string value that does not contain spaces.
1902    pub id: Option<std::string::String>,
1903    /// Additional content defined by implementations
1904    ///
1905    /// May be used to represent additional information that is not part of the
1906    /// basic definition of the element. To make the use of extensions safe and
1907    /// managable, there is a strict set of governance applied to the definition and
1908    /// use of extensions. Though any implementer can define an extension, there is
1909    /// a set of requirements that SHALL be met as part of the definition of the
1910    /// extension.
1911    pub extension: Vec<super::extension::Extension>,
1912    /// Extensions that cannot be ignored even if unrecognized
1913    ///
1914    /// May be used to represent additional information that is not part of the
1915    /// basic definition of the element and that modifies the understanding of the
1916    /// element in which it is contained and/or the understanding of the containing
1917    /// element's descendants. Usually modifier elements provide negation or
1918    /// qualification. To make the use of extensions safe and managable, there is a
1919    /// strict set of governance applied to the definition and use of extensions.
1920    /// Though any implementer can define an extension, there is a set of
1921    /// requirements that SHALL be met as part of the definition of the extension.
1922    /// Applications processing a resource are required to check for modifier
1923    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1924    /// on Resource or DomainResource (including cannot change the meaning of
1925    /// modifierExtension itself).
1926    pub modifier_extension: Vec<super::extension::Extension>,
1927    /// Version identifier for this version
1928    ///
1929    /// For version-less code systems, there should be a single version with no
1930    /// identifier.
1931    pub code: Option<super::primitives::String>,
1932    /// If this is the default version for this code system.
1933    pub is_default: Option<super::primitives::Boolean>,
1934    /// If compositional grammar is supported
1935    ///
1936    /// If the compositional grammar defined by the code system is supported.
1937    pub compositional: Option<super::primitives::Boolean>,
1938    /// Language Displays supported.
1939    pub language: Vec<super::primitives::Code>,
1940    /// Filter Properties supported.
1941    pub filter: Vec<TerminologyCapabilitiesCodeSystemVersionFilter>,
1942    /// Properties supported for $lookup.
1943    pub property: Vec<super::primitives::Code>,
1944}
1945
1946impl super::super::codec::Json for TerminologyCapabilitiesCodeSystemVersion {
1947    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1948        let mut object = super::super::codec::Object::new();
1949        if let Some(v) = &self.id {
1950            object.insert(
1951                std::string::String::from("id"),
1952                super::super::codec::Value::String(v.clone()),
1953            );
1954        }
1955        if !self.extension.is_empty() {
1956            let mut items = Vec::with_capacity(self.extension.len());
1957            for item in &self.extension {
1958                items.push(super::super::codec::Value::Object(
1959                    super::super::codec::Json::to_json(item)?,
1960                ));
1961            }
1962            object.insert(
1963                std::string::String::from("extension"),
1964                super::super::codec::Value::Array(items),
1965            );
1966        }
1967        if !self.modifier_extension.is_empty() {
1968            let mut items = Vec::with_capacity(self.modifier_extension.len());
1969            for item in &self.modifier_extension {
1970                items.push(super::super::codec::Value::Object(
1971                    super::super::codec::Json::to_json(item)?,
1972                ));
1973            }
1974            object.insert(
1975                std::string::String::from("modifierExtension"),
1976                super::super::codec::Value::Array(items),
1977            );
1978        }
1979        if let Some(item) = &self.code {
1980            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1981                object.insert(std::string::String::from("code"), v);
1982            }
1983            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1984                object.insert(std::string::String::from("_code"), e);
1985            }
1986        }
1987        if let Some(item) = &self.is_default {
1988            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1989                object.insert(std::string::String::from("isDefault"), v);
1990            }
1991            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1992                object.insert(std::string::String::from("_isDefault"), e);
1993            }
1994        }
1995        if let Some(item) = &self.compositional {
1996            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1997                object.insert(std::string::String::from("compositional"), v);
1998            }
1999            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2000                object.insert(std::string::String::from("_compositional"), e);
2001            }
2002        }
2003        if !self.language.is_empty() {
2004            let (values, elements) = super::super::codec::primitive_arrays(&self.language)?;
2005            if let Some(values) = values {
2006                object.insert(std::string::String::from("language"), values);
2007            }
2008            if let Some(elements) = elements {
2009                object.insert(std::string::String::from("_language"), elements);
2010            }
2011        }
2012        if !self.filter.is_empty() {
2013            let mut items = Vec::with_capacity(self.filter.len());
2014            for item in &self.filter {
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("filter"),
2021                super::super::codec::Value::Array(items),
2022            );
2023        }
2024        if !self.property.is_empty() {
2025            let (values, elements) = super::super::codec::primitive_arrays(&self.property)?;
2026            if let Some(values) = values {
2027                object.insert(std::string::String::from("property"), values);
2028            }
2029            if let Some(elements) = elements {
2030                object.insert(std::string::String::from("_property"), elements);
2031            }
2032        }
2033        Ok(object)
2034    }
2035
2036    fn from_json(
2037        object: &super::super::codec::Object,
2038        path: &mut super::super::codec::Path,
2039    ) -> Result<Self, super::super::codec::DecodeError> {
2040        let mut raw_id: Option<&super::super::codec::Value> = None;
2041        let mut raw_extension: Option<&super::super::codec::Value> = None;
2042        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2043        let mut raw_code: Option<&super::super::codec::Value> = None;
2044        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2045        let mut raw_is_default: Option<&super::super::codec::Value> = None;
2046        let mut raw_is_default_element: Option<&super::super::codec::Value> = None;
2047        let mut raw_compositional: Option<&super::super::codec::Value> = None;
2048        let mut raw_compositional_element: Option<&super::super::codec::Value> = None;
2049        let mut raw_language: Option<&super::super::codec::Value> = None;
2050        let mut raw_language_element: Option<&super::super::codec::Value> = None;
2051        let mut raw_filter: Option<&super::super::codec::Value> = None;
2052        let mut raw_property: Option<&super::super::codec::Value> = None;
2053        let mut raw_property_element: Option<&super::super::codec::Value> = None;
2054        for (key, value) in object {
2055            match key.as_str() {
2056                "id" => {
2057                    raw_id = Some(value);
2058                }
2059                "extension" => {
2060                    raw_extension = Some(value);
2061                }
2062                "modifierExtension" => {
2063                    raw_modifier_extension = Some(value);
2064                }
2065                "code" => {
2066                    raw_code = Some(value);
2067                }
2068                "_code" => {
2069                    raw_code_element = Some(value);
2070                }
2071                "isDefault" => {
2072                    raw_is_default = Some(value);
2073                }
2074                "_isDefault" => {
2075                    raw_is_default_element = Some(value);
2076                }
2077                "compositional" => {
2078                    raw_compositional = Some(value);
2079                }
2080                "_compositional" => {
2081                    raw_compositional_element = Some(value);
2082                }
2083                "language" => {
2084                    raw_language = Some(value);
2085                }
2086                "_language" => {
2087                    raw_language_element = Some(value);
2088                }
2089                "filter" => {
2090                    raw_filter = Some(value);
2091                }
2092                "property" => {
2093                    raw_property = Some(value);
2094                }
2095                "_property" => {
2096                    raw_property_element = Some(value);
2097                }
2098                other => {
2099                    return path.with(other, |path| {
2100                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2101                    });
2102                }
2103            }
2104        }
2105        let field_id = raw_id
2106            .map(|value| {
2107                path.with("id", |path| {
2108                    let value = super::super::codec::expect_single(value, path)?;
2109                    super::primitives::checked_string(
2110                        super::super::codec::expect_string(value, path)?,
2111                        path,
2112                    )
2113                })
2114            })
2115            .transpose()?;
2116        let mut field_extension = Vec::new();
2117        if let Some(raw) = raw_extension {
2118            for (index, value) in path
2119                .with("extension", |path| {
2120                    super::super::codec::expect_array(raw, path)
2121                })?
2122                .iter()
2123                .enumerate()
2124            {
2125                field_extension.push(path.with_index("extension", index, |path| {
2126                    super::super::codec::Json::from_json(
2127                        super::super::codec::expect_object(value, path)?,
2128                        path,
2129                    )
2130                })?);
2131            }
2132        }
2133        let mut field_modifier_extension = Vec::new();
2134        if let Some(raw) = raw_modifier_extension {
2135            for (index, value) in path
2136                .with("modifierExtension", |path| {
2137                    super::super::codec::expect_array(raw, path)
2138                })?
2139                .iter()
2140                .enumerate()
2141            {
2142                field_modifier_extension.push(path.with_index(
2143                    "modifierExtension",
2144                    index,
2145                    |path| {
2146                        super::super::codec::Json::from_json(
2147                            super::super::codec::expect_object(value, path)?,
2148                            path,
2149                        )
2150                    },
2151                )?);
2152            }
2153        }
2154        let field_code = match (raw_code, raw_code_element) {
2155            (None, None) => None,
2156            (value, element) => Some(path.with("code", |path| {
2157                super::super::codec::Primitive::from_json_parts(value, element, path)
2158            })?),
2159        };
2160        let field_is_default = match (raw_is_default, raw_is_default_element) {
2161            (None, None) => None,
2162            (value, element) => Some(path.with("isDefault", |path| {
2163                super::super::codec::Primitive::from_json_parts(value, element, path)
2164            })?),
2165        };
2166        let field_compositional = match (raw_compositional, raw_compositional_element) {
2167            (None, None) => None,
2168            (value, element) => Some(path.with("compositional", |path| {
2169                super::super::codec::Primitive::from_json_parts(value, element, path)
2170            })?),
2171        };
2172        let mut field_language = Vec::new();
2173        for (index, (value, element)) in path
2174            .with("language", |path| {
2175                super::super::codec::pair_arrays(raw_language, raw_language_element, path)
2176            })?
2177            .into_iter()
2178            .enumerate()
2179        {
2180            field_language.push(path.with_index("language", index, |path| {
2181                super::super::codec::Primitive::from_json_parts(value, element, path)
2182            })?);
2183        }
2184        let mut field_filter = Vec::new();
2185        if let Some(raw) = raw_filter {
2186            for (index, value) in path
2187                .with("filter", |path| {
2188                    super::super::codec::expect_array(raw, path)
2189                })?
2190                .iter()
2191                .enumerate()
2192            {
2193                field_filter.push(path.with_index("filter", index, |path| {
2194                    super::super::codec::Json::from_json(
2195                        super::super::codec::expect_object(value, path)?,
2196                        path,
2197                    )
2198                })?);
2199            }
2200        }
2201        let mut field_property = Vec::new();
2202        for (index, (value, element)) in path
2203            .with("property", |path| {
2204                super::super::codec::pair_arrays(raw_property, raw_property_element, path)
2205            })?
2206            .into_iter()
2207            .enumerate()
2208        {
2209            field_property.push(path.with_index("property", index, |path| {
2210                super::super::codec::Primitive::from_json_parts(value, element, path)
2211            })?);
2212        }
2213        Ok(Self {
2214            id: field_id,
2215            extension: field_extension,
2216            modifier_extension: field_modifier_extension,
2217            code: field_code,
2218            is_default: field_is_default,
2219            compositional: field_compositional,
2220            language: field_language,
2221            filter: field_filter,
2222            property: field_property,
2223        })
2224    }
2225}
2226
2227impl serde::Serialize for TerminologyCapabilitiesCodeSystemVersion {
2228    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2229        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2230        if let Some(item) = &self.code {
2231            super::super::codec::element_entry(&mut map, "_code", item)?;
2232        }
2233        if let Some(item) = &self.compositional {
2234            super::super::codec::element_entry(&mut map, "_compositional", item)?;
2235        }
2236        if let Some(item) = &self.is_default {
2237            super::super::codec::element_entry(&mut map, "_isDefault", item)?;
2238        }
2239        super::super::codec::element_list_entry(&mut map, "_language", &self.language)?;
2240        super::super::codec::element_list_entry(&mut map, "_property", &self.property)?;
2241        if let Some(item) = &self.code {
2242            super::super::codec::value_entry(&mut map, "code", item)?;
2243        }
2244        if let Some(item) = &self.compositional {
2245            super::super::codec::value_entry(&mut map, "compositional", item)?;
2246        }
2247        if !self.extension.is_empty() {
2248            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2249        }
2250        if !self.filter.is_empty() {
2251            serde::ser::SerializeMap::serialize_entry(&mut map, "filter", &self.filter)?;
2252        }
2253        if let Some(v) = &self.id {
2254            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2255        }
2256        if let Some(item) = &self.is_default {
2257            super::super::codec::value_entry(&mut map, "isDefault", item)?;
2258        }
2259        super::super::codec::value_list_entry(&mut map, "language", &self.language)?;
2260        if !self.modifier_extension.is_empty() {
2261            serde::ser::SerializeMap::serialize_entry(
2262                &mut map,
2263                "modifierExtension",
2264                &self.modifier_extension,
2265            )?;
2266        }
2267        super::super::codec::value_list_entry(&mut map, "property", &self.property)?;
2268        serde::ser::SerializeMap::end(map)
2269    }
2270}
2271
2272impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesCodeSystemVersion {
2273    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2274        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2275        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesCodeSystemVersion");
2276        let object =
2277            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2278        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2279    }
2280}
2281
2282/// Filter Properties supported.
2283#[derive(Debug, Clone, Default, PartialEq, Eq)]
2284pub struct TerminologyCapabilitiesCodeSystemVersionFilter {
2285    /// Unique id for inter-element referencing
2286    ///
2287    /// Unique id for the element within a resource (for internal references). This
2288    /// may be any string value that does not contain spaces.
2289    pub id: Option<std::string::String>,
2290    /// Additional content defined by implementations
2291    ///
2292    /// May be used to represent additional information that is not part of the
2293    /// basic definition of the element. To make the use of extensions safe and
2294    /// managable, there is a strict set of governance applied to the definition and
2295    /// use of extensions. Though any implementer can define an extension, there is
2296    /// a set of requirements that SHALL be met as part of the definition of the
2297    /// extension.
2298    pub extension: Vec<super::extension::Extension>,
2299    /// Extensions that cannot be ignored even if unrecognized
2300    ///
2301    /// May be used to represent additional information that is not part of the
2302    /// basic definition of the element and that modifies the understanding of the
2303    /// element in which it is contained and/or the understanding of the containing
2304    /// element's descendants. Usually modifier elements provide negation or
2305    /// qualification. To make the use of extensions safe and managable, there is a
2306    /// strict set of governance applied to the definition and use of extensions.
2307    /// Though any implementer can define an extension, there is a set of
2308    /// requirements that SHALL be met as part of the definition of the extension.
2309    /// Applications processing a resource are required to check for modifier
2310    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2311    /// on Resource or DomainResource (including cannot change the meaning of
2312    /// modifierExtension itself).
2313    pub modifier_extension: Vec<super::extension::Extension>,
2314    /// Code of the property supported.
2315    pub code: super::primitives::Code,
2316    /// Operations supported for the property.
2317    pub op: Vec<super::primitives::Code>,
2318}
2319
2320impl super::super::codec::Json for TerminologyCapabilitiesCodeSystemVersionFilter {
2321    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2322        let mut object = super::super::codec::Object::new();
2323        if let Some(v) = &self.id {
2324            object.insert(
2325                std::string::String::from("id"),
2326                super::super::codec::Value::String(v.clone()),
2327            );
2328        }
2329        if !self.extension.is_empty() {
2330            let mut items = Vec::with_capacity(self.extension.len());
2331            for item in &self.extension {
2332                items.push(super::super::codec::Value::Object(
2333                    super::super::codec::Json::to_json(item)?,
2334                ));
2335            }
2336            object.insert(
2337                std::string::String::from("extension"),
2338                super::super::codec::Value::Array(items),
2339            );
2340        }
2341        if !self.modifier_extension.is_empty() {
2342            let mut items = Vec::with_capacity(self.modifier_extension.len());
2343            for item in &self.modifier_extension {
2344                items.push(super::super::codec::Value::Object(
2345                    super::super::codec::Json::to_json(item)?,
2346                ));
2347            }
2348            object.insert(
2349                std::string::String::from("modifierExtension"),
2350                super::super::codec::Value::Array(items),
2351            );
2352        }
2353        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
2354            object.insert(std::string::String::from("code"), v);
2355        }
2356        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
2357            object.insert(std::string::String::from("_code"), e);
2358        }
2359        if !self.op.is_empty() {
2360            let (values, elements) = super::super::codec::primitive_arrays(&self.op)?;
2361            if let Some(values) = values {
2362                object.insert(std::string::String::from("op"), values);
2363            }
2364            if let Some(elements) = elements {
2365                object.insert(std::string::String::from("_op"), elements);
2366            }
2367        }
2368        Ok(object)
2369    }
2370
2371    fn from_json(
2372        object: &super::super::codec::Object,
2373        path: &mut super::super::codec::Path,
2374    ) -> Result<Self, super::super::codec::DecodeError> {
2375        let mut raw_id: Option<&super::super::codec::Value> = None;
2376        let mut raw_extension: Option<&super::super::codec::Value> = None;
2377        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2378        let mut raw_code: Option<&super::super::codec::Value> = None;
2379        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2380        let mut raw_op: Option<&super::super::codec::Value> = None;
2381        let mut raw_op_element: Option<&super::super::codec::Value> = None;
2382        for (key, value) in object {
2383            match key.as_str() {
2384                "id" => {
2385                    raw_id = Some(value);
2386                }
2387                "extension" => {
2388                    raw_extension = Some(value);
2389                }
2390                "modifierExtension" => {
2391                    raw_modifier_extension = Some(value);
2392                }
2393                "code" => {
2394                    raw_code = Some(value);
2395                }
2396                "_code" => {
2397                    raw_code_element = Some(value);
2398                }
2399                "op" => {
2400                    raw_op = Some(value);
2401                }
2402                "_op" => {
2403                    raw_op_element = Some(value);
2404                }
2405                other => {
2406                    return path.with(other, |path| {
2407                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2408                    });
2409                }
2410            }
2411        }
2412        let field_id = raw_id
2413            .map(|value| {
2414                path.with("id", |path| {
2415                    let value = super::super::codec::expect_single(value, path)?;
2416                    super::primitives::checked_string(
2417                        super::super::codec::expect_string(value, path)?,
2418                        path,
2419                    )
2420                })
2421            })
2422            .transpose()?;
2423        let mut field_extension = Vec::new();
2424        if let Some(raw) = raw_extension {
2425            for (index, value) in path
2426                .with("extension", |path| {
2427                    super::super::codec::expect_array(raw, path)
2428                })?
2429                .iter()
2430                .enumerate()
2431            {
2432                field_extension.push(path.with_index("extension", index, |path| {
2433                    super::super::codec::Json::from_json(
2434                        super::super::codec::expect_object(value, path)?,
2435                        path,
2436                    )
2437                })?);
2438            }
2439        }
2440        let mut field_modifier_extension = Vec::new();
2441        if let Some(raw) = raw_modifier_extension {
2442            for (index, value) in path
2443                .with("modifierExtension", |path| {
2444                    super::super::codec::expect_array(raw, path)
2445                })?
2446                .iter()
2447                .enumerate()
2448            {
2449                field_modifier_extension.push(path.with_index(
2450                    "modifierExtension",
2451                    index,
2452                    |path| {
2453                        super::super::codec::Json::from_json(
2454                            super::super::codec::expect_object(value, path)?,
2455                            path,
2456                        )
2457                    },
2458                )?);
2459            }
2460        }
2461        let field_code = path.with("code", |path| {
2462            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
2463        })?;
2464        let mut field_op = Vec::new();
2465        for (index, (value, element)) in path
2466            .with("op", |path| {
2467                super::super::codec::pair_arrays(raw_op, raw_op_element, path)
2468            })?
2469            .into_iter()
2470            .enumerate()
2471        {
2472            field_op.push(path.with_index("op", index, |path| {
2473                super::super::codec::Primitive::from_json_parts(value, element, path)
2474            })?);
2475        }
2476        if field_op.is_empty() && !path.is_lenient() {
2477            return path.with("op", |path| {
2478                Err(path.error(super::super::codec::DecodeErrorKind::MissingProperty))
2479            });
2480        }
2481        Ok(Self {
2482            id: field_id,
2483            extension: field_extension,
2484            modifier_extension: field_modifier_extension,
2485            code: field_code,
2486            op: field_op,
2487        })
2488    }
2489}
2490
2491impl serde::Serialize for TerminologyCapabilitiesCodeSystemVersionFilter {
2492    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2493        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2494        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
2495        super::super::codec::element_list_entry(&mut map, "_op", &self.op)?;
2496        super::super::codec::value_entry(&mut map, "code", &self.code)?;
2497        if !self.extension.is_empty() {
2498            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2499        }
2500        if let Some(v) = &self.id {
2501            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2502        }
2503        if !self.modifier_extension.is_empty() {
2504            serde::ser::SerializeMap::serialize_entry(
2505                &mut map,
2506                "modifierExtension",
2507                &self.modifier_extension,
2508            )?;
2509        }
2510        super::super::codec::value_list_entry(&mut map, "op", &self.op)?;
2511        serde::ser::SerializeMap::end(map)
2512    }
2513}
2514
2515impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesCodeSystemVersionFilter {
2516    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2517        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2518        let mut path =
2519            super::super::codec::Path::root("TerminologyCapabilitiesCodeSystemVersionFilter");
2520        let object =
2521            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2522        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2523    }
2524}
2525
2526/// Information about the \[ValueSet/$expand\](valueset-operation-expand.html)
2527/// operation.
2528#[derive(Debug, Clone, Default, PartialEq, Eq)]
2529pub struct TerminologyCapabilitiesExpansion {
2530    /// Unique id for inter-element referencing
2531    ///
2532    /// Unique id for the element within a resource (for internal references). This
2533    /// may be any string value that does not contain spaces.
2534    pub id: Option<std::string::String>,
2535    /// Additional content defined by implementations
2536    ///
2537    /// May be used to represent additional information that is not part of the
2538    /// basic definition of the element. To make the use of extensions safe and
2539    /// managable, there is a strict set of governance applied to the definition and
2540    /// use of extensions. Though any implementer can define an extension, there is
2541    /// a set of requirements that SHALL be met as part of the definition of the
2542    /// extension.
2543    pub extension: Vec<super::extension::Extension>,
2544    /// Extensions that cannot be ignored even if unrecognized
2545    ///
2546    /// May be used to represent additional information that is not part of the
2547    /// basic definition of the element and that modifies the understanding of the
2548    /// element in which it is contained and/or the understanding of the containing
2549    /// element's descendants. Usually modifier elements provide negation or
2550    /// qualification. To make the use of extensions safe and managable, there is a
2551    /// strict set of governance applied to the definition and use of extensions.
2552    /// Though any implementer can define an extension, there is a set of
2553    /// requirements that SHALL be met as part of the definition of the extension.
2554    /// Applications processing a resource are required to check for modifier
2555    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2556    /// on Resource or DomainResource (including cannot change the meaning of
2557    /// modifierExtension itself).
2558    pub modifier_extension: Vec<super::extension::Extension>,
2559    /// Whether the server can return nested value sets.
2560    pub hierarchical: Option<super::primitives::Boolean>,
2561    /// Whether the server supports paging on expansion.
2562    pub paging: Option<super::primitives::Boolean>,
2563    /// Allow request for incomplete expansions?
2564    ///
2565    /// True if requests for incomplete expansions are allowed.
2566    pub incomplete: Option<super::primitives::Boolean>,
2567    /// Supported expansion parameter.
2568    pub parameter: Vec<TerminologyCapabilitiesExpansionParameter>,
2569    /// Documentation about text searching works.
2570    pub text_filter: Option<super::primitives::Markdown>,
2571}
2572
2573impl super::super::codec::Json for TerminologyCapabilitiesExpansion {
2574    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2575        let mut object = super::super::codec::Object::new();
2576        if let Some(v) = &self.id {
2577            object.insert(
2578                std::string::String::from("id"),
2579                super::super::codec::Value::String(v.clone()),
2580            );
2581        }
2582        if !self.extension.is_empty() {
2583            let mut items = Vec::with_capacity(self.extension.len());
2584            for item in &self.extension {
2585                items.push(super::super::codec::Value::Object(
2586                    super::super::codec::Json::to_json(item)?,
2587                ));
2588            }
2589            object.insert(
2590                std::string::String::from("extension"),
2591                super::super::codec::Value::Array(items),
2592            );
2593        }
2594        if !self.modifier_extension.is_empty() {
2595            let mut items = Vec::with_capacity(self.modifier_extension.len());
2596            for item in &self.modifier_extension {
2597                items.push(super::super::codec::Value::Object(
2598                    super::super::codec::Json::to_json(item)?,
2599                ));
2600            }
2601            object.insert(
2602                std::string::String::from("modifierExtension"),
2603                super::super::codec::Value::Array(items),
2604            );
2605        }
2606        if let Some(item) = &self.hierarchical {
2607            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2608                object.insert(std::string::String::from("hierarchical"), v);
2609            }
2610            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2611                object.insert(std::string::String::from("_hierarchical"), e);
2612            }
2613        }
2614        if let Some(item) = &self.paging {
2615            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2616                object.insert(std::string::String::from("paging"), v);
2617            }
2618            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2619                object.insert(std::string::String::from("_paging"), e);
2620            }
2621        }
2622        if let Some(item) = &self.incomplete {
2623            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2624                object.insert(std::string::String::from("incomplete"), v);
2625            }
2626            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2627                object.insert(std::string::String::from("_incomplete"), e);
2628            }
2629        }
2630        if !self.parameter.is_empty() {
2631            let mut items = Vec::with_capacity(self.parameter.len());
2632            for item in &self.parameter {
2633                items.push(super::super::codec::Value::Object(
2634                    super::super::codec::Json::to_json(item)?,
2635                ));
2636            }
2637            object.insert(
2638                std::string::String::from("parameter"),
2639                super::super::codec::Value::Array(items),
2640            );
2641        }
2642        if let Some(item) = &self.text_filter {
2643            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2644                object.insert(std::string::String::from("textFilter"), v);
2645            }
2646            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2647                object.insert(std::string::String::from("_textFilter"), e);
2648            }
2649        }
2650        Ok(object)
2651    }
2652
2653    fn from_json(
2654        object: &super::super::codec::Object,
2655        path: &mut super::super::codec::Path,
2656    ) -> Result<Self, super::super::codec::DecodeError> {
2657        let mut raw_id: Option<&super::super::codec::Value> = None;
2658        let mut raw_extension: Option<&super::super::codec::Value> = None;
2659        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2660        let mut raw_hierarchical: Option<&super::super::codec::Value> = None;
2661        let mut raw_hierarchical_element: Option<&super::super::codec::Value> = None;
2662        let mut raw_paging: Option<&super::super::codec::Value> = None;
2663        let mut raw_paging_element: Option<&super::super::codec::Value> = None;
2664        let mut raw_incomplete: Option<&super::super::codec::Value> = None;
2665        let mut raw_incomplete_element: Option<&super::super::codec::Value> = None;
2666        let mut raw_parameter: Option<&super::super::codec::Value> = None;
2667        let mut raw_text_filter: Option<&super::super::codec::Value> = None;
2668        let mut raw_text_filter_element: Option<&super::super::codec::Value> = None;
2669        for (key, value) in object {
2670            match key.as_str() {
2671                "id" => {
2672                    raw_id = Some(value);
2673                }
2674                "extension" => {
2675                    raw_extension = Some(value);
2676                }
2677                "modifierExtension" => {
2678                    raw_modifier_extension = Some(value);
2679                }
2680                "hierarchical" => {
2681                    raw_hierarchical = Some(value);
2682                }
2683                "_hierarchical" => {
2684                    raw_hierarchical_element = Some(value);
2685                }
2686                "paging" => {
2687                    raw_paging = Some(value);
2688                }
2689                "_paging" => {
2690                    raw_paging_element = Some(value);
2691                }
2692                "incomplete" => {
2693                    raw_incomplete = Some(value);
2694                }
2695                "_incomplete" => {
2696                    raw_incomplete_element = Some(value);
2697                }
2698                "parameter" => {
2699                    raw_parameter = Some(value);
2700                }
2701                "textFilter" => {
2702                    raw_text_filter = Some(value);
2703                }
2704                "_textFilter" => {
2705                    raw_text_filter_element = Some(value);
2706                }
2707                other => {
2708                    return path.with(other, |path| {
2709                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2710                    });
2711                }
2712            }
2713        }
2714        let field_id = raw_id
2715            .map(|value| {
2716                path.with("id", |path| {
2717                    let value = super::super::codec::expect_single(value, path)?;
2718                    super::primitives::checked_string(
2719                        super::super::codec::expect_string(value, path)?,
2720                        path,
2721                    )
2722                })
2723            })
2724            .transpose()?;
2725        let mut field_extension = Vec::new();
2726        if let Some(raw) = raw_extension {
2727            for (index, value) in path
2728                .with("extension", |path| {
2729                    super::super::codec::expect_array(raw, path)
2730                })?
2731                .iter()
2732                .enumerate()
2733            {
2734                field_extension.push(path.with_index("extension", index, |path| {
2735                    super::super::codec::Json::from_json(
2736                        super::super::codec::expect_object(value, path)?,
2737                        path,
2738                    )
2739                })?);
2740            }
2741        }
2742        let mut field_modifier_extension = Vec::new();
2743        if let Some(raw) = raw_modifier_extension {
2744            for (index, value) in path
2745                .with("modifierExtension", |path| {
2746                    super::super::codec::expect_array(raw, path)
2747                })?
2748                .iter()
2749                .enumerate()
2750            {
2751                field_modifier_extension.push(path.with_index(
2752                    "modifierExtension",
2753                    index,
2754                    |path| {
2755                        super::super::codec::Json::from_json(
2756                            super::super::codec::expect_object(value, path)?,
2757                            path,
2758                        )
2759                    },
2760                )?);
2761            }
2762        }
2763        let field_hierarchical = match (raw_hierarchical, raw_hierarchical_element) {
2764            (None, None) => None,
2765            (value, element) => Some(path.with("hierarchical", |path| {
2766                super::super::codec::Primitive::from_json_parts(value, element, path)
2767            })?),
2768        };
2769        let field_paging = match (raw_paging, raw_paging_element) {
2770            (None, None) => None,
2771            (value, element) => Some(path.with("paging", |path| {
2772                super::super::codec::Primitive::from_json_parts(value, element, path)
2773            })?),
2774        };
2775        let field_incomplete = match (raw_incomplete, raw_incomplete_element) {
2776            (None, None) => None,
2777            (value, element) => Some(path.with("incomplete", |path| {
2778                super::super::codec::Primitive::from_json_parts(value, element, path)
2779            })?),
2780        };
2781        let mut field_parameter = Vec::new();
2782        if let Some(raw) = raw_parameter {
2783            for (index, value) in path
2784                .with("parameter", |path| {
2785                    super::super::codec::expect_array(raw, path)
2786                })?
2787                .iter()
2788                .enumerate()
2789            {
2790                field_parameter.push(path.with_index("parameter", index, |path| {
2791                    super::super::codec::Json::from_json(
2792                        super::super::codec::expect_object(value, path)?,
2793                        path,
2794                    )
2795                })?);
2796            }
2797        }
2798        let field_text_filter = match (raw_text_filter, raw_text_filter_element) {
2799            (None, None) => None,
2800            (value, element) => Some(path.with("textFilter", |path| {
2801                super::super::codec::Primitive::from_json_parts(value, element, path)
2802            })?),
2803        };
2804        Ok(Self {
2805            id: field_id,
2806            extension: field_extension,
2807            modifier_extension: field_modifier_extension,
2808            hierarchical: field_hierarchical,
2809            paging: field_paging,
2810            incomplete: field_incomplete,
2811            parameter: field_parameter,
2812            text_filter: field_text_filter,
2813        })
2814    }
2815}
2816
2817impl serde::Serialize for TerminologyCapabilitiesExpansion {
2818    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2819        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2820        if let Some(item) = &self.hierarchical {
2821            super::super::codec::element_entry(&mut map, "_hierarchical", item)?;
2822        }
2823        if let Some(item) = &self.incomplete {
2824            super::super::codec::element_entry(&mut map, "_incomplete", item)?;
2825        }
2826        if let Some(item) = &self.paging {
2827            super::super::codec::element_entry(&mut map, "_paging", item)?;
2828        }
2829        if let Some(item) = &self.text_filter {
2830            super::super::codec::element_entry(&mut map, "_textFilter", item)?;
2831        }
2832        if !self.extension.is_empty() {
2833            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2834        }
2835        if let Some(item) = &self.hierarchical {
2836            super::super::codec::value_entry(&mut map, "hierarchical", item)?;
2837        }
2838        if let Some(v) = &self.id {
2839            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2840        }
2841        if let Some(item) = &self.incomplete {
2842            super::super::codec::value_entry(&mut map, "incomplete", item)?;
2843        }
2844        if !self.modifier_extension.is_empty() {
2845            serde::ser::SerializeMap::serialize_entry(
2846                &mut map,
2847                "modifierExtension",
2848                &self.modifier_extension,
2849            )?;
2850        }
2851        if let Some(item) = &self.paging {
2852            super::super::codec::value_entry(&mut map, "paging", item)?;
2853        }
2854        if !self.parameter.is_empty() {
2855            serde::ser::SerializeMap::serialize_entry(&mut map, "parameter", &self.parameter)?;
2856        }
2857        if let Some(item) = &self.text_filter {
2858            super::super::codec::value_entry(&mut map, "textFilter", item)?;
2859        }
2860        serde::ser::SerializeMap::end(map)
2861    }
2862}
2863
2864impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesExpansion {
2865    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2866        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2867        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesExpansion");
2868        let object =
2869            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2870        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2871    }
2872}
2873
2874/// Supported expansion parameter.
2875#[derive(Debug, Clone, Default, PartialEq, Eq)]
2876pub struct TerminologyCapabilitiesExpansionParameter {
2877    /// Unique id for inter-element referencing
2878    ///
2879    /// Unique id for the element within a resource (for internal references). This
2880    /// may be any string value that does not contain spaces.
2881    pub id: Option<std::string::String>,
2882    /// Additional content defined by implementations
2883    ///
2884    /// May be used to represent additional information that is not part of the
2885    /// basic definition of the element. To make the use of extensions safe and
2886    /// managable, there is a strict set of governance applied to the definition and
2887    /// use of extensions. Though any implementer can define an extension, there is
2888    /// a set of requirements that SHALL be met as part of the definition of the
2889    /// extension.
2890    pub extension: Vec<super::extension::Extension>,
2891    /// Extensions that cannot be ignored even if unrecognized
2892    ///
2893    /// May be used to represent additional information that is not part of the
2894    /// basic definition of the element and that modifies the understanding of the
2895    /// element in which it is contained and/or the understanding of the containing
2896    /// element's descendants. Usually modifier elements provide negation or
2897    /// qualification. To make the use of extensions safe and managable, there is a
2898    /// strict set of governance applied to the definition and use of extensions.
2899    /// Though any implementer can define an extension, there is a set of
2900    /// requirements that SHALL be met as part of the definition of the extension.
2901    /// Applications processing a resource are required to check for modifier
2902    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2903    /// on Resource or DomainResource (including cannot change the meaning of
2904    /// modifierExtension itself).
2905    pub modifier_extension: Vec<super::extension::Extension>,
2906    /// Name of the supported expansion parameter.
2907    pub name: super::primitives::Code,
2908    /// Description of support for parameter.
2909    pub documentation: Option<super::primitives::String>,
2910}
2911
2912impl super::super::codec::Json for TerminologyCapabilitiesExpansionParameter {
2913    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2914        let mut object = super::super::codec::Object::new();
2915        if let Some(v) = &self.id {
2916            object.insert(
2917                std::string::String::from("id"),
2918                super::super::codec::Value::String(v.clone()),
2919            );
2920        }
2921        if !self.extension.is_empty() {
2922            let mut items = Vec::with_capacity(self.extension.len());
2923            for item in &self.extension {
2924                items.push(super::super::codec::Value::Object(
2925                    super::super::codec::Json::to_json(item)?,
2926                ));
2927            }
2928            object.insert(
2929                std::string::String::from("extension"),
2930                super::super::codec::Value::Array(items),
2931            );
2932        }
2933        if !self.modifier_extension.is_empty() {
2934            let mut items = Vec::with_capacity(self.modifier_extension.len());
2935            for item in &self.modifier_extension {
2936                items.push(super::super::codec::Value::Object(
2937                    super::super::codec::Json::to_json(item)?,
2938                ));
2939            }
2940            object.insert(
2941                std::string::String::from("modifierExtension"),
2942                super::super::codec::Value::Array(items),
2943            );
2944        }
2945        if let Some(v) = super::super::codec::Primitive::value_json(&self.name)? {
2946            object.insert(std::string::String::from("name"), v);
2947        }
2948        if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
2949            object.insert(std::string::String::from("_name"), e);
2950        }
2951        if let Some(item) = &self.documentation {
2952            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2953                object.insert(std::string::String::from("documentation"), v);
2954            }
2955            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2956                object.insert(std::string::String::from("_documentation"), e);
2957            }
2958        }
2959        Ok(object)
2960    }
2961
2962    fn from_json(
2963        object: &super::super::codec::Object,
2964        path: &mut super::super::codec::Path,
2965    ) -> Result<Self, super::super::codec::DecodeError> {
2966        let mut raw_id: Option<&super::super::codec::Value> = None;
2967        let mut raw_extension: Option<&super::super::codec::Value> = None;
2968        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2969        let mut raw_name: Option<&super::super::codec::Value> = None;
2970        let mut raw_name_element: Option<&super::super::codec::Value> = None;
2971        let mut raw_documentation: Option<&super::super::codec::Value> = None;
2972        let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
2973        for (key, value) in object {
2974            match key.as_str() {
2975                "id" => {
2976                    raw_id = Some(value);
2977                }
2978                "extension" => {
2979                    raw_extension = Some(value);
2980                }
2981                "modifierExtension" => {
2982                    raw_modifier_extension = Some(value);
2983                }
2984                "name" => {
2985                    raw_name = Some(value);
2986                }
2987                "_name" => {
2988                    raw_name_element = Some(value);
2989                }
2990                "documentation" => {
2991                    raw_documentation = Some(value);
2992                }
2993                "_documentation" => {
2994                    raw_documentation_element = Some(value);
2995                }
2996                other => {
2997                    return path.with(other, |path| {
2998                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2999                    });
3000                }
3001            }
3002        }
3003        let field_id = raw_id
3004            .map(|value| {
3005                path.with("id", |path| {
3006                    let value = super::super::codec::expect_single(value, path)?;
3007                    super::primitives::checked_string(
3008                        super::super::codec::expect_string(value, path)?,
3009                        path,
3010                    )
3011                })
3012            })
3013            .transpose()?;
3014        let mut field_extension = Vec::new();
3015        if let Some(raw) = raw_extension {
3016            for (index, value) in path
3017                .with("extension", |path| {
3018                    super::super::codec::expect_array(raw, path)
3019                })?
3020                .iter()
3021                .enumerate()
3022            {
3023                field_extension.push(path.with_index("extension", index, |path| {
3024                    super::super::codec::Json::from_json(
3025                        super::super::codec::expect_object(value, path)?,
3026                        path,
3027                    )
3028                })?);
3029            }
3030        }
3031        let mut field_modifier_extension = Vec::new();
3032        if let Some(raw) = raw_modifier_extension {
3033            for (index, value) in path
3034                .with("modifierExtension", |path| {
3035                    super::super::codec::expect_array(raw, path)
3036                })?
3037                .iter()
3038                .enumerate()
3039            {
3040                field_modifier_extension.push(path.with_index(
3041                    "modifierExtension",
3042                    index,
3043                    |path| {
3044                        super::super::codec::Json::from_json(
3045                            super::super::codec::expect_object(value, path)?,
3046                            path,
3047                        )
3048                    },
3049                )?);
3050            }
3051        }
3052        let field_name = path.with("name", |path| {
3053            super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
3054        })?;
3055        let field_documentation = match (raw_documentation, raw_documentation_element) {
3056            (None, None) => None,
3057            (value, element) => Some(path.with("documentation", |path| {
3058                super::super::codec::Primitive::from_json_parts(value, element, path)
3059            })?),
3060        };
3061        Ok(Self {
3062            id: field_id,
3063            extension: field_extension,
3064            modifier_extension: field_modifier_extension,
3065            name: field_name,
3066            documentation: field_documentation,
3067        })
3068    }
3069}
3070
3071impl serde::Serialize for TerminologyCapabilitiesExpansionParameter {
3072    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3073        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3074        if let Some(item) = &self.documentation {
3075            super::super::codec::element_entry(&mut map, "_documentation", item)?;
3076        }
3077        super::super::codec::element_entry(&mut map, "_name", &self.name)?;
3078        if let Some(item) = &self.documentation {
3079            super::super::codec::value_entry(&mut map, "documentation", item)?;
3080        }
3081        if !self.extension.is_empty() {
3082            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3083        }
3084        if let Some(v) = &self.id {
3085            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3086        }
3087        if !self.modifier_extension.is_empty() {
3088            serde::ser::SerializeMap::serialize_entry(
3089                &mut map,
3090                "modifierExtension",
3091                &self.modifier_extension,
3092            )?;
3093        }
3094        super::super::codec::value_entry(&mut map, "name", &self.name)?;
3095        serde::ser::SerializeMap::end(map)
3096    }
3097}
3098
3099impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesExpansionParameter {
3100    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3101        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3102        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesExpansionParameter");
3103        let object =
3104            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3105        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3106    }
3107}
3108
3109/// If this describes a specific instance
3110///
3111/// Identifies a specific implementation instance that is described by the
3112/// terminology capability statement - i.e. a particular installation, rather
3113/// than the capabilities of a software program.
3114#[derive(Debug, Clone, Default, PartialEq, Eq)]
3115pub struct TerminologyCapabilitiesImplementation {
3116    /// Unique id for inter-element referencing
3117    ///
3118    /// Unique id for the element within a resource (for internal references). This
3119    /// may be any string value that does not contain spaces.
3120    pub id: Option<std::string::String>,
3121    /// Additional content defined by implementations
3122    ///
3123    /// May be used to represent additional information that is not part of the
3124    /// basic definition of the element. To make the use of extensions safe and
3125    /// managable, there is a strict set of governance applied to the definition and
3126    /// use of extensions. Though any implementer can define an extension, there is
3127    /// a set of requirements that SHALL be met as part of the definition of the
3128    /// extension.
3129    pub extension: Vec<super::extension::Extension>,
3130    /// Extensions that cannot be ignored even if unrecognized
3131    ///
3132    /// May be used to represent additional information that is not part of the
3133    /// basic definition of the element and that modifies the understanding of the
3134    /// element in which it is contained and/or the understanding of the containing
3135    /// element's descendants. Usually modifier elements provide negation or
3136    /// qualification. To make the use of extensions safe and managable, there is a
3137    /// strict set of governance applied to the definition and use of extensions.
3138    /// Though any implementer can define an extension, there is a set of
3139    /// requirements that SHALL be met as part of the definition of the extension.
3140    /// Applications processing a resource are required to check for modifier
3141    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3142    /// on Resource or DomainResource (including cannot change the meaning of
3143    /// modifierExtension itself).
3144    pub modifier_extension: Vec<super::extension::Extension>,
3145    /// Describes this specific instance
3146    ///
3147    /// Information about the specific installation that this terminology capability
3148    /// statement relates to.
3149    pub description: super::primitives::String,
3150    /// Base URL for the implementation
3151    ///
3152    /// An absolute base URL for the implementation.
3153    pub url: Option<super::primitives::Url>,
3154}
3155
3156impl super::super::codec::Json for TerminologyCapabilitiesImplementation {
3157    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3158        let mut object = super::super::codec::Object::new();
3159        if let Some(v) = &self.id {
3160            object.insert(
3161                std::string::String::from("id"),
3162                super::super::codec::Value::String(v.clone()),
3163            );
3164        }
3165        if !self.extension.is_empty() {
3166            let mut items = Vec::with_capacity(self.extension.len());
3167            for item in &self.extension {
3168                items.push(super::super::codec::Value::Object(
3169                    super::super::codec::Json::to_json(item)?,
3170                ));
3171            }
3172            object.insert(
3173                std::string::String::from("extension"),
3174                super::super::codec::Value::Array(items),
3175            );
3176        }
3177        if !self.modifier_extension.is_empty() {
3178            let mut items = Vec::with_capacity(self.modifier_extension.len());
3179            for item in &self.modifier_extension {
3180                items.push(super::super::codec::Value::Object(
3181                    super::super::codec::Json::to_json(item)?,
3182                ));
3183            }
3184            object.insert(
3185                std::string::String::from("modifierExtension"),
3186                super::super::codec::Value::Array(items),
3187            );
3188        }
3189        if let Some(v) = super::super::codec::Primitive::value_json(&self.description)? {
3190            object.insert(std::string::String::from("description"), v);
3191        }
3192        if let Some(e) = super::super::codec::Primitive::element_json(&self.description)? {
3193            object.insert(std::string::String::from("_description"), e);
3194        }
3195        if let Some(item) = &self.url {
3196            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3197                object.insert(std::string::String::from("url"), v);
3198            }
3199            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3200                object.insert(std::string::String::from("_url"), e);
3201            }
3202        }
3203        Ok(object)
3204    }
3205
3206    fn from_json(
3207        object: &super::super::codec::Object,
3208        path: &mut super::super::codec::Path,
3209    ) -> Result<Self, super::super::codec::DecodeError> {
3210        let mut raw_id: Option<&super::super::codec::Value> = None;
3211        let mut raw_extension: Option<&super::super::codec::Value> = None;
3212        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3213        let mut raw_description: Option<&super::super::codec::Value> = None;
3214        let mut raw_description_element: Option<&super::super::codec::Value> = None;
3215        let mut raw_url: Option<&super::super::codec::Value> = None;
3216        let mut raw_url_element: Option<&super::super::codec::Value> = None;
3217        for (key, value) in object {
3218            match key.as_str() {
3219                "id" => {
3220                    raw_id = Some(value);
3221                }
3222                "extension" => {
3223                    raw_extension = Some(value);
3224                }
3225                "modifierExtension" => {
3226                    raw_modifier_extension = Some(value);
3227                }
3228                "description" => {
3229                    raw_description = Some(value);
3230                }
3231                "_description" => {
3232                    raw_description_element = Some(value);
3233                }
3234                "url" => {
3235                    raw_url = Some(value);
3236                }
3237                "_url" => {
3238                    raw_url_element = Some(value);
3239                }
3240                other => {
3241                    return path.with(other, |path| {
3242                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3243                    });
3244                }
3245            }
3246        }
3247        let field_id = raw_id
3248            .map(|value| {
3249                path.with("id", |path| {
3250                    let value = super::super::codec::expect_single(value, path)?;
3251                    super::primitives::checked_string(
3252                        super::super::codec::expect_string(value, path)?,
3253                        path,
3254                    )
3255                })
3256            })
3257            .transpose()?;
3258        let mut field_extension = Vec::new();
3259        if let Some(raw) = raw_extension {
3260            for (index, value) in path
3261                .with("extension", |path| {
3262                    super::super::codec::expect_array(raw, path)
3263                })?
3264                .iter()
3265                .enumerate()
3266            {
3267                field_extension.push(path.with_index("extension", index, |path| {
3268                    super::super::codec::Json::from_json(
3269                        super::super::codec::expect_object(value, path)?,
3270                        path,
3271                    )
3272                })?);
3273            }
3274        }
3275        let mut field_modifier_extension = Vec::new();
3276        if let Some(raw) = raw_modifier_extension {
3277            for (index, value) in path
3278                .with("modifierExtension", |path| {
3279                    super::super::codec::expect_array(raw, path)
3280                })?
3281                .iter()
3282                .enumerate()
3283            {
3284                field_modifier_extension.push(path.with_index(
3285                    "modifierExtension",
3286                    index,
3287                    |path| {
3288                        super::super::codec::Json::from_json(
3289                            super::super::codec::expect_object(value, path)?,
3290                            path,
3291                        )
3292                    },
3293                )?);
3294            }
3295        }
3296        let field_description = path.with("description", |path| {
3297            super::super::codec::Primitive::from_json_parts(
3298                raw_description,
3299                raw_description_element,
3300                path,
3301            )
3302        })?;
3303        let field_url = match (raw_url, raw_url_element) {
3304            (None, None) => None,
3305            (value, element) => Some(path.with("url", |path| {
3306                super::super::codec::Primitive::from_json_parts(value, element, path)
3307            })?),
3308        };
3309        Ok(Self {
3310            id: field_id,
3311            extension: field_extension,
3312            modifier_extension: field_modifier_extension,
3313            description: field_description,
3314            url: field_url,
3315        })
3316    }
3317}
3318
3319impl serde::Serialize for TerminologyCapabilitiesImplementation {
3320    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3321        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3322        super::super::codec::element_entry(&mut map, "_description", &self.description)?;
3323        if let Some(item) = &self.url {
3324            super::super::codec::element_entry(&mut map, "_url", item)?;
3325        }
3326        super::super::codec::value_entry(&mut map, "description", &self.description)?;
3327        if !self.extension.is_empty() {
3328            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3329        }
3330        if let Some(v) = &self.id {
3331            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3332        }
3333        if !self.modifier_extension.is_empty() {
3334            serde::ser::SerializeMap::serialize_entry(
3335                &mut map,
3336                "modifierExtension",
3337                &self.modifier_extension,
3338            )?;
3339        }
3340        if let Some(item) = &self.url {
3341            super::super::codec::value_entry(&mut map, "url", item)?;
3342        }
3343        serde::ser::SerializeMap::end(map)
3344    }
3345}
3346
3347impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesImplementation {
3348    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3349        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3350        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesImplementation");
3351        let object =
3352            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3353        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3354    }
3355}
3356
3357/// Software that is covered by this terminology capability statement
3358///
3359/// Software that is covered by this terminology capability statement. It is
3360/// used when the statement describes the capabilities of a particular software
3361/// version, independent of an installation.
3362#[derive(Debug, Clone, Default, PartialEq, Eq)]
3363pub struct TerminologyCapabilitiesSoftware {
3364    /// Unique id for inter-element referencing
3365    ///
3366    /// Unique id for the element within a resource (for internal references). This
3367    /// may be any string value that does not contain spaces.
3368    pub id: Option<std::string::String>,
3369    /// Additional content defined by implementations
3370    ///
3371    /// May be used to represent additional information that is not part of the
3372    /// basic definition of the element. To make the use of extensions safe and
3373    /// managable, there is a strict set of governance applied to the definition and
3374    /// use of extensions. Though any implementer can define an extension, there is
3375    /// a set of requirements that SHALL be met as part of the definition of the
3376    /// extension.
3377    pub extension: Vec<super::extension::Extension>,
3378    /// Extensions that cannot be ignored even if unrecognized
3379    ///
3380    /// May be used to represent additional information that is not part of the
3381    /// basic definition of the element and that modifies the understanding of the
3382    /// element in which it is contained and/or the understanding of the containing
3383    /// element's descendants. Usually modifier elements provide negation or
3384    /// qualification. To make the use of extensions safe and managable, there is a
3385    /// strict set of governance applied to the definition and use of extensions.
3386    /// Though any implementer can define an extension, there is a set of
3387    /// requirements that SHALL be met as part of the definition of the extension.
3388    /// Applications processing a resource are required to check for modifier
3389    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3390    /// on Resource or DomainResource (including cannot change the meaning of
3391    /// modifierExtension itself).
3392    pub modifier_extension: Vec<super::extension::Extension>,
3393    /// A name the software is known by
3394    ///
3395    /// Name the software is known by.
3396    pub name: super::primitives::String,
3397    /// Version covered by this statement
3398    ///
3399    /// The version identifier for the software covered by this statement.
3400    pub version: Option<super::primitives::String>,
3401}
3402
3403impl super::super::codec::Json for TerminologyCapabilitiesSoftware {
3404    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3405        let mut object = super::super::codec::Object::new();
3406        if let Some(v) = &self.id {
3407            object.insert(
3408                std::string::String::from("id"),
3409                super::super::codec::Value::String(v.clone()),
3410            );
3411        }
3412        if !self.extension.is_empty() {
3413            let mut items = Vec::with_capacity(self.extension.len());
3414            for item in &self.extension {
3415                items.push(super::super::codec::Value::Object(
3416                    super::super::codec::Json::to_json(item)?,
3417                ));
3418            }
3419            object.insert(
3420                std::string::String::from("extension"),
3421                super::super::codec::Value::Array(items),
3422            );
3423        }
3424        if !self.modifier_extension.is_empty() {
3425            let mut items = Vec::with_capacity(self.modifier_extension.len());
3426            for item in &self.modifier_extension {
3427                items.push(super::super::codec::Value::Object(
3428                    super::super::codec::Json::to_json(item)?,
3429                ));
3430            }
3431            object.insert(
3432                std::string::String::from("modifierExtension"),
3433                super::super::codec::Value::Array(items),
3434            );
3435        }
3436        if let Some(v) = super::super::codec::Primitive::value_json(&self.name)? {
3437            object.insert(std::string::String::from("name"), v);
3438        }
3439        if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
3440            object.insert(std::string::String::from("_name"), e);
3441        }
3442        if let Some(item) = &self.version {
3443            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3444                object.insert(std::string::String::from("version"), v);
3445            }
3446            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3447                object.insert(std::string::String::from("_version"), e);
3448            }
3449        }
3450        Ok(object)
3451    }
3452
3453    fn from_json(
3454        object: &super::super::codec::Object,
3455        path: &mut super::super::codec::Path,
3456    ) -> Result<Self, super::super::codec::DecodeError> {
3457        let mut raw_id: Option<&super::super::codec::Value> = None;
3458        let mut raw_extension: Option<&super::super::codec::Value> = None;
3459        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3460        let mut raw_name: Option<&super::super::codec::Value> = None;
3461        let mut raw_name_element: Option<&super::super::codec::Value> = None;
3462        let mut raw_version: Option<&super::super::codec::Value> = None;
3463        let mut raw_version_element: Option<&super::super::codec::Value> = None;
3464        for (key, value) in object {
3465            match key.as_str() {
3466                "id" => {
3467                    raw_id = Some(value);
3468                }
3469                "extension" => {
3470                    raw_extension = Some(value);
3471                }
3472                "modifierExtension" => {
3473                    raw_modifier_extension = Some(value);
3474                }
3475                "name" => {
3476                    raw_name = Some(value);
3477                }
3478                "_name" => {
3479                    raw_name_element = Some(value);
3480                }
3481                "version" => {
3482                    raw_version = Some(value);
3483                }
3484                "_version" => {
3485                    raw_version_element = Some(value);
3486                }
3487                other => {
3488                    return path.with(other, |path| {
3489                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3490                    });
3491                }
3492            }
3493        }
3494        let field_id = raw_id
3495            .map(|value| {
3496                path.with("id", |path| {
3497                    let value = super::super::codec::expect_single(value, path)?;
3498                    super::primitives::checked_string(
3499                        super::super::codec::expect_string(value, path)?,
3500                        path,
3501                    )
3502                })
3503            })
3504            .transpose()?;
3505        let mut field_extension = Vec::new();
3506        if let Some(raw) = raw_extension {
3507            for (index, value) in path
3508                .with("extension", |path| {
3509                    super::super::codec::expect_array(raw, path)
3510                })?
3511                .iter()
3512                .enumerate()
3513            {
3514                field_extension.push(path.with_index("extension", index, |path| {
3515                    super::super::codec::Json::from_json(
3516                        super::super::codec::expect_object(value, path)?,
3517                        path,
3518                    )
3519                })?);
3520            }
3521        }
3522        let mut field_modifier_extension = Vec::new();
3523        if let Some(raw) = raw_modifier_extension {
3524            for (index, value) in path
3525                .with("modifierExtension", |path| {
3526                    super::super::codec::expect_array(raw, path)
3527                })?
3528                .iter()
3529                .enumerate()
3530            {
3531                field_modifier_extension.push(path.with_index(
3532                    "modifierExtension",
3533                    index,
3534                    |path| {
3535                        super::super::codec::Json::from_json(
3536                            super::super::codec::expect_object(value, path)?,
3537                            path,
3538                        )
3539                    },
3540                )?);
3541            }
3542        }
3543        let field_name = path.with("name", |path| {
3544            super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
3545        })?;
3546        let field_version = match (raw_version, raw_version_element) {
3547            (None, None) => None,
3548            (value, element) => Some(path.with("version", |path| {
3549                super::super::codec::Primitive::from_json_parts(value, element, path)
3550            })?),
3551        };
3552        Ok(Self {
3553            id: field_id,
3554            extension: field_extension,
3555            modifier_extension: field_modifier_extension,
3556            name: field_name,
3557            version: field_version,
3558        })
3559    }
3560}
3561
3562impl serde::Serialize for TerminologyCapabilitiesSoftware {
3563    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3564        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3565        super::super::codec::element_entry(&mut map, "_name", &self.name)?;
3566        if let Some(item) = &self.version {
3567            super::super::codec::element_entry(&mut map, "_version", item)?;
3568        }
3569        if !self.extension.is_empty() {
3570            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3571        }
3572        if let Some(v) = &self.id {
3573            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3574        }
3575        if !self.modifier_extension.is_empty() {
3576            serde::ser::SerializeMap::serialize_entry(
3577                &mut map,
3578                "modifierExtension",
3579                &self.modifier_extension,
3580            )?;
3581        }
3582        super::super::codec::value_entry(&mut map, "name", &self.name)?;
3583        if let Some(item) = &self.version {
3584            super::super::codec::value_entry(&mut map, "version", item)?;
3585        }
3586        serde::ser::SerializeMap::end(map)
3587    }
3588}
3589
3590impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesSoftware {
3591    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3592        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3593        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesSoftware");
3594        let object =
3595            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3596        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3597    }
3598}
3599
3600/// Information about the
3601/// \[ConceptMap/$translate\](conceptmap-operation-translate.html) operation.
3602#[derive(Debug, Clone, Default, PartialEq, Eq)]
3603pub struct TerminologyCapabilitiesTranslation {
3604    /// Unique id for inter-element referencing
3605    ///
3606    /// Unique id for the element within a resource (for internal references). This
3607    /// may be any string value that does not contain spaces.
3608    pub id: Option<std::string::String>,
3609    /// Additional content defined by implementations
3610    ///
3611    /// May be used to represent additional information that is not part of the
3612    /// basic definition of the element. To make the use of extensions safe and
3613    /// managable, there is a strict set of governance applied to the definition and
3614    /// use of extensions. Though any implementer can define an extension, there is
3615    /// a set of requirements that SHALL be met as part of the definition of the
3616    /// extension.
3617    pub extension: Vec<super::extension::Extension>,
3618    /// Extensions that cannot be ignored even if unrecognized
3619    ///
3620    /// May be used to represent additional information that is not part of the
3621    /// basic definition of the element and that modifies the understanding of the
3622    /// element in which it is contained and/or the understanding of the containing
3623    /// element's descendants. Usually modifier elements provide negation or
3624    /// qualification. To make the use of extensions safe and managable, there is a
3625    /// strict set of governance applied to the definition and use of extensions.
3626    /// Though any implementer can define an extension, there is a set of
3627    /// requirements that SHALL be met as part of the definition of the extension.
3628    /// Applications processing a resource are required to check for modifier
3629    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3630    /// on Resource or DomainResource (including cannot change the meaning of
3631    /// modifierExtension itself).
3632    pub modifier_extension: Vec<super::extension::Extension>,
3633    /// Whether the client must identify the map.
3634    pub needs_map: super::primitives::Boolean,
3635}
3636
3637impl super::super::codec::Json for TerminologyCapabilitiesTranslation {
3638    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3639        let mut object = super::super::codec::Object::new();
3640        if let Some(v) = &self.id {
3641            object.insert(
3642                std::string::String::from("id"),
3643                super::super::codec::Value::String(v.clone()),
3644            );
3645        }
3646        if !self.extension.is_empty() {
3647            let mut items = Vec::with_capacity(self.extension.len());
3648            for item in &self.extension {
3649                items.push(super::super::codec::Value::Object(
3650                    super::super::codec::Json::to_json(item)?,
3651                ));
3652            }
3653            object.insert(
3654                std::string::String::from("extension"),
3655                super::super::codec::Value::Array(items),
3656            );
3657        }
3658        if !self.modifier_extension.is_empty() {
3659            let mut items = Vec::with_capacity(self.modifier_extension.len());
3660            for item in &self.modifier_extension {
3661                items.push(super::super::codec::Value::Object(
3662                    super::super::codec::Json::to_json(item)?,
3663                ));
3664            }
3665            object.insert(
3666                std::string::String::from("modifierExtension"),
3667                super::super::codec::Value::Array(items),
3668            );
3669        }
3670        if let Some(v) = super::super::codec::Primitive::value_json(&self.needs_map)? {
3671            object.insert(std::string::String::from("needsMap"), v);
3672        }
3673        if let Some(e) = super::super::codec::Primitive::element_json(&self.needs_map)? {
3674            object.insert(std::string::String::from("_needsMap"), e);
3675        }
3676        Ok(object)
3677    }
3678
3679    fn from_json(
3680        object: &super::super::codec::Object,
3681        path: &mut super::super::codec::Path,
3682    ) -> Result<Self, super::super::codec::DecodeError> {
3683        let mut raw_id: Option<&super::super::codec::Value> = None;
3684        let mut raw_extension: Option<&super::super::codec::Value> = None;
3685        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3686        let mut raw_needs_map: Option<&super::super::codec::Value> = None;
3687        let mut raw_needs_map_element: Option<&super::super::codec::Value> = None;
3688        for (key, value) in object {
3689            match key.as_str() {
3690                "id" => {
3691                    raw_id = Some(value);
3692                }
3693                "extension" => {
3694                    raw_extension = Some(value);
3695                }
3696                "modifierExtension" => {
3697                    raw_modifier_extension = Some(value);
3698                }
3699                "needsMap" => {
3700                    raw_needs_map = Some(value);
3701                }
3702                "_needsMap" => {
3703                    raw_needs_map_element = Some(value);
3704                }
3705                other => {
3706                    return path.with(other, |path| {
3707                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3708                    });
3709                }
3710            }
3711        }
3712        let field_id = raw_id
3713            .map(|value| {
3714                path.with("id", |path| {
3715                    let value = super::super::codec::expect_single(value, path)?;
3716                    super::primitives::checked_string(
3717                        super::super::codec::expect_string(value, path)?,
3718                        path,
3719                    )
3720                })
3721            })
3722            .transpose()?;
3723        let mut field_extension = Vec::new();
3724        if let Some(raw) = raw_extension {
3725            for (index, value) in path
3726                .with("extension", |path| {
3727                    super::super::codec::expect_array(raw, path)
3728                })?
3729                .iter()
3730                .enumerate()
3731            {
3732                field_extension.push(path.with_index("extension", index, |path| {
3733                    super::super::codec::Json::from_json(
3734                        super::super::codec::expect_object(value, path)?,
3735                        path,
3736                    )
3737                })?);
3738            }
3739        }
3740        let mut field_modifier_extension = Vec::new();
3741        if let Some(raw) = raw_modifier_extension {
3742            for (index, value) in path
3743                .with("modifierExtension", |path| {
3744                    super::super::codec::expect_array(raw, path)
3745                })?
3746                .iter()
3747                .enumerate()
3748            {
3749                field_modifier_extension.push(path.with_index(
3750                    "modifierExtension",
3751                    index,
3752                    |path| {
3753                        super::super::codec::Json::from_json(
3754                            super::super::codec::expect_object(value, path)?,
3755                            path,
3756                        )
3757                    },
3758                )?);
3759            }
3760        }
3761        let field_needs_map = path.with("needsMap", |path| {
3762            super::super::codec::Primitive::from_json_parts(
3763                raw_needs_map,
3764                raw_needs_map_element,
3765                path,
3766            )
3767        })?;
3768        Ok(Self {
3769            id: field_id,
3770            extension: field_extension,
3771            modifier_extension: field_modifier_extension,
3772            needs_map: field_needs_map,
3773        })
3774    }
3775}
3776
3777impl serde::Serialize for TerminologyCapabilitiesTranslation {
3778    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3779        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3780        super::super::codec::element_entry(&mut map, "_needsMap", &self.needs_map)?;
3781        if !self.extension.is_empty() {
3782            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3783        }
3784        if let Some(v) = &self.id {
3785            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3786        }
3787        if !self.modifier_extension.is_empty() {
3788            serde::ser::SerializeMap::serialize_entry(
3789                &mut map,
3790                "modifierExtension",
3791                &self.modifier_extension,
3792            )?;
3793        }
3794        super::super::codec::value_entry(&mut map, "needsMap", &self.needs_map)?;
3795        serde::ser::SerializeMap::end(map)
3796    }
3797}
3798
3799impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesTranslation {
3800    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3801        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3802        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesTranslation");
3803        let object =
3804            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3805        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3806    }
3807}
3808
3809/// Information about the
3810/// \[ValueSet/$validate-code\](valueset-operation-validate-code.html)
3811/// operation.
3812#[derive(Debug, Clone, Default, PartialEq, Eq)]
3813pub struct TerminologyCapabilitiesValidateCode {
3814    /// Unique id for inter-element referencing
3815    ///
3816    /// Unique id for the element within a resource (for internal references). This
3817    /// may be any string value that does not contain spaces.
3818    pub id: Option<std::string::String>,
3819    /// Additional content defined by implementations
3820    ///
3821    /// May be used to represent additional information that is not part of the
3822    /// basic definition of the element. To make the use of extensions safe and
3823    /// managable, there is a strict set of governance applied to the definition and
3824    /// use of extensions. Though any implementer can define an extension, there is
3825    /// a set of requirements that SHALL be met as part of the definition of the
3826    /// extension.
3827    pub extension: Vec<super::extension::Extension>,
3828    /// Extensions that cannot be ignored even if unrecognized
3829    ///
3830    /// May be used to represent additional information that is not part of the
3831    /// basic definition of the element and that modifies the understanding of the
3832    /// element in which it is contained and/or the understanding of the containing
3833    /// element's descendants. Usually modifier elements provide negation or
3834    /// qualification. To make the use of extensions safe and managable, there is a
3835    /// strict set of governance applied to the definition and use of extensions.
3836    /// Though any implementer can define an extension, there is a set of
3837    /// requirements that SHALL be met as part of the definition of the extension.
3838    /// Applications processing a resource are required to check for modifier
3839    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3840    /// on Resource or DomainResource (including cannot change the meaning of
3841    /// modifierExtension itself).
3842    pub modifier_extension: Vec<super::extension::Extension>,
3843    /// Whether translations are validated.
3844    pub translations: super::primitives::Boolean,
3845}
3846
3847impl super::super::codec::Json for TerminologyCapabilitiesValidateCode {
3848    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3849        let mut object = super::super::codec::Object::new();
3850        if let Some(v) = &self.id {
3851            object.insert(
3852                std::string::String::from("id"),
3853                super::super::codec::Value::String(v.clone()),
3854            );
3855        }
3856        if !self.extension.is_empty() {
3857            let mut items = Vec::with_capacity(self.extension.len());
3858            for item in &self.extension {
3859                items.push(super::super::codec::Value::Object(
3860                    super::super::codec::Json::to_json(item)?,
3861                ));
3862            }
3863            object.insert(
3864                std::string::String::from("extension"),
3865                super::super::codec::Value::Array(items),
3866            );
3867        }
3868        if !self.modifier_extension.is_empty() {
3869            let mut items = Vec::with_capacity(self.modifier_extension.len());
3870            for item in &self.modifier_extension {
3871                items.push(super::super::codec::Value::Object(
3872                    super::super::codec::Json::to_json(item)?,
3873                ));
3874            }
3875            object.insert(
3876                std::string::String::from("modifierExtension"),
3877                super::super::codec::Value::Array(items),
3878            );
3879        }
3880        if let Some(v) = super::super::codec::Primitive::value_json(&self.translations)? {
3881            object.insert(std::string::String::from("translations"), v);
3882        }
3883        if let Some(e) = super::super::codec::Primitive::element_json(&self.translations)? {
3884            object.insert(std::string::String::from("_translations"), e);
3885        }
3886        Ok(object)
3887    }
3888
3889    fn from_json(
3890        object: &super::super::codec::Object,
3891        path: &mut super::super::codec::Path,
3892    ) -> Result<Self, super::super::codec::DecodeError> {
3893        let mut raw_id: Option<&super::super::codec::Value> = None;
3894        let mut raw_extension: Option<&super::super::codec::Value> = None;
3895        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3896        let mut raw_translations: Option<&super::super::codec::Value> = None;
3897        let mut raw_translations_element: Option<&super::super::codec::Value> = None;
3898        for (key, value) in object {
3899            match key.as_str() {
3900                "id" => {
3901                    raw_id = Some(value);
3902                }
3903                "extension" => {
3904                    raw_extension = Some(value);
3905                }
3906                "modifierExtension" => {
3907                    raw_modifier_extension = Some(value);
3908                }
3909                "translations" => {
3910                    raw_translations = Some(value);
3911                }
3912                "_translations" => {
3913                    raw_translations_element = Some(value);
3914                }
3915                other => {
3916                    return path.with(other, |path| {
3917                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3918                    });
3919                }
3920            }
3921        }
3922        let field_id = raw_id
3923            .map(|value| {
3924                path.with("id", |path| {
3925                    let value = super::super::codec::expect_single(value, path)?;
3926                    super::primitives::checked_string(
3927                        super::super::codec::expect_string(value, path)?,
3928                        path,
3929                    )
3930                })
3931            })
3932            .transpose()?;
3933        let mut field_extension = Vec::new();
3934        if let Some(raw) = raw_extension {
3935            for (index, value) in path
3936                .with("extension", |path| {
3937                    super::super::codec::expect_array(raw, path)
3938                })?
3939                .iter()
3940                .enumerate()
3941            {
3942                field_extension.push(path.with_index("extension", index, |path| {
3943                    super::super::codec::Json::from_json(
3944                        super::super::codec::expect_object(value, path)?,
3945                        path,
3946                    )
3947                })?);
3948            }
3949        }
3950        let mut field_modifier_extension = Vec::new();
3951        if let Some(raw) = raw_modifier_extension {
3952            for (index, value) in path
3953                .with("modifierExtension", |path| {
3954                    super::super::codec::expect_array(raw, path)
3955                })?
3956                .iter()
3957                .enumerate()
3958            {
3959                field_modifier_extension.push(path.with_index(
3960                    "modifierExtension",
3961                    index,
3962                    |path| {
3963                        super::super::codec::Json::from_json(
3964                            super::super::codec::expect_object(value, path)?,
3965                            path,
3966                        )
3967                    },
3968                )?);
3969            }
3970        }
3971        let field_translations = path.with("translations", |path| {
3972            super::super::codec::Primitive::from_json_parts(
3973                raw_translations,
3974                raw_translations_element,
3975                path,
3976            )
3977        })?;
3978        Ok(Self {
3979            id: field_id,
3980            extension: field_extension,
3981            modifier_extension: field_modifier_extension,
3982            translations: field_translations,
3983        })
3984    }
3985}
3986
3987impl serde::Serialize for TerminologyCapabilitiesValidateCode {
3988    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3989        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3990        super::super::codec::element_entry(&mut map, "_translations", &self.translations)?;
3991        if !self.extension.is_empty() {
3992            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3993        }
3994        if let Some(v) = &self.id {
3995            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3996        }
3997        if !self.modifier_extension.is_empty() {
3998            serde::ser::SerializeMap::serialize_entry(
3999                &mut map,
4000                "modifierExtension",
4001                &self.modifier_extension,
4002            )?;
4003        }
4004        super::super::codec::value_entry(&mut map, "translations", &self.translations)?;
4005        serde::ser::SerializeMap::end(map)
4006    }
4007}
4008
4009impl<'de> serde::Deserialize<'de> for TerminologyCapabilitiesValidateCode {
4010    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4011        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
4012        let mut path = super::super::codec::Path::root("TerminologyCapabilitiesValidateCode");
4013        let object =
4014            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
4015        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
4016    }
4017}
4018
4019/// The \`versionAlgorithm\[x\]\` choice of \`TerminologyCapabilities\`.
4020///
4021/// Indicates the mechanism used to compare versions to determine which is more
4022/// current.
4023#[derive(Debug, Clone, PartialEq, Eq)]
4024pub enum TerminologyCapabilitiesVersionAlgorithm {
4025    /// The `string` form.
4026    String(super::primitives::String),
4027    /// The `Coding` form.
4028    Coding(Box<super::coding::Coding>),
4029}
4030
4031impl TerminologyCapabilitiesVersionAlgorithm {
4032    /// The key suffix, the value part, and the `_name` part of this form.
4033    ///
4034    /// # Errors
4035    ///
4036    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
4037    pub fn to_json_parts(
4038        &self,
4039    ) -> Result<
4040        (
4041            &'static str,
4042            Option<super::super::codec::Value>,
4043            Option<super::super::codec::Value>,
4044        ),
4045        super::super::codec::EncodeError,
4046    > {
4047        match self {
4048            Self::String(inner) => Ok((
4049                "String",
4050                super::super::codec::Primitive::value_json(inner)?,
4051                super::super::codec::Primitive::element_json(inner)?,
4052            )),
4053            Self::Coding(inner) => Ok((
4054                "Coding",
4055                Some(super::super::codec::Value::Object(
4056                    super::super::codec::Json::to_json(inner.as_ref())?,
4057                )),
4058                None,
4059            )),
4060        }
4061    }
4062
4063    /// Decodes the form named by `suffix` from its value and `_name` parts.
4064    ///
4065    /// # Errors
4066    ///
4067    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
4068    pub fn from_json_parts(
4069        suffix: &str,
4070        value: Option<&super::super::codec::Value>,
4071        element: Option<&super::super::codec::Value>,
4072        path: &mut super::super::codec::Path,
4073    ) -> Result<Self, super::super::codec::DecodeError> {
4074        match suffix {
4075            "String" => Ok(Self::String(
4076                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4077            )),
4078            "Coding" => {
4079                if element.is_some() {
4080                    return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
4081                        expected: "no underscore form for a complex type",
4082                    }));
4083                }
4084                let value = value.ok_or_else(|| {
4085                    path.error(super::super::codec::DecodeErrorKind::MissingProperty)
4086                })?;
4087                let inner = super::super::codec::Json::from_json(
4088                    super::super::codec::expect_object(
4089                        super::super::codec::expect_single(value, path)?,
4090                        path,
4091                    )?,
4092                    path,
4093                )?;
4094                Ok(Self::Coding(Box::new(inner)))
4095            }
4096            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
4097        }
4098    }
4099}