Skip to main content

fhir_types/r4b/
code_system.rs

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