wellfare_core/anatomy/
systems.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct BodySystem {
9 pub id: &'static str,
10 pub label: &'static str,
11 pub plain_label: &'static str,
12}
13
14pub static BODY_SYSTEMS: &[BodySystem] = &[
16 BodySystem {
17 id: "circulatory",
18 label: "Circulatory (Cardiovascular) System",
19 plain_label: "heart and blood flow",
20 },
21 BodySystem {
22 id: "respiratory",
23 label: "Respiratory System",
24 plain_label: "breathing",
25 },
26 BodySystem {
27 id: "digestive",
28 label: "Digestive System",
29 plain_label: "digestion",
30 },
31 BodySystem {
32 id: "nervous",
33 label: "Nervous System",
34 plain_label: "brain and nerves",
35 },
36 BodySystem {
37 id: "muscular",
38 label: "Muscular System",
39 plain_label: "muscles",
40 },
41 BodySystem {
42 id: "skeletal",
43 label: "Skeletal System",
44 plain_label: "bones and joints",
45 },
46 BodySystem {
47 id: "endocrine",
48 label: "Endocrine System",
49 plain_label: "hormones",
50 },
51 BodySystem {
52 id: "immune_lymphatic",
53 label: "Immune / Lymphatic System",
54 plain_label: "immune defences",
55 },
56 BodySystem {
57 id: "integumentary",
58 label: "Integumentary System",
59 plain_label: "skin",
60 },
61 BodySystem {
62 id: "urinary",
63 label: "Urinary (Excretory) System",
64 plain_label: "kidneys and fluid balance",
65 },
66 BodySystem {
67 id: "reproductive",
68 label: "Reproductive System",
69 plain_label: "reproductive health",
70 },
71 BodySystem {
72 id: "sensory",
73 label: "Sensory System",
74 plain_label: "senses",
75 },
76 BodySystem {
77 id: "vestibular",
78 label: "Vestibular System",
79 plain_label: "balance",
80 },
81 BodySystem {
82 id: "exocrine",
83 label: "Exocrine System",
84 plain_label: "glands",
85 },
86 BodySystem {
87 id: "ecs",
88 label: "Endocannabinoid System (ECS)",
89 plain_label: "internal balance (ECS)",
90 },
91 BodySystem {
92 id: "ens",
93 label: "Enteric Nervous System (ENS)",
94 plain_label: "gut nerves",
95 },
96 BodySystem {
97 id: "glymphatic",
98 label: "Glymphatic System",
99 plain_label: "the brain's overnight cleaning",
100 },
101];
102
103pub fn body_system(id: &str) -> Option<&'static BodySystem> {
105 BODY_SYSTEMS.iter().find(|s| s.id == id)
106}
107
108pub fn body_system_by_label(label: &str) -> Option<&'static BodySystem> {
112 let want = label.trim().to_ascii_lowercase();
113 BODY_SYSTEMS
114 .iter()
115 .find(|s| s.label.to_ascii_lowercase() == want)
116}
117
118#[cfg(test)]
119mod tests {
120 use super::*;
121
122 #[test]
123 fn seventeen_systems_and_lookup() {
124 assert_eq!(BODY_SYSTEMS.len(), 17);
125 assert_eq!(body_system("digestive").unwrap().label, "Digestive System");
126 assert_eq!(body_system("digestive").unwrap().plain_label, "digestion");
127 assert!(body_system("nope").is_none());
128 assert!(BODY_SYSTEMS.iter().all(|s| !s.plain_label.is_empty()));
130 }
131
132 #[test]
133 fn label_lookup_maps_bundled_knowledge_labels_to_ids() {
134 assert_eq!(
136 body_system_by_label("Endocrine System").unwrap().id,
137 "endocrine"
138 );
139 assert_eq!(
140 body_system_by_label("Circulatory (Cardiovascular) System")
141 .unwrap()
142 .id,
143 "circulatory"
144 );
145 assert_eq!(
146 body_system_by_label(" urinary (excretory) system ")
147 .unwrap()
148 .id,
149 "urinary"
150 );
151 assert!(body_system_by_label("Not A System").is_none());
152 }
153}