31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""FHIR Patient search by `name` (each word starts a word of a name; case and accents
|
|
ignored) and `identifier` (`[system|]value`, case ignored), as the lists' search box asks."""
|
|
|
|
from webapi.fhir import _matches
|
|
|
|
CURP = "https://isssteleon.org/fhir/sid/curp"
|
|
ROW = {
|
|
"names": ["IBARRA RIVERA MARTHA"],
|
|
"identifiers": [(CURP, "IARM800101MNLBVR09"), ("erick", "0451A")],
|
|
}
|
|
|
|
|
|
def test_name_words_start_words_of_her_name():
|
|
assert _matches(ROW, "martha ibarra", None)
|
|
assert _matches(ROW, "Már Riv", None)
|
|
assert not _matches(ROW, "arth", None)
|
|
assert not _matches(ROW, "martha lopez", None)
|
|
|
|
|
|
def test_identifier_by_value_or_system_and_value():
|
|
assert _matches(ROW, None, "iarm800101mnlbvr09")
|
|
assert _matches(ROW, None, f"{CURP}|IARM800101MNLBVR09")
|
|
assert _matches(ROW, None, "0451a")
|
|
assert not _matches(ROW, None, "451A")
|
|
assert not _matches(ROW, None, "erick|IARM800101MNLBVR09")
|
|
|
|
|
|
def test_both_must_match():
|
|
assert _matches(ROW, "martha", "0451A")
|
|
assert not _matches(ROW, "lucia", "0451A")
|