fix(anonymizer): cover CHCB real-world staff layouts
This commit is contained in:
@@ -107,3 +107,132 @@ def test_ogc_pdf_redaction_does_not_mask_numeric_substrings(tmp_path):
|
||||
redacted.close()
|
||||
assert "07C141" in text
|
||||
assert "142 : La facturation" in text
|
||||
|
||||
|
||||
def test_crop_epi_header_name_is_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = (
|
||||
"CROp Epi - NOMTEST, Jean-Michel\n"
|
||||
"Compte rendu opératoire\n"
|
||||
)
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "NOMTEST" not in anon.text_out
|
||||
assert "Jean-Michel" not in anon.text_out
|
||||
assert "CROp Epi - [NOM]" in anon.text_out
|
||||
assert any(
|
||||
h.kind == "NOM_FORCE" and "NOMTEST" in h.original
|
||||
for h in anon.audit
|
||||
)
|
||||
|
||||
|
||||
def test_crop_epi_header_name_with_spaced_suffix_is_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = (
|
||||
"CROp Epi - NOMTEST, Marie NOMSUFFIX\n"
|
||||
"Compte rendu opératoire\n"
|
||||
)
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "NOMTEST" not in anon.text_out
|
||||
assert "Marie" not in anon.text_out
|
||||
assert "NOMSUFFIX" not in anon.text_out
|
||||
assert "CROp Epi - [NOM]" in anon.text_out
|
||||
assert any(
|
||||
h.kind == "NOM_FORCE" and "NOMSUFFIX" in h.original
|
||||
for h in anon.audit
|
||||
)
|
||||
|
||||
|
||||
def test_standalone_compound_signature_name_is_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = (
|
||||
"Observation clinique stable.\n"
|
||||
"Alix-Pierre Nomtest\n"
|
||||
"Suite de la prise en charge.\n"
|
||||
)
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "Alix-Pierre" not in anon.text_out
|
||||
assert "Nomtest" not in anon.text_out
|
||||
assert "[NOM]" in anon.text_out
|
||||
assert any(
|
||||
h.kind == "NOM_FORCE" and "Alix-Pierre Nomtest" in h.original
|
||||
for h in anon.audit
|
||||
)
|
||||
|
||||
|
||||
def test_modified_by_application_banner_name_is_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = (
|
||||
">>>CRO type 10/04/23 14 : 19 "
|
||||
"(mod. le 13/04/23 15:58 par NOMTEST Fanny, statut : complet)\n"
|
||||
)
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "NOMTEST" not in anon.text_out
|
||||
assert "Fanny" not in anon.text_out
|
||||
assert "par [NOM], statut" in anon.text_out
|
||||
assert any(
|
||||
h.kind == "NOM_FORCE" and "NOMTEST Fanny" in h.original
|
||||
for h in anon.audit
|
||||
)
|
||||
|
||||
|
||||
def test_ref_initials_are_page_local_for_pdf_redaction():
|
||||
cfg = load_dictionaries(None)
|
||||
text = "Réf : RBG/FL\n"
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "Réf : [NOM]/[NOM]" in anon.text_out
|
||||
assert any(h.kind == "NOM_INITIAL" and h.original == "RBG" and h.page == 0 for h in anon.audit)
|
||||
assert any(h.kind == "NOM_INITIAL" and h.original == "FL" and h.page == 0 for h in anon.audit)
|
||||
|
||||
|
||||
def test_ref_initials_with_suffix_label_are_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = "Réf_CRO : EG/PB\nCOMPTE-RENDU OPÉRATOIRE\n"
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "EG/PB" not in anon.text_out
|
||||
assert "Réf_CRO : [NOM]/[NOM]" in anon.text_out
|
||||
assert any(h.kind == "NOM_INITIAL" and h.original == "EG" and h.page == 0 for h in anon.audit)
|
||||
assert any(h.kind == "NOM_INITIAL" and h.original == "PB" and h.page == 0 for h in anon.audit)
|
||||
|
||||
|
||||
def test_staff_role_with_interne_name_is_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = "Aide : l'interne Charles NOMTEST\nAnesthésiste : Docteur [NOM]\n"
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "Charles" not in anon.text_out
|
||||
assert "NOMTEST" not in anon.text_out
|
||||
assert "Aide : l'interne [NOM]" in anon.text_out
|
||||
assert any(
|
||||
h.kind == "NOM_FORCE" and "Charles NOMTEST" in h.original
|
||||
for h in anon.audit
|
||||
)
|
||||
|
||||
|
||||
def test_trackare_iao_multiline_staff_name_is_masked():
|
||||
cfg = load_dictionaries(None)
|
||||
text = (
|
||||
"Heure d'orientation\n"
|
||||
"18 : 48\n"
|
||||
"IAO\n"
|
||||
"NOMTEST Marlène\n"
|
||||
"Priorité\n"
|
||||
)
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "NOMTEST" not in anon.text_out
|
||||
assert "Marlène" not in anon.text_out
|
||||
assert any(h.kind in {"NOM", "NOM_FORCE", "NOM_GLOBAL"} for h in anon.audit)
|
||||
|
||||
Reference in New Issue
Block a user