Skip to main content

fhir_types/stu3/
concept_map.rs

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