fix(anonymizer): handle FC14 practitioner OGC rules
This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
Tests de non-régression sur des layouts d'identifiants vus en documents réels.
|
||||
"""
|
||||
from anonymizer_core_refactored_onnx import (
|
||||
PiiHit,
|
||||
RE_SCAN_FILENAME_ARTIFACT,
|
||||
anonymise_document_regex,
|
||||
fitz,
|
||||
load_dictionaries,
|
||||
redact_pdf_vector,
|
||||
)
|
||||
|
||||
|
||||
@@ -44,3 +47,63 @@ def test_scan_filename_artifact_suffix_is_masked():
|
||||
assert RE_SCAN_FILENAME_ARTIFACT.search("EXT2-[IPP]-2300249096.TIF") is not None
|
||||
assert "2300249096" not in anon.text_out
|
||||
assert "EXT2-[IPP]-[DOSSIER].TIF" in anon.text_out
|
||||
|
||||
|
||||
def test_practitioner_council_form_masks_professional_name_and_preserves_pmsi_codes():
|
||||
cfg = load_dictionaries(None)
|
||||
text = (
|
||||
"N° OGC : 14\n"
|
||||
"FICHE MEDICALE DE RECUEIL DU PRATICIEN CONSEIL (une fiche par RUM)\n"
|
||||
"Nom du praticien-conseil : V NOMTEST\n"
|
||||
"DP K851 PANCREATITE AIG. BIL.\n"
|
||||
"GHM après recodage : 07C141\n"
|
||||
"ARGUMENTAIRE DU MEDECIN CONTROLEUR\n"
|
||||
"142 : La facturation du GHS par l'etablissement n'est pas conforme\n"
|
||||
)
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "NOMTEST" not in anon.text_out
|
||||
assert "Nom du praticien-conseil : [NOM]" in anon.text_out
|
||||
assert "N° OGC : 14" in anon.text_out
|
||||
assert "07C141" in anon.text_out
|
||||
assert "142 : La facturation" in anon.text_out
|
||||
assert not any(h.kind in {"OGC", "OGC_court"} for h in anon.audit)
|
||||
assert any(
|
||||
h.kind == "NOM_FORCE" and "NOMTEST" in h.original
|
||||
for h in anon.audit
|
||||
)
|
||||
|
||||
|
||||
def test_ogc_is_still_masked_outside_practitioner_council_form():
|
||||
cfg = load_dictionaries(None)
|
||||
text = "N° OGC : 12\nCompte rendu standard\n"
|
||||
|
||||
anon = anonymise_document_regex([text], [[]], cfg)
|
||||
|
||||
assert "N° OGC : [OGC]" in anon.text_out
|
||||
assert "N° OGC : 12" not in anon.text_out
|
||||
assert any(h.kind == "OGC" and h.original == "12" for h in anon.audit)
|
||||
|
||||
|
||||
def test_ogc_pdf_redaction_does_not_mask_numeric_substrings(tmp_path):
|
||||
if fitz is None:
|
||||
return
|
||||
|
||||
source = tmp_path / "ogc_substrings.pdf"
|
||||
output = tmp_path / "ogc_substrings.redacted.pdf"
|
||||
doc = fitz.open()
|
||||
page = doc.new_page()
|
||||
page.insert_text((72, 72), "N° OGC : 14")
|
||||
page.insert_text((72, 100), "GHM apres recodage : 07C141")
|
||||
page.insert_text((72, 128), "142 : La facturation reste lisible")
|
||||
doc.save(source)
|
||||
doc.close()
|
||||
|
||||
redact_pdf_vector(source, [PiiHit(0, "OGC", "14", "[OGC]")], output)
|
||||
|
||||
redacted = fitz.open(output)
|
||||
text = redacted[0].get_text()
|
||||
redacted.close()
|
||||
assert "07C141" in text
|
||||
assert "142 : La facturation" in text
|
||||
|
||||
Reference in New Issue
Block a user