Skip to main content

fhir_types/r4b/
concept_map.rs

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