Skip to main content

fhir_types/r6/
value_set.rs

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