1use nutype::nutype;
9#[allow(unused_imports)]
10use serde::{Deserialize, Serialize};
11use std::fmt;
12
13#[nutype(
14 sanitize(trim),
15 validate(not_empty, len_char_max = 1000),
16 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
17)]
18pub struct FeedingInstruction(String);
20
21#[nutype(
22 sanitize(trim),
23 validate(not_empty, len_char_max = 120),
24 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
25)]
26pub struct AllergyName(String);
28
29#[nutype(
30 sanitize(trim),
31 validate(not_empty, len_char_max = 160),
32 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
33)]
34pub struct MedicalConditionName(String);
36
37#[nutype(
38 sanitize(trim),
39 validate(not_empty, len_char_max = 1000),
40 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
41)]
42pub struct MedicalNote(String);
44
45#[nutype(
46 sanitize(trim),
47 validate(not_empty, len_char_max = 160),
48 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
49)]
50pub struct ContactName(String);
52
53#[nutype(
54 sanitize(trim),
55 validate(not_empty, len_char_max = 160),
56 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
57)]
58pub struct MedicationName(String);
60
61#[nutype(
62 sanitize(trim),
63 validate(not_empty, len_char_max = 160),
64 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
65)]
66pub struct MedicationDose(String);
68
69#[nutype(
70 sanitize(trim),
71 validate(not_empty, len_char_max = 400),
72 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
73)]
74pub struct MedicationSchedule(String);
76
77#[nutype(
78 sanitize(trim),
79 validate(not_empty, len_char_max = 400),
80 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
81)]
82pub struct ReviewReason(String);
84
85macro_rules! redacted_debug {
86 ($type:ident, $label:literal) => {
87 impl fmt::Debug for $type {
88 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
89 formatter.write_str($label)
90 }
91 }
92 };
93}
94
95redacted_debug!(FeedingInstruction, "FeedingInstruction(<redacted>)");
96redacted_debug!(AllergyName, "AllergyName(<redacted>)");
97redacted_debug!(MedicalConditionName, "MedicalConditionName(<redacted>)");
98redacted_debug!(MedicalNote, "MedicalNote(<redacted>)");
99redacted_debug!(ContactName, "ContactName(<redacted>)");
100redacted_debug!(MedicationName, "MedicationName(<redacted>)");
101redacted_debug!(MedicationDose, "MedicationDose(<redacted>)");
102redacted_debug!(MedicationSchedule, "MedicationSchedule(<redacted>)");
103redacted_debug!(ReviewReason, "ReviewReason(<redacted>)");
104
105#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
106pub struct ContactRef {
108 pub name: ContactName,
110}
111
112impl ContactRef {
113 pub fn new(name: ContactName) -> Self {
115 Self { name }
116 }
117}
118
119#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
120pub enum MedicationReviewRequirement {
122 NotRequired,
124 RequiresReview {
126 reason: ReviewReason,
128 },
129}
130
131impl MedicationReviewRequirement {
132 pub fn requires_review(&self) -> bool {
134 matches!(self, Self::RequiresReview { .. })
135 }
136}