Skip to main content

WorkerBuilder

Struct WorkerBuilder 

Source
pub struct WorkerBuilder { /* private fields */ }
Expand description

Fluent builder for Worker.

All setters accept impl Into<String> so call-sites may pass &str, String, or &String interchangeably without explicit conversion.

§Example

use worker_matcher::{Gender, Worker, WorkerBuilder};
use chrono::NaiveDate;

let p: Worker = WorkerBuilder::default()
    .uk_nhs_number("9434765919")
    .given_name(String::from("Owen"))   // owned String
    .family_name("Williams")            // &str
    .date_of_birth(NaiveDate::from_ymd_opt(1972, 11, 4).unwrap())
    .gender(Gender::Male)
    .build();

assert_eq!(p.uk_nhs_number.as_deref(), Some("9434765919"));

Implementations§

Source§

impl WorkerBuilder

Source

pub fn uk_nhs_number<S: Into<String>>(self, value: S) -> Self

Set the United Kingdom NHS Number (England, Wales, Isle of Man).

The string is stored verbatim; normalisation and validation happen at match time via crate::identifiers::parse_uk_nhs_number. Whitespace in the canonical "XXX XXX XXXX" layout is permitted.

let p = Worker::builder().uk_nhs_number("943 476 5919").build();
assert_eq!(p.uk_nhs_number.as_deref(), Some("943 476 5919"));
Source

pub fn fr_nir<S: Into<String>>(self, value: S) -> Self

Set the France NIR (Numéro d’Inscription au Répertoire).

The 15-character national identifier. Stored verbatim; parsing happens at match time via crate::identifiers::parse_fr_nir.

let p = Worker::builder().fr_nir("180127512345642").build();
assert_eq!(p.fr_nir.as_deref(), Some("180127512345642"));
Source

pub fn es_tsi<S: Into<String>>(self, value: S) -> Self

Set the España (Spain) TSI (Tarjeta Sanitaria Individual) / CIP-SNS identifier.

Stored verbatim; parsing happens at match time via crate::identifiers::parse_es_tsi.

let p = Worker::builder().es_tsi("ABCD123456XY1234").build();
assert_eq!(p.es_tsi.as_deref(), Some("ABCD123456XY1234"));
Source

pub fn ie_ihi<S: Into<String>>(self, value: S) -> Self

Set the Éire (Ireland) IHI (Individual Health Identifier).

The 7-digit identifier. Stored verbatim; parsing happens at match time via crate::identifiers::parse_ie_ihi.

let p = Worker::builder().ie_ihi("1234567").build();
assert_eq!(p.ie_ihi.as_deref(), Some("1234567"));
Source

pub fn uk_hc_number<S: Into<String>>(self, value: S) -> Self

Set the United Kingdom Northern Ireland H&C (Health and Care) Number.

A 10-digit Modulus-11 identifier sharing the NHS Number algorithm. Stored verbatim; parsing happens at match time via crate::identifiers::parse_uk_hc_number.

let p = Worker::builder().uk_hc_number("9434765919").build();
assert_eq!(p.uk_hc_number.as_deref(), Some("9434765919"));
Source

pub fn us_ssn<S: Into<String>>(self, value: S) -> Self

Set the United States Social Security Number (SSN).

A 9-digit identifier issued by the Social Security Administration. Stored verbatim; parsing happens at match time via crate::identifiers::parse_us_ssn. The canonical "AAA-GG-SSSS" layout and the compact "AAAGGSSSS" layout are equivalent under parsing.

let p = Worker::builder().us_ssn("123-45-6789").build();
assert_eq!(p.us_ssn.as_deref(), Some("123-45-6789"));
Source

pub fn au_ihi<S: Into<String>>(self, value: S) -> Self

Set the Australia IHI (Individual Healthcare Identifier).

16-digit identifier with a Luhn check, conforming to ISO/IEC 7812-1. Stored verbatim; parsing happens at match time via crate::identifiers::parse_au_ihi.

let p = Worker::builder().au_ihi("8003601234567894").build();
assert_eq!(p.au_ihi.as_deref(), Some("8003601234567894"));
Source

pub fn de_kvnr<S: Into<String>>(self, value: S) -> Self

Set the Germany KVNR (Krankenversichertennummer).

10-character (1 letter + 9 digits) lifelong health-insurance number with a Mod-10 check. Stored verbatim; parsing happens at match time via crate::identifiers::parse_de_kvnr.

let p = Worker::builder().de_kvnr("A123456780").build();
assert_eq!(p.de_kvnr.as_deref(), Some("A123456780"));
Source

pub fn it_cf<S: Into<String>>(self, value: S) -> Self

Set the Italy Codice Fiscale (CF).

16-character alphanumeric tax identifier with a Mod-26 check character. Stored verbatim; parsing happens at match time via crate::identifiers::parse_it_cf.

let p = Worker::builder().it_cf("RSSMRA85T10A562S").build();
assert_eq!(p.it_cf.as_deref(), Some("RSSMRA85T10A562S"));
Source

pub fn nl_bsn<S: Into<String>>(self, value: S) -> Self

Set the Netherlands BSN (Burgerservicenummer).

9-digit citizen-service number with the “11-test” check rule. Stored verbatim; parsing happens at match time via crate::identifiers::parse_nl_bsn.

let p = Worker::builder().nl_bsn("111222333").build();
assert_eq!(p.nl_bsn.as_deref(), Some("111222333"));
Source

pub fn se_workernummer<S: Into<String>>(self, value: S) -> Self

Set the Sweden Workernummer.

10- or 12-digit workeral identity number with a Luhn check computed over the 10-digit form. Stored verbatim; parsing happens at match time via crate::identifiers::parse_se_workernummer.

let p = Worker::builder().se_workernummer("19460324-3850").build();
assert_eq!(p.se_workernummer.as_deref(), Some("19460324-3850"));
Source

pub fn uk_chi_number<S: Into<String>>(self, value: S) -> Self

Set the United Kingdom (Scotland) CHI Number (Community Health Index).

10-digit identifier issued by NHS Scotland, sharing the Mod-11 algorithm of the NHS Number but scheme-local. Stored verbatim; parsing happens at match time via crate::identifiers::parse_uk_chi_number.

let p = Worker::builder().uk_chi_number("0101701233").build();
assert_eq!(p.uk_chi_number.as_deref(), Some("0101701233"));
Source

pub fn be_nn<S: Into<String>>(self, value: S) -> Self

Set the Belgium National Number (Rijksregisternummer). 11 digits, Mod-97.

Source

pub fn bg_egn<S: Into<String>>(self, value: S) -> Self

Set the Bulgaria EGN (Edinen grazhdanski nomer). 10 digits, weighted Mod-11.

Source

pub fn cz_rc<S: Into<String>>(self, value: S) -> Self

Set the Czech Republic Rodné číslo. 9 or 10 digits.

Source

pub fn dk_cpr<S: Into<String>>(self, value: S) -> Self

Set the Denmark CPR (Centrale Workerregister). 10 digits.

Source

pub fn ee_ik<S: Into<String>>(self, value: S) -> Self

Set the Estonia Isikukood (Workeral Identification Code). 11 digits.

Source

pub fn es_dni<S: Into<String>>(self, value: S) -> Self

Set the Spain DNI / NIE. 8 digits + Mod-23 letter.

Source

pub fn fi_hetu<S: Into<String>>(self, value: S) -> Self

Set the Finland HETU (Henkilötunnus). 11 chars with century sign.

Source

pub fn hr_oib<S: Into<String>>(self, value: S) -> Self

Set the Croatia OIB (Osobni identifikacijski broj). 11 digits.

Source

pub fn is_kt<S: Into<String>>(self, value: S) -> Self

Set the Iceland Kennitala. 10 digits.

Source

pub fn lt_ak<S: Into<String>>(self, value: S) -> Self

Set the Lithuania Asmens kodas. 11 digits.

Source

pub fn lv_pk<S: Into<String>>(self, value: S) -> Self

Set the Latvia Workeras kods. 11 digits.

Source

pub fn mt_id<S: Into<String>>(self, value: S) -> Self

Set the Malta National ID. 7 digits + letter.

Source

pub fn no_fnr<S: Into<String>>(self, value: S) -> Self

Set the Norway Fødselsnummer. 11 digits, dual Mod-11.

Source

pub fn pl_pesel<S: Into<String>>(self, value: S) -> Self

Set the Poland PESEL. 11 digits, weighted Mod-10.

Source

pub fn ro_cnp<S: Into<String>>(self, value: S) -> Self

Set the Romania CNP (Cod Numeric Workeral). 13 digits.

Source

pub fn si_emso<S: Into<String>>(self, value: S) -> Self

Set the Slovenia EMŠO (Enotna Matična Številka Občana). 13 digits.

Source

pub fn sk_rc<S: Into<String>>(self, value: S) -> Self

Set the Slovakia Rodné číslo. 9 or 10 digits.

Source

pub fn uk_nino<S: Into<String>>(self, value: S) -> Self

Set the United Kingdom National Insurance Number (NINO).

Source

pub fn gr_dss<S: Into<String>>(self, value: S) -> Self

Set the Greece DSS investor share code. 10 digits.

Source

pub fn li_id<S: Into<String>>(self, value: S) -> Self

Set the Liechtenstein National Identity Card Number. 2 letters + 8 digits.

Source

pub fn nl_id<S: Into<String>>(self, value: S) -> Self

Set the Netherlands National Identity Card Number. 9 chars per spec.

Source

pub fn pl_nip<S: Into<String>>(self, value: S) -> Self

Set the Poland NIP (Numer Identyfikacji Podatkowej). 10 digits, weighted Mod-11.

Source

pub fn pt_nif<S: Into<String>>(self, value: S) -> Self

Set the Portugal NIF (Número de Identificação Fiscal). 9 digits, weighted Mod-11.

Source

pub fn br_cpf<S: Into<String>>(self, value: S) -> Self

Set the Brazil CPF (Cadastro de Pessoas Físicas). 11 digits, two Mod-11 check digits.

Source

pub fn cn_rrn<S: Into<String>>(self, value: S) -> Self

Set the China Resident Identity Card number (居民身份证). 18 chars, weighted Mod-11 + date substring.

Source

pub fn in_aadhaar<S: Into<String>>(self, value: S) -> Self

Set the India Aadhaar number. 12 digits, Verhoeff check digit.

Source

pub fn jp_my_number<S: Into<String>>(self, value: S) -> Self

Set the Japan My Number (個人番号). 12 digits, weighted Mod-11 check digit.

Source

pub fn mx_curp<S: Into<String>>(self, value: S) -> Self

Set the Mexico CURP. 18 alphanumeric chars, structural + Mod-10 check digit.

Source

pub fn nz_nhi<S: Into<String>>(self, value: S) -> Self

Set the New Zealand NHI Number. Original 7-char format (3 letters + 4 digits).

Source

pub fn za_id<S: Into<String>>(self, value: S) -> Self

Set the South Africa ID Number. 13 digits, Luhn + date substring.

Source

pub fn given_name<S: Into<String>>(self, value: S) -> Self

Set the given name (forename).

let p = Worker::builder().given_name("Carys").build();
assert_eq!(p.given_name.as_deref(), Some("Carys"));
Source

pub fn middle_name<S: Into<String>>(self, value: S) -> Self

Set the middle name(s).

Stored on the worker but not currently used in matching scoring (see spec OQ-1).

let p = Worker::builder().middle_name("Eleri").build();
assert_eq!(p.middle_name.as_deref(), Some("Eleri"));
Source

pub fn family_name<S: Into<String>>(self, value: S) -> Self

Set the family name (surname).

let p = Worker::builder().family_name("Pritchard").build();
assert_eq!(p.family_name.as_deref(), Some("Pritchard"));
Source

pub fn date_of_birth(self, value: NaiveDate) -> Self

Set the date of birth.

use chrono::NaiveDate;
let dob = NaiveDate::from_ymd_opt(1990, 1, 1).unwrap();
let p = Worker::builder().date_of_birth(dob).build();
assert_eq!(p.date_of_birth, Some(dob));
Source

pub fn death_date(self, value: NaiveDate) -> Self

Set the date of death (FHIR Patient.deceasedDateTime).

use chrono::NaiveDate;
let dod = NaiveDate::from_ymd_opt(2024, 6, 30).unwrap();
let p = Worker::builder().death_date(dod).build();
assert_eq!(p.death_date, Some(dod));
Source

pub fn gender(self, value: Gender) -> Self

Set the recorded gender.

let p = Worker::builder().gender(Gender::Female).build();
assert_eq!(p.gender, Some(Gender::Female));
Source

pub fn blood_type(self, value: BloodType) -> Self

Set the recorded ABO+RhD blood type.

let p = Worker::builder().blood_type(BloodType::OPositive).build();
assert_eq!(p.blood_type, Some(BloodType::OPositive));
Source

pub fn multiple_birth(self, value: u8) -> Self

Set the multiple-birth indicator (FHIR Patient.multipleBirth).

The value is the 1-indexed birth order within a multiple-birth set: 1 for the first born, 2 for the second, and so on. 0 is conventionally not used; consumers should pass None (do not call this setter) for singletons or unknown values.

// First of identical twins.
let p = Worker::builder().multiple_birth(1).build();
assert_eq!(p.multiple_birth, Some(1));
Source

pub fn address(self, value: Address) -> Self

Set the current residential address.

let mut a = Address::new();
a.postcode = Some("CF10 1AA".into());
let p = Worker::builder().address(a).build();
assert_eq!(p.address.unwrap().postcode.as_deref(), Some("CF10 1AA"));
Source

pub fn birth_place(self, value: Address) -> Self

Set the place of birth (FHIR Patient.birthPlace).

Typically only Address::city and Address::country are populated for a birth place.

let p = Worker::builder()
    .birth_place(Address::new().with_city("Cardiff").with_country("Wales"))
    .build();
assert_eq!(p.birth_place.as_ref().unwrap().city.as_deref(), Some("Cardiff"));
Source

pub fn death_place(self, value: Address) -> Self

Set the place of death.

Modelled as an Address for parity with Self::birth_place — typically only Address::city and Address::country are populated.

let p = Worker::builder()
    .death_place(Address::new().with_city("Glasgow").with_country("Scotland"))
    .build();
assert_eq!(p.death_place.as_ref().unwrap().city.as_deref(), Some("Glasgow"));
Source

pub fn previous_addresses(self, value: Vec<Address>) -> Self

Set the list of previous addresses. Used by the address sub-score (best-of cartesian product, see spec §12.4.2).

let p = Worker::builder()
    .previous_addresses(vec![Address::new(), Address::new()])
    .build();
assert_eq!(p.previous_addresses.len(), 2);
Source

pub fn add_passport_book(self, book: PassportBook) -> Self

Append a single passport book to the worker’s list. Chainable; call multiple times to record multi-country or historical books.

let p = Worker::builder()
    .add_passport_book(PassportBook::new("GB", "123456789").unwrap())
    .add_passport_book(PassportBook::new("US", "AB1234567").unwrap())
    .build();
assert_eq!(p.passport_books.len(), 2);
Source

pub fn passport_books(self, value: Vec<PassportBook>) -> Self

Replace the entire passport-book list.

let books = vec![PassportBook::new("GB", "123456789").unwrap()];
let p = Worker::builder().passport_books(books).build();
assert_eq!(p.passport_books.len(), 1);
Source

pub fn phone<S: Into<String>>(self, value: S) -> Self

Set the primary phone number.

let p = Worker::builder().phone("029 2034 5678").build();
assert_eq!(p.phone.as_deref(), Some("029 2034 5678"));
Source

pub fn mobile<S: Into<String>>(self, value: S) -> Self

Set the mobile phone number. Used as a fallback when phone is absent.

let p = Worker::builder().mobile("07700 900123").build();
assert_eq!(p.mobile.as_deref(), Some("07700 900123"));
Source

pub fn email<S: Into<String>>(self, value: S) -> Self

Set the email address. Not currently used in scoring.

let p = Worker::builder().email("alice@example.org").build();
assert_eq!(p.email.as_deref(), Some("alice@example.org"));
Source

pub fn local_id<S: Into<String>>(self, value: S) -> Self

Set the local hospital or practice identifier.

let p = Worker::builder().local_id("MRN-12345").build();
assert_eq!(p.local_id.as_deref(), Some("MRN-12345"));
Source

pub fn build(self) -> Worker

Consume the builder and produce the Worker.

let p = Worker::builder().given_name("Eira").build();
assert!(p.family_name.is_none());

Trait Implementations§

Source§

impl Default for WorkerBuilder

Source§

fn default() -> WorkerBuilder

Returns the “default value” for a type. Read more

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> 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, 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.