Skip to main content

BloodType

Enum BloodType 

Source
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

Source

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-");
Source

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 as O+.
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 supported

Trait Implementations§

Source§

impl Clone for BloodType

Source§

fn clone(&self) -> BloodType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BloodType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BloodType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for BloodType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for BloodType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BloodType

Source§

fn eq(&self, other: &BloodType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BloodType

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for BloodType

Source§

impl Eq for BloodType

Source§

impl StructuralPartialEq for BloodType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,