Skip to main content

domain/
care.rs

1//! Care-plan and medical-instruction value objects for safe resort workflows.
2//!
3//! Care data is sensitive source evidence: these values promote provider/customer facts
4//! into redacted, validated domain types before staff tasks, daily briefs, or customer
5//! messaging can use them. Review requirements make medication and special-handling labor
6//! explicit instead of hiding the work in free-text notes.
7
8use 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)]
18/// Redacted feeding instructions that can create care tasks and labor requirements.
19pub 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)]
26/// Redacted allergy label that guards unsafe care or grooming recommendations.
27pub 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)]
34/// Redacted medical-condition label requiring careful human handling.
35pub 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)]
42/// Redacted medical note retained as evidence, not as autonomous medical advice.
43pub 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)]
50/// Redacted staff/customer contact name for care-plan coordination.
51pub 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)]
58/// Redacted medication name used to schedule administration work safely.
59pub 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)]
66/// Redacted medication dose retained for staff review and audit trails.
67pub 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)]
74/// Redacted medication schedule that can drive labor and shift-handoff tasks.
75pub 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)]
82/// Redacted reason explaining why care-team review is required before action.
83pub 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)]
106/// Named staff or customer contact used for care-plan coordination.
107pub struct ContactRef {
108    /// Contact or display name used by staff.
109    pub name: ContactName,
110}
111
112impl ContactRef {
113    /// Assembles this care value from already-validated domain parts.
114    pub fn new(name: ContactName) -> Self {
115        Self { name }
116    }
117}
118
119#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
120/// Whether medication instructions require additional care-team review.
121pub enum MedicationReviewRequirement {
122    /// Medication instructions do not add a review gate beyond normal staff handling.
123    NotRequired,
124    /// Business reason staff should review before proceeding.
125    RequiresReview {
126        /// Reason carried by this variant.
127        reason: ReviewReason,
128    },
129}
130
131impl MedicationReviewRequirement {
132    /// Returns whether care-team review is required before proceeding.
133    pub fn requires_review(&self) -> bool {
134        matches!(self, Self::RequiresReview { .. })
135    }
136}