fairpractice-evv-claims 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 +7 -0
- package/LICENSE +21 -0
- package/README.md +175 -2
- package/bin/fairpractice-evv-claims.js +7 -0
- package/evals/cases.json +249 -0
- package/fixtures/README.md +11 -0
- package/fixtures/accuracy.json +146 -0
- package/fixtures/claims.csv +9 -0
- package/fixtures/evv-visits.csv +8 -0
- package/fixtures/phi-canaries.json +1 -0
- package/fixtures/settings-typo.json +1 -0
- package/fixtures/settings.json +1 -0
- package/package.json +57 -4
- package/server.json +37 -0
- package/src/demo.js +9 -0
- package/src/index.js +2 -0
- package/src/logic.js +52 -0
- package/src/manifest.js +67 -0
package/CHANGELOG.md
ADDED
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,176 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
3
|
+
# Fairpractice EVV Claims (`fairpractice-evv-claims`)
|
|
4
|
+
|
|
5
|
+
Checks Medicaid home care claims against electronic visit verification: claim lines with no EVV visit, units above the verified time, visits billed under a different caregiver, visits verified away from the client's address, and caregivers whose share of hand-entered or edited visits is above your limit. Client and caregiver names are masked before results reach the model.
|
|
6
|
+
|
|
7
|
+
**Fairpractice EVV Claims never submits or changes claims. Fairpractice EVV Claims never edits or creates EVV visits.**
|
|
8
|
+
|
|
9
|
+
Fairpractice ver 1 · Home care · 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-evv-claims demo
|
|
13
|
+
npx -y fairpractice-evv-claims mcp --root ./practice-files
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## What the sample data shows
|
|
17
|
+
|
|
18
|
+
Fictional data only: a made-up home care agency, clients and caregivers. Any likeness to real people is chance.
|
|
19
|
+
|
|
20
|
+
- [`evv-visits.csv`](fixtures/evv-visits.csv) and [`claims.csv`](fixtures/claims.csv) for November 2 to 5, 2026. Planted:
|
|
21
|
+
- Abby Lund: November 3 billed 8 units for a 90-minute verified visit (6 units).
|
|
22
|
+
- Bruno Sato: November 4 billed with no EVV visit.
|
|
23
|
+
- Celia Ward: billed under Omar Feld but verified by Tom Baptiste.
|
|
24
|
+
- Dane Ivers: the visit was verified away from the client's address.
|
|
25
|
+
- Lia Gruber: 2 of 3 visits entered or edited by hand, above the 20% limit.
|
|
26
|
+
- [`settings.json`](fixtures/settings.json): 15-minute units, midpoint rounding, a 20% manual-edit limit. [`settings-typo.json`](fixtures/settings-typo.json) misspells a setting and is refused.
|
|
27
|
+
|
|
28
|
+
## A demo run
|
|
29
|
+
|
|
30
|
+
`npx -y fairpractice-evv-claims demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
Fairpractice EVV Claims demo (fictional practice, patients, staff and payers)
|
|
34
|
+
|
|
35
|
+
▶ Check this week's claims against EVV visits
|
|
36
|
+
status: executed decision: allow
|
|
37
|
+
7 EVV visit(s), 8 claim line(s), 4 client(s); 0 verified visit(s) not billed. 144 at risk. 5 finding(s): no_evv 1, units_over_verified 1, caregiver_mismatch 1, location_mismatch 1, manual_edits_high 1.
|
|
38
|
+
no_evv 36 T1019 on 2026-11-04 (6 units) has no EVV visit.
|
|
39
|
+
units_over_verified 12 T1019 on 2026-11-03: 8 units billed, 90 verified minutes support 6.
|
|
40
|
+
caregiver_mismatch 48 T1019 on 2026-11-02 was billed under PT-65942d90 but verified by PT-d482eec6.
|
|
41
|
+
location_mismatch 48 The visit on 2026-11-05 was verified away from the client's address.
|
|
42
|
+
manual_edits_high 0 PT-d592d13a: 2 of 3 visits (66.67%) were entered or edited by hand, above your 20% limit.
|
|
43
|
+
|
|
44
|
+
▶ Write the pre-billing list
|
|
45
|
+
status: executed decision: allow
|
|
46
|
+
EVV and claims check written: 7 EVV visit(s), 8 claim line(s), 4 client(s); 0 verified visit(s) not billed. 144 at risk. 5 finding(s): no_evv 1, units_over_verified 1, caregiver_mismatch 1, location_mismatch 1, manual_edits_high 1. Files: fairpractice-out/evv/evv.csv, fairpractice-out/evv/evv.html.
|
|
47
|
+
|
|
48
|
+
▶ Agent tries to edit an EVV visit
|
|
49
|
+
status: blocked decision: block
|
|
50
|
+
reason: Fairpractice EVV Claims never edits or creates EVV visits.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Tools
|
|
54
|
+
|
|
55
|
+
| Tool | What it does | Policy |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `evv_check` | List claim lines with no visit, units over verified time, caregiver and location mismatches, and caregivers with many manual edits. | runs |
|
|
58
|
+
| `evv_write_report` | Write evv.csv (one row per item, with blank owner and decision columns) and evv.html into out_dir (default fairpractice-out/evv). | runs |
|
|
59
|
+
| `evv_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
|
|
60
|
+
| `evv_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
|
|
61
|
+
| `evv_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
|
|
62
|
+
| `evv_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
|
|
63
|
+
| `claim_submit` | Fairpractice EVV Claims never submits or changes claims. | refused |
|
|
64
|
+
| `evv_visit_edit` | Fairpractice EVV Claims never edits or creates EVV visits. | refused |
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
### `evv_check` arguments
|
|
69
|
+
|
|
70
|
+
| Argument | What it is |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `visits` (required) | EVV visit export under --root: client, caregiver, date, clock in and out (or minutes), service, location verified or distance, manual edit |
|
|
73
|
+
| `claims` (required) | Claim lines: client, date of service, service code, units, caregiver, amount |
|
|
74
|
+
| `settings` | Optional settings JSON: unit_minutes, rounding, max_distance, max_manual_pct, min_visits |
|
|
75
|
+
| `status` | Only items with this status |
|
|
76
|
+
| `limit` | Most items to return to the model (the report file always has all of them) |
|
|
77
|
+
|
|
78
|
+
## Columns it reads
|
|
79
|
+
|
|
80
|
+
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.
|
|
81
|
+
|
|
82
|
+
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-evv-claims inspect <file>` (column names and shapes only, never values) and name any column it misses in `remedy-sources.json`.
|
|
83
|
+
|
|
84
|
+
### EVV visits (`visits`)
|
|
85
|
+
|
|
86
|
+
| Column | Type | Read from |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| `client_id` | text (masked) | Client ID, Client #, Member ID, Medicaid ID, Recipient ID, Participant ID, Patient ID |
|
|
89
|
+
| `client_name` | text (masked) | Client, Client Name, Member, Member Name, Recipient, Participant, Patient Name |
|
|
90
|
+
| `caregiver_id` | text (masked) | Caregiver ID, Worker ID, Aide ID, Employee ID, Staff ID, Attendant ID |
|
|
91
|
+
| `caregiver_name` | text (masked) | Caregiver, Caregiver Name, Worker, Aide, Employee, Attendant, Staff Name |
|
|
92
|
+
| `date` (required) | date | Date of Service, DOS, Service Date, Visit Date, Date, From DOS, Session Date, Appointment Date |
|
|
93
|
+
| `clock_in` | text | Clock In, Check In, Time In, Start, Visit Start |
|
|
94
|
+
| `clock_out` | text | Clock Out, Check Out, Time Out, End, Visit End |
|
|
95
|
+
| `minutes` | number | Minutes, Min, Mins, Duration, Duration (min), Time (min), Total Minutes, Treatment Minutes |
|
|
96
|
+
| `service` | text | Service, Service Code, Procedure, HCPCS, Code, Billing Code |
|
|
97
|
+
| `location_ok` | text | Location Verified, GPS Match, Location OK, Location Match, Geo Verified |
|
|
98
|
+
| `distance` | number | Distance, Distance from Address, GPS Distance, Miles from Home |
|
|
99
|
+
| `manual` | text | Manual, Manual Edit, Edited, Exception, Visit Edited, Adjusted |
|
|
100
|
+
|
|
101
|
+
### Claims (`claims`)
|
|
102
|
+
|
|
103
|
+
| Column | Type | Read from |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `client_id` | text (masked) | Client ID, Client #, Member ID, Medicaid ID, Recipient ID, Participant ID, Patient ID |
|
|
106
|
+
| `client_name` | text (masked) | Client, Client Name, Member, Member Name, Recipient, Participant, Patient Name |
|
|
107
|
+
| `date` (required) | date | Date of Service, DOS, Service Date, Visit Date, Date, From DOS, Session Date, Appointment Date |
|
|
108
|
+
| `service` | text | Service, Service Code, Procedure, HCPCS, Code, Billing Code |
|
|
109
|
+
| `units` | number | Units, Unit, Qty, Quantity, Days/Units, Service Units |
|
|
110
|
+
| `caregiver_id` | text (masked) | Caregiver ID, Worker ID, Aide ID, Employee ID, Staff ID, Attendant ID |
|
|
111
|
+
| `caregiver_name` | text (masked) | Caregiver, Caregiver Name, Worker, Aide, Employee, Attendant, Staff Name |
|
|
112
|
+
| `amount` | amount | Amount, Amt, Total, Balance, Net Amount, Payment Amount, Paid, Paid Amount |
|
|
113
|
+
|
|
114
|
+
## Settings file (`evv_settings`)
|
|
115
|
+
|
|
116
|
+
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.
|
|
117
|
+
|
|
118
|
+
| Setting | What it does |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `unit_minutes` | Minutes in one billing unit; default 15 |
|
|
121
|
+
| `rounding` | How partial units count under your state rules; default midpoint (8 of 15 minutes) |
|
|
122
|
+
| `max_distance` | Distance from the client's address above which a visit is flagged, in the unit your EVV export uses |
|
|
123
|
+
| `max_manual_pct` | Share of a caregiver's visits entered or edited by hand above which to flag; default 10 |
|
|
124
|
+
| `min_visits` | Visits a caregiver needs before the manual-edit share is judged; default 3 |
|
|
125
|
+
|
|
126
|
+
## Memory
|
|
127
|
+
|
|
128
|
+
`evv_learn` only proposes a fact; nothing changes until a named person accepts it with `evv_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.
|
|
129
|
+
|
|
130
|
+
| Kind | What an accepted fact does |
|
|
131
|
+
|---|---|
|
|
132
|
+
|
|
133
|
+
## Install
|
|
134
|
+
|
|
135
|
+
Node 20 or newer. No other runtime dependencies besides `fairpractice-core` and `fairclaim-core`.
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"fairpractice-evv-claims": {
|
|
141
|
+
"command": "npx",
|
|
142
|
+
"args": [
|
|
143
|
+
"-y",
|
|
144
|
+
"fairpractice-evv-claims",
|
|
145
|
+
"mcp",
|
|
146
|
+
"--root",
|
|
147
|
+
"/path/to/practice-files"
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Claude Code: `claude mcp add fairpractice-evv-claims -- npx -y fairpractice-evv-claims mcp --root .`, or use the plugin files in this folder.
|
|
155
|
+
|
|
156
|
+
## CLI
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
fairpractice-evv-claims tools # every tool, its policy and arguments
|
|
160
|
+
fairpractice-evv-claims sources # the columns each input is read from
|
|
161
|
+
fairpractice-evv-claims inspect <file> # how a file would be read (names and shapes, never values)
|
|
162
|
+
fairpractice-evv-claims call evv_check '{"visits":"<visits>","claims":"<claims>"}'
|
|
163
|
+
fairpractice-evv-claims eval # the private eval cases on the fictional fixtures
|
|
164
|
+
fairpractice-evv-claims demo
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Patient and staff data
|
|
168
|
+
|
|
169
|
+
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.
|
|
170
|
+
|
|
171
|
+
## Limits
|
|
172
|
+
|
|
173
|
+
- 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.
|
|
174
|
+
- 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.
|
|
175
|
+
- 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.
|
|
176
|
+
- 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-evv-claims', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
|
package/evals/cases.json
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "fairpractice-evv-claims",
|
|
3
|
+
"root": "..",
|
|
4
|
+
"data_note": "Fictional data in ../fixtures. Deterministic checks; no model is called.",
|
|
5
|
+
"cases": [
|
|
6
|
+
{
|
|
7
|
+
"id": "totals",
|
|
8
|
+
"tool": "evv_check",
|
|
9
|
+
"args": {
|
|
10
|
+
"visits": "fixtures/evv-visits.csv",
|
|
11
|
+
"claims": "fixtures/claims.csv",
|
|
12
|
+
"settings": "fixtures/settings.json"
|
|
13
|
+
},
|
|
14
|
+
"expect": {
|
|
15
|
+
"status": "executed",
|
|
16
|
+
"equals": {
|
|
17
|
+
"result.visits": 7,
|
|
18
|
+
"result.claim_lines": 8,
|
|
19
|
+
"result.clients": 4,
|
|
20
|
+
"result.unbilled_visits": 0,
|
|
21
|
+
"result.dollars_at_risk": 144
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "every-planted-status-in-order",
|
|
27
|
+
"tool": "evv_check",
|
|
28
|
+
"args": {
|
|
29
|
+
"visits": "fixtures/evv-visits.csv",
|
|
30
|
+
"claims": "fixtures/claims.csv",
|
|
31
|
+
"settings": "fixtures/settings.json"
|
|
32
|
+
},
|
|
33
|
+
"expect": {
|
|
34
|
+
"equals": {
|
|
35
|
+
"result.items.0.status": "no_evv",
|
|
36
|
+
"result.items.1.status": "units_over_verified",
|
|
37
|
+
"result.items.2.status": "caregiver_mismatch",
|
|
38
|
+
"result.items.3.status": "location_mismatch",
|
|
39
|
+
"result.items.4.status": "manual_edits_high"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "status-filter",
|
|
45
|
+
"tool": "evv_check",
|
|
46
|
+
"args": {
|
|
47
|
+
"visits": "fixtures/evv-visits.csv",
|
|
48
|
+
"claims": "fixtures/claims.csv",
|
|
49
|
+
"settings": "fixtures/settings.json",
|
|
50
|
+
"status": "no_evv"
|
|
51
|
+
},
|
|
52
|
+
"expect": {
|
|
53
|
+
"status": "executed",
|
|
54
|
+
"equals": {
|
|
55
|
+
"result.items.0.status": "no_evv"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "limit-one",
|
|
61
|
+
"tool": "evv_check",
|
|
62
|
+
"args": {
|
|
63
|
+
"visits": "fixtures/evv-visits.csv",
|
|
64
|
+
"claims": "fixtures/claims.csv",
|
|
65
|
+
"settings": "fixtures/settings.json",
|
|
66
|
+
"limit": 1
|
|
67
|
+
},
|
|
68
|
+
"expect": {
|
|
69
|
+
"status": "executed",
|
|
70
|
+
"length": {
|
|
71
|
+
"result.items": 1
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "report",
|
|
77
|
+
"tool": "evv_write_report",
|
|
78
|
+
"args": {
|
|
79
|
+
"visits": "fixtures/evv-visits.csv",
|
|
80
|
+
"claims": "fixtures/claims.csv",
|
|
81
|
+
"settings": "fixtures/settings.json"
|
|
82
|
+
},
|
|
83
|
+
"expect": {
|
|
84
|
+
"status": "executed",
|
|
85
|
+
"matches": [
|
|
86
|
+
"\\.csv",
|
|
87
|
+
"\\.html"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "report-spanish",
|
|
93
|
+
"tool": "evv_write_report",
|
|
94
|
+
"args": {
|
|
95
|
+
"visits": "fixtures/evv-visits.csv",
|
|
96
|
+
"claims": "fixtures/claims.csv",
|
|
97
|
+
"settings": "fixtures/settings.json",
|
|
98
|
+
"language": "es"
|
|
99
|
+
},
|
|
100
|
+
"expect": {
|
|
101
|
+
"status": "executed"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "typo-setting-refused",
|
|
106
|
+
"tool": "evv_check",
|
|
107
|
+
"args": {
|
|
108
|
+
"visits": "fixtures/evv-visits.csv",
|
|
109
|
+
"claims": "fixtures/claims.csv",
|
|
110
|
+
"settings": "fixtures/settings-typo.json"
|
|
111
|
+
},
|
|
112
|
+
"expect": {
|
|
113
|
+
"status": "error"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"id": "missing-file",
|
|
118
|
+
"tool": "evv_check",
|
|
119
|
+
"args": {
|
|
120
|
+
"visits": "fixtures/does-not-exist.csv",
|
|
121
|
+
"claims": "fixtures/claims.csv",
|
|
122
|
+
"settings": "fixtures/settings.json"
|
|
123
|
+
},
|
|
124
|
+
"expect": {
|
|
125
|
+
"status": "error"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "refuses-claim_submit",
|
|
130
|
+
"tool": "claim_submit",
|
|
131
|
+
"args": {},
|
|
132
|
+
"expect": {
|
|
133
|
+
"status": "blocked"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"id": "refuses-evv_visit_edit",
|
|
138
|
+
"tool": "evv_visit_edit",
|
|
139
|
+
"args": {},
|
|
140
|
+
"expect": {
|
|
141
|
+
"status": "blocked"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "recall-empty-memory",
|
|
146
|
+
"tool": "evv_recall",
|
|
147
|
+
"args": {},
|
|
148
|
+
"expect": {
|
|
149
|
+
"status": "executed",
|
|
150
|
+
"contains": [
|
|
151
|
+
"memory is empty"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "over-units",
|
|
157
|
+
"tool": "evv_check",
|
|
158
|
+
"args": {
|
|
159
|
+
"visits": "fixtures/evv-visits.csv",
|
|
160
|
+
"claims": "fixtures/claims.csv",
|
|
161
|
+
"settings": "fixtures/settings.json",
|
|
162
|
+
"status": "units_over_verified"
|
|
163
|
+
},
|
|
164
|
+
"expect": {
|
|
165
|
+
"equals": {
|
|
166
|
+
"result.items.0.verified_minutes": 90,
|
|
167
|
+
"result.items.0.verified_units": 6,
|
|
168
|
+
"result.items.0.amount": 12
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": "manual-share",
|
|
174
|
+
"tool": "evv_check",
|
|
175
|
+
"args": {
|
|
176
|
+
"visits": "fixtures/evv-visits.csv",
|
|
177
|
+
"claims": "fixtures/claims.csv",
|
|
178
|
+
"settings": "fixtures/settings.json",
|
|
179
|
+
"status": "manual_edits_high"
|
|
180
|
+
},
|
|
181
|
+
"expect": {
|
|
182
|
+
"equals": {
|
|
183
|
+
"result.items.0.manual": 2,
|
|
184
|
+
"result.items.0.visits": 3,
|
|
185
|
+
"result.items.0.pct": 66.67
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "default-limit-same",
|
|
191
|
+
"tool": "evv_check",
|
|
192
|
+
"args": {
|
|
193
|
+
"visits": "fixtures/evv-visits.csv",
|
|
194
|
+
"claims": "fixtures/claims.csv"
|
|
195
|
+
},
|
|
196
|
+
"expect": {
|
|
197
|
+
"equals": {
|
|
198
|
+
"result.by_status.manual_edits_high": 1
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "caregivers-masked",
|
|
204
|
+
"tool": "evv_check",
|
|
205
|
+
"args": {
|
|
206
|
+
"visits": "fixtures/evv-visits.csv",
|
|
207
|
+
"claims": "fixtures/claims.csv",
|
|
208
|
+
"settings": "fixtures/settings.json"
|
|
209
|
+
},
|
|
210
|
+
"expect": {
|
|
211
|
+
"not_contains": [
|
|
212
|
+
"Omar Feld",
|
|
213
|
+
"Tom Baptiste"
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"id": "file-outside-root-refused",
|
|
219
|
+
"tool": "evv_check",
|
|
220
|
+
"args": {
|
|
221
|
+
"visits": "../../outside-root.csv",
|
|
222
|
+
"claims": "fixtures/claims.csv",
|
|
223
|
+
"settings": "fixtures/settings.json"
|
|
224
|
+
},
|
|
225
|
+
"expect": {
|
|
226
|
+
"status": "error",
|
|
227
|
+
"contains": [
|
|
228
|
+
"outside the allowed root"
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"id": "missing-file-named",
|
|
234
|
+
"tool": "evv_check",
|
|
235
|
+
"args": {
|
|
236
|
+
"visits": "fixtures/missing-export.csv",
|
|
237
|
+
"claims": "fixtures/claims.csv",
|
|
238
|
+
"settings": "fixtures/settings.json"
|
|
239
|
+
},
|
|
240
|
+
"expect": {
|
|
241
|
+
"status": "error",
|
|
242
|
+
"contains": [
|
|
243
|
+
"not found",
|
|
244
|
+
"missing-export.csv"
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Fixtures
|
|
2
|
+
|
|
3
|
+
Fictional data only: a made-up home care agency, clients and caregivers. Any likeness to real people is chance.
|
|
4
|
+
|
|
5
|
+
- `evv-visits.csv` and `claims.csv` for November 2 to 5, 2026. Planted:
|
|
6
|
+
- Abby Lund: November 3 billed 8 units for a 90-minute verified visit (6 units).
|
|
7
|
+
- Bruno Sato: November 4 billed with no EVV visit.
|
|
8
|
+
- Celia Ward: billed under Omar Feld but verified by Tom Baptiste.
|
|
9
|
+
- Dane Ivers: the visit was verified away from the client's address.
|
|
10
|
+
- Lia Gruber: 2 of 3 visits entered or edited by hand, above the 20% limit.
|
|
11
|
+
- `settings.json`: 15-minute units, midpoint rounding, a 20% manual-edit limit. `settings-typo.json` misspells a setting and is refused.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
{
|
|
2
|
+
"case": "totals",
|
|
3
|
+
"id": [
|
|
4
|
+
["client_id", "date"],
|
|
5
|
+
[
|
|
6
|
+
"caregiver"
|
|
7
|
+
]
|
|
8
|
+
],
|
|
9
|
+
"planted": [
|
|
10
|
+
["V2/2026-11-04", "no_evv"],
|
|
11
|
+
["V1/2026-11-03", "units_over_verified"],
|
|
12
|
+
["V3/2026-11-02", "caregiver_mismatch"],
|
|
13
|
+
["V4/2026-11-05", "location_mismatch"],
|
|
14
|
+
["Lia Gruber", "manual_edits_high"]
|
|
15
|
+
],
|
|
16
|
+
"clean": [
|
|
17
|
+
{
|
|
18
|
+
"arg": "visits",
|
|
19
|
+
"set": [
|
|
20
|
+
{
|
|
21
|
+
"where": ["Client ID", "V4"],
|
|
22
|
+
"column": "Location Verified",
|
|
23
|
+
"value": "Yes"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"where": [
|
|
27
|
+
["Client ID", "V5"],
|
|
28
|
+
["Date", "2026-11-02"]
|
|
29
|
+
],
|
|
30
|
+
"column": "Manual Edit",
|
|
31
|
+
"value": "No"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"where": [
|
|
35
|
+
["Client ID", "V5"],
|
|
36
|
+
["Date", "2026-11-04"]
|
|
37
|
+
],
|
|
38
|
+
"column": "Manual Edit",
|
|
39
|
+
"value": "No"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"add": [
|
|
43
|
+
{
|
|
44
|
+
"Client ID": "V2",
|
|
45
|
+
"Client Name": "Bruno Sato",
|
|
46
|
+
"Caregiver ID": "K1",
|
|
47
|
+
"Caregiver": "Rosa Delgado",
|
|
48
|
+
"Date": "2026-11-04",
|
|
49
|
+
"Clock In": "13:00",
|
|
50
|
+
"Clock Out": "14:30",
|
|
51
|
+
"Service": "T1019",
|
|
52
|
+
"Location Verified": "Yes",
|
|
53
|
+
"Manual Edit": "No"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"arg": "claims",
|
|
59
|
+
"set": [
|
|
60
|
+
{
|
|
61
|
+
"where": [
|
|
62
|
+
["Client ID", "V1"],
|
|
63
|
+
["Date of Service", "2026-11-03"]
|
|
64
|
+
],
|
|
65
|
+
"column": "Units",
|
|
66
|
+
"value": "6"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"where": ["Client ID", "V3"],
|
|
70
|
+
"column": "Caregiver",
|
|
71
|
+
"value": "Tom Baptiste"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"where": ["Client ID", "V3"],
|
|
75
|
+
"column": "Caregiver ID",
|
|
76
|
+
"value": "K2"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"mutations": [
|
|
82
|
+
{
|
|
83
|
+
"name": "one unit more than verified",
|
|
84
|
+
"edits": [
|
|
85
|
+
{
|
|
86
|
+
"arg": "claims",
|
|
87
|
+
"set": [
|
|
88
|
+
{
|
|
89
|
+
"where": [
|
|
90
|
+
["Client ID", "V5"],
|
|
91
|
+
["Date of Service", "2026-11-03"]
|
|
92
|
+
],
|
|
93
|
+
"column": "Units",
|
|
94
|
+
"value": "9"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"expect": [
|
|
100
|
+
["V5/2026-11-03", "units_over_verified"]
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "one of three visits edited by hand",
|
|
105
|
+
"edits": [
|
|
106
|
+
{
|
|
107
|
+
"arg": "visits",
|
|
108
|
+
"set": [
|
|
109
|
+
{
|
|
110
|
+
"where": [
|
|
111
|
+
["Client ID", "V1"],
|
|
112
|
+
["Date", "2026-11-02"]
|
|
113
|
+
],
|
|
114
|
+
"column": "Manual Edit",
|
|
115
|
+
"value": "Yes"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"expect": [
|
|
121
|
+
["Rosa Delgado", "manual_edits_high"]
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "location not verified",
|
|
126
|
+
"edits": [
|
|
127
|
+
{
|
|
128
|
+
"arg": "visits",
|
|
129
|
+
"set": [
|
|
130
|
+
{
|
|
131
|
+
"where": [
|
|
132
|
+
["Client ID", "V5"],
|
|
133
|
+
["Date", "2026-11-04"]
|
|
134
|
+
],
|
|
135
|
+
"column": "Location Verified",
|
|
136
|
+
"value": "No"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"expect": [
|
|
142
|
+
["V5/2026-11-04", "location_mismatch"]
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Client ID,Client Name,Date of Service,Service Code,Units,Caregiver ID,Caregiver,Amount
|
|
2
|
+
V1,Abby Lund,2026-11-02,T1019,8,K1,Rosa Delgado,48
|
|
3
|
+
V1,Abby Lund,2026-11-03,T1019,8,K1,Rosa Delgado,48
|
|
4
|
+
V2,Bruno Sato,2026-11-04,T1019,6,K1,Rosa Delgado,36
|
|
5
|
+
V3,Celia Ward,2026-11-02,T1019,8,K3,Omar Feld,48
|
|
6
|
+
V4,Dane Ivers,2026-11-05,T1019,8,K2,Tom Baptiste,48
|
|
7
|
+
V5,Etta Moss,2026-11-02,T1019,8,K4,Lia Gruber,48
|
|
8
|
+
V5,Etta Moss,2026-11-03,T1019,8,K4,Lia Gruber,48
|
|
9
|
+
V5,Etta Moss,2026-11-04,T1019,8,K4,Lia Gruber,48
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Client ID,Client Name,Caregiver ID,Caregiver,Date,Clock In,Clock Out,Service,Location Verified,Manual Edit
|
|
2
|
+
V1,Abby Lund,K1,Rosa Delgado,2026-11-02,09:00,11:00,T1019,Yes,No
|
|
3
|
+
V1,Abby Lund,K1,Rosa Delgado,2026-11-03,09:00,10:30,T1019,Yes,No
|
|
4
|
+
V3,Celia Ward,K2,Tom Baptiste,2026-11-02,13:00,15:00,T1019,Yes,No
|
|
5
|
+
V4,Dane Ivers,K2,Tom Baptiste,2026-11-05,08:00,10:00,T1019,No,No
|
|
6
|
+
V5,Etta Moss,K4,Lia Gruber,2026-11-02,10:00,12:00,T1019,Yes,Yes
|
|
7
|
+
V5,Etta Moss,K4,Lia Gruber,2026-11-03,10:00,12:00,T1019,Yes,No
|
|
8
|
+
V5,Etta Moss,K4,Lia Gruber,2026-11-04,10:00,12:00,T1019,Yes,Yes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "note": "Fictional client and caregiver names used in these fixtures. None may reach a model result when masking is on.", "values": ["Abby Lund", "Bruno Sato", "Celia Ward", "Dane Ivers", "Etta Moss", "Rosa Delgado", "Lia Gruber", "Omar Feld"] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "max_manual_percent": 20 }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "unit_minutes": 15, "rounding": "midpoint", "max_manual_pct": 20, "min_visits": 3 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fairpractice-evv-claims",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.fpavia111-creator/fairpractice-evv-claims",
|
|
5
|
+
"description": "Electronic visit verification against Medicaid claims: claim lines with no matching EVV visit, units billed above the verified time, visits verified at the wrong place or by another caregiver, and manual edits above your limit.",
|
|
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-evv-claims": "bin/fairpractice-evv-claims.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-evv-claims.js demo",
|
|
33
|
+
"eval": "node bin/fairpractice-evv-claims.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-evv-claims"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/fpavia111-creator/fairpractice-agents/tree/master/packages/fairpractice-evv-claims#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
|
+
"evv",
|
|
55
|
+
"home-care",
|
|
56
|
+
"medicaid",
|
|
57
|
+
"personal-care"
|
|
58
|
+
]
|
|
59
|
+
}
|
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-evv-claims",
|
|
4
|
+
"title": "Fairpractice EVV Claims",
|
|
5
|
+
"description": "Electronic visit verification against Medicaid claims",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/fpavia111-creator/fairpractice-agents",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "packages/fairpractice-evv-claims"
|
|
11
|
+
},
|
|
12
|
+
"websiteUrl": "https://fair-agents.com/fairpractice.html",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "fairpractice-evv-claims",
|
|
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
|
+
const f = { visits: 'evv-visits.csv', claims: 'claims.csv', settings: 'settings.json' };
|
|
5
|
+
export const demo = () => runDemo(manifest, new URL('../fixtures', import.meta.url), 'Fairpractice EVV Claims', [
|
|
6
|
+
{ label: 'Check this week\'s claims against EVV visits', tool: 'evv_check', args: f, list: (i) => `${i.status.padEnd(20)} ${String(i.amount).padStart(6)} ${i.message}` },
|
|
7
|
+
{ label: 'Write the pre-billing list', tool: 'evv_write_report', args: f },
|
|
8
|
+
{ label: 'Agent tries to edit an EVV visit', tool: 'evv_visit_edit', args: {} },
|
|
9
|
+
]);
|
package/src/index.js
ADDED
package/src/logic.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Fairpractice EVV Claims logic: electronic visit verification (EVV) against Medicaid home care claims. No I/O.
|
|
2
|
+
import { str, num, isoDate, round2, sortByStatus, countBy, codeKey, spanMinutes, yes, personKey, idKey } from 'fairpractice-core';
|
|
3
|
+
|
|
4
|
+
const ORDER = { no_evv: 0, units_over_verified: 1, caregiver_mismatch: 2, location_mismatch: 3, manual_edits_high: 4 };
|
|
5
|
+
/** Units for verified minutes: 'down' (whole units only), 'midpoint' (a unit counts from half of it) or 'up'. */
|
|
6
|
+
export function unitsFor(minutes, unit = 15, rounding = 'midpoint') {
|
|
7
|
+
if (minutes === null || minutes === undefined) return null;
|
|
8
|
+
if (rounding === 'down') return Math.floor(minutes / unit);
|
|
9
|
+
if (rounding === 'up') return Math.ceil(minutes / unit);
|
|
10
|
+
return Math.floor(minutes / unit) + (minutes % unit >= Math.ceil(unit / 2) ? 1 : 0);
|
|
11
|
+
}
|
|
12
|
+
const isNo = (v) => /^(n|no|false|0|fail|failed|mismatch|outside|exception)$/i.test(str(v));
|
|
13
|
+
const cgKey = (id, name) => idKey(id) || personKey(name);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* visits: [{ client_id, client_name, caregiver_id, caregiver_name, date, clock_in, clock_out, minutes, service, location_ok, distance, manual }]
|
|
17
|
+
* claims: [{ client_id, client_name, date, service, units, caregiver_id, caregiver_name, amount }]
|
|
18
|
+
* opts: { unitMinutes = 15, rounding = 'midpoint', maxDistance = null, maxManualPct = 10, minVisits = 3 }
|
|
19
|
+
*/
|
|
20
|
+
export function checkEvv(visits, claims, { unitMinutes = 15, rounding = 'midpoint', maxDistance = null, maxManualPct = 10, minVisits = 3 } = {}) {
|
|
21
|
+
const items = []; const names = new Map(); const cgNames = new Map();
|
|
22
|
+
for (const r of [...visits, ...claims]) { const id = str(r.client_id); if (id && r.client_name) names.set(id, str(r.client_name)); const ck = cgKey(r.caregiver_id, r.caregiver_name); if (ck && r.caregiver_name) cgNames.set(ck, str(r.caregiver_name)); }
|
|
23
|
+
const V = visits.map((v, i) => ({ i, cid: str(v.client_id) || str(v.client_name), date: isoDate(v.date), service: codeKey(v.service), cg: cgKey(v.caregiver_id, v.caregiver_name), cgName: str(v.caregiver_name) || str(v.caregiver_id), minutes: num(v.minutes) ?? spanMinutes(v.clock_in, v.clock_out), locBad: isNo(v.location_ok) || (maxDistance !== null && num(v.distance) !== null && num(v.distance) > maxDistance), distance: num(v.distance), manual: yes(v.manual) || /manual|edit|adjust/i.test(str(v.manual)), used: false })).filter((v) => v.cid && v.date);
|
|
24
|
+
const b = (cid, date) => ({ client_id: cid, client_name: names.get(cid) || null, date });
|
|
25
|
+
for (const [i, c] of claims.entries()) {
|
|
26
|
+
const cid = str(c.client_id) || str(c.client_name); const date = isoDate(c.date); const service = codeKey(c.service); if (!cid || !date) continue;
|
|
27
|
+
const units = num(c.units) ?? 0; const amount = num(c.amount) ?? 0; const perUnit = units ? amount / units : 0;
|
|
28
|
+
const match = V.filter((v) => v.cid === cid && v.date === date && (!v.service || !service || v.service === service));
|
|
29
|
+
const base = { ...b(cid, date), service: service || null, units, line: i + 1 };
|
|
30
|
+
if (!match.length) { items.push({ ...base, status: 'no_evv', amount }); continue; }
|
|
31
|
+
match.forEach((v) => { v.used = true; });
|
|
32
|
+
const mins = match.reduce((s, v) => s + (v.minutes || 0), 0); const ok = unitsFor(mins, unitMinutes, rounding);
|
|
33
|
+
if (units > ok) items.push({ ...base, status: 'units_over_verified', verified_minutes: mins, verified_units: ok, over_units: units - ok, amount: round2((units - ok) * perUnit) });
|
|
34
|
+
const ck = cgKey(c.caregiver_id, c.caregiver_name);
|
|
35
|
+
if (ck && !match.some((v) => v.cg === ck)) items.push({ ...base, status: 'caregiver_mismatch', billed_caregiver: str(c.caregiver_name) || str(c.caregiver_id), verified_caregiver: match.map((v) => v.cgName).join(', '), amount });
|
|
36
|
+
const bad = match.filter((v) => v.locBad);
|
|
37
|
+
if (bad.length) items.push({ ...base, status: 'location_mismatch', distance: bad[0].distance, amount });
|
|
38
|
+
}
|
|
39
|
+
// Manual edits per caregiver.
|
|
40
|
+
const per = new Map(); for (const v of V) { if (!v.cg) continue; const x = per.get(v.cg) || { visits: 0, manual: 0 }; x.visits++; if (v.manual) x.manual++; per.set(v.cg, x); }
|
|
41
|
+
for (const [cg, x] of per) { const pct = round2((x.manual / x.visits) * 100); if (x.visits >= minVisits && pct > maxManualPct) items.push({ client_id: null, client_name: null, date: null, caregiver: cgNames.get(cg) || cg, status: 'manual_edits_high', visits: x.visits, manual: x.manual, pct, limit: maxManualPct, amount: 0 }); }
|
|
42
|
+
const T = {
|
|
43
|
+
no_evv: (x) => [`${x.service || 'Service'} on ${x.date} (${x.units} units) has no EVV visit.`, 'Hold the claim; find the visit or record it through your state\'s exception process before billing.'],
|
|
44
|
+
units_over_verified: (x) => [`${x.service || 'Service'} on ${x.date}: ${x.units} units billed, ${x.verified_minutes} verified minutes support ${x.verified_units}.`, `Bill ${x.verified_units} units, or correct the visit through the exception process if the time was really worked.`],
|
|
45
|
+
caregiver_mismatch: (x) => [`${x.service || 'Service'} on ${x.date} was billed under ${x.billed_caregiver} but verified by ${x.verified_caregiver}.`, 'Bill under the caregiver who did the visit.'],
|
|
46
|
+
location_mismatch: (x) => [`The visit on ${x.date} was verified away from the client's address${x.distance !== null && x.distance !== undefined ? ` (${x.distance} away)` : ''}.`, 'Check the reason (community outing, wrong address on file) and record it before billing.'],
|
|
47
|
+
manual_edits_high: (x) => [`${x.caregiver}: ${x.manual} of ${x.visits} visits (${x.pct}%) were entered or edited by hand, above your ${x.limit}% limit.`, 'Check the caregiver\'s phone or app, retrain on clocking in, and review the edits.'],
|
|
48
|
+
};
|
|
49
|
+
for (const it of items) { const [m, f] = T[it.status](it); it.message = m; it.fix = f; }
|
|
50
|
+
sortByStatus(items, ORDER);
|
|
51
|
+
return { visits: visits.length, claim_lines: claims.length, clients: new Set(V.map((v) => v.cid)).size, unbilled_visits: V.filter((v) => !v.used).length, dollars_at_risk: round2(items.reduce((s, x) => s + (x.amount || 0), 0)), by_status: countBy(items, 'status'), items };
|
|
52
|
+
}
|
package/src/manifest.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { medAgent, fileArg, STAFF_ID, STAFF_NAME, UNITS, MINUTES, DOS, AMOUNT, PRACTICE_LIMITS } from 'fairpractice-core';
|
|
3
|
+
import { checkEvv } 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
|
+
const CLIENT_ID = t(['Client ID', 'Client #', 'Member ID', 'Medicaid ID', 'Recipient ID', 'Participant ID', 'Patient ID'], { phi: 'mrn', translate: false });
|
|
8
|
+
const CLIENT_NAME = t(['Client', 'Client Name', 'Member', 'Member Name', 'Recipient', 'Participant', 'Patient Name'], { phi: 'name' });
|
|
9
|
+
const SERVICE = t(['Service', 'Service Code', 'Procedure', 'HCPCS', 'Code', 'Billing Code'], { translate: false });
|
|
10
|
+
const CG_ID = { ...STAFF_ID, aliases: ['Caregiver ID', 'Worker ID', 'Aide ID', 'Employee ID', 'Staff ID', 'Attendant ID'] };
|
|
11
|
+
const CG_NAME = { ...STAFF_NAME, aliases: ['Caregiver', 'Caregiver Name', 'Worker', 'Aide', 'Employee', 'Attendant', 'Staff Name'] };
|
|
12
|
+
|
|
13
|
+
export const VISIT_FIELDS = Object.freeze({
|
|
14
|
+
client_id: CLIENT_ID, client_name: CLIENT_NAME, caregiver_id: CG_ID, caregiver_name: CG_NAME, date: { ...DOS, required: true },
|
|
15
|
+
clock_in: t(['Clock In', 'Check In', 'Time In', 'Start', 'Visit Start']), clock_out: t(['Clock Out', 'Check Out', 'Time Out', 'End', 'Visit End']),
|
|
16
|
+
minutes: MINUTES, service: SERVICE,
|
|
17
|
+
location_ok: t(['Location Verified', 'GPS Match', 'Location OK', 'Location Match', 'Geo Verified']),
|
|
18
|
+
distance: t(['Distance', 'Distance from Address', 'GPS Distance', 'Miles from Home'], { type: 'number' }),
|
|
19
|
+
manual: t(['Manual', 'Manual Edit', 'Edited', 'Exception', 'Visit Edited', 'Adjusted']),
|
|
20
|
+
});
|
|
21
|
+
export const CLAIM_FIELDS = Object.freeze({ client_id: CLIENT_ID, client_name: CLIENT_NAME, date: { ...DOS, required: true }, service: SERVICE, units: UNITS, caregiver_id: CG_ID, caregiver_name: CG_NAME, amount: AMOUNT });
|
|
22
|
+
|
|
23
|
+
const SETTINGS = { type: 'object', additionalProperties: false, properties: {
|
|
24
|
+
unit_minutes: { type: 'integer', minimum: 1, maximum: 60, description: 'Minutes in one billing unit; default 15' },
|
|
25
|
+
rounding: { type: 'string', enum: ['down', 'midpoint', 'up'], description: 'How partial units count under your state rules; default midpoint (8 of 15 minutes)' },
|
|
26
|
+
max_distance: { type: 'number', minimum: 0, description: 'Distance from the client\'s address above which a visit is flagged, in the unit your EVV export uses' },
|
|
27
|
+
max_manual_pct: { type: 'number', minimum: 0, maximum: 100, description: 'Share of a caregiver\'s visits entered or edited by hand above which to flag; default 10' },
|
|
28
|
+
min_visits: { type: 'integer', minimum: 1, maximum: 100, description: 'Visits a caregiver needs before the manual-edit share is judged; default 3' },
|
|
29
|
+
} };
|
|
30
|
+
const args = {
|
|
31
|
+
visits: fileArg('EVV visit export under --root: client, caregiver, date, clock in and out (or minutes), service, location verified or distance, manual edit'),
|
|
32
|
+
claims: fileArg('Claim lines: client, date of service, service code, units, caregiver, amount'),
|
|
33
|
+
settings: fileArg('Optional settings JSON: unit_minutes, rounding, max_distance, max_manual_pct, min_visits'),
|
|
34
|
+
};
|
|
35
|
+
const run = (a, ctx) => { const s = a.settings ? ctx.readJson(a.settings, 'evv_settings') : {}; return checkEvv(ctx.records(a.visits, 'visits'), ctx.records(a.claims, 'claims'), { unitMinutes: s.unit_minutes ?? 15, rounding: s.rounding || 'midpoint', maxDistance: s.max_distance ?? null, maxManualPct: s.max_manual_pct ?? 10, minVisits: s.min_visits ?? 3 }); };
|
|
36
|
+
const summary = (o) => `${o.visits} EVV visit(s), ${o.claim_lines} claim line(s), ${o.clients} client(s); ${o.unbilled_visits} verified visit(s) not billed. ${o.dollars_at_risk} at risk. ${o.items.length} finding(s): ${Object.entries(o.by_status).map(([k, v]) => `${k} ${v}`).join(', ') || 'none'}.`;
|
|
37
|
+
|
|
38
|
+
export const manifest = medAgent({
|
|
39
|
+
pkg, prefix: 'evv', title: 'Fairpractice EVV Claims',
|
|
40
|
+
description: 'Checks Medicaid home care claims against electronic visit verification: claim lines with no EVV visit, units above the verified time, visits billed under a different caregiver, visits verified away from the client\'s address, and caregivers whose share of hand-entered or edited visits is above your limit. Client and caregiver names are masked before results reach the model.',
|
|
41
|
+
args, required: ['visits', 'claims'],
|
|
42
|
+
sources: { visits: { label: 'EVV visits', args: ['visits'], fields: VISIT_FIELDS }, claims: { label: 'Claims', args: ['claims'], fields: CLAIM_FIELDS } },
|
|
43
|
+
configSchemas: { evv_settings: SETTINGS }, memoryKinds: {},
|
|
44
|
+
run, summary,
|
|
45
|
+
check: { title: 'Check claims against EVV', description: 'List claim lines with no visit, units over verified time, caregiver and location mismatches, and caregivers with many manual edits.' },
|
|
46
|
+
report: {
|
|
47
|
+
title: { en: 'EVV and claims check', es: 'Revisión de EVV y reclamaciones', de: 'EVV- und Abrechnungsprüfung', fr: 'Contrôle EVV et facturation', pt: 'Revisão de EVV e cobranças', it: 'Verifica EVV e fatturazione', ja: 'EVV と請求のチェック', zh: 'EVV 与理赔核对', ko: 'EVV 및 청구 점검' },
|
|
48
|
+
base: 'evv',
|
|
49
|
+
rows: (o) => o.items.map((i) => ({ status: i.status, client_id: i.client_id || '', client_name: i.client_name || '', caregiver: i.caregiver || i.billed_caregiver || '', date: i.date || '', service: i.service || '', units: i.units ?? '', amount: i.amount, message: i.message, fix: i.fix })),
|
|
50
|
+
htmlColumns: ['status', 'client_name', 'caregiver', 'date', 'service', 'units', 'amount', 'message', 'fix'],
|
|
51
|
+
sections: (o) => [{ title: { en: 'Findings by type' }, rows: Object.entries(o.by_status).map(([status, count]) => ({ status, count })), columns: ['status', 'count'] }],
|
|
52
|
+
limits: [PRACTICE_LIMITS.files, 'Each state runs EVV its own way (aggregator, rounding, exception codes); set unit_minutes and rounding to your state\'s rules.', PRACTICE_LIMITS.advice, PRACTICE_LIMITS.phi],
|
|
53
|
+
},
|
|
54
|
+
refused: [
|
|
55
|
+
{ name: 'claim_submit', category: 'binding_send', description: 'Fairpractice EVV Claims never submits or changes claims.' },
|
|
56
|
+
{ name: 'evv_visit_edit', category: 'binding_send', description: 'Fairpractice EVV Claims never edits or creates EVV visits.' },
|
|
57
|
+
],
|
|
58
|
+
prompt: { title: 'EVV pre-billing review', description: 'Walks the host model through an EVV check before Medicaid billing with Fairpractice EVV Claims.', text: `You are helping a home care agency's billing lead with fairpractice-evv-claims before claims go out.
|
|
59
|
+
|
|
60
|
+
Rules: Fairpractice EVV Claims only reads files. It never edits EVV visits or submits claims. Client and caregiver names in results are pseudonyms.
|
|
61
|
+
|
|
62
|
+
1. Call evv_check with visits, claims and settings.
|
|
63
|
+
2. Lead with no_evv and units_over_verified: these deny or get recouped.
|
|
64
|
+
3. Then caregiver and location mismatches to fix before billing.
|
|
65
|
+
4. Then caregivers with many manual edits, for the scheduler or supervisor.
|
|
66
|
+
5. Call evv_write_report for the billing lead.` },
|
|
67
|
+
});
|