Skip to main content

fhir_types/r4b/
value_set.rs

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