1use nutype::nutype;
26#[allow(unused_imports)]
27use serde::{Deserialize, Serialize};
28use std::fmt;
29
30#[nutype(
31 sanitize(trim),
32 validate(not_empty, len_char_max = 1000),
33 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
34)]
35pub struct FeedingInstruction(String);
37
38#[nutype(
39 sanitize(trim),
40 validate(not_empty, len_char_max = 120),
41 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
42)]
43pub struct AllergyName(String);
45
46#[nutype(
47 sanitize(trim),
48 validate(not_empty, len_char_max = 160),
49 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
50)]
51pub struct MedicalConditionName(String);
53
54#[nutype(
55 sanitize(trim),
56 validate(not_empty, len_char_max = 1000),
57 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
58)]
59pub struct MedicalNote(String);
61
62#[nutype(
63 sanitize(trim),
64 validate(not_empty, len_char_max = 160),
65 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
66)]
67pub struct ContactName(String);
69
70#[nutype(
71 sanitize(trim),
72 validate(not_empty, len_char_max = 160),
73 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
74)]
75pub struct MedicationName(String);
77
78#[nutype(
79 sanitize(trim),
80 validate(not_empty, len_char_max = 160),
81 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
82)]
83pub struct MedicationDose(String);
85
86#[nutype(
87 sanitize(trim),
88 validate(not_empty, len_char_max = 400),
89 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
90)]
91pub struct MedicationSchedule(String);
93
94#[nutype(
95 sanitize(trim),
96 validate(not_empty, len_char_max = 400),
97 derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)
98)]
99pub struct ReviewReason(String);
101
102macro_rules! redacted_debug {
103 ($type:ident, $label:literal) => {
104 impl fmt::Debug for $type {
105 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
106 formatter.write_str($label)
107 }
108 }
109 };
110}
111
112redacted_debug!(FeedingInstruction, "FeedingInstruction(<redacted>)");
113redacted_debug!(AllergyName, "AllergyName(<redacted>)");
114redacted_debug!(MedicalConditionName, "MedicalConditionName(<redacted>)");
115redacted_debug!(MedicalNote, "MedicalNote(<redacted>)");
116redacted_debug!(ContactName, "ContactName(<redacted>)");
117redacted_debug!(MedicationName, "MedicationName(<redacted>)");
118redacted_debug!(MedicationDose, "MedicationDose(<redacted>)");
119redacted_debug!(MedicationSchedule, "MedicationSchedule(<redacted>)");
120redacted_debug!(ReviewReason, "ReviewReason(<redacted>)");
121
122#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
123pub struct ContactRef {
125 pub name: ContactName,
127}
128
129impl ContactRef {
130 pub fn new(name: ContactName) -> Self {
132 Self { name }
133 }
134}
135
136#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
137pub enum MedicationReviewRequirement {
139 NotRequired,
141 RequiresReview {
143 reason: ReviewReason,
145 },
146}
147
148impl MedicationReviewRequirement {
149 pub fn requires_review(&self) -> bool {
151 matches!(self, Self::RequiresReview { .. })
152 }
153}