pub enum BloodType {
APositive,
ANegative,
BPositive,
BNegative,
ABPositive,
ABNegative,
OPositive,
ONegative,
}Expand description
ABO + RhD blood type used as supporting evidence in worker matcher.
Blood type is a weak positive signal and a strong negative signal:
- Many people share a blood type (≈38% of the US population is O+), so agreement alone is not strong evidence of a match.
- Two records with disagreeing blood types almost certainly refer to different people — blood type does not change over a lifetime (modulo bone-marrow transplant edge cases).
The matcher therefore weights blood type at the same low level as
gender by default (MatchConfig::blood_type_weight = 0.05) but the
per-field score in MatchBreakdown::blood_type_score is surfaced
for downstream consumers that want to flag disagreement explicitly.
Blood type is not an identifying field for Worker::validate,
and it is not consulted by deterministic_match — disagreement
is a soft signal, not a binary disqualifier.
§JSON
Variants serialise as their canonical short form ("A+", "O-",
"AB+", etc.) via #[serde(rename = …)].
use worker_matcher::BloodType;
assert_eq!(serde_json::to_string(&BloodType::APositive).unwrap(), "\"A+\"");
let back: BloodType = serde_json::from_str("\"AB-\"").unwrap();
assert_eq!(back, BloodType::ABNegative);§Parsing
BloodType::parse accepts the canonical short forms plus the
most common textual layouts found in real EMR data:
use worker_matcher::BloodType;
assert_eq!(BloodType::parse("A+"), Some(BloodType::APositive));
assert_eq!(BloodType::parse("a positive"), Some(BloodType::APositive));
assert_eq!(BloodType::parse("AB neg"), Some(BloodType::ABNegative));
assert_eq!(BloodType::parse("O-"), Some(BloodType::ONegative));
assert_eq!(BloodType::parse("0+"), Some(BloodType::OPositive)); // zero/O confusion
assert_eq!(BloodType::parse(""), None);
assert_eq!(BloodType::parse("Z+"), None);Variants§
APositive
A positive (A+).
ANegative
A negative (A−).
BPositive
B positive (B+).
BNegative
B negative (B−).
ABPositive
AB positive (AB+). Universal red-cell recipient.
ABNegative
AB negative (AB−). Rare; universal-plasma donor.
OPositive
O positive (O+). Most common worldwide.
ONegative
O negative (O−). Universal red-cell donor.
Implementations§
Source§impl BloodType
impl BloodType
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
Canonical short form: "A+", "A-", "B+", "B-", "AB+",
"AB-", "O+", "O-".
use worker_matcher::BloodType;
assert_eq!(BloodType::APositive.as_str(), "A+");
assert_eq!(BloodType::ABNegative.as_str(), "AB-");Sourcepub fn parse(s: &str) -> Option<BloodType>
pub fn parse(s: &str) -> Option<BloodType>
Parse a blood-type string, accepting canonical short forms as
well as the common textual layouts seen in EMR / HL7 data.
Returns None for unparseable, empty, or rare-phenotype input;
consumers that need to preserve a rare phenotype should store
the raw string elsewhere.
Accepted shapes (case-insensitive, whitespace tolerated):
- Canonical:
A+,A-,B+,B-,AB+,AB-,O+,O-. - Word forms:
A positive,A pos,A negative,A neg. - With sign-separator:
A_pos,A-neg,AB +. - With zero/O confusion:
0+is read asO+.
use worker_matcher::BloodType;
assert_eq!(BloodType::parse("O Negative"), Some(BloodType::ONegative));
assert_eq!(BloodType::parse("ab+"), Some(BloodType::ABPositive));
assert_eq!(BloodType::parse("Bombay"), None); // rare phenotype, not supportedTrait Implementations§
Source§impl<'de> Deserialize<'de> for BloodType
impl<'de> Deserialize<'de> for BloodType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for BloodType
impl Eq for BloodType
impl StructuralPartialEq for BloodType
Auto Trait Implementations§
impl Freeze for BloodType
impl RefUnwindSafe for BloodType
impl Send for BloodType
impl Sync for BloodType
impl Unpin for BloodType
impl UnsafeUnpin for BloodType
impl UnwindSafe for BloodType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more