Skip to main content

fhirkit/r4/resources/
medicinal_product_contraindication.rs

1// @generated by fhirkit-gen from hl7.fhir.r4.core 4.0.1. Do not edit.
2//! The FHIR R4 `MedicinalProductContraindication` resource.
3
4#![allow(
5    unused_imports,
6    clippy::large_enum_variant,
7    clippy::too_many_lines,
8    clippy::doc_markdown
9)]
10
11use crate::decode::{
12    choice_key, required, required_list, resource_type, Choice, Decoder, FhirJson, Obj, ObjWriter,
13};
14use crate::json::Json;
15use crate::primitive::{Decimal, Kind, Primitive};
16use crate::r4::*;
17
18/// The clinical particulars - indications, contraindications etc. of a medicinal product, including for regulatory purposes.
19///
20/// FHIR path: `MedicinalProductContraindication`.
21#[cfg(feature = "specialized")]
22#[derive(Debug, Clone, PartialEq, Default)]
23pub struct MedicinalProductContraindication {
24    /// `id` (0..1): Logical id of this artifact
25    pub id: Option<String>,
26    /// `meta` (0..1): Metadata about the resource
27    pub meta: Option<Meta>,
28    /// `implicitRules` (0..1): A set of rules under which this content was created
29    pub implicit_rules: Option<Primitive<String>>,
30    /// `language` (0..1): Language of the resource content
31    pub language: Option<Primitive<String>>,
32    /// `text` (0..1): Text summary of the resource, for human interpretation
33    pub text: Option<Narrative>,
34    /// `contained` (0..*): Contained, inline Resources
35    pub contained: Vec<Resource>,
36    /// `extension` (0..*): Additional content defined by implementations
37    pub extension: Vec<Extension>,
38    /// `modifierExtension` (0..*): Extensions that cannot be ignored
39    pub modifier_extension: Vec<Extension>,
40    /// `subject` (0..*): The medication for which this is an indication
41    pub subject: Vec<Reference>,
42    /// `disease` (0..1): The disease, symptom or procedure for the contraindication
43    pub disease: Option<CodeableConcept>,
44    /// `diseaseStatus` (0..1): The status of the disease or symptom for the contraindication
45    pub disease_status: Option<CodeableConcept>,
46    /// `comorbidity` (0..*): A comorbidity (concurrent condition) or coinfection
47    pub comorbidity: Vec<CodeableConcept>,
48    /// `therapeuticIndication` (0..*): Information about the use of the medicinal product in relation to other therapies as part of the indication
49    pub therapeutic_indication: Vec<Reference>,
50    /// `otherTherapy` (0..*): Information about the use of the medicinal product in relation to other therapies described as part of the indication
51    pub other_therapy: Vec<MedicinalProductContraindicationOtherTherapy>,
52    /// `population` (0..*): The population group to which this applies
53    pub population: Vec<Population>,
54}
55
56#[cfg(feature = "specialized")]
57impl FhirJson for MedicinalProductContraindication {
58    const TYPE_NAME: &'static str = "MedicinalProductContraindication";
59
60    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
61        let mut o = Obj::new(v, d)?;
62        resource_type(&mut o, d, "MedicinalProductContraindication");
63        let r = MedicinalProductContraindication {
64            id: o.string(d, "id"),
65            meta: o.one(d, "meta"),
66            implicit_rules: o.prim(d, "implicitRules", Kind::Uri),
67            language: o.prim(d, "language", Kind::Code),
68            text: o.one(d, "text"),
69            contained: o.list(d, "contained"),
70            extension: o.list(d, "extension"),
71            modifier_extension: o.list(d, "modifierExtension"),
72            subject: o.list(d, "subject"),
73            disease: o.one(d, "disease"),
74            disease_status: o.one(d, "diseaseStatus"),
75            comorbidity: o.list(d, "comorbidity"),
76            therapeutic_indication: o.list(d, "therapeuticIndication"),
77            other_therapy: o.list(d, "otherTherapy"),
78            population: o.list(d, "population"),
79        };
80        o.finish(d);
81        Some(r)
82    }
83
84    fn encode(&self) -> Json {
85        let mut w = ObjWriter::new();
86        w.raw(
87            "resourceType",
88            Json::String("MedicinalProductContraindication".into()),
89        );
90        w.string("id", &self.id);
91        w.one("meta", &self.meta);
92        w.prim("implicitRules", &self.implicit_rules);
93        w.prim("language", &self.language);
94        w.one("text", &self.text);
95        w.list("contained", &self.contained);
96        w.list("extension", &self.extension);
97        w.list("modifierExtension", &self.modifier_extension);
98        w.list("subject", &self.subject);
99        w.one("disease", &self.disease);
100        w.one("diseaseStatus", &self.disease_status);
101        w.list("comorbidity", &self.comorbidity);
102        w.list("therapeuticIndication", &self.therapeutic_indication);
103        w.list("otherTherapy", &self.other_therapy);
104        w.list("population", &self.population);
105        w.finish()
106    }
107}
108
109/// Information about the use of the medicinal product in relation to other therapies described as part of the indication
110///
111/// FHIR path: `MedicinalProductContraindication.otherTherapy`.
112#[cfg(feature = "specialized")]
113#[derive(Debug, Clone, PartialEq, Default)]
114pub struct MedicinalProductContraindicationOtherTherapy {
115    /// `id` (0..1): Unique id for inter-element referencing
116    pub id: Option<String>,
117    /// `extension` (0..*): Additional content defined by implementations
118    pub extension: Vec<Extension>,
119    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
120    pub modifier_extension: Vec<Extension>,
121    /// `therapyRelationshipType` (1..1): The type of relationship between the medicinal product indication or contraindication and another therapy
122    pub therapy_relationship_type: Option<CodeableConcept>,
123    /// `medication[x]` (1..1): Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication
124    pub medication: Option<MedicinalProductContraindicationOtherTherapyMedication>,
125}
126
127#[cfg(feature = "specialized")]
128impl FhirJson for MedicinalProductContraindicationOtherTherapy {
129    const TYPE_NAME: &'static str = "MedicinalProductContraindicationOtherTherapy";
130
131    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
132        let mut o = Obj::new(v, d)?;
133        let r = MedicinalProductContraindicationOtherTherapy {
134            id: o.string(d, "id"),
135            extension: o.list(d, "extension"),
136            modifier_extension: o.list(d, "modifierExtension"),
137            therapy_relationship_type: o.one(d, "therapyRelationshipType"),
138            medication: o.choice(d, "medication"),
139        };
140        required(d, "therapyRelationshipType", &r.therapy_relationship_type);
141        required(d, "medication[x]", &r.medication);
142        o.finish(d);
143        Some(r)
144    }
145
146    fn encode(&self) -> Json {
147        let mut w = ObjWriter::new();
148        w.string("id", &self.id);
149        w.list("extension", &self.extension);
150        w.list("modifierExtension", &self.modifier_extension);
151        w.one("therapyRelationshipType", &self.therapy_relationship_type);
152        w.choice("medication", &self.medication);
153        w.finish()
154    }
155}
156
157/// The types `MedicinalProductContraindication.otherTherapy.medication[x]` allows.
158#[cfg(feature = "specialized")]
159#[derive(Debug, Clone, PartialEq)]
160pub enum MedicinalProductContraindicationOtherTherapyMedication {
161    /// `CodeableConcept`
162    CodeableConcept(CodeableConcept),
163    /// `Reference`
164    Reference(Reference),
165}
166
167#[cfg(feature = "specialized")]
168impl Choice for MedicinalProductContraindicationOtherTherapyMedication {
169    const TYPES: &'static [&'static str] = &["CodeableConcept", "Reference"];
170
171    fn decode_as(code: &str, key: &str, o: &mut Obj<'_>, d: &mut Decoder) -> Option<Self> {
172        match code {
173            "CodeableConcept" => o.one(d, key).map(Self::CodeableConcept),
174            "Reference" => o.one(d, key).map(Self::Reference),
175            _ => None,
176        }
177    }
178
179    fn encode_into(&self, base: &str, w: &mut ObjWriter) {
180        match self {
181            Self::CodeableConcept(v) => w.value(&choice_key(base, "CodeableConcept"), v),
182            Self::Reference(v) => w.value(&choice_key(base, "Reference"), v),
183        }
184    }
185}