← All posts

How to Find PHI on a File Share for HIPAA

November 23, 2026

You must find the protected health information (PHI) on a file share. The reason can be a HIPAA risk analysis, an audit, a breach-response plan or a cleanup before a migration. The share has thousands of folders, and the clinical, billing and HR files are mixed together.

The usual first step is a PII scan. The scan finds names, phone numbers and dates of birth. But a PII scan is not a PHI scan. On a typical share, it puts the staff phone list at the top of the results and the patient referral notes near the bottom.

This guide shows why that happens, which HIPAA identifiers a scanner can find, and how to add the identifiers that no scanner knows: your medical record numbers.

Why a PII scan ranks the wrong files first

We made a small test share with four files. All the people and numbers are made up.

File What is in it PHI?
clinical/discharge-summary.docx Name, date of birth, MRN 00428177, admission date, diagnosis, phone Yes
clinical/referral-note.txt Name, MRN 00519302, Medicare number 7FJ3-K82-QM51, diagnosis Yes
billing/medicare-claims-2025.xlsx Two patient names, Medicare numbers, account numbers, phones Yes
hr/staff-directory.csv Two staff names, work emails, work phones No

We scanned the share with the default PII Crawler detectors. This table shows the findings for each file:

File Findings Types
hr/staff-directory.csv 6 2 names, 2 phones, 2 emails
billing/medicare-claims-2025.xlsx 4 2 names, 2 phones
clinical/discharge-summary.docx 3 name, date of birth, phone
clinical/referral-note.txt 1 name

The file with no PHI has the most findings. The referral note has an MRN, a Medicare number and a diagnosis, but it has the fewest findings. Most PII scanners give a similar result, for four reasons.

1. PHI is an identifier plus health information

Under HIPAA, PHI is health information that identifies a person. A name in a staff list is PII, but it is not PHI. The same name in a discharge summary is PHI. A PII scanner finds the name. It does not know if the file is about health.

2. Medical record numbers have no standard format

Each EHR system and each hospital uses its own MRN format. An MRN can be seven digits, ten digits, or letters and digits. No built-in detector can know your format, so no PII scanner finds MRNs without help. In our test, the default scan found neither MRN.

3. Health plan numbers look like codes

A Medicare Beneficiary Identifier (MBI) has 11 letters and digits, for example 5KQ9XW2RT48. To a PII scanner, it looks like a product code or a serial number. The default scan did not report the three MBIs in the test share.

4. HIPAA counts more dates than birth dates

A date-of-birth detector reports birth dates. It does not report the admission date 10/02/2025 in the discharge summary, and that is the correct behavior for a PII scan. But HIPAA counts admission, discharge and death dates as identifiers too.

The 18 HIPAA identifiers, and how to find each one

The HIPAA de-identification rule, 45 CFR 164.514(b)(2), lists 18 identifiers. This table shows which ones a text scan can find, and how.

HIPAA identifier How PII Crawler finds it
Names Built in (name)
Geographic data smaller than a state Built in (address, city_state_zip)
Dates related to a person Built in for birth dates (dob). Other dates: use the health words in step 2
Telephone numbers Built in (phone)
Fax numbers Built in (phone). The format is the same, so a fax number is reported as a phone number
Email addresses Built in (email)
Social Security numbers Built in (ssn)
Medical record numbers Your own regex (step 1)
Health plan beneficiary numbers Your own regex (step 1)
Account numbers Your own regex
Certificate and license numbers Built in for US driver's licenses (drivers-license). Others: your own regex
Vehicle identifiers and license plates Your own regex
Device identifiers and serial numbers Your own regex
Web URLs Your own regex
IP addresses Your own regex
Biometric identifiers Not by a text scan
Full-face photos Not by a text scan
Any other unique number or code Your own regex

PII Crawler has no built-in detector for health data. It does not find MRNs, MBIs, NPIs or diagnosis codes by default. The steps below add them.

Step 1: Write patterns for your MRNs and plan numbers

Get one real MRN from your EHR, and write a pattern for its format. Most documents put a label such as "MRN" in front of the number. A pattern that needs the label gives fewer false results than a pattern for the digits alone. This pattern finds MRN: 00428177, MRN 00519302 and mrn:12345678:

(?i)\bMRN:?\s*[0-9]{6,10}\b

Change [0-9]{6,10} to the format of your MRNs.

The MBI format comes from the CMS MBI format sheet. Characters 1, 4, 7, 10 and 11 are digits, and character 1 is never 0. Characters 2, 5, 8 and 9 are letters. Characters 3 and 6 are letters or digits. The letters S, L, O, I, B and Z are never used. People often write the MBI with two dashes, so the pattern accepts them:

\b[1-9][AC-HJKMNP-RT-Y][AC-HJKMNP-RT-Y0-9][0-9]-?[AC-HJKMNP-RT-Y][AC-HJKMNP-RT-Y0-9][0-9]-?[AC-HJKMNP-RT-Y]{2}[0-9]{2}\b

On our test share, this pattern found all three MBIs. It did not match ACCT-771204, a ten-digit order number, or a serial number with the letters S and O in it.

PII Crawler uses a regex engine without lookarounds. A pattern with (?!...) or (?<=...) stops the scan before it starts, with the message look-around, including look-ahead and look-behind, is not supported. Write character classes, as in the two patterns above.

Step 2: Add a list of health words

A health word near a name is the signal that a file holds PHI. Put the words in a text file, one on each line. Use the words that your documents use. For example, health-terms.txt:

diagnosis
discharge
admitted
patient
prescription
medication
Medicare
Medicaid
MRN
date of service

PII Crawler matches each word as a whole word, and it ignores case. A match is reported as the type terms-list-healthterms, from the file name. Do not add short or common words such as "care" or "plan". They match too many files.

Step 3: Scan the share

To scan an SMB share without mounting it, use the smb command. Put the password in the PIICRAWLER_SMB_PASSWORD environment variable, so that it does not go into your shell history. Do not use --only, because you need the default detectors for names, dates of birth, addresses and phone numbers:

piicrawler smb fileserver Clinical -u svc-scan --domain CORP \
  --regex 'mrn=(?i)\bMRN:?\s*[0-9]{6,10}\b' \
  --regex 'mbi=\b[1-9][AC-HJKMNP-RT-Y][AC-HJKMNP-RT-Y0-9][0-9]-?[AC-HJKMNP-RT-Y][AC-HJKMNP-RT-Y0-9][0-9]-?[AC-HJKMNP-RT-Y]{2}[0-9]{2}\b' \
  --terms-file health-terms.txt \
  --name "PHI sweep: Clinical share"

The command saves the results and writes the scan ID to standard output. Matches of the two patterns are reported as regex-mrn and regex-mbi. If the share is already mounted, or if you scan a local folder, use scan with the same flags and --save.

The scan reads Word, Excel and PDF files, scanned pages with OCR, ZIP and 7z files, Outlook PST files and .msg files. It also reads the TIFF files that fax machines and document scanners make, in Group 3, Group 4 and older fax codings. Clinics often keep faxed referrals and lab results in a share as TIFF files. The supported file types page has the full list. For the problems that a text search has with these formats, see our guide to finding SSNs on a file share.

A scan from the command line does not use proximity groups. A proximity group reports a match only when two patterns are near each other, for example an MRN pattern and a name pattern within 300 characters. To use one, start the scan from the web UI (piicrawler serve) or the terminal UI.

Step 4: Sort the files by PHI, not by count

A file is a PHI candidate when it has an identifier and a health word. Export the findings without the false positives, and list the files that have both:

piicrawler export 42 --exclude-fp --out phi-findings.csv

Replace 42 with your scan ID. piicrawler scans shows the IDs. Then run this short Python script on the export:

import csv, collections

health, ids = collections.defaultdict(set), collections.defaultdict(set)
with open("phi-findings.csv", newline="", encoding="utf-8") as f:
    for row in csv.DictReader(f):
        kind = row["pii_type"]
        if kind.startswith("terms-list-"):
            health[row["file_path"]].add(kind)
        else:
            ids[row["file_path"]].add(kind)

for path in sorted(set(health) & set(ids)):
    print(path, ", ".join(sorted(ids[path])), sep="\t")

The script prints each PHI candidate with its identifier types. A file with regex-mrn or regex-mbi is almost always PHI. A file with only a name and a health word needs a person to look at it.

Examine the candidates in the web UI or the terminal UI. Mark each false result as a false positive, so that the next scan does not report it again. See triaging findings. Then delete, move or redact each file with an action list. An action list shows a preview before it changes a file.

Keep a record for the risk analysis

The HIPAA Security Rule, 45 CFR 164.308(a)(1)(ii)(A), requires "an accurate and thorough assessment" of the risks to the electronic PHI that you hold. You cannot assess PHI that you cannot find, so the scan is a good first input. Keep these files from each scan:

piicrawler report 42 --out clinical-share-phi-report.html
piicrawler export 42 --out clinical-share-phi-findings.csv

After the cleanup, scan the share again and keep the second report. Two reports, before and after, show that the cleanup worked.

PII Crawler runs on your own computer. It does not send file content or findings to a cloud service, so the scan does not give PHI to a new third party. For more about this, see air-gapped PII scanning.

Frequently asked questions

Does PII Crawler detect medical record numbers?

Not by default. MRN formats are different in each organization. Add your format with --regex, as in step 1. In the web UI and the terminal UI, you can also save the pattern as a custom regex rule. New scans from these two interfaces then use it. A scan from the command line uses only the patterns that you give with --regex.

Can it find diagnosis codes?

Only with your own pattern or terms list. ICD-10 codes are short, for example E11.9, and a pattern for them also matches many part numbers and version numbers. A list of the diagnosis words that your documents use usually gives better results.

Does a scan change my files?

No. A scan only reads files. Files change only when you run an action list, and the action list shows a preview first.

What about PHI in email?

PII Crawler reads Outlook PST and OST files, .msg, .eml and .mbox files, and IMAP mailboxes. In PST and OST files, it reads the subject, body, sender and recipients of each message, but it does not read attachments. See scanning email over IMAP.