Skip to main content

fhir_types/r5/
concept_map.rs

1// @generated by fhir-codegen from hl7.fhir.r5.core 5.0.0. DO NOT EDIT.
2// Change the emitter (tools/fhir-codegen) and regenerate.
3// SPDX-FileCopyrightText: Cadasto B.V.
4// SPDX-License-Identifier: Apache-2.0
5//! A map from one set of concepts to one or more other concepts
6
7/// A map from one set of concepts to one or more other concepts
8///
9/// A statement of relationships from one set of concepts to one or more other
10/// concepts - either concepts in code systems, or data element/data element
11/// concepts, or classes in class models.
12#[derive(Debug, Clone, Default, PartialEq, Eq)]
13pub struct ConceptMap {
14    /// Logical id of this artifact
15    ///
16    /// The logical id of the resource, as used in the URL for the resource. Once
17    /// assigned, this value never changes.
18    pub id: Option<std::string::String>,
19    /// Metadata about the resource
20    ///
21    /// The metadata about the resource. This is content that is maintained by the
22    /// infrastructure. Changes to the content might not always be associated with
23    /// version changes to the resource.
24    pub meta: Option<super::meta::Meta>,
25    /// A set of rules under which this content was created
26    ///
27    /// A reference to a set of rules that were followed when the resource was
28    /// constructed, and which must be understood when processing the content.
29    /// Often, this is a reference to an implementation guide that defines the
30    /// special rules along with other profiles etc.
31    pub implicit_rules: Option<super::primitives::Uri>,
32    /// Language of the resource content
33    ///
34    /// The base language in which the resource is written.
35    pub language: Option<super::primitives::Code>,
36    /// Text summary of the resource, for human interpretation
37    ///
38    /// A human-readable narrative that contains a summary of the resource and can
39    /// be used to represent the content of the resource to a human. The narrative
40    /// need not encode all the structured data, but is required to contain
41    /// sufficient detail to make it "clinically safe" for a human to just read the
42    /// narrative. Resource definitions may define what content should be
43    /// represented in the narrative to ensure clinical safety.
44    pub text: Option<super::narrative::Narrative>,
45    /// Contained, inline Resources
46    ///
47    /// These resources do not have an independent existence apart from the resource
48    /// that contains them - they cannot be identified independently, nor can they
49    /// have their own independent transaction scope. This is allowed to be a
50    /// Parameters resource if and only if it is referenced by a resource that
51    /// provides context/meaning.
52    pub contained: Vec<super::resource::Resource>,
53    /// Additional content defined by implementations
54    ///
55    /// May be used to represent additional information that is not part of the
56    /// basic definition of the resource. To make the use of extensions safe and
57    /// managable, there is a strict set of governance applied to the definition and
58    /// use of extensions. Though any implementer can define an extension, there is
59    /// a set of requirements that SHALL be met as part of the definition of the
60    /// extension.
61    pub extension: Vec<super::extension::Extension>,
62    /// Extensions that cannot be ignored
63    ///
64    /// May be used to represent additional information that is not part of the
65    /// basic definition of the resource and that modifies the understanding of the
66    /// element that contains it and/or the understanding of the containing
67    /// element's descendants. Usually modifier elements provide negation or
68    /// qualification. To make the use of extensions safe and managable, there is a
69    /// strict set of governance applied to the definition and use of extensions.
70    /// Though any implementer is allowed to define an extension, there is a set of
71    /// requirements that SHALL be met as part of the definition of the extension.
72    /// Applications processing a resource are required to check for modifier
73    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
74    /// on Resource or DomainResource (including cannot change the meaning of
75    /// modifierExtension itself).
76    pub modifier_extension: Vec<super::extension::Extension>,
77    /// Canonical identifier for this concept map, represented as a URI (globally
78    /// unique)
79    ///
80    /// An absolute URI that is used to identify this concept map when it is
81    /// referenced in a specification, model, design or an instance; also called its
82    /// canonical identifier. This SHOULD be globally unique and SHOULD be a literal
83    /// address at which an authoritative instance of this concept map is (or will
84    /// be) published. This URL can be the target of a canonical reference. It SHALL
85    /// remain the same when the concept map is stored on different servers.
86    pub url: Option<super::primitives::Uri>,
87    /// Additional identifier for the concept map
88    ///
89    /// A formal identifier that is used to identify this concept map when it is
90    /// represented in other formats, or referenced in a specification, model,
91    /// design or an instance.
92    pub identifier: Vec<super::identifier::Identifier>,
93    /// Business version of the concept map
94    ///
95    /// The identifier that is used to identify this version of the concept map when
96    /// it is referenced in a specification, model, design or instance. This is an
97    /// arbitrary value managed by the concept map author and is not expected to be
98    /// globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a
99    /// managed version is not available. There is also no expectation that versions
100    /// can be placed in a lexicographical sequence.
101    pub version: Option<super::primitives::String>,
102    /// How to compare versions
103    ///
104    /// Indicates the mechanism used to compare versions to determine which
105    /// ConceptMap is more current.
106    pub version_algorithm: Option<ConceptMapVersionAlgorithm>,
107    /// Name for this concept map (computer friendly)
108    ///
109    /// A natural language name identifying the concept map. This name should be
110    /// usable as an identifier for the module by machine processing applications
111    /// such as code generation.
112    pub name: Option<super::primitives::String>,
113    /// Name for this concept map (human friendly)
114    ///
115    /// A short, descriptive, user-friendly title for the concept map.
116    pub title: Option<super::primitives::String>,
117    /// draft | active | retired | unknown
118    ///
119    /// The status of this concept map. Enables tracking the life-cycle of the
120    /// content.
121    pub status: super::primitives::Code,
122    /// For testing purposes, not real usage
123    ///
124    /// A Boolean value to indicate that this concept map is authored for testing
125    /// purposes (or education/evaluation/marketing) and is not intended to be used
126    /// for genuine usage.
127    pub experimental: Option<super::primitives::Boolean>,
128    /// Date last changed
129    ///
130    /// The date (and optionally time) when the concept map was last significantly
131    /// changed. The date must change when the business version changes and it must
132    /// change if the status code changes. In addition, it should change when the
133    /// substantive content of the concept map changes.
134    pub date: Option<super::primitives::DateTime>,
135    /// Name of the publisher/steward (organization or individual)
136    ///
137    /// The name of the organization or individual responsible for the release and
138    /// ongoing maintenance of the concept map.
139    pub publisher: Option<super::primitives::String>,
140    /// Contact details for the publisher
141    ///
142    /// Contact details to assist a user in finding and communicating with the
143    /// publisher.
144    pub contact: Vec<super::contact_detail::ContactDetail>,
145    /// Natural language description of the concept map
146    ///
147    /// A free text natural language description of the concept map from a
148    /// consumer's perspective.
149    pub description: Option<super::primitives::Markdown>,
150    /// The context that the content is intended to support
151    ///
152    /// The content was developed with a focus and intent of supporting the contexts
153    /// that are listed. These contexts may be general categories (gender, age, ...)
154    /// or may be references to specific programs (insurance plans, studies, ...)
155    /// and may be used to assist with indexing and searching for appropriate
156    /// concept map instances.
157    pub use_context: Vec<super::usage_context::UsageContext>,
158    /// Intended jurisdiction for concept map (if applicable)
159    ///
160    /// A legal or geographic region in which the concept map is intended to be
161    /// used.
162    pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
163    /// Why this concept map is defined
164    ///
165    /// Explanation of why this concept map is needed and why it has been designed
166    /// as it has.
167    pub purpose: Option<super::primitives::Markdown>,
168    /// Use and/or publishing restrictions
169    ///
170    /// A copyright statement relating to the concept map and/or its contents.
171    /// Copyright statements are generally legal restrictions on the use and
172    /// publishing of the concept map.
173    pub copyright: Option<super::primitives::Markdown>,
174    /// Copyright holder and year(s)
175    ///
176    /// A short string (\<50 characters), suitable for inclusion in a page footer
177    /// that identifies the copyright holder, effective period, and optionally
178    /// whether rights are resctricted. (e.g. 'All rights reserved', 'Some rights
179    /// reserved').
180    pub copyright_label: Option<super::primitives::String>,
181    /// When the ConceptMap was approved by publisher
182    ///
183    /// The date on which the resource content was approved by the publisher.
184    /// Approval happens once when the content is officially approved for usage.
185    pub approval_date: Option<super::primitives::Date>,
186    /// When the ConceptMap was last reviewed by the publisher
187    ///
188    /// The date on which the resource content was last reviewed. Review happens
189    /// periodically after approval but does not change the original approval date.
190    pub last_review_date: Option<super::primitives::Date>,
191    /// When the ConceptMap is expected to be used
192    ///
193    /// The period during which the ConceptMap content was or is planned to be in
194    /// active use.
195    pub effective_period: Option<super::period::Period>,
196    /// E.g. Education, Treatment, Assessment, etc
197    ///
198    /// Descriptions related to the content of the ConceptMap. Topics provide a
199    /// high-level categorization as well as keywords for the ConceptMap that can be
200    /// useful for filtering and searching.
201    pub topic: Vec<super::codeable_concept::CodeableConcept>,
202    /// Who authored the ConceptMap
203    ///
204    /// An individiual or organization primarily involved in the creation and
205    /// maintenance of the ConceptMap.
206    pub author: Vec<super::contact_detail::ContactDetail>,
207    /// Who edited the ConceptMap
208    ///
209    /// An individual or organization primarily responsible for internal coherence
210    /// of the ConceptMap.
211    pub editor: Vec<super::contact_detail::ContactDetail>,
212    /// Who reviewed the ConceptMap
213    ///
214    /// An individual or organization asserted by the publisher to be primarily
215    /// responsible for review of some aspect of the ConceptMap.
216    pub reviewer: Vec<super::contact_detail::ContactDetail>,
217    /// Who endorsed the ConceptMap
218    ///
219    /// An individual or organization asserted by the publisher to be responsible
220    /// for officially endorsing the ConceptMap for use in some setting.
221    pub endorser: Vec<super::contact_detail::ContactDetail>,
222    /// Additional documentation, citations, etc
223    ///
224    /// Related artifacts such as additional documentation, justification,
225    /// dependencies, bibliographic references, and predecessor and successor
226    /// artifacts.
227    pub related_artifact: Vec<super::related_artifact::RelatedArtifact>,
228    /// Additional properties of the mapping
229    ///
230    /// A property defines a slot through which additional information can be
231    /// provided about a map from source -\> target.
232    pub property: Vec<ConceptMapProperty>,
233    /// Definition of an additional attribute to act as a data source or target
234    ///
235    /// An additionalAttribute defines an additional data element found in the
236    /// source or target data model where the data will come from or be mapped to.
237    /// Some mappings are based on data in addition to the source data element,
238    /// where codes in multiple fields are combined to a single field (or vice
239    /// versa).
240    pub additional_attribute: Vec<ConceptMapAdditionalAttribute>,
241    /// The source value set that contains the concepts that are being mapped
242    ///
243    /// Identifier for the source value set that contains the concepts that are
244    /// being mapped and provides context for the mappings. Limits the scope of the
245    /// map to source codes (ConceptMap.group.element code or valueSet) that are
246    /// members of this value set.
247    pub source_scope: Option<ConceptMapSourceScope>,
248    /// The target value set which provides context for the mappings
249    ///
250    /// Identifier for the target value set that provides important context about
251    /// how the mapping choices are made. Limits the scope of the map to target
252    /// codes (ConceptMap.group.element.target code or valueSet) that are members of
253    /// this value set.
254    pub target_scope: Option<ConceptMapTargetScope>,
255    /// Same source and target systems
256    ///
257    /// A group of mappings that all have the same source and target system.
258    pub group: Vec<ConceptMapGroup>,
259}
260
261impl super::super::codec::Json for ConceptMap {
262    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
263        let mut object = super::super::codec::Object::new();
264        object.insert(
265            std::string::String::from("resourceType"),
266            super::super::codec::Value::String(std::string::String::from("ConceptMap")),
267        );
268        if let Some(v) = &self.id {
269            object.insert(
270                std::string::String::from("id"),
271                super::super::codec::Value::String(v.clone()),
272            );
273        }
274        if let Some(item) = &self.meta {
275            object.insert(
276                std::string::String::from("meta"),
277                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
278            );
279        }
280        if let Some(item) = &self.implicit_rules {
281            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
282                object.insert(std::string::String::from("implicitRules"), v);
283            }
284            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
285                object.insert(std::string::String::from("_implicitRules"), e);
286            }
287        }
288        if let Some(item) = &self.language {
289            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
290                object.insert(std::string::String::from("language"), v);
291            }
292            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
293                object.insert(std::string::String::from("_language"), e);
294            }
295        }
296        if let Some(item) = &self.text {
297            object.insert(
298                std::string::String::from("text"),
299                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
300            );
301        }
302        if !self.contained.is_empty() {
303            let mut items = Vec::with_capacity(self.contained.len());
304            for item in &self.contained {
305                items.push(super::super::codec::Value::Object(
306                    super::super::codec::Json::to_json(item)?,
307                ));
308            }
309            object.insert(
310                std::string::String::from("contained"),
311                super::super::codec::Value::Array(items),
312            );
313        }
314        if !self.extension.is_empty() {
315            let mut items = Vec::with_capacity(self.extension.len());
316            for item in &self.extension {
317                items.push(super::super::codec::Value::Object(
318                    super::super::codec::Json::to_json(item)?,
319                ));
320            }
321            object.insert(
322                std::string::String::from("extension"),
323                super::super::codec::Value::Array(items),
324            );
325        }
326        if !self.modifier_extension.is_empty() {
327            let mut items = Vec::with_capacity(self.modifier_extension.len());
328            for item in &self.modifier_extension {
329                items.push(super::super::codec::Value::Object(
330                    super::super::codec::Json::to_json(item)?,
331                ));
332            }
333            object.insert(
334                std::string::String::from("modifierExtension"),
335                super::super::codec::Value::Array(items),
336            );
337        }
338        if let Some(item) = &self.url {
339            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
340                object.insert(std::string::String::from("url"), v);
341            }
342            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
343                object.insert(std::string::String::from("_url"), e);
344            }
345        }
346        if !self.identifier.is_empty() {
347            let mut items = Vec::with_capacity(self.identifier.len());
348            for item in &self.identifier {
349                items.push(super::super::codec::Value::Object(
350                    super::super::codec::Json::to_json(item)?,
351                ));
352            }
353            object.insert(
354                std::string::String::from("identifier"),
355                super::super::codec::Value::Array(items),
356            );
357        }
358        if let Some(item) = &self.version {
359            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
360                object.insert(std::string::String::from("version"), v);
361            }
362            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
363                object.insert(std::string::String::from("_version"), e);
364            }
365        }
366        if let Some(item) = &self.version_algorithm {
367            let (suffix, value, element) = item.to_json_parts()?;
368            if let Some(value) = value {
369                object.insert(format!("versionAlgorithm{suffix}"), value);
370            }
371            if let Some(element) = element {
372                object.insert(format!("_versionAlgorithm{suffix}"), element);
373            }
374        }
375        if let Some(item) = &self.name {
376            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
377                object.insert(std::string::String::from("name"), v);
378            }
379            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
380                object.insert(std::string::String::from("_name"), e);
381            }
382        }
383        if let Some(item) = &self.title {
384            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
385                object.insert(std::string::String::from("title"), v);
386            }
387            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
388                object.insert(std::string::String::from("_title"), e);
389            }
390        }
391        if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
392            object.insert(std::string::String::from("status"), v);
393        }
394        if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
395            object.insert(std::string::String::from("_status"), e);
396        }
397        if let Some(item) = &self.experimental {
398            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
399                object.insert(std::string::String::from("experimental"), v);
400            }
401            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
402                object.insert(std::string::String::from("_experimental"), e);
403            }
404        }
405        if let Some(item) = &self.date {
406            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
407                object.insert(std::string::String::from("date"), v);
408            }
409            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
410                object.insert(std::string::String::from("_date"), e);
411            }
412        }
413        if let Some(item) = &self.publisher {
414            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
415                object.insert(std::string::String::from("publisher"), v);
416            }
417            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
418                object.insert(std::string::String::from("_publisher"), e);
419            }
420        }
421        if !self.contact.is_empty() {
422            let mut items = Vec::with_capacity(self.contact.len());
423            for item in &self.contact {
424                items.push(super::super::codec::Value::Object(
425                    super::super::codec::Json::to_json(item)?,
426                ));
427            }
428            object.insert(
429                std::string::String::from("contact"),
430                super::super::codec::Value::Array(items),
431            );
432        }
433        if let Some(item) = &self.description {
434            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
435                object.insert(std::string::String::from("description"), v);
436            }
437            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
438                object.insert(std::string::String::from("_description"), e);
439            }
440        }
441        if !self.use_context.is_empty() {
442            let mut items = Vec::with_capacity(self.use_context.len());
443            for item in &self.use_context {
444                items.push(super::super::codec::Value::Object(
445                    super::super::codec::Json::to_json(item)?,
446                ));
447            }
448            object.insert(
449                std::string::String::from("useContext"),
450                super::super::codec::Value::Array(items),
451            );
452        }
453        if !self.jurisdiction.is_empty() {
454            let mut items = Vec::with_capacity(self.jurisdiction.len());
455            for item in &self.jurisdiction {
456                items.push(super::super::codec::Value::Object(
457                    super::super::codec::Json::to_json(item)?,
458                ));
459            }
460            object.insert(
461                std::string::String::from("jurisdiction"),
462                super::super::codec::Value::Array(items),
463            );
464        }
465        if let Some(item) = &self.purpose {
466            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
467                object.insert(std::string::String::from("purpose"), v);
468            }
469            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
470                object.insert(std::string::String::from("_purpose"), e);
471            }
472        }
473        if let Some(item) = &self.copyright {
474            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
475                object.insert(std::string::String::from("copyright"), v);
476            }
477            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
478                object.insert(std::string::String::from("_copyright"), e);
479            }
480        }
481        if let Some(item) = &self.copyright_label {
482            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
483                object.insert(std::string::String::from("copyrightLabel"), v);
484            }
485            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
486                object.insert(std::string::String::from("_copyrightLabel"), e);
487            }
488        }
489        if let Some(item) = &self.approval_date {
490            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
491                object.insert(std::string::String::from("approvalDate"), v);
492            }
493            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
494                object.insert(std::string::String::from("_approvalDate"), e);
495            }
496        }
497        if let Some(item) = &self.last_review_date {
498            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
499                object.insert(std::string::String::from("lastReviewDate"), v);
500            }
501            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
502                object.insert(std::string::String::from("_lastReviewDate"), e);
503            }
504        }
505        if let Some(item) = &self.effective_period {
506            object.insert(
507                std::string::String::from("effectivePeriod"),
508                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
509            );
510        }
511        if !self.topic.is_empty() {
512            let mut items = Vec::with_capacity(self.topic.len());
513            for item in &self.topic {
514                items.push(super::super::codec::Value::Object(
515                    super::super::codec::Json::to_json(item)?,
516                ));
517            }
518            object.insert(
519                std::string::String::from("topic"),
520                super::super::codec::Value::Array(items),
521            );
522        }
523        if !self.author.is_empty() {
524            let mut items = Vec::with_capacity(self.author.len());
525            for item in &self.author {
526                items.push(super::super::codec::Value::Object(
527                    super::super::codec::Json::to_json(item)?,
528                ));
529            }
530            object.insert(
531                std::string::String::from("author"),
532                super::super::codec::Value::Array(items),
533            );
534        }
535        if !self.editor.is_empty() {
536            let mut items = Vec::with_capacity(self.editor.len());
537            for item in &self.editor {
538                items.push(super::super::codec::Value::Object(
539                    super::super::codec::Json::to_json(item)?,
540                ));
541            }
542            object.insert(
543                std::string::String::from("editor"),
544                super::super::codec::Value::Array(items),
545            );
546        }
547        if !self.reviewer.is_empty() {
548            let mut items = Vec::with_capacity(self.reviewer.len());
549            for item in &self.reviewer {
550                items.push(super::super::codec::Value::Object(
551                    super::super::codec::Json::to_json(item)?,
552                ));
553            }
554            object.insert(
555                std::string::String::from("reviewer"),
556                super::super::codec::Value::Array(items),
557            );
558        }
559        if !self.endorser.is_empty() {
560            let mut items = Vec::with_capacity(self.endorser.len());
561            for item in &self.endorser {
562                items.push(super::super::codec::Value::Object(
563                    super::super::codec::Json::to_json(item)?,
564                ));
565            }
566            object.insert(
567                std::string::String::from("endorser"),
568                super::super::codec::Value::Array(items),
569            );
570        }
571        if !self.related_artifact.is_empty() {
572            let mut items = Vec::with_capacity(self.related_artifact.len());
573            for item in &self.related_artifact {
574                items.push(super::super::codec::Value::Object(
575                    super::super::codec::Json::to_json(item)?,
576                ));
577            }
578            object.insert(
579                std::string::String::from("relatedArtifact"),
580                super::super::codec::Value::Array(items),
581            );
582        }
583        if !self.property.is_empty() {
584            let mut items = Vec::with_capacity(self.property.len());
585            for item in &self.property {
586                items.push(super::super::codec::Value::Object(
587                    super::super::codec::Json::to_json(item)?,
588                ));
589            }
590            object.insert(
591                std::string::String::from("property"),
592                super::super::codec::Value::Array(items),
593            );
594        }
595        if !self.additional_attribute.is_empty() {
596            let mut items = Vec::with_capacity(self.additional_attribute.len());
597            for item in &self.additional_attribute {
598                items.push(super::super::codec::Value::Object(
599                    super::super::codec::Json::to_json(item)?,
600                ));
601            }
602            object.insert(
603                std::string::String::from("additionalAttribute"),
604                super::super::codec::Value::Array(items),
605            );
606        }
607        if let Some(item) = &self.source_scope {
608            let (suffix, value, element) = item.to_json_parts()?;
609            if let Some(value) = value {
610                object.insert(format!("sourceScope{suffix}"), value);
611            }
612            if let Some(element) = element {
613                object.insert(format!("_sourceScope{suffix}"), element);
614            }
615        }
616        if let Some(item) = &self.target_scope {
617            let (suffix, value, element) = item.to_json_parts()?;
618            if let Some(value) = value {
619                object.insert(format!("targetScope{suffix}"), value);
620            }
621            if let Some(element) = element {
622                object.insert(format!("_targetScope{suffix}"), element);
623            }
624        }
625        if !self.group.is_empty() {
626            let mut items = Vec::with_capacity(self.group.len());
627            for item in &self.group {
628                items.push(super::super::codec::Value::Object(
629                    super::super::codec::Json::to_json(item)?,
630                ));
631            }
632            object.insert(
633                std::string::String::from("group"),
634                super::super::codec::Value::Array(items),
635            );
636        }
637        Ok(object)
638    }
639
640    fn from_json(
641        object: &super::super::codec::Object,
642        path: &mut super::super::codec::Path,
643    ) -> Result<Self, super::super::codec::DecodeError> {
644        let mut raw_id: Option<&super::super::codec::Value> = None;
645        let mut raw_meta: Option<&super::super::codec::Value> = None;
646        let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
647        let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
648        let mut raw_language: Option<&super::super::codec::Value> = None;
649        let mut raw_language_element: Option<&super::super::codec::Value> = None;
650        let mut raw_text: Option<&super::super::codec::Value> = None;
651        let mut raw_contained: Option<&super::super::codec::Value> = None;
652        let mut raw_extension: Option<&super::super::codec::Value> = None;
653        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
654        let mut raw_url: Option<&super::super::codec::Value> = None;
655        let mut raw_url_element: Option<&super::super::codec::Value> = None;
656        let mut raw_identifier: Option<&super::super::codec::Value> = None;
657        let mut raw_version: Option<&super::super::codec::Value> = None;
658        let mut raw_version_element: Option<&super::super::codec::Value> = None;
659        let mut raw_version_algorithm = super::super::codec::ChoiceSlot::default();
660        let mut raw_name: Option<&super::super::codec::Value> = None;
661        let mut raw_name_element: Option<&super::super::codec::Value> = None;
662        let mut raw_title: Option<&super::super::codec::Value> = None;
663        let mut raw_title_element: Option<&super::super::codec::Value> = None;
664        let mut raw_status: Option<&super::super::codec::Value> = None;
665        let mut raw_status_element: Option<&super::super::codec::Value> = None;
666        let mut raw_experimental: Option<&super::super::codec::Value> = None;
667        let mut raw_experimental_element: Option<&super::super::codec::Value> = None;
668        let mut raw_date: Option<&super::super::codec::Value> = None;
669        let mut raw_date_element: Option<&super::super::codec::Value> = None;
670        let mut raw_publisher: Option<&super::super::codec::Value> = None;
671        let mut raw_publisher_element: Option<&super::super::codec::Value> = None;
672        let mut raw_contact: Option<&super::super::codec::Value> = None;
673        let mut raw_description: Option<&super::super::codec::Value> = None;
674        let mut raw_description_element: Option<&super::super::codec::Value> = None;
675        let mut raw_use_context: Option<&super::super::codec::Value> = None;
676        let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
677        let mut raw_purpose: Option<&super::super::codec::Value> = None;
678        let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
679        let mut raw_copyright: Option<&super::super::codec::Value> = None;
680        let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
681        let mut raw_copyright_label: Option<&super::super::codec::Value> = None;
682        let mut raw_copyright_label_element: Option<&super::super::codec::Value> = None;
683        let mut raw_approval_date: Option<&super::super::codec::Value> = None;
684        let mut raw_approval_date_element: Option<&super::super::codec::Value> = None;
685        let mut raw_last_review_date: Option<&super::super::codec::Value> = None;
686        let mut raw_last_review_date_element: Option<&super::super::codec::Value> = None;
687        let mut raw_effective_period: Option<&super::super::codec::Value> = None;
688        let mut raw_topic: Option<&super::super::codec::Value> = None;
689        let mut raw_author: Option<&super::super::codec::Value> = None;
690        let mut raw_editor: Option<&super::super::codec::Value> = None;
691        let mut raw_reviewer: Option<&super::super::codec::Value> = None;
692        let mut raw_endorser: Option<&super::super::codec::Value> = None;
693        let mut raw_related_artifact: Option<&super::super::codec::Value> = None;
694        let mut raw_property: Option<&super::super::codec::Value> = None;
695        let mut raw_additional_attribute: Option<&super::super::codec::Value> = None;
696        let mut raw_source_scope = super::super::codec::ChoiceSlot::default();
697        let mut raw_target_scope = super::super::codec::ChoiceSlot::default();
698        let mut raw_group: Option<&super::super::codec::Value> = None;
699        for (key, value) in object {
700            match key.as_str() {
701                "resourceType" => {
702                    if value.as_str() != Some("ConceptMap") {
703                        return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
704                    }
705                }
706                "id" => {
707                    raw_id = Some(value);
708                }
709                "meta" => {
710                    raw_meta = Some(value);
711                }
712                "implicitRules" => {
713                    raw_implicit_rules = Some(value);
714                }
715                "_implicitRules" => {
716                    raw_implicit_rules_element = Some(value);
717                }
718                "language" => {
719                    raw_language = Some(value);
720                }
721                "_language" => {
722                    raw_language_element = Some(value);
723                }
724                "text" => {
725                    raw_text = Some(value);
726                }
727                "contained" => {
728                    raw_contained = Some(value);
729                }
730                "extension" => {
731                    raw_extension = Some(value);
732                }
733                "modifierExtension" => {
734                    raw_modifier_extension = Some(value);
735                }
736                "url" => {
737                    raw_url = Some(value);
738                }
739                "_url" => {
740                    raw_url_element = Some(value);
741                }
742                "identifier" => {
743                    raw_identifier = Some(value);
744                }
745                "version" => {
746                    raw_version = Some(value);
747                }
748                "_version" => {
749                    raw_version_element = Some(value);
750                }
751                "versionAlgorithmString" => {
752                    raw_version_algorithm.value("String", value, path)?;
753                }
754                "_versionAlgorithmString" => {
755                    raw_version_algorithm.element("String", value, path)?;
756                }
757                "versionAlgorithmCoding" => {
758                    raw_version_algorithm.value("Coding", value, path)?;
759                }
760                "_versionAlgorithmCoding" => {
761                    raw_version_algorithm.element("Coding", value, path)?;
762                }
763                "name" => {
764                    raw_name = Some(value);
765                }
766                "_name" => {
767                    raw_name_element = Some(value);
768                }
769                "title" => {
770                    raw_title = Some(value);
771                }
772                "_title" => {
773                    raw_title_element = Some(value);
774                }
775                "status" => {
776                    raw_status = Some(value);
777                }
778                "_status" => {
779                    raw_status_element = Some(value);
780                }
781                "experimental" => {
782                    raw_experimental = Some(value);
783                }
784                "_experimental" => {
785                    raw_experimental_element = Some(value);
786                }
787                "date" => {
788                    raw_date = Some(value);
789                }
790                "_date" => {
791                    raw_date_element = Some(value);
792                }
793                "publisher" => {
794                    raw_publisher = Some(value);
795                }
796                "_publisher" => {
797                    raw_publisher_element = Some(value);
798                }
799                "contact" => {
800                    raw_contact = Some(value);
801                }
802                "description" => {
803                    raw_description = Some(value);
804                }
805                "_description" => {
806                    raw_description_element = Some(value);
807                }
808                "useContext" => {
809                    raw_use_context = Some(value);
810                }
811                "jurisdiction" => {
812                    raw_jurisdiction = Some(value);
813                }
814                "purpose" => {
815                    raw_purpose = Some(value);
816                }
817                "_purpose" => {
818                    raw_purpose_element = Some(value);
819                }
820                "copyright" => {
821                    raw_copyright = Some(value);
822                }
823                "_copyright" => {
824                    raw_copyright_element = Some(value);
825                }
826                "copyrightLabel" => {
827                    raw_copyright_label = Some(value);
828                }
829                "_copyrightLabel" => {
830                    raw_copyright_label_element = Some(value);
831                }
832                "approvalDate" => {
833                    raw_approval_date = Some(value);
834                }
835                "_approvalDate" => {
836                    raw_approval_date_element = Some(value);
837                }
838                "lastReviewDate" => {
839                    raw_last_review_date = Some(value);
840                }
841                "_lastReviewDate" => {
842                    raw_last_review_date_element = Some(value);
843                }
844                "effectivePeriod" => {
845                    raw_effective_period = Some(value);
846                }
847                "topic" => {
848                    raw_topic = Some(value);
849                }
850                "author" => {
851                    raw_author = Some(value);
852                }
853                "editor" => {
854                    raw_editor = Some(value);
855                }
856                "reviewer" => {
857                    raw_reviewer = Some(value);
858                }
859                "endorser" => {
860                    raw_endorser = Some(value);
861                }
862                "relatedArtifact" => {
863                    raw_related_artifact = Some(value);
864                }
865                "property" => {
866                    raw_property = Some(value);
867                }
868                "additionalAttribute" => {
869                    raw_additional_attribute = Some(value);
870                }
871                "sourceScopeUri" => {
872                    raw_source_scope.value("Uri", value, path)?;
873                }
874                "_sourceScopeUri" => {
875                    raw_source_scope.element("Uri", value, path)?;
876                }
877                "sourceScopeCanonical" => {
878                    raw_source_scope.value("Canonical", value, path)?;
879                }
880                "_sourceScopeCanonical" => {
881                    raw_source_scope.element("Canonical", value, path)?;
882                }
883                "targetScopeUri" => {
884                    raw_target_scope.value("Uri", value, path)?;
885                }
886                "_targetScopeUri" => {
887                    raw_target_scope.element("Uri", value, path)?;
888                }
889                "targetScopeCanonical" => {
890                    raw_target_scope.value("Canonical", value, path)?;
891                }
892                "_targetScopeCanonical" => {
893                    raw_target_scope.element("Canonical", value, path)?;
894                }
895                "group" => {
896                    raw_group = Some(value);
897                }
898                other => {
899                    return path.with(other, |path| {
900                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
901                    });
902                }
903            }
904        }
905        let field_id = raw_id
906            .map(|value| {
907                path.with("id", |path| {
908                    let value = super::super::codec::expect_single(value, path)?;
909                    super::primitives::checked_id(
910                        super::super::codec::expect_string(value, path)?,
911                        path,
912                    )
913                })
914            })
915            .transpose()?;
916        let field_meta = raw_meta
917            .map(|value| {
918                path.with("meta", |path| {
919                    super::super::codec::Json::from_json(
920                        super::super::codec::expect_object(
921                            super::super::codec::expect_single(value, path)?,
922                            path,
923                        )?,
924                        path,
925                    )
926                })
927            })
928            .transpose()?;
929        let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
930            (None, None) => None,
931            (value, element) => Some(path.with("implicitRules", |path| {
932                super::super::codec::Primitive::from_json_parts(value, element, path)
933            })?),
934        };
935        let field_language = match (raw_language, raw_language_element) {
936            (None, None) => None,
937            (value, element) => Some(path.with("language", |path| {
938                super::super::codec::Primitive::from_json_parts(value, element, path)
939            })?),
940        };
941        let field_text = raw_text
942            .map(|value| {
943                path.with("text", |path| {
944                    super::super::codec::Json::from_json(
945                        super::super::codec::expect_object(
946                            super::super::codec::expect_single(value, path)?,
947                            path,
948                        )?,
949                        path,
950                    )
951                })
952            })
953            .transpose()?;
954        let mut field_contained = Vec::new();
955        if let Some(raw) = raw_contained {
956            for (index, value) in path
957                .with("contained", |path| {
958                    super::super::codec::expect_array(raw, path)
959                })?
960                .iter()
961                .enumerate()
962            {
963                field_contained.push(path.with_index("contained", index, |path| {
964                    super::super::codec::Json::from_json(
965                        super::super::codec::expect_object(value, path)?,
966                        path,
967                    )
968                })?);
969            }
970        }
971        let mut field_extension = Vec::new();
972        if let Some(raw) = raw_extension {
973            for (index, value) in path
974                .with("extension", |path| {
975                    super::super::codec::expect_array(raw, path)
976                })?
977                .iter()
978                .enumerate()
979            {
980                field_extension.push(path.with_index("extension", index, |path| {
981                    super::super::codec::Json::from_json(
982                        super::super::codec::expect_object(value, path)?,
983                        path,
984                    )
985                })?);
986            }
987        }
988        let mut field_modifier_extension = Vec::new();
989        if let Some(raw) = raw_modifier_extension {
990            for (index, value) in path
991                .with("modifierExtension", |path| {
992                    super::super::codec::expect_array(raw, path)
993                })?
994                .iter()
995                .enumerate()
996            {
997                field_modifier_extension.push(path.with_index(
998                    "modifierExtension",
999                    index,
1000                    |path| {
1001                        super::super::codec::Json::from_json(
1002                            super::super::codec::expect_object(value, path)?,
1003                            path,
1004                        )
1005                    },
1006                )?);
1007            }
1008        }
1009        let field_url = match (raw_url, raw_url_element) {
1010            (None, None) => None,
1011            (value, element) => Some(path.with("url", |path| {
1012                super::super::codec::Primitive::from_json_parts(value, element, path)
1013            })?),
1014        };
1015        let mut field_identifier = Vec::new();
1016        if let Some(raw) = raw_identifier {
1017            for (index, value) in path
1018                .with("identifier", |path| {
1019                    super::super::codec::expect_array(raw, path)
1020                })?
1021                .iter()
1022                .enumerate()
1023            {
1024                field_identifier.push(path.with_index("identifier", index, |path| {
1025                    super::super::codec::Json::from_json(
1026                        super::super::codec::expect_object(value, path)?,
1027                        path,
1028                    )
1029                })?);
1030            }
1031        }
1032        let field_version = match (raw_version, raw_version_element) {
1033            (None, None) => None,
1034            (value, element) => Some(path.with("version", |path| {
1035                super::super::codec::Primitive::from_json_parts(value, element, path)
1036            })?),
1037        };
1038        let field_version_algorithm = match raw_version_algorithm.suffix {
1039            None => None,
1040            Some(suffix) => Some(path.with("versionAlgorithm", |path| {
1041                ConceptMapVersionAlgorithm::from_json_parts(
1042                    suffix,
1043                    raw_version_algorithm.value,
1044                    raw_version_algorithm.element,
1045                    path,
1046                )
1047            })?),
1048        };
1049        let field_name = match (raw_name, raw_name_element) {
1050            (None, None) => None,
1051            (value, element) => Some(path.with("name", |path| {
1052                super::super::codec::Primitive::from_json_parts(value, element, path)
1053            })?),
1054        };
1055        let field_title = match (raw_title, raw_title_element) {
1056            (None, None) => None,
1057            (value, element) => Some(path.with("title", |path| {
1058                super::super::codec::Primitive::from_json_parts(value, element, path)
1059            })?),
1060        };
1061        let field_status = path.with("status", |path| {
1062            super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
1063        })?;
1064        let field_experimental = match (raw_experimental, raw_experimental_element) {
1065            (None, None) => None,
1066            (value, element) => Some(path.with("experimental", |path| {
1067                super::super::codec::Primitive::from_json_parts(value, element, path)
1068            })?),
1069        };
1070        let field_date = match (raw_date, raw_date_element) {
1071            (None, None) => None,
1072            (value, element) => Some(path.with("date", |path| {
1073                super::super::codec::Primitive::from_json_parts(value, element, path)
1074            })?),
1075        };
1076        let field_publisher = match (raw_publisher, raw_publisher_element) {
1077            (None, None) => None,
1078            (value, element) => Some(path.with("publisher", |path| {
1079                super::super::codec::Primitive::from_json_parts(value, element, path)
1080            })?),
1081        };
1082        let mut field_contact = Vec::new();
1083        if let Some(raw) = raw_contact {
1084            for (index, value) in path
1085                .with("contact", |path| {
1086                    super::super::codec::expect_array(raw, path)
1087                })?
1088                .iter()
1089                .enumerate()
1090            {
1091                field_contact.push(path.with_index("contact", index, |path| {
1092                    super::super::codec::Json::from_json(
1093                        super::super::codec::expect_object(value, path)?,
1094                        path,
1095                    )
1096                })?);
1097            }
1098        }
1099        let field_description = match (raw_description, raw_description_element) {
1100            (None, None) => None,
1101            (value, element) => Some(path.with("description", |path| {
1102                super::super::codec::Primitive::from_json_parts(value, element, path)
1103            })?),
1104        };
1105        let mut field_use_context = Vec::new();
1106        if let Some(raw) = raw_use_context {
1107            for (index, value) in path
1108                .with("useContext", |path| {
1109                    super::super::codec::expect_array(raw, path)
1110                })?
1111                .iter()
1112                .enumerate()
1113            {
1114                field_use_context.push(path.with_index("useContext", index, |path| {
1115                    super::super::codec::Json::from_json(
1116                        super::super::codec::expect_object(value, path)?,
1117                        path,
1118                    )
1119                })?);
1120            }
1121        }
1122        let mut field_jurisdiction = Vec::new();
1123        if let Some(raw) = raw_jurisdiction {
1124            for (index, value) in path
1125                .with("jurisdiction", |path| {
1126                    super::super::codec::expect_array(raw, path)
1127                })?
1128                .iter()
1129                .enumerate()
1130            {
1131                field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
1132                    super::super::codec::Json::from_json(
1133                        super::super::codec::expect_object(value, path)?,
1134                        path,
1135                    )
1136                })?);
1137            }
1138        }
1139        let field_purpose = match (raw_purpose, raw_purpose_element) {
1140            (None, None) => None,
1141            (value, element) => Some(path.with("purpose", |path| {
1142                super::super::codec::Primitive::from_json_parts(value, element, path)
1143            })?),
1144        };
1145        let field_copyright = match (raw_copyright, raw_copyright_element) {
1146            (None, None) => None,
1147            (value, element) => Some(path.with("copyright", |path| {
1148                super::super::codec::Primitive::from_json_parts(value, element, path)
1149            })?),
1150        };
1151        let field_copyright_label = match (raw_copyright_label, raw_copyright_label_element) {
1152            (None, None) => None,
1153            (value, element) => Some(path.with("copyrightLabel", |path| {
1154                super::super::codec::Primitive::from_json_parts(value, element, path)
1155            })?),
1156        };
1157        let field_approval_date = match (raw_approval_date, raw_approval_date_element) {
1158            (None, None) => None,
1159            (value, element) => Some(path.with("approvalDate", |path| {
1160                super::super::codec::Primitive::from_json_parts(value, element, path)
1161            })?),
1162        };
1163        let field_last_review_date = match (raw_last_review_date, raw_last_review_date_element) {
1164            (None, None) => None,
1165            (value, element) => Some(path.with("lastReviewDate", |path| {
1166                super::super::codec::Primitive::from_json_parts(value, element, path)
1167            })?),
1168        };
1169        let field_effective_period = raw_effective_period
1170            .map(|value| {
1171                path.with("effectivePeriod", |path| {
1172                    super::super::codec::Json::from_json(
1173                        super::super::codec::expect_object(
1174                            super::super::codec::expect_single(value, path)?,
1175                            path,
1176                        )?,
1177                        path,
1178                    )
1179                })
1180            })
1181            .transpose()?;
1182        let mut field_topic = Vec::new();
1183        if let Some(raw) = raw_topic {
1184            for (index, value) in path
1185                .with("topic", |path| super::super::codec::expect_array(raw, path))?
1186                .iter()
1187                .enumerate()
1188            {
1189                field_topic.push(path.with_index("topic", index, |path| {
1190                    super::super::codec::Json::from_json(
1191                        super::super::codec::expect_object(value, path)?,
1192                        path,
1193                    )
1194                })?);
1195            }
1196        }
1197        let mut field_author = Vec::new();
1198        if let Some(raw) = raw_author {
1199            for (index, value) in path
1200                .with("author", |path| {
1201                    super::super::codec::expect_array(raw, path)
1202                })?
1203                .iter()
1204                .enumerate()
1205            {
1206                field_author.push(path.with_index("author", index, |path| {
1207                    super::super::codec::Json::from_json(
1208                        super::super::codec::expect_object(value, path)?,
1209                        path,
1210                    )
1211                })?);
1212            }
1213        }
1214        let mut field_editor = Vec::new();
1215        if let Some(raw) = raw_editor {
1216            for (index, value) in path
1217                .with("editor", |path| {
1218                    super::super::codec::expect_array(raw, path)
1219                })?
1220                .iter()
1221                .enumerate()
1222            {
1223                field_editor.push(path.with_index("editor", index, |path| {
1224                    super::super::codec::Json::from_json(
1225                        super::super::codec::expect_object(value, path)?,
1226                        path,
1227                    )
1228                })?);
1229            }
1230        }
1231        let mut field_reviewer = Vec::new();
1232        if let Some(raw) = raw_reviewer {
1233            for (index, value) in path
1234                .with("reviewer", |path| {
1235                    super::super::codec::expect_array(raw, path)
1236                })?
1237                .iter()
1238                .enumerate()
1239            {
1240                field_reviewer.push(path.with_index("reviewer", index, |path| {
1241                    super::super::codec::Json::from_json(
1242                        super::super::codec::expect_object(value, path)?,
1243                        path,
1244                    )
1245                })?);
1246            }
1247        }
1248        let mut field_endorser = Vec::new();
1249        if let Some(raw) = raw_endorser {
1250            for (index, value) in path
1251                .with("endorser", |path| {
1252                    super::super::codec::expect_array(raw, path)
1253                })?
1254                .iter()
1255                .enumerate()
1256            {
1257                field_endorser.push(path.with_index("endorser", index, |path| {
1258                    super::super::codec::Json::from_json(
1259                        super::super::codec::expect_object(value, path)?,
1260                        path,
1261                    )
1262                })?);
1263            }
1264        }
1265        let mut field_related_artifact = Vec::new();
1266        if let Some(raw) = raw_related_artifact {
1267            for (index, value) in path
1268                .with("relatedArtifact", |path| {
1269                    super::super::codec::expect_array(raw, path)
1270                })?
1271                .iter()
1272                .enumerate()
1273            {
1274                field_related_artifact.push(path.with_index("relatedArtifact", index, |path| {
1275                    super::super::codec::Json::from_json(
1276                        super::super::codec::expect_object(value, path)?,
1277                        path,
1278                    )
1279                })?);
1280            }
1281        }
1282        let mut field_property = Vec::new();
1283        if let Some(raw) = raw_property {
1284            for (index, value) in path
1285                .with("property", |path| {
1286                    super::super::codec::expect_array(raw, path)
1287                })?
1288                .iter()
1289                .enumerate()
1290            {
1291                field_property.push(path.with_index("property", index, |path| {
1292                    super::super::codec::Json::from_json(
1293                        super::super::codec::expect_object(value, path)?,
1294                        path,
1295                    )
1296                })?);
1297            }
1298        }
1299        let mut field_additional_attribute = Vec::new();
1300        if let Some(raw) = raw_additional_attribute {
1301            for (index, value) in path
1302                .with("additionalAttribute", |path| {
1303                    super::super::codec::expect_array(raw, path)
1304                })?
1305                .iter()
1306                .enumerate()
1307            {
1308                field_additional_attribute.push(path.with_index(
1309                    "additionalAttribute",
1310                    index,
1311                    |path| {
1312                        super::super::codec::Json::from_json(
1313                            super::super::codec::expect_object(value, path)?,
1314                            path,
1315                        )
1316                    },
1317                )?);
1318            }
1319        }
1320        let field_source_scope = match raw_source_scope.suffix {
1321            None => None,
1322            Some(suffix) => Some(path.with("sourceScope", |path| {
1323                ConceptMapSourceScope::from_json_parts(
1324                    suffix,
1325                    raw_source_scope.value,
1326                    raw_source_scope.element,
1327                    path,
1328                )
1329            })?),
1330        };
1331        let field_target_scope = match raw_target_scope.suffix {
1332            None => None,
1333            Some(suffix) => Some(path.with("targetScope", |path| {
1334                ConceptMapTargetScope::from_json_parts(
1335                    suffix,
1336                    raw_target_scope.value,
1337                    raw_target_scope.element,
1338                    path,
1339                )
1340            })?),
1341        };
1342        let mut field_group = Vec::new();
1343        if let Some(raw) = raw_group {
1344            for (index, value) in path
1345                .with("group", |path| super::super::codec::expect_array(raw, path))?
1346                .iter()
1347                .enumerate()
1348            {
1349                field_group.push(path.with_index("group", index, |path| {
1350                    super::super::codec::Json::from_json(
1351                        super::super::codec::expect_object(value, path)?,
1352                        path,
1353                    )
1354                })?);
1355            }
1356        }
1357        Ok(Self {
1358            id: field_id,
1359            meta: field_meta,
1360            implicit_rules: field_implicit_rules,
1361            language: field_language,
1362            text: field_text,
1363            contained: field_contained,
1364            extension: field_extension,
1365            modifier_extension: field_modifier_extension,
1366            url: field_url,
1367            identifier: field_identifier,
1368            version: field_version,
1369            version_algorithm: field_version_algorithm,
1370            name: field_name,
1371            title: field_title,
1372            status: field_status,
1373            experimental: field_experimental,
1374            date: field_date,
1375            publisher: field_publisher,
1376            contact: field_contact,
1377            description: field_description,
1378            use_context: field_use_context,
1379            jurisdiction: field_jurisdiction,
1380            purpose: field_purpose,
1381            copyright: field_copyright,
1382            copyright_label: field_copyright_label,
1383            approval_date: field_approval_date,
1384            last_review_date: field_last_review_date,
1385            effective_period: field_effective_period,
1386            topic: field_topic,
1387            author: field_author,
1388            editor: field_editor,
1389            reviewer: field_reviewer,
1390            endorser: field_endorser,
1391            related_artifact: field_related_artifact,
1392            property: field_property,
1393            additional_attribute: field_additional_attribute,
1394            source_scope: field_source_scope,
1395            target_scope: field_target_scope,
1396            group: field_group,
1397        })
1398    }
1399}
1400
1401impl serde::Serialize for ConceptMap {
1402    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1403        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1404        if let Some(item) = &self.approval_date {
1405            super::super::codec::element_entry(&mut map, "_approvalDate", item)?;
1406        }
1407        if let Some(item) = &self.copyright {
1408            super::super::codec::element_entry(&mut map, "_copyright", item)?;
1409        }
1410        if let Some(item) = &self.copyright_label {
1411            super::super::codec::element_entry(&mut map, "_copyrightLabel", item)?;
1412        }
1413        if let Some(item) = &self.date {
1414            super::super::codec::element_entry(&mut map, "_date", item)?;
1415        }
1416        if let Some(item) = &self.description {
1417            super::super::codec::element_entry(&mut map, "_description", item)?;
1418        }
1419        if let Some(item) = &self.experimental {
1420            super::super::codec::element_entry(&mut map, "_experimental", item)?;
1421        }
1422        if let Some(item) = &self.implicit_rules {
1423            super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
1424        }
1425        if let Some(item) = &self.language {
1426            super::super::codec::element_entry(&mut map, "_language", item)?;
1427        }
1428        if let Some(item) = &self.last_review_date {
1429            super::super::codec::element_entry(&mut map, "_lastReviewDate", item)?;
1430        }
1431        if let Some(item) = &self.name {
1432            super::super::codec::element_entry(&mut map, "_name", item)?;
1433        }
1434        if let Some(item) = &self.publisher {
1435            super::super::codec::element_entry(&mut map, "_publisher", item)?;
1436        }
1437        if let Some(item) = &self.purpose {
1438            super::super::codec::element_entry(&mut map, "_purpose", item)?;
1439        }
1440        match &self.source_scope {
1441            Some(ConceptMapSourceScope::Canonical(inner)) => {
1442                super::super::codec::element_entry(&mut map, "_sourceScopeCanonical", inner)?;
1443            }
1444            Some(ConceptMapSourceScope::Uri(inner)) => {
1445                super::super::codec::element_entry(&mut map, "_sourceScopeUri", inner)?;
1446            }
1447            None => {}
1448        }
1449        super::super::codec::element_entry(&mut map, "_status", &self.status)?;
1450        match &self.target_scope {
1451            Some(ConceptMapTargetScope::Canonical(inner)) => {
1452                super::super::codec::element_entry(&mut map, "_targetScopeCanonical", inner)?;
1453            }
1454            Some(ConceptMapTargetScope::Uri(inner)) => {
1455                super::super::codec::element_entry(&mut map, "_targetScopeUri", inner)?;
1456            }
1457            None => {}
1458        }
1459        if let Some(item) = &self.title {
1460            super::super::codec::element_entry(&mut map, "_title", item)?;
1461        }
1462        if let Some(item) = &self.url {
1463            super::super::codec::element_entry(&mut map, "_url", item)?;
1464        }
1465        if let Some(item) = &self.version {
1466            super::super::codec::element_entry(&mut map, "_version", item)?;
1467        }
1468        if let Some(ConceptMapVersionAlgorithm::String(inner)) = &self.version_algorithm {
1469            super::super::codec::element_entry(&mut map, "_versionAlgorithmString", inner)?;
1470        }
1471        if !self.additional_attribute.is_empty() {
1472            serde::ser::SerializeMap::serialize_entry(
1473                &mut map,
1474                "additionalAttribute",
1475                &self.additional_attribute,
1476            )?;
1477        }
1478        if let Some(item) = &self.approval_date {
1479            super::super::codec::value_entry(&mut map, "approvalDate", item)?;
1480        }
1481        if !self.author.is_empty() {
1482            serde::ser::SerializeMap::serialize_entry(&mut map, "author", &self.author)?;
1483        }
1484        if !self.contact.is_empty() {
1485            serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
1486        }
1487        if !self.contained.is_empty() {
1488            serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
1489        }
1490        if let Some(item) = &self.copyright {
1491            super::super::codec::value_entry(&mut map, "copyright", item)?;
1492        }
1493        if let Some(item) = &self.copyright_label {
1494            super::super::codec::value_entry(&mut map, "copyrightLabel", item)?;
1495        }
1496        if let Some(item) = &self.date {
1497            super::super::codec::value_entry(&mut map, "date", item)?;
1498        }
1499        if let Some(item) = &self.description {
1500            super::super::codec::value_entry(&mut map, "description", item)?;
1501        }
1502        if !self.editor.is_empty() {
1503            serde::ser::SerializeMap::serialize_entry(&mut map, "editor", &self.editor)?;
1504        }
1505        if let Some(item) = &self.effective_period {
1506            serde::ser::SerializeMap::serialize_entry(&mut map, "effectivePeriod", item)?;
1507        }
1508        if !self.endorser.is_empty() {
1509            serde::ser::SerializeMap::serialize_entry(&mut map, "endorser", &self.endorser)?;
1510        }
1511        if let Some(item) = &self.experimental {
1512            super::super::codec::value_entry(&mut map, "experimental", item)?;
1513        }
1514        if !self.extension.is_empty() {
1515            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1516        }
1517        if !self.group.is_empty() {
1518            serde::ser::SerializeMap::serialize_entry(&mut map, "group", &self.group)?;
1519        }
1520        if let Some(v) = &self.id {
1521            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1522        }
1523        if !self.identifier.is_empty() {
1524            serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
1525        }
1526        if let Some(item) = &self.implicit_rules {
1527            super::super::codec::value_entry(&mut map, "implicitRules", item)?;
1528        }
1529        if !self.jurisdiction.is_empty() {
1530            serde::ser::SerializeMap::serialize_entry(
1531                &mut map,
1532                "jurisdiction",
1533                &self.jurisdiction,
1534            )?;
1535        }
1536        if let Some(item) = &self.language {
1537            super::super::codec::value_entry(&mut map, "language", item)?;
1538        }
1539        if let Some(item) = &self.last_review_date {
1540            super::super::codec::value_entry(&mut map, "lastReviewDate", item)?;
1541        }
1542        if let Some(item) = &self.meta {
1543            serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
1544        }
1545        if !self.modifier_extension.is_empty() {
1546            serde::ser::SerializeMap::serialize_entry(
1547                &mut map,
1548                "modifierExtension",
1549                &self.modifier_extension,
1550            )?;
1551        }
1552        if let Some(item) = &self.name {
1553            super::super::codec::value_entry(&mut map, "name", item)?;
1554        }
1555        if !self.property.is_empty() {
1556            serde::ser::SerializeMap::serialize_entry(&mut map, "property", &self.property)?;
1557        }
1558        if let Some(item) = &self.publisher {
1559            super::super::codec::value_entry(&mut map, "publisher", item)?;
1560        }
1561        if let Some(item) = &self.purpose {
1562            super::super::codec::value_entry(&mut map, "purpose", item)?;
1563        }
1564        if !self.related_artifact.is_empty() {
1565            serde::ser::SerializeMap::serialize_entry(
1566                &mut map,
1567                "relatedArtifact",
1568                &self.related_artifact,
1569            )?;
1570        }
1571        serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "ConceptMap")?;
1572        if !self.reviewer.is_empty() {
1573            serde::ser::SerializeMap::serialize_entry(&mut map, "reviewer", &self.reviewer)?;
1574        }
1575        match &self.source_scope {
1576            Some(ConceptMapSourceScope::Canonical(inner)) => {
1577                super::super::codec::value_entry(&mut map, "sourceScopeCanonical", inner)?;
1578            }
1579            Some(ConceptMapSourceScope::Uri(inner)) => {
1580                super::super::codec::value_entry(&mut map, "sourceScopeUri", inner)?;
1581            }
1582            None => {}
1583        }
1584        super::super::codec::value_entry(&mut map, "status", &self.status)?;
1585        match &self.target_scope {
1586            Some(ConceptMapTargetScope::Canonical(inner)) => {
1587                super::super::codec::value_entry(&mut map, "targetScopeCanonical", inner)?;
1588            }
1589            Some(ConceptMapTargetScope::Uri(inner)) => {
1590                super::super::codec::value_entry(&mut map, "targetScopeUri", inner)?;
1591            }
1592            None => {}
1593        }
1594        if let Some(item) = &self.text {
1595            serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
1596        }
1597        if let Some(item) = &self.title {
1598            super::super::codec::value_entry(&mut map, "title", item)?;
1599        }
1600        if !self.topic.is_empty() {
1601            serde::ser::SerializeMap::serialize_entry(&mut map, "topic", &self.topic)?;
1602        }
1603        if let Some(item) = &self.url {
1604            super::super::codec::value_entry(&mut map, "url", item)?;
1605        }
1606        if !self.use_context.is_empty() {
1607            serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
1608        }
1609        if let Some(item) = &self.version {
1610            super::super::codec::value_entry(&mut map, "version", item)?;
1611        }
1612        match &self.version_algorithm {
1613            Some(ConceptMapVersionAlgorithm::Coding(inner)) => {
1614                serde::ser::SerializeMap::serialize_entry(
1615                    &mut map,
1616                    "versionAlgorithmCoding",
1617                    inner.as_ref(),
1618                )?;
1619            }
1620            Some(ConceptMapVersionAlgorithm::String(inner)) => {
1621                super::super::codec::value_entry(&mut map, "versionAlgorithmString", inner)?;
1622            }
1623            None => {}
1624        }
1625        serde::ser::SerializeMap::end(map)
1626    }
1627}
1628
1629impl<'de> serde::Deserialize<'de> for ConceptMap {
1630    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1631        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1632        let mut path = super::super::codec::Path::root("ConceptMap");
1633        let object =
1634            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1635        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1636    }
1637}
1638
1639/// Definition of an additional attribute to act as a data source or target
1640///
1641/// An additionalAttribute defines an additional data element found in the
1642/// source or target data model where the data will come from or be mapped to.
1643/// Some mappings are based on data in addition to the source data element,
1644/// where codes in multiple fields are combined to a single field (or vice
1645/// versa).
1646#[derive(Debug, Clone, Default, PartialEq, Eq)]
1647pub struct ConceptMapAdditionalAttribute {
1648    /// Unique id for inter-element referencing
1649    ///
1650    /// Unique id for the element within a resource (for internal references). This
1651    /// may be any string value that does not contain spaces.
1652    pub id: Option<std::string::String>,
1653    /// Additional content defined by implementations
1654    ///
1655    /// May be used to represent additional information that is not part of the
1656    /// basic definition of the element. To make the use of extensions safe and
1657    /// managable, there is a strict set of governance applied to the definition and
1658    /// use of extensions. Though any implementer can define an extension, there is
1659    /// a set of requirements that SHALL be met as part of the definition of the
1660    /// extension.
1661    pub extension: Vec<super::extension::Extension>,
1662    /// Extensions that cannot be ignored even if unrecognized
1663    ///
1664    /// May be used to represent additional information that is not part of the
1665    /// basic definition of the element and that modifies the understanding of the
1666    /// element in which it is contained and/or the understanding of the containing
1667    /// element's descendants. Usually modifier elements provide negation or
1668    /// qualification. To make the use of extensions safe and managable, there is a
1669    /// strict set of governance applied to the definition and use of extensions.
1670    /// Though any implementer can define an extension, there is a set of
1671    /// requirements that SHALL be met as part of the definition of the extension.
1672    /// Applications processing a resource are required to check for modifier
1673    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1674    /// on Resource or DomainResource (including cannot change the meaning of
1675    /// modifierExtension itself).
1676    pub modifier_extension: Vec<super::extension::Extension>,
1677    /// Identifies this additional attribute through this resource
1678    ///
1679    /// A code that is used to identify this additional data attribute. The code is
1680    /// used internally in ConceptMap.group.element.target.dependsOn.attribute and
1681    /// ConceptMap.group.element.target.product.attribute.
1682    pub code: super::primitives::Code,
1683    /// Formal identifier for the data element referred to in this attribte
1684    ///
1685    /// Reference to the formal definition of the source/target data element. For
1686    /// elements defined by the FHIR specification, or using a FHIR logical model,
1687    /// the correct format is {canonical-url}\#{element-id}.
1688    pub uri: Option<super::primitives::Uri>,
1689    /// Why the additional attribute is defined, and/or what the data element it
1690    /// refers to is
1691    ///
1692    /// A description of the additional attribute and/or the data element it refers
1693    /// to - why it is defined, and how the value might be used in mappings, and a
1694    /// discussion of issues associated with the use of the data element.
1695    pub description: Option<super::primitives::String>,
1696    /// code | Coding | string | boolean | Quantity
1697    ///
1698    /// The type of the source data contained in this concept map for this data
1699    /// element.
1700    pub r#type: super::primitives::Code,
1701}
1702
1703impl super::super::codec::Json for ConceptMapAdditionalAttribute {
1704    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
1705        let mut object = super::super::codec::Object::new();
1706        if let Some(v) = &self.id {
1707            object.insert(
1708                std::string::String::from("id"),
1709                super::super::codec::Value::String(v.clone()),
1710            );
1711        }
1712        if !self.extension.is_empty() {
1713            let mut items = Vec::with_capacity(self.extension.len());
1714            for item in &self.extension {
1715                items.push(super::super::codec::Value::Object(
1716                    super::super::codec::Json::to_json(item)?,
1717                ));
1718            }
1719            object.insert(
1720                std::string::String::from("extension"),
1721                super::super::codec::Value::Array(items),
1722            );
1723        }
1724        if !self.modifier_extension.is_empty() {
1725            let mut items = Vec::with_capacity(self.modifier_extension.len());
1726            for item in &self.modifier_extension {
1727                items.push(super::super::codec::Value::Object(
1728                    super::super::codec::Json::to_json(item)?,
1729                ));
1730            }
1731            object.insert(
1732                std::string::String::from("modifierExtension"),
1733                super::super::codec::Value::Array(items),
1734            );
1735        }
1736        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
1737            object.insert(std::string::String::from("code"), v);
1738        }
1739        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
1740            object.insert(std::string::String::from("_code"), e);
1741        }
1742        if let Some(item) = &self.uri {
1743            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1744                object.insert(std::string::String::from("uri"), v);
1745            }
1746            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1747                object.insert(std::string::String::from("_uri"), e);
1748            }
1749        }
1750        if let Some(item) = &self.description {
1751            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
1752                object.insert(std::string::String::from("description"), v);
1753            }
1754            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
1755                object.insert(std::string::String::from("_description"), e);
1756            }
1757        }
1758        if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
1759            object.insert(std::string::String::from("type"), v);
1760        }
1761        if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
1762            object.insert(std::string::String::from("_type"), e);
1763        }
1764        Ok(object)
1765    }
1766
1767    fn from_json(
1768        object: &super::super::codec::Object,
1769        path: &mut super::super::codec::Path,
1770    ) -> Result<Self, super::super::codec::DecodeError> {
1771        let mut raw_id: Option<&super::super::codec::Value> = None;
1772        let mut raw_extension: Option<&super::super::codec::Value> = None;
1773        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
1774        let mut raw_code: Option<&super::super::codec::Value> = None;
1775        let mut raw_code_element: Option<&super::super::codec::Value> = None;
1776        let mut raw_uri: Option<&super::super::codec::Value> = None;
1777        let mut raw_uri_element: Option<&super::super::codec::Value> = None;
1778        let mut raw_description: Option<&super::super::codec::Value> = None;
1779        let mut raw_description_element: Option<&super::super::codec::Value> = None;
1780        let mut raw_type: Option<&super::super::codec::Value> = None;
1781        let mut raw_type_element: Option<&super::super::codec::Value> = None;
1782        for (key, value) in object {
1783            match key.as_str() {
1784                "id" => {
1785                    raw_id = Some(value);
1786                }
1787                "extension" => {
1788                    raw_extension = Some(value);
1789                }
1790                "modifierExtension" => {
1791                    raw_modifier_extension = Some(value);
1792                }
1793                "code" => {
1794                    raw_code = Some(value);
1795                }
1796                "_code" => {
1797                    raw_code_element = Some(value);
1798                }
1799                "uri" => {
1800                    raw_uri = Some(value);
1801                }
1802                "_uri" => {
1803                    raw_uri_element = Some(value);
1804                }
1805                "description" => {
1806                    raw_description = Some(value);
1807                }
1808                "_description" => {
1809                    raw_description_element = Some(value);
1810                }
1811                "type" => {
1812                    raw_type = Some(value);
1813                }
1814                "_type" => {
1815                    raw_type_element = Some(value);
1816                }
1817                other => {
1818                    return path.with(other, |path| {
1819                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
1820                    });
1821                }
1822            }
1823        }
1824        let field_id = raw_id
1825            .map(|value| {
1826                path.with("id", |path| {
1827                    let value = super::super::codec::expect_single(value, path)?;
1828                    super::primitives::checked_string(
1829                        super::super::codec::expect_string(value, path)?,
1830                        path,
1831                    )
1832                })
1833            })
1834            .transpose()?;
1835        let mut field_extension = Vec::new();
1836        if let Some(raw) = raw_extension {
1837            for (index, value) in path
1838                .with("extension", |path| {
1839                    super::super::codec::expect_array(raw, path)
1840                })?
1841                .iter()
1842                .enumerate()
1843            {
1844                field_extension.push(path.with_index("extension", index, |path| {
1845                    super::super::codec::Json::from_json(
1846                        super::super::codec::expect_object(value, path)?,
1847                        path,
1848                    )
1849                })?);
1850            }
1851        }
1852        let mut field_modifier_extension = Vec::new();
1853        if let Some(raw) = raw_modifier_extension {
1854            for (index, value) in path
1855                .with("modifierExtension", |path| {
1856                    super::super::codec::expect_array(raw, path)
1857                })?
1858                .iter()
1859                .enumerate()
1860            {
1861                field_modifier_extension.push(path.with_index(
1862                    "modifierExtension",
1863                    index,
1864                    |path| {
1865                        super::super::codec::Json::from_json(
1866                            super::super::codec::expect_object(value, path)?,
1867                            path,
1868                        )
1869                    },
1870                )?);
1871            }
1872        }
1873        let field_code = path.with("code", |path| {
1874            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
1875        })?;
1876        let field_uri = match (raw_uri, raw_uri_element) {
1877            (None, None) => None,
1878            (value, element) => Some(path.with("uri", |path| {
1879                super::super::codec::Primitive::from_json_parts(value, element, path)
1880            })?),
1881        };
1882        let field_description = match (raw_description, raw_description_element) {
1883            (None, None) => None,
1884            (value, element) => Some(path.with("description", |path| {
1885                super::super::codec::Primitive::from_json_parts(value, element, path)
1886            })?),
1887        };
1888        let field_type = path.with("type", |path| {
1889            super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
1890        })?;
1891        Ok(Self {
1892            id: field_id,
1893            extension: field_extension,
1894            modifier_extension: field_modifier_extension,
1895            code: field_code,
1896            uri: field_uri,
1897            description: field_description,
1898            r#type: field_type,
1899        })
1900    }
1901}
1902
1903impl serde::Serialize for ConceptMapAdditionalAttribute {
1904    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1905        let mut map = serde::Serializer::serialize_map(serializer, None)?;
1906        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
1907        if let Some(item) = &self.description {
1908            super::super::codec::element_entry(&mut map, "_description", item)?;
1909        }
1910        super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
1911        if let Some(item) = &self.uri {
1912            super::super::codec::element_entry(&mut map, "_uri", item)?;
1913        }
1914        super::super::codec::value_entry(&mut map, "code", &self.code)?;
1915        if let Some(item) = &self.description {
1916            super::super::codec::value_entry(&mut map, "description", item)?;
1917        }
1918        if !self.extension.is_empty() {
1919            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
1920        }
1921        if let Some(v) = &self.id {
1922            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
1923        }
1924        if !self.modifier_extension.is_empty() {
1925            serde::ser::SerializeMap::serialize_entry(
1926                &mut map,
1927                "modifierExtension",
1928                &self.modifier_extension,
1929            )?;
1930        }
1931        super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
1932        if let Some(item) = &self.uri {
1933            super::super::codec::value_entry(&mut map, "uri", item)?;
1934        }
1935        serde::ser::SerializeMap::end(map)
1936    }
1937}
1938
1939impl<'de> serde::Deserialize<'de> for ConceptMapAdditionalAttribute {
1940    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1941        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
1942        let mut path = super::super::codec::Path::root("ConceptMapAdditionalAttribute");
1943        let object =
1944            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
1945        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
1946    }
1947}
1948
1949/// Same source and target systems
1950///
1951/// A group of mappings that all have the same source and target system.
1952#[derive(Debug, Clone, Default, PartialEq, Eq)]
1953pub struct ConceptMapGroup {
1954    /// Unique id for inter-element referencing
1955    ///
1956    /// Unique id for the element within a resource (for internal references). This
1957    /// may be any string value that does not contain spaces.
1958    pub id: Option<std::string::String>,
1959    /// Additional content defined by implementations
1960    ///
1961    /// May be used to represent additional information that is not part of the
1962    /// basic definition of the element. To make the use of extensions safe and
1963    /// managable, there is a strict set of governance applied to the definition and
1964    /// use of extensions. Though any implementer can define an extension, there is
1965    /// a set of requirements that SHALL be met as part of the definition of the
1966    /// extension.
1967    pub extension: Vec<super::extension::Extension>,
1968    /// Extensions that cannot be ignored even if unrecognized
1969    ///
1970    /// May be used to represent additional information that is not part of the
1971    /// basic definition of the element and that modifies the understanding of the
1972    /// element in which it is contained and/or the understanding of the containing
1973    /// element's descendants. Usually modifier elements provide negation or
1974    /// qualification. To make the use of extensions safe and managable, there is a
1975    /// strict set of governance applied to the definition and use of extensions.
1976    /// Though any implementer can define an extension, there is a set of
1977    /// requirements that SHALL be met as part of the definition of the extension.
1978    /// Applications processing a resource are required to check for modifier
1979    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
1980    /// on Resource or DomainResource (including cannot change the meaning of
1981    /// modifierExtension itself).
1982    pub modifier_extension: Vec<super::extension::Extension>,
1983    /// Source system where concepts to be mapped are defined
1984    ///
1985    /// An absolute URI that identifies the source system where the concepts to be
1986    /// mapped are defined.
1987    pub source: Option<super::primitives::Canonical>,
1988    /// Target system that the concepts are to be mapped to
1989    ///
1990    /// An absolute URI that identifies the target system that the concepts will be
1991    /// mapped to.
1992    pub target: Option<super::primitives::Canonical>,
1993    /// Mappings for a concept from the source set
1994    ///
1995    /// Mappings for an individual concept in the source to one or more concepts in
1996    /// the target.
1997    pub element: Vec<ConceptMapGroupElement>,
1998    /// What to do when there is no mapping target for the source concept and
1999    /// ConceptMap.group.element.noMap is not true
2000    ///
2001    /// What to do when there is no mapping to a target concept from the source
2002    /// concept and ConceptMap.group.element.noMap is not true. This provides the
2003    /// "default" to be applied when there is no target concept mapping specified or
2004    /// the expansion of ConceptMap.group.element.target.valueSet is empty.
2005    pub unmapped: Option<ConceptMapGroupUnmapped>,
2006}
2007
2008impl super::super::codec::Json for ConceptMapGroup {
2009    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2010        let mut object = super::super::codec::Object::new();
2011        if let Some(v) = &self.id {
2012            object.insert(
2013                std::string::String::from("id"),
2014                super::super::codec::Value::String(v.clone()),
2015            );
2016        }
2017        if !self.extension.is_empty() {
2018            let mut items = Vec::with_capacity(self.extension.len());
2019            for item in &self.extension {
2020                items.push(super::super::codec::Value::Object(
2021                    super::super::codec::Json::to_json(item)?,
2022                ));
2023            }
2024            object.insert(
2025                std::string::String::from("extension"),
2026                super::super::codec::Value::Array(items),
2027            );
2028        }
2029        if !self.modifier_extension.is_empty() {
2030            let mut items = Vec::with_capacity(self.modifier_extension.len());
2031            for item in &self.modifier_extension {
2032                items.push(super::super::codec::Value::Object(
2033                    super::super::codec::Json::to_json(item)?,
2034                ));
2035            }
2036            object.insert(
2037                std::string::String::from("modifierExtension"),
2038                super::super::codec::Value::Array(items),
2039            );
2040        }
2041        if let Some(item) = &self.source {
2042            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2043                object.insert(std::string::String::from("source"), v);
2044            }
2045            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2046                object.insert(std::string::String::from("_source"), e);
2047            }
2048        }
2049        if let Some(item) = &self.target {
2050            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2051                object.insert(std::string::String::from("target"), v);
2052            }
2053            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2054                object.insert(std::string::String::from("_target"), e);
2055            }
2056        }
2057        if !self.element.is_empty() {
2058            let mut items = Vec::with_capacity(self.element.len());
2059            for item in &self.element {
2060                items.push(super::super::codec::Value::Object(
2061                    super::super::codec::Json::to_json(item)?,
2062                ));
2063            }
2064            object.insert(
2065                std::string::String::from("element"),
2066                super::super::codec::Value::Array(items),
2067            );
2068        }
2069        if let Some(item) = &self.unmapped {
2070            object.insert(
2071                std::string::String::from("unmapped"),
2072                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
2073            );
2074        }
2075        Ok(object)
2076    }
2077
2078    fn from_json(
2079        object: &super::super::codec::Object,
2080        path: &mut super::super::codec::Path,
2081    ) -> Result<Self, super::super::codec::DecodeError> {
2082        let mut raw_id: Option<&super::super::codec::Value> = None;
2083        let mut raw_extension: Option<&super::super::codec::Value> = None;
2084        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2085        let mut raw_source: Option<&super::super::codec::Value> = None;
2086        let mut raw_source_element: Option<&super::super::codec::Value> = None;
2087        let mut raw_target: Option<&super::super::codec::Value> = None;
2088        let mut raw_target_element: Option<&super::super::codec::Value> = None;
2089        let mut raw_element: Option<&super::super::codec::Value> = None;
2090        let mut raw_unmapped: Option<&super::super::codec::Value> = None;
2091        for (key, value) in object {
2092            match key.as_str() {
2093                "id" => {
2094                    raw_id = Some(value);
2095                }
2096                "extension" => {
2097                    raw_extension = Some(value);
2098                }
2099                "modifierExtension" => {
2100                    raw_modifier_extension = Some(value);
2101                }
2102                "source" => {
2103                    raw_source = Some(value);
2104                }
2105                "_source" => {
2106                    raw_source_element = Some(value);
2107                }
2108                "target" => {
2109                    raw_target = Some(value);
2110                }
2111                "_target" => {
2112                    raw_target_element = Some(value);
2113                }
2114                "element" => {
2115                    raw_element = Some(value);
2116                }
2117                "unmapped" => {
2118                    raw_unmapped = Some(value);
2119                }
2120                other => {
2121                    return path.with(other, |path| {
2122                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2123                    });
2124                }
2125            }
2126        }
2127        let field_id = raw_id
2128            .map(|value| {
2129                path.with("id", |path| {
2130                    let value = super::super::codec::expect_single(value, path)?;
2131                    super::primitives::checked_string(
2132                        super::super::codec::expect_string(value, path)?,
2133                        path,
2134                    )
2135                })
2136            })
2137            .transpose()?;
2138        let mut field_extension = Vec::new();
2139        if let Some(raw) = raw_extension {
2140            for (index, value) in path
2141                .with("extension", |path| {
2142                    super::super::codec::expect_array(raw, path)
2143                })?
2144                .iter()
2145                .enumerate()
2146            {
2147                field_extension.push(path.with_index("extension", index, |path| {
2148                    super::super::codec::Json::from_json(
2149                        super::super::codec::expect_object(value, path)?,
2150                        path,
2151                    )
2152                })?);
2153            }
2154        }
2155        let mut field_modifier_extension = Vec::new();
2156        if let Some(raw) = raw_modifier_extension {
2157            for (index, value) in path
2158                .with("modifierExtension", |path| {
2159                    super::super::codec::expect_array(raw, path)
2160                })?
2161                .iter()
2162                .enumerate()
2163            {
2164                field_modifier_extension.push(path.with_index(
2165                    "modifierExtension",
2166                    index,
2167                    |path| {
2168                        super::super::codec::Json::from_json(
2169                            super::super::codec::expect_object(value, path)?,
2170                            path,
2171                        )
2172                    },
2173                )?);
2174            }
2175        }
2176        let field_source = match (raw_source, raw_source_element) {
2177            (None, None) => None,
2178            (value, element) => Some(path.with("source", |path| {
2179                super::super::codec::Primitive::from_json_parts(value, element, path)
2180            })?),
2181        };
2182        let field_target = match (raw_target, raw_target_element) {
2183            (None, None) => None,
2184            (value, element) => Some(path.with("target", |path| {
2185                super::super::codec::Primitive::from_json_parts(value, element, path)
2186            })?),
2187        };
2188        let mut field_element = Vec::new();
2189        if let Some(raw) = raw_element {
2190            for (index, value) in path
2191                .with("element", |path| {
2192                    super::super::codec::expect_array(raw, path)
2193                })?
2194                .iter()
2195                .enumerate()
2196            {
2197                field_element.push(path.with_index("element", index, |path| {
2198                    super::super::codec::Json::from_json(
2199                        super::super::codec::expect_object(value, path)?,
2200                        path,
2201                    )
2202                })?);
2203            }
2204        }
2205        if field_element.is_empty() && !path.is_lenient() {
2206            return path.with("element", |path| {
2207                Err(path.error(super::super::codec::DecodeErrorKind::MissingProperty))
2208            });
2209        }
2210        let field_unmapped = raw_unmapped
2211            .map(|value| {
2212                path.with("unmapped", |path| {
2213                    super::super::codec::Json::from_json(
2214                        super::super::codec::expect_object(
2215                            super::super::codec::expect_single(value, path)?,
2216                            path,
2217                        )?,
2218                        path,
2219                    )
2220                })
2221            })
2222            .transpose()?;
2223        Ok(Self {
2224            id: field_id,
2225            extension: field_extension,
2226            modifier_extension: field_modifier_extension,
2227            source: field_source,
2228            target: field_target,
2229            element: field_element,
2230            unmapped: field_unmapped,
2231        })
2232    }
2233}
2234
2235impl serde::Serialize for ConceptMapGroup {
2236    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2237        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2238        if let Some(item) = &self.source {
2239            super::super::codec::element_entry(&mut map, "_source", item)?;
2240        }
2241        if let Some(item) = &self.target {
2242            super::super::codec::element_entry(&mut map, "_target", item)?;
2243        }
2244        if !self.element.is_empty() {
2245            serde::ser::SerializeMap::serialize_entry(&mut map, "element", &self.element)?;
2246        }
2247        if !self.extension.is_empty() {
2248            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2249        }
2250        if let Some(v) = &self.id {
2251            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2252        }
2253        if !self.modifier_extension.is_empty() {
2254            serde::ser::SerializeMap::serialize_entry(
2255                &mut map,
2256                "modifierExtension",
2257                &self.modifier_extension,
2258            )?;
2259        }
2260        if let Some(item) = &self.source {
2261            super::super::codec::value_entry(&mut map, "source", item)?;
2262        }
2263        if let Some(item) = &self.target {
2264            super::super::codec::value_entry(&mut map, "target", item)?;
2265        }
2266        if let Some(item) = &self.unmapped {
2267            serde::ser::SerializeMap::serialize_entry(&mut map, "unmapped", item)?;
2268        }
2269        serde::ser::SerializeMap::end(map)
2270    }
2271}
2272
2273impl<'de> serde::Deserialize<'de> for ConceptMapGroup {
2274    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2275        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2276        let mut path = super::super::codec::Path::root("ConceptMapGroup");
2277        let object =
2278            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2279        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2280    }
2281}
2282
2283/// Mappings for a concept from the source set
2284///
2285/// Mappings for an individual concept in the source to one or more concepts in
2286/// the target.
2287#[derive(Debug, Clone, Default, PartialEq, Eq)]
2288pub struct ConceptMapGroupElement {
2289    /// Unique id for inter-element referencing
2290    ///
2291    /// Unique id for the element within a resource (for internal references). This
2292    /// may be any string value that does not contain spaces.
2293    pub id: Option<std::string::String>,
2294    /// Additional content defined by implementations
2295    ///
2296    /// May be used to represent additional information that is not part of the
2297    /// basic definition of the element. To make the use of extensions safe and
2298    /// managable, there is a strict set of governance applied to the definition and
2299    /// use of extensions. Though any implementer can define an extension, there is
2300    /// a set of requirements that SHALL be met as part of the definition of the
2301    /// extension.
2302    pub extension: Vec<super::extension::Extension>,
2303    /// Extensions that cannot be ignored even if unrecognized
2304    ///
2305    /// May be used to represent additional information that is not part of the
2306    /// basic definition of the element and that modifies the understanding of the
2307    /// element in which it is contained and/or the understanding of the containing
2308    /// element's descendants. Usually modifier elements provide negation or
2309    /// qualification. To make the use of extensions safe and managable, there is a
2310    /// strict set of governance applied to the definition and use of extensions.
2311    /// Though any implementer can define an extension, there is a set of
2312    /// requirements that SHALL be met as part of the definition of the extension.
2313    /// Applications processing a resource are required to check for modifier
2314    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2315    /// on Resource or DomainResource (including cannot change the meaning of
2316    /// modifierExtension itself).
2317    pub modifier_extension: Vec<super::extension::Extension>,
2318    /// Identifies element being mapped
2319    ///
2320    /// Identity (code or path) or the element/item being mapped.
2321    pub code: Option<super::primitives::Code>,
2322    /// Display for the code
2323    ///
2324    /// The display for the code. The display is only provided to help editors when
2325    /// editing the concept map.
2326    pub display: Option<super::primitives::String>,
2327    /// Identifies the set of concepts being mapped
2328    ///
2329    /// The set of concepts from the ConceptMap.group.source code system which are
2330    /// all being mapped to the target as part of this mapping rule.
2331    pub value_set: Option<super::primitives::Canonical>,
2332    /// No mapping to a target concept for this source concept
2333    ///
2334    /// If noMap = true this indicates that no mapping to a target concept exists
2335    /// for this source concept.
2336    pub no_map: Option<super::primitives::Boolean>,
2337    /// Concept in target system for element
2338    ///
2339    /// A concept from the target value set that this concept maps to.
2340    pub target: Vec<ConceptMapGroupElementTarget>,
2341}
2342
2343impl super::super::codec::Json for ConceptMapGroupElement {
2344    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2345        let mut object = super::super::codec::Object::new();
2346        if let Some(v) = &self.id {
2347            object.insert(
2348                std::string::String::from("id"),
2349                super::super::codec::Value::String(v.clone()),
2350            );
2351        }
2352        if !self.extension.is_empty() {
2353            let mut items = Vec::with_capacity(self.extension.len());
2354            for item in &self.extension {
2355                items.push(super::super::codec::Value::Object(
2356                    super::super::codec::Json::to_json(item)?,
2357                ));
2358            }
2359            object.insert(
2360                std::string::String::from("extension"),
2361                super::super::codec::Value::Array(items),
2362            );
2363        }
2364        if !self.modifier_extension.is_empty() {
2365            let mut items = Vec::with_capacity(self.modifier_extension.len());
2366            for item in &self.modifier_extension {
2367                items.push(super::super::codec::Value::Object(
2368                    super::super::codec::Json::to_json(item)?,
2369                ));
2370            }
2371            object.insert(
2372                std::string::String::from("modifierExtension"),
2373                super::super::codec::Value::Array(items),
2374            );
2375        }
2376        if let Some(item) = &self.code {
2377            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2378                object.insert(std::string::String::from("code"), v);
2379            }
2380            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2381                object.insert(std::string::String::from("_code"), e);
2382            }
2383        }
2384        if let Some(item) = &self.display {
2385            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2386                object.insert(std::string::String::from("display"), v);
2387            }
2388            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2389                object.insert(std::string::String::from("_display"), e);
2390            }
2391        }
2392        if let Some(item) = &self.value_set {
2393            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2394                object.insert(std::string::String::from("valueSet"), v);
2395            }
2396            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2397                object.insert(std::string::String::from("_valueSet"), e);
2398            }
2399        }
2400        if let Some(item) = &self.no_map {
2401            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2402                object.insert(std::string::String::from("noMap"), v);
2403            }
2404            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2405                object.insert(std::string::String::from("_noMap"), e);
2406            }
2407        }
2408        if !self.target.is_empty() {
2409            let mut items = Vec::with_capacity(self.target.len());
2410            for item in &self.target {
2411                items.push(super::super::codec::Value::Object(
2412                    super::super::codec::Json::to_json(item)?,
2413                ));
2414            }
2415            object.insert(
2416                std::string::String::from("target"),
2417                super::super::codec::Value::Array(items),
2418            );
2419        }
2420        Ok(object)
2421    }
2422
2423    fn from_json(
2424        object: &super::super::codec::Object,
2425        path: &mut super::super::codec::Path,
2426    ) -> Result<Self, super::super::codec::DecodeError> {
2427        let mut raw_id: Option<&super::super::codec::Value> = None;
2428        let mut raw_extension: Option<&super::super::codec::Value> = None;
2429        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2430        let mut raw_code: Option<&super::super::codec::Value> = None;
2431        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2432        let mut raw_display: Option<&super::super::codec::Value> = None;
2433        let mut raw_display_element: Option<&super::super::codec::Value> = None;
2434        let mut raw_value_set: Option<&super::super::codec::Value> = None;
2435        let mut raw_value_set_element: Option<&super::super::codec::Value> = None;
2436        let mut raw_no_map: Option<&super::super::codec::Value> = None;
2437        let mut raw_no_map_element: Option<&super::super::codec::Value> = None;
2438        let mut raw_target: Option<&super::super::codec::Value> = None;
2439        for (key, value) in object {
2440            match key.as_str() {
2441                "id" => {
2442                    raw_id = Some(value);
2443                }
2444                "extension" => {
2445                    raw_extension = Some(value);
2446                }
2447                "modifierExtension" => {
2448                    raw_modifier_extension = Some(value);
2449                }
2450                "code" => {
2451                    raw_code = Some(value);
2452                }
2453                "_code" => {
2454                    raw_code_element = Some(value);
2455                }
2456                "display" => {
2457                    raw_display = Some(value);
2458                }
2459                "_display" => {
2460                    raw_display_element = Some(value);
2461                }
2462                "valueSet" => {
2463                    raw_value_set = Some(value);
2464                }
2465                "_valueSet" => {
2466                    raw_value_set_element = Some(value);
2467                }
2468                "noMap" => {
2469                    raw_no_map = Some(value);
2470                }
2471                "_noMap" => {
2472                    raw_no_map_element = Some(value);
2473                }
2474                "target" => {
2475                    raw_target = Some(value);
2476                }
2477                other => {
2478                    return path.with(other, |path| {
2479                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2480                    });
2481                }
2482            }
2483        }
2484        let field_id = raw_id
2485            .map(|value| {
2486                path.with("id", |path| {
2487                    let value = super::super::codec::expect_single(value, path)?;
2488                    super::primitives::checked_string(
2489                        super::super::codec::expect_string(value, path)?,
2490                        path,
2491                    )
2492                })
2493            })
2494            .transpose()?;
2495        let mut field_extension = Vec::new();
2496        if let Some(raw) = raw_extension {
2497            for (index, value) in path
2498                .with("extension", |path| {
2499                    super::super::codec::expect_array(raw, path)
2500                })?
2501                .iter()
2502                .enumerate()
2503            {
2504                field_extension.push(path.with_index("extension", index, |path| {
2505                    super::super::codec::Json::from_json(
2506                        super::super::codec::expect_object(value, path)?,
2507                        path,
2508                    )
2509                })?);
2510            }
2511        }
2512        let mut field_modifier_extension = Vec::new();
2513        if let Some(raw) = raw_modifier_extension {
2514            for (index, value) in path
2515                .with("modifierExtension", |path| {
2516                    super::super::codec::expect_array(raw, path)
2517                })?
2518                .iter()
2519                .enumerate()
2520            {
2521                field_modifier_extension.push(path.with_index(
2522                    "modifierExtension",
2523                    index,
2524                    |path| {
2525                        super::super::codec::Json::from_json(
2526                            super::super::codec::expect_object(value, path)?,
2527                            path,
2528                        )
2529                    },
2530                )?);
2531            }
2532        }
2533        let field_code = match (raw_code, raw_code_element) {
2534            (None, None) => None,
2535            (value, element) => Some(path.with("code", |path| {
2536                super::super::codec::Primitive::from_json_parts(value, element, path)
2537            })?),
2538        };
2539        let field_display = match (raw_display, raw_display_element) {
2540            (None, None) => None,
2541            (value, element) => Some(path.with("display", |path| {
2542                super::super::codec::Primitive::from_json_parts(value, element, path)
2543            })?),
2544        };
2545        let field_value_set = match (raw_value_set, raw_value_set_element) {
2546            (None, None) => None,
2547            (value, element) => Some(path.with("valueSet", |path| {
2548                super::super::codec::Primitive::from_json_parts(value, element, path)
2549            })?),
2550        };
2551        let field_no_map = match (raw_no_map, raw_no_map_element) {
2552            (None, None) => None,
2553            (value, element) => Some(path.with("noMap", |path| {
2554                super::super::codec::Primitive::from_json_parts(value, element, path)
2555            })?),
2556        };
2557        let mut field_target = Vec::new();
2558        if let Some(raw) = raw_target {
2559            for (index, value) in path
2560                .with("target", |path| {
2561                    super::super::codec::expect_array(raw, path)
2562                })?
2563                .iter()
2564                .enumerate()
2565            {
2566                field_target.push(path.with_index("target", index, |path| {
2567                    super::super::codec::Json::from_json(
2568                        super::super::codec::expect_object(value, path)?,
2569                        path,
2570                    )
2571                })?);
2572            }
2573        }
2574        Ok(Self {
2575            id: field_id,
2576            extension: field_extension,
2577            modifier_extension: field_modifier_extension,
2578            code: field_code,
2579            display: field_display,
2580            value_set: field_value_set,
2581            no_map: field_no_map,
2582            target: field_target,
2583        })
2584    }
2585}
2586
2587impl serde::Serialize for ConceptMapGroupElement {
2588    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2589        let mut map = serde::Serializer::serialize_map(serializer, None)?;
2590        if let Some(item) = &self.code {
2591            super::super::codec::element_entry(&mut map, "_code", item)?;
2592        }
2593        if let Some(item) = &self.display {
2594            super::super::codec::element_entry(&mut map, "_display", item)?;
2595        }
2596        if let Some(item) = &self.no_map {
2597            super::super::codec::element_entry(&mut map, "_noMap", item)?;
2598        }
2599        if let Some(item) = &self.value_set {
2600            super::super::codec::element_entry(&mut map, "_valueSet", item)?;
2601        }
2602        if let Some(item) = &self.code {
2603            super::super::codec::value_entry(&mut map, "code", item)?;
2604        }
2605        if let Some(item) = &self.display {
2606            super::super::codec::value_entry(&mut map, "display", item)?;
2607        }
2608        if !self.extension.is_empty() {
2609            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
2610        }
2611        if let Some(v) = &self.id {
2612            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
2613        }
2614        if !self.modifier_extension.is_empty() {
2615            serde::ser::SerializeMap::serialize_entry(
2616                &mut map,
2617                "modifierExtension",
2618                &self.modifier_extension,
2619            )?;
2620        }
2621        if let Some(item) = &self.no_map {
2622            super::super::codec::value_entry(&mut map, "noMap", item)?;
2623        }
2624        if !self.target.is_empty() {
2625            serde::ser::SerializeMap::serialize_entry(&mut map, "target", &self.target)?;
2626        }
2627        if let Some(item) = &self.value_set {
2628            super::super::codec::value_entry(&mut map, "valueSet", item)?;
2629        }
2630        serde::ser::SerializeMap::end(map)
2631    }
2632}
2633
2634impl<'de> serde::Deserialize<'de> for ConceptMapGroupElement {
2635    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2636        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
2637        let mut path = super::super::codec::Path::root("ConceptMapGroupElement");
2638        let object =
2639            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
2640        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
2641    }
2642}
2643
2644/// Concept in target system for element
2645///
2646/// A concept from the target value set that this concept maps to.
2647#[derive(Debug, Clone, Default, PartialEq, Eq)]
2648pub struct ConceptMapGroupElementTarget {
2649    /// Unique id for inter-element referencing
2650    ///
2651    /// Unique id for the element within a resource (for internal references). This
2652    /// may be any string value that does not contain spaces.
2653    pub id: Option<std::string::String>,
2654    /// Additional content defined by implementations
2655    ///
2656    /// May be used to represent additional information that is not part of the
2657    /// basic definition of the element. To make the use of extensions safe and
2658    /// managable, there is a strict set of governance applied to the definition and
2659    /// use of extensions. Though any implementer can define an extension, there is
2660    /// a set of requirements that SHALL be met as part of the definition of the
2661    /// extension.
2662    pub extension: Vec<super::extension::Extension>,
2663    /// Extensions that cannot be ignored even if unrecognized
2664    ///
2665    /// May be used to represent additional information that is not part of the
2666    /// basic definition of the element and that modifies the understanding of the
2667    /// element in which it is contained and/or the understanding of the containing
2668    /// element's descendants. Usually modifier elements provide negation or
2669    /// qualification. To make the use of extensions safe and managable, there is a
2670    /// strict set of governance applied to the definition and use of extensions.
2671    /// Though any implementer can define an extension, there is a set of
2672    /// requirements that SHALL be met as part of the definition of the extension.
2673    /// Applications processing a resource are required to check for modifier
2674    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
2675    /// on Resource or DomainResource (including cannot change the meaning of
2676    /// modifierExtension itself).
2677    pub modifier_extension: Vec<super::extension::Extension>,
2678    /// Code that identifies the target element
2679    ///
2680    /// Identity (code or path) or the element/item that the map refers to.
2681    pub code: Option<super::primitives::Code>,
2682    /// Display for the code
2683    ///
2684    /// The display for the code. The display is only provided to help editors when
2685    /// editing the concept map.
2686    pub display: Option<super::primitives::String>,
2687    /// Identifies the set of target concepts
2688    ///
2689    /// The set of concepts from the ConceptMap.group.target code system which are
2690    /// all being mapped to as part of this mapping rule. The effect of using this
2691    /// data element is the same as having multiple ConceptMap.group.element.target
2692    /// elements with one for each concept in the
2693    /// ConceptMap.group.element.target.valueSet value set.
2694    pub value_set: Option<super::primitives::Canonical>,
2695    /// related-to | equivalent | source-is-narrower-than-target |
2696    /// source-is-broader-than-target | not-related-to
2697    ///
2698    /// The relationship between the source and target concepts. The relationship is
2699    /// read from source to target (e.g. source-is-narrower-than-target).
2700    pub relationship: super::primitives::Code,
2701    /// Description of status/issues in mapping
2702    ///
2703    /// A description of status/issues in mapping that conveys additional
2704    /// information not represented in the structured data.
2705    pub comment: Option<super::primitives::String>,
2706    /// Property value for the source -\> target mapping
2707    ///
2708    /// A property value for this source -\> target mapping.
2709    pub property: Vec<ConceptMapGroupElementTargetProperty>,
2710    /// Other properties required for this mapping
2711    ///
2712    /// A set of additional dependencies for this mapping to hold. This mapping is
2713    /// only applicable if the specified data attribute can be resolved, and it has
2714    /// the specified value.
2715    pub depends_on: Vec<ConceptMapGroupElementTargetDependsOn>,
2716    /// Other data elements that this mapping also produces
2717    ///
2718    /// Product is the output of a ConceptMap that provides additional values that
2719    /// go in other attributes / data elemnts of the target data.
2720    pub product: Vec<ConceptMapGroupElementTargetDependsOn>,
2721}
2722
2723impl super::super::codec::Json for ConceptMapGroupElementTarget {
2724    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
2725        let mut object = super::super::codec::Object::new();
2726        if let Some(v) = &self.id {
2727            object.insert(
2728                std::string::String::from("id"),
2729                super::super::codec::Value::String(v.clone()),
2730            );
2731        }
2732        if !self.extension.is_empty() {
2733            let mut items = Vec::with_capacity(self.extension.len());
2734            for item in &self.extension {
2735                items.push(super::super::codec::Value::Object(
2736                    super::super::codec::Json::to_json(item)?,
2737                ));
2738            }
2739            object.insert(
2740                std::string::String::from("extension"),
2741                super::super::codec::Value::Array(items),
2742            );
2743        }
2744        if !self.modifier_extension.is_empty() {
2745            let mut items = Vec::with_capacity(self.modifier_extension.len());
2746            for item in &self.modifier_extension {
2747                items.push(super::super::codec::Value::Object(
2748                    super::super::codec::Json::to_json(item)?,
2749                ));
2750            }
2751            object.insert(
2752                std::string::String::from("modifierExtension"),
2753                super::super::codec::Value::Array(items),
2754            );
2755        }
2756        if let Some(item) = &self.code {
2757            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2758                object.insert(std::string::String::from("code"), v);
2759            }
2760            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2761                object.insert(std::string::String::from("_code"), e);
2762            }
2763        }
2764        if let Some(item) = &self.display {
2765            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2766                object.insert(std::string::String::from("display"), v);
2767            }
2768            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2769                object.insert(std::string::String::from("_display"), e);
2770            }
2771        }
2772        if let Some(item) = &self.value_set {
2773            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2774                object.insert(std::string::String::from("valueSet"), v);
2775            }
2776            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2777                object.insert(std::string::String::from("_valueSet"), e);
2778            }
2779        }
2780        if let Some(v) = super::super::codec::Primitive::value_json(&self.relationship)? {
2781            object.insert(std::string::String::from("relationship"), v);
2782        }
2783        if let Some(e) = super::super::codec::Primitive::element_json(&self.relationship)? {
2784            object.insert(std::string::String::from("_relationship"), e);
2785        }
2786        if let Some(item) = &self.comment {
2787            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
2788                object.insert(std::string::String::from("comment"), v);
2789            }
2790            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
2791                object.insert(std::string::String::from("_comment"), e);
2792            }
2793        }
2794        if !self.property.is_empty() {
2795            let mut items = Vec::with_capacity(self.property.len());
2796            for item in &self.property {
2797                items.push(super::super::codec::Value::Object(
2798                    super::super::codec::Json::to_json(item)?,
2799                ));
2800            }
2801            object.insert(
2802                std::string::String::from("property"),
2803                super::super::codec::Value::Array(items),
2804            );
2805        }
2806        if !self.depends_on.is_empty() {
2807            let mut items = Vec::with_capacity(self.depends_on.len());
2808            for item in &self.depends_on {
2809                items.push(super::super::codec::Value::Object(
2810                    super::super::codec::Json::to_json(item)?,
2811                ));
2812            }
2813            object.insert(
2814                std::string::String::from("dependsOn"),
2815                super::super::codec::Value::Array(items),
2816            );
2817        }
2818        if !self.product.is_empty() {
2819            let mut items = Vec::with_capacity(self.product.len());
2820            for item in &self.product {
2821                items.push(super::super::codec::Value::Object(
2822                    super::super::codec::Json::to_json(item)?,
2823                ));
2824            }
2825            object.insert(
2826                std::string::String::from("product"),
2827                super::super::codec::Value::Array(items),
2828            );
2829        }
2830        Ok(object)
2831    }
2832
2833    fn from_json(
2834        object: &super::super::codec::Object,
2835        path: &mut super::super::codec::Path,
2836    ) -> Result<Self, super::super::codec::DecodeError> {
2837        let mut raw_id: Option<&super::super::codec::Value> = None;
2838        let mut raw_extension: Option<&super::super::codec::Value> = None;
2839        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
2840        let mut raw_code: Option<&super::super::codec::Value> = None;
2841        let mut raw_code_element: Option<&super::super::codec::Value> = None;
2842        let mut raw_display: Option<&super::super::codec::Value> = None;
2843        let mut raw_display_element: Option<&super::super::codec::Value> = None;
2844        let mut raw_value_set: Option<&super::super::codec::Value> = None;
2845        let mut raw_value_set_element: Option<&super::super::codec::Value> = None;
2846        let mut raw_relationship: Option<&super::super::codec::Value> = None;
2847        let mut raw_relationship_element: Option<&super::super::codec::Value> = None;
2848        let mut raw_comment: Option<&super::super::codec::Value> = None;
2849        let mut raw_comment_element: Option<&super::super::codec::Value> = None;
2850        let mut raw_property: Option<&super::super::codec::Value> = None;
2851        let mut raw_depends_on: Option<&super::super::codec::Value> = None;
2852        let mut raw_product: Option<&super::super::codec::Value> = None;
2853        for (key, value) in object {
2854            match key.as_str() {
2855                "id" => {
2856                    raw_id = Some(value);
2857                }
2858                "extension" => {
2859                    raw_extension = Some(value);
2860                }
2861                "modifierExtension" => {
2862                    raw_modifier_extension = Some(value);
2863                }
2864                "code" => {
2865                    raw_code = Some(value);
2866                }
2867                "_code" => {
2868                    raw_code_element = Some(value);
2869                }
2870                "display" => {
2871                    raw_display = Some(value);
2872                }
2873                "_display" => {
2874                    raw_display_element = Some(value);
2875                }
2876                "valueSet" => {
2877                    raw_value_set = Some(value);
2878                }
2879                "_valueSet" => {
2880                    raw_value_set_element = Some(value);
2881                }
2882                "relationship" => {
2883                    raw_relationship = Some(value);
2884                }
2885                "_relationship" => {
2886                    raw_relationship_element = Some(value);
2887                }
2888                "comment" => {
2889                    raw_comment = Some(value);
2890                }
2891                "_comment" => {
2892                    raw_comment_element = Some(value);
2893                }
2894                "property" => {
2895                    raw_property = Some(value);
2896                }
2897                "dependsOn" => {
2898                    raw_depends_on = Some(value);
2899                }
2900                "product" => {
2901                    raw_product = Some(value);
2902                }
2903                other => {
2904                    return path.with(other, |path| {
2905                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
2906                    });
2907                }
2908            }
2909        }
2910        let field_id = raw_id
2911            .map(|value| {
2912                path.with("id", |path| {
2913                    let value = super::super::codec::expect_single(value, path)?;
2914                    super::primitives::checked_string(
2915                        super::super::codec::expect_string(value, path)?,
2916                        path,
2917                    )
2918                })
2919            })
2920            .transpose()?;
2921        let mut field_extension = Vec::new();
2922        if let Some(raw) = raw_extension {
2923            for (index, value) in path
2924                .with("extension", |path| {
2925                    super::super::codec::expect_array(raw, path)
2926                })?
2927                .iter()
2928                .enumerate()
2929            {
2930                field_extension.push(path.with_index("extension", index, |path| {
2931                    super::super::codec::Json::from_json(
2932                        super::super::codec::expect_object(value, path)?,
2933                        path,
2934                    )
2935                })?);
2936            }
2937        }
2938        let mut field_modifier_extension = Vec::new();
2939        if let Some(raw) = raw_modifier_extension {
2940            for (index, value) in path
2941                .with("modifierExtension", |path| {
2942                    super::super::codec::expect_array(raw, path)
2943                })?
2944                .iter()
2945                .enumerate()
2946            {
2947                field_modifier_extension.push(path.with_index(
2948                    "modifierExtension",
2949                    index,
2950                    |path| {
2951                        super::super::codec::Json::from_json(
2952                            super::super::codec::expect_object(value, path)?,
2953                            path,
2954                        )
2955                    },
2956                )?);
2957            }
2958        }
2959        let field_code = match (raw_code, raw_code_element) {
2960            (None, None) => None,
2961            (value, element) => Some(path.with("code", |path| {
2962                super::super::codec::Primitive::from_json_parts(value, element, path)
2963            })?),
2964        };
2965        let field_display = match (raw_display, raw_display_element) {
2966            (None, None) => None,
2967            (value, element) => Some(path.with("display", |path| {
2968                super::super::codec::Primitive::from_json_parts(value, element, path)
2969            })?),
2970        };
2971        let field_value_set = match (raw_value_set, raw_value_set_element) {
2972            (None, None) => None,
2973            (value, element) => Some(path.with("valueSet", |path| {
2974                super::super::codec::Primitive::from_json_parts(value, element, path)
2975            })?),
2976        };
2977        let field_relationship = path.with("relationship", |path| {
2978            super::super::codec::Primitive::from_json_parts(
2979                raw_relationship,
2980                raw_relationship_element,
2981                path,
2982            )
2983        })?;
2984        let field_comment = match (raw_comment, raw_comment_element) {
2985            (None, None) => None,
2986            (value, element) => Some(path.with("comment", |path| {
2987                super::super::codec::Primitive::from_json_parts(value, element, path)
2988            })?),
2989        };
2990        let mut field_property = Vec::new();
2991        if let Some(raw) = raw_property {
2992            for (index, value) in path
2993                .with("property", |path| {
2994                    super::super::codec::expect_array(raw, path)
2995                })?
2996                .iter()
2997                .enumerate()
2998            {
2999                field_property.push(path.with_index("property", index, |path| {
3000                    super::super::codec::Json::from_json(
3001                        super::super::codec::expect_object(value, path)?,
3002                        path,
3003                    )
3004                })?);
3005            }
3006        }
3007        let mut field_depends_on = Vec::new();
3008        if let Some(raw) = raw_depends_on {
3009            for (index, value) in path
3010                .with("dependsOn", |path| {
3011                    super::super::codec::expect_array(raw, path)
3012                })?
3013                .iter()
3014                .enumerate()
3015            {
3016                field_depends_on.push(path.with_index("dependsOn", index, |path| {
3017                    super::super::codec::Json::from_json(
3018                        super::super::codec::expect_object(value, path)?,
3019                        path,
3020                    )
3021                })?);
3022            }
3023        }
3024        let mut field_product = Vec::new();
3025        if let Some(raw) = raw_product {
3026            for (index, value) in path
3027                .with("product", |path| {
3028                    super::super::codec::expect_array(raw, path)
3029                })?
3030                .iter()
3031                .enumerate()
3032            {
3033                field_product.push(path.with_index("product", index, |path| {
3034                    super::super::codec::Json::from_json(
3035                        super::super::codec::expect_object(value, path)?,
3036                        path,
3037                    )
3038                })?);
3039            }
3040        }
3041        Ok(Self {
3042            id: field_id,
3043            extension: field_extension,
3044            modifier_extension: field_modifier_extension,
3045            code: field_code,
3046            display: field_display,
3047            value_set: field_value_set,
3048            relationship: field_relationship,
3049            comment: field_comment,
3050            property: field_property,
3051            depends_on: field_depends_on,
3052            product: field_product,
3053        })
3054    }
3055}
3056
3057impl serde::Serialize for ConceptMapGroupElementTarget {
3058    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3059        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3060        if let Some(item) = &self.code {
3061            super::super::codec::element_entry(&mut map, "_code", item)?;
3062        }
3063        if let Some(item) = &self.comment {
3064            super::super::codec::element_entry(&mut map, "_comment", item)?;
3065        }
3066        if let Some(item) = &self.display {
3067            super::super::codec::element_entry(&mut map, "_display", item)?;
3068        }
3069        super::super::codec::element_entry(&mut map, "_relationship", &self.relationship)?;
3070        if let Some(item) = &self.value_set {
3071            super::super::codec::element_entry(&mut map, "_valueSet", item)?;
3072        }
3073        if let Some(item) = &self.code {
3074            super::super::codec::value_entry(&mut map, "code", item)?;
3075        }
3076        if let Some(item) = &self.comment {
3077            super::super::codec::value_entry(&mut map, "comment", item)?;
3078        }
3079        if !self.depends_on.is_empty() {
3080            serde::ser::SerializeMap::serialize_entry(&mut map, "dependsOn", &self.depends_on)?;
3081        }
3082        if let Some(item) = &self.display {
3083            super::super::codec::value_entry(&mut map, "display", item)?;
3084        }
3085        if !self.extension.is_empty() {
3086            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3087        }
3088        if let Some(v) = &self.id {
3089            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3090        }
3091        if !self.modifier_extension.is_empty() {
3092            serde::ser::SerializeMap::serialize_entry(
3093                &mut map,
3094                "modifierExtension",
3095                &self.modifier_extension,
3096            )?;
3097        }
3098        if !self.product.is_empty() {
3099            serde::ser::SerializeMap::serialize_entry(&mut map, "product", &self.product)?;
3100        }
3101        if !self.property.is_empty() {
3102            serde::ser::SerializeMap::serialize_entry(&mut map, "property", &self.property)?;
3103        }
3104        super::super::codec::value_entry(&mut map, "relationship", &self.relationship)?;
3105        if let Some(item) = &self.value_set {
3106            super::super::codec::value_entry(&mut map, "valueSet", item)?;
3107        }
3108        serde::ser::SerializeMap::end(map)
3109    }
3110}
3111
3112impl<'de> serde::Deserialize<'de> for ConceptMapGroupElementTarget {
3113    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3114        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3115        let mut path = super::super::codec::Path::root("ConceptMapGroupElementTarget");
3116        let object =
3117            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3118        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3119    }
3120}
3121
3122/// Other properties required for this mapping
3123///
3124/// A set of additional dependencies for this mapping to hold. This mapping is
3125/// only applicable if the specified data attribute can be resolved, and it has
3126/// the specified value.
3127#[derive(Debug, Clone, Default, PartialEq, Eq)]
3128pub struct ConceptMapGroupElementTargetDependsOn {
3129    /// Unique id for inter-element referencing
3130    ///
3131    /// Unique id for the element within a resource (for internal references). This
3132    /// may be any string value that does not contain spaces.
3133    pub id: Option<std::string::String>,
3134    /// Additional content defined by implementations
3135    ///
3136    /// May be used to represent additional information that is not part of the
3137    /// basic definition of the element. To make the use of extensions safe and
3138    /// managable, there is a strict set of governance applied to the definition and
3139    /// use of extensions. Though any implementer can define an extension, there is
3140    /// a set of requirements that SHALL be met as part of the definition of the
3141    /// extension.
3142    pub extension: Vec<super::extension::Extension>,
3143    /// Extensions that cannot be ignored even if unrecognized
3144    ///
3145    /// May be used to represent additional information that is not part of the
3146    /// basic definition of the element and that modifies the understanding of the
3147    /// element in which it is contained and/or the understanding of the containing
3148    /// element's descendants. Usually modifier elements provide negation or
3149    /// qualification. To make the use of extensions safe and managable, there is a
3150    /// strict set of governance applied to the definition and use of extensions.
3151    /// Though any implementer can define an extension, there is a set of
3152    /// requirements that SHALL be met as part of the definition of the extension.
3153    /// Applications processing a resource are required to check for modifier
3154    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3155    /// on Resource or DomainResource (including cannot change the meaning of
3156    /// modifierExtension itself).
3157    pub modifier_extension: Vec<super::extension::Extension>,
3158    /// A reference to a mapping attribute defined in ConceptMap.additionalAttribute
3159    ///
3160    /// A reference to the additional attribute that holds a value the map depends
3161    /// on.
3162    pub attribute: super::primitives::Code,
3163    /// Value of the referenced data element
3164    ///
3165    /// Data element value that the map depends on / produces.
3166    pub value: Option<ConceptMapGroupElementTargetDependsOnValue>,
3167    /// The mapping depends on a data element with a value from this value set
3168    ///
3169    /// This mapping applies if the data element value is a code from this value
3170    /// set.
3171    pub value_set: Option<super::primitives::Canonical>,
3172}
3173
3174impl super::super::codec::Json for ConceptMapGroupElementTargetDependsOn {
3175    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3176        let mut object = super::super::codec::Object::new();
3177        if let Some(v) = &self.id {
3178            object.insert(
3179                std::string::String::from("id"),
3180                super::super::codec::Value::String(v.clone()),
3181            );
3182        }
3183        if !self.extension.is_empty() {
3184            let mut items = Vec::with_capacity(self.extension.len());
3185            for item in &self.extension {
3186                items.push(super::super::codec::Value::Object(
3187                    super::super::codec::Json::to_json(item)?,
3188                ));
3189            }
3190            object.insert(
3191                std::string::String::from("extension"),
3192                super::super::codec::Value::Array(items),
3193            );
3194        }
3195        if !self.modifier_extension.is_empty() {
3196            let mut items = Vec::with_capacity(self.modifier_extension.len());
3197            for item in &self.modifier_extension {
3198                items.push(super::super::codec::Value::Object(
3199                    super::super::codec::Json::to_json(item)?,
3200                ));
3201            }
3202            object.insert(
3203                std::string::String::from("modifierExtension"),
3204                super::super::codec::Value::Array(items),
3205            );
3206        }
3207        if let Some(v) = super::super::codec::Primitive::value_json(&self.attribute)? {
3208            object.insert(std::string::String::from("attribute"), v);
3209        }
3210        if let Some(e) = super::super::codec::Primitive::element_json(&self.attribute)? {
3211            object.insert(std::string::String::from("_attribute"), e);
3212        }
3213        if let Some(item) = &self.value {
3214            let (suffix, value, element) = item.to_json_parts()?;
3215            if let Some(value) = value {
3216                object.insert(format!("value{suffix}"), value);
3217            }
3218            if let Some(element) = element {
3219                object.insert(format!("_value{suffix}"), element);
3220            }
3221        }
3222        if let Some(item) = &self.value_set {
3223            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
3224                object.insert(std::string::String::from("valueSet"), v);
3225            }
3226            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
3227                object.insert(std::string::String::from("_valueSet"), e);
3228            }
3229        }
3230        Ok(object)
3231    }
3232
3233    fn from_json(
3234        object: &super::super::codec::Object,
3235        path: &mut super::super::codec::Path,
3236    ) -> Result<Self, super::super::codec::DecodeError> {
3237        let mut raw_id: Option<&super::super::codec::Value> = None;
3238        let mut raw_extension: Option<&super::super::codec::Value> = None;
3239        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3240        let mut raw_attribute: Option<&super::super::codec::Value> = None;
3241        let mut raw_attribute_element: Option<&super::super::codec::Value> = None;
3242        let mut raw_value = super::super::codec::ChoiceSlot::default();
3243        let mut raw_value_set: Option<&super::super::codec::Value> = None;
3244        let mut raw_value_set_element: Option<&super::super::codec::Value> = None;
3245        for (key, value) in object {
3246            match key.as_str() {
3247                "id" => {
3248                    raw_id = Some(value);
3249                }
3250                "extension" => {
3251                    raw_extension = Some(value);
3252                }
3253                "modifierExtension" => {
3254                    raw_modifier_extension = Some(value);
3255                }
3256                "attribute" => {
3257                    raw_attribute = Some(value);
3258                }
3259                "_attribute" => {
3260                    raw_attribute_element = Some(value);
3261                }
3262                "valueCode" => {
3263                    raw_value.value("Code", value, path)?;
3264                }
3265                "_valueCode" => {
3266                    raw_value.element("Code", value, path)?;
3267                }
3268                "valueCoding" => {
3269                    raw_value.value("Coding", value, path)?;
3270                }
3271                "_valueCoding" => {
3272                    raw_value.element("Coding", value, path)?;
3273                }
3274                "valueString" => {
3275                    raw_value.value("String", value, path)?;
3276                }
3277                "_valueString" => {
3278                    raw_value.element("String", value, path)?;
3279                }
3280                "valueBoolean" => {
3281                    raw_value.value("Boolean", value, path)?;
3282                }
3283                "_valueBoolean" => {
3284                    raw_value.element("Boolean", value, path)?;
3285                }
3286                "valueQuantity" => {
3287                    raw_value.value("Quantity", value, path)?;
3288                }
3289                "_valueQuantity" => {
3290                    raw_value.element("Quantity", value, path)?;
3291                }
3292                "valueSet" => {
3293                    raw_value_set = Some(value);
3294                }
3295                "_valueSet" => {
3296                    raw_value_set_element = Some(value);
3297                }
3298                other => {
3299                    return path.with(other, |path| {
3300                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3301                    });
3302                }
3303            }
3304        }
3305        let field_id = raw_id
3306            .map(|value| {
3307                path.with("id", |path| {
3308                    let value = super::super::codec::expect_single(value, path)?;
3309                    super::primitives::checked_string(
3310                        super::super::codec::expect_string(value, path)?,
3311                        path,
3312                    )
3313                })
3314            })
3315            .transpose()?;
3316        let mut field_extension = Vec::new();
3317        if let Some(raw) = raw_extension {
3318            for (index, value) in path
3319                .with("extension", |path| {
3320                    super::super::codec::expect_array(raw, path)
3321                })?
3322                .iter()
3323                .enumerate()
3324            {
3325                field_extension.push(path.with_index("extension", index, |path| {
3326                    super::super::codec::Json::from_json(
3327                        super::super::codec::expect_object(value, path)?,
3328                        path,
3329                    )
3330                })?);
3331            }
3332        }
3333        let mut field_modifier_extension = Vec::new();
3334        if let Some(raw) = raw_modifier_extension {
3335            for (index, value) in path
3336                .with("modifierExtension", |path| {
3337                    super::super::codec::expect_array(raw, path)
3338                })?
3339                .iter()
3340                .enumerate()
3341            {
3342                field_modifier_extension.push(path.with_index(
3343                    "modifierExtension",
3344                    index,
3345                    |path| {
3346                        super::super::codec::Json::from_json(
3347                            super::super::codec::expect_object(value, path)?,
3348                            path,
3349                        )
3350                    },
3351                )?);
3352            }
3353        }
3354        let field_attribute = path.with("attribute", |path| {
3355            super::super::codec::Primitive::from_json_parts(
3356                raw_attribute,
3357                raw_attribute_element,
3358                path,
3359            )
3360        })?;
3361        let field_value = match raw_value.suffix {
3362            None => None,
3363            Some(suffix) => Some(path.with("value", |path| {
3364                ConceptMapGroupElementTargetDependsOnValue::from_json_parts(
3365                    suffix,
3366                    raw_value.value,
3367                    raw_value.element,
3368                    path,
3369                )
3370            })?),
3371        };
3372        let field_value_set = match (raw_value_set, raw_value_set_element) {
3373            (None, None) => None,
3374            (value, element) => Some(path.with("valueSet", |path| {
3375                super::super::codec::Primitive::from_json_parts(value, element, path)
3376            })?),
3377        };
3378        Ok(Self {
3379            id: field_id,
3380            extension: field_extension,
3381            modifier_extension: field_modifier_extension,
3382            attribute: field_attribute,
3383            value: field_value,
3384            value_set: field_value_set,
3385        })
3386    }
3387}
3388
3389impl serde::Serialize for ConceptMapGroupElementTargetDependsOn {
3390    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3391        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3392        super::super::codec::element_entry(&mut map, "_attribute", &self.attribute)?;
3393        match &self.value {
3394            Some(ConceptMapGroupElementTargetDependsOnValue::Boolean(inner)) => {
3395                super::super::codec::element_entry(&mut map, "_valueBoolean", inner)?;
3396            }
3397            Some(ConceptMapGroupElementTargetDependsOnValue::Code(inner)) => {
3398                super::super::codec::element_entry(&mut map, "_valueCode", inner)?;
3399            }
3400            _ => {}
3401        }
3402        if let Some(item) = &self.value_set {
3403            super::super::codec::element_entry(&mut map, "_valueSet", item)?;
3404        }
3405        if let Some(ConceptMapGroupElementTargetDependsOnValue::String(inner)) = &self.value {
3406            super::super::codec::element_entry(&mut map, "_valueString", inner)?;
3407        }
3408        super::super::codec::value_entry(&mut map, "attribute", &self.attribute)?;
3409        if !self.extension.is_empty() {
3410            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3411        }
3412        if let Some(v) = &self.id {
3413            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3414        }
3415        if !self.modifier_extension.is_empty() {
3416            serde::ser::SerializeMap::serialize_entry(
3417                &mut map,
3418                "modifierExtension",
3419                &self.modifier_extension,
3420            )?;
3421        }
3422        match &self.value {
3423            Some(ConceptMapGroupElementTargetDependsOnValue::Boolean(inner)) => {
3424                super::super::codec::value_entry(&mut map, "valueBoolean", inner)?;
3425            }
3426            Some(ConceptMapGroupElementTargetDependsOnValue::Code(inner)) => {
3427                super::super::codec::value_entry(&mut map, "valueCode", inner)?;
3428            }
3429            Some(ConceptMapGroupElementTargetDependsOnValue::Coding(inner)) => {
3430                serde::ser::SerializeMap::serialize_entry(&mut map, "valueCoding", inner.as_ref())?;
3431            }
3432            Some(ConceptMapGroupElementTargetDependsOnValue::Quantity(inner)) => {
3433                serde::ser::SerializeMap::serialize_entry(
3434                    &mut map,
3435                    "valueQuantity",
3436                    inner.as_ref(),
3437                )?;
3438            }
3439            _ => {}
3440        }
3441        if let Some(item) = &self.value_set {
3442            super::super::codec::value_entry(&mut map, "valueSet", item)?;
3443        }
3444        if let Some(ConceptMapGroupElementTargetDependsOnValue::String(inner)) = &self.value {
3445            super::super::codec::value_entry(&mut map, "valueString", inner)?;
3446        }
3447        serde::ser::SerializeMap::end(map)
3448    }
3449}
3450
3451impl<'de> serde::Deserialize<'de> for ConceptMapGroupElementTargetDependsOn {
3452    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3453        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3454        let mut path = super::super::codec::Path::root("ConceptMapGroupElementTargetDependsOn");
3455        let object =
3456            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3457        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3458    }
3459}
3460
3461/// The \`value\[x\]\` choice of \`ConceptMapGroupElementTargetDependsOn\`.
3462///
3463/// Data element value that the map depends on / produces.
3464#[derive(Debug, Clone, PartialEq, Eq)]
3465pub enum ConceptMapGroupElementTargetDependsOnValue {
3466    /// The `code` form.
3467    Code(super::primitives::Code),
3468    /// The `Coding` form.
3469    Coding(Box<super::coding::Coding>),
3470    /// The `string` form.
3471    String(super::primitives::String),
3472    /// The `boolean` form.
3473    Boolean(super::primitives::Boolean),
3474    /// The `Quantity` form.
3475    Quantity(Box<super::quantity::Quantity>),
3476}
3477
3478impl ConceptMapGroupElementTargetDependsOnValue {
3479    /// The key suffix, the value part, and the `_name` part of this form.
3480    ///
3481    /// # Errors
3482    ///
3483    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
3484    pub fn to_json_parts(
3485        &self,
3486    ) -> Result<
3487        (
3488            &'static str,
3489            Option<super::super::codec::Value>,
3490            Option<super::super::codec::Value>,
3491        ),
3492        super::super::codec::EncodeError,
3493    > {
3494        match self {
3495            Self::Code(inner) => Ok((
3496                "Code",
3497                super::super::codec::Primitive::value_json(inner)?,
3498                super::super::codec::Primitive::element_json(inner)?,
3499            )),
3500            Self::Coding(inner) => Ok((
3501                "Coding",
3502                Some(super::super::codec::Value::Object(
3503                    super::super::codec::Json::to_json(inner.as_ref())?,
3504                )),
3505                None,
3506            )),
3507            Self::String(inner) => Ok((
3508                "String",
3509                super::super::codec::Primitive::value_json(inner)?,
3510                super::super::codec::Primitive::element_json(inner)?,
3511            )),
3512            Self::Boolean(inner) => Ok((
3513                "Boolean",
3514                super::super::codec::Primitive::value_json(inner)?,
3515                super::super::codec::Primitive::element_json(inner)?,
3516            )),
3517            Self::Quantity(inner) => Ok((
3518                "Quantity",
3519                Some(super::super::codec::Value::Object(
3520                    super::super::codec::Json::to_json(inner.as_ref())?,
3521                )),
3522                None,
3523            )),
3524        }
3525    }
3526
3527    /// Decodes the form named by `suffix` from its value and `_name` parts.
3528    ///
3529    /// # Errors
3530    ///
3531    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
3532    pub fn from_json_parts(
3533        suffix: &str,
3534        value: Option<&super::super::codec::Value>,
3535        element: Option<&super::super::codec::Value>,
3536        path: &mut super::super::codec::Path,
3537    ) -> Result<Self, super::super::codec::DecodeError> {
3538        match suffix {
3539            "Code" => Ok(Self::Code(super::super::codec::Primitive::from_json_parts(
3540                value, element, path,
3541            )?)),
3542            "Coding" => {
3543                if element.is_some() {
3544                    return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
3545                        expected: "no underscore form for a complex type",
3546                    }));
3547                }
3548                let value = value.ok_or_else(|| {
3549                    path.error(super::super::codec::DecodeErrorKind::MissingProperty)
3550                })?;
3551                let inner = super::super::codec::Json::from_json(
3552                    super::super::codec::expect_object(
3553                        super::super::codec::expect_single(value, path)?,
3554                        path,
3555                    )?,
3556                    path,
3557                )?;
3558                Ok(Self::Coding(Box::new(inner)))
3559            }
3560            "String" => Ok(Self::String(
3561                super::super::codec::Primitive::from_json_parts(value, element, path)?,
3562            )),
3563            "Boolean" => Ok(Self::Boolean(
3564                super::super::codec::Primitive::from_json_parts(value, element, path)?,
3565            )),
3566            "Quantity" => {
3567                if element.is_some() {
3568                    return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
3569                        expected: "no underscore form for a complex type",
3570                    }));
3571                }
3572                let value = value.ok_or_else(|| {
3573                    path.error(super::super::codec::DecodeErrorKind::MissingProperty)
3574                })?;
3575                let inner = super::super::codec::Json::from_json(
3576                    super::super::codec::expect_object(
3577                        super::super::codec::expect_single(value, path)?,
3578                        path,
3579                    )?,
3580                    path,
3581                )?;
3582                Ok(Self::Quantity(Box::new(inner)))
3583            }
3584            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
3585        }
3586    }
3587}
3588
3589/// Property value for the source -\> target mapping
3590///
3591/// A property value for this source -\> target mapping.
3592#[derive(Debug, Clone, PartialEq, Eq)]
3593pub struct ConceptMapGroupElementTargetProperty {
3594    /// Unique id for inter-element referencing
3595    ///
3596    /// Unique id for the element within a resource (for internal references). This
3597    /// may be any string value that does not contain spaces.
3598    pub id: Option<std::string::String>,
3599    /// Additional content defined by implementations
3600    ///
3601    /// May be used to represent additional information that is not part of the
3602    /// basic definition of the element. To make the use of extensions safe and
3603    /// managable, there is a strict set of governance applied to the definition and
3604    /// use of extensions. Though any implementer can define an extension, there is
3605    /// a set of requirements that SHALL be met as part of the definition of the
3606    /// extension.
3607    pub extension: Vec<super::extension::Extension>,
3608    /// Extensions that cannot be ignored even if unrecognized
3609    ///
3610    /// May be used to represent additional information that is not part of the
3611    /// basic definition of the element and that modifies the understanding of the
3612    /// element in which it is contained and/or the understanding of the containing
3613    /// element's descendants. Usually modifier elements provide negation or
3614    /// qualification. To make the use of extensions safe and managable, there is a
3615    /// strict set of governance applied to the definition and use of extensions.
3616    /// Though any implementer can define an extension, there is a set of
3617    /// requirements that SHALL be met as part of the definition of the extension.
3618    /// Applications processing a resource are required to check for modifier
3619    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
3620    /// on Resource or DomainResource (including cannot change the meaning of
3621    /// modifierExtension itself).
3622    pub modifier_extension: Vec<super::extension::Extension>,
3623    /// Reference to ConceptMap.property.code
3624    ///
3625    /// A reference to a mapping property defined in ConceptMap.property.
3626    pub code: super::primitives::Code,
3627    /// Value of the property for this concept
3628    ///
3629    /// The value of this property. If the type chosen for this element is 'code',
3630    /// then the property SHALL be defined in a ConceptMap.property element.
3631    pub value: ConceptMapGroupElementTargetPropertyValue,
3632}
3633
3634impl super::super::codec::Json for ConceptMapGroupElementTargetProperty {
3635    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
3636        let mut object = super::super::codec::Object::new();
3637        if let Some(v) = &self.id {
3638            object.insert(
3639                std::string::String::from("id"),
3640                super::super::codec::Value::String(v.clone()),
3641            );
3642        }
3643        if !self.extension.is_empty() {
3644            let mut items = Vec::with_capacity(self.extension.len());
3645            for item in &self.extension {
3646                items.push(super::super::codec::Value::Object(
3647                    super::super::codec::Json::to_json(item)?,
3648                ));
3649            }
3650            object.insert(
3651                std::string::String::from("extension"),
3652                super::super::codec::Value::Array(items),
3653            );
3654        }
3655        if !self.modifier_extension.is_empty() {
3656            let mut items = Vec::with_capacity(self.modifier_extension.len());
3657            for item in &self.modifier_extension {
3658                items.push(super::super::codec::Value::Object(
3659                    super::super::codec::Json::to_json(item)?,
3660                ));
3661            }
3662            object.insert(
3663                std::string::String::from("modifierExtension"),
3664                super::super::codec::Value::Array(items),
3665            );
3666        }
3667        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
3668            object.insert(std::string::String::from("code"), v);
3669        }
3670        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
3671            object.insert(std::string::String::from("_code"), e);
3672        }
3673        let (suffix, value, element) = self.value.to_json_parts()?;
3674        if let Some(value) = value {
3675            object.insert(format!("value{suffix}"), value);
3676        }
3677        if let Some(element) = element {
3678            object.insert(format!("_value{suffix}"), element);
3679        }
3680        Ok(object)
3681    }
3682
3683    fn from_json(
3684        object: &super::super::codec::Object,
3685        path: &mut super::super::codec::Path,
3686    ) -> Result<Self, super::super::codec::DecodeError> {
3687        let mut raw_id: Option<&super::super::codec::Value> = None;
3688        let mut raw_extension: Option<&super::super::codec::Value> = None;
3689        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
3690        let mut raw_code: Option<&super::super::codec::Value> = None;
3691        let mut raw_code_element: Option<&super::super::codec::Value> = None;
3692        let mut raw_value = super::super::codec::ChoiceSlot::default();
3693        for (key, value) in object {
3694            match key.as_str() {
3695                "id" => {
3696                    raw_id = Some(value);
3697                }
3698                "extension" => {
3699                    raw_extension = Some(value);
3700                }
3701                "modifierExtension" => {
3702                    raw_modifier_extension = Some(value);
3703                }
3704                "code" => {
3705                    raw_code = Some(value);
3706                }
3707                "_code" => {
3708                    raw_code_element = Some(value);
3709                }
3710                "valueCoding" => {
3711                    raw_value.value("Coding", value, path)?;
3712                }
3713                "_valueCoding" => {
3714                    raw_value.element("Coding", value, path)?;
3715                }
3716                "valueString" => {
3717                    raw_value.value("String", value, path)?;
3718                }
3719                "_valueString" => {
3720                    raw_value.element("String", value, path)?;
3721                }
3722                "valueInteger" => {
3723                    raw_value.value("Integer", value, path)?;
3724                }
3725                "_valueInteger" => {
3726                    raw_value.element("Integer", value, path)?;
3727                }
3728                "valueBoolean" => {
3729                    raw_value.value("Boolean", value, path)?;
3730                }
3731                "_valueBoolean" => {
3732                    raw_value.element("Boolean", value, path)?;
3733                }
3734                "valueDateTime" => {
3735                    raw_value.value("DateTime", value, path)?;
3736                }
3737                "_valueDateTime" => {
3738                    raw_value.element("DateTime", value, path)?;
3739                }
3740                "valueDecimal" => {
3741                    raw_value.value("Decimal", value, path)?;
3742                }
3743                "_valueDecimal" => {
3744                    raw_value.element("Decimal", value, path)?;
3745                }
3746                "valueCode" => {
3747                    raw_value.value("Code", value, path)?;
3748                }
3749                "_valueCode" => {
3750                    raw_value.element("Code", value, path)?;
3751                }
3752                other => {
3753                    return path.with(other, |path| {
3754                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
3755                    });
3756                }
3757            }
3758        }
3759        let field_id = raw_id
3760            .map(|value| {
3761                path.with("id", |path| {
3762                    let value = super::super::codec::expect_single(value, path)?;
3763                    super::primitives::checked_string(
3764                        super::super::codec::expect_string(value, path)?,
3765                        path,
3766                    )
3767                })
3768            })
3769            .transpose()?;
3770        let mut field_extension = Vec::new();
3771        if let Some(raw) = raw_extension {
3772            for (index, value) in path
3773                .with("extension", |path| {
3774                    super::super::codec::expect_array(raw, path)
3775                })?
3776                .iter()
3777                .enumerate()
3778            {
3779                field_extension.push(path.with_index("extension", index, |path| {
3780                    super::super::codec::Json::from_json(
3781                        super::super::codec::expect_object(value, path)?,
3782                        path,
3783                    )
3784                })?);
3785            }
3786        }
3787        let mut field_modifier_extension = Vec::new();
3788        if let Some(raw) = raw_modifier_extension {
3789            for (index, value) in path
3790                .with("modifierExtension", |path| {
3791                    super::super::codec::expect_array(raw, path)
3792                })?
3793                .iter()
3794                .enumerate()
3795            {
3796                field_modifier_extension.push(path.with_index(
3797                    "modifierExtension",
3798                    index,
3799                    |path| {
3800                        super::super::codec::Json::from_json(
3801                            super::super::codec::expect_object(value, path)?,
3802                            path,
3803                        )
3804                    },
3805                )?);
3806            }
3807        }
3808        let field_code = path.with("code", |path| {
3809            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
3810        })?;
3811        let field_value = path.with("value", |path| {
3812            let suffix = raw_value
3813                .suffix
3814                .ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
3815            ConceptMapGroupElementTargetPropertyValue::from_json_parts(
3816                suffix,
3817                raw_value.value,
3818                raw_value.element,
3819                path,
3820            )
3821        })?;
3822        Ok(Self {
3823            id: field_id,
3824            extension: field_extension,
3825            modifier_extension: field_modifier_extension,
3826            code: field_code,
3827            value: field_value,
3828        })
3829    }
3830}
3831
3832impl serde::Serialize for ConceptMapGroupElementTargetProperty {
3833    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3834        let mut map = serde::Serializer::serialize_map(serializer, None)?;
3835        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
3836        match &self.value {
3837            ConceptMapGroupElementTargetPropertyValue::Boolean(inner) => {
3838                super::super::codec::element_entry(&mut map, "_valueBoolean", inner)?;
3839            }
3840            ConceptMapGroupElementTargetPropertyValue::Code(inner) => {
3841                super::super::codec::element_entry(&mut map, "_valueCode", inner)?;
3842            }
3843            ConceptMapGroupElementTargetPropertyValue::DateTime(inner) => {
3844                super::super::codec::element_entry(&mut map, "_valueDateTime", inner)?;
3845            }
3846            ConceptMapGroupElementTargetPropertyValue::Decimal(inner) => {
3847                super::super::codec::element_entry(&mut map, "_valueDecimal", inner)?;
3848            }
3849            ConceptMapGroupElementTargetPropertyValue::Integer(inner) => {
3850                super::super::codec::element_entry(&mut map, "_valueInteger", inner)?;
3851            }
3852            ConceptMapGroupElementTargetPropertyValue::String(inner) => {
3853                super::super::codec::element_entry(&mut map, "_valueString", inner)?;
3854            }
3855            ConceptMapGroupElementTargetPropertyValue::Coding(_) => {}
3856        }
3857        super::super::codec::value_entry(&mut map, "code", &self.code)?;
3858        if !self.extension.is_empty() {
3859            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
3860        }
3861        if let Some(v) = &self.id {
3862            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
3863        }
3864        if !self.modifier_extension.is_empty() {
3865            serde::ser::SerializeMap::serialize_entry(
3866                &mut map,
3867                "modifierExtension",
3868                &self.modifier_extension,
3869            )?;
3870        }
3871        match &self.value {
3872            ConceptMapGroupElementTargetPropertyValue::Boolean(inner) => {
3873                super::super::codec::value_entry(&mut map, "valueBoolean", inner)?;
3874            }
3875            ConceptMapGroupElementTargetPropertyValue::Code(inner) => {
3876                super::super::codec::value_entry(&mut map, "valueCode", inner)?;
3877            }
3878            ConceptMapGroupElementTargetPropertyValue::Coding(inner) => {
3879                serde::ser::SerializeMap::serialize_entry(&mut map, "valueCoding", inner.as_ref())?;
3880            }
3881            ConceptMapGroupElementTargetPropertyValue::DateTime(inner) => {
3882                super::super::codec::value_entry(&mut map, "valueDateTime", inner)?;
3883            }
3884            ConceptMapGroupElementTargetPropertyValue::Decimal(inner) => {
3885                super::super::codec::value_entry(&mut map, "valueDecimal", inner)?;
3886            }
3887            ConceptMapGroupElementTargetPropertyValue::Integer(inner) => {
3888                super::super::codec::value_entry(&mut map, "valueInteger", inner)?;
3889            }
3890            ConceptMapGroupElementTargetPropertyValue::String(inner) => {
3891                super::super::codec::value_entry(&mut map, "valueString", inner)?;
3892            }
3893        }
3894        serde::ser::SerializeMap::end(map)
3895    }
3896}
3897
3898impl<'de> serde::Deserialize<'de> for ConceptMapGroupElementTargetProperty {
3899    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3900        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
3901        let mut path = super::super::codec::Path::root("ConceptMapGroupElementTargetProperty");
3902        let object =
3903            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
3904        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
3905    }
3906}
3907
3908/// The \`value\[x\]\` choice of \`ConceptMapGroupElementTargetProperty\`.
3909///
3910/// The value of this property. If the type chosen for this element is 'code',
3911/// then the property SHALL be defined in a ConceptMap.property element.
3912#[derive(Debug, Clone, PartialEq, Eq)]
3913pub enum ConceptMapGroupElementTargetPropertyValue {
3914    /// The `Coding` form.
3915    Coding(Box<super::coding::Coding>),
3916    /// The `string` form.
3917    String(super::primitives::String),
3918    /// The `integer` form.
3919    Integer(super::primitives::Integer),
3920    /// The `boolean` form.
3921    Boolean(super::primitives::Boolean),
3922    /// The `dateTime` form.
3923    DateTime(super::primitives::DateTime),
3924    /// The `decimal` form.
3925    Decimal(super::primitives::Decimal),
3926    /// The `code` form.
3927    Code(super::primitives::Code),
3928}
3929
3930impl ConceptMapGroupElementTargetPropertyValue {
3931    /// The key suffix, the value part, and the `_name` part of this form.
3932    ///
3933    /// # Errors
3934    ///
3935    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
3936    pub fn to_json_parts(
3937        &self,
3938    ) -> Result<
3939        (
3940            &'static str,
3941            Option<super::super::codec::Value>,
3942            Option<super::super::codec::Value>,
3943        ),
3944        super::super::codec::EncodeError,
3945    > {
3946        match self {
3947            Self::Coding(inner) => Ok((
3948                "Coding",
3949                Some(super::super::codec::Value::Object(
3950                    super::super::codec::Json::to_json(inner.as_ref())?,
3951                )),
3952                None,
3953            )),
3954            Self::String(inner) => Ok((
3955                "String",
3956                super::super::codec::Primitive::value_json(inner)?,
3957                super::super::codec::Primitive::element_json(inner)?,
3958            )),
3959            Self::Integer(inner) => Ok((
3960                "Integer",
3961                super::super::codec::Primitive::value_json(inner)?,
3962                super::super::codec::Primitive::element_json(inner)?,
3963            )),
3964            Self::Boolean(inner) => Ok((
3965                "Boolean",
3966                super::super::codec::Primitive::value_json(inner)?,
3967                super::super::codec::Primitive::element_json(inner)?,
3968            )),
3969            Self::DateTime(inner) => Ok((
3970                "DateTime",
3971                super::super::codec::Primitive::value_json(inner)?,
3972                super::super::codec::Primitive::element_json(inner)?,
3973            )),
3974            Self::Decimal(inner) => Ok((
3975                "Decimal",
3976                super::super::codec::Primitive::value_json(inner)?,
3977                super::super::codec::Primitive::element_json(inner)?,
3978            )),
3979            Self::Code(inner) => Ok((
3980                "Code",
3981                super::super::codec::Primitive::value_json(inner)?,
3982                super::super::codec::Primitive::element_json(inner)?,
3983            )),
3984        }
3985    }
3986
3987    /// Decodes the form named by `suffix` from its value and `_name` parts.
3988    ///
3989    /// # Errors
3990    ///
3991    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
3992    pub fn from_json_parts(
3993        suffix: &str,
3994        value: Option<&super::super::codec::Value>,
3995        element: Option<&super::super::codec::Value>,
3996        path: &mut super::super::codec::Path,
3997    ) -> Result<Self, super::super::codec::DecodeError> {
3998        match suffix {
3999            "Coding" => {
4000                if element.is_some() {
4001                    return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
4002                        expected: "no underscore form for a complex type",
4003                    }));
4004                }
4005                let value = value.ok_or_else(|| {
4006                    path.error(super::super::codec::DecodeErrorKind::MissingProperty)
4007                })?;
4008                let inner = super::super::codec::Json::from_json(
4009                    super::super::codec::expect_object(
4010                        super::super::codec::expect_single(value, path)?,
4011                        path,
4012                    )?,
4013                    path,
4014                )?;
4015                Ok(Self::Coding(Box::new(inner)))
4016            }
4017            "String" => Ok(Self::String(
4018                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4019            )),
4020            "Integer" => Ok(Self::Integer(
4021                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4022            )),
4023            "Boolean" => Ok(Self::Boolean(
4024                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4025            )),
4026            "DateTime" => Ok(Self::DateTime(
4027                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4028            )),
4029            "Decimal" => Ok(Self::Decimal(
4030                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4031            )),
4032            "Code" => Ok(Self::Code(super::super::codec::Primitive::from_json_parts(
4033                value, element, path,
4034            )?)),
4035            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
4036        }
4037    }
4038}
4039
4040/// What to do when there is no mapping target for the source concept and
4041/// ConceptMap.group.element.noMap is not true
4042///
4043/// What to do when there is no mapping to a target concept from the source
4044/// concept and ConceptMap.group.element.noMap is not true. This provides the
4045/// "default" to be applied when there is no target concept mapping specified or
4046/// the expansion of ConceptMap.group.element.target.valueSet is empty.
4047#[derive(Debug, Clone, Default, PartialEq, Eq)]
4048pub struct ConceptMapGroupUnmapped {
4049    /// Unique id for inter-element referencing
4050    ///
4051    /// Unique id for the element within a resource (for internal references). This
4052    /// may be any string value that does not contain spaces.
4053    pub id: Option<std::string::String>,
4054    /// Additional content defined by implementations
4055    ///
4056    /// May be used to represent additional information that is not part of the
4057    /// basic definition of the element. To make the use of extensions safe and
4058    /// managable, there is a strict set of governance applied to the definition and
4059    /// use of extensions. Though any implementer can define an extension, there is
4060    /// a set of requirements that SHALL be met as part of the definition of the
4061    /// extension.
4062    pub extension: Vec<super::extension::Extension>,
4063    /// Extensions that cannot be ignored even if unrecognized
4064    ///
4065    /// May be used to represent additional information that is not part of the
4066    /// basic definition of the element and that modifies the understanding of the
4067    /// element in which it is contained and/or the understanding of the containing
4068    /// element's descendants. Usually modifier elements provide negation or
4069    /// qualification. To make the use of extensions safe and managable, there is a
4070    /// strict set of governance applied to the definition and use of extensions.
4071    /// Though any implementer can define an extension, there is a set of
4072    /// requirements that SHALL be met as part of the definition of the extension.
4073    /// Applications processing a resource are required to check for modifier
4074    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
4075    /// on Resource or DomainResource (including cannot change the meaning of
4076    /// modifierExtension itself).
4077    pub modifier_extension: Vec<super::extension::Extension>,
4078    /// use-source-code | fixed | other-map
4079    ///
4080    /// Defines which action to take if there is no match for the source concept in
4081    /// the target system designated for the group. One of 3 actions are possible:
4082    /// use the unmapped source code (this is useful when doing a mapping between
4083    /// versions, and only a few codes have changed), use a fixed code (a default
4084    /// code), or alternatively, a reference to a different concept map can be
4085    /// provided (by canonical URL).
4086    pub mode: super::primitives::Code,
4087    /// Fixed code when mode = fixed
4088    ///
4089    /// The fixed code to use when the mode = 'fixed' - all unmapped codes are
4090    /// mapped to a single fixed code.
4091    pub code: Option<super::primitives::Code>,
4092    /// Display for the code
4093    ///
4094    /// The display for the code. The display is only provided to help editors when
4095    /// editing the concept map.
4096    pub display: Option<super::primitives::String>,
4097    /// Fixed code set when mode = fixed
4098    ///
4099    /// The set of fixed codes to use when the mode = 'fixed' - all unmapped codes
4100    /// are mapped to each of the fixed codes.
4101    pub value_set: Option<super::primitives::Canonical>,
4102    /// related-to | equivalent | source-is-narrower-than-target |
4103    /// source-is-broader-than-target | not-related-to
4104    ///
4105    /// The default relationship value to apply between the source and target
4106    /// concepts when the source code is unmapped and the mode is 'fixed' or
4107    /// 'use-source-code'.
4108    pub relationship: Option<super::primitives::Code>,
4109    /// canonical reference to an additional ConceptMap to use for mapping if the
4110    /// source concept is unmapped
4111    ///
4112    /// The canonical reference to an additional ConceptMap resource instance to use
4113    /// for mapping if this ConceptMap resource contains no matching mapping for the
4114    /// source concept.
4115    pub other_map: Option<super::primitives::Canonical>,
4116}
4117
4118impl super::super::codec::Json for ConceptMapGroupUnmapped {
4119    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
4120        let mut object = super::super::codec::Object::new();
4121        if let Some(v) = &self.id {
4122            object.insert(
4123                std::string::String::from("id"),
4124                super::super::codec::Value::String(v.clone()),
4125            );
4126        }
4127        if !self.extension.is_empty() {
4128            let mut items = Vec::with_capacity(self.extension.len());
4129            for item in &self.extension {
4130                items.push(super::super::codec::Value::Object(
4131                    super::super::codec::Json::to_json(item)?,
4132                ));
4133            }
4134            object.insert(
4135                std::string::String::from("extension"),
4136                super::super::codec::Value::Array(items),
4137            );
4138        }
4139        if !self.modifier_extension.is_empty() {
4140            let mut items = Vec::with_capacity(self.modifier_extension.len());
4141            for item in &self.modifier_extension {
4142                items.push(super::super::codec::Value::Object(
4143                    super::super::codec::Json::to_json(item)?,
4144                ));
4145            }
4146            object.insert(
4147                std::string::String::from("modifierExtension"),
4148                super::super::codec::Value::Array(items),
4149            );
4150        }
4151        if let Some(v) = super::super::codec::Primitive::value_json(&self.mode)? {
4152            object.insert(std::string::String::from("mode"), v);
4153        }
4154        if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
4155            object.insert(std::string::String::from("_mode"), e);
4156        }
4157        if let Some(item) = &self.code {
4158            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4159                object.insert(std::string::String::from("code"), v);
4160            }
4161            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4162                object.insert(std::string::String::from("_code"), e);
4163            }
4164        }
4165        if let Some(item) = &self.display {
4166            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4167                object.insert(std::string::String::from("display"), v);
4168            }
4169            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4170                object.insert(std::string::String::from("_display"), e);
4171            }
4172        }
4173        if let Some(item) = &self.value_set {
4174            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4175                object.insert(std::string::String::from("valueSet"), v);
4176            }
4177            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4178                object.insert(std::string::String::from("_valueSet"), e);
4179            }
4180        }
4181        if let Some(item) = &self.relationship {
4182            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4183                object.insert(std::string::String::from("relationship"), v);
4184            }
4185            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4186                object.insert(std::string::String::from("_relationship"), e);
4187            }
4188        }
4189        if let Some(item) = &self.other_map {
4190            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4191                object.insert(std::string::String::from("otherMap"), v);
4192            }
4193            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4194                object.insert(std::string::String::from("_otherMap"), e);
4195            }
4196        }
4197        Ok(object)
4198    }
4199
4200    fn from_json(
4201        object: &super::super::codec::Object,
4202        path: &mut super::super::codec::Path,
4203    ) -> Result<Self, super::super::codec::DecodeError> {
4204        let mut raw_id: Option<&super::super::codec::Value> = None;
4205        let mut raw_extension: Option<&super::super::codec::Value> = None;
4206        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
4207        let mut raw_mode: Option<&super::super::codec::Value> = None;
4208        let mut raw_mode_element: Option<&super::super::codec::Value> = None;
4209        let mut raw_code: Option<&super::super::codec::Value> = None;
4210        let mut raw_code_element: Option<&super::super::codec::Value> = None;
4211        let mut raw_display: Option<&super::super::codec::Value> = None;
4212        let mut raw_display_element: Option<&super::super::codec::Value> = None;
4213        let mut raw_value_set: Option<&super::super::codec::Value> = None;
4214        let mut raw_value_set_element: Option<&super::super::codec::Value> = None;
4215        let mut raw_relationship: Option<&super::super::codec::Value> = None;
4216        let mut raw_relationship_element: Option<&super::super::codec::Value> = None;
4217        let mut raw_other_map: Option<&super::super::codec::Value> = None;
4218        let mut raw_other_map_element: Option<&super::super::codec::Value> = None;
4219        for (key, value) in object {
4220            match key.as_str() {
4221                "id" => {
4222                    raw_id = Some(value);
4223                }
4224                "extension" => {
4225                    raw_extension = Some(value);
4226                }
4227                "modifierExtension" => {
4228                    raw_modifier_extension = Some(value);
4229                }
4230                "mode" => {
4231                    raw_mode = Some(value);
4232                }
4233                "_mode" => {
4234                    raw_mode_element = Some(value);
4235                }
4236                "code" => {
4237                    raw_code = Some(value);
4238                }
4239                "_code" => {
4240                    raw_code_element = Some(value);
4241                }
4242                "display" => {
4243                    raw_display = Some(value);
4244                }
4245                "_display" => {
4246                    raw_display_element = Some(value);
4247                }
4248                "valueSet" => {
4249                    raw_value_set = Some(value);
4250                }
4251                "_valueSet" => {
4252                    raw_value_set_element = Some(value);
4253                }
4254                "relationship" => {
4255                    raw_relationship = Some(value);
4256                }
4257                "_relationship" => {
4258                    raw_relationship_element = Some(value);
4259                }
4260                "otherMap" => {
4261                    raw_other_map = Some(value);
4262                }
4263                "_otherMap" => {
4264                    raw_other_map_element = Some(value);
4265                }
4266                other => {
4267                    return path.with(other, |path| {
4268                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
4269                    });
4270                }
4271            }
4272        }
4273        let field_id = raw_id
4274            .map(|value| {
4275                path.with("id", |path| {
4276                    let value = super::super::codec::expect_single(value, path)?;
4277                    super::primitives::checked_string(
4278                        super::super::codec::expect_string(value, path)?,
4279                        path,
4280                    )
4281                })
4282            })
4283            .transpose()?;
4284        let mut field_extension = Vec::new();
4285        if let Some(raw) = raw_extension {
4286            for (index, value) in path
4287                .with("extension", |path| {
4288                    super::super::codec::expect_array(raw, path)
4289                })?
4290                .iter()
4291                .enumerate()
4292            {
4293                field_extension.push(path.with_index("extension", index, |path| {
4294                    super::super::codec::Json::from_json(
4295                        super::super::codec::expect_object(value, path)?,
4296                        path,
4297                    )
4298                })?);
4299            }
4300        }
4301        let mut field_modifier_extension = Vec::new();
4302        if let Some(raw) = raw_modifier_extension {
4303            for (index, value) in path
4304                .with("modifierExtension", |path| {
4305                    super::super::codec::expect_array(raw, path)
4306                })?
4307                .iter()
4308                .enumerate()
4309            {
4310                field_modifier_extension.push(path.with_index(
4311                    "modifierExtension",
4312                    index,
4313                    |path| {
4314                        super::super::codec::Json::from_json(
4315                            super::super::codec::expect_object(value, path)?,
4316                            path,
4317                        )
4318                    },
4319                )?);
4320            }
4321        }
4322        let field_mode = path.with("mode", |path| {
4323            super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
4324        })?;
4325        let field_code = match (raw_code, raw_code_element) {
4326            (None, None) => None,
4327            (value, element) => Some(path.with("code", |path| {
4328                super::super::codec::Primitive::from_json_parts(value, element, path)
4329            })?),
4330        };
4331        let field_display = match (raw_display, raw_display_element) {
4332            (None, None) => None,
4333            (value, element) => Some(path.with("display", |path| {
4334                super::super::codec::Primitive::from_json_parts(value, element, path)
4335            })?),
4336        };
4337        let field_value_set = match (raw_value_set, raw_value_set_element) {
4338            (None, None) => None,
4339            (value, element) => Some(path.with("valueSet", |path| {
4340                super::super::codec::Primitive::from_json_parts(value, element, path)
4341            })?),
4342        };
4343        let field_relationship = match (raw_relationship, raw_relationship_element) {
4344            (None, None) => None,
4345            (value, element) => Some(path.with("relationship", |path| {
4346                super::super::codec::Primitive::from_json_parts(value, element, path)
4347            })?),
4348        };
4349        let field_other_map = match (raw_other_map, raw_other_map_element) {
4350            (None, None) => None,
4351            (value, element) => Some(path.with("otherMap", |path| {
4352                super::super::codec::Primitive::from_json_parts(value, element, path)
4353            })?),
4354        };
4355        Ok(Self {
4356            id: field_id,
4357            extension: field_extension,
4358            modifier_extension: field_modifier_extension,
4359            mode: field_mode,
4360            code: field_code,
4361            display: field_display,
4362            value_set: field_value_set,
4363            relationship: field_relationship,
4364            other_map: field_other_map,
4365        })
4366    }
4367}
4368
4369impl serde::Serialize for ConceptMapGroupUnmapped {
4370    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4371        let mut map = serde::Serializer::serialize_map(serializer, None)?;
4372        if let Some(item) = &self.code {
4373            super::super::codec::element_entry(&mut map, "_code", item)?;
4374        }
4375        if let Some(item) = &self.display {
4376            super::super::codec::element_entry(&mut map, "_display", item)?;
4377        }
4378        super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
4379        if let Some(item) = &self.other_map {
4380            super::super::codec::element_entry(&mut map, "_otherMap", item)?;
4381        }
4382        if let Some(item) = &self.relationship {
4383            super::super::codec::element_entry(&mut map, "_relationship", item)?;
4384        }
4385        if let Some(item) = &self.value_set {
4386            super::super::codec::element_entry(&mut map, "_valueSet", item)?;
4387        }
4388        if let Some(item) = &self.code {
4389            super::super::codec::value_entry(&mut map, "code", item)?;
4390        }
4391        if let Some(item) = &self.display {
4392            super::super::codec::value_entry(&mut map, "display", item)?;
4393        }
4394        if !self.extension.is_empty() {
4395            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
4396        }
4397        if let Some(v) = &self.id {
4398            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
4399        }
4400        super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
4401        if !self.modifier_extension.is_empty() {
4402            serde::ser::SerializeMap::serialize_entry(
4403                &mut map,
4404                "modifierExtension",
4405                &self.modifier_extension,
4406            )?;
4407        }
4408        if let Some(item) = &self.other_map {
4409            super::super::codec::value_entry(&mut map, "otherMap", item)?;
4410        }
4411        if let Some(item) = &self.relationship {
4412            super::super::codec::value_entry(&mut map, "relationship", item)?;
4413        }
4414        if let Some(item) = &self.value_set {
4415            super::super::codec::value_entry(&mut map, "valueSet", item)?;
4416        }
4417        serde::ser::SerializeMap::end(map)
4418    }
4419}
4420
4421impl<'de> serde::Deserialize<'de> for ConceptMapGroupUnmapped {
4422    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4423        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
4424        let mut path = super::super::codec::Path::root("ConceptMapGroupUnmapped");
4425        let object =
4426            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
4427        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
4428    }
4429}
4430
4431/// Additional properties of the mapping
4432///
4433/// A property defines a slot through which additional information can be
4434/// provided about a map from source -\> target.
4435#[derive(Debug, Clone, Default, PartialEq, Eq)]
4436pub struct ConceptMapProperty {
4437    /// Unique id for inter-element referencing
4438    ///
4439    /// Unique id for the element within a resource (for internal references). This
4440    /// may be any string value that does not contain spaces.
4441    pub id: Option<std::string::String>,
4442    /// Additional content defined by implementations
4443    ///
4444    /// May be used to represent additional information that is not part of the
4445    /// basic definition of the element. To make the use of extensions safe and
4446    /// managable, there is a strict set of governance applied to the definition and
4447    /// use of extensions. Though any implementer can define an extension, there is
4448    /// a set of requirements that SHALL be met as part of the definition of the
4449    /// extension.
4450    pub extension: Vec<super::extension::Extension>,
4451    /// Extensions that cannot be ignored even if unrecognized
4452    ///
4453    /// May be used to represent additional information that is not part of the
4454    /// basic definition of the element and that modifies the understanding of the
4455    /// element in which it is contained and/or the understanding of the containing
4456    /// element's descendants. Usually modifier elements provide negation or
4457    /// qualification. To make the use of extensions safe and managable, there is a
4458    /// strict set of governance applied to the definition and use of extensions.
4459    /// Though any implementer can define an extension, there is a set of
4460    /// requirements that SHALL be met as part of the definition of the extension.
4461    /// Applications processing a resource are required to check for modifier
4462    /// extensions. Modifier extensions SHALL NOT change the meaning of any elements
4463    /// on Resource or DomainResource (including cannot change the meaning of
4464    /// modifierExtension itself).
4465    pub modifier_extension: Vec<super::extension::Extension>,
4466    /// Identifies the property on the mappings, and when referred to in the
4467    /// $translate operation
4468    ///
4469    /// A code that is used to identify the property. The code is used internally
4470    /// (in ConceptMap.group.element.target.property.code) and also in the
4471    /// $translate operation.
4472    pub code: super::primitives::Code,
4473    /// Formal identifier for the property
4474    ///
4475    /// Reference to the formal meaning of the property.
4476    pub uri: Option<super::primitives::Uri>,
4477    /// Why the property is defined, and/or what it conveys
4478    ///
4479    /// A description of the property - why it is defined, and how its value might
4480    /// be used.
4481    pub description: Option<super::primitives::String>,
4482    /// Coding | string | integer | boolean | dateTime | decimal | code
4483    ///
4484    /// The type of the property value.
4485    pub r#type: super::primitives::Code,
4486    /// The CodeSystem from which code values come
4487    ///
4488    /// The CodeSystem that defines the codes from which values of type
4489    /// \`\`\`code\`\`\` in property values.
4490    pub system: Option<super::primitives::Canonical>,
4491}
4492
4493impl super::super::codec::Json for ConceptMapProperty {
4494    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
4495        let mut object = super::super::codec::Object::new();
4496        if let Some(v) = &self.id {
4497            object.insert(
4498                std::string::String::from("id"),
4499                super::super::codec::Value::String(v.clone()),
4500            );
4501        }
4502        if !self.extension.is_empty() {
4503            let mut items = Vec::with_capacity(self.extension.len());
4504            for item in &self.extension {
4505                items.push(super::super::codec::Value::Object(
4506                    super::super::codec::Json::to_json(item)?,
4507                ));
4508            }
4509            object.insert(
4510                std::string::String::from("extension"),
4511                super::super::codec::Value::Array(items),
4512            );
4513        }
4514        if !self.modifier_extension.is_empty() {
4515            let mut items = Vec::with_capacity(self.modifier_extension.len());
4516            for item in &self.modifier_extension {
4517                items.push(super::super::codec::Value::Object(
4518                    super::super::codec::Json::to_json(item)?,
4519                ));
4520            }
4521            object.insert(
4522                std::string::String::from("modifierExtension"),
4523                super::super::codec::Value::Array(items),
4524            );
4525        }
4526        if let Some(v) = super::super::codec::Primitive::value_json(&self.code)? {
4527            object.insert(std::string::String::from("code"), v);
4528        }
4529        if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
4530            object.insert(std::string::String::from("_code"), e);
4531        }
4532        if let Some(item) = &self.uri {
4533            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4534                object.insert(std::string::String::from("uri"), v);
4535            }
4536            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4537                object.insert(std::string::String::from("_uri"), e);
4538            }
4539        }
4540        if let Some(item) = &self.description {
4541            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4542                object.insert(std::string::String::from("description"), v);
4543            }
4544            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4545                object.insert(std::string::String::from("_description"), e);
4546            }
4547        }
4548        if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
4549            object.insert(std::string::String::from("type"), v);
4550        }
4551        if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
4552            object.insert(std::string::String::from("_type"), e);
4553        }
4554        if let Some(item) = &self.system {
4555            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
4556                object.insert(std::string::String::from("system"), v);
4557            }
4558            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
4559                object.insert(std::string::String::from("_system"), e);
4560            }
4561        }
4562        Ok(object)
4563    }
4564
4565    fn from_json(
4566        object: &super::super::codec::Object,
4567        path: &mut super::super::codec::Path,
4568    ) -> Result<Self, super::super::codec::DecodeError> {
4569        let mut raw_id: Option<&super::super::codec::Value> = None;
4570        let mut raw_extension: Option<&super::super::codec::Value> = None;
4571        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
4572        let mut raw_code: Option<&super::super::codec::Value> = None;
4573        let mut raw_code_element: Option<&super::super::codec::Value> = None;
4574        let mut raw_uri: Option<&super::super::codec::Value> = None;
4575        let mut raw_uri_element: Option<&super::super::codec::Value> = None;
4576        let mut raw_description: Option<&super::super::codec::Value> = None;
4577        let mut raw_description_element: Option<&super::super::codec::Value> = None;
4578        let mut raw_type: Option<&super::super::codec::Value> = None;
4579        let mut raw_type_element: Option<&super::super::codec::Value> = None;
4580        let mut raw_system: Option<&super::super::codec::Value> = None;
4581        let mut raw_system_element: Option<&super::super::codec::Value> = None;
4582        for (key, value) in object {
4583            match key.as_str() {
4584                "id" => {
4585                    raw_id = Some(value);
4586                }
4587                "extension" => {
4588                    raw_extension = Some(value);
4589                }
4590                "modifierExtension" => {
4591                    raw_modifier_extension = Some(value);
4592                }
4593                "code" => {
4594                    raw_code = Some(value);
4595                }
4596                "_code" => {
4597                    raw_code_element = Some(value);
4598                }
4599                "uri" => {
4600                    raw_uri = Some(value);
4601                }
4602                "_uri" => {
4603                    raw_uri_element = Some(value);
4604                }
4605                "description" => {
4606                    raw_description = Some(value);
4607                }
4608                "_description" => {
4609                    raw_description_element = Some(value);
4610                }
4611                "type" => {
4612                    raw_type = Some(value);
4613                }
4614                "_type" => {
4615                    raw_type_element = Some(value);
4616                }
4617                "system" => {
4618                    raw_system = Some(value);
4619                }
4620                "_system" => {
4621                    raw_system_element = Some(value);
4622                }
4623                other => {
4624                    return path.with(other, |path| {
4625                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
4626                    });
4627                }
4628            }
4629        }
4630        let field_id = raw_id
4631            .map(|value| {
4632                path.with("id", |path| {
4633                    let value = super::super::codec::expect_single(value, path)?;
4634                    super::primitives::checked_string(
4635                        super::super::codec::expect_string(value, path)?,
4636                        path,
4637                    )
4638                })
4639            })
4640            .transpose()?;
4641        let mut field_extension = Vec::new();
4642        if let Some(raw) = raw_extension {
4643            for (index, value) in path
4644                .with("extension", |path| {
4645                    super::super::codec::expect_array(raw, path)
4646                })?
4647                .iter()
4648                .enumerate()
4649            {
4650                field_extension.push(path.with_index("extension", index, |path| {
4651                    super::super::codec::Json::from_json(
4652                        super::super::codec::expect_object(value, path)?,
4653                        path,
4654                    )
4655                })?);
4656            }
4657        }
4658        let mut field_modifier_extension = Vec::new();
4659        if let Some(raw) = raw_modifier_extension {
4660            for (index, value) in path
4661                .with("modifierExtension", |path| {
4662                    super::super::codec::expect_array(raw, path)
4663                })?
4664                .iter()
4665                .enumerate()
4666            {
4667                field_modifier_extension.push(path.with_index(
4668                    "modifierExtension",
4669                    index,
4670                    |path| {
4671                        super::super::codec::Json::from_json(
4672                            super::super::codec::expect_object(value, path)?,
4673                            path,
4674                        )
4675                    },
4676                )?);
4677            }
4678        }
4679        let field_code = path.with("code", |path| {
4680            super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
4681        })?;
4682        let field_uri = match (raw_uri, raw_uri_element) {
4683            (None, None) => None,
4684            (value, element) => Some(path.with("uri", |path| {
4685                super::super::codec::Primitive::from_json_parts(value, element, path)
4686            })?),
4687        };
4688        let field_description = match (raw_description, raw_description_element) {
4689            (None, None) => None,
4690            (value, element) => Some(path.with("description", |path| {
4691                super::super::codec::Primitive::from_json_parts(value, element, path)
4692            })?),
4693        };
4694        let field_type = path.with("type", |path| {
4695            super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
4696        })?;
4697        let field_system = match (raw_system, raw_system_element) {
4698            (None, None) => None,
4699            (value, element) => Some(path.with("system", |path| {
4700                super::super::codec::Primitive::from_json_parts(value, element, path)
4701            })?),
4702        };
4703        Ok(Self {
4704            id: field_id,
4705            extension: field_extension,
4706            modifier_extension: field_modifier_extension,
4707            code: field_code,
4708            uri: field_uri,
4709            description: field_description,
4710            r#type: field_type,
4711            system: field_system,
4712        })
4713    }
4714}
4715
4716impl serde::Serialize for ConceptMapProperty {
4717    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4718        let mut map = serde::Serializer::serialize_map(serializer, None)?;
4719        super::super::codec::element_entry(&mut map, "_code", &self.code)?;
4720        if let Some(item) = &self.description {
4721            super::super::codec::element_entry(&mut map, "_description", item)?;
4722        }
4723        if let Some(item) = &self.system {
4724            super::super::codec::element_entry(&mut map, "_system", item)?;
4725        }
4726        super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
4727        if let Some(item) = &self.uri {
4728            super::super::codec::element_entry(&mut map, "_uri", item)?;
4729        }
4730        super::super::codec::value_entry(&mut map, "code", &self.code)?;
4731        if let Some(item) = &self.description {
4732            super::super::codec::value_entry(&mut map, "description", item)?;
4733        }
4734        if !self.extension.is_empty() {
4735            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
4736        }
4737        if let Some(v) = &self.id {
4738            serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
4739        }
4740        if !self.modifier_extension.is_empty() {
4741            serde::ser::SerializeMap::serialize_entry(
4742                &mut map,
4743                "modifierExtension",
4744                &self.modifier_extension,
4745            )?;
4746        }
4747        if let Some(item) = &self.system {
4748            super::super::codec::value_entry(&mut map, "system", item)?;
4749        }
4750        super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
4751        if let Some(item) = &self.uri {
4752            super::super::codec::value_entry(&mut map, "uri", item)?;
4753        }
4754        serde::ser::SerializeMap::end(map)
4755    }
4756}
4757
4758impl<'de> serde::Deserialize<'de> for ConceptMapProperty {
4759    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4760        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
4761        let mut path = super::super::codec::Path::root("ConceptMapProperty");
4762        let object =
4763            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
4764        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
4765    }
4766}
4767
4768/// The \`sourceScope\[x\]\` choice of \`ConceptMap\`.
4769///
4770/// Identifier for the source value set that contains the concepts that are
4771/// being mapped and provides context for the mappings. Limits the scope of the
4772/// map to source codes (ConceptMap.group.element code or valueSet) that are
4773/// members of this value set.
4774#[derive(Debug, Clone, PartialEq, Eq)]
4775pub enum ConceptMapSourceScope {
4776    /// The `uri` form.
4777    Uri(super::primitives::Uri),
4778    /// The `canonical` form.
4779    Canonical(super::primitives::Canonical),
4780}
4781
4782impl ConceptMapSourceScope {
4783    /// The key suffix, the value part, and the `_name` part of this form.
4784    ///
4785    /// # Errors
4786    ///
4787    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
4788    pub fn to_json_parts(
4789        &self,
4790    ) -> Result<
4791        (
4792            &'static str,
4793            Option<super::super::codec::Value>,
4794            Option<super::super::codec::Value>,
4795        ),
4796        super::super::codec::EncodeError,
4797    > {
4798        match self {
4799            Self::Uri(inner) => Ok((
4800                "Uri",
4801                super::super::codec::Primitive::value_json(inner)?,
4802                super::super::codec::Primitive::element_json(inner)?,
4803            )),
4804            Self::Canonical(inner) => Ok((
4805                "Canonical",
4806                super::super::codec::Primitive::value_json(inner)?,
4807                super::super::codec::Primitive::element_json(inner)?,
4808            )),
4809        }
4810    }
4811
4812    /// Decodes the form named by `suffix` from its value and `_name` parts.
4813    ///
4814    /// # Errors
4815    ///
4816    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
4817    pub fn from_json_parts(
4818        suffix: &str,
4819        value: Option<&super::super::codec::Value>,
4820        element: Option<&super::super::codec::Value>,
4821        path: &mut super::super::codec::Path,
4822    ) -> Result<Self, super::super::codec::DecodeError> {
4823        match suffix {
4824            "Uri" => Ok(Self::Uri(super::super::codec::Primitive::from_json_parts(
4825                value, element, path,
4826            )?)),
4827            "Canonical" => Ok(Self::Canonical(
4828                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4829            )),
4830            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
4831        }
4832    }
4833}
4834
4835/// The \`targetScope\[x\]\` choice of \`ConceptMap\`.
4836///
4837/// Identifier for the target value set that provides important context about
4838/// how the mapping choices are made. Limits the scope of the map to target
4839/// codes (ConceptMap.group.element.target code or valueSet) that are members of
4840/// this value set.
4841#[derive(Debug, Clone, PartialEq, Eq)]
4842pub enum ConceptMapTargetScope {
4843    /// The `uri` form.
4844    Uri(super::primitives::Uri),
4845    /// The `canonical` form.
4846    Canonical(super::primitives::Canonical),
4847}
4848
4849impl ConceptMapTargetScope {
4850    /// The key suffix, the value part, and the `_name` part of this form.
4851    ///
4852    /// # Errors
4853    ///
4854    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
4855    pub fn to_json_parts(
4856        &self,
4857    ) -> Result<
4858        (
4859            &'static str,
4860            Option<super::super::codec::Value>,
4861            Option<super::super::codec::Value>,
4862        ),
4863        super::super::codec::EncodeError,
4864    > {
4865        match self {
4866            Self::Uri(inner) => Ok((
4867                "Uri",
4868                super::super::codec::Primitive::value_json(inner)?,
4869                super::super::codec::Primitive::element_json(inner)?,
4870            )),
4871            Self::Canonical(inner) => Ok((
4872                "Canonical",
4873                super::super::codec::Primitive::value_json(inner)?,
4874                super::super::codec::Primitive::element_json(inner)?,
4875            )),
4876        }
4877    }
4878
4879    /// Decodes the form named by `suffix` from its value and `_name` parts.
4880    ///
4881    /// # Errors
4882    ///
4883    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
4884    pub fn from_json_parts(
4885        suffix: &str,
4886        value: Option<&super::super::codec::Value>,
4887        element: Option<&super::super::codec::Value>,
4888        path: &mut super::super::codec::Path,
4889    ) -> Result<Self, super::super::codec::DecodeError> {
4890        match suffix {
4891            "Uri" => Ok(Self::Uri(super::super::codec::Primitive::from_json_parts(
4892                value, element, path,
4893            )?)),
4894            "Canonical" => Ok(Self::Canonical(
4895                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4896            )),
4897            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
4898        }
4899    }
4900}
4901
4902/// The \`versionAlgorithm\[x\]\` choice of \`ConceptMap\`.
4903///
4904/// Indicates the mechanism used to compare versions to determine which
4905/// ConceptMap is more current.
4906#[derive(Debug, Clone, PartialEq, Eq)]
4907pub enum ConceptMapVersionAlgorithm {
4908    /// The `string` form.
4909    String(super::primitives::String),
4910    /// The `Coding` form.
4911    Coding(Box<super::coding::Coding>),
4912}
4913
4914impl ConceptMapVersionAlgorithm {
4915    /// The key suffix, the value part, and the `_name` part of this form.
4916    ///
4917    /// # Errors
4918    ///
4919    /// Returns [`super::super::codec::EncodeError`] when a held value has no JSON form.
4920    pub fn to_json_parts(
4921        &self,
4922    ) -> Result<
4923        (
4924            &'static str,
4925            Option<super::super::codec::Value>,
4926            Option<super::super::codec::Value>,
4927        ),
4928        super::super::codec::EncodeError,
4929    > {
4930        match self {
4931            Self::String(inner) => Ok((
4932                "String",
4933                super::super::codec::Primitive::value_json(inner)?,
4934                super::super::codec::Primitive::element_json(inner)?,
4935            )),
4936            Self::Coding(inner) => Ok((
4937                "Coding",
4938                Some(super::super::codec::Value::Object(
4939                    super::super::codec::Json::to_json(inner.as_ref())?,
4940                )),
4941                None,
4942            )),
4943        }
4944    }
4945
4946    /// Decodes the form named by `suffix` from its value and `_name` parts.
4947    ///
4948    /// # Errors
4949    ///
4950    /// Returns [`super::super::codec::DecodeError`] for an unknown suffix or a malformed part.
4951    pub fn from_json_parts(
4952        suffix: &str,
4953        value: Option<&super::super::codec::Value>,
4954        element: Option<&super::super::codec::Value>,
4955        path: &mut super::super::codec::Path,
4956    ) -> Result<Self, super::super::codec::DecodeError> {
4957        match suffix {
4958            "String" => Ok(Self::String(
4959                super::super::codec::Primitive::from_json_parts(value, element, path)?,
4960            )),
4961            "Coding" => {
4962                if element.is_some() {
4963                    return Err(path.error(super::super::codec::DecodeErrorKind::WrongType {
4964                        expected: "no underscore form for a complex type",
4965                    }));
4966                }
4967                let value = value.ok_or_else(|| {
4968                    path.error(super::super::codec::DecodeErrorKind::MissingProperty)
4969                })?;
4970                let inner = super::super::codec::Json::from_json(
4971                    super::super::codec::expect_object(
4972                        super::super::codec::expect_single(value, path)?,
4973                        path,
4974                    )?,
4975                    path,
4976                )?;
4977                Ok(Self::Coding(Box::new(inner)))
4978            }
4979            _ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
4980        }
4981    }
4982}