Skip to main content

fhir_types/stu3/
code_system.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 code system resource specifies a set of codes drawn from one or more code
10/// systems.
11#[derive(Debug, Clone, Default, PartialEq, Eq)]
12pub struct CodeSystem {
13    /// Logical id of this artifact
14    ///
15    /// The logical id of the resource, as used in the URL for the resource. Once
16    /// assigned, this value never changes.
17    pub id: Option<super::primitives::Id>,
18    /// Metadata about the resource
19    ///
20    /// The metadata about the resource. This is content that is maintained by the
21    /// infrastructure. Changes to the content may not always be associated with
22    /// version changes to the resource.
23    pub meta: Option<super::meta::Meta>,
24    /// A set of rules under which this content was created
25    ///
26    /// A reference to a set of rules that were followed when the resource was
27    /// constructed, and which must be understood when processing the content.
28    pub implicit_rules: Option<super::primitives::Uri>,
29    /// Language of the resource content
30    ///
31    /// The base language in which the resource is written.
32    pub language: Option<super::primitives::Code>,
33    /// Text summary of the resource, for human interpretation
34    ///
35    /// A human-readable narrative that contains a summary of the resource, and may
36    /// be used to represent the content of the resource to a human. The narrative
37    /// need not encode all the structured data, but is required to contain
38    /// sufficient detail to make it "clinically safe" for a human to just read the
39    /// narrative. Resource definitions may define what content should be
40    /// represented in the narrative to ensure clinical safety.
41    pub text: Option<super::narrative::Narrative>,
42    /// Contained, inline Resources
43    ///
44    /// These resources do not have an independent existence apart from the resource
45    /// that contains them - they cannot be identified independently, and nor can
46    /// they have their own independent transaction scope.
47    pub contained: Vec<super::resource::Resource>,
48    /// Additional Content defined by implementations
49    ///
50    /// May be used to represent additional information that is not part of the
51    /// basic definition of the resource. In order to make the use of extensions
52    /// safe and manageable, there is a strict set of governance applied to the
53    /// definition and use of extensions. Though any implementer is allowed to
54    /// define an extension, there is a set of requirements that SHALL be met as
55    /// part of the definition of the extension.
56    pub extension: Vec<super::extension::Extension>,
57    /// Extensions that cannot be ignored
58    ///
59    /// May be used to represent additional information that is not part of the
60    /// basic definition of the resource, and that modifies the understanding of the
61    /// element that contains it. Usually modifier elements provide negation or
62    /// qualification. In order to make the use of extensions safe and manageable,
63    /// there is a strict set of governance applied to the definition and use of
64    /// extensions. Though any implementer is allowed to define an extension, there
65    /// is a set of requirements that SHALL be met as part of the definition of the
66    /// extension. Applications processing a resource are required to check for
67    /// modifier extensions.
68    pub modifier_extension: Vec<super::extension::Extension>,
69    /// Logical URI to reference this code system (globally unique) (Coding.system)
70    ///
71    /// An absolute URI that is used to identify this code system when it is
72    /// referenced in a specification, model, design or an instance. This SHALL be a
73    /// URL, SHOULD be globally unique, and SHOULD be an address at which this code
74    /// system is (or will be) published. The URL SHOULD include the major version
75    /// of the code system. For more information see \[Technical and Business
76    /// Versions\](resource.html\#versions). This is used in
77    /// \[Coding\]{datatypes.html\#Coding}.system.
78    pub url: Option<super::primitives::Uri>,
79    /// Additional identifier for the code system
80    ///
81    /// A formal identifier that is used to identify this code system when it is
82    /// represented in other formats, or referenced in a specification, model,
83    /// design or an instance.
84    pub identifier: Option<super::identifier::Identifier>,
85    /// Business version of the code system (Coding.version)
86    ///
87    /// The identifier that is used to identify this version of the code system when
88    /// it is referenced in a specification, model, design or instance. This is an
89    /// arbitrary value managed by the code system author and is not expected to be
90    /// globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a
91    /// managed version is not available. There is also no expectation that versions
92    /// can be placed in a lexicographical sequence. This is used in
93    /// \[Coding\]{datatypes.html\#Coding}.version.
94    pub version: Option<super::primitives::String>,
95    /// Name for this code system (computer friendly)
96    ///
97    /// A natural language name identifying the code system. This name should be
98    /// usable as an identifier for the module by machine processing applications
99    /// such as code generation.
100    pub name: Option<super::primitives::String>,
101    /// Name for this code system (human friendly)
102    ///
103    /// A short, descriptive, user-friendly title for the code system.
104    pub title: Option<super::primitives::String>,
105    /// draft | active | retired | unknown
106    ///
107    /// The status of this code system. Enables tracking the life-cycle of the
108    /// content.
109    pub status: super::primitives::Code,
110    /// For testing purposes, not real usage
111    ///
112    /// A boolean value to indicate that this code system is authored for testing
113    /// purposes (or education/evaluation/marketing), and is not intended to be used
114    /// for genuine usage.
115    pub experimental: Option<super::primitives::Boolean>,
116    /// Date this was last changed
117    ///
118    /// The date (and optionally time) when the code system was published. The date
119    /// must change if and when the business version changes and it must change if
120    /// the status code changes. In addition, it should change when the substantive
121    /// content of the code system changes.
122    pub date: Option<super::primitives::DateTime>,
123    /// Name of the publisher (organization or individual)
124    ///
125    /// The name of the individual or organization that published the code system.
126    pub publisher: Option<super::primitives::String>,
127    /// Contact details for the publisher
128    ///
129    /// Contact details to assist a user in finding and communicating with the
130    /// publisher.
131    pub contact: Vec<super::contact_detail::ContactDetail>,
132    /// Natural language description of the code system
133    ///
134    /// A free text natural language description of the code system from a
135    /// consumer's perspective.
136    pub description: Option<super::primitives::Markdown>,
137    /// Context the content is intended to support
138    ///
139    /// The content was developed with a focus and intent of supporting the contexts
140    /// that are listed. These terms may be used to assist with indexing and
141    /// searching for appropriate code system instances.
142    pub use_context: Vec<super::usage_context::UsageContext>,
143    /// Intended jurisdiction for code system (if applicable)
144    ///
145    /// A legal or geographic region in which the code system is intended to be
146    /// used.
147    pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
148    /// Why this code system is defined
149    ///
150    /// Explaination of why this code system is needed and why it has been designed
151    /// as it has.
152    pub purpose: Option<super::primitives::Markdown>,
153    /// Use and/or publishing restrictions
154    ///
155    /// A copyright statement relating to the code system and/or its contents.
156    /// Copyright statements are generally legal restrictions on the use and
157    /// publishing of the code system.
158    pub copyright: Option<super::primitives::Markdown>,
159    /// If code comparison is case sensitive
160    ///
161    /// If code comparison is case sensitive when codes within this system are
162    /// compared to each other.
163    pub case_sensitive: Option<super::primitives::Boolean>,
164    /// Canonical URL for value set with entire code system
165    ///
166    /// Canonical URL of value set that contains the entire code system.
167    pub value_set: Option<super::primitives::Uri>,
168    /// grouped-by | is-a | part-of | classified-with
169    ///
170    /// The meaning of the hierarchy of concepts.
171    pub hierarchy_meaning: Option<super::primitives::Code>,
172    /// If code system defines a post-composition grammar
173    ///
174    /// True If code system defines a post-composition grammar.
175    pub compositional: Option<super::primitives::Boolean>,
176    /// If definitions are not stable
177    ///
178    /// This flag is used to signify that the code system has not (or does not)
179    /// maintain the definitions, and a version must be specified when referencing
180    /// this code system.
181    pub version_needed: Option<super::primitives::Boolean>,
182    /// not-present | example | fragment | complete
183    ///
184    /// How much of the content of the code system - the concepts and codes it
185    /// defines - are represented in this resource.
186    pub content: super::primitives::Code,
187    /// Total concepts in the code system
188    ///
189    /// The total number of concepts defined by the code system. Where the code
190    /// system has a compositional grammar, the count refers to the number of base
191    /// (primitive) concepts.
192    pub count: Option<super::primitives::UnsignedInt>,
193    /// Filter that can be used in a value set
194    ///
195    /// A filter that can be used in a value set compose statement when selecting
196    /// concepts using a filter.
197    pub filter: Vec<CodeSystemFilter>,
198    /// Additional information supplied about each concept
199    ///
200    /// A property defines an additional slot through which additional information
201    /// can be provided about a concept.
202    pub property: Vec<CodeSystemProperty>,
203    /// Concepts in the code system
204    ///
205    /// Concepts that are in the code system. The concept definitions are inherently
206    /// hierarchical, but the definitions must be consulted to determine what the
207    /// meaning of the hierarchical relationships are.
208    pub concept: Vec<CodeSystemConcept>,
209}
210
211impl super::super::codec::Json for CodeSystem {
212    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
213        let mut object = super::super::codec::Object::new();
214        object.insert(
215            std::string::String::from("resourceType"),
216            super::super::codec::Value::String(std::string::String::from("CodeSystem")),
217        );
218        if let Some(item) = &self.id {
219            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
220                object.insert(std::string::String::from("id"), v);
221            }
222            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
223                object.insert(std::string::String::from("_id"), e);
224            }
225        }
226        if let Some(item) = &self.meta {
227            object.insert(
228                std::string::String::from("meta"),
229                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
230            );
231        }
232        if let Some(item) = &self.implicit_rules {
233            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
234                object.insert(std::string::String::from("implicitRules"), v);
235            }
236            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
237                object.insert(std::string::String::from("_implicitRules"), e);
238            }
239        }
240        if let Some(item) = &self.language {
241            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
242                object.insert(std::string::String::from("language"), v);
243            }
244            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
245                object.insert(std::string::String::from("_language"), e);
246            }
247        }
248        if let Some(item) = &self.text {
249            object.insert(
250                std::string::String::from("text"),
251                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
252            );
253        }
254        if !self.contained.is_empty() {
255            let mut items = Vec::with_capacity(self.contained.len());
256            for item in &self.contained {
257                items.push(super::super::codec::Value::Object(
258                    super::super::codec::Json::to_json(item)?,
259                ));
260            }
261            object.insert(
262                std::string::String::from("contained"),
263                super::super::codec::Value::Array(items),
264            );
265        }
266        if !self.extension.is_empty() {
267            let mut items = Vec::with_capacity(self.extension.len());
268            for item in &self.extension {
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("extension"),
275                super::super::codec::Value::Array(items),
276            );
277        }
278        if !self.modifier_extension.is_empty() {
279            let mut items = Vec::with_capacity(self.modifier_extension.len());
280            for item in &self.modifier_extension {
281                items.push(super::super::codec::Value::Object(
282                    super::super::codec::Json::to_json(item)?,
283                ));
284            }
285            object.insert(
286                std::string::String::from("modifierExtension"),
287                super::super::codec::Value::Array(items),
288            );
289        }
290        if let Some(item) = &self.url {
291            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
292                object.insert(std::string::String::from("url"), v);
293            }
294            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
295                object.insert(std::string::String::from("_url"), e);
296            }
297        }
298        if let Some(item) = &self.identifier {
299            object.insert(
300                std::string::String::from("identifier"),
301                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
302            );
303        }
304        if let Some(item) = &self.version {
305            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
306                object.insert(std::string::String::from("version"), v);
307            }
308            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
309                object.insert(std::string::String::from("_version"), e);
310            }
311        }
312        if let Some(item) = &self.name {
313            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
314                object.insert(std::string::String::from("name"), v);
315            }
316            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
317                object.insert(std::string::String::from("_name"), e);
318            }
319        }
320        if let Some(item) = &self.title {
321            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
322                object.insert(std::string::String::from("title"), v);
323            }
324            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
325                object.insert(std::string::String::from("_title"), e);
326            }
327        }
328        if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
329            object.insert(std::string::String::from("status"), v);
330        }
331        if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
332            object.insert(std::string::String::from("_status"), e);
333        }
334        if let Some(item) = &self.experimental {
335            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
336                object.insert(std::string::String::from("experimental"), v);
337            }
338            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
339                object.insert(std::string::String::from("_experimental"), e);
340            }
341        }
342        if let Some(item) = &self.date {
343            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
344                object.insert(std::string::String::from("date"), v);
345            }
346            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
347                object.insert(std::string::String::from("_date"), e);
348            }
349        }
350        if let Some(item) = &self.publisher {
351            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
352                object.insert(std::string::String::from("publisher"), v);
353            }
354            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
355                object.insert(std::string::String::from("_publisher"), e);
356            }
357        }
358        if !self.contact.is_empty() {
359            let mut items = Vec::with_capacity(self.contact.len());
360            for item in &self.contact {
361                items.push(super::super::codec::Value::Object(
362                    super::super::codec::Json::to_json(item)?,
363                ));
364            }
365            object.insert(
366                std::string::String::from("contact"),
367                super::super::codec::Value::Array(items),
368            );
369        }
370        if let Some(item) = &self.description {
371            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
372                object.insert(std::string::String::from("description"), v);
373            }
374            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
375                object.insert(std::string::String::from("_description"), e);
376            }
377        }
378        if !self.use_context.is_empty() {
379            let mut items = Vec::with_capacity(self.use_context.len());
380            for item in &self.use_context {
381                items.push(super::super::codec::Value::Object(
382                    super::super::codec::Json::to_json(item)?,
383                ));
384            }
385            object.insert(
386                std::string::String::from("useContext"),
387                super::super::codec::Value::Array(items),
388            );
389        }
390        if !self.jurisdiction.is_empty() {
391            let mut items = Vec::with_capacity(self.jurisdiction.len());
392            for item in &self.jurisdiction {
393                items.push(super::super::codec::Value::Object(
394                    super::super::codec::Json::to_json(item)?,
395                ));
396            }
397            object.insert(
398                std::string::String::from("jurisdiction"),
399                super::super::codec::Value::Array(items),
400            );
401        }
402        if let Some(item) = &self.purpose {
403            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
404                object.insert(std::string::String::from("purpose"), v);
405            }
406            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
407                object.insert(std::string::String::from("_purpose"), e);
408            }
409        }
410        if let Some(item) = &self.copyright {
411            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
412                object.insert(std::string::String::from("copyright"), v);
413            }
414            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
415                object.insert(std::string::String::from("_copyright"), e);
416            }
417        }
418        if let Some(item) = &self.case_sensitive {
419            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
420                object.insert(std::string::String::from("caseSensitive"), v);
421            }
422            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
423                object.insert(std::string::String::from("_caseSensitive"), e);
424            }
425        }
426        if let Some(item) = &self.value_set {
427            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
428                object.insert(std::string::String::from("valueSet"), v);
429            }
430            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
431                object.insert(std::string::String::from("_valueSet"), e);
432            }
433        }
434        if let Some(item) = &self.hierarchy_meaning {
435            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
436                object.insert(std::string::String::from("hierarchyMeaning"), v);
437            }
438            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
439                object.insert(std::string::String::from("_hierarchyMeaning"), e);
440            }
441        }
442        if let Some(item) = &self.compositional {
443            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
444                object.insert(std::string::String::from("compositional"), v);
445            }
446            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
447                object.insert(std::string::String::from("_compositional"), e);
448            }
449        }
450        if let Some(item) = &self.version_needed {
451            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
452                object.insert(std::string::String::from("versionNeeded"), v);
453            }
454            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
455                object.insert(std::string::String::from("_versionNeeded"), e);
456            }
457        }
458        if let Some(v) = super::super::codec::Primitive::value_json(&self.content)? {
459            object.insert(std::string::String::from("content"), v);
460        }
461        if let Some(e) = super::super::codec::Primitive::element_json(&self.content)? {
462            object.insert(std::string::String::from("_content"), e);
463        }
464        if let Some(item) = &self.count {
465            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
466                object.insert(std::string::String::from("count"), v);
467            }
468            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
469                object.insert(std::string::String::from("_count"), e);
470            }
471        }
472        if !self.filter.is_empty() {
473            let mut items = Vec::with_capacity(self.filter.len());
474            for item in &self.filter {
475                items.push(super::super::codec::Value::Object(
476                    super::super::codec::Json::to_json(item)?,
477                ));
478            }
479            object.insert(
480                std::string::String::from("filter"),
481                super::super::codec::Value::Array(items),
482            );
483        }
484        if !self.property.is_empty() {
485            let mut items = Vec::with_capacity(self.property.len());
486            for item in &self.property {
487                items.push(super::super::codec::Value::Object(
488                    super::super::codec::Json::to_json(item)?,
489                ));
490            }
491            object.insert(
492                std::string::String::from("property"),
493                super::super::codec::Value::Array(items),
494            );
495        }
496        if !self.concept.is_empty() {
497            let mut items = Vec::with_capacity(self.concept.len());
498            for item in &self.concept {
499                items.push(super::super::codec::Value::Object(
500                    super::super::codec::Json::to_json(item)?,
501                ));
502            }
503            object.insert(
504                std::string::String::from("concept"),
505                super::super::codec::Value::Array(items),
506            );
507        }
508        Ok(object)
509    }
510
511    fn from_json(
512        object: &super::super::codec::Object,
513        path: &mut super::super::codec::Path,
514    ) -> Result<Self, super::super::codec::DecodeError> {
515        let mut raw_id: Option<&super::super::codec::Value> = None;
516        let mut raw_id_element: Option<&super::super::codec::Value> = None;
517        let mut raw_meta: Option<&super::super::codec::Value> = None;
518        let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
519        let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
520        let mut raw_language: Option<&super::super::codec::Value> = None;
521        let mut raw_language_element: Option<&super::super::codec::Value> = None;
522        let mut raw_text: Option<&super::super::codec::Value> = None;
523        let mut raw_contained: Option<&super::super::codec::Value> = None;
524        let mut raw_extension: Option<&super::super::codec::Value> = None;
525        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
526        let mut raw_url: Option<&super::super::codec::Value> = None;
527        let mut raw_url_element: Option<&super::super::codec::Value> = None;
528        let mut raw_identifier: Option<&super::super::codec::Value> = None;
529        let mut raw_version: Option<&super::super::codec::Value> = None;
530        let mut raw_version_element: Option<&super::super::codec::Value> = None;
531        let mut raw_name: Option<&super::super::codec::Value> = None;
532        let mut raw_name_element: Option<&super::super::codec::Value> = None;
533        let mut raw_title: Option<&super::super::codec::Value> = None;
534        let mut raw_title_element: Option<&super::super::codec::Value> = None;
535        let mut raw_status: Option<&super::super::codec::Value> = None;
536        let mut raw_status_element: Option<&super::super::codec::Value> = None;
537        let mut raw_experimental: Option<&super::super::codec::Value> = None;
538        let mut raw_experimental_element: Option<&super::super::codec::Value> = None;
539        let mut raw_date: Option<&super::super::codec::Value> = None;
540        let mut raw_date_element: Option<&super::super::codec::Value> = None;
541        let mut raw_publisher: Option<&super::super::codec::Value> = None;
542        let mut raw_publisher_element: Option<&super::super::codec::Value> = None;
543        let mut raw_contact: Option<&super::super::codec::Value> = None;
544        let mut raw_description: Option<&super::super::codec::Value> = None;
545        let mut raw_description_element: Option<&super::super::codec::Value> = None;
546        let mut raw_use_context: Option<&super::super::codec::Value> = None;
547        let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
548        let mut raw_purpose: Option<&super::super::codec::Value> = None;
549        let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
550        let mut raw_copyright: Option<&super::super::codec::Value> = None;
551        let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
552        let mut raw_case_sensitive: Option<&super::super::codec::Value> = None;
553        let mut raw_case_sensitive_element: Option<&super::super::codec::Value> = None;
554        let mut raw_value_set: Option<&super::super::codec::Value> = None;
555        let mut raw_value_set_element: Option<&super::super::codec::Value> = None;
556        let mut raw_hierarchy_meaning: Option<&super::super::codec::Value> = None;
557        let mut raw_hierarchy_meaning_element: Option<&super::super::codec::Value> = None;
558        let mut raw_compositional: Option<&super::super::codec::Value> = None;
559        let mut raw_compositional_element: Option<&super::super::codec::Value> = None;
560        let mut raw_version_needed: Option<&super::super::codec::Value> = None;
561        let mut raw_version_needed_element: Option<&super::super::codec::Value> = None;
562        let mut raw_content: Option<&super::super::codec::Value> = None;
563        let mut raw_content_element: Option<&super::super::codec::Value> = None;
564        let mut raw_count: Option<&super::super::codec::Value> = None;
565        let mut raw_count_element: Option<&super::super::codec::Value> = None;
566        let mut raw_filter: Option<&super::super::codec::Value> = None;
567        let mut raw_property: Option<&super::super::codec::Value> = None;
568        let mut raw_concept: Option<&super::super::codec::Value> = None;
569        for (key, value) in object {
570            match key.as_str() {
571                "resourceType" => {
572                    if value.as_str() != Some("CodeSystem") {
573                        return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
574                    }
575                }
576                "id" => {
577                    raw_id = Some(value);
578                }
579                "_id" => {
580                    raw_id_element = Some(value);
581                }
582                "meta" => {
583                    raw_meta = Some(value);
584                }
585                "implicitRules" => {
586                    raw_implicit_rules = Some(value);
587                }
588                "_implicitRules" => {
589                    raw_implicit_rules_element = Some(value);
590                }
591                "language" => {
592                    raw_language = Some(value);
593                }
594                "_language" => {
595                    raw_language_element = Some(value);
596                }
597                "text" => {
598                    raw_text = Some(value);
599                }
600                "contained" => {
601                    raw_contained = Some(value);
602                }
603                "extension" => {
604                    raw_extension = Some(value);
605                }
606                "modifierExtension" => {
607                    raw_modifier_extension = Some(value);
608                }
609                "url" => {
610                    raw_url = Some(value);
611                }
612                "_url" => {
613                    raw_url_element = Some(value);
614                }
615                "identifier" => {
616                    raw_identifier = Some(value);
617                }
618                "version" => {
619                    raw_version = Some(value);
620                }
621                "_version" => {
622                    raw_version_element = Some(value);
623                }
624                "name" => {
625                    raw_name = Some(value);
626                }
627                "_name" => {
628                    raw_name_element = Some(value);
629                }
630                "title" => {
631                    raw_title = Some(value);
632                }
633                "_title" => {
634                    raw_title_element = Some(value);
635                }
636                "status" => {
637                    raw_status = Some(value);
638                }
639                "_status" => {
640                    raw_status_element = Some(value);
641                }
642                "experimental" => {
643                    raw_experimental = Some(value);
644                }
645                "_experimental" => {
646                    raw_experimental_element = Some(value);
647                }
648                "date" => {
649                    raw_date = Some(value);
650                }
651                "_date" => {
652                    raw_date_element = Some(value);
653                }
654                "publisher" => {
655                    raw_publisher = Some(value);
656                }
657                "_publisher" => {
658                    raw_publisher_element = Some(value);
659                }
660                "contact" => {
661                    raw_contact = Some(value);
662                }
663                "description" => {
664                    raw_description = Some(value);
665                }
666                "_description" => {
667                    raw_description_element = Some(value);
668                }
669                "useContext" => {
670                    raw_use_context = Some(value);
671                }
672                "jurisdiction" => {
673                    raw_jurisdiction = Some(value);
674                }
675                "purpose" => {
676                    raw_purpose = Some(value);
677                }
678                "_purpose" => {
679                    raw_purpose_element = Some(value);
680                }
681                "copyright" => {
682                    raw_copyright = Some(value);
683                }
684                "_copyright" => {
685                    raw_copyright_element = Some(value);
686                }
687                "caseSensitive" => {
688                    raw_case_sensitive = Some(value);
689                }
690                "_caseSensitive" => {
691                    raw_case_sensitive_element = Some(value);
692                }
693                "valueSet" => {
694                    raw_value_set = Some(value);
695                }
696                "_valueSet" => {
697                    raw_value_set_element = Some(value);
698                }
699                "hierarchyMeaning" => {
700                    raw_hierarchy_meaning = Some(value);
701                }
702                "_hierarchyMeaning" => {
703                    raw_hierarchy_meaning_element = Some(value);
704                }
705                "compositional" => {
706                    raw_compositional = Some(value);
707                }
708                "_compositional" => {
709                    raw_compositional_element = Some(value);
710                }
711                "versionNeeded" => {
712                    raw_version_needed = Some(value);
713                }
714                "_versionNeeded" => {
715                    raw_version_needed_element = Some(value);
716                }
717                "content" => {
718                    raw_content = Some(value);
719                }
720                "_content" => {
721                    raw_content_element = Some(value);
722                }
723                "count" => {
724                    raw_count = Some(value);
725                }
726                "_count" => {
727                    raw_count_element = Some(value);
728                }
729                "filter" => {
730                    raw_filter = Some(value);
731                }
732                "property" => {
733                    raw_property = Some(value);
734                }
735                "concept" => {
736                    raw_concept = Some(value);
737                }
738                other => {
739                    return path.with(other, |path| {
740                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
741                    });
742                }
743            }
744        }
745        let field_id = match (raw_id, raw_id_element) {
746            (None, None) => None,
747            (value, element) => Some(path.with("id", |path| {
748                super::super::codec::Primitive::from_json_parts(value, element, path)
749            })?),
750        };
751        let field_meta = raw_meta
752            .map(|value| {
753                path.with("meta", |path| {
754                    super::super::codec::Json::from_json(
755                        super::super::codec::expect_object(
756                            super::super::codec::expect_single(value, path)?,
757                            path,
758                        )?,
759                        path,
760                    )
761                })
762            })
763            .transpose()?;
764        let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
765            (None, None) => None,
766            (value, element) => Some(path.with("implicitRules", |path| {
767                super::super::codec::Primitive::from_json_parts(value, element, path)
768            })?),
769        };
770        let field_language = match (raw_language, raw_language_element) {
771            (None, None) => None,
772            (value, element) => Some(path.with("language", |path| {
773                super::super::codec::Primitive::from_json_parts(value, element, path)
774            })?),
775        };
776        let field_text = raw_text
777            .map(|value| {
778                path.with("text", |path| {
779                    super::super::codec::Json::from_json(
780                        super::super::codec::expect_object(
781                            super::super::codec::expect_single(value, path)?,
782                            path,
783                        )?,
784                        path,
785                    )
786                })
787            })
788            .transpose()?;
789        let mut field_contained = Vec::new();
790        if let Some(raw) = raw_contained {
791            for (index, value) in path
792                .with("contained", |path| {
793                    super::super::codec::expect_array(raw, path)
794                })?
795                .iter()
796                .enumerate()
797            {
798                field_contained.push(path.with_index("contained", index, |path| {
799                    super::super::codec::Json::from_json(
800                        super::super::codec::expect_object(value, path)?,
801                        path,
802                    )
803                })?);
804            }
805        }
806        let mut field_extension = Vec::new();
807        if let Some(raw) = raw_extension {
808            for (index, value) in path
809                .with("extension", |path| {
810                    super::super::codec::expect_array(raw, path)
811                })?
812                .iter()
813                .enumerate()
814            {
815                field_extension.push(path.with_index("extension", index, |path| {
816                    super::super::codec::Json::from_json(
817                        super::super::codec::expect_object(value, path)?,
818                        path,
819                    )
820                })?);
821            }
822        }
823        let mut field_modifier_extension = Vec::new();
824        if let Some(raw) = raw_modifier_extension {
825            for (index, value) in path
826                .with("modifierExtension", |path| {
827                    super::super::codec::expect_array(raw, path)
828                })?
829                .iter()
830                .enumerate()
831            {
832                field_modifier_extension.push(path.with_index(
833                    "modifierExtension",
834                    index,
835                    |path| {
836                        super::super::codec::Json::from_json(
837                            super::super::codec::expect_object(value, path)?,
838                            path,
839                        )
840                    },
841                )?);
842            }
843        }
844        let field_url = match (raw_url, raw_url_element) {
845            (None, None) => None,
846            (value, element) => Some(path.with("url", |path| {
847                super::super::codec::Primitive::from_json_parts(value, element, path)
848            })?),
849        };
850        let field_identifier = raw_identifier
851            .map(|value| {
852                path.with("identifier", |path| {
853                    super::super::codec::Json::from_json(
854                        super::super::codec::expect_object(
855                            super::super::codec::expect_single(value, path)?,
856                            path,
857                        )?,
858                        path,
859                    )
860                })
861            })
862            .transpose()?;
863        let field_version = match (raw_version, raw_version_element) {
864            (None, None) => None,
865            (value, element) => Some(path.with("version", |path| {
866                super::super::codec::Primitive::from_json_parts(value, element, path)
867            })?),
868        };
869        let field_name = match (raw_name, raw_name_element) {
870            (None, None) => None,
871            (value, element) => Some(path.with("name", |path| {
872                super::super::codec::Primitive::from_json_parts(value, element, path)
873            })?),
874        };
875        let field_title = match (raw_title, raw_title_element) {
876            (None, None) => None,
877            (value, element) => Some(path.with("title", |path| {
878                super::super::codec::Primitive::from_json_parts(value, element, path)
879            })?),
880        };
881        let field_status = path.with("status", |path| {
882            super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
883        })?;
884        let field_experimental = match (raw_experimental, raw_experimental_element) {
885            (None, None) => None,
886            (value, element) => Some(path.with("experimental", |path| {
887                super::super::codec::Primitive::from_json_parts(value, element, path)
888            })?),
889        };
890        let field_date = match (raw_date, raw_date_element) {
891            (None, None) => None,
892            (value, element) => Some(path.with("date", |path| {
893                super::super::codec::Primitive::from_json_parts(value, element, path)
894            })?),
895        };
896        let field_publisher = match (raw_publisher, raw_publisher_element) {
897            (None, None) => None,
898            (value, element) => Some(path.with("publisher", |path| {
899                super::super::codec::Primitive::from_json_parts(value, element, path)
900            })?),
901        };
902        let mut field_contact = Vec::new();
903        if let Some(raw) = raw_contact {
904            for (index, value) in path
905                .with("contact", |path| {
906                    super::super::codec::expect_array(raw, path)
907                })?
908                .iter()
909                .enumerate()
910            {
911                field_contact.push(path.with_index("contact", index, |path| {
912                    super::super::codec::Json::from_json(
913                        super::super::codec::expect_object(value, path)?,
914                        path,
915                    )
916                })?);
917            }
918        }
919        let field_description = match (raw_description, raw_description_element) {
920            (None, None) => None,
921            (value, element) => Some(path.with("description", |path| {
922                super::super::codec::Primitive::from_json_parts(value, element, path)
923            })?),
924        };
925        let mut field_use_context = Vec::new();
926        if let Some(raw) = raw_use_context {
927            for (index, value) in path
928                .with("useContext", |path| {
929                    super::super::codec::expect_array(raw, path)
930                })?
931                .iter()
932                .enumerate()
933            {
934                field_use_context.push(path.with_index("useContext", index, |path| {
935                    super::super::codec::Json::from_json(
936                        super::super::codec::expect_object(value, path)?,
937                        path,
938                    )
939                })?);
940            }
941        }
942        let mut field_jurisdiction = Vec::new();
943        if let Some(raw) = raw_jurisdiction {
944            for (index, value) in path
945                .with("jurisdiction", |path| {
946                    super::super::codec::expect_array(raw, path)
947                })?
948                .iter()
949                .enumerate()
950            {
951                field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
952                    super::super::codec::Json::from_json(
953                        super::super::codec::expect_object(value, path)?,
954                        path,
955                    )
956                })?);
957            }
958        }
959        let field_purpose = match (raw_purpose, raw_purpose_element) {
960            (None, None) => None,
961            (value, element) => Some(path.with("purpose", |path| {
962                super::super::codec::Primitive::from_json_parts(value, element, path)
963            })?),
964        };
965        let field_copyright = match (raw_copyright, raw_copyright_element) {
966            (None, None) => None,
967            (value, element) => Some(path.with("copyright", |path| {
968                super::super::codec::Primitive::from_json_parts(value, element, path)
969            })?),
970        };
971        let field_case_sensitive = match (raw_case_sensitive, raw_case_sensitive_element) {
972            (None, None) => None,
973            (value, element) => Some(path.with("caseSensitive", |path| {
974                super::super::codec::Primitive::from_json_parts(value, element, path)
975            })?),
976        };
977        let field_value_set = match (raw_value_set, raw_value_set_element) {
978            (None, None) => None,
979            (value, element) => Some(path.with("valueSet", |path| {
980                super::super::codec::Primitive::from_json_parts(value, element, path)
981            })?),
982        };
983        let field_hierarchy_meaning = match (raw_hierarchy_meaning, raw_hierarchy_meaning_element) {
984            (None, None) => None,
985            (value, element) => Some(path.with("hierarchyMeaning", |path| {
986                super::super::codec::Primitive::from_json_parts(value, element, path)
987            })?),
988        };
989        let field_compositional = match (raw_compositional, raw_compositional_element) {
990            (None, None) => None,
991            (value, element) => Some(path.with("compositional", |path| {
992                super::super::codec::Primitive::from_json_parts(value, element, path)
993            })?),
994        };
995        let field_version_needed = match (raw_version_needed, raw_version_needed_element) {
996            (None, None) => None,
997            (value, element) => Some(path.with("versionNeeded", |path| {
998                super::super::codec::Primitive::from_json_parts(value, element, path)
999            })?),
1000        };
1001        let field_content = path.with("content", |path| {
1002            super::super::codec::Primitive::from_json_parts(raw_content, raw_content_element, path)
1003        })?;
1004        let field_count = match (raw_count, raw_count_element) {
1005            (None, None) => None,
1006            (value, element) => Some(path.with("count", |path| {
1007                super::super::codec::Primitive::from_json_parts(value, element, path)
1008            })?),
1009        };
1010        let mut field_filter = Vec::new();
1011        if let Some(raw) = raw_filter {
1012            for (index, value) in path
1013                .with("filter", |path| {
1014                    super::super::codec::expect_array(raw, path)
1015                })?
1016                .iter()
1017                .enumerate()
1018            {
1019                field_filter.push(path.with_index("filter", index, |path| {
1020                    super::super::codec::Json::from_json(
1021                        super::super::codec::expect_object(value, path)?,
1022                        path,
1023                    )
1024                })?);
1025            }
1026        }
1027        let mut field_property = Vec::new();
1028        if let Some(raw) = raw_property {
1029            for (index, value) in path
1030                .with("property", |path| {
1031                    super::super::codec::expect_array(raw, path)
1032                })?
1033                .iter()
1034                .enumerate()
1035            {
1036                field_property.push(path.with_index("property", index, |path| {
1037                    super::super::codec::Json::from_json(
1038                        super::super::codec::expect_object(value, path)?,
1039                        path,
1040                    )
1041                })?);
1042            }
1043        }
1044        let mut field_concept = Vec::new();
1045        if let Some(raw) = raw_concept {
1046            for (index, value) in path
1047                .with("concept", |path| {
1048                    super::super::codec::expect_array(raw, path)
1049                })?
1050                .iter()
1051                .enumerate()
1052            {
1053                field_concept.push(path.with_index("concept", index, |path| {
1054                    super::super::codec::Json::from_json(
1055                        super::super::codec::expect_object(value, path)?,
1056                        path,
1057                    )
1058                })?);
1059            }
1060        }
1061        Ok(Self {
1062            id: field_id,
1063            meta: field_meta,
1064            implicit_rules: field_implicit_rules,
1065            language: field_language,
1066            text: field_text,
1067            contained: field_contained,
1068            extension: field_extension,
1069            modifier_extension: field_modifier_extension,
1070            url: field_url,
1071            identifier: field_identifier,
1072            version: field_version,
1073            name: field_name,
1074            title: field_title,
1075            status: field_status,
1076            experimental: field_experimental,
1077            date: field_date,
1078            publisher: field_publisher,
1079            contact: field_contact,
1080            description: field_description,
1081            use_context: field_use_context,
1082            jurisdiction: field_jurisdiction,
1083            purpose: field_purpose,
1084            copyright: field_copyright,
1085            case_sensitive: field_case_sensitive,
1086            value_set: field_value_set,
1087            hierarchy_meaning: field_hierarchy_meaning,
1088            compositional: field_compositional,
1089            version_needed: field_version_needed,
1090            content: field_content,
1091            count: field_count,
1092            filter: field_filter,
1093            property: field_property,
1094            concept: field_concept,
1095        })
1096    }
1097}
1098
1099impl serde::Serialize for CodeSystem {
1100    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1101        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1102        if let Some(item) = &self.case_sensitive {
1103            super::super::codec::element_entry(&mut map, "_caseSensitive", item)?;
1104        }
1105        if let Some(item) = &self.compositional {
1106            super::super::codec::element_entry(&mut map, "_compositional", item)?;
1107        }
1108        super::super::codec::element_entry(&mut map, "_content", &self.content)?;
1109        if let Some(item) = &self.copyright {
1110            super::super::codec::element_entry(&mut map, "_copyright", item)?;
1111        }
1112        if let Some(item) = &self.count {
1113            super::super::codec::element_entry(&mut map, "_count", item)?;
1114        }
1115        if let Some(item) = &self.date {
1116            super::super::codec::element_entry(&mut map, "_date", item)?;
1117        }
1118        if let Some(item) = &self.description {
1119            super::super::codec::element_entry(&mut map, "_description", item)?;
1120        }
1121        if let Some(item) = &self.experimental {
1122            super::super::codec::element_entry(&mut map, "_experimental", item)?;
1123        }
1124        if let Some(item) = &self.hierarchy_meaning {
1125            super::super::codec::element_entry(&mut map, "_hierarchyMeaning", item)?;
1126        }
1127        if let Some(item) = &self.id {
1128            super::super::codec::element_entry(&mut map, "_id", item)?;
1129        }
1130        if let Some(item) = &self.implicit_rules {
1131            super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
1132        }
1133        if let Some(item) = &self.language {
1134            super::super::codec::element_entry(&mut map, "_language", item)?;
1135        }
1136        if let Some(item) = &self.name {
1137            super::super::codec::element_entry(&mut map, "_name", item)?;
1138        }
1139        if let Some(item) = &self.publisher {
1140            super::super::codec::element_entry(&mut map, "_publisher", item)?;
1141        }
1142        if let Some(item) = &self.purpose {
1143            super::super::codec::element_entry(&mut map, "_purpose", item)?;
1144        }
1145        super::super::codec::element_entry(&mut map, "_status", &self.status)?;
1146        if let Some(item) = &self.title {
1147            super::super::codec::element_entry(&mut map, "_title", item)?;
1148        }
1149        if let Some(item) = &self.url {
1150            super::super::codec::element_entry(&mut map, "_url", item)?;
1151        }
1152        if let Some(item) = &self.value_set {
1153            super::super::codec::element_entry(&mut map, "_valueSet", item)?;
1154        }
1155        if let Some(item) = &self.version {
1156            super::super::codec::element_entry(&mut map, "_version", item)?;
1157        }
1158        if let Some(item) = &self.version_needed {
1159            super::super::codec::element_entry(&mut map, "_versionNeeded", item)?;
1160        }
1161        if let Some(item) = &self.case_sensitive {
1162            super::super::codec::value_entry(&mut map, "caseSensitive", item)?;
1163        }
1164        if let Some(item) = &self.compositional {
1165            super::super::codec::value_entry(&mut map, "compositional", item)?;
1166        }
1167        if !self.concept.is_empty() {
1168            serde::ser::SerializeMap::serialize_entry(&mut map, "concept", &self.concept)?;
1169        }
1170        if !self.contact.is_empty() {
1171            serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
1172        }
1173        if !self.contained.is_empty() {
1174            serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
1175        }
1176        super::super::codec::value_entry(&mut map, "content", &self.content)?;
1177        if let Some(item) = &self.copyright {
1178            super::super::codec::value_entry(&mut map, "copyright", item)?;
1179        }
1180        if let Some(item) = &self.count {
1181            super::super::codec::value_entry(&mut map, "count", item)?;
1182        }
1183        if let Some(item) = &self.date {
1184            super::super::codec::value_entry(&mut map, "date", item)?;
1185        }
1186        if let Some(item) = &self.description {
1187            super::super::codec::value_entry(&mut map, "description", item)?;
1188        }
1189        if let Some(item) = &self.experimental {
1190            super::super::codec::value_entry(&mut map, "experimental", item)?;
1191        }
1192        if !self.extension.is_empty() {
1193            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1194        }
1195        if !self.filter.is_empty() {
1196            serde::ser::SerializeMap::serialize_entry(&mut map, "filter", &self.filter)?;
1197        }
1198        if let Some(item) = &self.hierarchy_meaning {
1199            super::super::codec::value_entry(&mut map, "hierarchyMeaning", item)?;
1200        }
1201        if let Some(item) = &self.id {
1202            super::super::codec::value_entry(&mut map, "id", item)?;
1203        }
1204        if let Some(item) = &self.identifier {
1205            serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", item)?;
1206        }
1207        if let Some(item) = &self.implicit_rules {
1208            super::super::codec::value_entry(&mut map, "implicitRules", item)?;
1209        }
1210        if !self.jurisdiction.is_empty() {
1211            serde::ser::SerializeMap::serialize_entry(
1212                &mut map,
1213                "jurisdiction",
1214                &self.jurisdiction,
1215            )?;
1216        }
1217        if let Some(item) = &self.language {
1218            super::super::codec::value_entry(&mut map, "language", item)?;
1219        }
1220        if let Some(item) = &self.meta {
1221            serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
1222        }
1223        if !self.modifier_extension.is_empty() {
1224            serde::ser::SerializeMap::serialize_entry(
1225                &mut map,
1226                "modifierExtension",
1227                &self.modifier_extension,
1228            )?;
1229        }
1230        if let Some(item) = &self.name {
1231            super::super::codec::value_entry(&mut map, "name", item)?;
1232        }
1233        if !self.property.is_empty() {
1234            serde::ser::SerializeMap::serialize_entry(&mut map, "property", &self.property)?;
1235        }
1236        if let Some(item) = &self.publisher {
1237            super::super::codec::value_entry(&mut map, "publisher", item)?;
1238        }
1239        if let Some(item) = &self.purpose {
1240            super::super::codec::value_entry(&mut map, "purpose", item)?;
1241        }
1242        serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "CodeSystem")?;
1243        super::super::codec::value_entry(&mut map, "status", &self.status)?;
1244        if let Some(item) = &self.text {
1245            serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
1246        }
1247        if let Some(item) = &self.title {
1248            super::super::codec::value_entry(&mut map, "title", item)?;
1249        }
1250        if let Some(item) = &self.url {
1251            super::super::codec::value_entry(&mut map, "url", item)?;
1252        }
1253        if !self.use_context.is_empty() {
1254            serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
1255        }
1256        if let Some(item) = &self.value_set {
1257            super::super::codec::value_entry(&mut map, "valueSet", item)?;
1258        }
1259        if let Some(item) = &self.version {
1260            super::super::codec::value_entry(&mut map, "version", item)?;
1261        }
1262        if let Some(item) = &self.version_needed {
1263            super::super::codec::value_entry(&mut map, "versionNeeded", item)?;
1264        }
1265        serde::ser::SerializeMap::end(map)
1266    }
1267}
1268
1269impl<'de> serde::Deserialize<'de> for CodeSystem {
1270    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1271        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1272        let mut path = super::super::codec::Path::root("CodeSystem");
1273        let object =
1274            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1275        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1276    }
1277}
1278
1279/// Concepts in the code system
1280///
1281/// Concepts that are in the code system. The concept definitions are inherently
1282/// hierarchical, but the definitions must be consulted to determine what the
1283/// meaning of the hierarchical relationships are.
1284#[derive(Debug, Clone, Default, PartialEq, Eq)]
1285pub struct CodeSystemConcept {
1286    /// xml:id (or equivalent in JSON)
1287    ///
1288    /// unique id for the element within a resource (for internal references). This
1289    /// may be any string value that does not contain spaces.
1290    pub id: Option<std::string::String>,
1291    /// Additional Content defined by implementations
1292    ///
1293    /// May be used to represent additional information that is not part of the
1294    /// basic definition of the element. In order to make the use of extensions safe
1295    /// and manageable, there is a strict set of governance applied to the
1296    /// definition and use of extensions. Though any implementer is allowed to
1297    /// define an extension, there is a set of requirements that SHALL be met as
1298    /// part of the definition of the extension.
1299    pub extension: Vec<super::extension::Extension>,
1300    /// Extensions that cannot be ignored
1301    ///
1302    /// May be used to represent additional information that is not part of the
1303    /// basic definition of the element, and that modifies the understanding of the
1304    /// element that contains it. Usually modifier elements provide negation or
1305    /// qualification. In order to make the use of extensions safe and manageable,
1306    /// there is a strict set of governance applied to the definition and use of
1307    /// extensions. Though any implementer is allowed to define an extension, there
1308    /// is a set of requirements that SHALL be met as part of the definition of the
1309    /// extension. Applications processing a resource are required to check for
1310    /// modifier extensions.
1311    pub modifier_extension: Vec<super::extension::Extension>,
1312    /// Code that identifies concept
1313    ///
1314    /// A code - a text symbol - that uniquely identifies the concept within the
1315    /// code system.
1316    pub code: super::primitives::Code,
1317    /// Text to display to the user
1318    ///
1319    /// A human readable string that is the recommended default way to present this
1320    /// concept to a user.
1321    pub display: Option<super::primitives::String>,
1322    /// Formal definition
1323    ///
1324    /// The formal definition of the concept. The code system resource does not make
1325    /// formal definitions required, because of the prevalence of legacy systems.
1326    /// However, they are highly recommended, as without them there is no formal
1327    /// meaning associated with the concept.
1328    pub definition: Option<super::primitives::String>,
1329    /// Additional representations for the concept
1330    ///
1331    /// Additional representations for the concept - other languages, aliases,
1332    /// specialized purposes, used for particular purposes, etc.
1333    pub designation: Vec<CodeSystemConceptDesignation>,
1334    /// Property value for the concept
1335    ///
1336    /// A property value for this concept.
1337    pub property: Vec<CodeSystemConceptProperty>,
1338    /// Child Concepts (is-a/contains/categorizes)
1339    ///
1340    /// Defines children of a concept to produce a hierarchy of concepts. The nature
1341    /// of the relationships is variable (is-a/contains/categorizes) - see
1342    /// hierarchyMeaning.
1343    pub concept: Vec<CodeSystemConcept>,
1344}
1345
1346impl super::super::codec::Json for CodeSystemConcept {
1347    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1348        let mut object = super::super::codec::Object::new();
1349        if let Some(v) = &self.id {
1350            object.insert(
1351                std::string::String::from("id"),
1352                super::super::codec::Value::String(v.clone()),
1353            );
1354        }
1355        if !self.extension.is_empty() {
1356            let mut items = Vec::with_capacity(self.extension.len());
1357            for item in &self.extension {
1358                items.push(super::super::codec::Value::Object(
1359                    super::super::codec::Json::to_json(item)?,
1360                ));
1361            }
1362            object.insert(
1363                std::string::String::from("extension"),
1364                super::super::codec::Value::Array(items),
1365            );
1366        }
1367        if !self.modifier_extension.is_empty() {
1368            let mut items = Vec::with_capacity(self.modifier_extension.len());
1369            for item in &self.modifier_extension {
1370                items.push(super::super::codec::Value::Object(
1371                    super::super::codec::Json::to_json(item)?,
1372                ));
1373            }
1374            object.insert(
1375                std::string::String::from("modifierExtension"),
1376                super::super::codec::Value::Array(items),
1377            );
1378        }
1379        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
1380            object.insert(std::string::String::from("code"), v);
1381        }
1382        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
1383            object.insert(std::string::String::from("_code"), e);
1384        }
1385        if let Some(item) = &self.display {
1386            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1387                object.insert(std::string::String::from("display"), v);
1388            }
1389            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1390                object.insert(std::string::String::from("_display"), e);
1391            }
1392        }
1393        if let Some(item) = &self.definition {
1394            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1395                object.insert(std::string::String::from("definition"), v);
1396            }
1397            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1398                object.insert(std::string::String::from("_definition"), e);
1399            }
1400        }
1401        if !self.designation.is_empty() {
1402            let mut items = Vec::with_capacity(self.designation.len());
1403            for item in &self.designation {
1404                items.push(super::super::codec::Value::Object(
1405                    super::super::codec::Json::to_json(item)?,
1406                ));
1407            }
1408            object.insert(
1409                std::string::String::from("designation"),
1410                super::super::codec::Value::Array(items),
1411            );
1412        }
1413        if !self.property.is_empty() {
1414            let mut items = Vec::with_capacity(self.property.len());
1415            for item in &self.property {
1416                items.push(super::super::codec::Value::Object(
1417                    super::super::codec::Json::to_json(item)?,
1418                ));
1419            }
1420            object.insert(
1421                std::string::String::from("property"),
1422                super::super::codec::Value::Array(items),
1423            );
1424        }
1425        if !self.concept.is_empty() {
1426            let mut items = Vec::with_capacity(self.concept.len());
1427            for item in &self.concept {
1428                items.push(super::super::codec::Value::Object(
1429                    super::super::codec::Json::to_json(item)?,
1430                ));
1431            }
1432            object.insert(
1433                std::string::String::from("concept"),
1434                super::super::codec::Value::Array(items),
1435            );
1436        }
1437        Ok(object)
1438    }
1439
1440    fn from_json(
1441        object: &super::super::codec::Object,
1442        path: &mut super::super::codec::Path,
1443    ) -> Result<Self, super::super::codec::DecodeError> {
1444        let mut raw_id: Option<&super::super::codec::Value> = None;
1445        let mut raw_extension: Option<&super::super::codec::Value> = None;
1446        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1447        let mut raw_code: Option<&super::super::codec::Value> = None;
1448        let mut raw_code_element: Option<&super::super::codec::Value> = None;
1449        let mut raw_display: Option<&super::super::codec::Value> = None;
1450        let mut raw_display_element: Option<&super::super::codec::Value> = None;
1451        let mut raw_definition: Option<&super::super::codec::Value> = None;
1452        let mut raw_definition_element: Option<&super::super::codec::Value> = None;
1453        let mut raw_designation: Option<&super::super::codec::Value> = None;
1454        let mut raw_property: Option<&super::super::codec::Value> = None;
1455        let mut raw_concept: Option<&super::super::codec::Value> = None;
1456        for (key, value) in object {
1457            match key.as_str() {
1458                "id" => {
1459                    raw_id = Some(value);
1460                }
1461                "extension" => {
1462                    raw_extension = Some(value);
1463                }
1464                "modifierExtension" => {
1465                    raw_modifier_extension = Some(value);
1466                }
1467                "code" => {
1468                    raw_code = Some(value);
1469                }
1470                "_code" => {
1471                    raw_code_element = Some(value);
1472                }
1473                "display" => {
1474                    raw_display = Some(value);
1475                }
1476                "_display" => {
1477                    raw_display_element = Some(value);
1478                }
1479                "definition" => {
1480                    raw_definition = Some(value);
1481                }
1482                "_definition" => {
1483                    raw_definition_element = Some(value);
1484                }
1485                "designation" => {
1486                    raw_designation = Some(value);
1487                }
1488                "property" => {
1489                    raw_property = Some(value);
1490                }
1491                "concept" => {
1492                    raw_concept = Some(value);
1493                }
1494                other => {
1495                    return path.with(other, |path| {
1496                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1497                    });
1498                }
1499            }
1500        }
1501        let field_id = raw_id
1502            .map(|value| {
1503                path.with("id", |path| {
1504                    let value = super::super::codec::expect_single(value, path)?;
1505                    super::super::codec::expect_string(value, path)
1506                })
1507            })
1508            .transpose()?;
1509        let mut field_extension = Vec::new();
1510        if let Some(raw) = raw_extension {
1511            for (index, value) in path
1512                .with("extension", |path| {
1513                    super::super::codec::expect_array(raw, path)
1514                })?
1515                .iter()
1516                .enumerate()
1517            {
1518                field_extension.push(path.with_index("extension", index, |path| {
1519                    super::super::codec::Json::from_json(
1520                        super::super::codec::expect_object(value, path)?,
1521                        path,
1522                    )
1523                })?);
1524            }
1525        }
1526        let mut field_modifier_extension = Vec::new();
1527        if let Some(raw) = raw_modifier_extension {
1528            for (index, value) in path
1529                .with("modifierExtension", |path| {
1530                    super::super::codec::expect_array(raw, path)
1531                })?
1532                .iter()
1533                .enumerate()
1534            {
1535                field_modifier_extension.push(path.with_index(
1536                    "modifierExtension",
1537                    index,
1538                    |path| {
1539                        super::super::codec::Json::from_json(
1540                            super::super::codec::expect_object(value, path)?,
1541                            path,
1542                        )
1543                    },
1544                )?);
1545            }
1546        }
1547        let field_code = path.with("code", |path| {
1548            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
1549        })?;
1550        let field_display = match (raw_display, raw_display_element) {
1551            (None, None) => None,
1552            (value, element) => Some(path.with("display", |path| {
1553                super::super::codec::Primitive::from_json_parts(value, element, path)
1554            })?),
1555        };
1556        let field_definition = match (raw_definition, raw_definition_element) {
1557            (None, None) => None,
1558            (value, element) => Some(path.with("definition", |path| {
1559                super::super::codec::Primitive::from_json_parts(value, element, path)
1560            })?),
1561        };
1562        let mut field_designation = Vec::new();
1563        if let Some(raw) = raw_designation {
1564            for (index, value) in path
1565                .with("designation", |path| {
1566                    super::super::codec::expect_array(raw, path)
1567                })?
1568                .iter()
1569                .enumerate()
1570            {
1571                field_designation.push(path.with_index("designation", index, |path| {
1572                    super::super::codec::Json::from_json(
1573                        super::super::codec::expect_object(value, path)?,
1574                        path,
1575                    )
1576                })?);
1577            }
1578        }
1579        let mut field_property = Vec::new();
1580        if let Some(raw) = raw_property {
1581            for (index, value) in path
1582                .with("property", |path| {
1583                    super::super::codec::expect_array(raw, path)
1584                })?
1585                .iter()
1586                .enumerate()
1587            {
1588                field_property.push(path.with_index("property", index, |path| {
1589                    super::super::codec::Json::from_json(
1590                        super::super::codec::expect_object(value, path)?,
1591                        path,
1592                    )
1593                })?);
1594            }
1595        }
1596        let mut field_concept = Vec::new();
1597        if let Some(raw) = raw_concept {
1598            for (index, value) in path
1599                .with("concept", |path| {
1600                    super::super::codec::expect_array(raw, path)
1601                })?
1602                .iter()
1603                .enumerate()
1604            {
1605                field_concept.push(path.with_index("concept", index, |path| {
1606                    super::super::codec::Json::from_json(
1607                        super::super::codec::expect_object(value, path)?,
1608                        path,
1609                    )
1610                })?);
1611            }
1612        }
1613        Ok(Self {
1614            id: field_id,
1615            extension: field_extension,
1616            modifier_extension: field_modifier_extension,
1617            code: field_code,
1618            display: field_display,
1619            definition: field_definition,
1620            designation: field_designation,
1621            property: field_property,
1622            concept: field_concept,
1623        })
1624    }
1625}
1626
1627impl serde::Serialize for CodeSystemConcept {
1628    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1629        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1630        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
1631        if let Some(item) = &self.definition {
1632            super::super::codec::element_entry(&mut map, "_definition", item)?;
1633        }
1634        if let Some(item) = &self.display {
1635            super::super::codec::element_entry(&mut map, "_display", item)?;
1636        }
1637        super::super::codec::value_entry(&mut map, "code", &self.code)?;
1638        if !self.concept.is_empty() {
1639            serde::ser::SerializeMap::serialize_entry(&mut map, "concept", &self.concept)?;
1640        }
1641        if let Some(item) = &self.definition {
1642            super::super::codec::value_entry(&mut map, "definition", item)?;
1643        }
1644        if !self.designation.is_empty() {
1645            serde::ser::SerializeMap::serialize_entry(&mut map, "designation", &self.designation)?;
1646        }
1647        if let Some(item) = &self.display {
1648            super::super::codec::value_entry(&mut map, "display", item)?;
1649        }
1650        if !self.extension.is_empty() {
1651            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1652        }
1653        if let Some(v) = &self.id {
1654            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1655        }
1656        if !self.modifier_extension.is_empty() {
1657            serde::ser::SerializeMap::serialize_entry(
1658                &mut map,
1659                "modifierExtension",
1660                &self.modifier_extension,
1661            )?;
1662        }
1663        if !self.property.is_empty() {
1664            serde::ser::SerializeMap::serialize_entry(&mut map, "property", &self.property)?;
1665        }
1666        serde::ser::SerializeMap::end(map)
1667    }
1668}
1669
1670impl<'de> serde::Deserialize<'de> for CodeSystemConcept {
1671    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1672        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1673        let mut path = super::super::codec::Path::root("CodeSystemConcept");
1674        let object =
1675            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1676        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1677    }
1678}
1679
1680/// Additional representations for the concept
1681///
1682/// Additional representations for the concept - other languages, aliases,
1683/// specialized purposes, used for particular purposes, etc.
1684#[derive(Debug, Clone, Default, PartialEq, Eq)]
1685pub struct CodeSystemConceptDesignation {
1686    /// xml:id (or equivalent in JSON)
1687    ///
1688    /// unique id for the element within a resource (for internal references). This
1689    /// may be any string value that does not contain spaces.
1690    pub id: Option<std::string::String>,
1691    /// Additional Content defined by implementations
1692    ///
1693    /// May be used to represent additional information that is not part of the
1694    /// basic definition of the element. In order to make the use of extensions safe
1695    /// and manageable, there is a strict set of governance applied to the
1696    /// definition and use of extensions. Though any implementer is allowed to
1697    /// define an extension, there is a set of requirements that SHALL be met as
1698    /// part of the definition of the extension.
1699    pub extension: Vec<super::extension::Extension>,
1700    /// Extensions that cannot be ignored
1701    ///
1702    /// May be used to represent additional information that is not part of the
1703    /// basic definition of the element, and that modifies the understanding of the
1704    /// element that contains it. Usually modifier elements provide negation or
1705    /// qualification. In order to make the use of extensions safe and manageable,
1706    /// there is a strict set of governance applied to the definition and use of
1707    /// extensions. Though any implementer is allowed to define an extension, there
1708    /// is a set of requirements that SHALL be met as part of the definition of the
1709    /// extension. Applications processing a resource are required to check for
1710    /// modifier extensions.
1711    pub modifier_extension: Vec<super::extension::Extension>,
1712    /// Human language of the designation
1713    ///
1714    /// The language this designation is defined for.
1715    pub language: Option<super::primitives::Code>,
1716    /// Details how this designation would be used
1717    ///
1718    /// A code that details how this designation would be used.
1719    pub r#use: Option<super::coding::Coding>,
1720    /// The text value for this designation.
1721    pub value: super::primitives::String,
1722}
1723
1724impl super::super::codec::Json for CodeSystemConceptDesignation {
1725    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1726        let mut object = super::super::codec::Object::new();
1727        if let Some(v) = &self.id {
1728            object.insert(
1729                std::string::String::from("id"),
1730                super::super::codec::Value::String(v.clone()),
1731            );
1732        }
1733        if !self.extension.is_empty() {
1734            let mut items = Vec::with_capacity(self.extension.len());
1735            for item in &self.extension {
1736                items.push(super::super::codec::Value::Object(
1737                    super::super::codec::Json::to_json(item)?,
1738                ));
1739            }
1740            object.insert(
1741                std::string::String::from("extension"),
1742                super::super::codec::Value::Array(items),
1743            );
1744        }
1745        if !self.modifier_extension.is_empty() {
1746            let mut items = Vec::with_capacity(self.modifier_extension.len());
1747            for item in &self.modifier_extension {
1748                items.push(super::super::codec::Value::Object(
1749                    super::super::codec::Json::to_json(item)?,
1750                ));
1751            }
1752            object.insert(
1753                std::string::String::from("modifierExtension"),
1754                super::super::codec::Value::Array(items),
1755            );
1756        }
1757        if let Some(item) = &self.language {
1758            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1759                object.insert(std::string::String::from("language"), v);
1760            }
1761            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1762                object.insert(std::string::String::from("_language"), e);
1763            }
1764        }
1765        if let Some(item) = &self.r#use {
1766            object.insert(
1767                std::string::String::from("use"),
1768                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
1769            );
1770        }
1771        if let Some(v) = super::super::codec::Primitive::value_json(&self.value)? {
1772            object.insert(std::string::String::from("value"), v);
1773        }
1774        if let Some(e) = super::super::codec::Primitive::element_json(&self.value)? {
1775            object.insert(std::string::String::from("_value"), e);
1776        }
1777        Ok(object)
1778    }
1779
1780    fn from_json(
1781        object: &super::super::codec::Object,
1782        path: &mut super::super::codec::Path,
1783    ) -> Result<Self, super::super::codec::DecodeError> {
1784        let mut raw_id: Option<&super::super::codec::Value> = None;
1785        let mut raw_extension: Option<&super::super::codec::Value> = None;
1786        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1787        let mut raw_language: Option<&super::super::codec::Value> = None;
1788        let mut raw_language_element: Option<&super::super::codec::Value> = None;
1789        let mut raw_use: Option<&super::super::codec::Value> = None;
1790        let mut raw_value: Option<&super::super::codec::Value> = None;
1791        let mut raw_value_element: Option<&super::super::codec::Value> = None;
1792        for (key, value) in object {
1793            match key.as_str() {
1794                "id" => {
1795                    raw_id = Some(value);
1796                }
1797                "extension" => {
1798                    raw_extension = Some(value);
1799                }
1800                "modifierExtension" => {
1801                    raw_modifier_extension = Some(value);
1802                }
1803                "language" => {
1804                    raw_language = Some(value);
1805                }
1806                "_language" => {
1807                    raw_language_element = Some(value);
1808                }
1809                "use" => {
1810                    raw_use = Some(value);
1811                }
1812                "value" => {
1813                    raw_value = Some(value);
1814                }
1815                "_value" => {
1816                    raw_value_element = Some(value);
1817                }
1818                other => {
1819                    return path.with(other, |path| {
1820                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1821                    });
1822                }
1823            }
1824        }
1825        let field_id = raw_id
1826            .map(|value| {
1827                path.with("id", |path| {
1828                    let value = super::super::codec::expect_single(value, path)?;
1829                    super::super::codec::expect_string(value, path)
1830                })
1831            })
1832            .transpose()?;
1833        let mut field_extension = Vec::new();
1834        if let Some(raw) = raw_extension {
1835            for (index, value) in path
1836                .with("extension", |path| {
1837                    super::super::codec::expect_array(raw, path)
1838                })?
1839                .iter()
1840                .enumerate()
1841            {
1842                field_extension.push(path.with_index("extension", index, |path| {
1843                    super::super::codec::Json::from_json(
1844                        super::super::codec::expect_object(value, path)?,
1845                        path,
1846                    )
1847                })?);
1848            }
1849        }
1850        let mut field_modifier_extension = Vec::new();
1851        if let Some(raw) = raw_modifier_extension {
1852            for (index, value) in path
1853                .with("modifierExtension", |path| {
1854                    super::super::codec::expect_array(raw, path)
1855                })?
1856                .iter()
1857                .enumerate()
1858            {
1859                field_modifier_extension.push(path.with_index(
1860                    "modifierExtension",
1861                    index,
1862                    |path| {
1863                        super::super::codec::Json::from_json(
1864                            super::super::codec::expect_object(value, path)?,
1865                            path,
1866                        )
1867                    },
1868                )?);
1869            }
1870        }
1871        let field_language = match (raw_language, raw_language_element) {
1872            (None, None) => None,
1873            (value, element) => Some(path.with("language", |path| {
1874                super::super::codec::Primitive::from_json_parts(value, element, path)
1875            })?),
1876        };
1877        let field_use = raw_use
1878            .map(|value| {
1879                path.with("use", |path| {
1880                    super::super::codec::Json::from_json(
1881                        super::super::codec::expect_object(
1882                            super::super::codec::expect_single(value, path)?,
1883                            path,
1884                        )?,
1885                        path,
1886                    )
1887                })
1888            })
1889            .transpose()?;
1890        let field_value = path.with("value", |path| {
1891            super::super::codec::Primitive::from_json_parts(raw_value, raw_value_element, path)
1892        })?;
1893        Ok(Self {
1894            id: field_id,
1895            extension: field_extension,
1896            modifier_extension: field_modifier_extension,
1897            language: field_language,
1898            r#use: field_use,
1899            value: field_value,
1900        })
1901    }
1902}
1903
1904impl serde::Serialize for CodeSystemConceptDesignation {
1905    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1906        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1907        if let Some(item) = &self.language {
1908            super::super::codec::element_entry(&mut map, "_language", item)?;
1909        }
1910        super::super::codec::element_entry(&mut map, "_value", &self.value)?;
1911        if !self.extension.is_empty() {
1912            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1913        }
1914        if let Some(v) = &self.id {
1915            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1916        }
1917        if let Some(item) = &self.language {
1918            super::super::codec::value_entry(&mut map, "language", item)?;
1919        }
1920        if !self.modifier_extension.is_empty() {
1921            serde::ser::SerializeMap::serialize_entry(
1922                &mut map,
1923                "modifierExtension",
1924                &self.modifier_extension,
1925            )?;
1926        }
1927        if let Some(item) = &self.r#use {
1928            serde::ser::SerializeMap::serialize_entry(&mut map, "use", item)?;
1929        }
1930        super::super::codec::value_entry(&mut map, "value", &self.value)?;
1931        serde::ser::SerializeMap::end(map)
1932    }
1933}
1934
1935impl<'de> serde::Deserialize<'de> for CodeSystemConceptDesignation {
1936    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1937        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1938        let mut path = super::super::codec::Path::root("CodeSystemConceptDesignation");
1939        let object =
1940            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1941        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1942    }
1943}
1944
1945/// Property value for the concept
1946///
1947/// A property value for this concept.
1948#[derive(Debug, Clone, PartialEq, Eq)]
1949pub struct CodeSystemConceptProperty {
1950    /// xml:id (or equivalent in JSON)
1951    ///
1952    /// unique id for the element within a resource (for internal references). This
1953    /// may be any string value that does not contain spaces.
1954    pub id: Option<std::string::String>,
1955    /// Additional Content defined by implementations
1956    ///
1957    /// May be used to represent additional information that is not part of the
1958    /// basic definition of the element. In order to make the use of extensions safe
1959    /// and manageable, there is a strict set of governance applied to the
1960    /// definition and use of extensions. Though any implementer is allowed to
1961    /// define an extension, there is a set of requirements that SHALL be met as
1962    /// part of the definition of the extension.
1963    pub extension: Vec<super::extension::Extension>,
1964    /// Extensions that cannot be ignored
1965    ///
1966    /// May be used to represent additional information that is not part of the
1967    /// basic definition of the element, and that modifies the understanding of the
1968    /// element that contains it. Usually modifier elements provide negation or
1969    /// qualification. In order to make the use of extensions safe and manageable,
1970    /// there is a strict set of governance applied to the definition and use of
1971    /// extensions. Though any implementer is allowed to define an extension, there
1972    /// is a set of requirements that SHALL be met as part of the definition of the
1973    /// extension. Applications processing a resource are required to check for
1974    /// modifier extensions.
1975    pub modifier_extension: Vec<super::extension::Extension>,
1976    /// Reference to CodeSystem.property.code
1977    ///
1978    /// A code that is a reference to CodeSystem.property.code.
1979    pub code: super::primitives::Code,
1980    /// Value of the property for this concept
1981    ///
1982    /// The value of this property.
1983    pub value: CodeSystemConceptPropertyValue,
1984}
1985
1986impl super::super::codec::Json for CodeSystemConceptProperty {
1987    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1988        let mut object = super::super::codec::Object::new();
1989        if let Some(v) = &self.id {
1990            object.insert(
1991                std::string::String::from("id"),
1992                super::super::codec::Value::String(v.clone()),
1993            );
1994        }
1995        if !self.extension.is_empty() {
1996            let mut items = Vec::with_capacity(self.extension.len());
1997            for item in &self.extension {
1998                items.push(super::super::codec::Value::Object(
1999                    super::super::codec::Json::to_json(item)?,
2000                ));
2001            }
2002            object.insert(
2003                std::string::String::from("extension"),
2004                super::super::codec::Value::Array(items),
2005            );
2006        }
2007        if !self.modifier_extension.is_empty() {
2008            let mut items = Vec::with_capacity(self.modifier_extension.len());
2009            for item in &self.modifier_extension {
2010                items.push(super::super::codec::Value::Object(
2011                    super::super::codec::Json::to_json(item)?,
2012                ));
2013            }
2014            object.insert(
2015                std::string::String::from("modifierExtension"),
2016                super::super::codec::Value::Array(items),
2017            );
2018        }
2019        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
2020            object.insert(std::string::String::from("code"), v);
2021        }
2022        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
2023            object.insert(std::string::String::from("_code"), e);
2024        }
2025        let (suffix, value, element) = self.value.to_json_parts()?;
2026        if let Some(value) = value {
2027            object.insert(format!("value{suffix}"), value);
2028        }
2029        if let Some(element) = element {
2030            object.insert(format!("_value{suffix}"), element);
2031        }
2032        Ok(object)
2033    }
2034
2035    fn from_json(
2036        object: &super::super::codec::Object,
2037        path: &mut super::super::codec::Path,
2038    ) -> Result<Self, super::super::codec::DecodeError> {
2039        let mut raw_id: Option<&super::super::codec::Value> = None;
2040        let mut raw_extension: Option<&super::super::codec::Value> = None;
2041        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2042        let mut raw_code: Option<&super::super::codec::Value> = None;
2043        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2044        let mut raw_value = super::super::codec::ChoiceSlot::default();
2045        for (key, value) in object {
2046            match key.as_str() {
2047                "id" => {
2048                    raw_id = Some(value);
2049                }
2050                "extension" => {
2051                    raw_extension = Some(value);
2052                }
2053                "modifierExtension" => {
2054                    raw_modifier_extension = Some(value);
2055                }
2056                "code" => {
2057                    raw_code = Some(value);
2058                }
2059                "_code" => {
2060                    raw_code_element = Some(value);
2061                }
2062                "valueCode" => {
2063                    raw_value.value("Code", value, path)?;
2064                }
2065                "_valueCode" => {
2066                    raw_value.element("Code", value, path)?;
2067                }
2068                "valueCoding" => {
2069                    raw_value.value("Coding", value, path)?;
2070                }
2071                "_valueCoding" => {
2072                    raw_value.element("Coding", value, path)?;
2073                }
2074                "valueString" => {
2075                    raw_value.value("String", value, path)?;
2076                }
2077                "_valueString" => {
2078                    raw_value.element("String", value, path)?;
2079                }
2080                "valueInteger" => {
2081                    raw_value.value("Integer", value, path)?;
2082                }
2083                "_valueInteger" => {
2084                    raw_value.element("Integer", value, path)?;
2085                }
2086                "valueBoolean" => {
2087                    raw_value.value("Boolean", value, path)?;
2088                }
2089                "_valueBoolean" => {
2090                    raw_value.element("Boolean", value, path)?;
2091                }
2092                "valueDateTime" => {
2093                    raw_value.value("DateTime", value, path)?;
2094                }
2095                "_valueDateTime" => {
2096                    raw_value.element("DateTime", value, path)?;
2097                }
2098                other => {
2099                    return path.with(other, |path| {
2100                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2101                    });
2102                }
2103            }
2104        }
2105        let field_id = raw_id
2106            .map(|value| {
2107                path.with("id", |path| {
2108                    let value = super::super::codec::expect_single(value, path)?;
2109                    super::super::codec::expect_string(value, path)
2110                })
2111            })
2112            .transpose()?;
2113        let mut field_extension = Vec::new();
2114        if let Some(raw) = raw_extension {
2115            for (index, value) in path
2116                .with("extension", |path| {
2117                    super::super::codec::expect_array(raw, path)
2118                })?
2119                .iter()
2120                .enumerate()
2121            {
2122                field_extension.push(path.with_index("extension", index, |path| {
2123                    super::super::codec::Json::from_json(
2124                        super::super::codec::expect_object(value, path)?,
2125                        path,
2126                    )
2127                })?);
2128            }
2129        }
2130        let mut field_modifier_extension = Vec::new();
2131        if let Some(raw) = raw_modifier_extension {
2132            for (index, value) in path
2133                .with("modifierExtension", |path| {
2134                    super::super::codec::expect_array(raw, path)
2135                })?
2136                .iter()
2137                .enumerate()
2138            {
2139                field_modifier_extension.push(path.with_index(
2140                    "modifierExtension",
2141                    index,
2142                    |path| {
2143                        super::super::codec::Json::from_json(
2144                            super::super::codec::expect_object(value, path)?,
2145                            path,
2146                        )
2147                    },
2148                )?);
2149            }
2150        }
2151        let field_code = path.with("code", |path| {
2152            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
2153        })?;
2154        let field_value = path.with("value", |path| {
2155            let suffix = raw_value
2156                .suffix
2157                .ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
2158            CodeSystemConceptPropertyValue::from_json_parts(
2159                suffix,
2160                raw_value.value,
2161                raw_value.element,
2162                path,
2163            )
2164        })?;
2165        Ok(Self {
2166            id: field_id,
2167            extension: field_extension,
2168            modifier_extension: field_modifier_extension,
2169            code: field_code,
2170            value: field_value,
2171        })
2172    }
2173}
2174
2175impl serde::Serialize for CodeSystemConceptProperty {
2176    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2177        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2178        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
2179        match &self.value {
2180            CodeSystemConceptPropertyValue::Boolean(inner) => {
2181                super::super::codec::element_entry(&mut map, "_valueBoolean", inner)?;
2182            }
2183            CodeSystemConceptPropertyValue::Code(inner) => {
2184                super::super::codec::element_entry(&mut map, "_valueCode", inner)?;
2185            }
2186            CodeSystemConceptPropertyValue::DateTime(inner) => {
2187                super::super::codec::element_entry(&mut map, "_valueDateTime", inner)?;
2188            }
2189            CodeSystemConceptPropertyValue::Integer(inner) => {
2190                super::super::codec::element_entry(&mut map, "_valueInteger", inner)?;
2191            }
2192            CodeSystemConceptPropertyValue::String(inner) => {
2193                super::super::codec::element_entry(&mut map, "_valueString", inner)?;
2194            }
2195            CodeSystemConceptPropertyValue::Coding(_) => {}
2196        }
2197        super::super::codec::value_entry(&mut map, "code", &self.code)?;
2198        if !self.extension.is_empty() {
2199            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2200        }
2201        if let Some(v) = &self.id {
2202            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2203        }
2204        if !self.modifier_extension.is_empty() {
2205            serde::ser::SerializeMap::serialize_entry(
2206                &mut map,
2207                "modifierExtension",
2208                &self.modifier_extension,
2209            )?;
2210        }
2211        match &self.value {
2212            CodeSystemConceptPropertyValue::Boolean(inner) => {
2213                super::super::codec::value_entry(&mut map, "valueBoolean", inner)?;
2214            }
2215            CodeSystemConceptPropertyValue::Code(inner) => {
2216                super::super::codec::value_entry(&mut map, "valueCode", inner)?;
2217            }
2218            CodeSystemConceptPropertyValue::Coding(inner) => {
2219                serde::ser::SerializeMap::serialize_entry(&mut map, "valueCoding", inner.as_ref())?;
2220            }
2221            CodeSystemConceptPropertyValue::DateTime(inner) => {
2222                super::super::codec::value_entry(&mut map, "valueDateTime", inner)?;
2223            }
2224            CodeSystemConceptPropertyValue::Integer(inner) => {
2225                super::super::codec::value_entry(&mut map, "valueInteger", inner)?;
2226            }
2227            CodeSystemConceptPropertyValue::String(inner) => {
2228                super::super::codec::value_entry(&mut map, "valueString", inner)?;
2229            }
2230        }
2231        serde::ser::SerializeMap::end(map)
2232    }
2233}
2234
2235impl<'de> serde::Deserialize<'de> for CodeSystemConceptProperty {
2236    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2237        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2238        let mut path = super::super::codec::Path::root("CodeSystemConceptProperty");
2239        let object =
2240            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2241        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2242    }
2243}
2244
2245/// The \`value\[x\]\` choice of \`CodeSystemConceptProperty\`.
2246///
2247/// The value of this property.
2248#[derive(Debug, Clone, PartialEq, Eq)]
2249pub enum CodeSystemConceptPropertyValue {
2250    /// The `code` form.
2251    Code(super::primitives::Code),
2252    /// The `Coding` form.
2253    Coding(Box<super::coding::Coding>),
2254    /// The `string` form.
2255    String(super::primitives::String),
2256    /// The `integer` form.
2257    Integer(super::primitives::Integer),
2258    /// The `boolean` form.
2259    Boolean(super::primitives::Boolean),
2260    /// The `dateTime` form.
2261    DateTime(super::primitives::DateTime),
2262}
2263
2264impl CodeSystemConceptPropertyValue {
2265    /// The key suffix, the value part, and the `_name` part of this form.
2266    ///
2267    /// # Errors
2268    ///
2269    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
2270    pub fn to_json_parts(
2271        &self,
2272    ) -> Result<
2273        (
2274            &'static str,
2275            Option<super::super::codec::Value>,
2276            Option<super::super::codec::Value>,
2277        ),
2278        super::super::codec::EncodeError,
2279    > {
2280        match self {
2281            Self::Code(inner) => Ok((
2282                "Code",
2283                super::super::codec::Primitive::value_json(inner)?,
2284                super::super::codec::Primitive::element_json(inner)?,
2285            )),
2286            Self::Coding(inner) => Ok((
2287                "Coding",
2288                Some(super::super::codec::Value::Object(
2289                    super::super::codec::Json::to_json(inner.as_ref())?,
2290                )),
2291                None,
2292            )),
2293            Self::String(inner) => Ok((
2294                "String",
2295                super::super::codec::Primitive::value_json(inner)?,
2296                super::super::codec::Primitive::element_json(inner)?,
2297            )),
2298            Self::Integer(inner) => Ok((
2299                "Integer",
2300                super::super::codec::Primitive::value_json(inner)?,
2301                super::super::codec::Primitive::element_json(inner)?,
2302            )),
2303            Self::Boolean(inner) => Ok((
2304                "Boolean",
2305                super::super::codec::Primitive::value_json(inner)?,
2306                super::super::codec::Primitive::element_json(inner)?,
2307            )),
2308            Self::DateTime(inner) => Ok((
2309                "DateTime",
2310                super::super::codec::Primitive::value_json(inner)?,
2311                super::super::codec::Primitive::element_json(inner)?,
2312            )),
2313        }
2314    }
2315
2316    /// Decodes the form named by `suffix` from its value and `_name` parts.
2317    ///
2318    /// # Errors
2319    ///
2320    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
2321    pub fn from_json_parts(
2322        suffix: &str,
2323        value: Option<&super::super::codec::Value>,
2324        element: Option<&super::super::codec::Value>,
2325        path: &mut super::super::codec::Path,
2326    ) -> Result<Self, super::super::codec::DecodeError> {
2327        match suffix {
2328            "Code" => Ok(Self::Code(super::super::codec::Primitive::from_json_parts(
2329                value, element, path,
2330            )?)),
2331            "Coding" => {
2332                if element.is_some() {
2333                    return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
2334                        expected: "no underscore form for a complex type",
2335                    }));
2336                }
2337                let value = value.ok_or_else(|| {
2338                    path.error(super::super::codec::DecodeErrorKind::MissingProperty)
2339                })?;
2340                let inner = super::super::codec::Json::from_json(
2341                    super::super::codec::expect_object(
2342                        super::super::codec::expect_single(value, path)?,
2343                        path,
2344                    )?,
2345                    path,
2346                )?;
2347                Ok(Self::Coding(Box::new(inner)))
2348            }
2349            "String" => Ok(Self::String(
2350                super::super::codec::Primitive::from_json_parts(value, element, path)?,
2351            )),
2352            "Integer" => Ok(Self::Integer(
2353                super::super::codec::Primitive::from_json_parts(value, element, path)?,
2354            )),
2355            "Boolean" => Ok(Self::Boolean(
2356                super::super::codec::Primitive::from_json_parts(value, element, path)?,
2357            )),
2358            "DateTime" => Ok(Self::DateTime(
2359                super::super::codec::Primitive::from_json_parts(value, element, path)?,
2360            )),
2361            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
2362        }
2363    }
2364}
2365
2366/// Filter that can be used in a value set
2367///
2368/// A filter that can be used in a value set compose statement when selecting
2369/// concepts using a filter.
2370#[derive(Debug, Clone, Default, PartialEq, Eq)]
2371pub struct CodeSystemFilter {
2372    /// xml:id (or equivalent in JSON)
2373    ///
2374    /// unique id for the element within a resource (for internal references). This
2375    /// may be any string value that does not contain spaces.
2376    pub id: Option<std::string::String>,
2377    /// Additional Content defined by implementations
2378    ///
2379    /// May be used to represent additional information that is not part of the
2380    /// basic definition of the element. In order to make the use of extensions safe
2381    /// and manageable, there is a strict set of governance applied to the
2382    /// definition and use of extensions. Though any implementer is allowed to
2383    /// define an extension, there is a set of requirements that SHALL be met as
2384    /// part of the definition of the extension.
2385    pub extension: Vec<super::extension::Extension>,
2386    /// Extensions that cannot be ignored
2387    ///
2388    /// May be used to represent additional information that is not part of the
2389    /// basic definition of the element, and that modifies the understanding of the
2390    /// element that contains it. Usually modifier elements provide negation or
2391    /// qualification. In order to make the use of extensions safe and manageable,
2392    /// there is a strict set of governance applied to the definition and use of
2393    /// extensions. Though any implementer is allowed to define an extension, there
2394    /// is a set of requirements that SHALL be met as part of the definition of the
2395    /// extension. Applications processing a resource are required to check for
2396    /// modifier extensions.
2397    pub modifier_extension: Vec<super::extension::Extension>,
2398    /// Code that identifies the filter
2399    ///
2400    /// The code that identifies this filter when it is used in the instance.
2401    pub code: super::primitives::Code,
2402    /// How or why the filter is used
2403    ///
2404    /// A description of how or why the filter is used.
2405    pub description: Option<super::primitives::String>,
2406    /// Operators that can be used with filter
2407    ///
2408    /// A list of operators that can be used with the filter.
2409    pub operator: Vec<super::primitives::Code>,
2410    /// What to use for the value
2411    ///
2412    /// A description of what the value for the filter should be.
2413    pub value: super::primitives::String,
2414}
2415
2416impl super::super::codec::Json for CodeSystemFilter {
2417    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2418        let mut object = super::super::codec::Object::new();
2419        if let Some(v) = &self.id {
2420            object.insert(
2421                std::string::String::from("id"),
2422                super::super::codec::Value::String(v.clone()),
2423            );
2424        }
2425        if !self.extension.is_empty() {
2426            let mut items = Vec::with_capacity(self.extension.len());
2427            for item in &self.extension {
2428                items.push(super::super::codec::Value::Object(
2429                    super::super::codec::Json::to_json(item)?,
2430                ));
2431            }
2432            object.insert(
2433                std::string::String::from("extension"),
2434                super::super::codec::Value::Array(items),
2435            );
2436        }
2437        if !self.modifier_extension.is_empty() {
2438            let mut items = Vec::with_capacity(self.modifier_extension.len());
2439            for item in &self.modifier_extension {
2440                items.push(super::super::codec::Value::Object(
2441                    super::super::codec::Json::to_json(item)?,
2442                ));
2443            }
2444            object.insert(
2445                std::string::String::from("modifierExtension"),
2446                super::super::codec::Value::Array(items),
2447            );
2448        }
2449        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
2450            object.insert(std::string::String::from("code"), v);
2451        }
2452        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
2453            object.insert(std::string::String::from("_code"), e);
2454        }
2455        if let Some(item) = &self.description {
2456            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2457                object.insert(std::string::String::from("description"), v);
2458            }
2459            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2460                object.insert(std::string::String::from("_description"), e);
2461            }
2462        }
2463        if !self.operator.is_empty() {
2464            let (values, elements) = super::super::codec::primitive_arrays(&self.operator)?;
2465            if let Some(values) = values {
2466                object.insert(std::string::String::from("operator"), values);
2467            }
2468            if let Some(elements) = elements {
2469                object.insert(std::string::String::from("_operator"), elements);
2470            }
2471        }
2472        if let Some(v) = super::super::codec::Primitive::value_json(&self.value)? {
2473            object.insert(std::string::String::from("value"), v);
2474        }
2475        if let Some(e) = super::super::codec::Primitive::element_json(&self.value)? {
2476            object.insert(std::string::String::from("_value"), e);
2477        }
2478        Ok(object)
2479    }
2480
2481    fn from_json(
2482        object: &super::super::codec::Object,
2483        path: &mut super::super::codec::Path,
2484    ) -> Result<Self, super::super::codec::DecodeError> {
2485        let mut raw_id: Option<&super::super::codec::Value> = None;
2486        let mut raw_extension: Option<&super::super::codec::Value> = None;
2487        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2488        let mut raw_code: Option<&super::super::codec::Value> = None;
2489        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2490        let mut raw_description: Option<&super::super::codec::Value> = None;
2491        let mut raw_description_element: Option<&super::super::codec::Value> = None;
2492        let mut raw_operator: Option<&super::super::codec::Value> = None;
2493        let mut raw_operator_element: Option<&super::super::codec::Value> = None;
2494        let mut raw_value: Option<&super::super::codec::Value> = None;
2495        let mut raw_value_element: Option<&super::super::codec::Value> = None;
2496        for (key, value) in object {
2497            match key.as_str() {
2498                "id" => {
2499                    raw_id = Some(value);
2500                }
2501                "extension" => {
2502                    raw_extension = Some(value);
2503                }
2504                "modifierExtension" => {
2505                    raw_modifier_extension = Some(value);
2506                }
2507                "code" => {
2508                    raw_code = Some(value);
2509                }
2510                "_code" => {
2511                    raw_code_element = Some(value);
2512                }
2513                "description" => {
2514                    raw_description = Some(value);
2515                }
2516                "_description" => {
2517                    raw_description_element = Some(value);
2518                }
2519                "operator" => {
2520                    raw_operator = Some(value);
2521                }
2522                "_operator" => {
2523                    raw_operator_element = Some(value);
2524                }
2525                "value" => {
2526                    raw_value = Some(value);
2527                }
2528                "_value" => {
2529                    raw_value_element = Some(value);
2530                }
2531                other => {
2532                    return path.with(other, |path| {
2533                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2534                    });
2535                }
2536            }
2537        }
2538        let field_id = raw_id
2539            .map(|value| {
2540                path.with("id", |path| {
2541                    let value = super::super::codec::expect_single(value, path)?;
2542                    super::super::codec::expect_string(value, path)
2543                })
2544            })
2545            .transpose()?;
2546        let mut field_extension = Vec::new();
2547        if let Some(raw) = raw_extension {
2548            for (index, value) in path
2549                .with("extension", |path| {
2550                    super::super::codec::expect_array(raw, path)
2551                })?
2552                .iter()
2553                .enumerate()
2554            {
2555                field_extension.push(path.with_index("extension", index, |path| {
2556                    super::super::codec::Json::from_json(
2557                        super::super::codec::expect_object(value, path)?,
2558                        path,
2559                    )
2560                })?);
2561            }
2562        }
2563        let mut field_modifier_extension = Vec::new();
2564        if let Some(raw) = raw_modifier_extension {
2565            for (index, value) in path
2566                .with("modifierExtension", |path| {
2567                    super::super::codec::expect_array(raw, path)
2568                })?
2569                .iter()
2570                .enumerate()
2571            {
2572                field_modifier_extension.push(path.with_index(
2573                    "modifierExtension",
2574                    index,
2575                    |path| {
2576                        super::super::codec::Json::from_json(
2577                            super::super::codec::expect_object(value, path)?,
2578                            path,
2579                        )
2580                    },
2581                )?);
2582            }
2583        }
2584        let field_code = path.with("code", |path| {
2585            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
2586        })?;
2587        let field_description = match (raw_description, raw_description_element) {
2588            (None, None) => None,
2589            (value, element) => Some(path.with("description", |path| {
2590                super::super::codec::Primitive::from_json_parts(value, element, path)
2591            })?),
2592        };
2593        let mut field_operator = Vec::new();
2594        for (index, (value, element)) in path
2595            .with("operator", |path| {
2596                super::super::codec::pair_arrays(raw_operator, raw_operator_element, path)
2597            })?
2598            .into_iter()
2599            .enumerate()
2600        {
2601            field_operator.push(path.with_index("operator", index, |path| {
2602                super::super::codec::Primitive::from_json_parts(value, element, path)
2603            })?);
2604        }
2605        if field_operator.is_empty() && !path.is_lenient() {
2606            return path.with("operator", |path| {
2607                Err(path.error(super::super::codec::DecodeErrorKind::MissingProperty))
2608            });
2609        }
2610        let field_value = path.with("value", |path| {
2611            super::super::codec::Primitive::from_json_parts(raw_value, raw_value_element, path)
2612        })?;
2613        Ok(Self {
2614            id: field_id,
2615            extension: field_extension,
2616            modifier_extension: field_modifier_extension,
2617            code: field_code,
2618            description: field_description,
2619            operator: field_operator,
2620            value: field_value,
2621        })
2622    }
2623}
2624
2625impl serde::Serialize for CodeSystemFilter {
2626    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2627        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2628        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
2629        if let Some(item) = &self.description {
2630            super::super::codec::element_entry(&mut map, "_description", item)?;
2631        }
2632        super::super::codec::element_list_entry(&mut map, "_operator", &self.operator)?;
2633        super::super::codec::element_entry(&mut map, "_value", &self.value)?;
2634        super::super::codec::value_entry(&mut map, "code", &self.code)?;
2635        if let Some(item) = &self.description {
2636            super::super::codec::value_entry(&mut map, "description", item)?;
2637        }
2638        if !self.extension.is_empty() {
2639            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2640        }
2641        if let Some(v) = &self.id {
2642            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2643        }
2644        if !self.modifier_extension.is_empty() {
2645            serde::ser::SerializeMap::serialize_entry(
2646                &mut map,
2647                "modifierExtension",
2648                &self.modifier_extension,
2649            )?;
2650        }
2651        super::super::codec::value_list_entry(&mut map, "operator", &self.operator)?;
2652        super::super::codec::value_entry(&mut map, "value", &self.value)?;
2653        serde::ser::SerializeMap::end(map)
2654    }
2655}
2656
2657impl<'de> serde::Deserialize<'de> for CodeSystemFilter {
2658    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2659        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2660        let mut path = super::super::codec::Path::root("CodeSystemFilter");
2661        let object =
2662            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2663        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2664    }
2665}
2666
2667/// Additional information supplied about each concept
2668///
2669/// A property defines an additional slot through which additional information
2670/// can be provided about a concept.
2671#[derive(Debug, Clone, Default, PartialEq, Eq)]
2672pub struct CodeSystemProperty {
2673    /// xml:id (or equivalent in JSON)
2674    ///
2675    /// unique id for the element within a resource (for internal references). This
2676    /// may be any string value that does not contain spaces.
2677    pub id: Option<std::string::String>,
2678    /// Additional Content defined by implementations
2679    ///
2680    /// May be used to represent additional information that is not part of the
2681    /// basic definition of the element. In order to make the use of extensions safe
2682    /// and manageable, there is a strict set of governance applied to the
2683    /// definition and use of extensions. Though any implementer is allowed to
2684    /// define an extension, there is a set of requirements that SHALL be met as
2685    /// part of the definition of the extension.
2686    pub extension: Vec<super::extension::Extension>,
2687    /// Extensions that cannot be ignored
2688    ///
2689    /// May be used to represent additional information that is not part of the
2690    /// basic definition of the element, and that modifies the understanding of the
2691    /// element that contains it. Usually modifier elements provide negation or
2692    /// qualification. In order to make the use of extensions safe and manageable,
2693    /// there is a strict set of governance applied to the definition and use of
2694    /// extensions. Though any implementer is allowed to define an extension, there
2695    /// is a set of requirements that SHALL be met as part of the definition of the
2696    /// extension. Applications processing a resource are required to check for
2697    /// modifier extensions.
2698    pub modifier_extension: Vec<super::extension::Extension>,
2699    /// Identifies the property on the concepts, and when referred to in operations
2700    ///
2701    /// A code that is used to identify the property. The code is used internally
2702    /// (in CodeSystem.concept.property.code) and also externally, such as in
2703    /// property filters.
2704    pub code: super::primitives::Code,
2705    /// Formal identifier for the property
2706    ///
2707    /// Reference to the formal meaning of the property. One possible source of
2708    /// meaning is the \[Concept Properties\](codesystem-concept-properties.html)
2709    /// code system.
2710    pub uri: Option<super::primitives::Uri>,
2711    /// Why the property is defined, and/or what it conveys
2712    ///
2713    /// A description of the property- why it is defined, and how its value might be
2714    /// used.
2715    pub description: Option<super::primitives::String>,
2716    /// code | Coding | string | integer | boolean | dateTime
2717    ///
2718    /// The type of the property value. Properties of type "code" contain a code
2719    /// defined by the code system (e.g. a reference to anotherr defined concept).
2720    pub r#type: super::primitives::Code,
2721}
2722
2723impl super::super::codec::Json for CodeSystemProperty {
2724    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2725        let mut object = super::super::codec::Object::new();
2726        if let Some(v) = &self.id {
2727            object.insert(
2728                std::string::String::from("id"),
2729                super::super::codec::Value::String(v.clone()),
2730            );
2731        }
2732        if !self.extension.is_empty() {
2733            let mut items = Vec::with_capacity(self.extension.len());
2734            for item in &self.extension {
2735                items.push(super::super::codec::Value::Object(
2736                    super::super::codec::Json::to_json(item)?,
2737                ));
2738            }
2739            object.insert(
2740                std::string::String::from("extension"),
2741                super::super::codec::Value::Array(items),
2742            );
2743        }
2744        if !self.modifier_extension.is_empty() {
2745            let mut items = Vec::with_capacity(self.modifier_extension.len());
2746            for item in &self.modifier_extension {
2747                items.push(super::super::codec::Value::Object(
2748                    super::super::codec::Json::to_json(item)?,
2749                ));
2750            }
2751            object.insert(
2752                std::string::String::from("modifierExtension"),
2753                super::super::codec::Value::Array(items),
2754            );
2755        }
2756        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
2757            object.insert(std::string::String::from("code"), v);
2758        }
2759        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
2760            object.insert(std::string::String::from("_code"), e);
2761        }
2762        if let Some(item) = &self.uri {
2763            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2764                object.insert(std::string::String::from("uri"), v);
2765            }
2766            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2767                object.insert(std::string::String::from("_uri"), e);
2768            }
2769        }
2770        if let Some(item) = &self.description {
2771            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2772                object.insert(std::string::String::from("description"), v);
2773            }
2774            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2775                object.insert(std::string::String::from("_description"), e);
2776            }
2777        }
2778        if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
2779            object.insert(std::string::String::from("type"), v);
2780        }
2781        if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
2782            object.insert(std::string::String::from("_type"), e);
2783        }
2784        Ok(object)
2785    }
2786
2787    fn from_json(
2788        object: &super::super::codec::Object,
2789        path: &mut super::super::codec::Path,
2790    ) -> Result<Self, super::super::codec::DecodeError> {
2791        let mut raw_id: Option<&super::super::codec::Value> = None;
2792        let mut raw_extension: Option<&super::super::codec::Value> = None;
2793        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2794        let mut raw_code: Option<&super::super::codec::Value> = None;
2795        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2796        let mut raw_uri: Option<&super::super::codec::Value> = None;
2797        let mut raw_uri_element: Option<&super::super::codec::Value> = None;
2798        let mut raw_description: Option<&super::super::codec::Value> = None;
2799        let mut raw_description_element: Option<&super::super::codec::Value> = None;
2800        let mut raw_type: Option<&super::super::codec::Value> = None;
2801        let mut raw_type_element: Option<&super::super::codec::Value> = None;
2802        for (key, value) in object {
2803            match key.as_str() {
2804                "id" => {
2805                    raw_id = Some(value);
2806                }
2807                "extension" => {
2808                    raw_extension = Some(value);
2809                }
2810                "modifierExtension" => {
2811                    raw_modifier_extension = Some(value);
2812                }
2813                "code" => {
2814                    raw_code = Some(value);
2815                }
2816                "_code" => {
2817                    raw_code_element = Some(value);
2818                }
2819                "uri" => {
2820                    raw_uri = Some(value);
2821                }
2822                "_uri" => {
2823                    raw_uri_element = Some(value);
2824                }
2825                "description" => {
2826                    raw_description = Some(value);
2827                }
2828                "_description" => {
2829                    raw_description_element = Some(value);
2830                }
2831                "type" => {
2832                    raw_type = Some(value);
2833                }
2834                "_type" => {
2835                    raw_type_element = Some(value);
2836                }
2837                other => {
2838                    return path.with(other, |path| {
2839                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2840                    });
2841                }
2842            }
2843        }
2844        let field_id = raw_id
2845            .map(|value| {
2846                path.with("id", |path| {
2847                    let value = super::super::codec::expect_single(value, path)?;
2848                    super::super::codec::expect_string(value, path)
2849                })
2850            })
2851            .transpose()?;
2852        let mut field_extension = Vec::new();
2853        if let Some(raw) = raw_extension {
2854            for (index, value) in path
2855                .with("extension", |path| {
2856                    super::super::codec::expect_array(raw, path)
2857                })?
2858                .iter()
2859                .enumerate()
2860            {
2861                field_extension.push(path.with_index("extension", index, |path| {
2862                    super::super::codec::Json::from_json(
2863                        super::super::codec::expect_object(value, path)?,
2864                        path,
2865                    )
2866                })?);
2867            }
2868        }
2869        let mut field_modifier_extension = Vec::new();
2870        if let Some(raw) = raw_modifier_extension {
2871            for (index, value) in path
2872                .with("modifierExtension", |path| {
2873                    super::super::codec::expect_array(raw, path)
2874                })?
2875                .iter()
2876                .enumerate()
2877            {
2878                field_modifier_extension.push(path.with_index(
2879                    "modifierExtension",
2880                    index,
2881                    |path| {
2882                        super::super::codec::Json::from_json(
2883                            super::super::codec::expect_object(value, path)?,
2884                            path,
2885                        )
2886                    },
2887                )?);
2888            }
2889        }
2890        let field_code = path.with("code", |path| {
2891            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
2892        })?;
2893        let field_uri = match (raw_uri, raw_uri_element) {
2894            (None, None) => None,
2895            (value, element) => Some(path.with("uri", |path| {
2896                super::super::codec::Primitive::from_json_parts(value, element, path)
2897            })?),
2898        };
2899        let field_description = match (raw_description, raw_description_element) {
2900            (None, None) => None,
2901            (value, element) => Some(path.with("description", |path| {
2902                super::super::codec::Primitive::from_json_parts(value, element, path)
2903            })?),
2904        };
2905        let field_type = path.with("type", |path| {
2906            super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
2907        })?;
2908        Ok(Self {
2909            id: field_id,
2910            extension: field_extension,
2911            modifier_extension: field_modifier_extension,
2912            code: field_code,
2913            uri: field_uri,
2914            description: field_description,
2915            r#type: field_type,
2916        })
2917    }
2918}
2919
2920impl serde::Serialize for CodeSystemProperty {
2921    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2922        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2923        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
2924        if let Some(item) = &self.description {
2925            super::super::codec::element_entry(&mut map, "_description", item)?;
2926        }
2927        super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
2928        if let Some(item) = &self.uri {
2929            super::super::codec::element_entry(&mut map, "_uri", item)?;
2930        }
2931        super::super::codec::value_entry(&mut map, "code", &self.code)?;
2932        if let Some(item) = &self.description {
2933            super::super::codec::value_entry(&mut map, "description", item)?;
2934        }
2935        if !self.extension.is_empty() {
2936            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2937        }
2938        if let Some(v) = &self.id {
2939            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2940        }
2941        if !self.modifier_extension.is_empty() {
2942            serde::ser::SerializeMap::serialize_entry(
2943                &mut map,
2944                "modifierExtension",
2945                &self.modifier_extension,
2946            )?;
2947        }
2948        super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
2949        if let Some(item) = &self.uri {
2950            super::super::codec::value_entry(&mut map, "uri", item)?;
2951        }
2952        serde::ser::SerializeMap::end(map)
2953    }
2954}
2955
2956impl<'de> serde::Deserialize<'de> for CodeSystemProperty {
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("CodeSystemProperty");
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}