Skip to main content

fhir_types/stu3/
value_set.rs

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