fairpractice-records-requests 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ Renamed from `owl-of-access-requests` on 18 Nov 2026 (tool names were `owl_*`, now `access_*`).
4
+
5
+ ## 0.1.0 (unreleased)
6
+
7
+ - First version (Fairpractice ver 1).
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,166 @@
1
- # Temporary Holding Version
1
+ <!-- Generated by scripts/readme.mjs from the agent itself. Edit the manifest or fixtures/README.md, then run npm run readme. -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # Fairpractice Records Requests (`fairpractice-records-requests`)
4
+
5
+ Tracks patient right-of-access requests against the HIPAA clock (30 days plus one 30-day extension with written notice, or your shorter state limit): requests past due or due soon, answered late, extensions with no timely notice, denials with no reason and fees above your fee settings. Patient names are masked before results reach the model.
6
+
7
+ **Fairpractice Records Requests never sends records to anyone; your release-of-information staff do. Fairpractice Records Requests never issues refunds.**
8
+
9
+ Fairpractice ver 1 · Compliance pack · MIT · Node 20 or newer · local files only · patient and staff identifiers masked before results reach the model · built on [`fairpractice-core`](../fairpractice-core)
10
+
11
+ ```bash
12
+ npx -y fairpractice-records-requests demo
13
+ npx -y fairpractice-records-requests mcp --root ./practice-files
14
+ ```
15
+
16
+ ## What the sample data shows
17
+
18
+ Fictional data only: Bluewater Family Medicine (a made-up practice) and made-up patients. Any likeness to real people is chance.
19
+
20
+ - [`access-requests.csv`](fixtures/access-requests.csv): Planted: a request answered in 11 days (AR-1001, clean), paper copies sent 8 days late and charged 25.00 against an allowed 15.00 (AR-1002), an open request 15 days past due (AR-1003), an extension whose notice went out after the first 30 days and 10 paper pages charged 8.00 against an allowed 7.50 (AR-1004), a request due within 7 days (AR-1005), a denial with no reason or date recorded (AR-1006), an email copy charged 15.00 against the 6.50 flat fee (AR-1007) and a new request not due yet (AR-1008).
21
+ - [`settings.json`](fixtures/settings.json): 30 days plus one 30-day extension, a 6.50 flat fee for electronic copies, paper at 5.00 plus 0.25 a page, capped at 50. These are examples; use your policy and state law. [`settings-typo.json`](fixtures/settings-typo.json) misspells a setting and is refused.
22
+
23
+ ## A demo run
24
+
25
+ `npx -y fairpractice-records-requests demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
26
+
27
+ ```text
28
+ Fairpractice Records Requests demo (fictional practice, patients, staff and payers)
29
+
30
+ ▶ Check this quarter's access requests
31
+ status: executed decision: allow
32
+ 8 request(s): 3 open, 5 answered, 28 days on average. 8 finding(s): past_due 1, fulfilled_late 1, extension_no_notice 1, denial_no_reason 1, fee_over_limit 3, due_soon 1. Overcharged 19.
33
+ past_due Request AR-1003 received 2026-10-01 was due 2026-10-31 and is 15 day(s) late.
34
+ fulfilled_late Request AR-1002 was answered 2026-10-28, 8 day(s) after the 2026-10-20 deadline.
35
+ extension_no_notice Request AR-1004 was extended without a written notice inside the first 30 days (notice 10 day(s) late).
36
+ denial_no_reason Request AR-1006 was denied with no reason recorded.
37
+ fee_over_limit Request AR-1002 was charged 25; your fee settings allow 15.
38
+ fee_over_limit Request AR-1004 was charged 8; your fee settings allow 7.5.
39
+ fee_over_limit Request AR-1007 was charged 15; your fee settings allow 6.5.
40
+ due_soon Request AR-1005 is due 2026-11-19 (in 4 day(s)).
41
+
42
+ ▶ Write the privacy meeting list
43
+ status: executed decision: allow
44
+ Patient access requests written: 8 request(s): 3 open, 5 answered, 28 days on average. 8 finding(s): past_due 1, fulfilled_late 1, extension_no_notice 1, denial_no_reason 1, fee_over_limit 3, due_soon 1. Overcharged 19. Files: fairpractice-out/access/access-requests.csv, fairpractice-out/access/access-requests.html.
45
+
46
+ ▶ Agent tries to release records itself
47
+ status: blocked decision: block
48
+ reason: Fairpractice Records Requests never sends records to anyone; your release-of-information staff do.
49
+ ```
50
+
51
+ ## Tools
52
+
53
+ | Tool | What it does | Policy |
54
+ |---|---|---|
55
+ | `access_check` | List access requests that are late, due soon, extended without notice, denied without a reason or overcharged. | runs |
56
+ | `access_write_report` | Write access-requests.csv (one row per item, with blank owner and decision columns) and access-requests.html into out_dir (default fairpractice-out/access). | runs |
57
+ | `access_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
58
+ | `access_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
59
+ | `access_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
60
+ | `access_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
61
+ | `records_release` | Fairpractice Records Requests never sends records to anyone; your release-of-information staff do. | refused |
62
+ | `refund_issue` | Fairpractice Records Requests never issues refunds. | refused |
63
+
64
+ 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.
65
+
66
+ ### `access_check` arguments
67
+
68
+ | Argument | What it is |
69
+ |---|---|
70
+ | `requests` (required) | Access request log under --root: request, patient, received date, requester type, format, pages, extension, notice date, fulfilled or denied date, reason and fee |
71
+ | `settings` | Optional settings JSON: response_days, extension_days, warn_days, flat_fee, per_page, base_fee, fee_cap |
72
+ | `as_of` | Date to measure deadlines and ages from (YYYY-MM-DD); default today |
73
+ | `status` | Only items with this status |
74
+ | `limit` | Most items to return to the model (the report file always has all of them) |
75
+
76
+ ## Columns it reads
77
+
78
+ 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.
79
+
80
+ 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-records-requests inspect <file>` (column names and shapes only, never values) and name any column it misses in `remedy-sources.json`.
81
+
82
+ ### Access request log (`requests`)
83
+
84
+ | Column | Type | Read from |
85
+ |---|---|---|
86
+ | `request_id` | text | Request ID, Request #, Request, ROI #, Log #, Ticket |
87
+ | `patient_id` | text (masked) | Patient ID, Patient #, Patient Number, MRN, Medical Record Number, Chart #, Chart Number, Account # |
88
+ | `patient_name` | text (masked) | Patient, Patient Name, Name, Client, Client Name, Member, Member Name, Beneficiary |
89
+ | `received` (required) | date | Received, Date Received, Received On, Request Date, Requested |
90
+ | `requester_type` | text | Requester Type, Requested By, Requester, Request Type |
91
+ | `format` | text | Format, Delivery, Media, Copy Format, Delivery Method |
92
+ | `pages` | number | Pages, Page Count, # Pages |
93
+ | `extended` | text | Extended, Extension, Extension Taken |
94
+ | `extension_notice_on` | date | Extension Notice, Extension Notice Date, Extension Letter Sent |
95
+ | `fulfilled` | date | Fulfilled, Completed, Sent, Date Sent, Closed, Released, Date Completed |
96
+ | `denied` | text | Denied, Denial |
97
+ | `denied_on` | date | Denied On, Denial Date |
98
+ | `denial_reason` | text | Denial Reason, Reason Denied, Reason |
99
+ | `fee` | amount | Fee, Fee Charged, Charge, Amount Charged |
100
+ | `postage` | amount | Postage, Shipping |
101
+
102
+ ## Settings file (`access_settings`)
103
+
104
+ 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.
105
+
106
+ | Setting | What it does |
107
+ |---|---|
108
+ | `response_days` | Calendar days to answer (HIPAA: 30; some states are shorter) |
109
+ | `extension_days` | Days one extension adds (HIPAA: 30) |
110
+ | `warn_days` | Days ahead to warn; default 7 |
111
+ | `flat_fee` | Flat fee you charge for electronic copies (HHS describes $6.50 as an option), or null |
112
+ | `per_page` | Per-page fee for paper copies under your policy or state law, or null |
113
+ | `base_fee` | Fixed fee added to per-page fees (labor or search fee your state allows), default 0 |
114
+ | `fee_cap` | Most you charge for one request, or null |
115
+
116
+ ## Memory
117
+
118
+ `access_learn` only proposes a fact; nothing changes until a named person accepts it with `access_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.
119
+
120
+ | Kind | What an accepted fact does |
121
+ |---|---|
122
+
123
+ ## Install
124
+
125
+ Node 20 or newer. No other runtime dependencies besides `fairpractice-core` and `fairclaim-core`.
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "fairpractice-records-requests": {
131
+ "command": "npx",
132
+ "args": [
133
+ "-y",
134
+ "fairpractice-records-requests",
135
+ "mcp",
136
+ "--root",
137
+ "/path/to/practice-files"
138
+ ]
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ Claude Code: `claude mcp add fairpractice-records-requests -- npx -y fairpractice-records-requests mcp --root .`, or use the plugin files in this folder.
145
+
146
+ ## CLI
147
+
148
+ ```bash
149
+ fairpractice-records-requests tools # every tool, its policy and arguments
150
+ fairpractice-records-requests sources # the columns each input is read from
151
+ fairpractice-records-requests inspect <file> # how a file would be read (names and shapes, never values)
152
+ fairpractice-records-requests call access_check '{"requests":"<requests>"}'
153
+ fairpractice-records-requests eval # the private eval cases on the fictional fixtures
154
+ fairpractice-records-requests demo
155
+ ```
156
+
157
+ ## Patient and staff data
158
+
159
+ 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.
160
+
161
+ ## Limits
162
+
163
+ - 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.
164
+ - 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.
165
+ - 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.
166
+ - 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-records-requests', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,269 @@
1
+ {
2
+ "suite": "fairpractice-records-requests",
3
+ "root": "..",
4
+ "data_note": "Fictional data in ../fixtures. Deterministic checks; no model is called.",
5
+ "cases": [
6
+ {
7
+ "id": "totals",
8
+ "tool": "access_check",
9
+ "args": {
10
+ "requests": "fixtures/access-requests.csv",
11
+ "settings": "fixtures/settings.json",
12
+ "as_of": "2026-11-15"
13
+ },
14
+ "expect": {
15
+ "status": "executed",
16
+ "equals": {
17
+ "result.requests": 8,
18
+ "result.open": 3,
19
+ "result.closed": 5,
20
+ "result.overcharged": 19
21
+ }
22
+ }
23
+ },
24
+ {
25
+ "id": "every-planted-status-in-order",
26
+ "tool": "access_check",
27
+ "args": {
28
+ "requests": "fixtures/access-requests.csv",
29
+ "settings": "fixtures/settings.json",
30
+ "as_of": "2026-11-15"
31
+ },
32
+ "expect": {
33
+ "equals": {
34
+ "result.items.0.status": "past_due",
35
+ "result.items.1.status": "fulfilled_late",
36
+ "result.items.2.status": "extension_no_notice",
37
+ "result.items.3.status": "denial_no_reason",
38
+ "result.items.4.status": "fee_over_limit",
39
+ "result.items.5.status": "fee_over_limit",
40
+ "result.items.6.status": "fee_over_limit",
41
+ "result.items.7.status": "due_soon"
42
+ }
43
+ }
44
+ },
45
+ {
46
+ "id": "status-filter",
47
+ "tool": "access_check",
48
+ "args": {
49
+ "requests": "fixtures/access-requests.csv",
50
+ "settings": "fixtures/settings.json",
51
+ "as_of": "2026-11-15",
52
+ "status": "past_due"
53
+ },
54
+ "expect": {
55
+ "status": "executed",
56
+ "equals": {
57
+ "result.items.0.status": "past_due"
58
+ }
59
+ }
60
+ },
61
+ {
62
+ "id": "limit-one",
63
+ "tool": "access_check",
64
+ "args": {
65
+ "requests": "fixtures/access-requests.csv",
66
+ "settings": "fixtures/settings.json",
67
+ "as_of": "2026-11-15",
68
+ "limit": 1
69
+ },
70
+ "expect": {
71
+ "status": "executed",
72
+ "length": {
73
+ "result.items": 1
74
+ }
75
+ }
76
+ },
77
+ {
78
+ "id": "report",
79
+ "tool": "access_write_report",
80
+ "args": {
81
+ "requests": "fixtures/access-requests.csv",
82
+ "settings": "fixtures/settings.json",
83
+ "as_of": "2026-11-15"
84
+ },
85
+ "expect": {
86
+ "status": "executed",
87
+ "matches": [
88
+ "\\.csv",
89
+ "\\.html"
90
+ ]
91
+ }
92
+ },
93
+ {
94
+ "id": "report-spanish",
95
+ "tool": "access_write_report",
96
+ "args": {
97
+ "requests": "fixtures/access-requests.csv",
98
+ "settings": "fixtures/settings.json",
99
+ "as_of": "2026-11-15",
100
+ "language": "es"
101
+ },
102
+ "expect": {
103
+ "status": "executed"
104
+ }
105
+ },
106
+ {
107
+ "id": "typo-setting-refused",
108
+ "tool": "access_check",
109
+ "args": {
110
+ "requests": "fixtures/access-requests.csv",
111
+ "settings": "fixtures/settings-typo.json",
112
+ "as_of": "2026-11-15"
113
+ },
114
+ "expect": {
115
+ "status": "error"
116
+ }
117
+ },
118
+ {
119
+ "id": "missing-file",
120
+ "tool": "access_check",
121
+ "args": {
122
+ "requests": "fixtures/does-not-exist.csv",
123
+ "settings": "fixtures/settings.json",
124
+ "as_of": "2026-11-15"
125
+ },
126
+ "expect": {
127
+ "status": "error"
128
+ }
129
+ },
130
+ {
131
+ "id": "refuses-records_release",
132
+ "tool": "records_release",
133
+ "args": {},
134
+ "expect": {
135
+ "status": "blocked"
136
+ }
137
+ },
138
+ {
139
+ "id": "refuses-refund_issue",
140
+ "tool": "refund_issue",
141
+ "args": {},
142
+ "expect": {
143
+ "status": "blocked"
144
+ }
145
+ },
146
+ {
147
+ "id": "recall-empty-memory",
148
+ "tool": "access_recall",
149
+ "args": {},
150
+ "expect": {
151
+ "status": "executed",
152
+ "contains": [
153
+ "memory is empty"
154
+ ]
155
+ }
156
+ },
157
+ {
158
+ "id": "past-due-days",
159
+ "tool": "access_check",
160
+ "args": {
161
+ "requests": "fixtures/access-requests.csv",
162
+ "settings": "fixtures/settings.json",
163
+ "as_of": "2026-11-15",
164
+ "status": "past_due"
165
+ },
166
+ "expect": {
167
+ "length": {
168
+ "result.items": 1
169
+ },
170
+ "equals": {
171
+ "result.items.0.request_id": "AR-1003",
172
+ "result.items.0.days": 15
173
+ }
174
+ }
175
+ },
176
+ {
177
+ "id": "flat-fee-electronic",
178
+ "tool": "access_check",
179
+ "args": {
180
+ "requests": "fixtures/access-requests.csv",
181
+ "settings": "fixtures/settings.json",
182
+ "as_of": "2026-11-15",
183
+ "status": "fee_over_limit"
184
+ },
185
+ "expect": {
186
+ "equals": {
187
+ "result.items.0.fee_allowed": 15,
188
+ "result.items.2.fee_allowed": 6.5,
189
+ "result.items.2.amount": 8.5
190
+ }
191
+ }
192
+ },
193
+ {
194
+ "id": "null-settings-refused",
195
+ "tool": "access_check",
196
+ "args": {
197
+ "requests": "fixtures/access-requests.csv",
198
+ "settings": null,
199
+ "as_of": "2026-11-15"
200
+ },
201
+ "expect": {
202
+ "status": "error"
203
+ }
204
+ },
205
+ {
206
+ "id": "no-settings-defaults",
207
+ "tool": "access_check",
208
+ "args": {
209
+ "requests": "fixtures/access-requests.csv",
210
+ "as_of": "2026-11-15"
211
+ },
212
+ "expect": {
213
+ "equals": {
214
+ "result.by_status.past_due": 1
215
+ },
216
+ "not_contains": [
217
+ "\"fee_over_limit\""
218
+ ]
219
+ }
220
+ },
221
+ {
222
+ "id": "extension-moves-deadline",
223
+ "tool": "access_check",
224
+ "args": {
225
+ "requests": "fixtures/access-requests.csv",
226
+ "settings": "fixtures/settings.json",
227
+ "as_of": "2026-11-15",
228
+ "status": "extension_no_notice"
229
+ },
230
+ "expect": {
231
+ "equals": {
232
+ "result.items.0.due": "2026-11-14",
233
+ "result.items.0.days": 10
234
+ }
235
+ }
236
+ },
237
+ {
238
+ "id": "file-outside-root-refused",
239
+ "tool": "access_check",
240
+ "args": {
241
+ "requests": "../../outside-root.csv",
242
+ "settings": "fixtures/settings.json",
243
+ "as_of": "2026-11-15"
244
+ },
245
+ "expect": {
246
+ "status": "error",
247
+ "contains": [
248
+ "outside the allowed root"
249
+ ]
250
+ }
251
+ },
252
+ {
253
+ "id": "missing-file-named",
254
+ "tool": "access_check",
255
+ "args": {
256
+ "requests": "fixtures/missing-export.csv",
257
+ "settings": "fixtures/settings.json",
258
+ "as_of": "2026-11-15"
259
+ },
260
+ "expect": {
261
+ "status": "error",
262
+ "contains": [
263
+ "not found",
264
+ "missing-export.csv"
265
+ ]
266
+ }
267
+ }
268
+ ]
269
+ }
@@ -0,0 +1,6 @@
1
+ # Fixtures
2
+
3
+ Fictional data only: Bluewater Family Medicine (a made-up practice) and made-up patients. Any likeness to real people is chance.
4
+
5
+ - `access-requests.csv`: Planted: a request answered in 11 days (AR-1001, clean), paper copies sent 8 days late and charged 25.00 against an allowed 15.00 (AR-1002), an open request 15 days past due (AR-1003), an extension whose notice went out after the first 30 days and 10 paper pages charged 8.00 against an allowed 7.50 (AR-1004), a request due within 7 days (AR-1005), a denial with no reason or date recorded (AR-1006), an email copy charged 15.00 against the 6.50 flat fee (AR-1007) and a new request not due yet (AR-1008).
6
+ - `settings.json`: 30 days plus one 30-day extension, a 6.50 flat fee for electronic copies, paper at 5.00 plus 0.25 a page, capped at 50. These are examples; use your policy and state law. `settings-typo.json` misspells a setting and is refused.
@@ -0,0 +1,9 @@
1
+ Request #,Patient #,Patient Name,Date Received,Requested By,Format,Pages,Extended,Extension Notice,Date Sent,Denied,Denial Reason,Fee Charged,Postage
2
+ AR-1001,P5001,Opal Hendricks,2026-09-01,patient,portal,,no,,2026-09-12,,,0,
3
+ AR-1002,P5002,Wesley Carver,2026-09-20,patient,paper,40,no,,2026-10-28,,,25.00,
4
+ AR-1003,P5003,Imani Rhodes,2026-10-01,patient,electronic,,no,,,,,,
5
+ AR-1004,P5004,Gustav Lindqvist,2026-09-15,personal representative,paper,10,yes,2026-10-25,2026-11-10,,,8.00,
6
+ AR-1005,P5005,Rosa Delgado,2026-10-20,patient,electronic,,no,,,,,,
7
+ AR-1006,P5006,Elliot Shaw,2026-08-10,patient,paper,,no,,,yes,,,
8
+ AR-1007,P5007,Mina Kaur,2026-10-02,patient,email,,no,,2026-10-09,,,15.00,
9
+ AR-1008,P5008,Abel Ferreira,2026-11-10,patient,portal,,no,,,,,,
@@ -0,0 +1,126 @@
1
+ {
2
+ "case": "totals",
3
+ "id": [
4
+ [
5
+ "request_id"
6
+ ]
7
+ ],
8
+ "planted": [
9
+ ["AR-1003", "past_due"],
10
+ ["AR-1002", "fulfilled_late"],
11
+ ["AR-1004", "extension_no_notice"],
12
+ ["AR-1006", "denial_no_reason"],
13
+ ["AR-1002", "fee_over_limit"],
14
+ ["AR-1004", "fee_over_limit"],
15
+ ["AR-1007", "fee_over_limit"],
16
+ ["AR-1005", "due_soon"]
17
+ ],
18
+ "clean": [
19
+ {
20
+ "arg": "requests",
21
+ "set": [
22
+ {
23
+ "where": ["Request #", "AR-1003"],
24
+ "column": "Date Sent",
25
+ "value": "2026-10-20"
26
+ },
27
+ {
28
+ "where": ["Request #", "AR-1002"],
29
+ "column": "Date Sent",
30
+ "value": "2026-10-15"
31
+ },
32
+ {
33
+ "where": ["Request #", "AR-1002"],
34
+ "column": "Fee Charged",
35
+ "value": "15.00"
36
+ },
37
+ {
38
+ "where": ["Request #", "AR-1004"],
39
+ "column": "Extension Notice",
40
+ "value": "2026-10-10"
41
+ },
42
+ {
43
+ "where": ["Request #", "AR-1004"],
44
+ "column": "Fee Charged",
45
+ "value": "7.50"
46
+ },
47
+ {
48
+ "where": ["Request #", "AR-1006"],
49
+ "column": "Denial Reason",
50
+ "value": "psychotherapy notes"
51
+ },
52
+ {
53
+ "where": ["Request #", "AR-1006"],
54
+ "column": "Date Sent",
55
+ "value": "2026-08-20"
56
+ },
57
+ {
58
+ "where": ["Request #", "AR-1007"],
59
+ "column": "Fee Charged",
60
+ "value": "6.50"
61
+ },
62
+ {
63
+ "where": ["Request #", "AR-1005"],
64
+ "column": "Date Sent",
65
+ "value": "2026-11-10"
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ "mutations": [
71
+ {
72
+ "name": "a fee for a portal copy over the flat fee",
73
+ "edits": [
74
+ {
75
+ "arg": "requests",
76
+ "set": [
77
+ {
78
+ "where": ["Request #", "AR-1001"],
79
+ "column": "Fee Charged",
80
+ "value": "10"
81
+ }
82
+ ]
83
+ }
84
+ ],
85
+ "expect": [
86
+ ["AR-1001", "fee_over_limit"]
87
+ ]
88
+ },
89
+ {
90
+ "name": "received a month earlier, still open",
91
+ "edits": [
92
+ {
93
+ "arg": "requests",
94
+ "set": [
95
+ {
96
+ "where": ["Request #", "AR-1008"],
97
+ "column": "Date Received",
98
+ "value": "2026-10-12"
99
+ }
100
+ ]
101
+ }
102
+ ],
103
+ "expect": [
104
+ ["AR-1008", "past_due"]
105
+ ]
106
+ },
107
+ {
108
+ "name": "sent after 34 days",
109
+ "edits": [
110
+ {
111
+ "arg": "requests",
112
+ "set": [
113
+ {
114
+ "where": ["Request #", "AR-1001"],
115
+ "column": "Date Sent",
116
+ "value": "2026-10-05"
117
+ }
118
+ ]
119
+ }
120
+ ],
121
+ "expect": [
122
+ ["AR-1001", "fulfilled_late"]
123
+ ]
124
+ }
125
+ ]
126
+ }
@@ -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": ["Opal Hendricks", "Wesley Carver", "Imani Rhodes", "Gustav Lindqvist", "Rosa Delgado", "Elliot Shaw", "Mina Kaur", "P5003"] }
@@ -0,0 +1 @@
1
+ { "response_dayz": 15 }
@@ -0,0 +1 @@
1
+ { "response_days": 30, "extension_days": 30, "warn_days": 7, "flat_fee": 6.5, "per_page": 0.25, "base_fee": 5, "fee_cap": 50 }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "fairpractice-records-requests",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.fpavia111-creator/fairpractice-records-requests",
5
+ "description": "Patient right-of-access requests: the 30-day clock and one 30-day extension, requests past due, extensions without a written notice, fees above your limit or the flat fee, and denials without a reason.",
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-records-requests": "bin/fairpractice-records-requests.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-records-requests.js demo",
33
+ "eval": "node bin/fairpractice-records-requests.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-records-requests"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairpractice-agents/tree/master/packages/fairpractice-records-requests#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
+ "hipaa",
55
+ "right-of-access",
56
+ "medical-records",
57
+ "ocr"
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-records-requests",
4
+ "title": "Fairpractice Records Requests",
5
+ "description": "Patient right-of-access requests",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairpractice-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairpractice-records-requests"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairpractice.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairpractice-records-requests",
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: 'access-requests.csv', settings: 'settings.json', as_of: '2026-11-15' };
5
+ export const demo = () => runDemo(manifest, new URL('../fixtures', import.meta.url), 'Fairpractice Records Requests', [
6
+ { label: 'Check this quarter\'s access requests', tool: 'access_check', args: f, list: (i) => `${i.status.padEnd(20)} ${i.message}` },
7
+ { label: 'Write the privacy meeting list', tool: 'access_write_report', args: f },
8
+ { label: 'Agent tries to release records itself', tool: 'records_release', args: {} },
9
+ ]);
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { manifest } from './manifest.js';
2
+ export * from './logic.js';
package/src/logic.js ADDED
@@ -0,0 +1,55 @@
1
+ // Fairpractice Records Requests logic: patient right-of-access requests against the response clock and fee limits. No I/O.
2
+ import { str, num, isoDate, addDays, daysBetween, yes, round2, sortByStatus, countBy } from 'fairpractice-core';
3
+
4
+ const ORDER = { past_due: 0, fulfilled_late: 1, extension_no_notice: 2, denial_no_reason: 3, fee_over_limit: 4, due_soon: 5 };
5
+
6
+ /** Fee allowed for a request under the settings: a flat fee for electronic copies when chosen, else per page plus postage, capped. */
7
+ export function feeAllowed(r, { flatFee = null, perPage = null, base = 0, cap = null } = {}) {
8
+ const electronic = /electr|portal|email|e-mail|usb|cd|digital/i.test(str(r.format));
9
+ let allowed = null;
10
+ if (electronic && flatFee !== null) allowed = flatFee;
11
+ else if (perPage !== null && num(r.pages) !== null) allowed = round2(base + perPage * num(r.pages) + (num(r.postage) || 0));
12
+ if (cap !== null) allowed = allowed === null ? cap : Math.min(allowed, cap);
13
+ return allowed;
14
+ }
15
+
16
+ /**
17
+ * rows: [{ request_id, patient_id, patient_name, received, requester_type, format, pages, extended, extension_notice_on, fulfilled, denied, denial_reason, fee, postage }]
18
+ * opts: { asOf, responseDays = 30, extensionDays = 30, warnDays = 7, fees: { flatFee, perPage, base, cap } }
19
+ */
20
+ export function checkAccess(rows, { asOf, responseDays = 30, extensionDays = 30, warnDays = 7, fees = {} } = {}) {
21
+ const items = []; let open = 0; let closed = 0; const turnaround = [];
22
+ for (const [i, r] of rows.entries()) {
23
+ const rec = isoDate(r.received); if (!rec) continue;
24
+ const firstDue = addDays(rec, responseDays);
25
+ const ext = yes(r.extended) || !!isoDate(r.extension_notice_on);
26
+ const notice = isoDate(r.extension_notice_on);
27
+ const due = ext ? addDays(firstDue, extensionDays) : firstDue;
28
+ const done = isoDate(r.fulfilled) || (yes(r.denied) ? isoDate(r.denied_on) || isoDate(r.fulfilled) : null);
29
+ const base = { request_id: str(r.request_id) || `line ${i + 1}`, patient_id: str(r.patient_id) || null, patient_name: str(r.patient_name) || null, received: rec, due, fulfilled: done, requester_type: str(r.requester_type) || null, line: i + 1 };
30
+ const deniedUndated = yes(r.denied) && !done;
31
+ if (done) { closed++; turnaround.push(daysBetween(rec, done)); } else if (deniedUndated) closed++; else open++;
32
+ if (ext && (!notice || notice > firstDue)) items.push({ ...base, status: 'extension_no_notice', days: notice ? daysBetween(firstDue, notice) : null, amount: 0 });
33
+ if (!done && !deniedUndated && asOf > due) items.push({ ...base, status: 'past_due', days: daysBetween(due, asOf), amount: 0 });
34
+ else if (!done && !deniedUndated && daysBetween(asOf, due) <= warnDays) items.push({ ...base, status: 'due_soon', days: daysBetween(asOf, due), amount: 0 });
35
+ if (done && done > due) items.push({ ...base, status: 'fulfilled_late', days: daysBetween(due, done), amount: 0 });
36
+ if (yes(r.denied) && !str(r.denial_reason)) items.push({ ...base, status: 'denial_no_reason', days: null, amount: 0 });
37
+ const fee = num(r.fee);
38
+ if (fee !== null && fee > 0) {
39
+ const allowed = feeAllowed(r, fees);
40
+ if (allowed !== null && fee > allowed + 0.005) items.push({ ...base, status: 'fee_over_limit', days: null, fee, fee_allowed: allowed, amount: round2(fee - allowed) });
41
+ }
42
+ }
43
+ const T = {
44
+ past_due: (x) => [`Request ${x.request_id} received ${x.received} was due ${x.due} and is ${x.days} day(s) late.`, 'Send the records now; late access is the most common reason for an OCR fine.'],
45
+ fulfilled_late: (x) => [`Request ${x.request_id} was answered ${x.fulfilled}, ${x.days} day(s) after the ${x.due} deadline.`, 'Note the cause in the log and fix the step that slowed it.'],
46
+ extension_no_notice: (x) => [`Request ${x.request_id} was extended without a written notice inside the first ${'30'} days${x.days ? ` (notice ${x.days} day(s) late)` : ''}.`, 'An extension needs a written notice with the reason and the new date before the first deadline.'],
47
+ denial_no_reason: (x) => [`Request ${x.request_id} was denied with no reason recorded.`, 'A denial needs a written reason and, where it applies, review rights.'],
48
+ fee_over_limit: (x) => [`Request ${x.request_id} was charged ${x.fee}; your fee settings allow ${x.fee_allowed}.`, 'Refund the difference and correct the fee method.'],
49
+ due_soon: (x) => [`Request ${x.request_id} is due ${x.due} (in ${x.days} day(s)).`, 'Finish it, or send a written extension notice before the deadline.'],
50
+ };
51
+ for (const it of items) { const [m, f] = T[it.status](it); it.message = m.replace("'30'", String(responseDays)).replace(`first 30 days`, `first ${responseDays} days`); it.fix = f; }
52
+ sortByStatus(items, ORDER, 'days');
53
+ const avg = turnaround.length ? round2(turnaround.reduce((s, x) => s + x, 0) / turnaround.length) : null;
54
+ return { requests: rows.length, open, closed, average_days_to_answer: avg, overcharged: round2(items.filter((i) => i.status === 'fee_over_limit').reduce((s, x) => s + x.amount, 0)), by_status: countBy(items, 'status'), items };
55
+ }
@@ -0,0 +1,74 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { medAgent, fileArg, AS_OF_ARG, PATIENT_ID, PATIENT_NAME, PRACTICE_LIMITS, today } from 'fairpractice-core';
3
+ import { checkAccess } 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 #', 'Request', 'ROI #', 'Log #', 'Ticket'], { translate: false }),
10
+ patient_id: PATIENT_ID, patient_name: PATIENT_NAME,
11
+ received: t(['Received', 'Date Received', 'Received On', 'Request Date', 'Requested'], { type: 'date', required: true }),
12
+ requester_type: t(['Requester Type', 'Requested By', 'Requester', 'Request Type']),
13
+ format: t(['Format', 'Delivery', 'Media', 'Copy Format', 'Delivery Method']),
14
+ pages: t(['Pages', 'Page Count', '# Pages'], { type: 'number' }),
15
+ extended: t(['Extended', 'Extension', 'Extension Taken']),
16
+ extension_notice_on: t(['Extension Notice', 'Extension Notice Date', 'Extension Letter Sent'], { type: 'date' }),
17
+ fulfilled: t(['Fulfilled', 'Completed', 'Sent', 'Date Sent', 'Closed', 'Released', 'Date Completed'], { type: 'date' }),
18
+ denied: t(['Denied', 'Denial']),
19
+ denied_on: t(['Denied On', 'Denial Date'], { type: 'date' }),
20
+ denial_reason: t(['Denial Reason', 'Reason Denied', 'Reason']),
21
+ fee: t(['Fee', 'Fee Charged', 'Charge', 'Amount Charged'], { type: 'money' }),
22
+ postage: t(['Postage', 'Shipping'], { type: 'money' }),
23
+ });
24
+
25
+ const SETTINGS = { type: 'object', additionalProperties: false, properties: {
26
+ response_days: { type: 'integer', minimum: 1, maximum: 60, description: 'Calendar days to answer (HIPAA: 30; some states are shorter)' },
27
+ extension_days: { type: 'integer', minimum: 0, maximum: 30, description: 'Days one extension adds (HIPAA: 30)' },
28
+ warn_days: { type: 'integer', minimum: 0, maximum: 30, description: 'Days ahead to warn; default 7' },
29
+ flat_fee: { type: ['number', 'null'], minimum: 0, description: 'Flat fee you charge for electronic copies (HHS describes $6.50 as an option), or null' },
30
+ per_page: { type: ['number', 'null'], minimum: 0, description: 'Per-page fee for paper copies under your policy or state law, or null' },
31
+ base_fee: { type: 'number', minimum: 0, description: 'Fixed fee added to per-page fees (labor or search fee your state allows), default 0' },
32
+ fee_cap: { type: ['number', 'null'], minimum: 0, description: 'Most you charge for one request, or null' },
33
+ } };
34
+
35
+ const args = {
36
+ requests: fileArg('Access request log under --root: request, patient, received date, requester type, format, pages, extension, notice date, fulfilled or denied date, reason and fee'),
37
+ settings: fileArg('Optional settings JSON: response_days, extension_days, warn_days, flat_fee, per_page, base_fee, fee_cap'),
38
+ as_of: AS_OF_ARG,
39
+ };
40
+ const run = (a, ctx) => {
41
+ const s = a.settings ? ctx.readJson(a.settings, 'access_settings') : {};
42
+ return checkAccess(ctx.records(a.requests, 'requests'), { asOf: a.as_of || today(), responseDays: s.response_days ?? 30, extensionDays: s.extension_days ?? 30, warnDays: s.warn_days ?? 7, fees: { flatFee: s.flat_fee ?? null, perPage: s.per_page ?? null, base: s.base_fee ?? 0, cap: s.fee_cap ?? null } });
43
+ };
44
+ const summary = (o) => `${o.requests} request(s): ${o.open} open, ${o.closed} answered, ${o.average_days_to_answer ?? 'n/a'} days on average. ${o.items.length} finding(s): ${Object.entries(o.by_status).map(([k, v]) => `${k} ${v}`).join(', ') || 'none'}. Overcharged ${o.overcharged}.`;
45
+
46
+ export const manifest = medAgent({
47
+ pkg, prefix: 'access', title: 'Fairpractice Records Requests',
48
+ description: 'Tracks patient right-of-access requests against the HIPAA clock (30 days plus one 30-day extension with written notice, or your shorter state limit): requests past due or due soon, answered late, extensions with no timely notice, denials with no reason and fees above your fee settings. Patient names are masked before results reach the model.',
49
+ args, required: ['requests'],
50
+ sources: { requests: { label: 'Access request log', args: ['requests'], fields: REQUEST_FIELDS } },
51
+ configSchemas: { access_settings: SETTINGS }, memoryKinds: {},
52
+ run, summary,
53
+ check: { title: 'Check access requests', description: 'List access requests that are late, due soon, extended without notice, denied without a reason or overcharged.' },
54
+ report: {
55
+ title: { en: 'Patient access requests', es: 'Solicitudes de acceso de pacientes', de: 'Auskunftsersuchen von Patienten', fr: 'Demandes d\'accès des patients', pt: 'Pedidos de acesso de pacientes', it: 'Richieste di accesso dei pazienti', ja: '患者の記録開示請求', zh: '患者查阅请求', ko: '환자 열람 요청' },
56
+ base: 'access-requests',
57
+ rows: (o) => o.items.map((i) => ({ status: i.status, request_id: i.request_id, patient_id: i.patient_id, patient_name: i.patient_name, received: i.received, due: i.due, fulfilled: i.fulfilled || '', amount: i.amount, message: i.message, fix: i.fix })),
58
+ htmlColumns: ['status', 'request_id', 'patient_name', 'received', 'due', 'fulfilled', 'message', 'fix'],
59
+ sections: (o) => [{ title: { en: 'Findings by type' }, rows: Object.entries(o.by_status).map(([status, count]) => ({ status, count })), columns: ['status', 'count'] }],
60
+ limits: [PRACTICE_LIMITS.files, 'Deadlines count calendar days from the received date. Requests from third parties under a patient authorization follow other rules; mark them in requester_type.', PRACTICE_LIMITS.advice, PRACTICE_LIMITS.phi],
61
+ },
62
+ refused: [
63
+ { name: 'records_release', category: 'binding_send', description: 'Fairpractice Records Requests never sends records to anyone; your release-of-information staff do.' },
64
+ { name: 'refund_issue', category: 'payment', description: 'Fairpractice Records Requests never issues refunds.' },
65
+ ],
66
+ prompt: { title: 'Right-of-access review', description: 'Walks the host model through a weekly access request review with Fairpractice Records Requests.', text: `You are helping a privacy officer or release-of-information lead with fairpractice-records-requests.
67
+
68
+ Rules: Fairpractice Records Requests only reads the log. Patient names in results are pseudonyms.
69
+
70
+ 1. Call access_check with the request log, settings and as_of.
71
+ 2. Lead with past_due, then due_soon, so nothing new goes late.
72
+ 3. Explain extension_no_notice and fee_over_limit in one line each.
73
+ 4. Call access_write_report for the weekly privacy meeting.` },
74
+ });