Skip to main content

fhir_types/r5/
code_system.rs

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