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
//! Address
//!
//! URL: http://hl7.org/fhir/StructureDefinition/Address
//!
//! Version:
//!
//! An address expressed using postal conventions (as opposed to GPS or other
//! location definition formats)
//!
//! FHIR R3: <https://hl7.org/fhir/STU3/>
// The `types` import is unused by a handful of types that have only primitive fields.
#![allow(unused_imports)]
use crate::r3::types;
use ::serde::{Deserialize, Serialize};
use fhir_derive_macros::{Builder, Validate};
/// Base StructureDefinition for Address Type
///
/// # Examples
///
/// ```
/// use fhir::r3::types::address::Address;
///
/// let value = Address::default();
/// let json = ::serde_json::to_value(&value).unwrap();
/// let back: Address = ::serde_json::from_value(json).unwrap();
/// assert_eq!(value, back);
/// ```
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate, Builder)]
#[serde(rename_all = "camelCase")]
#[fhir_version("r3")]
pub struct Address {
/// xml:id (or equivalent in JSON)
pub id: Option<types::String>,
/// Additional Content defined by implementations
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub extension: Vec<types::Extension>,
/// home | work | temp | old - purpose of this address
pub r#use: Option<crate::coded::Coded<crate::r3::codes::AddressUse>>,
/// Primitive extension sibling for [`r#use`](Self::r#use) (FHIR `_use`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_use")]
pub use_ext: Option<types::Element>,
/// postal | physical | both
pub r#type: Option<crate::coded::Coded<crate::r3::codes::AddressType>>,
/// Primitive extension sibling for [`r#type`](Self::r#type) (FHIR `_type`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_type")]
pub type_ext: Option<types::Element>,
/// Text representation of the address
pub text: Option<types::String>,
/// Primitive extension sibling for [`text`](Self::text) (FHIR `_text`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_text")]
pub text_ext: Option<types::Element>,
/// Street name, number, direction & P.O. Box etc.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub line: Vec<types::String>,
/// Primitive extension sibling for [`line`](Self::line) (FHIR `_line`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_line")]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub line_ext: Vec<Option<types::Element>>,
/// Name of city, town etc.
pub city: Option<types::String>,
/// Primitive extension sibling for [`city`](Self::city) (FHIR `_city`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_city")]
pub city_ext: Option<types::Element>,
/// District name (aka county)
pub district: Option<types::String>,
/// Primitive extension sibling for [`district`](Self::district) (FHIR `_district`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_district")]
pub district_ext: Option<types::Element>,
/// Sub-unit of country (abbreviations ok)
pub state: Option<types::String>,
/// Primitive extension sibling for [`state`](Self::state) (FHIR `_state`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_state")]
pub state_ext: Option<types::Element>,
/// Postal code for area
pub postal_code: Option<types::String>,
/// Primitive extension sibling for [`postal_code`](Self::postal_code) (FHIR `_postalCode`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_postalCode")]
pub postal_code_ext: Option<types::Element>,
/// Country (e.g. can be ISO 3166 2 or 3 letter code)
pub country: Option<types::String>,
/// Primitive extension sibling for [`country`](Self::country) (FHIR `_country`):
/// carries `id` and/or `extension` for the primitive value.
#[serde(rename = "_country")]
pub country_ext: Option<types::Element>,
/// Time period when address was/is in use
pub period: Option<types::Period>,
}
#[cfg(test)]
mod tests {
use super::*;
type T = Address;
#[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);
}
}