fhir 1.2.0

Fast Healthcare Interoperability Resources (FHIR) data model for Rust: the complete FHIR R5, R4, and R3 resources, datatypes, and code systems as serde-serializable types, plus a spec-driven code generator.
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
//! DeviceDefinition
//!
//! URL: http://hl7.org/fhir/StructureDefinition/DeviceDefinition
//!
//! Version: 5.0.0
//!
//! DeviceDefinition Resource: This is a specialized resource that defines the characteristics and capabilities of a device.
//!
//! 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;

/// The characteristics, operational status and capabilities of a medical-related
/// component of a medical device.
///
/// The DeviceDefinition resource describes the "kind" of device, in contrast to
/// the Device resource which represents a specific instance. It captures
/// manufacturer information, identifiers, classifications, versions, properties,
/// materials, packaging, and regulatory details that are common to all instances
/// of that device model. It is used to catalog and reference device models across
/// clinical, administrative, and supply workflows.
///
/// Administratively, DeviceDefinition acts as a master catalog or product entry
/// that manufacturers, distributors, and healthcare organizations can publish and
/// reference so that individual device instances, orders, and regulatory
/// submissions do not need to repeat shared model-level data. Clinically, it
/// helps ensure that the correct kind of device (with its intended use,
/// contraindications, warnings, and conformance to standards) is selected and
/// tracked wherever it is used, for example in medication administration,
/// implant tracking, or supply chain management.
///
/// # See also
///
/// - [`types::Identifier`] for the business identifiers used across device
///   definitions and their UDI entries.
/// - [`types::CodeableConcept`] for coded classifications, properties, and
///   safety characteristics.
/// - [`types::Reference`] for links to related resources such as the owning
///   organization or manufacturer.
///
/// # Examples
///
/// ```
/// use fhir::r5::resources::device_definition::DeviceDefinition;
///
/// let value = DeviceDefinition::default();
/// let json = ::serde_json::to_value(&value).unwrap();
/// let back: DeviceDefinition = ::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 DeviceDefinition {
    /// 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>,

    /// Additional narrative information to describe the device model, its intended purpose, and general use
    pub description: Option<types::Markdown>,
    /// Primitive extension sibling for [`description`](Self::description) (FHIR `_description`).
    #[serde(rename = "_description")]
    pub description_ext: Option<types::Element>,

    /// Business identifier(s) for this device definition, assigned by the manufacturer or a regulatory body
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub identifier: Vec<types::Identifier>,

    /// Unique Device Identifier (UDI) Barcode string
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub udi_device_identifier: Vec<DeviceDefinitionUdiDeviceIdentifier>,

    /// Regulatory identifier(s) associated with this device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub regulatory_identifier: Vec<DeviceDefinitionRegulatoryIdentifier>,

    /// The part number or catalog number of the device
    pub part_number: Option<types::String>,
    /// Primitive extension sibling for [`part_number`](Self::part_number) (FHIR `_partNumber`).
    #[serde(rename = "_partNumber")]
    pub part_number_ext: Option<types::Element>,

    /// Name of device manufacturer, as a reference to an Organization resource
    pub manufacturer: Option<types::Reference>,

    /// The name or names of the device as given by the manufacturer
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub device_name: Vec<DeviceDefinitionDeviceName>,

    /// The catalog or model number for the device for example as defined by the manufacturer
    pub model_number: Option<types::String>,
    /// Primitive extension sibling for [`model_number`](Self::model_number) (FHIR `_modelNumber`).
    #[serde(rename = "_modelNumber")]
    pub model_number_ext: Option<types::Element>,

    /// What kind of device or device system this is, e.g. its risk class or device category
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub classification: Vec<DeviceDefinitionClassification>,

    /// Identifies the standards, specifications, or formal guidances for the capabilities supported by the device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conforms_to: Vec<DeviceDefinitionConformsTo>,

    /// A device, part of the current one
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub has_part: Vec<DeviceDefinitionHasPart>,

    /// Information about the packaging of the device, i.e. how the device is packaged
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub packaging: Vec<DeviceDefinitionPackaging>,

    /// The version of the device or software
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub version: Vec<DeviceDefinitionVersion>,

    /// Safety characteristics of the device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub safety: Vec<types::CodeableConcept>,

    /// Shelf Life and storage information
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub shelf_life_storage: Vec<types::ProductShelfLife>,

    /// Language code for the human-readable text strings produced by the device (all supported)
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub language_code: Vec<types::CodeableConcept>,

    /// Inherent, essentially fixed, characteristics of this kind of device, e.g., time properties, size, etc
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub property: Vec<DeviceDefinitionProperty>,

    /// The organization responsible for device, typically the manufacturer or its authorized representative
    pub owner: Option<types::Reference>,

    /// Details for human/organization for support
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub contact: Vec<types::ContactPoint>,

    /// An associated device, attached to, used with, communicating with or linking a previous or new device model to the focal device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub link: Vec<DeviceDefinitionLink>,

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

    /// A substance used to create the material(s) of which the device is made
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub material: Vec<DeviceDefinitionMaterial>,

    /// lot-number | manufactured-date | serial-number | expiration-date | biological-source | software-version
    #[serde(rename = "productionIdentifierInUDI")]
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub production_identifier_in_udi: Vec<crate::r5::coded::Coded<crate::r5::codes::DeviceProductidentifierinudi>>,

    /// Information aimed at providing directions for the usage of this model of device
    pub guideline: Option<DeviceDefinitionGuideline>,

    /// Tracking of latest field safety corrective action
    pub corrective_action: Option<DeviceDefinitionCorrectiveAction>,

    /// Billing code or reference associated with the device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub charge_item: Vec<DeviceDefinitionChargeItem>,
}

/// Unique Device Identifier (UDI) Barcode string.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionUdiDeviceIdentifier {
    /// 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 identifier that is to be associated with every Device that references this DeviceDefintiion for the issuer and jurisdiction provided in the DeviceDefinition.udiDeviceIdentifier
    pub device_identifier: types::String,
    /// Primitive extension sibling for [`device_identifier`](Self::device_identifier) (FHIR `_deviceIdentifier`).
    #[serde(rename = "_deviceIdentifier")]
    pub device_identifier_ext: Option<types::Element>,

    /// The organization that assigns the identifier algorithm
    pub issuer: types::Uri,
    /// Primitive extension sibling for [`issuer`](Self::issuer) (FHIR `_issuer`).
    #[serde(rename = "_issuer")]
    pub issuer_ext: Option<types::Element>,

    /// The jurisdiction to which the deviceIdentifier applies
    pub jurisdiction: types::Uri,
    /// Primitive extension sibling for [`jurisdiction`](Self::jurisdiction) (FHIR `_jurisdiction`).
    #[serde(rename = "_jurisdiction")]
    pub jurisdiction_ext: Option<types::Element>,

    /// Indicates whether and when the device is available on the market
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub market_distribution: Vec<DeviceDefinitionUdiDeviceIdentifierMarketDistribution>,
}

/// Indicates whether and when the device is available on the market.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionUdiDeviceIdentifierMarketDistribution {
    /// 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>,

    /// Begin and end dates for the commercial distribution of the device
    pub market_period: types::Period,

    /// National state or territory where the device is commercialized
    pub sub_jurisdiction: types::Uri,
    /// Primitive extension sibling for [`sub_jurisdiction`](Self::sub_jurisdiction) (FHIR `_subJurisdiction`).
    #[serde(rename = "_subJurisdiction")]
    pub sub_jurisdiction_ext: Option<types::Element>,
}

/// Regulatory identifier(s) associated with this device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionRegulatoryIdentifier {
    /// 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>,

    /// basic | master | license
    pub r#type: crate::r5::coded::Coded<crate::r5::codes::DevicedefinitionRegulatoryIdentifierType>,
    /// Primitive extension sibling for [`type`](Self::r#type) (FHIR `_type`).
    #[serde(rename = "_type")]
    pub type_ext: Option<types::Element>,

    /// The identifier itself
    pub device_identifier: types::String,
    /// Primitive extension sibling for [`device_identifier`](Self::device_identifier) (FHIR `_deviceIdentifier`).
    #[serde(rename = "_deviceIdentifier")]
    pub device_identifier_ext: Option<types::Element>,

    /// The organization that issued this identifier
    pub issuer: types::Uri,
    /// Primitive extension sibling for [`issuer`](Self::issuer) (FHIR `_issuer`).
    #[serde(rename = "_issuer")]
    pub issuer_ext: Option<types::Element>,

    /// The jurisdiction to which the deviceIdentifier applies
    pub jurisdiction: types::Uri,
    /// Primitive extension sibling for [`jurisdiction`](Self::jurisdiction) (FHIR `_jurisdiction`).
    #[serde(rename = "_jurisdiction")]
    pub jurisdiction_ext: Option<types::Element>,
}

/// The name or names of the device as given by the manufacturer.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionDeviceName {
    /// 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>,

    /// A name that is used to refer to the device
    pub name: types::String,
    /// Primitive extension sibling for [`name`](Self::name) (FHIR `_name`).
    #[serde(rename = "_name")]
    pub name_ext: Option<types::Element>,

    /// registered-name | user-friendly-name | patient-reported-name
    pub r#type: crate::r5::coded::Coded<crate::r5::codes::DeviceNametype>,
    /// Primitive extension sibling for [`type`](Self::r#type) (FHIR `_type`).
    #[serde(rename = "_type")]
    pub type_ext: Option<types::Element>,
}

/// What kind of device or device system this is.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionClassification {
    /// 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>,

    /// A classification or risk class of the device model
    pub r#type: types::CodeableConcept,

    /// Further information qualifying this classification of the device model
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub justification: Vec<types::RelatedArtifact>,
}

/// Identifies the standards, specifications, or formal guidances for the
/// capabilities supported by the device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionConformsTo {
    /// 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>,

    /// Describes the common type of the standard, specification, or formal guidance
    pub category: Option<types::CodeableConcept>,

    /// Identifies the standard, specification, or formal guidance that the device adheres to the Device Specification type
    pub specification: types::CodeableConcept,

    /// The specific form or variant of the standard, specification or formal guidance
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub version: Vec<types::String>,
    /// Primitive extension sibling for [`version`](Self::version) (FHIR `_version`).
    #[serde(rename = "_version")]
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub version_ext: Vec<Option<types::Element>>,

    /// Standard, regulation, certification, or guidance website, document, or other publication, or similar, supporting the conformance
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub source: Vec<types::RelatedArtifact>,
}

/// A device, part of the current one.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionHasPart {
    /// 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 the part
    pub reference: types::Reference,

    /// Number of occurrences of the part
    pub count: Option<types::Integer>,
    /// Primitive extension sibling for [`count`](Self::count) (FHIR `_count`).
    #[serde(rename = "_count")]
    pub count_ext: Option<types::Element>,
}

/// Information about the packaging of the device, i.e. how the device is packaged.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionPackaging {
    /// 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>,

    /// Business identifier of the packaged medication
    pub identifier: Option<types::Identifier>,

    /// A code that defines the specific type of packaging
    pub r#type: Option<types::CodeableConcept>,

    /// The number of items contained in the package (devices or sub-packages)
    pub count: Option<types::Integer>,
    /// Primitive extension sibling for [`count`](Self::count) (FHIR `_count`).
    #[serde(rename = "_count")]
    pub count_ext: Option<types::Element>,

    /// An organization that distributes the packaged device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub distributor: Vec<DeviceDefinitionPackagingDistributor>,

    /// Unique Device Identifier (UDI) Barcode string on the packaging
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub udi_device_identifier: Vec<DeviceDefinitionUdiDeviceIdentifier>,

    /// Allows packages within packages
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub packaging: Vec<DeviceDefinitionPackaging>,
}

/// An organization that distributes the packaged device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionPackagingDistributor {
    /// 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>,

    /// Distributor's human-readable name
    pub name: Option<types::String>,
    /// Primitive extension sibling for [`name`](Self::name) (FHIR `_name`).
    #[serde(rename = "_name")]
    pub name_ext: Option<types::Element>,

    /// Distributor as an Organization resource
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub organization_reference: Vec<types::Reference>,
}

/// The version of the device or software.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionVersion {
    /// 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 the device version, e.g. manufacturer, approved, internal
    pub r#type: Option<types::CodeableConcept>,

    /// The hardware or software module of the device to which the version applies
    pub component: Option<types::Identifier>,

    /// The version text
    pub value: types::String,
    /// Primitive extension sibling for [`value`](Self::value) (FHIR `_value`).
    #[serde(rename = "_value")]
    pub value_ext: Option<types::Element>,
}

/// Inherent, essentially fixed, characteristics of this kind of device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionProperty {
    /// 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 that specifies the property being represented
    pub r#type: types::CodeableConcept,

    /// The `DeviceDefinition.property.value[x]` choice element (0..1); see [`DeviceDefinitionPropertyValue`].
    #[serde(flatten)]
    pub value: Option<DeviceDefinitionPropertyValue>,
}

/// An associated device, linking a previous or new device model to the focal
/// device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionLink {
    /// 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 indicates the relationship of the related device to the device instance
    pub relation: types::Coding,

    /// A reference to the linked device
    pub related_device: types::CodeableReference,
}

/// A substance used to create the material(s) of which the device is made.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionMaterial {
    /// 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>,

    /// A relevant substance that the device contains, may contain, or is made of
    pub substance: types::CodeableConcept,

    /// Indicates an alternative material of the device
    pub alternate: Option<types::Boolean>,
    /// Primitive extension sibling for [`alternate`](Self::alternate) (FHIR `_alternate`).
    #[serde(rename = "_alternate")]
    pub alternate_ext: Option<types::Element>,

    /// Whether the substance is a known or suspected allergen
    pub allergenic_indicator: Option<types::Boolean>,
    /// Primitive extension sibling for [`allergenic_indicator`](Self::allergenic_indicator) (FHIR `_allergenicIndicator`).
    #[serde(rename = "_allergenicIndicator")]
    pub allergenic_indicator_ext: Option<types::Element>,
}

/// Information aimed at providing directions for the usage of this model of
/// device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionGuideline {
    /// 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 circumstances that form the setting for using the device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub use_context: Vec<types::UsageContext>,

    /// Detailed written and visual directions for the user on how to use the device
    pub usage_instruction: Option<types::Markdown>,
    /// Primitive extension sibling for [`usage_instruction`](Self::usage_instruction) (FHIR `_usageInstruction`).
    #[serde(rename = "_usageInstruction")]
    pub usage_instruction_ext: Option<types::Element>,

    /// A source of information or reference for this guideline
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub related_artifact: Vec<types::RelatedArtifact>,

    /// A clinical condition for which the device was designed to be used
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub indication: Vec<types::CodeableConcept>,

    /// A specific situation when a device should not be used because it may cause harm
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub contraindication: Vec<types::CodeableConcept>,

    /// Specific hazard alert information that a user needs to know before using the device
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub warning: Vec<types::CodeableConcept>,

    /// A description of the general purpose or medical use of the device or its function
    pub intended_use: Option<types::String>,
    /// Primitive extension sibling for [`intended_use`](Self::intended_use) (FHIR `_intendedUse`).
    #[serde(rename = "_intendedUse")]
    pub intended_use_ext: Option<types::Element>,
}

/// Tracking of latest field safety corrective action.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionCorrectiveAction {
    /// 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>,

    /// Whether the corrective action was a recall
    pub recall: types::Boolean,
    /// Primitive extension sibling for [`recall`](Self::recall) (FHIR `_recall`).
    #[serde(rename = "_recall")]
    pub recall_ext: Option<types::Element>,

    /// model | lot-numbers | serial-numbers
    pub scope: Option<crate::r5::coded::Coded<crate::r5::codes::DeviceCorrectiveactionscope>>,
    /// Primitive extension sibling for [`scope`](Self::scope) (FHIR `_scope`).
    #[serde(rename = "_scope")]
    pub scope_ext: Option<types::Element>,

    /// Start and end dates of the corrective action
    pub period: types::Period,
}

/// Billing code or reference associated with the device.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDefinitionChargeItem {
    /// 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 code or reference for the charge item
    pub charge_item_code: types::CodeableReference,

    /// Coefficient applicable to the billing code
    pub count: types::Quantity,

    /// A specific time period in which this charge item applies
    pub effective_period: Option<types::Period>,

    /// The context to which this charge item applies
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub use_context: Vec<types::UsageContext>,
}

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

    #[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 `DeviceDefinition.property.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 DeviceDefinitionPropertyValue {
    /// `valueQuantity` variant.
    #[fhir("valueQuantity")]
    Quantity(Box<types::Quantity>),
    /// `valueCodeableConcept` variant.
    #[fhir("valueCodeableConcept")]
    CodeableConcept(Box<types::CodeableConcept>),
    /// `valueString` variant.
    #[fhir("valueString")]
    String(crate::r5::choice::Primitive<types::String>),
    /// `valueBoolean` variant.
    #[fhir("valueBoolean")]
    Boolean(crate::r5::choice::Primitive<types::Boolean>),
    /// `valueInteger` variant.
    #[fhir("valueInteger")]
    Integer(crate::r5::choice::Primitive<types::Integer>),
    /// `valueRange` variant.
    #[fhir("valueRange")]
    Range(Box<types::Range>),
    /// `valueAttachment` variant.
    #[fhir("valueAttachment")]
    Attachment(Box<types::Attachment>),
}