14.4.11. crate_anon.linkage.people

crate_anon/linkage/people.py


Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

This file is part of CRATE.

CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.


People representations for fuzzy matching.

exception crate_anon.linkage.people.DuplicateIDError[source]
class crate_anon.linkage.people.People(cfg: MatchConfig, person: Person | None = None, people: Iterable[Person] | None = None)[source]

Represents a group of people, and implements a shortlist.

__init__(cfg: MatchConfig, person: Person | None = None, people: Iterable[Person] | None = None) None[source]

Creates a blank collection.

Raises crate_anon.linkage.fuzzy_id_match.DuplicateLocalIDError if some people have duplicate local_id values.

add_people(people: Iterable[Person]) None[source]

Adds multiple people.

Raises crate_anon.linkage.fuzzy_id_match.DuplicateLocalIDError if some people have duplicate local_id values with respect to those we already know.

add_person(person: Person) None[source]

Adds a single person.

Raises crate_anon.linkage.fuzzy_id_match.DuplicateLocalIDError if the person has a local_id value already in our collection.

copy() People[source]

Returns a copy of itself.

ensure_valid_as_probands() None[source]

Ensures all people have sufficient information to act as a proband, or raises ValueError.

ensure_valid_as_sample() None[source]

Ensures all people have sufficient information to act as a candidate from a sample, or raises ValueError.

gen_shortlist(proband: Person) Generator[Person, None, None][source]

Generates a shortlist of potential candidates for fuzzy matching (e.g. by restriction to same/similar dates of birth – or with no such restriction, if preferred).

Yields:

proband – a Person

get_perfect_match(proband: Person) Person | None[source]

Returns the first person who matches on a perfect (person-unique) ID, or None.

get_unique_match(proband: Person) Person | None[source]

Returns a single person matching the proband, or None if there is no match (as defined by the probability settings in cfg).

Parameters:

proband – a Person

Returns:

the winner (a Person) or None

get_unique_match_detailed(proband: Person) MatchResult[source]

Returns a single person matching the proband, or None if there is no match (as defined by the probability settings in cfg).

Parameters:

proband – a Person

hashed() People[source]

Returns a hashed version of itself.

size() int[source]

Returns the number of people in this object.