Skip to main content

fhir_types/r5/
value_set.rs

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