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
//! DeviceUsage
//!
//! URL: http://hl7.org/fhir/StructureDefinition/DeviceUsage
//!
//! Version: 5.0.0
//!
//! DeviceUsage Resource: A record of a device being used by a patient where the record is the result of a report from the patient or a clinician.
//!
//! 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;
/// A record of a device being used by a patient where the record is the result
/// of a report from the patient or a clinician.
///
/// DeviceUsage records that a patient is or was using a particular device. In
/// FHIR R5 it captures who is using the device, which device is involved, the
/// timing and context of the usage, and any adherence, status, or reason
/// information supplied by the patient or a clinician. It is commonly used to
/// track patient-reported or clinician-reported device use over time.
///
/// Unlike [`DeviceRequest`](crate::r5::resources::device_request::DeviceRequest),
/// which represents an order or proposal for device use, DeviceUsage is a
/// statement of fact describing actual (or historical) use as reported by the
/// patient, a caregiver, or a clinician; it is not itself an authorization. It
/// is administratively useful for medication-reconciliation-style workflows for
/// durable medical equipment and other devices, for tracking compliance with a
/// prescribed device regimen, and for capturing why a patient stopped, changed,
/// or continued using a device.
///
/// # Related resources
///
/// - [`Patient`](crate::r5::resources::patient::Patient) — the subject who is using the device.
/// - `Device` — the physical or virtual device being used, referenced via the `device` field.
/// - [`CodeableConcept`](crate::r5::types::CodeableConcept) — used for coded values such as `usage_status` and `usage_reason`.
/// - `Encounter` — the encounter or episode of care providing context, referenced via `context`.
///
/// # Examples
///
/// ```
/// use fhir::r5::resources::device_usage::DeviceUsage;
///
/// let value = DeviceUsage::default();
/// let json = ::serde_json::to_value(&value).unwrap();
/// let back: DeviceUsage = ::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 DeviceUsage {
/// 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>,
/// External identifier for this record
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub identifier: Vec<types::Identifier>,
/// Fulfills plan, proposal or order
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub based_on: Vec<types::Reference>,
/// The current state of this device usage record: active | completed | not-done | entered-in-error +
pub status: crate::r5::coded::Coded<crate::r5::codes::DeviceusageStatus>,
/// Primitive extension sibling for [`status`](Self::status) (FHIR `_status`).
#[serde(rename = "_status")]
pub status_ext: Option<types::Element>,
/// The category of the statement - classifying how the statement is made
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub category: Vec<types::CodeableConcept>,
/// A reference to the [`Patient`](crate::r5::resources::patient::Patient) (or group) reported to be using the device
pub patient: types::Reference,
/// Supporting information
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub derived_from: Vec<types::Reference>,
/// The encounter or episode of care that establishes the context for this device use statement
pub context: Option<types::Reference>,
/// The `DeviceUsage.timing[x]` choice element (0..1); see [`DeviceUsageTiming`].
#[serde(flatten)]
pub timing: Option<DeviceUsageTiming>,
/// When the statement was made (and recorded)
pub date_asserted: Option<types::DateTime>,
/// Primitive extension sibling for [`date_asserted`](Self::date_asserted) (FHIR `_dateAsserted`).
#[serde(rename = "_dateAsserted")]
pub date_asserted_ext: Option<types::Element>,
/// The status of the device usage, for example always, sometimes, never. This is not the same as the status of the statement
pub usage_status: Option<types::CodeableConcept>,
/// The reason for asserting the usage status - for example forgot, lost, stolen, broken
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub usage_reason: Vec<types::CodeableConcept>,
/// How device is being used
pub adherence: Option<DeviceUsageAdherence>,
/// Who made the statement
pub information_source: Option<types::Reference>,
/// The device that was used, given either as a coded value or as a reference to a `Device` resource
pub device: types::CodeableReference,
/// Why device was used
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub reason: Vec<types::CodeableReference>,
/// Target body site
pub body_site: Option<types::CodeableReference>,
/// Addition details (comments, instructions)
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub note: Vec<types::Annotation>,
}
/// How device is being used.
///
/// Backbone element describing the patient's adherence to the device usage,
/// including a code such as always, never, or sometimes, and the reasons that
/// explain that adherence status.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct DeviceUsageAdherence {
/// 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>,
/// always | never | sometimes
pub code: types::CodeableConcept,
/// lost | stolen | prescribed | broken | burned | forgot
pub reason: vec1::Vec1<types::CodeableConcept>,
}
#[cfg(test)]
mod tests {
use super::*;
type T = DeviceUsage;
#[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 `DeviceUsage.timing[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 DeviceUsageTiming {
/// `timingTiming` variant.
#[fhir("timingTiming")]
Timing(Box<types::Timing>),
/// `timingPeriod` variant.
#[fhir("timingPeriod")]
Period(Box<types::Period>),
/// `timingDateTime` variant.
#[fhir("timingDateTime")]
DateTime(crate::r5::choice::Primitive<types::DateTime>),
}