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
//! id
//!
//! URL: http://hl7.org/fhir/StructureDefinition/id
//!
//! Version:
//!
//! FHIR R3: <https://hl7.org/fhir/STU3/>
use ::serde::{Deserialize, Serialize};
/// Base StructureDefinition for id type: Any combination of letters, numerals,
/// "-" and ".", with a length limit of 64 characters. (This might be an
/// integer, an unprefixed OID, UUID or any other identifier pattern that meets
/// these constraints.) Ids are case-insensitive.
///
/// # Examples
///
/// ```
/// use fhir::r3::types::id::Id;
///
/// let value = Id::default();
/// let json = ::serde_json::to_value(&value).unwrap();
/// let back: Id = ::serde_json::from_value(json).unwrap();
/// assert_eq!(value, back);
/// ```
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Id(
/// The logical id: up to 64 characters of `[A-Za-z0-9-.]`.
pub std::string::String,
);
#[cfg(test)]
mod tests {
use super::*;
use ::serde_json::json;
#[test]
fn test_default() {
assert_eq!(Id::default(), Id(std::string::String::new()));
}
#[test]
fn test_serde() {
let value = Id("pat-1".to_string());
let json = ::serde_json::to_value(&value).expect("to_value");
assert_eq!(json, json!("pat-1"));
let back: Id = ::serde_json::from_value(json).expect("from_value");
assert_eq!(value, back);
}
}