Skip to main content

fhir_types/r6/
concept_map.rs

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