fhir 1.0.0

Fast Healthcare Interoperability Resources (FHIR) API is a standardized, RESTful interface for exchanging electronic health records.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
//! MedicationKnowledge
//!
//! URL: http://hl7.org/fhir/StructureDefinition/MedicationKnowledge
//!
//! Version: 5.0.0
//!
//! MedicationKnowledge Resource: Information about a medication that is used to support knowledge.
//!
//! FHIR: <https://build.fhir.org/>
//!
//! UML: <https://build.fhir.org/uml.html>

// Allow unused crate::r5::types as types;
#![allow(unused_imports)]

use crate::r5::types;
use ::serde::{Deserialize, Serialize};
use fhir_derive_macros::Validate;

/// Information about a medication that is used to support knowledge.
///
/// MedicationKnowledge is a definitional resource that captures broad,
/// reference-style information about a medication independent of any single
/// patient or administration event. Rather than recording that a particular
/// product was prescribed, dispensed, or administered, it describes what is
/// generally known about a medication: its names and codes, product type and
/// classification, ingredients and dose form, cost and packaging, storage and
/// regulatory constraints, monitoring programs, associated monographs, and
/// indication-specific dosing guidelines. In FHIR R5 it is typically populated
/// by drug knowledge vendors, formularies, and pharmacy systems, then consumed
/// to power decision support, formulary lookups, drug reference databases,
/// pricing, and clinician-facing monographs.
///
/// It is distinct from the Medication resource, which represents a specific
/// product used in a clinical workflow; MedicationKnowledge instead provides
/// the surrounding definitional and reference knowledge about such products.
///
/// # Related resources
///
/// See also the `Medication` resource for a specific product instance, and
/// [`CodeableConcept`](crate::r5::types::CodeableConcept) and
/// [`Reference`](crate::r5::types::Reference), which are used throughout this
/// resource to carry coded values and links to related resources.
///
/// # Examples
///
/// ```
/// use fhir::r5::resources::medication_knowledge::MedicationKnowledge;
///
/// let value = MedicationKnowledge::default();
/// let json = ::serde_json::to_value(&value).unwrap();
/// let back: MedicationKnowledge = ::serde_json::from_value(json).unwrap();
/// assert_eq!(value, back);
/// ```
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledge {
    /// Logical id of this artifact
    pub id: Option<types::String>,

    /// Metadata about the resource
    pub meta: Option<types::Meta>,

    /// A set of rules under which this content was created
    pub implicit_rules: Option<types::Uri>,
    /// Primitive extension sibling for [`implicit_rules`](Self::implicit_rules) (FHIR `_implicitRules`).
    #[serde(rename = "_implicitRules")]
    pub implicit_rules_ext: Option<types::Element>,

    /// Language of the resource content
    pub language: Option<types::Code>,
    /// Primitive extension sibling for [`language`](Self::language) (FHIR `_language`).
    #[serde(rename = "_language")]
    pub language_ext: Option<types::Element>,

    /// Text summary of the resource, for human interpretation
    pub text: Option<types::Narrative>,

    /// Contained, inline Resources
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub contained: Vec<::serde_json::Value>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Business identifier(s) for this medication knowledge record, distinct from any identifiers on a specific Medication product
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub identifier: Vec<types::Identifier>,

    /// Code that identifies this medication, typically drawn from a drug terminology such as RxNorm or SNOMED CT
    pub code: Option<types::CodeableConcept>,

    /// Lifecycle status of this knowledge record: active, entered-in-error, or inactive
    pub status: Option<crate::r5::coded::Coded<crate::r5::codes::MedicationknowledgeStatus>>,
    /// Primitive extension sibling for [`status`](Self::status) (FHIR `_status`).
    #[serde(rename = "_status")]
    pub status_ext: Option<types::Element>,

    /// Creator or owner of the knowledge or information about the medication
    pub author: Option<types::Reference>,

    /// Codes that identify the different jurisdictions for which the information of this resource was created
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub intended_jurisdiction: Vec<types::CodeableConcept>,

    /// A name associated with the medication being described, such as a brand, generic, or synonym name
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub name: Vec<types::String>,
    /// Primitive extension sibling for [`name`](Self::name) (FHIR `_name`).
    #[serde(rename = "_name")]
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub name_ext: Vec<Option<types::Element>>,

    /// Associated or related medication information
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub related_medication_knowledge: Vec<MedicationKnowledgeRelatedMedicationKnowledge>,

    /// The set of medication resources that are associated with this medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub associated_medication: Vec<types::Reference>,

    /// Category of the medication or product
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub product_type: Vec<types::CodeableConcept>,

    /// Associated documentation about the medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub monograph: Vec<MedicationKnowledgeMonograph>,

    /// The instructions for preparing the medication
    pub preparation_instruction: Option<types::Markdown>,
    /// Primitive extension sibling for [`preparation_instruction`](Self::preparation_instruction) (FHIR `_preparationInstruction`).
    #[serde(rename = "_preparationInstruction")]
    pub preparation_instruction_ext: Option<types::Element>,

    /// The pricing of the medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub cost: Vec<MedicationKnowledgeCost>,

    /// Program under which a medication is reviewed
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub monitoring_program: Vec<MedicationKnowledgeMonitoringProgram>,

    /// Guidelines or protocols for administration of the medication for an indication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub indication_guideline: Vec<MedicationKnowledgeIndicationGuideline>,

    /// Categorization of the medication within a formulary or classification system
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub medicine_classification: Vec<MedicationKnowledgeMedicineClassification>,

    /// Details about packaged medications
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub packaging: Vec<MedicationKnowledgePackaging>,

    /// Potential clinical issue with or between medication(s), such as a known interaction, contraindication, or warning
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub clinical_use_issue: Vec<types::Reference>,

    /// How the medication should be stored
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub storage_guideline: Vec<MedicationKnowledgeStorageGuideline>,

    /// Regulatory information about a medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub regulatory: Vec<MedicationKnowledgeRegulatory>,

    /// Minimal definitional information such as dose form, route, and ingredients that characterizes the medication
    pub definitional: Option<MedicationKnowledgeDefinitional>,
}

/// Associated or related medication information.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeRelatedMedicationKnowledge {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Category of medicationKnowledge
    pub r#type: types::CodeableConcept,

    /// Associated documentation about the associated medication knowledge
    pub reference: vec1::Vec1<types::Reference>,
}

/// Associated documentation about the medication.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeMonograph {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// The category of medication document
    pub r#type: Option<types::CodeableConcept>,

    /// Associated documentation about the medication
    pub source: Option<types::Reference>,
}

/// The pricing of the medication.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeCost {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// The date range for which the cost is effective
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub effective_date: Vec<types::Period>,

    /// The category of the cost information
    pub r#type: types::CodeableConcept,

    /// The source or owner for the price information
    pub source: Option<types::String>,
    /// Primitive extension sibling for [`source`](Self::source) (FHIR `_source`).
    #[serde(rename = "_source")]
    pub source_ext: Option<types::Element>,

    /// The `MedicationKnowledge.cost.cost[x]` choice element (0..1); see [`MedicationKnowledgeCostCost`].
    #[serde(flatten)]
    pub cost: Option<MedicationKnowledgeCostCost>,
}

/// Program under which a medication is reviewed.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeMonitoringProgram {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Type of program under which the medication is monitored
    pub r#type: Option<types::CodeableConcept>,

    /// Name of the reviewing program
    pub name: Option<types::String>,
    /// Primitive extension sibling for [`name`](Self::name) (FHIR `_name`).
    #[serde(rename = "_name")]
    pub name_ext: Option<types::Element>,
}

/// Guidelines or protocols for administration of the medication for an indication.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeIndicationGuideline {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Indication for use that applies to the specific administration guideline
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub indication: Vec<types::CodeableReference>,

    /// Guidelines for dosage of the medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub dosing_guideline: Vec<MedicationKnowledgeIndicationGuidelineDosingGuideline>,
}

/// Guidelines for dosage of the medication.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeIndicationGuidelineDosingGuideline {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Intention of the treatment
    pub treatment_intent: Option<types::CodeableConcept>,

    /// Dosage for the medication for the specific guidelines
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub dosage: Vec<MedicationKnowledgeIndicationGuidelineDosingGuidelineDosage>,

    /// Type of treatment the guideline applies to
    pub administration_treatment: Option<types::CodeableConcept>,

    /// Characteristics of the patient that are relevant to the administration guidelines
    pub patient_characteristic:
        Option<Vec<MedicationKnowledgeIndicationGuidelineDosingGuidelinePatientCharacteristic>>,
}

/// Dosage for the medication for the specific guidelines.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeIndicationGuidelineDosingGuidelineDosage {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Category of dosage for a medication
    pub r#type: types::CodeableConcept,

    /// Dosage for the medication for the specific guidelines
    pub dosage: vec1::Vec1<types::Dosage>,
}

/// Characteristics of the patient that are relevant to the administration guidelines.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeIndicationGuidelineDosingGuidelinePatientCharacteristic {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Categorization of specific characteristic that is relevant to the administration guideline
    pub r#type: types::CodeableConcept,

    /// The `MedicationKnowledge.indicationGuideline.dosingGuideline.patientCharacteristic.value[x]` choice element (0..1); see [`MedicationKnowledgeIndicationGuidelineDosingGuidelinePatientCharacteristicValue`].
    #[serde(flatten)]
    pub value: Option<MedicationKnowledgeIndicationGuidelineDosingGuidelinePatientCharacteristicValue>,
}

/// Categorization of the medication within a formulary or classification system.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeMedicineClassification {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// The type of category for the medication (for example, therapeutic classification, therapeutic sub-classification)
    pub r#type: types::CodeableConcept,

    /// The `MedicationKnowledge.medicineClassification.source[x]` choice element (0..1); see [`MedicationKnowledgeMedicineClassificationSource`].
    #[serde(flatten)]
    pub source: Option<MedicationKnowledgeMedicineClassificationSource>,

    /// Specific category assigned to the medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub classification: Vec<types::CodeableConcept>,
}

/// Details about packaged medications.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgePackaging {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Cost of the packaged medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub cost: Vec<MedicationKnowledgeCost>,

    /// The packaged medication that is being priced
    pub packaged_product: Option<types::Reference>,
}

/// How the medication should be stored.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeStorageGuideline {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Reference to additional information
    pub reference: Option<types::Uri>,
    /// Primitive extension sibling for [`reference`](Self::reference) (FHIR `_reference`).
    #[serde(rename = "_reference")]
    pub reference_ext: Option<types::Element>,

    /// Additional storage notes
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub note: Vec<types::Annotation>,

    /// Duration remains stable
    pub stability_duration: Option<types::Duration>,

    /// Setting or value of environment for adequate storage
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub environmental_setting: Vec<MedicationKnowledgeStorageGuidelineEnvironmentalSetting>,
}

/// Setting or value of environment for adequate storage.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeStorageGuidelineEnvironmentalSetting {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Categorization of the setting
    pub r#type: types::CodeableConcept,

    /// The `MedicationKnowledge.storageGuideline.environmentalSetting.value[x]` choice element (0..1); see [`MedicationKnowledgeStorageGuidelineEnvironmentalSettingValue`].
    #[serde(flatten)]
    pub value: Option<MedicationKnowledgeStorageGuidelineEnvironmentalSettingValue>,
}

/// Regulatory information about a medication.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeRegulatory {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Specifies the authority of the regulation
    pub regulatory_authority: types::Reference,

    /// Specifies if changes are allowed when dispensing a medication from a regulatory perspective
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub substitution: Vec<MedicationKnowledgeRegulatorySubstitution>,

    /// Specifies the schedule of a medication in jurisdiction
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub schedule: Vec<types::CodeableConcept>,

    /// The maximum number of units of the medication that can be dispensed in a period
    pub max_dispense: Option<MedicationKnowledgeRegulatoryMaxDispense>,
}

/// Specifies if changes are allowed when dispensing a medication from a regulatory perspective.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeRegulatorySubstitution {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Specifies the type of substitution allowed
    pub r#type: types::CodeableConcept,

    /// Specifies if regulation allows for changes in the medication when dispensing
    pub allowed: types::Boolean,
    /// Primitive extension sibling for [`allowed`](Self::allowed) (FHIR `_allowed`).
    #[serde(rename = "_allowed")]
    pub allowed_ext: Option<types::Element>,
}

/// The maximum number of units of the medication that can be dispensed in a period.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeRegulatoryMaxDispense {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// The maximum number of units of the medication that can be dispensed
    pub quantity: types::Quantity,

    /// The period that applies to the maximum number of units
    pub period: Option<types::Duration>,
}

/// Minimal definition information about the medication.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeDefinitional {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Definitional resources that provide more information about this medication
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub definition: Vec<types::Reference>,

    /// powder | tablets | capsule +
    pub dose_form: Option<types::CodeableConcept>,

    /// The intended or approved route of administration
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub intended_route: Vec<types::CodeableConcept>,

    /// Active or inactive ingredient
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub ingredient: Vec<MedicationKnowledgeDefinitionalIngredient>,

    /// Specifies descriptive properties of the medicine
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub drug_characteristic: Vec<MedicationKnowledgeDefinitionalDrugCharacteristic>,
}

/// Active or inactive ingredient.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeDefinitionalIngredient {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Substances contained in the medication
    pub item: types::CodeableReference,

    /// A code that defines the type of ingredient, active, base, etc
    pub r#type: Option<types::CodeableConcept>,

    /// The `MedicationKnowledge.definitional.ingredient.strength[x]` choice element (0..1); see [`MedicationKnowledgeDefinitionalIngredientStrength`].
    #[serde(flatten)]
    pub strength: Option<MedicationKnowledgeDefinitionalIngredientStrength>,
}

/// Specifies descriptive properties of the medicine.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct MedicationKnowledgeDefinitionalDrugCharacteristic {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Code specifying the type of characteristic of medication
    pub r#type: Option<types::CodeableConcept>,

    /// The `MedicationKnowledge.definitional.drugCharacteristic.value[x]` choice element (0..1); see [`MedicationKnowledgeDefinitionalDrugCharacteristicValue`].
    #[serde(flatten)]
    pub value: Option<MedicationKnowledgeDefinitionalDrugCharacteristicValue>,
}

#[cfg(test)]
mod tests {
    use super::*;
    type T = MedicationKnowledge;

    #[test]
    fn test_default() {
        let _ = T::default();
    }

    #[test]
    fn test_serde_round_trip() {
        let value = T::default();
        let json = ::serde_json::to_value(&value).expect("to_value");
        let back: T = ::serde_json::from_value(json).expect("from_value");
        assert_eq!(value, back);
    }
}
/// The `MedicationKnowledge.cost.cost[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum MedicationKnowledgeCostCost {
    /// `costMoney` variant.
    #[fhir("costMoney")]
    Money(Box<types::Money>),
    /// `costCodeableConcept` variant.
    #[fhir("costCodeableConcept")]
    CodeableConcept(Box<types::CodeableConcept>),
}

/// The `MedicationKnowledge.definitional.drugCharacteristic.value[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum MedicationKnowledgeDefinitionalDrugCharacteristicValue {
    /// `valueCodeableConcept` variant.
    #[fhir("valueCodeableConcept")]
    CodeableConcept(Box<types::CodeableConcept>),
    /// `valueString` variant.
    #[fhir("valueString")]
    String(crate::r5::choice::Primitive<types::String>),
    /// `valueQuantity` variant.
    #[fhir("valueQuantity")]
    Quantity(Box<types::Quantity>),
    /// `valueBase64Binary` variant.
    #[fhir("valueBase64Binary")]
    Base64Binary(crate::r5::choice::Primitive<types::Base64Binary>),
    /// `valueAttachment` variant.
    #[fhir("valueAttachment")]
    Attachment(Box<types::Attachment>),
}

/// The `MedicationKnowledge.definitional.ingredient.strength[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum MedicationKnowledgeDefinitionalIngredientStrength {
    /// `strengthRatio` variant.
    #[fhir("strengthRatio")]
    Ratio(Box<types::Ratio>),
    /// `strengthCodeableConcept` variant.
    #[fhir("strengthCodeableConcept")]
    CodeableConcept(Box<types::CodeableConcept>),
    /// `strengthQuantity` variant.
    #[fhir("strengthQuantity")]
    Quantity(Box<types::Quantity>),
}

/// The `MedicationKnowledge.indicationGuideline.dosingGuideline.patientCharacteristic.value[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum MedicationKnowledgeIndicationGuidelineDosingGuidelinePatientCharacteristicValue {
    /// `valueCodeableConcept` variant.
    #[fhir("valueCodeableConcept")]
    CodeableConcept(Box<types::CodeableConcept>),
    /// `valueQuantity` variant.
    #[fhir("valueQuantity")]
    Quantity(Box<types::Quantity>),
    /// `valueRange` variant.
    #[fhir("valueRange")]
    Range(Box<types::Range>),
}

/// The `MedicationKnowledge.medicineClassification.source[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum MedicationKnowledgeMedicineClassificationSource {
    /// `sourceString` variant.
    #[fhir("sourceString")]
    String(crate::r5::choice::Primitive<types::String>),
    /// `sourceUri` variant.
    #[fhir("sourceUri")]
    Uri(crate::r5::choice::Primitive<types::Uri>),
}

/// The `MedicationKnowledge.storageGuideline.environmentalSetting.value[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum MedicationKnowledgeStorageGuidelineEnvironmentalSettingValue {
    /// `valueQuantity` variant.
    #[fhir("valueQuantity")]
    Quantity(Box<types::Quantity>),
    /// `valueRange` variant.
    #[fhir("valueRange")]
    Range(Box<types::Range>),
    /// `valueCodeableConcept` variant.
    #[fhir("valueCodeableConcept")]
    CodeableConcept(Box<types::CodeableConcept>),
}