fairpractice-prior-auth-lists 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 +6 -0
- package/LICENSE +21 -0
- package/README.md +161 -2
- package/bin/fairpractice-prior-auth-lists.js +7 -0
- package/evals/cases.json +300 -0
- package/fixtures/README.md +7 -0
- package/fixtures/accuracy.json +115 -0
- package/fixtures/auth-lists.csv +6 -0
- package/fixtures/phi-canaries.json +1 -0
- package/fixtures/schedule.csv +10 -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 +41 -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,162 @@
|
|
|
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 Prior Auth Lists (`fairpractice-prior-auth-lists`)
|
|
4
|
+
|
|
5
|
+
Checks each scheduled service against the payer authorization lists you download (single codes, ranges and wildcards, with effective dates): services that need an authorization and have none, urgent ones close to the visit, codes payers added to their lists recently, and payers with no list loaded. Patient names are masked before results reach the model.
|
|
6
|
+
|
|
7
|
+
**Fairpractice Prior Auth Lists never submits an authorization request; your authorization staff do. Fairpractice Prior Auth Lists never logs in to a payer portal.**
|
|
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-prior-auth-lists demo
|
|
13
|
+
npx -y fairpractice-prior-auth-lists 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 made-up payers (Goldfield Health, Copperline Advantage, Arbor Ridge Medicaid). The lists are invented for the sample; no real payer's list is copied.
|
|
19
|
+
|
|
20
|
+
- [`schedule.csv`](fixtures/schedule.csv): nine appointments, checked on Sunday 15 November 2026. Planted: a head CT on 17 November and a knee replacement on 19 November with no authorization (urgent: within five business days), a lumbar MRI on 8 December with none (not urgent yet), and two Arbor Ridge Medicaid visits with no list loaded. A-308 is in the past and skipped; A-303 and A-304 have numbers; A-307 is an office visit no list covers.
|
|
21
|
+
- [`auth-lists.csv`](fixtures/auth-lists.csv): Goldfield Health lists CT head as a range, added the MRI spine range on 1 October (reported as newly added) and dropped 97110 at the end of June; Copperline Advantage lists 27447 and every J9 code.
|
|
22
|
+
- [`settings.json`](fixtures/settings.json): five business days and a 90-day "newly added" window. [`settings-typo.json`](fixtures/settings-typo.json) misspells a setting and is refused.
|
|
23
|
+
|
|
24
|
+
## A demo run
|
|
25
|
+
|
|
26
|
+
`npx -y fairpractice-prior-auth-lists demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
Fairpractice Prior Auth Lists demo (fictional practice, patients, staff and payers)
|
|
30
|
+
|
|
31
|
+
▶ Check the next weeks of appointments against the payer lists
|
|
32
|
+
status: executed decision: allow
|
|
33
|
+
8 upcoming service(s), 5 on a payer authorization list, lists for 2 payer(s). 5 finding(s): auth_missing_urgent 2, auth_missing 1, payer_list_missing 1, newly_added 1.
|
|
34
|
+
auth_missing_urgent Appointment A-301 on 2026-11-17 (Goldfield Health, 70450) needs an authorization and none is recorded; 2 business day(s) left.
|
|
35
|
+
auth_missing_urgent Appointment A-305 on 2026-11-19 (Copperline Advantage, 27447) needs an authorization and none is recorded; 4 business day(s) left.
|
|
36
|
+
auth_missing Appointment A-302 on 2026-12-08 (Goldfield Health, 72148) is on the payer's authorization list (72141-72158) and has no authorization number.
|
|
37
|
+
payer_list_missing No authorization list is loaded for Arbor Ridge Medicaid; 2 upcoming appointment(s) could not be checked.
|
|
38
|
+
newly_added Goldfield Health added 72141-72158 to its authorization list on 2026-10-01.
|
|
39
|
+
|
|
40
|
+
▶ Write the authorization worklist
|
|
41
|
+
status: executed decision: allow
|
|
42
|
+
Prior authorization needed written: 8 upcoming service(s), 5 on a payer authorization list, lists for 2 payer(s). 5 finding(s): auth_missing_urgent 2, auth_missing 1, payer_list_missing 1, newly_added 1. Files: fairpractice-out/priorauth/prior-auth-needed.csv, fairpractice-out/priorauth/prior-auth-needed.html.
|
|
43
|
+
|
|
44
|
+
▶ Agent tries to submit an authorization itself
|
|
45
|
+
status: blocked decision: block
|
|
46
|
+
reason: Fairpractice Prior Auth Lists never submits an authorization request; your authorization staff do.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Tools
|
|
50
|
+
|
|
51
|
+
| Tool | What it does | Policy |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `priorauth_check` | List upcoming services that need an authorization and have none (urgent first), payers with no list and codes newly added to a list. | runs |
|
|
54
|
+
| `priorauth_write_report` | Write prior-auth-needed.csv (one row per item, with blank owner and decision columns) and prior-auth-needed.html into out_dir (default fairpractice-out/priorauth). | runs |
|
|
55
|
+
| `priorauth_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
|
|
56
|
+
| `priorauth_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
|
|
57
|
+
| `priorauth_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
|
+
| `priorauth_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
|
|
59
|
+
| `auth_submit` | Fairpractice Prior Auth Lists never submits an authorization request; your authorization staff do. | refused |
|
|
60
|
+
| `portal_login` | Fairpractice Prior Auth Lists never logs in to a payer portal. | 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
|
+
### `priorauth_check` arguments
|
|
65
|
+
|
|
66
|
+
| Argument | What it is |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `schedule` (required) | Upcoming appointments or orders under --root: appointment, patient, date, payer, CPT or HCPCS code, provider and authorization number |
|
|
69
|
+
| `auth_lists` (required) | Payer authorization lists you downloaded, one row per payer and code, range (70450-70498) or wildcard (J9*), with effective dates |
|
|
70
|
+
| `settings` | Optional settings JSON: lead_days, new_days |
|
|
71
|
+
| `as_of` | Date to measure deadlines and ages from (YYYY-MM-DD); default today |
|
|
72
|
+
| `status` | Only items with this status |
|
|
73
|
+
| `limit` | Most items to return to the model (the report file always has all of them) |
|
|
74
|
+
|
|
75
|
+
## Columns it reads
|
|
76
|
+
|
|
77
|
+
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.
|
|
78
|
+
|
|
79
|
+
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-prior-auth-lists inspect <file>` (column names and shapes only, never values) and name any column it misses in `remedy-sources.json`.
|
|
80
|
+
|
|
81
|
+
### Schedule (`schedule`)
|
|
82
|
+
|
|
83
|
+
| Column | Type | Read from |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `appt_id` | text | Appointment, Appointment ID, Appt #, Appt ID, Visit ID, Order # |
|
|
86
|
+
| `patient_id` | text (masked) | Patient ID, Patient #, Patient Number, MRN, Medical Record Number, Chart #, Chart Number, Account # |
|
|
87
|
+
| `patient_name` | text (masked) | Patient, Patient Name, Name, Client, Client Name, Member, Member Name, Beneficiary |
|
|
88
|
+
| `date` (required) | date | Date, Appointment Date, Service Date, Scheduled Date, Appt Date |
|
|
89
|
+
| `payer` (required) | text | Payer, Payer Name, Primary Payer, Insurance, Insurance Name, Plan, Plan Name, Payor |
|
|
90
|
+
| `cpt` (required) | text | CPT, Code, Procedure, Procedure Code, CPT/HCPCS, HCPCS, Service Code, Proc Code |
|
|
91
|
+
| `provider` | text (masked) | Provider, Rendering Provider, Rendering, Clinician, Therapist, Physician, Doctor, Practitioner |
|
|
92
|
+
| `auth_number` | text | Auth #, Auth Number, Authorization, Authorization Number, Prior Auth, PA Number |
|
|
93
|
+
|
|
94
|
+
### Payer authorization lists (`auth_lists`)
|
|
95
|
+
|
|
96
|
+
| Column | Type | Read from |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `payer` (required) | text | Payer, Payer Name, Primary Payer, Insurance, Insurance Name, Plan, Plan Name, Payor |
|
|
99
|
+
| `code` (required) | text | Code, CPT, HCPCS, Code Range, Procedure Code, Service Code |
|
|
100
|
+
| `effective_from` | date | Effective, Effective Date, Effective From, Added, Start Date |
|
|
101
|
+
| `effective_to` | date | Effective To, End Date, Removed, Termed |
|
|
102
|
+
|
|
103
|
+
## Settings file (`priorauth_settings`)
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
| Setting | What it does |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `lead_days` | Business days before the visit under which a missing authorization is urgent; default 5 |
|
|
110
|
+
| `new_days` | List entries that took effect within this many days are reported as newly added; default 90 |
|
|
111
|
+
|
|
112
|
+
## Memory
|
|
113
|
+
|
|
114
|
+
`priorauth_learn` only proposes a fact; nothing changes until a named person accepts it with `priorauth_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.
|
|
115
|
+
|
|
116
|
+
| Kind | What an accepted fact does |
|
|
117
|
+
|---|---|
|
|
118
|
+
|
|
119
|
+
## Install
|
|
120
|
+
|
|
121
|
+
Node 20 or newer. No other runtime dependencies besides `fairpractice-core` and `fairclaim-core`.
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"mcpServers": {
|
|
126
|
+
"fairpractice-prior-auth-lists": {
|
|
127
|
+
"command": "npx",
|
|
128
|
+
"args": [
|
|
129
|
+
"-y",
|
|
130
|
+
"fairpractice-prior-auth-lists",
|
|
131
|
+
"mcp",
|
|
132
|
+
"--root",
|
|
133
|
+
"/path/to/practice-files"
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Claude Code: `claude mcp add fairpractice-prior-auth-lists -- npx -y fairpractice-prior-auth-lists mcp --root .`, or use the plugin files in this folder.
|
|
141
|
+
|
|
142
|
+
## CLI
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
fairpractice-prior-auth-lists tools # every tool, its policy and arguments
|
|
146
|
+
fairpractice-prior-auth-lists sources # the columns each input is read from
|
|
147
|
+
fairpractice-prior-auth-lists inspect <file> # how a file would be read (names and shapes, never values)
|
|
148
|
+
fairpractice-prior-auth-lists call priorauth_check '{"schedule":"<schedule>","auth_lists":"<auth_lists>"}'
|
|
149
|
+
fairpractice-prior-auth-lists eval # the private eval cases on the fictional fixtures
|
|
150
|
+
fairpractice-prior-auth-lists demo
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Patient and staff data
|
|
154
|
+
|
|
155
|
+
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.
|
|
156
|
+
|
|
157
|
+
## Limits
|
|
158
|
+
|
|
159
|
+
- 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.
|
|
160
|
+
- 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.
|
|
161
|
+
- 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.
|
|
162
|
+
- 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-prior-auth-lists', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
|
package/evals/cases.json
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "fairpractice-prior-auth-lists",
|
|
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": "priorauth_recall",
|
|
9
|
+
"args": {},
|
|
10
|
+
"expect": {
|
|
11
|
+
"status": "executed",
|
|
12
|
+
"contains": [
|
|
13
|
+
"memory is empty"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "refuses-auth_submit",
|
|
19
|
+
"tool": "auth_submit",
|
|
20
|
+
"args": {},
|
|
21
|
+
"expect": {
|
|
22
|
+
"status": "blocked"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "refuses-portal_login",
|
|
27
|
+
"tool": "portal_login",
|
|
28
|
+
"args": {},
|
|
29
|
+
"expect": {
|
|
30
|
+
"status": "blocked"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "report",
|
|
35
|
+
"tool": "priorauth_write_report",
|
|
36
|
+
"args": {
|
|
37
|
+
"schedule": "fixtures/schedule.csv",
|
|
38
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
39
|
+
"settings": "fixtures/settings.json",
|
|
40
|
+
"as_of": "2026-11-15"
|
|
41
|
+
},
|
|
42
|
+
"expect": {
|
|
43
|
+
"status": "executed",
|
|
44
|
+
"matches": [
|
|
45
|
+
"\\.csv",
|
|
46
|
+
"\\.html"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "totals",
|
|
52
|
+
"tool": "priorauth_check",
|
|
53
|
+
"args": {
|
|
54
|
+
"schedule": "fixtures/schedule.csv",
|
|
55
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
56
|
+
"settings": "fixtures/settings.json",
|
|
57
|
+
"as_of": "2026-11-15"
|
|
58
|
+
},
|
|
59
|
+
"expect": {
|
|
60
|
+
"status": "executed",
|
|
61
|
+
"equals": {
|
|
62
|
+
"result.upcoming": 8,
|
|
63
|
+
"result.need_auth": 5,
|
|
64
|
+
"result.payers_with_lists": 2
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "every-planted-status-in-order",
|
|
70
|
+
"tool": "priorauth_check",
|
|
71
|
+
"args": {
|
|
72
|
+
"schedule": "fixtures/schedule.csv",
|
|
73
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
74
|
+
"settings": "fixtures/settings.json",
|
|
75
|
+
"as_of": "2026-11-15"
|
|
76
|
+
},
|
|
77
|
+
"expect": {
|
|
78
|
+
"equals": {
|
|
79
|
+
"result.items.0.status": "auth_missing_urgent",
|
|
80
|
+
"result.items.1.status": "auth_missing_urgent",
|
|
81
|
+
"result.items.2.status": "auth_missing",
|
|
82
|
+
"result.items.3.status": "payer_list_missing",
|
|
83
|
+
"result.items.4.status": "newly_added"
|
|
84
|
+
},
|
|
85
|
+
"length": {
|
|
86
|
+
"result.items": 5
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "status-filter",
|
|
92
|
+
"tool": "priorauth_check",
|
|
93
|
+
"args": {
|
|
94
|
+
"schedule": "fixtures/schedule.csv",
|
|
95
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
96
|
+
"settings": "fixtures/settings.json",
|
|
97
|
+
"as_of": "2026-11-15",
|
|
98
|
+
"status": "auth_missing_urgent"
|
|
99
|
+
},
|
|
100
|
+
"expect": {
|
|
101
|
+
"status": "executed",
|
|
102
|
+
"equals": {
|
|
103
|
+
"result.items.0.status": "auth_missing_urgent"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "limit-one",
|
|
109
|
+
"tool": "priorauth_check",
|
|
110
|
+
"args": {
|
|
111
|
+
"schedule": "fixtures/schedule.csv",
|
|
112
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
113
|
+
"settings": "fixtures/settings.json",
|
|
114
|
+
"as_of": "2026-11-15",
|
|
115
|
+
"limit": 1
|
|
116
|
+
},
|
|
117
|
+
"expect": {
|
|
118
|
+
"status": "executed",
|
|
119
|
+
"length": {
|
|
120
|
+
"result.items": 1
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"id": "report-spanish",
|
|
126
|
+
"tool": "priorauth_write_report",
|
|
127
|
+
"args": {
|
|
128
|
+
"schedule": "fixtures/schedule.csv",
|
|
129
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
130
|
+
"settings": "fixtures/settings.json",
|
|
131
|
+
"as_of": "2026-11-15",
|
|
132
|
+
"language": "es"
|
|
133
|
+
},
|
|
134
|
+
"expect": {
|
|
135
|
+
"status": "executed"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "report-japanese",
|
|
140
|
+
"tool": "priorauth_write_report",
|
|
141
|
+
"args": {
|
|
142
|
+
"schedule": "fixtures/schedule.csv",
|
|
143
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
144
|
+
"settings": "fixtures/settings.json",
|
|
145
|
+
"as_of": "2026-11-15",
|
|
146
|
+
"language": "ja"
|
|
147
|
+
},
|
|
148
|
+
"expect": {
|
|
149
|
+
"status": "executed",
|
|
150
|
+
"matches": [
|
|
151
|
+
"\\.html"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "typo-setting-refused",
|
|
157
|
+
"tool": "priorauth_check",
|
|
158
|
+
"args": {
|
|
159
|
+
"schedule": "fixtures/schedule.csv",
|
|
160
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
161
|
+
"settings": "fixtures/settings-typo.json",
|
|
162
|
+
"as_of": "2026-11-15"
|
|
163
|
+
},
|
|
164
|
+
"expect": {
|
|
165
|
+
"status": "error"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "null-settings-refused",
|
|
170
|
+
"tool": "priorauth_check",
|
|
171
|
+
"args": {
|
|
172
|
+
"schedule": "fixtures/schedule.csv",
|
|
173
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
174
|
+
"settings": null,
|
|
175
|
+
"as_of": "2026-11-15"
|
|
176
|
+
},
|
|
177
|
+
"expect": {
|
|
178
|
+
"status": "error"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"id": "file-outside-root-refused",
|
|
183
|
+
"tool": "priorauth_check",
|
|
184
|
+
"args": {
|
|
185
|
+
"schedule": "../../outside-root.csv",
|
|
186
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
187
|
+
"settings": "fixtures/settings.json",
|
|
188
|
+
"as_of": "2026-11-15"
|
|
189
|
+
},
|
|
190
|
+
"expect": {
|
|
191
|
+
"status": "error",
|
|
192
|
+
"contains": [
|
|
193
|
+
"outside the allowed root"
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "missing-file-named",
|
|
199
|
+
"tool": "priorauth_check",
|
|
200
|
+
"args": {
|
|
201
|
+
"schedule": "fixtures/missing-export.csv",
|
|
202
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
203
|
+
"settings": "fixtures/settings.json",
|
|
204
|
+
"as_of": "2026-11-15"
|
|
205
|
+
},
|
|
206
|
+
"expect": {
|
|
207
|
+
"status": "error",
|
|
208
|
+
"contains": [
|
|
209
|
+
"not found",
|
|
210
|
+
"missing-export.csv"
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"id": "no-settings-defaults",
|
|
216
|
+
"tool": "priorauth_check",
|
|
217
|
+
"args": {
|
|
218
|
+
"schedule": "fixtures/schedule.csv",
|
|
219
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
220
|
+
"as_of": "2026-11-15"
|
|
221
|
+
},
|
|
222
|
+
"expect": {
|
|
223
|
+
"status": "executed",
|
|
224
|
+
"equals": {
|
|
225
|
+
"result.by_status.auth_missing_urgent": 2
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"id": "urgent-soonest-first",
|
|
231
|
+
"tool": "priorauth_check",
|
|
232
|
+
"args": {
|
|
233
|
+
"schedule": "fixtures/schedule.csv",
|
|
234
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
235
|
+
"settings": "fixtures/settings.json",
|
|
236
|
+
"as_of": "2026-11-15",
|
|
237
|
+
"status": "auth_missing_urgent"
|
|
238
|
+
},
|
|
239
|
+
"expect": {
|
|
240
|
+
"equals": {
|
|
241
|
+
"result.items.0.appt_id": "A-301",
|
|
242
|
+
"result.items.0.business_days": 2,
|
|
243
|
+
"result.items.1.appt_id": "A-305"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"id": "missing-list-counted",
|
|
249
|
+
"tool": "priorauth_check",
|
|
250
|
+
"args": {
|
|
251
|
+
"schedule": "fixtures/schedule.csv",
|
|
252
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
253
|
+
"settings": "fixtures/settings.json",
|
|
254
|
+
"as_of": "2026-11-15",
|
|
255
|
+
"status": "payer_list_missing"
|
|
256
|
+
},
|
|
257
|
+
"expect": {
|
|
258
|
+
"equals": {
|
|
259
|
+
"result.items.0.payer": "Arbor Ridge Medicaid",
|
|
260
|
+
"result.items.0.appointments": 2
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"id": "new-list-entry",
|
|
266
|
+
"tool": "priorauth_check",
|
|
267
|
+
"args": {
|
|
268
|
+
"schedule": "fixtures/schedule.csv",
|
|
269
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
270
|
+
"settings": "fixtures/settings.json",
|
|
271
|
+
"as_of": "2026-11-15",
|
|
272
|
+
"status": "newly_added"
|
|
273
|
+
},
|
|
274
|
+
"expect": {
|
|
275
|
+
"equals": {
|
|
276
|
+
"result.items.0.list_entry": "72141-72158",
|
|
277
|
+
"result.items.0.effective_from": "2026-10-01"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"id": "past-and-authorized-not-listed",
|
|
283
|
+
"tool": "priorauth_check",
|
|
284
|
+
"args": {
|
|
285
|
+
"schedule": "fixtures/schedule.csv",
|
|
286
|
+
"auth_lists": "fixtures/auth-lists.csv",
|
|
287
|
+
"settings": "fixtures/settings.json",
|
|
288
|
+
"as_of": "2026-11-15"
|
|
289
|
+
},
|
|
290
|
+
"expect": {
|
|
291
|
+
"not_contains": [
|
|
292
|
+
"A-308",
|
|
293
|
+
"A-303",
|
|
294
|
+
"A-304",
|
|
295
|
+
"A-307"
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Fixtures
|
|
2
|
+
|
|
3
|
+
Fictional data only: Cedar Ridge Medical Group, made-up patients and made-up payers (Goldfield Health, Copperline Advantage, Arbor Ridge Medicaid). The lists are invented for the sample; no real payer's list is copied.
|
|
4
|
+
|
|
5
|
+
- `schedule.csv`: nine appointments, checked on Sunday 15 November 2026. Planted: a head CT on 17 November and a knee replacement on 19 November with no authorization (urgent: within five business days), a lumbar MRI on 8 December with none (not urgent yet), and two Arbor Ridge Medicaid visits with no list loaded. A-308 is in the past and skipped; A-303 and A-304 have numbers; A-307 is an office visit no list covers.
|
|
6
|
+
- `auth-lists.csv`: Goldfield Health lists CT head as a range, added the MRI spine range on 1 October (reported as newly added) and dropped 97110 at the end of June; Copperline Advantage lists 27447 and every J9 code.
|
|
7
|
+
- `settings.json`: five business days and a 90-day "newly added" window. `settings-typo.json` misspells a setting and is refused.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"case": "totals",
|
|
3
|
+
"id": [
|
|
4
|
+
[
|
|
5
|
+
"appt_id"
|
|
6
|
+
],
|
|
7
|
+
["payer", "code"],
|
|
8
|
+
["payer", "date"]
|
|
9
|
+
],
|
|
10
|
+
"planted": [
|
|
11
|
+
["A-301", "auth_missing_urgent"],
|
|
12
|
+
["A-305", "auth_missing_urgent"],
|
|
13
|
+
["A-302", "auth_missing"],
|
|
14
|
+
["Arbor Ridge Medicaid/2026-11-25", "payer_list_missing"],
|
|
15
|
+
["Goldfield Health/72148", "newly_added"]
|
|
16
|
+
],
|
|
17
|
+
"clean": [
|
|
18
|
+
{
|
|
19
|
+
"arg": "schedule",
|
|
20
|
+
"set": [
|
|
21
|
+
{
|
|
22
|
+
"where": ["Appt ID", "A-301"],
|
|
23
|
+
"column": "Auth Number",
|
|
24
|
+
"value": "AUTH-55130"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"where": ["Appt ID", "A-305"],
|
|
28
|
+
"column": "Auth Number",
|
|
29
|
+
"value": "SA-88220"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"where": ["Appt ID", "A-302"],
|
|
33
|
+
"column": "Auth Number",
|
|
34
|
+
"value": "AUTH-55140"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"arg": "auth_lists",
|
|
40
|
+
"set": [
|
|
41
|
+
{
|
|
42
|
+
"where": [
|
|
43
|
+
["Payer", "Goldfield Health"],
|
|
44
|
+
["Code Range", "72141-72158"]
|
|
45
|
+
],
|
|
46
|
+
"column": "Effective Date",
|
|
47
|
+
"value": "2025-01-01"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"add": [
|
|
51
|
+
{
|
|
52
|
+
"Payer": "Arbor Ridge Medicaid",
|
|
53
|
+
"Code Range": "70551-70553",
|
|
54
|
+
"Effective Date": "2025-01-01"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"mutations": [
|
|
60
|
+
{
|
|
61
|
+
"name": "office visit rebooked as a CT",
|
|
62
|
+
"edits": [
|
|
63
|
+
{
|
|
64
|
+
"arg": "schedule",
|
|
65
|
+
"set": [
|
|
66
|
+
{
|
|
67
|
+
"where": ["Appt ID", "A-307"],
|
|
68
|
+
"column": "CPT",
|
|
69
|
+
"value": "70470"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"expect": [
|
|
75
|
+
["A-307", "auth_missing"]
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "authorization number removed this week",
|
|
80
|
+
"edits": [
|
|
81
|
+
{
|
|
82
|
+
"arg": "schedule",
|
|
83
|
+
"set": [
|
|
84
|
+
{
|
|
85
|
+
"where": ["Appt ID", "A-303"],
|
|
86
|
+
"column": "Auth Number",
|
|
87
|
+
"value": ""
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"expect": [
|
|
93
|
+
["A-303", "auth_missing_urgent"]
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "Medicaid list covers CT head",
|
|
98
|
+
"edits": [
|
|
99
|
+
{
|
|
100
|
+
"arg": "auth_lists",
|
|
101
|
+
"set": [
|
|
102
|
+
{
|
|
103
|
+
"where": ["Payer", "Arbor Ridge Medicaid"],
|
|
104
|
+
"column": "Code Range",
|
|
105
|
+
"value": "70450"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"expect": [
|
|
111
|
+
["A-306", "auth_missing"]
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"note":"Fictional patient and provider names and ids used in these fixtures. None may reach a model result when masking is on.","values":["Mara Ellison","Otto Brandt","Uma Novak","Pablo Ruiz","P8001","Dana Whitfield","Elena Sorensen","Marcus Bello"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Appt ID,Patient #,Patient Name,Appointment Date,Insurance,CPT,Provider,Auth Number
|
|
2
|
+
A-308,P8008,Quentin Hale,2026-11-10,Goldfield Health,70450,Dana Whitfield,
|
|
3
|
+
A-301,P8001,Mara Ellison,2026-11-17,Goldfield Health,70450,Dana Whitfield,
|
|
4
|
+
A-305,P8005,Otto Brandt,2026-11-19,Copperline Advantage,27447,Elena Sorensen,
|
|
5
|
+
A-303,P8003,Nina Patel,2026-11-20,Goldfield Health,72148,Dana Whitfield,AUTH-55120
|
|
6
|
+
A-306,P8006,Pablo Ruiz,2026-11-25,Arbor Ridge Medicaid,70450,Dana Whitfield,
|
|
7
|
+
A-309,P8009,Rosa Kim,2026-11-27,Arbor Ridge Medicaid,99214,Marcus Bello,
|
|
8
|
+
A-307,P8007,Sean Doyle,2026-11-30,Goldfield Health,99213,Marcus Bello,
|
|
9
|
+
A-304,P8004,Talia Grey,2026-12-01,Copperline Advantage,27447,Elena Sorensen,SA-88213
|
|
10
|
+
A-302,P8002,Uma Novak,2026-12-08,Goldfield Health,72148,Dana Whitfield,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "lead_time": 5 }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "lead_days": 5, "new_days": 90 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fairpractice-prior-auth-lists",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.fpavia111-creator/fairpractice-prior-auth-lists",
|
|
5
|
+
"description": "Prior authorization requirements: each scheduled service checked against the payer authorization lists you download (single codes, ranges and wildcards), with missing authorizations, urgent ones close to the visit, codes newly added to a list and payers with no list loaded.",
|
|
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-prior-auth-lists": "bin/fairpractice-prior-auth-lists.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-prior-auth-lists.js demo",
|
|
33
|
+
"eval": "node bin/fairpractice-prior-auth-lists.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-prior-auth-lists"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/fpavia111-creator/fairpractice2-agents/tree/master/packages/fairpractice-prior-auth-lists#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
|
+
"prior-authorization",
|
|
55
|
+
"payer-policy",
|
|
56
|
+
"scheduling",
|
|
57
|
+
"revenue-cycle"
|
|
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-prior-auth-lists",
|
|
4
|
+
"title": "Fairpractice Prior Auth Lists",
|
|
5
|
+
"description": "Prior authorization requirements",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/fpavia111-creator/fairpractice2-agents",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "packages/fairpractice-prior-auth-lists"
|
|
11
|
+
},
|
|
12
|
+
"websiteUrl": "https://fair-agents.com/fairpractice.html",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "fairpractice-prior-auth-lists",
|
|
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 = { schedule: 'schedule.csv', auth_lists: 'auth-lists.csv', settings: 'settings.json', as_of: '2026-11-15' };
|
|
5
|
+
export const demo = () => runDemo(manifest, new URL('../fixtures', import.meta.url), 'Fairpractice Prior Auth Lists', [
|
|
6
|
+
{ label: 'Check the next weeks of appointments against the payer lists', tool: 'priorauth_check', args: f, list: (i) => `${i.status.padEnd(20)} ${i.message}` },
|
|
7
|
+
{ label: 'Write the authorization worklist', tool: 'priorauth_write_report', args: f },
|
|
8
|
+
{ label: 'Agent tries to submit an authorization itself', tool: 'auth_submit', args: {} },
|
|
9
|
+
]);
|
package/src/index.js
ADDED
package/src/logic.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Prior authorization requirement logic: scheduled services against the payer auth lists you downloaded. No I/O.
|
|
2
|
+
import { str, isoDate, daysBetween, payerKey, inCodeList, businessDaysBetween, sortByStatus, countBy } from 'fairpractice-core';
|
|
3
|
+
|
|
4
|
+
const ORDER = { auth_missing_urgent: 0, auth_missing: 1, payer_list_missing: 2, newly_added: 3 };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* schedule: [{ appt_id, patient_id, patient_name, date, payer, cpt, provider, auth_number }]
|
|
8
|
+
* lists: [{ payer, code, effective_from, effective_to }] code: single, range (70450-70498) or wildcard (J9*)
|
|
9
|
+
* opts: { asOf, leadDays = 5, newDays = 90 }
|
|
10
|
+
*/
|
|
11
|
+
export function checkPriorAuth(schedule, lists, { asOf, leadDays = 5, newDays = 90 } = {}) {
|
|
12
|
+
const byPayer = new Map();
|
|
13
|
+
for (const l of lists) { const k = payerKey(l.payer); if (!k || !str(l.code)) continue; if (!byPayer.has(k)) byPayer.set(k, []); byPayer.get(k).push(l); }
|
|
14
|
+
const items = []; const missingPayers = new Map(); const newSeen = new Set(); let upcoming = 0; let needAuth = 0;
|
|
15
|
+
const rows = schedule.map((r, i) => ({ ...r, i, d: isoDate(r.date) })).filter((r) => r.d && r.d >= asOf).sort((a, b) => a.d.localeCompare(b.d) || a.i - b.i);
|
|
16
|
+
for (const r of rows) {
|
|
17
|
+
upcoming++;
|
|
18
|
+
const pk = payerKey(r.payer); const code = str(r.cpt);
|
|
19
|
+
const base = { appt_id: str(r.appt_id) || `line ${r.i + 1}`, patient_id: str(r.patient_id) || null, patient_name: str(r.patient_name) || null, date: r.d, payer: str(r.payer) || null, code };
|
|
20
|
+
const list = byPayer.get(pk);
|
|
21
|
+
if (!list) { const m = missingPayers.get(pk) || { payer: str(r.payer) || '(no payer)', appointments: 0, first: r.d }; m.appointments++; missingPayers.set(pk, m); continue; }
|
|
22
|
+
const hit = list.find((l) => inCodeList(code, [l.code]) && (!isoDate(l.effective_from) || isoDate(l.effective_from) <= r.d) && (!isoDate(l.effective_to) || isoDate(l.effective_to) >= r.d));
|
|
23
|
+
if (!hit) continue;
|
|
24
|
+
needAuth++;
|
|
25
|
+
const from = isoDate(hit.effective_from);
|
|
26
|
+
if (from && daysBetween(from, asOf) <= newDays && daysBetween(from, asOf) >= 0 && !newSeen.has(`${pk}|${code}`)) { newSeen.add(`${pk}|${code}`); items.push({ ...base, appt_id: null, patient_id: null, patient_name: null, status: 'newly_added', list_entry: str(hit.code), effective_from: from }); }
|
|
27
|
+
if (str(r.auth_number)) continue;
|
|
28
|
+
const bd = businessDaysBetween(asOf, r.d);
|
|
29
|
+
items.push({ ...base, status: bd <= leadDays ? 'auth_missing_urgent' : 'auth_missing', business_days: bd, list_entry: str(hit.code) });
|
|
30
|
+
}
|
|
31
|
+
for (const m of missingPayers.values()) items.push({ appt_id: null, patient_id: null, patient_name: null, date: m.first, payer: m.payer, code: null, status: 'payer_list_missing', appointments: m.appointments });
|
|
32
|
+
const T = {
|
|
33
|
+
auth_missing_urgent: (x) => [`Appointment ${x.appt_id} on ${x.date} (${x.payer}, ${x.code}) needs an authorization and none is recorded; ${x.business_days} business day(s) left.`, 'Request the authorization today, or move the visit if it cannot come back in time.'],
|
|
34
|
+
auth_missing: (x) => [`Appointment ${x.appt_id} on ${x.date} (${x.payer}, ${x.code}) is on the payer's authorization list (${x.list_entry}) and has no authorization number.`, 'Start the request and record the number on the appointment.'],
|
|
35
|
+
payer_list_missing: (x) => [`No authorization list is loaded for ${x.payer}; ${x.appointments} upcoming appointment(s) could not be checked.`, 'Download the payer\'s current list and add it, or record that the payer needs none.'],
|
|
36
|
+
newly_added: (x) => [`${x.payer} added ${x.list_entry} to its authorization list on ${x.effective_from}.`, 'Tell schedulers; visits booked before the change may still need an authorization.'],
|
|
37
|
+
};
|
|
38
|
+
for (const it of items) { const [m, f] = T[it.status](it); it.message = m; it.fix = f; }
|
|
39
|
+
sortByStatus(items, ORDER);
|
|
40
|
+
return { upcoming, need_auth: needAuth, payers_with_lists: byPayer.size, by_status: countBy(items, 'status'), items };
|
|
41
|
+
}
|
package/src/manifest.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { medAgent, fileArg, AS_OF_ARG, PATIENT_ID, PATIENT_NAME, PAYER, CPT, PROVIDER, PRACTICE_LIMITS, today } from 'fairpractice-core';
|
|
3
|
+
import { checkPriorAuth } 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 SCHEDULE_FIELDS = Object.freeze({
|
|
9
|
+
appt_id: t(['Appointment', 'Appointment ID', 'Appt #', 'Appt ID', 'Visit ID', 'Order #'], { translate: false }),
|
|
10
|
+
patient_id: PATIENT_ID, patient_name: PATIENT_NAME,
|
|
11
|
+
date: t(['Date', 'Appointment Date', 'Service Date', 'Scheduled Date', 'Appt Date'], { type: 'date', translate: 'date', required: true }),
|
|
12
|
+
payer: { ...PAYER, required: true }, cpt: { ...CPT, required: true }, provider: { ...PROVIDER, phi: 'name' },
|
|
13
|
+
auth_number: t(['Auth #', 'Auth Number', 'Authorization', 'Authorization Number', 'Prior Auth', 'PA Number'], { translate: false }),
|
|
14
|
+
});
|
|
15
|
+
export const LIST_FIELDS = Object.freeze({
|
|
16
|
+
payer: { ...PAYER, required: true },
|
|
17
|
+
code: t(['Code', 'CPT', 'HCPCS', 'Code Range', 'Procedure Code', 'Service Code'], { translate: false, required: true }),
|
|
18
|
+
effective_from: t(['Effective', 'Effective Date', 'Effective From', 'Added', 'Start Date'], { type: 'date', translate: false }),
|
|
19
|
+
effective_to: t(['Effective To', 'End Date', 'Removed', 'Termed'], { type: 'date', translate: false }),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const SETTINGS = { type: 'object', additionalProperties: false, properties: {
|
|
23
|
+
lead_days: { type: 'integer', minimum: 0, maximum: 30, description: 'Business days before the visit under which a missing authorization is urgent; default 5' },
|
|
24
|
+
new_days: { type: 'integer', minimum: 0, maximum: 365, description: 'List entries that took effect within this many days are reported as newly added; default 90' },
|
|
25
|
+
} };
|
|
26
|
+
|
|
27
|
+
const args = {
|
|
28
|
+
schedule: fileArg('Upcoming appointments or orders under --root: appointment, patient, date, payer, CPT or HCPCS code, provider and authorization number'),
|
|
29
|
+
auth_lists: fileArg('Payer authorization lists you downloaded, one row per payer and code, range (70450-70498) or wildcard (J9*), with effective dates'),
|
|
30
|
+
settings: fileArg('Optional settings JSON: lead_days, new_days'),
|
|
31
|
+
as_of: AS_OF_ARG,
|
|
32
|
+
};
|
|
33
|
+
const run = (a, ctx) => {
|
|
34
|
+
const s = a.settings ? ctx.readJson(a.settings, 'priorauth_settings') : {};
|
|
35
|
+
return checkPriorAuth(ctx.records(a.schedule, 'schedule'), ctx.records(a.auth_lists, 'lists'), { asOf: a.as_of || today(), leadDays: s.lead_days ?? 5, newDays: s.new_days ?? 90 });
|
|
36
|
+
};
|
|
37
|
+
const summary = (o) => `${o.upcoming} upcoming service(s), ${o.need_auth} on a payer authorization list, lists for ${o.payers_with_lists} payer(s). ${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'}.`;
|
|
38
|
+
|
|
39
|
+
export const manifest = medAgent({
|
|
40
|
+
pkg, prefix: 'priorauth', title: 'Fairpractice Prior Auth Lists',
|
|
41
|
+
description: 'Checks each scheduled service against the payer authorization lists you download (single codes, ranges and wildcards, with effective dates): services that need an authorization and have none, urgent ones close to the visit, codes payers added to their lists recently, and payers with no list loaded. Patient names are masked before results reach the model.',
|
|
42
|
+
args, required: ['schedule', 'auth_lists'],
|
|
43
|
+
sources: { schedule: { label: 'Schedule', args: ['schedule'], fields: SCHEDULE_FIELDS }, lists: { label: 'Payer authorization lists', args: ['auth_lists'], fields: LIST_FIELDS } },
|
|
44
|
+
configSchemas: { priorauth_settings: SETTINGS }, memoryKinds: {},
|
|
45
|
+
run, summary,
|
|
46
|
+
check: { title: 'Check prior authorization needs', description: 'List upcoming services that need an authorization and have none (urgent first), payers with no list and codes newly added to a list.' },
|
|
47
|
+
report: {
|
|
48
|
+
title: { en: 'Prior authorization needed', es: 'Autorización previa necesaria', de: 'Erforderliche Vorabgenehmigungen', fr: 'Autorisations préalables requises', pt: 'Autorizações prévias necessárias', it: 'Autorizzazioni preventive necessarie', ja: '事前承認が必要な予約', zh: '需事先授权的预约', ko: '사전 승인이 필요한 예약' },
|
|
49
|
+
base: 'prior-auth-needed',
|
|
50
|
+
rows: (o) => o.items.map((i) => ({ status: i.status, appt_id: i.appt_id || '', patient_id: i.patient_id || '', patient_name: i.patient_name || '', date: i.date || '', payer: i.payer || '', code: i.code || i.list_entry || '', message: i.message, fix: i.fix })),
|
|
51
|
+
htmlColumns: ['status', 'appt_id', 'patient_name', 'date', 'payer', 'code', 'message', 'fix'],
|
|
52
|
+
sections: (o) => [{ title: { en: 'Findings by type' }, rows: Object.entries(o.by_status).map(([status, count]) => ({ status, count })), columns: ['status', 'count'] }],
|
|
53
|
+
limits: [PRACTICE_LIMITS.files, 'It knows only the lists you load: payers also require authorizations by site of care, diagnosis or plan, which a list of codes cannot show. A missing list is reported, never read as "no authorization needed".', PRACTICE_LIMITS.advice, PRACTICE_LIMITS.phi],
|
|
54
|
+
},
|
|
55
|
+
refused: [
|
|
56
|
+
{ name: 'auth_submit', category: 'binding_send', description: 'Fairpractice Prior Auth Lists never submits an authorization request; your authorization staff do.' },
|
|
57
|
+
{ name: 'portal_login', category: 'binding_send', description: 'Fairpractice Prior Auth Lists never logs in to a payer portal.' },
|
|
58
|
+
],
|
|
59
|
+
prompt: { title: 'Prior authorization check', description: 'Walks the host model through a daily prior authorization check.', text: `You are helping a scheduling or authorization lead with fairpractice-prior-auth-lists.
|
|
60
|
+
|
|
61
|
+
Rules: it only reads files. Patient names in results are pseudonyms.
|
|
62
|
+
|
|
63
|
+
1. Call priorauth_check with the schedule, the payer lists and as_of.
|
|
64
|
+
2. Lead with auth_missing_urgent: those visits are days away.
|
|
65
|
+
3. Name payers with no list; never treat them as "no authorization needed".
|
|
66
|
+
4. Call priorauth_write_report for the authorization team.` },
|
|
67
|
+
});
|