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
impl WorkerBuilder
Sourcepub fn uk_nhs_number<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn fr_nir<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn es_tsi<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn ie_ihi<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn uk_hc_number<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn us_ssn<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn au_ihi<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn de_kvnr<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn it_cf<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn nl_bsn<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn se_workernummer<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn uk_chi_number<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn be_nn<S: Into<String>>(self, value: S) -> Self
pub fn be_nn<S: Into<String>>(self, value: S) -> Self
Set the Belgium National Number (Rijksregisternummer). 11 digits, Mod-97.
Sourcepub fn bg_egn<S: Into<String>>(self, value: S) -> Self
pub fn bg_egn<S: Into<String>>(self, value: S) -> Self
Set the Bulgaria EGN (Edinen grazhdanski nomer). 10 digits, weighted Mod-11.
Sourcepub fn cz_rc<S: Into<String>>(self, value: S) -> Self
pub fn cz_rc<S: Into<String>>(self, value: S) -> Self
Set the Czech Republic Rodné číslo. 9 or 10 digits.
Sourcepub fn dk_cpr<S: Into<String>>(self, value: S) -> Self
pub fn dk_cpr<S: Into<String>>(self, value: S) -> Self
Set the Denmark CPR (Centrale Workerregister). 10 digits.
Sourcepub fn ee_ik<S: Into<String>>(self, value: S) -> Self
pub fn ee_ik<S: Into<String>>(self, value: S) -> Self
Set the Estonia Isikukood (Workeral Identification Code). 11 digits.
Sourcepub fn es_dni<S: Into<String>>(self, value: S) -> Self
pub fn es_dni<S: Into<String>>(self, value: S) -> Self
Set the Spain DNI / NIE. 8 digits + Mod-23 letter.
Sourcepub fn fi_hetu<S: Into<String>>(self, value: S) -> Self
pub fn fi_hetu<S: Into<String>>(self, value: S) -> Self
Set the Finland HETU (Henkilötunnus). 11 chars with century sign.
Sourcepub fn hr_oib<S: Into<String>>(self, value: S) -> Self
pub fn hr_oib<S: Into<String>>(self, value: S) -> Self
Set the Croatia OIB (Osobni identifikacijski broj). 11 digits.
Sourcepub fn lt_ak<S: Into<String>>(self, value: S) -> Self
pub fn lt_ak<S: Into<String>>(self, value: S) -> Self
Set the Lithuania Asmens kodas. 11 digits.
Sourcepub fn mt_id<S: Into<String>>(self, value: S) -> Self
pub fn mt_id<S: Into<String>>(self, value: S) -> Self
Set the Malta National ID. 7 digits + letter.
Sourcepub fn no_fnr<S: Into<String>>(self, value: S) -> Self
pub fn no_fnr<S: Into<String>>(self, value: S) -> Self
Set the Norway Fødselsnummer. 11 digits, dual Mod-11.
Sourcepub fn pl_pesel<S: Into<String>>(self, value: S) -> Self
pub fn pl_pesel<S: Into<String>>(self, value: S) -> Self
Set the Poland PESEL. 11 digits, weighted Mod-10.
Sourcepub fn ro_cnp<S: Into<String>>(self, value: S) -> Self
pub fn ro_cnp<S: Into<String>>(self, value: S) -> Self
Set the Romania CNP (Cod Numeric Workeral). 13 digits.
Sourcepub fn si_emso<S: Into<String>>(self, value: S) -> Self
pub fn si_emso<S: Into<String>>(self, value: S) -> Self
Set the Slovenia EMŠO (Enotna Matična Številka Občana). 13 digits.
Sourcepub fn sk_rc<S: Into<String>>(self, value: S) -> Self
pub fn sk_rc<S: Into<String>>(self, value: S) -> Self
Set the Slovakia Rodné číslo. 9 or 10 digits.
Sourcepub fn uk_nino<S: Into<String>>(self, value: S) -> Self
pub fn uk_nino<S: Into<String>>(self, value: S) -> Self
Set the United Kingdom National Insurance Number (NINO).
Sourcepub fn gr_dss<S: Into<String>>(self, value: S) -> Self
pub fn gr_dss<S: Into<String>>(self, value: S) -> Self
Set the Greece DSS investor share code. 10 digits.
Sourcepub fn li_id<S: Into<String>>(self, value: S) -> Self
pub fn li_id<S: Into<String>>(self, value: S) -> Self
Set the Liechtenstein National Identity Card Number. 2 letters + 8 digits.
Sourcepub fn nl_id<S: Into<String>>(self, value: S) -> Self
pub fn nl_id<S: Into<String>>(self, value: S) -> Self
Set the Netherlands National Identity Card Number. 9 chars per spec.
Sourcepub fn pl_nip<S: Into<String>>(self, value: S) -> Self
pub fn pl_nip<S: Into<String>>(self, value: S) -> Self
Set the Poland NIP (Numer Identyfikacji Podatkowej). 10 digits, weighted Mod-11.
Sourcepub fn pt_nif<S: Into<String>>(self, value: S) -> Self
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.
Sourcepub fn br_cpf<S: Into<String>>(self, value: S) -> Self
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.
Sourcepub fn cn_rrn<S: Into<String>>(self, value: S) -> Self
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.
Sourcepub fn in_aadhaar<S: Into<String>>(self, value: S) -> Self
pub fn in_aadhaar<S: Into<String>>(self, value: S) -> Self
Set the India Aadhaar number. 12 digits, Verhoeff check digit.
Sourcepub fn jp_my_number<S: Into<String>>(self, value: S) -> Self
pub fn jp_my_number<S: Into<String>>(self, value: S) -> Self
Set the Japan My Number (個人番号). 12 digits, weighted Mod-11 check digit.
Sourcepub fn mx_curp<S: Into<String>>(self, value: S) -> Self
pub fn mx_curp<S: Into<String>>(self, value: S) -> Self
Set the Mexico CURP. 18 alphanumeric chars, structural + Mod-10 check digit.
Sourcepub fn nz_nhi<S: Into<String>>(self, value: S) -> Self
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).
Sourcepub fn za_id<S: Into<String>>(self, value: S) -> Self
pub fn za_id<S: Into<String>>(self, value: S) -> Self
Set the South Africa ID Number. 13 digits, Luhn + date substring.
Sourcepub fn given_name<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn middle_name<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn family_name<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn date_of_birth(self, value: NaiveDate) -> Self
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));Sourcepub fn death_date(self, value: NaiveDate) -> Self
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));Sourcepub fn gender(self, value: Gender) -> Self
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));Sourcepub fn blood_type(self, value: BloodType) -> Self
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));Sourcepub fn multiple_birth(self, value: u8) -> Self
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));Sourcepub fn address(self, value: Address) -> Self
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"));Sourcepub fn birth_place(self, value: Address) -> Self
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"));Sourcepub fn death_place(self, value: Address) -> Self
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"));Sourcepub fn previous_addresses(self, value: Vec<Address>) -> Self
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);Sourcepub fn add_passport_book(self, book: PassportBook) -> Self
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);Sourcepub fn passport_books(self, value: Vec<PassportBook>) -> Self
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);Sourcepub fn phone<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn mobile<S: Into<String>>(self, value: S) -> Self
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"));Sourcepub fn email<S: Into<String>>(self, value: S) -> Self
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"));Trait Implementations§
Source§impl Default for WorkerBuilder
impl Default for WorkerBuilder
Source§fn default() -> WorkerBuilder
fn default() -> WorkerBuilder
Auto Trait Implementations§
impl Freeze for WorkerBuilder
impl RefUnwindSafe for WorkerBuilder
impl Send for WorkerBuilder
impl Sync for WorkerBuilder
impl Unpin for WorkerBuilder
impl UnsafeUnpin for WorkerBuilder
impl UnwindSafe for WorkerBuilder
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> 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