fairpractice-payer-audits 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 +5 -0
- package/LICENSE +21 -0
- package/README.md +160 -2
- package/bin/fairpractice-payer-audits.js +7 -0
- package/evals/cases.json +287 -0
- package/fixtures/README.md +6 -0
- package/fixtures/accuracy.json +91 -0
- package/fixtures/audit-log.csv +9 -0
- package/fixtures/phi-canaries.json +1 -0
- package/fixtures/settings-typo.json +1 -0
- package/fixtures/settings.json +1 -0
- package/package.json +58 -4
- package/server.json +37 -0
- package/src/demo.js +9 -0
- package/src/index.js +2 -0
- package/src/logic.js +49 -0
- package/src/manifest.js +69 -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,161 @@
|
|
|
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 Payer Audits (`fairpractice-payer-audits`)
|
|
4
|
+
|
|
5
|
+
Tracks payer and auditor record requests (ADR, RAC, UPIC, TPE and commercial audits): responses overdue or due soon, records sent late, unfavorable results with the appeal window closing or missed, and money taken back while an appeal filed in time was open. Patient names are masked before results reach the model.
|
|
6
|
+
|
|
7
|
+
**Fairpractice Payer Audits never sends records to a payer or auditor. Fairpractice Payer Audits never files an appeal.**
|
|
8
|
+
|
|
9
|
+
Fairpractice wave 2 ver 1 · Payers and prior authorization · 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-payer-audits demo
|
|
13
|
+
npx -y fairpractice-payer-audits mcp --root ./practice-files
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## What the sample data shows
|
|
17
|
+
|
|
18
|
+
Fictional data only: Cedar Ridge Medical Group, made-up patients and claims. Checked on 15 November 2026.
|
|
19
|
+
|
|
20
|
+
- [`audit-log.csv`](fixtures/audit-log.csv): eight requests. Planted: ADR AU-501 was due 4 November and has not been sent; RAC AU-502 is due 19 November; UPIC AU-503 was due 1 October and sent 5 October; ADR AU-504 lost on 10 August and its 120-day appeal window ends 8 December; RAC AU-505 lost on 1 June with no appeal (window ended 29 September); ADR AU-506 was appealed 15 days after the result but 975.00 was taken back on 20 October anyway. AU-507 (commercial, with its own due date) and AU-508 (TPE, sent, no result yet) are clean.
|
|
21
|
+
- [`settings.json`](fixtures/settings.json): the default response days, 120-day appeals, a 30-day warning and a 30-day recoupment hold. These are examples; letters can set other dates. [`settings-typo.json`](fixtures/settings-typo.json) misspells a setting and is refused.
|
|
22
|
+
|
|
23
|
+
## A demo run
|
|
24
|
+
|
|
25
|
+
`npx -y fairpractice-payer-audits demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Fairpractice Payer Audits demo (fictional practice, patients, staff and payers)
|
|
29
|
+
|
|
30
|
+
▶ Check the record request and audit log
|
|
31
|
+
status: executed decision: allow
|
|
32
|
+
8 request(s), 2 not answered yet (2270 at risk on overdue or due-soon requests). 6 finding(s): response_overdue 1, response_due_soon 1, appeal_window_closing 1, appeal_missed 1, recouped_during_appeal 1, sent_late 1.
|
|
33
|
+
response_overdue ADR request AU-501 (Medicare Part B, claim C-31001) was due 2026-11-04 and has not been sent (11 day(s) late).
|
|
34
|
+
response_due_soon RAC request AU-502 (Medicare Part B, claim C-31002) is due 2026-11-19 (in 4 day(s)).
|
|
35
|
+
appeal_window_closing ADR request AU-504: unfavorable result on 2026-08-10; the appeal window you set ends 2026-12-08 (in 23 day(s)).
|
|
36
|
+
appeal_missed RAC request AU-505: unfavorable result on 2026-06-01; the appeal window ended 2026-09-29.
|
|
37
|
+
recouped_during_appeal ADR request AU-506: 975 was taken back on 2026-10-20 although an appeal was filed 2026-09-30, within 30 days of the result.
|
|
38
|
+
sent_late UPIC request AU-503 was due 2026-10-01 and sent 2026-10-05 (4 day(s) late).
|
|
39
|
+
|
|
40
|
+
▶ Write the compliance meeting list
|
|
41
|
+
status: executed decision: allow
|
|
42
|
+
Payer record requests and audits written: 8 request(s), 2 not answered yet (2270 at risk on overdue or due-soon requests). 6 finding(s): response_overdue 1, response_due_soon 1, appeal_window_closing 1, appeal_missed 1, recouped_during_appeal 1, sent_late 1. Files: fairpractice-out/payeraudits/payer-audits.csv, fairpractice-out/payeraudits/payer-audits.html.
|
|
43
|
+
|
|
44
|
+
▶ Agent tries to send records itself
|
|
45
|
+
status: blocked decision: block
|
|
46
|
+
reason: Fairpractice Payer Audits never sends records to a payer or auditor.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Tools
|
|
50
|
+
|
|
51
|
+
| Tool | What it does | Policy |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `payeraudits_check` | List record requests overdue or due soon, records sent late, appeal windows closing or missed, and recoupments during a timely appeal. | runs |
|
|
54
|
+
| `payeraudits_write_report` | Write payer-audits.csv (one row per item, with blank owner and decision columns) and payer-audits.html into out_dir (default fairpractice-out/payeraudits). | runs |
|
|
55
|
+
| `payeraudits_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
|
|
56
|
+
| `payeraudits_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
|
|
57
|
+
| `payeraudits_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
|
|
58
|
+
| `payeraudits_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
|
|
59
|
+
| `records_send` | Fairpractice Payer Audits never sends records to a payer or auditor. | refused |
|
|
60
|
+
| `appeal_submit` | Fairpractice Payer Audits never files an appeal. | refused |
|
|
61
|
+
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
### `payeraudits_check` arguments
|
|
65
|
+
|
|
66
|
+
| Argument | What it is |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `requests` (required) | Record request and audit log under --root: request, auditor or type, payer, claim, patient, received and due dates, sent date, result and its date, amount at risk, amount recouped and date, appeal date |
|
|
69
|
+
| `settings` | Optional settings JSON: due_days, appeal_days, warn_days, recoup_hold_days |
|
|
70
|
+
| `as_of` | Date to measure deadlines and ages from (YYYY-MM-DD); default today |
|
|
71
|
+
| `status` | Only items with this status |
|
|
72
|
+
| `limit` | Most items to return to the model (the report file always has all of them) |
|
|
73
|
+
|
|
74
|
+
## Columns it reads
|
|
75
|
+
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
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-payer-audits inspect <file>` (column names and shapes only, never values) and name any column it misses in `remedy-sources.json`.
|
|
79
|
+
|
|
80
|
+
### Record request and audit log (`requests`)
|
|
81
|
+
|
|
82
|
+
| Column | Type | Read from |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `request_id` | text | Request ID, Request #, Letter #, Case #, Reference, ADR # |
|
|
85
|
+
| `auditor` | text | Auditor, Audit Type, Request Type, Type, Program |
|
|
86
|
+
| `payer` | text | Payer, Payer Name, Primary Payer, Insurance, Insurance Name, Plan, Plan Name, Payor |
|
|
87
|
+
| `claim_id` | text | Claim, Claim ID, Claim #, Claim Number, Encounter, Encounter ID, Visit ID, Invoice |
|
|
88
|
+
| `patient_id` | text (masked) | Patient ID, Patient #, Patient Number, MRN, Medical Record Number, Chart #, Chart Number, Account # |
|
|
89
|
+
| `patient_name` | text (masked) | Patient, Patient Name, Name, Client, Client Name, Member, Member Name, Beneficiary |
|
|
90
|
+
| `received` (required) | date | Received, Date Received, Letter Date, Request Date |
|
|
91
|
+
| `due` | date | Due, Due Date, Response Due, Records Due |
|
|
92
|
+
| `sent` | date | Sent, Date Sent, Submitted, Records Sent, Response Sent |
|
|
93
|
+
| `result` | text | Result, Outcome, Finding, Determination |
|
|
94
|
+
| `result_date` | date | Result Date, Outcome Date, Determination Date, Decision Date |
|
|
95
|
+
| `amount_at_risk` | amount | Amount at Risk, Claim Amount, Amount, Paid Amount, Overpayment |
|
|
96
|
+
| `recouped` | amount | Recouped, Amount Recouped, Offset, Taken Back |
|
|
97
|
+
| `recouped_on` | date | Recouped On, Recoupment Date, Offset Date |
|
|
98
|
+
| `appeal_filed` | date | Appeal Filed, Appeal Date, Redetermination Filed |
|
|
99
|
+
|
|
100
|
+
## Settings file (`payeraudits_settings`)
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
| Setting | What it does |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `due_days` | Days to respond by request type when the log has no due date (ADR, RAC, UPIC, TPE, SMRC, CERT, commercial); defaults ADR 45, RAC 45, UPIC 30, TPE 45, SMRC 45, CERT 75, commercial 30 |
|
|
107
|
+
| `appeal_days` | Days after an unfavorable result to appeal (Medicare redetermination: 120); default 120 |
|
|
108
|
+
| `warn_days` | Days ahead to warn about due dates and appeal deadlines; default 10 |
|
|
109
|
+
| `recoup_hold_days` | An appeal filed within this many days of the result should stop recoupment (Medicare: 30); default 30 |
|
|
110
|
+
|
|
111
|
+
## Memory
|
|
112
|
+
|
|
113
|
+
`payeraudits_learn` only proposes a fact; nothing changes until a named person accepts it with `payeraudits_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.
|
|
114
|
+
|
|
115
|
+
| Kind | What an accepted fact does |
|
|
116
|
+
|---|---|
|
|
117
|
+
|
|
118
|
+
## Install
|
|
119
|
+
|
|
120
|
+
Node 20 or newer. No other runtime dependencies besides `fairpractice-core` and `fairclaim-core`.
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"fairpractice-payer-audits": {
|
|
126
|
+
"command": "npx",
|
|
127
|
+
"args": [
|
|
128
|
+
"-y",
|
|
129
|
+
"fairpractice-payer-audits",
|
|
130
|
+
"mcp",
|
|
131
|
+
"--root",
|
|
132
|
+
"/path/to/practice-files"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Claude Code: `claude mcp add fairpractice-payer-audits -- npx -y fairpractice-payer-audits mcp --root .`, or use the plugin files in this folder.
|
|
140
|
+
|
|
141
|
+
## CLI
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
fairpractice-payer-audits tools # every tool, its policy and arguments
|
|
145
|
+
fairpractice-payer-audits sources # the columns each input is read from
|
|
146
|
+
fairpractice-payer-audits inspect <file> # how a file would be read (names and shapes, never values)
|
|
147
|
+
fairpractice-payer-audits call payeraudits_check '{"requests":"<requests>"}'
|
|
148
|
+
fairpractice-payer-audits eval # the private eval cases on the fictional fixtures
|
|
149
|
+
fairpractice-payer-audits demo
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Patient and staff data
|
|
153
|
+
|
|
154
|
+
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.
|
|
155
|
+
|
|
156
|
+
## Limits
|
|
157
|
+
|
|
158
|
+
- 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.
|
|
159
|
+
- 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.
|
|
160
|
+
- 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.
|
|
161
|
+
- 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-payer-audits', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
|
package/evals/cases.json
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "fairpractice-payer-audits",
|
|
3
|
+
"root": "..",
|
|
4
|
+
"data_note": "Fictional data in ../fixtures. Deterministic checks; no model is called.",
|
|
5
|
+
"cases": [
|
|
6
|
+
{
|
|
7
|
+
"id": "recall-empty-memory",
|
|
8
|
+
"tool": "payeraudits_recall",
|
|
9
|
+
"args": {},
|
|
10
|
+
"expect": {
|
|
11
|
+
"status": "executed",
|
|
12
|
+
"contains": [
|
|
13
|
+
"memory is empty"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "refuses-records_send",
|
|
19
|
+
"tool": "records_send",
|
|
20
|
+
"args": {},
|
|
21
|
+
"expect": {
|
|
22
|
+
"status": "blocked"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "refuses-appeal_submit",
|
|
27
|
+
"tool": "appeal_submit",
|
|
28
|
+
"args": {},
|
|
29
|
+
"expect": {
|
|
30
|
+
"status": "blocked"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "report",
|
|
35
|
+
"tool": "payeraudits_write_report",
|
|
36
|
+
"args": {
|
|
37
|
+
"requests": "fixtures/audit-log.csv",
|
|
38
|
+
"settings": "fixtures/settings.json",
|
|
39
|
+
"as_of": "2026-11-15"
|
|
40
|
+
},
|
|
41
|
+
"expect": {
|
|
42
|
+
"status": "executed",
|
|
43
|
+
"matches": [
|
|
44
|
+
"\\.csv",
|
|
45
|
+
"\\.html"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "totals",
|
|
51
|
+
"tool": "payeraudits_check",
|
|
52
|
+
"args": {
|
|
53
|
+
"requests": "fixtures/audit-log.csv",
|
|
54
|
+
"settings": "fixtures/settings.json",
|
|
55
|
+
"as_of": "2026-11-15"
|
|
56
|
+
},
|
|
57
|
+
"expect": {
|
|
58
|
+
"status": "executed",
|
|
59
|
+
"equals": {
|
|
60
|
+
"result.requests": 8,
|
|
61
|
+
"result.open": 2,
|
|
62
|
+
"result.at_risk_open": 2270,
|
|
63
|
+
"result.by_auditor.ADR": 3
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "every-planted-status-in-order",
|
|
69
|
+
"tool": "payeraudits_check",
|
|
70
|
+
"args": {
|
|
71
|
+
"requests": "fixtures/audit-log.csv",
|
|
72
|
+
"settings": "fixtures/settings.json",
|
|
73
|
+
"as_of": "2026-11-15"
|
|
74
|
+
},
|
|
75
|
+
"expect": {
|
|
76
|
+
"equals": {
|
|
77
|
+
"result.items.0.status": "response_overdue",
|
|
78
|
+
"result.items.1.status": "response_due_soon",
|
|
79
|
+
"result.items.2.status": "appeal_window_closing",
|
|
80
|
+
"result.items.3.status": "appeal_missed",
|
|
81
|
+
"result.items.4.status": "recouped_during_appeal",
|
|
82
|
+
"result.items.5.status": "sent_late"
|
|
83
|
+
},
|
|
84
|
+
"length": {
|
|
85
|
+
"result.items": 6
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "status-filter",
|
|
91
|
+
"tool": "payeraudits_check",
|
|
92
|
+
"args": {
|
|
93
|
+
"requests": "fixtures/audit-log.csv",
|
|
94
|
+
"settings": "fixtures/settings.json",
|
|
95
|
+
"as_of": "2026-11-15",
|
|
96
|
+
"status": "response_overdue"
|
|
97
|
+
},
|
|
98
|
+
"expect": {
|
|
99
|
+
"status": "executed",
|
|
100
|
+
"equals": {
|
|
101
|
+
"result.items.0.status": "response_overdue"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "limit-one",
|
|
107
|
+
"tool": "payeraudits_check",
|
|
108
|
+
"args": {
|
|
109
|
+
"requests": "fixtures/audit-log.csv",
|
|
110
|
+
"settings": "fixtures/settings.json",
|
|
111
|
+
"as_of": "2026-11-15",
|
|
112
|
+
"limit": 1
|
|
113
|
+
},
|
|
114
|
+
"expect": {
|
|
115
|
+
"status": "executed",
|
|
116
|
+
"length": {
|
|
117
|
+
"result.items": 1
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "report-spanish",
|
|
123
|
+
"tool": "payeraudits_write_report",
|
|
124
|
+
"args": {
|
|
125
|
+
"requests": "fixtures/audit-log.csv",
|
|
126
|
+
"settings": "fixtures/settings.json",
|
|
127
|
+
"as_of": "2026-11-15",
|
|
128
|
+
"language": "es"
|
|
129
|
+
},
|
|
130
|
+
"expect": {
|
|
131
|
+
"status": "executed"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "report-japanese",
|
|
136
|
+
"tool": "payeraudits_write_report",
|
|
137
|
+
"args": {
|
|
138
|
+
"requests": "fixtures/audit-log.csv",
|
|
139
|
+
"settings": "fixtures/settings.json",
|
|
140
|
+
"as_of": "2026-11-15",
|
|
141
|
+
"language": "ja"
|
|
142
|
+
},
|
|
143
|
+
"expect": {
|
|
144
|
+
"status": "executed",
|
|
145
|
+
"matches": [
|
|
146
|
+
"\\.html"
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "typo-setting-refused",
|
|
152
|
+
"tool": "payeraudits_check",
|
|
153
|
+
"args": {
|
|
154
|
+
"requests": "fixtures/audit-log.csv",
|
|
155
|
+
"settings": "fixtures/settings-typo.json",
|
|
156
|
+
"as_of": "2026-11-15"
|
|
157
|
+
},
|
|
158
|
+
"expect": {
|
|
159
|
+
"status": "error"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"id": "null-settings-refused",
|
|
164
|
+
"tool": "payeraudits_check",
|
|
165
|
+
"args": {
|
|
166
|
+
"requests": "fixtures/audit-log.csv",
|
|
167
|
+
"settings": null,
|
|
168
|
+
"as_of": "2026-11-15"
|
|
169
|
+
},
|
|
170
|
+
"expect": {
|
|
171
|
+
"status": "error"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"id": "file-outside-root-refused",
|
|
176
|
+
"tool": "payeraudits_check",
|
|
177
|
+
"args": {
|
|
178
|
+
"requests": "../../outside-root.csv",
|
|
179
|
+
"settings": "fixtures/settings.json",
|
|
180
|
+
"as_of": "2026-11-15"
|
|
181
|
+
},
|
|
182
|
+
"expect": {
|
|
183
|
+
"status": "error",
|
|
184
|
+
"contains": [
|
|
185
|
+
"outside the allowed root"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "missing-file-named",
|
|
191
|
+
"tool": "payeraudits_check",
|
|
192
|
+
"args": {
|
|
193
|
+
"requests": "fixtures/missing-export.csv",
|
|
194
|
+
"settings": "fixtures/settings.json",
|
|
195
|
+
"as_of": "2026-11-15"
|
|
196
|
+
},
|
|
197
|
+
"expect": {
|
|
198
|
+
"status": "error",
|
|
199
|
+
"contains": [
|
|
200
|
+
"not found",
|
|
201
|
+
"missing-export.csv"
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "no-settings-defaults",
|
|
207
|
+
"tool": "payeraudits_check",
|
|
208
|
+
"args": {
|
|
209
|
+
"requests": "fixtures/audit-log.csv",
|
|
210
|
+
"as_of": "2026-11-15"
|
|
211
|
+
},
|
|
212
|
+
"expect": {
|
|
213
|
+
"status": "executed",
|
|
214
|
+
"not_contains": [
|
|
215
|
+
"\"appeal_window_closing\""
|
|
216
|
+
],
|
|
217
|
+
"equals": {
|
|
218
|
+
"result.by_status.response_overdue": 1
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"id": "due-date-from-type",
|
|
224
|
+
"tool": "payeraudits_check",
|
|
225
|
+
"args": {
|
|
226
|
+
"requests": "fixtures/audit-log.csv",
|
|
227
|
+
"settings": "fixtures/settings.json",
|
|
228
|
+
"as_of": "2026-11-15",
|
|
229
|
+
"status": "response_overdue"
|
|
230
|
+
},
|
|
231
|
+
"expect": {
|
|
232
|
+
"equals": {
|
|
233
|
+
"result.items.0.request_id": "AU-501",
|
|
234
|
+
"result.items.0.due": "2026-11-04",
|
|
235
|
+
"result.items.0.days": 11
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"id": "appeal-deadline",
|
|
241
|
+
"tool": "payeraudits_check",
|
|
242
|
+
"args": {
|
|
243
|
+
"requests": "fixtures/audit-log.csv",
|
|
244
|
+
"settings": "fixtures/settings.json",
|
|
245
|
+
"as_of": "2026-11-15",
|
|
246
|
+
"status": "appeal_window_closing"
|
|
247
|
+
},
|
|
248
|
+
"expect": {
|
|
249
|
+
"equals": {
|
|
250
|
+
"result.items.0.appeal_by": "2026-12-08",
|
|
251
|
+
"result.items.0.days": 23
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"id": "recoupment-amount",
|
|
257
|
+
"tool": "payeraudits_check",
|
|
258
|
+
"args": {
|
|
259
|
+
"requests": "fixtures/audit-log.csv",
|
|
260
|
+
"settings": "fixtures/settings.json",
|
|
261
|
+
"as_of": "2026-11-15",
|
|
262
|
+
"status": "recouped_during_appeal"
|
|
263
|
+
},
|
|
264
|
+
"expect": {
|
|
265
|
+
"equals": {
|
|
266
|
+
"result.items.0.request_id": "AU-506",
|
|
267
|
+
"result.items.0.amount": 975
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"id": "clean-requests-not-listed",
|
|
273
|
+
"tool": "payeraudits_check",
|
|
274
|
+
"args": {
|
|
275
|
+
"requests": "fixtures/audit-log.csv",
|
|
276
|
+
"settings": "fixtures/settings.json",
|
|
277
|
+
"as_of": "2026-11-15"
|
|
278
|
+
},
|
|
279
|
+
"expect": {
|
|
280
|
+
"not_contains": [
|
|
281
|
+
"AU-507",
|
|
282
|
+
"AU-508"
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Fixtures
|
|
2
|
+
|
|
3
|
+
Fictional data only: Cedar Ridge Medical Group, made-up patients and claims. Checked on 15 November 2026.
|
|
4
|
+
|
|
5
|
+
- `audit-log.csv`: eight requests. Planted: ADR AU-501 was due 4 November and has not been sent; RAC AU-502 is due 19 November; UPIC AU-503 was due 1 October and sent 5 October; ADR AU-504 lost on 10 August and its 120-day appeal window ends 8 December; RAC AU-505 lost on 1 June with no appeal (window ended 29 September); ADR AU-506 was appealed 15 days after the result but 975.00 was taken back on 20 October anyway. AU-507 (commercial, with its own due date) and AU-508 (TPE, sent, no result yet) are clean.
|
|
6
|
+
- `settings.json`: the default response days, 120-day appeals, a 30-day warning and a 30-day recoupment hold. These are examples; letters can set other dates. `settings-typo.json` misspells a setting and is refused.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"case": "totals",
|
|
3
|
+
"id": [
|
|
4
|
+
[
|
|
5
|
+
"claim_id"
|
|
6
|
+
]
|
|
7
|
+
],
|
|
8
|
+
"planted": [
|
|
9
|
+
["C-31001", "response_overdue"],
|
|
10
|
+
["C-31002", "response_due_soon"],
|
|
11
|
+
["C-31004", "appeal_window_closing"],
|
|
12
|
+
["C-31005", "appeal_missed"],
|
|
13
|
+
["C-31006", "recouped_during_appeal"],
|
|
14
|
+
["C-31003", "sent_late"]
|
|
15
|
+
],
|
|
16
|
+
"clean": [
|
|
17
|
+
{
|
|
18
|
+
"arg": "requests",
|
|
19
|
+
"drop": [
|
|
20
|
+
["Request #", "AU-505"]
|
|
21
|
+
],
|
|
22
|
+
"set": [
|
|
23
|
+
{
|
|
24
|
+
"where": ["Request #", "AU-501"],
|
|
25
|
+
"column": "Date Sent",
|
|
26
|
+
"value": "2026-10-15"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"where": ["Request #", "AU-502"],
|
|
30
|
+
"column": "Date Sent",
|
|
31
|
+
"value": "2026-10-30"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"where": ["Request #", "AU-503"],
|
|
35
|
+
"column": "Date Sent",
|
|
36
|
+
"value": "2026-09-25"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"where": ["Request #", "AU-504"],
|
|
40
|
+
"column": "Appeal Filed",
|
|
41
|
+
"value": "2026-08-30"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"where": ["Request #", "AU-506"],
|
|
45
|
+
"column": "Amount Recouped",
|
|
46
|
+
"value": ""
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"where": ["Request #", "AU-506"],
|
|
50
|
+
"column": "Recoupment Date",
|
|
51
|
+
"value": ""
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"mutations": [
|
|
57
|
+
{
|
|
58
|
+
"name": "commercial audit answered two days late",
|
|
59
|
+
"edits": [
|
|
60
|
+
{
|
|
61
|
+
"arg": "requests",
|
|
62
|
+
"set": [
|
|
63
|
+
{
|
|
64
|
+
"where": ["Request #", "AU-507"],
|
|
65
|
+
"column": "Date Sent",
|
|
66
|
+
"value": "2026-10-12"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"expect": [
|
|
72
|
+
["C-31007", "sent_late"]
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "a 20-day answer window for ADRs",
|
|
77
|
+
"edits": [
|
|
78
|
+
{
|
|
79
|
+
"arg": "settings",
|
|
80
|
+
"json": {
|
|
81
|
+
"due_days.ADR": 20
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"expect": [
|
|
86
|
+
["C-31001", "sent_late"],
|
|
87
|
+
["C-31006", "sent_late"]
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Request #,Audit Type,Payer,Claim #,Patient #,Patient Name,Date Received,Due Date,Date Sent,Outcome,Outcome Date,Amount at Risk,Amount Recouped,Recoupment Date,Appeal Filed
|
|
2
|
+
AU-501,ADR,Medicare Part B,C-31001,P1201,Arlo Benson,2026-09-20,,,,,420.00,,,
|
|
3
|
+
AU-502,RAC,Medicare Part B,C-31002,P1202,Beatrix Lane,2026-10-05,,,,,1850.00,,,
|
|
4
|
+
AU-503,UPIC,Medicare Part B,C-31003,P1203,Caspar Doyle,2026-09-01,,2026-10-05,Favorable,2026-10-30,310.00,,,
|
|
5
|
+
AU-504,ADR,Medicare Part B,C-31004,P1204,Delia Frost,2026-06-01,,2026-06-20,Unfavorable,2026-08-10,560.00,,,
|
|
6
|
+
AU-505,RAC,Medicare Part B,C-31005,P1205,Emil Haas,2026-03-01,,2026-03-30,Denied,2026-06-01,2300.00,2300.00,2026-07-15,
|
|
7
|
+
AU-506,ADR,Medicare Part B,C-31006,P1206,Freya Isles,2026-07-01,,2026-07-25,Unfavorable,2026-09-15,975.00,975.00,2026-10-20,2026-09-30
|
|
8
|
+
AU-507,Commercial audit,Goldfield Health,C-31007,P1207,Gideon Juarez,2026-09-10,2026-10-10,2026-10-01,Favorable,2026-10-25,640.00,,,
|
|
9
|
+
AU-508,TPE,Medicare Part B,C-31008,P1208,Hana Kovac,2026-10-01,,2026-10-20,,,280.00,,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "note": "Fictional patient names and ids used in these fixtures. None may reach a model result when masking is on.", "values": ["Arlo Benson", "Beatrix Lane", "Freya Isles", "Emil Haas", "P1201"] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "appeal_window": 120 }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "due_days": { "ADR": 45, "RAC": 45, "UPIC": 30, "TPE": 45, "commercial": 30 }, "appeal_days": 120, "warn_days": 30, "recoup_hold_days": 30 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fairpractice-payer-audits",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.fpavia111-creator/fairpractice-payer-audits",
|
|
5
|
+
"description": "Payer and auditor record requests (ADR, RAC, UPIC, TPE and commercial audits): responses overdue or due soon, records sent late, adverse results with the appeal window closing or missed, and money taken back while a timely appeal was pending.",
|
|
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-payer-audits": "bin/fairpractice-payer-audits.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-payer-audits.js demo",
|
|
33
|
+
"eval": "node bin/fairpractice-payer-audits.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/fairpractice2-agents.git",
|
|
41
|
+
"directory": "packages/fairpractice-payer-audits"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/fpavia111-creator/fairpractice2-agents/tree/master/packages/fairpractice-payer-audits#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/fpavia111-creator/fairpractice2-agents/issues"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"mcp",
|
|
49
|
+
"mcp-server",
|
|
50
|
+
"healthcare",
|
|
51
|
+
"medical-billing",
|
|
52
|
+
"revenue-cycle",
|
|
53
|
+
"healthcare-compliance",
|
|
54
|
+
"medical-records-requests",
|
|
55
|
+
"adr",
|
|
56
|
+
"rac",
|
|
57
|
+
"audits",
|
|
58
|
+
"appeals"
|
|
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-payer-audits",
|
|
4
|
+
"title": "Fairpractice Payer Audits",
|
|
5
|
+
"description": "Payer and auditor record requests (ADR, RAC, UPIC, TPE and commercial audits)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/fpavia111-creator/fairpractice2-agents",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "packages/fairpractice-payer-audits"
|
|
11
|
+
},
|
|
12
|
+
"websiteUrl": "https://fair-agents.com/fairpractice.html",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "fairpractice-payer-audits",
|
|
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 = { requests: 'audit-log.csv', settings: 'settings.json', as_of: '2026-11-15' };
|
|
5
|
+
export const demo = () => runDemo(manifest, new URL('../fixtures', import.meta.url), 'Fairpractice Payer Audits', [
|
|
6
|
+
{ label: 'Check the record request and audit log', tool: 'payeraudits_check', args: f, list: (i) => `${i.status.padEnd(24)} ${i.message}` },
|
|
7
|
+
{ label: 'Write the compliance meeting list', tool: 'payeraudits_write_report', args: f },
|
|
8
|
+
{ label: 'Agent tries to send records itself', tool: 'records_send', args: {} },
|
|
9
|
+
]);
|
package/src/index.js
ADDED
package/src/logic.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Payer and auditor record requests: response clocks, appeal windows and recoupments during an appeal. No I/O.
|
|
2
|
+
import { str, num, isoDate, addDays, daysBetween, round2, lookupRule, sortByStatus, countBy } from 'fairpractice-core';
|
|
3
|
+
|
|
4
|
+
const ORDER = { response_overdue: 0, response_due_soon: 1, appeal_window_closing: 2, appeal_missed: 3, recouped_during_appeal: 4, sent_late: 5 };
|
|
5
|
+
export const DEFAULT_DUE_DAYS = Object.freeze({ ADR: 45, RAC: 45, UPIC: 30, TPE: 45, SMRC: 45, CERT: 75, commercial: 30 });
|
|
6
|
+
const adverse = (v) => /unfav|denied|adverse|partial|overpay|recoup|disallow/i.test(str(v));
|
|
7
|
+
const kindOf = (v) => { const s = str(v).toUpperCase(); for (const k of ['ADR', 'RAC', 'UPIC', 'TPE', 'SMRC', 'CERT']) if (s.includes(k)) return k; return s ? 'commercial' : 'commercial'; };
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* requests: [{ request_id, auditor, payer, claim_id, patient_id, patient_name, received, due, sent, result, result_date, amount_at_risk, recouped, recouped_on, appeal_filed }]
|
|
11
|
+
* opts: { asOf, dueDays = DEFAULT_DUE_DAYS, appealDays = 120, warnDays = 10, recoupHoldDays = 30 }
|
|
12
|
+
*/
|
|
13
|
+
export function checkAudits(requests, { asOf, dueDays = {}, appealDays = 120, warnDays = 10, recoupHoldDays = 30 } = {}) {
|
|
14
|
+
const days = { ...DEFAULT_DUE_DAYS, ...dueDays }; const items = []; let open = 0;
|
|
15
|
+
for (const [i, r] of requests.entries()) {
|
|
16
|
+
const rec = isoDate(r.received); if (!rec) continue;
|
|
17
|
+
const kind = kindOf(r.auditor); const due = isoDate(r.due) || addDays(rec, lookupRule(days, kind) ?? days.commercial);
|
|
18
|
+
const sent = isoDate(r.sent); const res = isoDate(r.result_date); const app = isoDate(r.appeal_filed);
|
|
19
|
+
const base = { request_id: str(r.request_id) || `line ${i + 1}`, auditor: kind, payer: str(r.payer) || null, claim_id: str(r.claim_id) || null, patient_id: str(r.patient_id) || null, patient_name: str(r.patient_name) || null, received: rec, due, amount: round2(num(r.amount_at_risk) || 0) };
|
|
20
|
+
if (!sent) {
|
|
21
|
+
open++;
|
|
22
|
+
if (due < asOf) items.push({ ...base, status: 'response_overdue', days: daysBetween(due, asOf) });
|
|
23
|
+
else if (daysBetween(asOf, due) <= warnDays) items.push({ ...base, status: 'response_due_soon', days: daysBetween(asOf, due) });
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (sent > due) items.push({ ...base, status: 'sent_late', sent, days: daysBetween(due, sent) });
|
|
27
|
+
if (res && adverse(r.result)) {
|
|
28
|
+
const last = addDays(res, appealDays);
|
|
29
|
+
if (!app) {
|
|
30
|
+
const left = daysBetween(asOf, last);
|
|
31
|
+
if (left < 0) items.push({ ...base, status: 'appeal_missed', result_date: res, appeal_by: last, days: -left });
|
|
32
|
+
else if (left <= warnDays) items.push({ ...base, status: 'appeal_window_closing', result_date: res, appeal_by: last, days: left });
|
|
33
|
+
}
|
|
34
|
+
const rq = isoDate(r.recouped_on); const amt = num(r.recouped) || 0;
|
|
35
|
+
if (app && rq && amt > 0 && daysBetween(res, app) <= recoupHoldDays && rq >= app) items.push({ ...base, status: 'recouped_during_appeal', appeal_filed: app, recouped_on: rq, amount: round2(amt) });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const T = {
|
|
39
|
+
response_overdue: (x) => [`${x.auditor} request ${x.request_id} (${x.payer}, claim ${x.claim_id}) was due ${x.due} and has not been sent (${x.days} day(s) late).`, 'Send the records now; an unanswered request is usually denied in full.'],
|
|
40
|
+
response_due_soon: (x) => [`${x.auditor} request ${x.request_id} (${x.payer}, claim ${x.claim_id}) is due ${x.due} (in ${x.days} day(s)).`, 'Gather the records and send them before the due date.'],
|
|
41
|
+
appeal_window_closing: (x) => [`${x.auditor} request ${x.request_id}: unfavorable result on ${x.result_date}; the appeal window you set ends ${x.appeal_by} (in ${x.days} day(s)).`, 'Decide whether to appeal and file before the deadline.'],
|
|
42
|
+
appeal_missed: (x) => [`${x.auditor} request ${x.request_id}: unfavorable result on ${x.result_date}; the appeal window ended ${x.appeal_by}.`, 'Record the outcome; ask whether a late appeal is possible for good cause.'],
|
|
43
|
+
recouped_during_appeal: (x) => [`${x.auditor} request ${x.request_id}: ${x.amount} was taken back on ${x.recouped_on} although an appeal was filed ${x.appeal_filed}, within ${recoupHoldDays} days of the result.`, 'Ask the contractor to stop and return the recoupment while the appeal is open.'],
|
|
44
|
+
sent_late: (x) => [`${x.auditor} request ${x.request_id} was due ${x.due} and sent ${x.sent} (${x.days} day(s) late).`, 'Note the cause; check the result for a denial for no records.'],
|
|
45
|
+
};
|
|
46
|
+
for (const it of items) { const [m, f] = T[it.status](it); it.message = m; it.fix = f; }
|
|
47
|
+
sortByStatus(items, ORDER);
|
|
48
|
+
return { requests: requests.length, open, at_risk_open: round2(items.filter((x) => /^response_/.test(x.status)).reduce((s, x) => s + x.amount, 0)), by_auditor: countBy(requests, (r) => kindOf(r.auditor)), by_status: countBy(items, 'status'), items };
|
|
49
|
+
}
|
package/src/manifest.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { medAgent, fileArg, AS_OF_ARG, PATIENT_ID, PATIENT_NAME, PAYER, CLAIM_ID, PRACTICE_LIMITS, today } from 'fairpractice-core';
|
|
3
|
+
import { checkAudits } 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 REQUEST_FIELDS = Object.freeze({
|
|
9
|
+
request_id: t(['Request ID', 'Request #', 'Letter #', 'Case #', 'Reference', 'ADR #'], { translate: false }),
|
|
10
|
+
auditor: t(['Auditor', 'Audit Type', 'Request Type', 'Type', 'Program'], { translate: false }),
|
|
11
|
+
payer: PAYER, claim_id: CLAIM_ID, patient_id: PATIENT_ID, patient_name: PATIENT_NAME,
|
|
12
|
+
received: t(['Received', 'Date Received', 'Letter Date', 'Request Date'], { type: 'date', translate: 'requested_at', required: true }),
|
|
13
|
+
due: t(['Due', 'Due Date', 'Response Due', 'Records Due'], { type: 'date', translate: 'due_date' }),
|
|
14
|
+
sent: t(['Sent', 'Date Sent', 'Submitted', 'Records Sent', 'Response Sent'], { type: 'date', translate: false }),
|
|
15
|
+
result: t(['Result', 'Outcome', 'Finding', 'Determination'], { translate: false }),
|
|
16
|
+
result_date: t(['Result Date', 'Outcome Date', 'Determination Date', 'Decision Date'], { type: 'date', translate: false }),
|
|
17
|
+
amount_at_risk: t(['Amount at Risk', 'Claim Amount', 'Amount', 'Paid Amount', 'Overpayment'], { type: 'money', translate: 'amount' }),
|
|
18
|
+
recouped: t(['Recouped', 'Amount Recouped', 'Offset', 'Taken Back'], { type: 'money', translate: false }),
|
|
19
|
+
recouped_on: t(['Recouped On', 'Recoupment Date', 'Offset Date'], { type: 'date', translate: false }),
|
|
20
|
+
appeal_filed: t(['Appeal Filed', 'Appeal Date', 'Redetermination Filed'], { type: 'date', translate: false }),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const SETTINGS = { type: 'object', additionalProperties: false, properties: {
|
|
24
|
+
due_days: { type: 'object', additionalProperties: { type: 'integer', minimum: 1, maximum: 365 }, description: 'Days to respond by request type when the log has no due date (ADR, RAC, UPIC, TPE, SMRC, CERT, commercial); defaults ADR 45, RAC 45, UPIC 30, TPE 45, SMRC 45, CERT 75, commercial 30' },
|
|
25
|
+
appeal_days: { type: 'integer', minimum: 1, maximum: 365, description: 'Days after an unfavorable result to appeal (Medicare redetermination: 120); default 120' },
|
|
26
|
+
warn_days: { type: 'integer', minimum: 0, maximum: 60, description: 'Days ahead to warn about due dates and appeal deadlines; default 10' },
|
|
27
|
+
recoup_hold_days: { type: 'integer', minimum: 0, maximum: 120, description: 'An appeal filed within this many days of the result should stop recoupment (Medicare: 30); default 30' },
|
|
28
|
+
} };
|
|
29
|
+
|
|
30
|
+
const args = {
|
|
31
|
+
requests: fileArg('Record request and audit log under --root: request, auditor or type, payer, claim, patient, received and due dates, sent date, result and its date, amount at risk, amount recouped and date, appeal date'),
|
|
32
|
+
settings: fileArg('Optional settings JSON: due_days, appeal_days, warn_days, recoup_hold_days'),
|
|
33
|
+
as_of: AS_OF_ARG,
|
|
34
|
+
};
|
|
35
|
+
const run = (a, ctx) => {
|
|
36
|
+
const s = a.settings ? ctx.readJson(a.settings, 'payeraudits_settings') : {};
|
|
37
|
+
return checkAudits(ctx.records(a.requests, 'requests'), { asOf: a.as_of || today(), dueDays: s.due_days || {}, appealDays: s.appeal_days ?? 120, warnDays: s.warn_days ?? 10, recoupHoldDays: s.recoup_hold_days ?? 30 });
|
|
38
|
+
};
|
|
39
|
+
const summary = (o) => `${o.requests} request(s), ${o.open} not answered yet (${o.at_risk_open} at risk on overdue or due-soon requests). ${Object.values(o.by_status).reduce((s, x) => s + x, 0)} finding(s): ${Object.entries(o.by_status).map(([k, v]) => `${k} ${v}`).join(', ') || 'none'}.`;
|
|
40
|
+
|
|
41
|
+
export const manifest = medAgent({
|
|
42
|
+
pkg, prefix: 'payeraudits', title: 'Fairpractice Payer Audits',
|
|
43
|
+
description: 'Tracks payer and auditor record requests (ADR, RAC, UPIC, TPE and commercial audits): responses overdue or due soon, records sent late, unfavorable results with the appeal window closing or missed, and money taken back while an appeal filed in time was open. Patient names are masked before results reach the model.',
|
|
44
|
+
args, required: ['requests'],
|
|
45
|
+
sources: { requests: { label: 'Record request and audit log', args: ['requests'], fields: REQUEST_FIELDS } },
|
|
46
|
+
configSchemas: { payeraudits_settings: SETTINGS }, memoryKinds: {},
|
|
47
|
+
run, summary,
|
|
48
|
+
check: { title: 'Check record requests and audits', description: 'List record requests overdue or due soon, records sent late, appeal windows closing or missed, and recoupments during a timely appeal.' },
|
|
49
|
+
report: {
|
|
50
|
+
title: { en: 'Payer record requests and audits', es: 'Solicitudes de registros y auditorías de pagadores', de: 'Unterlagenanforderungen und Prüfungen der Kostenträger', fr: 'Demandes de dossiers et audits des payeurs', pt: 'Solicitações de prontuários e auditorias', it: 'Richieste di documentazione e audit dei pagatori', ja: '支払者の記録要求と監査', zh: '付款方病历调阅与审计', ko: '지불자 기록 요청 및 감사' },
|
|
51
|
+
base: 'payer-audits',
|
|
52
|
+
rows: (o) => o.items.map((i) => ({ status: i.status, request_id: i.request_id, auditor: i.auditor, payer: i.payer || '', claim_id: i.claim_id || '', patient_name: i.patient_name || '', due: i.due, amount: i.amount, message: i.message, fix: i.fix })),
|
|
53
|
+
htmlColumns: ['status', 'request_id', 'auditor', 'payer', 'claim_id', 'due', 'amount', 'message', 'fix'],
|
|
54
|
+
sections: (o) => [{ title: { en: 'Requests by auditor' }, rows: Object.entries(o.by_auditor).map(([auditor, count]) => ({ auditor, count })), columns: ['auditor', 'count'] }],
|
|
55
|
+
limits: [PRACTICE_LIMITS.files, 'Response and appeal days come from the letter, the contract or the settings; letters can set other dates, so record the due date when the letter gives one.', PRACTICE_LIMITS.advice, PRACTICE_LIMITS.phi],
|
|
56
|
+
},
|
|
57
|
+
refused: [
|
|
58
|
+
{ name: 'records_send', category: 'binding_send', description: 'Fairpractice Payer Audits never sends records to a payer or auditor.' },
|
|
59
|
+
{ name: 'appeal_submit', category: 'binding_send', description: 'Fairpractice Payer Audits never files an appeal.' },
|
|
60
|
+
],
|
|
61
|
+
prompt: { title: 'Record request and audit review', description: 'Walks the host model through a weekly audit log review.', text: `You are helping a compliance or billing lead with fairpractice-payer-audits.
|
|
62
|
+
|
|
63
|
+
Rules: it only reads the log. Patient names in results are pseudonyms.
|
|
64
|
+
|
|
65
|
+
1. Call payeraudits_check with the log and as_of.
|
|
66
|
+
2. Lead with response_overdue and response_due_soon, with the amount at risk.
|
|
67
|
+
3. Name appeal deadlines and any recoupment taken during a timely appeal.
|
|
68
|
+
4. Call payeraudits_write_report for the compliance meeting.` },
|
|
69
|
+
});
|