fairpractice-exclusion-screening 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ Renamed from `heron-of-exclusions` on 18 Nov 2026 (tool names were `heron_*`, now `exclusions_*`).
4
+
5
+ ## 0.1.0 (unreleased)
6
+
7
+ - First version (Fairpractice ver 1).
8
+ - Final pass (19 Nov 2026), from the real OIG LEIE file: a near name with a birth date on both sides that differ is counted (near_names_other_birth_date) and not listed; near names with the same or no birth date are listed and say which. On 1,000 made-up staff with common names this took the findings from 6,357 to 529; 500 of 500 listed people are still found. The fixture near name now has the same birth date.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kurt Francisco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,196 @@
1
- # Temporary Holding Version
1
+ <!-- Generated by scripts/readme.mjs from the agent itself. Edit the manifest or fixtures/README.md, then run npm run readme. -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # Fairpractice Exclusion Screening (`fairpractice-exclusion-screening`)
4
+
5
+ Screens everyone a practice pays (staff, providers, contractors, vendors) against the exclusion lists you download (OIG LEIE, SAM, state Medicaid): NPI matches, name and birth-date matches, near-name matches to clear, reinstated entries and people not screened recently. Names are masked before results reach the model.
6
+
7
+ **Fairpractice Exclusion Screening never changes anyone's employment or vendor status; HR and compliance decide. Fairpractice Exclusion Screening never files an OIG self-disclosure or contacts a payer; counsel does.**
8
+
9
+ Fairpractice ver 1 · Compliance pack · MIT · Node 20 or newer · local files only · patient and staff identifiers masked before results reach the model · built on [`fairpractice-core`](../fairpractice-core)
10
+
11
+ ```bash
12
+ npx -y fairpractice-exclusion-screening demo
13
+ npx -y fairpractice-exclusion-screening mcp --root ./practice-files
14
+ ```
15
+
16
+ ## What the sample data shows
17
+
18
+ Fictional data only: Bluewater Family Medicine (a made-up practice), made-up staff and vendors, and made-up list entries marked "(FICTIONAL)". Any likeness to real people or firms is chance. The real OIG and state files are public downloads; these only copy their layout.
19
+
20
+ - [`people.csv`](fixtures/people.csv): staff, a provider, a contractor and vendors. Planted: an NPI on the list (E102), a name and birth-date match (E103), a name match with no birth date (E104), a near name with the same birth date (E105), same name but a different birth date (E106), a reinstated entry (E107), someone never screened (E108), someone last screened in August (E109) and a vendor on the state list (V201).
21
+ - [`leie-2026-11.csv`](fixtures/leie-2026-11.csv): OIG LEIE layout (dates as YYYYMMDD, zeros for blanks).
22
+ - [`state-medicaid-2026-11.csv`](fixtures/state-medicaid-2026-11.csv): a state list with different column names.
23
+ - [`settings.json`](fixtures/settings.json): near-name threshold 0.9 and a 31-day screening interval. [`settings-typo.json`](fixtures/settings-typo.json) misspells a setting and is refused.
24
+
25
+ ## A demo run
26
+
27
+ `npx -y fairpractice-exclusion-screening demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
28
+
29
+ ```text
30
+ Fairpractice Exclusion Screening demo (fictional practice, patients, staff and payers)
31
+
32
+ ▶ Screen staff, providers and vendors against the November lists
33
+ status: executed decision: allow
34
+ 11 people screened against 9 list entries. 4 need action now. 9 finding(s): npi_match 1, confirmed_match 1, possible_match 2, near_name 1, dob_differs 1, reinstated 1, never_screened 1, screening_overdue 1.
35
+ npi_match PT-c6779338's NPI is on exclusion list (excluded 2024-03-15).
36
+ confirmed_match PT-e613dd62 matches exclusion list by name and birth date (excluded 2022-01-10).
37
+ possible_match PT-e4cd17c4 matches a name on exclusion list; no birth date to confirm.
38
+ possible_match PT-62992339 matches a name on state list; no birth date to confirm.
39
+ near_name PT-570ce66c is close to PT-946ee91f PT-9a1643f5 on exclusion list (similarity 0.94), with the same birth date.
40
+ dob_differs PT-a4e6eb65 has the same name as an entry on exclusion list, but the birth dates differ.
41
+ reinstated PT-ebf9b8ea matches exclusion list, reinstated on 2025-06-01.
42
+ never_screened PT-22ef4d75 has no screening date.
43
+ screening_overdue PT-0cc38ac9 was last screened 87 days ago.
44
+
45
+ ▶ Write the screening file (Spanish page)
46
+ status: executed decision: allow
47
+ Exclusion screening written: 11 people screened against 9 list entries. 4 need action now. 9 finding(s): npi_match 1, confirmed_match 1, possible_match 2, near_name 1, dob_differs 1, reinstated 1, never_screened 1, screening_overdue 1. Files: fairpractice-out/exclusions/exclusions.csv, fairpractice-out/exclusions/exclusions.html.
48
+
49
+ ▶ Record a near-name match the officer checked
50
+ status: executed decision: allow
51
+ Stored MEM-cd6aa1ac288f as waiting. It changes nothing until a named person accepts it with exclusions_accept_learning (id "MEM-cd6aa1ac288f", decision "accept").
52
+
53
+ ▶ Agent tries to end someone's employment
54
+ status: blocked decision: block
55
+ reason: Fairpractice Exclusion Screening never changes anyone's employment or vendor status; HR and compliance decide.
56
+ ```
57
+
58
+ ## Tools
59
+
60
+ | Tool | What it does | Policy |
61
+ |---|---|---|
62
+ | `exclusions_check` | Match every person and vendor against the exclusion files and list matches to act on, near names to clear and people not screened recently. | runs |
63
+ | `exclusions_write_report` | Write exclusions.csv (one row per item, with blank owner and decision columns) and exclusions.html into out_dir (default fairpractice-out/exclusions). | runs |
64
+ | `exclusions_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
65
+ | `exclusions_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
66
+ | `exclusions_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
67
+ | `exclusions_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
68
+ | `employment_terminate` | Fairpractice Exclusion Screening never changes anyone's employment or vendor status; HR and compliance decide. | refused |
69
+ | `self_disclosure_submit` | Fairpractice Exclusion Screening never files an OIG self-disclosure or contacts a payer; counsel does. | refused |
70
+
71
+ Any tool name not in this table is blocked, including names a model invents. Refused tools are listed so a model can see they exist and are refused.
72
+
73
+ ### `exclusions_check` arguments
74
+
75
+ | Argument | What it is |
76
+ |---|---|
77
+ | `people` (required) | Everyone you pay or bill under (CSV, Excel, JSON): employees, providers, contractors and vendors with name, type, birth date, NPI and last screening date |
78
+ | `exclusions` (required) | Exclusion list you downloaded under --root, for example the OIG LEIE file (UPDATED.csv) or a SAM exclusions extract |
79
+ | `state_list` | Optional second list, for example your state Medicaid exclusion file |
80
+ | `settings` | Optional settings JSON: near_name_threshold and screening_interval_days |
81
+ | `as_of` | Date to measure deadlines and ages from (YYYY-MM-DD); default today |
82
+ | `status` | Only items with this status |
83
+ | `limit` | Most items to return to the model (the report file always has all of them) |
84
+
85
+ ## Columns it reads
86
+
87
+ Tables can be CSV, TSV, semicolon- or pipe-separated text, Excel `.xlsx`, JSON or JSONL. Columns are matched by the names below (any case and punctuation), and by their usual names in German, French, Spanish, Portuguese, Italian, Japanese, Chinese and Korean. Dates become `YYYY-MM-DD`. Columns marked *masked* hold patient or staff identifiers.
88
+
89
+ The PointClickCare, MatrixCare and American HealthTech style names were written from public help pages and general knowledge, **not checked against real exports**. Run `npx fairpractice-exclusion-screening inspect <file>` (column names and shapes only, never values) and name any column it misses in `remedy-sources.json`.
90
+
91
+ ### People you pay (`people`)
92
+
93
+ | Column | Type | Read from |
94
+ |---|---|---|
95
+ | `id` | text (masked) | Employee ID, Employee #, Emp ID, Staff ID, Worker ID, Caregiver ID, Badge, Person ID |
96
+ | `name` (required) | text (masked) | Employee, Employee Name, Staff, Staff Name, Name, Full Name, Worker, Caregiver |
97
+ | `type` | text | Type, Person Type, Category, Relationship, Worker Type, Payee Type |
98
+ | `dob` | date (masked) | DOB, Date of Birth, Birth Date, Birthdate |
99
+ | `npi` | text | NPI, Provider NPI, Rendering NPI, Individual NPI |
100
+ | `last_screened` | date | Last Screened, Last Check, Screened On, Last Screening Date, Last Verified, Exclusion Check Date |
101
+
102
+ ### Exclusion list (`exclusions`)
103
+
104
+ | Column | Type | Read from |
105
+ |---|---|---|
106
+ | `last_name` | text (masked) | LASTNAME, Last Name, Last, Surname |
107
+ | `first_name` | text (masked) | FIRSTNAME, First Name, First, Given Name |
108
+ | `middle_name` | text (masked) | MIDNAME, Middle Name, Middle, MI |
109
+ | `name` | text (masked) | Full Name, Individual Name, Provider Name, Excluded Name |
110
+ | `business_name` | text | BUSNAME, Business Name, Entity Name, Firm, Name |
111
+ | `npi` | text | NPI, Provider NPI |
112
+ | `dob` | date (masked) | DOB, Date of Birth, Birth Date |
113
+ | `exclusion_type` | text | EXCLTYPE, Exclusion Type, Exclusion Authority, Sanction Type, Classification |
114
+ | `excluded_on` | date | EXCLDATE, Exclusion Date, Active Date, Effective Date, Sanction Date, Date Excluded |
115
+ | `reinstated_on` | date | REINDATE, Reinstatement Date, Reinstated, Termination Date, End Date |
116
+ | `state` | text | STATE, State |
117
+ | `source` | text | Source, List |
118
+
119
+ ### Second exclusion list (`state_list`)
120
+
121
+ | Column | Type | Read from |
122
+ |---|---|---|
123
+ | `last_name` | text (masked) | LASTNAME, Last Name, Last, Surname |
124
+ | `first_name` | text (masked) | FIRSTNAME, First Name, First, Given Name |
125
+ | `middle_name` | text (masked) | MIDNAME, Middle Name, Middle, MI |
126
+ | `name` | text (masked) | Full Name, Individual Name, Provider Name, Excluded Name |
127
+ | `business_name` | text | BUSNAME, Business Name, Entity Name, Firm, Name |
128
+ | `npi` | text | NPI, Provider NPI |
129
+ | `dob` | date (masked) | DOB, Date of Birth, Birth Date |
130
+ | `exclusion_type` | text | EXCLTYPE, Exclusion Type, Exclusion Authority, Sanction Type, Classification |
131
+ | `excluded_on` | date | EXCLDATE, Exclusion Date, Active Date, Effective Date, Sanction Date, Date Excluded |
132
+ | `reinstated_on` | date | REINDATE, Reinstatement Date, Reinstated, Termination Date, End Date |
133
+ | `state` | text | STATE, State |
134
+ | `source` | text | Source, List |
135
+
136
+ ## Settings file (`exclusions_settings`)
137
+
138
+ A small JSON file you pass by path. A misspelled setting is refused by name rather than ignored, so a typo never silently changes a check.
139
+
140
+ | Setting | What it does |
141
+ |---|---|
142
+ | `near_name_threshold` | Name similarity (0.8-1) at which a different spelling is shown as a near-name match; default 0.92 |
143
+ | `screening_interval_days` | Days after which a person counts as not screened recently; default 31 (monthly) |
144
+
145
+ ## Memory
146
+
147
+ `exclusions_learn` only proposes a fact; nothing changes until a named person accepts it with `exclusions_accept_learning`, which is one click even in Auto. Facts live in a hash-chained file under `.remedy/memory/`; if the chain does not verify, no fact is used. Credentials, personal identifiers and text that reads like instructions to an AI are refused.
148
+
149
+ | Kind | What an accepted fact does |
150
+ |---|---|
151
+ | `cleared_match` | stops name and near-name matches to that entry from showing again for that person; an NPI match always shows. |
152
+
153
+ ## Install
154
+
155
+ Node 20 or newer. No other runtime dependencies besides `fairpractice-core` and `fairclaim-core`.
156
+
157
+ ```json
158
+ {
159
+ "mcpServers": {
160
+ "fairpractice-exclusion-screening": {
161
+ "command": "npx",
162
+ "args": [
163
+ "-y",
164
+ "fairpractice-exclusion-screening",
165
+ "mcp",
166
+ "--root",
167
+ "/path/to/practice-files"
168
+ ]
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ Claude Code: `claude mcp add fairpractice-exclusion-screening -- npx -y fairpractice-exclusion-screening mcp --root .`, or use the plugin files in this folder.
175
+
176
+ ## CLI
177
+
178
+ ```bash
179
+ fairpractice-exclusion-screening tools # every tool, its policy and arguments
180
+ fairpractice-exclusion-screening sources # the columns each input is read from
181
+ fairpractice-exclusion-screening inspect <file> # how a file would be read (names and shapes, never values)
182
+ fairpractice-exclusion-screening call exclusions_check '{"people":"<people>","exclusions":"<exclusions>"}'
183
+ fairpractice-exclusion-screening eval # the private eval cases on the fictional fixtures
184
+ fairpractice-exclusion-screening demo
185
+ ```
186
+
187
+ ## Patient and staff data
188
+
189
+ Results go to an AI model, so identifiers are masked before they leave the agent: patient and staff names become stable pseudonyms such as `PT-3f9a1c2e`, record and account numbers become `MRN-…` or `ACCT-…`, and e-mails and phone numbers are removed, also inside free text. Report files written to disk keep real names because staff work from them: keep them in a folder only your staff can open. The shared tests check that no fictional identifier from the fixtures reaches any eval result, and the hostile-input check plants spreadsheet formulas, HTML and AI-aimed instructions in the data. This keeps PHI away from the model; it is **not** a HIPAA compliance determination. Your business associate agreements, access controls and policies still apply.
190
+
191
+ ## Limits
192
+
193
+ - Reads only the files you give it. It does not log in to an EHR, practice-management system, payer portal, clearinghouse, state system, HR or payroll system, or bank.
194
+ - Payer, Medicare, Medicaid, state and federal rules are summarised from public material as of 2026, and the numbers are settings you supply; a billing, compliance or legal professional checks them before you rely on them.
195
+ - Not legal, billing, coding, tax, clinical or HIPAA advice. It does not diagnose or recommend care. A person decides what to bill, pay, report, file or send.
196
+ - Every call is written to a hash-chained audit log under `.remedy/` in the root. No network calls, no telemetry, no credentials. The bundled data is fictional.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from 'node:url';
3
+ import { main } from 'fairpractice-core';
4
+ import { manifest } from '../src/manifest.js';
5
+ import { demo } from '../src/demo.js';
6
+
7
+ main(manifest, { bin: 'fairpractice-exclusion-screening', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,310 @@
1
+ {
2
+ "suite": "fairpractice-exclusion-screening",
3
+ "root": "..",
4
+ "data_note": "Fictional data in ../fixtures. Deterministic checks; no model is called.",
5
+ "cases": [
6
+ {
7
+ "id": "totals",
8
+ "tool": "exclusions_check",
9
+ "args": {
10
+ "people": "fixtures/people.csv",
11
+ "exclusions": "fixtures/leie-2026-11.csv",
12
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
13
+ "settings": "fixtures/settings.json",
14
+ "as_of": "2026-11-15"
15
+ },
16
+ "expect": {
17
+ "status": "executed",
18
+ "equals": {
19
+ "result.people": 11,
20
+ "result.list_entries": 9,
21
+ "result.needs_action": 4
22
+ }
23
+ }
24
+ },
25
+ {
26
+ "id": "every-planted-status-in-order",
27
+ "tool": "exclusions_check",
28
+ "args": {
29
+ "people": "fixtures/people.csv",
30
+ "exclusions": "fixtures/leie-2026-11.csv",
31
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
32
+ "settings": "fixtures/settings.json",
33
+ "as_of": "2026-11-15"
34
+ },
35
+ "expect": {
36
+ "equals": {
37
+ "result.items.0.status": "npi_match",
38
+ "result.items.1.status": "confirmed_match",
39
+ "result.items.2.status": "possible_match",
40
+ "result.items.3.status": "possible_match",
41
+ "result.items.4.status": "near_name",
42
+ "result.items.5.status": "dob_differs",
43
+ "result.items.6.status": "reinstated",
44
+ "result.items.7.status": "never_screened",
45
+ "result.items.8.status": "screening_overdue"
46
+ }
47
+ }
48
+ },
49
+ {
50
+ "id": "status-filter",
51
+ "tool": "exclusions_check",
52
+ "args": {
53
+ "people": "fixtures/people.csv",
54
+ "exclusions": "fixtures/leie-2026-11.csv",
55
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
56
+ "settings": "fixtures/settings.json",
57
+ "as_of": "2026-11-15",
58
+ "status": "npi_match"
59
+ },
60
+ "expect": {
61
+ "status": "executed",
62
+ "equals": {
63
+ "result.items.0.status": "npi_match"
64
+ }
65
+ }
66
+ },
67
+ {
68
+ "id": "limit-one",
69
+ "tool": "exclusions_check",
70
+ "args": {
71
+ "people": "fixtures/people.csv",
72
+ "exclusions": "fixtures/leie-2026-11.csv",
73
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
74
+ "settings": "fixtures/settings.json",
75
+ "as_of": "2026-11-15",
76
+ "limit": 1
77
+ },
78
+ "expect": {
79
+ "status": "executed",
80
+ "length": {
81
+ "result.items": 1
82
+ }
83
+ }
84
+ },
85
+ {
86
+ "id": "report",
87
+ "tool": "exclusions_write_report",
88
+ "args": {
89
+ "people": "fixtures/people.csv",
90
+ "exclusions": "fixtures/leie-2026-11.csv",
91
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
92
+ "settings": "fixtures/settings.json",
93
+ "as_of": "2026-11-15"
94
+ },
95
+ "expect": {
96
+ "status": "executed",
97
+ "matches": [
98
+ "\\.csv",
99
+ "\\.html"
100
+ ]
101
+ }
102
+ },
103
+ {
104
+ "id": "report-spanish",
105
+ "tool": "exclusions_write_report",
106
+ "args": {
107
+ "people": "fixtures/people.csv",
108
+ "exclusions": "fixtures/leie-2026-11.csv",
109
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
110
+ "settings": "fixtures/settings.json",
111
+ "as_of": "2026-11-15",
112
+ "language": "es"
113
+ },
114
+ "expect": {
115
+ "status": "executed"
116
+ }
117
+ },
118
+ {
119
+ "id": "typo-setting-refused",
120
+ "tool": "exclusions_check",
121
+ "args": {
122
+ "people": "fixtures/people.csv",
123
+ "exclusions": "fixtures/leie-2026-11.csv",
124
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
125
+ "settings": "fixtures/settings-typo.json",
126
+ "as_of": "2026-11-15"
127
+ },
128
+ "expect": {
129
+ "status": "error"
130
+ }
131
+ },
132
+ {
133
+ "id": "missing-file",
134
+ "tool": "exclusions_check",
135
+ "args": {
136
+ "people": "fixtures/people.csv",
137
+ "exclusions": "fixtures/does-not-exist.csv",
138
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
139
+ "settings": "fixtures/settings.json",
140
+ "as_of": "2026-11-15"
141
+ },
142
+ "expect": {
143
+ "status": "error"
144
+ }
145
+ },
146
+ {
147
+ "id": "refuses-employment_terminate",
148
+ "tool": "employment_terminate",
149
+ "args": {},
150
+ "expect": {
151
+ "status": "blocked"
152
+ }
153
+ },
154
+ {
155
+ "id": "refuses-self_disclosure_submit",
156
+ "tool": "self_disclosure_submit",
157
+ "args": {},
158
+ "expect": {
159
+ "status": "blocked"
160
+ }
161
+ },
162
+ {
163
+ "id": "recall-empty-memory",
164
+ "tool": "exclusions_recall",
165
+ "args": {},
166
+ "expect": {
167
+ "status": "executed",
168
+ "contains": [
169
+ "memory is empty"
170
+ ]
171
+ }
172
+ },
173
+ {
174
+ "id": "learn-waits",
175
+ "tool": "exclusions_learn",
176
+ "args": {
177
+ "kind": "cleared_match",
178
+ "value": {
179
+ "person_id": "E105",
180
+ "excluded_on": "2021-09-09"
181
+ }
182
+ },
183
+ "expect": {
184
+ "status": "executed",
185
+ "matches": [
186
+ "waiting"
187
+ ]
188
+ }
189
+ },
190
+ {
191
+ "id": "vendor-on-state-list",
192
+ "tool": "exclusions_check",
193
+ "args": {
194
+ "people": "fixtures/people.csv",
195
+ "exclusions": "fixtures/leie-2026-11.csv",
196
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
197
+ "settings": "fixtures/settings.json",
198
+ "as_of": "2026-11-15",
199
+ "status": "possible_match"
200
+ },
201
+ "expect": {
202
+ "equals": {
203
+ "result.items.1.list": "state list",
204
+ "result.items.1.type": "vendor"
205
+ }
206
+ }
207
+ },
208
+ {
209
+ "id": "npi-match-has-exclusion-date",
210
+ "tool": "exclusions_check",
211
+ "args": {
212
+ "people": "fixtures/people.csv",
213
+ "exclusions": "fixtures/leie-2026-11.csv",
214
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
215
+ "settings": "fixtures/settings.json",
216
+ "as_of": "2026-11-15",
217
+ "status": "npi_match"
218
+ },
219
+ "expect": {
220
+ "equals": {
221
+ "result.items.0.excluded_on": "2024-03-15",
222
+ "result.items.0.listed_npi": "1234567893"
223
+ }
224
+ }
225
+ },
226
+ {
227
+ "id": "overdue-days",
228
+ "tool": "exclusions_check",
229
+ "args": {
230
+ "people": "fixtures/people.csv",
231
+ "exclusions": "fixtures/leie-2026-11.csv",
232
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
233
+ "settings": "fixtures/settings.json",
234
+ "as_of": "2026-11-15",
235
+ "status": "screening_overdue"
236
+ },
237
+ "expect": {
238
+ "equals": {
239
+ "result.items.0.days_since": 87
240
+ }
241
+ }
242
+ },
243
+ {
244
+ "id": "default-threshold-still-finds-near-name",
245
+ "tool": "exclusions_check",
246
+ "args": {
247
+ "people": "fixtures/people.csv",
248
+ "exclusions": "fixtures/leie-2026-11.csv",
249
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
250
+ "as_of": "2026-11-15"
251
+ },
252
+ "expect": {
253
+ "equals": {
254
+ "result.by_status.near_name": 1
255
+ }
256
+ }
257
+ },
258
+ {
259
+ "id": "no-state-list",
260
+ "tool": "exclusions_check",
261
+ "args": {
262
+ "people": "fixtures/people.csv",
263
+ "exclusions": "fixtures/leie-2026-11.csv",
264
+ "settings": "fixtures/settings.json",
265
+ "as_of": "2026-11-15"
266
+ },
267
+ "expect": {
268
+ "equals": {
269
+ "result.by_status.possible_match": 1,
270
+ "result.list_entries": 7
271
+ }
272
+ }
273
+ },
274
+ {
275
+ "id": "file-outside-root-refused",
276
+ "tool": "exclusions_check",
277
+ "args": {
278
+ "people": "../../outside-root.csv",
279
+ "exclusions": "fixtures/leie-2026-11.csv",
280
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
281
+ "settings": "fixtures/settings.json",
282
+ "as_of": "2026-11-15"
283
+ },
284
+ "expect": {
285
+ "status": "error",
286
+ "contains": [
287
+ "outside the allowed root"
288
+ ]
289
+ }
290
+ },
291
+ {
292
+ "id": "missing-file-named",
293
+ "tool": "exclusions_check",
294
+ "args": {
295
+ "people": "fixtures/missing-export.csv",
296
+ "exclusions": "fixtures/leie-2026-11.csv",
297
+ "state_list": "fixtures/state-medicaid-2026-11.csv",
298
+ "settings": "fixtures/settings.json",
299
+ "as_of": "2026-11-15"
300
+ },
301
+ "expect": {
302
+ "status": "error",
303
+ "contains": [
304
+ "not found",
305
+ "missing-export.csv"
306
+ ]
307
+ }
308
+ }
309
+ ]
310
+ }
@@ -0,0 +1,8 @@
1
+ # Fixtures
2
+
3
+ Fictional data only: Bluewater Family Medicine (a made-up practice), made-up staff and vendors, and made-up list entries marked "(FICTIONAL)". Any likeness to real people or firms is chance. The real OIG and state files are public downloads; these only copy their layout.
4
+
5
+ - `people.csv`: staff, a provider, a contractor and vendors. Planted: an NPI on the list (E102), a name and birth-date match (E103), a name match with no birth date (E104), a near name with the same birth date (E105), same name but a different birth date (E106), a reinstated entry (E107), someone never screened (E108), someone last screened in August (E109) and a vendor on the state list (V201).
6
+ - `leie-2026-11.csv`: OIG LEIE layout (dates as YYYYMMDD, zeros for blanks).
7
+ - `state-medicaid-2026-11.csv`: a state list with different column names.
8
+ - `settings.json`: near-name threshold 0.9 and a 31-day screening interval. `settings-typo.json` misspells a setting and is refused.
@@ -0,0 +1,124 @@
1
+ {
2
+ "case": "totals",
3
+ "id": [
4
+ [
5
+ "person_id"
6
+ ]
7
+ ],
8
+ "planted": [
9
+ ["E102", "npi_match"],
10
+ ["E103", "confirmed_match"],
11
+ ["E104", "possible_match"],
12
+ ["V201", "possible_match"],
13
+ ["E105", "near_name"],
14
+ ["E106", "dob_differs"],
15
+ ["E107", "reinstated"],
16
+ ["E108", "never_screened"],
17
+ ["E109", "screening_overdue"]
18
+ ],
19
+ "clean": [
20
+ {
21
+ "arg": "exclusions",
22
+ "drop": [
23
+ ["LASTNAME", "ASHBY"],
24
+ ["LASTNAME", "MERCER"],
25
+ ["LASTNAME", "WHITLOCK"],
26
+ ["LASTNAME", "PRYCE"],
27
+ ["LASTNAME", "OKOYE"],
28
+ ["LASTNAME", "LUND"]
29
+ ]
30
+ },
31
+ {
32
+ "arg": "state_list",
33
+ "drop": [
34
+ ["Name", "GULFLINE MEDICAL SUPPLY"]
35
+ ]
36
+ },
37
+ {
38
+ "arg": "people",
39
+ "set": [
40
+ {
41
+ "where": ["Employee ID", "E108"],
42
+ "column": "Last Screened",
43
+ "value": "2026-11-01"
44
+ },
45
+ {
46
+ "where": ["Employee ID", "E109"],
47
+ "column": "Last Screened",
48
+ "value": "2026-11-01"
49
+ }
50
+ ]
51
+ }
52
+ ],
53
+ "mutations": [
54
+ {
55
+ "name": "an employee added to the federal list",
56
+ "edits": [
57
+ {
58
+ "arg": "exclusions",
59
+ "add": [
60
+ {
61
+ "LASTNAME": "VEGA",
62
+ "FIRSTNAME": "MARISOL",
63
+ "MIDNAME": "",
64
+ "BUSNAME": "",
65
+ "GENERAL": "NURSING PROFESSION",
66
+ "SPECIALTY": "",
67
+ "UPIN": "",
68
+ "NPI": "0000000000",
69
+ "DOB": "19850312",
70
+ "ADDRESS": "",
71
+ "CITY": "",
72
+ "STATE": "TX",
73
+ "ZIP": "",
74
+ "EXCLTYPE": "1128a1",
75
+ "EXCLDATE": "20250101",
76
+ "REINDATE": "00000000",
77
+ "WAIVERDATE": "00000000",
78
+ "WVRSTATE": ""
79
+ }
80
+ ]
81
+ }
82
+ ],
83
+ "expect": [
84
+ ["E101", "confirmed_match"]
85
+ ]
86
+ },
87
+ {
88
+ "name": "a vendor on the state list",
89
+ "edits": [
90
+ {
91
+ "arg": "state_list",
92
+ "set": [
93
+ {
94
+ "where": ["Name", "WINSLOW TRAVERS"],
95
+ "column": "Name",
96
+ "value": "HARBORVIEW LINEN SERVICE"
97
+ }
98
+ ]
99
+ }
100
+ ],
101
+ "expect": [
102
+ ["V202", "possible_match"]
103
+ ]
104
+ },
105
+ {
106
+ "name": "last screened in September",
107
+ "edits": [
108
+ {
109
+ "arg": "people",
110
+ "set": [
111
+ {
112
+ "where": ["Employee ID", "E101"],
113
+ "column": "Last Screened",
114
+ "value": "2026-09-01"
115
+ }
116
+ ]
117
+ }
118
+ ],
119
+ "expect": [
120
+ ["E101", "screening_overdue"]
121
+ ]
122
+ }
123
+ ]
124
+ }
@@ -0,0 +1,8 @@
1
+ LASTNAME,FIRSTNAME,MIDNAME,BUSNAME,GENERAL,SPECIALTY,UPIN,NPI,DOB,ADDRESS,CITY,STATE,ZIP,EXCLTYPE,EXCLDATE,REINDATE,WAIVERDATE,WVRSTATE
2
+ ASHBY,THEODORE,R,,IND- LIC HC SERV PRO,PHYSICIAN,,1234567893,19700704,1 ELM ST (FICTIONAL),SPRINGFIELD,TX,75001,1128b4,20240315,00000000,00000000,
3
+ MERCER,ROSALIND,,,NURSING PROFESSION,NURSE/NURSES AIDE,,0000000000,19790220,2 OAK AVE (FICTIONAL),SPRINGFIELD,TX,75002,1128a1,20220110,00000000,00000000,
4
+ WHITLOCK,DANA,,,OTHER BUSINESS,,,0000000000,,3 PINE RD (FICTIONAL),LAKETOWN,OK,73001,1128b7,20230601,00000000,00000000,
5
+ PRYCE,JONATHON,,,PHARMACY,PHARMACIST,,0000000000,19900505,4 BAY LN (FICTIONAL),PORTVILLE,LA,70001,1128a3,20210909,00000000,00000000,
6
+ OKOYE,SAMUEL,,,MEDICAL PRACTICE,,,0000000000,19600302,5 HILL CT (FICTIONAL),RIVERTON,TX,75003,1128b4,20190505,00000000,00000000,
7
+ LUND,BEATRICE,,,NURSING PROFESSION,NURSE/NURSES AIDE,,0000000000,19750101,6 LAKE DR (FICTIONAL),SPRINGFIELD,TX,75004,1128b4,20200101,20250601,00000000,
8
+ ,,,NORTHSTAR AMBULANCE (FICTIONAL),AMBULANCE,,,0000000000,,7 MAIN ST (FICTIONAL),RIVERTON,TX,75005,1128a1,20200202,00000000,00000000,
@@ -0,0 +1,12 @@
1
+ Employee ID,Name,Type,Date of Birth,NPI,Last Screened
2
+ E101,Marisol Vega,employee,1985-03-12,,2026-11-01
3
+ E102,Theodore Ashby,provider,1970-07-04,1234567893,2026-11-01
4
+ E103,Rosalind Mercer,employee,1979-02-20,,2026-11-03
5
+ E104,Dana Whitlock,contractor,,,2026-11-02
6
+ E105,Jonathan Price,employee,1990-05-05,,2026-11-01
7
+ E106,Samuel Okoye,employee,1988-09-09,,2026-11-01
8
+ E107,Beatrice Lund,employee,1975-01-01,,2026-11-01
9
+ E108,Carlos Mendez,employee,1992-12-12,,
10
+ E109,Priya Nair,employee,1987-04-04,,2026-08-20
11
+ V201,Gulfline Medical Supply LLC,vendor,,,2026-11-01
12
+ V202,Harborview Linen Service,vendor,,,2026-11-01
@@ -0,0 +1 @@
1
+ { "note": "Fictional staff names and ids used in these fixtures. None may reach a model result when masking is on.", "values": ["Marisol Vega", "Theodore Ashby", "Rosalind Mercer", "Dana Whitlock", "Jonathan Price", "Samuel Okoye", "Priya Nair", "Carlos Mendez"] }
@@ -0,0 +1 @@
1
+ { "near_name_treshold": 0.9 }
@@ -0,0 +1 @@
1
+ { "near_name_threshold": 0.9, "screening_interval_days": 31 }
@@ -0,0 +1,3 @@
1
+ Name,Exclusion Type,Effective Date,Termination Date
2
+ GULFLINE MEDICAL SUPPLY,Medicaid fraud (fictional),2025-10-01,
3
+ WINSLOW TRAVERS,Medicaid fraud (fictional),2024-02-02,
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "fairpractice-exclusion-screening",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.fpavia111-creator/fairpractice-exclusion-screening",
5
+ "description": "Exclusion screening for everyone a practice pays: staff, providers, contractors and vendors checked against the OIG exclusion list, SAM and state Medicaid exclusion files you download, with NPI and birth-date matches, near-name matches to clear, reinstatements and people not screened this month.",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "Kurt Francisco",
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "main": "src/index.js",
13
+ "exports": {
14
+ ".": "./src/index.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "bin": {
18
+ "fairpractice-exclusion-screening": "bin/fairpractice-exclusion-screening.js"
19
+ },
20
+ "files": [
21
+ "src",
22
+ "bin",
23
+ "fixtures",
24
+ "evals",
25
+ "README.md",
26
+ "CHANGELOG.md",
27
+ "LICENSE",
28
+ "server.json"
29
+ ],
30
+ "scripts": {
31
+ "test": "node scripts/run-tests.cjs",
32
+ "demo": "node bin/fairpractice-exclusion-screening.js demo",
33
+ "eval": "node bin/fairpractice-exclusion-screening.js eval"
34
+ },
35
+ "dependencies": {
36
+ "fairpractice-core": "^0.3.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/fpavia111-creator/fairpractice-agents.git",
41
+ "directory": "packages/fairpractice-exclusion-screening"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairpractice-agents/tree/master/packages/fairpractice-exclusion-screening#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/fpavia111-creator/fairpractice-agents/issues"
46
+ },
47
+ "keywords": [
48
+ "mcp",
49
+ "mcp-server",
50
+ "healthcare",
51
+ "medical-billing",
52
+ "revenue-cycle",
53
+ "healthcare-compliance",
54
+ "exclusion-screening",
55
+ "oig",
56
+ "leie",
57
+ "sam",
58
+ "compliance"
59
+ ]
60
+ }
package/server.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.fpavia111-creator/fairpractice-exclusion-screening",
4
+ "title": "Fairpractice Exclusion Screening",
5
+ "description": "Exclusion screening for everyone a practice pays",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairpractice-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairpractice-exclusion-screening"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairpractice.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairpractice-exclusion-screening",
17
+ "version": "0.1.0",
18
+ "transport": {
19
+ "type": "stdio"
20
+ },
21
+ "packageArguments": [
22
+ {
23
+ "type": "positional",
24
+ "value": "mcp"
25
+ },
26
+ {
27
+ "type": "named",
28
+ "name": "--root",
29
+ "description": "Folder holding the exports this agent may read and write (it cannot reach outside it)",
30
+ "isRequired": true,
31
+ "format": "filepath",
32
+ "valueHint": "exports_folder"
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
package/src/demo.js ADDED
@@ -0,0 +1,9 @@
1
+ import { runDemo } from 'fairpractice-core';
2
+ import { manifest } from './manifest.js';
3
+
4
+ export const demo = () => runDemo(manifest, new URL('../fixtures', import.meta.url), 'Fairpractice Exclusion Screening', [
5
+ { label: 'Screen staff, providers and vendors against the November lists', tool: 'exclusions_check', args: { people: 'people.csv', exclusions: 'leie-2026-11.csv', state_list: 'state-medicaid-2026-11.csv', settings: 'settings.json', as_of: '2026-11-15' }, list: (i) => `${i.status.padEnd(18)} ${i.message}` },
6
+ { label: 'Write the screening file (Spanish page)', tool: 'exclusions_write_report', args: { people: 'people.csv', exclusions: 'leie-2026-11.csv', state_list: 'state-medicaid-2026-11.csv', settings: 'settings.json', as_of: '2026-11-15', language: 'es' } },
7
+ { label: 'Record a near-name match the officer checked', tool: 'exclusions_learn', args: { kind: 'cleared_match', value: { person_id: 'E105', excluded_on: '2021-09-09', note: 'different birth date, checked on the list site' } } },
8
+ { label: 'Agent tries to end someone\'s employment', tool: 'employment_terminate', args: {} },
9
+ ]);
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { manifest } from './manifest.js';
2
+ export * from './logic.js';
package/src/logic.js ADDED
@@ -0,0 +1,83 @@
1
+ // Fairpractice Exclusion Screening logic: everyone you pay against exclusion lists. No I/O.
2
+ import { str, isoDate, daysBetween, personKey, jaroWinkler, round2, nearNameIndex, normalizeName, npiValid, sortByStatus, countBy } from 'fairpractice-core';
3
+
4
+ const ORDER = { npi_match: 0, confirmed_match: 1, possible_match: 2, near_name: 3, dob_differs: 4, reinstated: 5, never_screened: 6, screening_overdue: 7 };
5
+ const ENTITY_TYPES = /vendor|business|company|entity|supplier|org/i;
6
+
7
+ /** One exclusion entry from an OIG LEIE, SAM or state row (fields already mapped). */
8
+ export function exclusionEntry(r, source) {
9
+ const name = str(r.name) || [r.first_name, r.middle_name, r.last_name].map(str).filter(Boolean).join(' ');
10
+ const business = str(r.business_name);
11
+ return { source: str(r.source) || source, name: name || null, business: business || null, npi: /^\d{10}$/.test(str(r.npi)) && str(r.npi) !== '0000000000' ? str(r.npi) : null, dob: isoDate(r.dob), excluded_on: isoDate(r.excluded_on), reinstated_on: isoDate(r.reinstated_on), type: str(r.exclusion_type) || null, state: str(r.state) || null };
12
+ }
13
+
14
+ /**
15
+ * Screen people against exclusion entries.
16
+ * people: [{ id, name, dob, npi, type, last_screened }]
17
+ * opts: { asOf, nearThreshold = 0.92, intervalDays = 31, cleared(person, entry) -> true when a person reviewed and cleared that entry }
18
+ */
19
+ export function screen(people, entries, { asOf, nearThreshold = 0.92, intervalDays = 31, cleared = () => false } = {}) {
20
+ const byNpi = new Map(); const byName = new Map(); const byBiz = new Map();
21
+ for (const e of entries) {
22
+ if (e.npi) { if (!byNpi.has(e.npi)) byNpi.set(e.npi, []); byNpi.get(e.npi).push(e); }
23
+ if (e.name) { const k = personKey(e.name); if (k) { if (!byName.has(k)) byName.set(k, []); byName.get(k).push(e); } }
24
+ // A business is matched on the list's business name, or on its plain name when the list has one name column
25
+ // for people and companies alike (most state Medicaid lists; a German or French export names it as a person's name).
26
+ const biz = e.business || e.name; if (biz) { const k = normalizeName(biz); if (k) { if (!byBiz.has(k)) byBiz.set(k, []); byBiz.get(k).push(e); } }
27
+ }
28
+ // Near names: only listed names sharing a word, or a word one typo away (fairpractice-core nearNameIndex), are
29
+ // compared, not every listed name for every person (minutes at 10,000 rows; the OIG list has about 80,000).
30
+ const candidates = nearNameIndex(byName.keys(), { maxLenDiff: 4 });
31
+ const nearCache = new Map();
32
+ const nearOf = (pk) => {
33
+ if (nearCache.has(pk)) return nearCache.get(pk);
34
+ const out = []; for (const k of candidates(pk)) { const sim = round2(jaroWinkler(k, pk)); if (sim >= nearThreshold) out.push([k, sim]); }
35
+ nearCache.set(pk, out); return out;
36
+ };
37
+ const active = (e) => !(e.reinstated_on && (!asOf || e.reinstated_on <= asOf));
38
+ const items = []; let nearOtherDob = 0;
39
+ for (const [i, p] of people.entries()) {
40
+ const name = str(p.name); if (!name && !str(p.npi)) continue;
41
+ const base = { person_id: str(p.id) || null, name: name || null, type: str(p.type) || null, line: i + 1 };
42
+ const seen = new Set();
43
+ const push = (status, e, extra = {}) => { const key = `${status}|${e ? (e.name || e.business) + e.source : ''}`; if (seen.has(key)) return; seen.add(key); items.push({ ...base, status, list: e ? e.source : null, listed_name: e ? (e.name || e.business) : null, listed_npi: e ? e.npi : null, excluded_on: e ? e.excluded_on : null, reinstated_on: e ? e.reinstated_on : null, ...extra }); };
44
+ const npi = str(p.npi);
45
+ const hits = [];
46
+ if (npi && npiValid(npi)) for (const e of byNpi.get(npi) || []) hits.push(['npi', e]);
47
+ const pk = personKey(name);
48
+ const isEntity = ENTITY_TYPES.test(str(p.type));
49
+ if (isEntity) { for (const e of byBiz.get(normalizeName(name)) || []) hits.push(['name', e]); }
50
+ else if (pk) {
51
+ for (const e of byName.get(pk) || []) hits.push(['name', e]);
52
+ if (!(byName.get(pk) || []).length) for (const [k, sim] of nearOf(pk)) for (const e of byName.get(k)) hits.push(['near', e, sim]);
53
+ }
54
+ const npiHit = new Set(hits.filter((h) => h[0] === 'npi').map((h) => h[1]));
55
+ for (const [how, e, sim] of hits) {
56
+ if (how !== 'npi' && npiHit.has(e)) continue;
57
+ if (how !== 'npi' && cleared(p, e)) continue;
58
+ if (!active(e)) { push('reinstated', e); continue; }
59
+ if (how === 'npi') { push('npi_match', e); continue; }
60
+ const pd = isoDate(p.dob);
61
+ // A near name with birth dates on both sides that differ is a different person: counted, not listed.
62
+ // (On the real OIG file, 1,000 made-up staff with common names gave 4,991 such near names.)
63
+ if (how === 'near') { if (pd && e.dob && pd !== e.dob) { nearOtherDob++; continue; } push('near_name', e, { similarity: sim, same_dob: !!(pd && e.dob) }); continue; }
64
+ if (pd && e.dob) push(pd === e.dob ? 'confirmed_match' : 'dob_differs', e); else push('possible_match', e);
65
+ }
66
+ const last = isoDate(p.last_screened);
67
+ if (!last) push('never_screened', null); else if (asOf && daysBetween(last, asOf) > intervalDays) push('screening_overdue', null, { last_screened: last, days_since: daysBetween(last, asOf) });
68
+ }
69
+ const T = {
70
+ npi_match: (x) => [`${x.name}'s NPI is on ${x.list} (excluded ${x.excluded_on || 'date not given'}).`, 'Stop billing for this person\'s services today and take it to your compliance officer and counsel; claims they touched since the exclusion may have to be repaid.'],
71
+ confirmed_match: (x) => [`${x.name} matches ${x.list} by name and birth date (excluded ${x.excluded_on || 'date not given'}).`, 'Treat as excluded: remove from federal program work and take it to your compliance officer and counsel.'],
72
+ possible_match: (x) => [`${x.name} matches a name on ${x.list}; no birth date to confirm.`, 'Verify with a second identifier (birth date, NPI, address, SSN through the official site) and record the result.'],
73
+ near_name: (x) => [`${x.name} is close to ${x.listed_name} on ${x.list} (similarity ${x.similarity})${x.same_dob ? ', with the same birth date' : ', with no birth date to compare'}.`, 'Usually a different person: compare birth date or NPI, then clear it (exclusions_learn, kind cleared_match) so it stops showing.'],
74
+ dob_differs: (x) => [`${x.name} has the same name as an entry on ${x.list}, but the birth dates differ.`, 'Likely a different person. Note the check in the file and clear it.'],
75
+ reinstated: (x) => [`${x.name} matches ${x.list}, reinstated on ${x.reinstated_on}.`, 'Keep the reinstatement record with the file; no action if the dates line up.'],
76
+ never_screened: (x) => [`${x.name} has no screening date.`, 'Screen before their next shift or payment, then record the date.'],
77
+ screening_overdue: (x) => [`${x.name} was last screened ${x.days_since} days ago.`, 'Screen this month; most payers and states expect monthly checks.'],
78
+ };
79
+ for (const it of items) { const [m, f] = T[it.status](it); it.message = m; it.fix = f; }
80
+ sortByStatus(items, ORDER);
81
+ const flagged = new Set(items.filter((i) => ORDER[i.status] <= 2).map((i) => i.line));
82
+ return { people: people.length, list_entries: entries.length, needs_action: flagged.size, near_names_other_birth_date: nearOtherDob, by_status: countBy(items, 'status'), items };
83
+ }
@@ -0,0 +1,90 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { medAgent, fileArg, AS_OF_ARG, STAFF_ID, STAFF_NAME, NPI, PRACTICE_LIMITS, today } from 'fairpractice-core';
3
+ import { screen, exclusionEntry } from './logic.js';
4
+
5
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
6
+ const t = (aliases, extra = {}) => ({ aliases, ...extra });
7
+
8
+ export const PEOPLE_FIELDS = Object.freeze({
9
+ id: STAFF_ID,
10
+ name: { ...STAFF_NAME, aliases: [...STAFF_NAME.aliases, 'Vendor', 'Vendor Name', 'Payee', 'Contractor', 'Legal Name'], required: true },
11
+ type: t(['Type', 'Person Type', 'Category', 'Relationship', 'Worker Type', 'Payee Type']),
12
+ dob: t(['DOB', 'Date of Birth', 'Birth Date', 'Birthdate'], { type: 'date', phi: 'dob' }),
13
+ npi: NPI,
14
+ last_screened: t(['Last Screened', 'Last Check', 'Screened On', 'Last Screening Date', 'Last Verified', 'Exclusion Check Date'], { type: 'date' }),
15
+ });
16
+ export const EXCLUSION_FIELDS = Object.freeze({
17
+ last_name: t(['LASTNAME', 'Last Name', 'Last', 'Surname'], { phi: 'name' }),
18
+ first_name: t(['FIRSTNAME', 'First Name', 'First', 'Given Name'], { phi: 'name' }),
19
+ middle_name: t(['MIDNAME', 'Middle Name', 'Middle', 'MI'], { phi: 'name' }),
20
+ name: t(['Full Name', 'Individual Name', 'Provider Name', 'Excluded Name'], { phi: 'name' }),
21
+ business_name: t(['BUSNAME', 'Business Name', 'Entity Name', 'Firm', 'Name']),
22
+ npi: t(['NPI', 'Provider NPI'], { translate: false }),
23
+ dob: t(['DOB', 'Date of Birth', 'Birth Date'], { type: 'date', phi: 'dob' }),
24
+ exclusion_type: t(['EXCLTYPE', 'Exclusion Type', 'Exclusion Authority', 'Sanction Type', 'Classification']),
25
+ excluded_on: t(['EXCLDATE', 'Exclusion Date', 'Active Date', 'Effective Date', 'Sanction Date', 'Date Excluded'], { type: 'date' }),
26
+ reinstated_on: t(['REINDATE', 'Reinstatement Date', 'Reinstated', 'Termination Date', 'End Date'], { type: 'date' }),
27
+ state: t(['STATE', 'State']),
28
+ source: t(['Source', 'List']),
29
+ });
30
+
31
+ const SETTINGS = { type: 'object', additionalProperties: false, properties: {
32
+ near_name_threshold: { type: 'number', minimum: 0.8, maximum: 1, description: 'Name similarity (0.8-1) at which a different spelling is shown as a near-name match; default 0.92' },
33
+ screening_interval_days: { type: 'integer', minimum: 1, maximum: 366, description: 'Days after which a person counts as not screened recently; default 31 (monthly)' },
34
+ } };
35
+
36
+ export const MEMORY_KINDS = Object.freeze({
37
+ cleared_match: {
38
+ description: 'A reviewed name match that is not this person (checked by birth date, NPI or the official site). person_id is the id from the result (a pseudonym is fine); excluded_on is the list entry\'s exclusion date, e.g. {"person_id": "MRN-1a2b3c4d", "excluded_on": "2021-09-09", "note": "different DOB, verified on the OIG site 2026-11-02"}. Leave excluded_on out to clear every name match for that person.',
39
+ effect: 'stops name and near-name matches to that entry from showing again for that person; an NPI match always shows.',
40
+ schema: { type: 'object', additionalProperties: false, required: ['person_id'], properties: { person_id: { type: 'string', minLength: 1, maxLength: 80 }, excluded_on: { type: 'string', format: 'date' }, note: { type: 'string', maxLength: 300 } } },
41
+ },
42
+ });
43
+
44
+ const args = {
45
+ people: fileArg('Everyone you pay or bill under (CSV, Excel, JSON): employees, providers, contractors and vendors with name, type, birth date, NPI and last screening date'),
46
+ exclusions: fileArg('Exclusion list you downloaded under --root, for example the OIG LEIE file (UPDATED.csv) or a SAM exclusions extract'),
47
+ state_list: fileArg('Optional second list, for example your state Medicaid exclusion file'),
48
+ settings: fileArg('Optional settings JSON: near_name_threshold and screening_interval_days'),
49
+ as_of: AS_OF_ARG,
50
+ };
51
+
52
+ const run = (a, ctx) => {
53
+ const s = a.settings ? ctx.readJson(a.settings, 'exclusions_settings') : {};
54
+ const entries = [...ctx.records(a.exclusions, 'exclusions').map((r) => exclusionEntry(r, 'exclusion list')), ...(a.state_list ? ctx.records(a.state_list, 'state_list').map((r) => exclusionEntry(r, 'state list')) : [])];
55
+ const facts = ctx.memoryFacts('cleared_match').map((f) => f.value);
56
+ const cleared = (p, e) => facts.some((v) => ctx.phi.same(String(p.id ?? ''), v.person_id, 'mrn') && (!v.excluded_on || v.excluded_on === e.excluded_on));
57
+ return screen(ctx.records(a.people, 'people'), entries, { asOf: a.as_of || today(), nearThreshold: s.near_name_threshold ?? 0.92, intervalDays: s.screening_interval_days ?? 31, cleared });
58
+ };
59
+ const summary = (o) => `${o.people} people screened against ${o.list_entries} list entries. ${o.needs_action} need action now.${o.near_names_other_birth_date ? ` ${o.near_names_other_birth_date} near name(s) with a different birth date left out.` : ''} ${o.items.length} finding(s): ${Object.entries(o.by_status).map(([k, v]) => `${k} ${v}`).join(', ') || 'none'}.`;
60
+
61
+ export const manifest = medAgent({
62
+ pkg, prefix: 'exclusions', title: 'Fairpractice Exclusion Screening',
63
+ description: 'Screens everyone a practice pays (staff, providers, contractors, vendors) against the exclusion lists you download (OIG LEIE, SAM, state Medicaid): NPI matches, name and birth-date matches, near-name matches to clear, reinstated entries and people not screened recently. Names are masked before results reach the model.',
64
+ args, required: ['people', 'exclusions'],
65
+ sources: { people: { label: 'People you pay', args: ['people'], fields: PEOPLE_FIELDS }, exclusions: { label: 'Exclusion list', args: ['exclusions'], fields: EXCLUSION_FIELDS }, state_list: { label: 'Second exclusion list', args: ['state_list'], fields: EXCLUSION_FIELDS } },
66
+ configSchemas: { exclusions_settings: SETTINGS }, memoryKinds: MEMORY_KINDS,
67
+ run, summary,
68
+ check: { title: 'Screen against exclusion lists', description: 'Match every person and vendor against the exclusion files and list matches to act on, near names to clear and people not screened recently.' },
69
+ report: {
70
+ title: { en: 'Exclusion screening', es: 'Verificación de exclusiones', de: 'Ausschlussprüfung', fr: 'Contrôle des exclusions', pt: 'Verificação de exclusões', it: 'Verifica delle esclusioni', ja: '除外リスト照合', zh: '排除名单筛查', ko: '제외 명단 대조' },
71
+ base: 'exclusions',
72
+ rows: (o) => o.items.map((i) => ({ status: i.status, person_id: i.person_id, name: i.name, type: i.type, list: i.list || '', listed_name: i.listed_name || '', excluded_on: i.excluded_on || '', message: i.message, fix: i.fix })),
73
+ htmlColumns: ['status', 'name', 'type', 'list', 'listed_name', 'excluded_on', 'message', 'fix'],
74
+ sections: (o) => [{ title: { en: 'Findings by type' }, rows: Object.entries(o.by_status).map(([status, count]) => ({ status, count })), columns: ['status', 'count'] }],
75
+ limits: [PRACTICE_LIMITS.files, 'A name match is not proof: confirm with a second identifier on the official list site before acting. The lists are only as current as the files you downloaded.', PRACTICE_LIMITS.advice, PRACTICE_LIMITS.phi],
76
+ },
77
+ refused: [
78
+ { name: 'employment_terminate', category: 'production_deploy', description: 'Fairpractice Exclusion Screening never changes anyone\'s employment or vendor status; HR and compliance decide.' },
79
+ { name: 'self_disclosure_submit', category: 'binding_send', description: 'Fairpractice Exclusion Screening never files an OIG self-disclosure or contacts a payer; counsel does.' },
80
+ ],
81
+ prompt: { title: 'Monthly exclusion screening', description: 'Walks the host model through a monthly exclusion check with Fairpractice Exclusion Screening.', text: `You are helping a compliance officer with fairpractice-exclusion-screening.
82
+
83
+ Rules: Fairpractice Exclusion Screening only reads files. A name match is never proof; names in results are pseudonyms.
84
+
85
+ 1. Call exclusions_check with the people file, the exclusion list(s) and as_of.
86
+ 2. Lead with npi_match and confirmed_match: these go to the compliance officer today.
87
+ 3. For possible_match and near_name, say what second identifier would settle it.
88
+ 4. When the user has verified that an entry is a different person, offer exclusions_learn (kind cleared_match).
89
+ 5. Call exclusions_write_report for the screening file.` },
90
+ });