Skip to main content

Worker

Struct Worker 

Source
#[non_exhaustive]
pub struct Worker {
Show 59 fields pub uk_nhs_number: Option<String>, pub fr_nir: Option<String>, pub es_tsi: Option<String>, pub ie_ihi: Option<String>, pub uk_hc_number: Option<String>, pub us_ssn: Option<String>, pub au_ihi: Option<String>, pub de_kvnr: Option<String>, pub it_cf: Option<String>, pub nl_bsn: Option<String>, pub se_workernummer: Option<String>, pub uk_chi_number: Option<String>, pub be_nn: Option<String>, pub bg_egn: Option<String>, pub cz_rc: Option<String>, pub dk_cpr: Option<String>, pub ee_ik: Option<String>, pub es_dni: Option<String>, pub fi_hetu: Option<String>, pub hr_oib: Option<String>, pub is_kt: Option<String>, pub lt_ak: Option<String>, pub lv_pk: Option<String>, pub mt_id: Option<String>, pub no_fnr: Option<String>, pub pl_pesel: Option<String>, pub ro_cnp: Option<String>, pub si_emso: Option<String>, pub sk_rc: Option<String>, pub uk_nino: Option<String>, pub gr_dss: Option<String>, pub li_id: Option<String>, pub nl_id: Option<String>, pub pl_nip: Option<String>, pub pt_nif: Option<String>, pub br_cpf: Option<String>, pub cn_rrn: Option<String>, pub in_aadhaar: Option<String>, pub jp_my_number: Option<String>, pub mx_curp: Option<String>, pub nz_nhi: Option<String>, pub za_id: Option<String>, pub given_name: Option<String>, pub middle_name: Option<String>, pub family_name: Option<String>, pub date_of_birth: Option<NaiveDate>, pub death_date: Option<NaiveDate>, pub gender: Option<Gender>, pub blood_type: Option<BloodType>, pub multiple_birth: Option<u8>, pub address: Option<Address>, pub birth_place: Option<Address>, pub death_place: Option<Address>, pub previous_addresses: Vec<Address>, pub passport_books: Vec<PassportBook>, pub phone: Option<String>, pub mobile: Option<String>, pub email: Option<String>, pub local_id: Option<String>,
}
Expand description

Core worker demographic data structure.

Every field is optional. The matcher tolerates missing data field-by-field — a None value never penalises a worker. See crate::matcher::MatchingEngine::match_workers for how missing fields affect the weighted score.

Construct via Worker::builder rather than struct literal syntax so the call-site stays compact and forward-compatible if fields are added.

§Example

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

let p = Worker::builder()
    .given_name("Siân")
    .family_name("Evans")
    .date_of_birth(NaiveDate::from_ymd_opt(1990, 3, 10).unwrap())
    .gender(Gender::Female)
    .build();

assert_eq!(p.given_name.as_deref(), Some("Siân"));
assert!(p.uk_nhs_number.is_none());

Worker round-trips through serde.

let p = Worker::builder().given_name("Test").family_name("Worker").build();
let json = serde_json::to_string(&p).unwrap();
let back: Worker = serde_json::from_str(&json).unwrap();
assert_eq!(p, back);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§uk_nhs_number: Option<String>

United Kingdom NHS Number (England, Wales, Isle of Man) — a 10-digit Modulus-11 identifier parsed via crate::identifiers::parse_uk_nhs_number. Whitespace tolerated in the spaced "XXX XXX XXXX" layout.

§fr_nir: Option<String>

France NIR (Numéro d’Inscription au Répertoire) — the 15-character national identifier with a Modulus-97 check key. Parsed via crate::identifiers::parse_fr_nir.

§es_tsi: Option<String>

España (Spain) TSI (Tarjeta Sanitaria Individual) / CIP-SNS — the national healthcare identifier with regionally-varying format. Parsed via crate::identifiers::parse_es_tsi.

§ie_ihi: Option<String>

Éire (Ireland) IHI (Individual Health Identifier) — the 7-digit healthcare identifier issued under the Health Identifiers Act 2014. Parsed via crate::identifiers::parse_ie_ihi.

§uk_hc_number: Option<String>

United Kingdom Northern Ireland H&C Number (Health and Care Number) — a 10-digit Modulus-11 identifier issued by HSC. Shares the NHS Number algorithm. Parsed via crate::identifiers::parse_uk_hc_number.

§us_ssn: Option<String>

United States Social Security Number (SSN) — a 9-digit identifier issued by the Social Security Administration. Parsed via crate::identifiers::parse_us_ssn.

§au_ihi: Option<String>

Australia IHI (Individual Healthcare Identifier) — 16-digit identifier issued by the Healthcare Identifiers Service. Parsed via crate::identifiers::parse_au_ihi.

§de_kvnr: Option<String>

Germany KVNR (Krankenversichertennummer) — 10-character (letter + 9 digits) lifelong health-insurance number. Parsed via crate::identifiers::parse_de_kvnr.

§it_cf: Option<String>

Italy Codice Fiscale (CF) — 16-character alphanumeric identifier issued by the tax authority. Parsed via crate::identifiers::parse_it_cf.

§nl_bsn: Option<String>

Netherlands BSN (Burgerservicenummer) — 9-digit citizen-service number used by Dutch authorities and healthcare providers. Parsed via crate::identifiers::parse_nl_bsn.

§se_workernummer: Option<String>

Sweden Workernummer — 10- or 12-digit workeral identity number (YYMMDDNNNC or YYYYMMDDNNNC with optional - / + separator). Parsed via crate::identifiers::parse_se_workernummer.

§uk_chi_number: Option<String>

United Kingdom (Scotland) CHI Number (Community Health Index) — 10-digit identifier used by NHS Scotland. Shares the Mod-11 algorithm of the NHS Number but is scheme-local. Parsed via crate::identifiers::parse_uk_chi_number.

§be_nn: Option<String>

Belgium National Number (Rijksregisternummer). 11 digits, Mod-97. Parsed via crate::identifiers::parse_be_nn.

§bg_egn: Option<String>

Bulgaria EGN (Edinen grazhdanski nomer). 10 digits, weighted Mod-11. Parsed via crate::identifiers::parse_bg_egn.

§cz_rc: Option<String>

Czech Republic Rodné číslo. 9 or 10 digits (10-digit divisible by 11). Parsed via crate::identifiers::parse_cz_rc.

§dk_cpr: Option<String>

Denmark CPR (Centrale Workerregister). 10 digits, format only. Parsed via crate::identifiers::parse_dk_cpr.

§ee_ik: Option<String>

Estonia Isikukood (Workeral Identification Code). 11 digits, cascading Mod-11. Parsed via crate::identifiers::parse_ee_ik.

§es_dni: Option<String>

Spain DNI / NIE. 8 digits + Mod-23 control letter (NIE prefixed X/Y/Z). Parsed via crate::identifiers::parse_es_dni.

§fi_hetu: Option<String>

Finland HETU (Henkilötunnus). 11 chars with century sign + Mod-31 check. Parsed via crate::identifiers::parse_fi_hetu.

§hr_oib: Option<String>

Croatia OIB (Osobni identifikacijski broj). 11 digits, ISO 7064 MOD 11,10. Parsed via crate::identifiers::parse_hr_oib.

§is_kt: Option<String>

Iceland Kennitala. 10 digits, weighted Mod-11. Parsed via crate::identifiers::parse_is_kt.

§lt_ak: Option<String>

Lithuania Asmens kodas. 11 digits, cascading Mod-11 (same algorithm as Estonia). Parsed via crate::identifiers::parse_lt_ak.

§lv_pk: Option<String>

Latvia Workeras kods. 11 digits, weighted Mod-11. Parsed via crate::identifiers::parse_lv_pk.

§mt_id: Option<String>

Malta National ID. 7 digits + letter in {M, G, A, P, L, H, B, Z}. Parsed via crate::identifiers::parse_mt_id.

§no_fnr: Option<String>

Norway Fødselsnummer. 11 digits, dual Mod-11. Parsed via crate::identifiers::parse_no_fnr.

§pl_pesel: Option<String>

Poland PESEL. 11 digits, weighted Mod-10. Parsed via crate::identifiers::parse_pl_pesel.

§ro_cnp: Option<String>

Romania CNP (Cod Numeric Workeral). 13 digits, weighted Mod-11. Parsed via crate::identifiers::parse_ro_cnp.

§si_emso: Option<String>

Slovenia EMŠO (Enotna Matična Številka Občana). 13 digits, weighted Mod-11. Parsed via crate::identifiers::parse_si_emso.

§sk_rc: Option<String>

Slovakia Rodné číslo. 9 or 10 digits (same algorithm as Czech RČ). Parsed via crate::identifiers::parse_sk_rc.

§uk_nino: Option<String>

United Kingdom National Insurance Number (NINO). Format AA999999A with banned prefixes and {A,B,C,D} suffix. Parsed via crate::identifiers::parse_uk_nino.

§gr_dss: Option<String>

Greece DSS (Dematerialised Securities System) investor share code. 10-digit identifier issued by the Hellenic Central Securities Depository (ATHEXCSD). Parsed via crate::identifiers::parse_gr_dss.

§li_id: Option<String>

Liechtenstein National Identity Card Number. 2 letters + 8 digits (per the spec) or 2 letters + 9 digits (per the spec’s example). Note: the LI ID card number is regenerated on each renewal, so consumers that need stable cross-renewal matching should prefer PassportBook with country = "LI". Parsed via crate::identifiers::parse_li_id.

§nl_id: Option<String>

Netherlands National Identity Card Number. 9 characters: positions 1–2 are uppercase letters except O; positions 3–8 are alphanumeric except O; position 9 is a digit. Distinct from the BSN (citizen-service number), which is permanent — this ID-card number changes with each renewed card. Parsed via crate::identifiers::parse_nl_id.

§pl_nip: Option<String>

Poland NIP (Numer Identyfikacji Podatkowej) tax identification number. 10 digits, weighted Mod-11 check. Parsed via crate::identifiers::parse_pl_nip.

§pt_nif: Option<String>

Portugal NIF (Número de Identificação Fiscal) tax identification number. 9 digits, weighted Mod-11 check. Parsed via crate::identifiers::parse_pt_nif.

§br_cpf: Option<String>

Brazil CPF (Cadastro de Pessoas Físicas). 11-digit national tax / identification number with two Mod-11 check digits. Parsed at match time via crate::identifiers::parse_br_cpf.

§cn_rrn: Option<String>

China Resident Identity Card number (居民身份证) — 18-character 1999 reform format (17 digits + check character). Parsed at match time via crate::identifiers::parse_cn_rrn.

§in_aadhaar: Option<String>

India Aadhaar number. 12 digits with Verhoeff check digit. Parsed at match time via crate::identifiers::parse_in_aadhaar.

§jp_my_number: Option<String>

Japan My Number (個人番号). 12-digit workeral identification number with weighted Mod-11 check digit. Parsed at match time via crate::identifiers::parse_jp_my_number.

§mx_curp: Option<String>

Mexico CURP (Clave Única de Registro de Población). 18-character alphanumeric identifier encoding name initials, date of birth, sex, state, and a check digit. Parsed at match time via crate::identifiers::parse_mx_curp.

§nz_nhi: Option<String>

New Zealand NHI (National Health Index) number. Original 7-character format (3 letters + 4 digits, Mod-11 check digit). The 2019 alphanumeric NHI revision is not supported by the parser. Parsed at match time via crate::identifiers::parse_nz_nhi.

§za_id: Option<String>

South Africa ID Number. 13 digits encoding date of birth, sequence, citizenship, and a Luhn check digit. Parsed at match time via crate::identifiers::parse_za_id.

§given_name: Option<String>

Given name (sometimes called “first name” or “forename”).

§middle_name: Option<String>

Middle name(s). Currently unused in scoring — see spec OQ-1.

§family_name: Option<String>

Family name (sometimes called “surname” or “last name”).

§date_of_birth: Option<NaiveDate>

Date of birth. Compared by exact equality.

§death_date: Option<NaiveDate>

Date of death (FHIR Patient.deceasedDateTime). Compared using the same DOB transposition heuristic as Worker::date_of_birth — DD/MM ↔ MM/DD data-entry bugs are just as common in death records as in birth records.

§gender: Option<Gender>

Administrative gender. See Gender.

§blood_type: Option<BloodType>

ABO+RhD blood type. Stable for life, so disagreement is strong evidence against a match; agreement is a weak positive signal (many people share a blood type). See BloodType for the scoring contract.

§multiple_birth: Option<u8>

FHIR Patient.multipleBirth — birth order in a multiple-birth set (twin / triplet / etc.). Convention:

  • None — unknown, not recorded, or singleton (the matcher treats None as “no signal” and skips the field).
  • Some(n) with n >= 1 — the n-th birth in a multiple-birth set (1-indexed).

Used to distinguish identical twins who otherwise share name, DOB, address, and demographic data. Disagreement (e.g. Some(1) vs Some(2)) is reliable evidence the records refer to different people in the same multiple-birth set.

§address: Option<Address>

Current residential address.

§birth_place: Option<Address>

Place of birth. Modelled as an Address for FHIR (Patient.birthPlace) parity — typically only city and country are populated in practice. Stable over a lifetime (modulo refugee / adoption edge cases), so disagreement on a populated value is informative. Scored independently from the current address field.

§death_place: Option<Address>

Place of death. Modelled as an Address (parallel to Worker::birth_place) — typically only city and country are populated. Useful for disambiguating records of deceased workers (e.g. distinguishing two people with the same name and DOB by where they died). Scored independently from address and birth_place.

§previous_addresses: Vec<Address>

Previous residential addresses. Used by the address sub-score (best-of cartesian product across address ∪ previous_addresses on both sides; see spec §12.4.2).

§passport_books: Vec<PassportBook>

Passport books held by the worker. A single worker may hold passports from multiple countries simultaneously and may accumulate historical book numbers as old passports are renewed; this Vec carries every book ever recorded on the worker (current and historical) without privileging any particular jurisdiction. Matching treats any shared (country, number) pair across the two workers’ lists as evidence that the records refer to the same worker, regardless of issue date. See PassportBook.

§phone: Option<String>

Primary phone number. Falls back to Self::mobile in scoring if absent.

§mobile: Option<String>

Mobile phone number. Used as the fallback for Self::phone.

§email: Option<String>

Email address. Not currently used in scoring (see spec task T-11).

§local_id: Option<String>

Local hospital or practice identifier. Not normalised — different organisations may issue colliding values.

Implementations§

Source§

impl Worker

Source

pub fn builder() -> WorkerBuilder

Begin constructing a Worker with the WorkerBuilder.

All fields default to None / empty until a setter is called.

§Example
use worker_matcher::Worker;

let p = Worker::builder()
    .given_name("John")
    .family_name("Smith")
    .build();

assert_eq!(p.family_name.as_deref(), Some("Smith"));
Source

pub fn validate(&self) -> Result<()>

Validate that the worker carries at least one identifying field.

Returns Ok(()) if any of the following is set: a name (given_name or family_name), or any national identifier (uk_nhs_number, fr_nir, es_tsi, ie_ihi, uk_hc_number). Otherwise returns crate::MatchingError::MissingField.

This is not invoked automatically by the matcher — call it at the system boundary when you ingest data, not on every comparison.

§Example
use worker_matcher::Worker;

assert!(Worker::builder().given_name("Ada").build().validate().is_ok());
assert!(Worker::builder().uk_nhs_number("9434765919").build().validate().is_ok());
assert!(Worker::builder().ie_ihi("1234567").build().validate().is_ok());
assert!(Worker::builder().us_ssn("123-45-6789").build().validate().is_ok());
assert!(Worker::builder().de_kvnr("A123456780").build().validate().is_ok());
assert!(
    Worker::builder()
        .add_passport_book(worker_matcher::PassportBook::new("GB", "123456789").unwrap())
        .build()
        .validate()
        .is_ok()
);
assert!(Worker::builder().build().validate().is_err());

Trait Implementations§

Source§

impl Clone for Worker

Source§

fn clone(&self) -> Worker

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 Worker

Source§

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

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

impl<'de> Deserialize<'de> for Worker

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 PartialEq for Worker

Source§

fn eq(&self, other: &Worker) -> 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 Worker

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 StructuralPartialEq for Worker

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