fairpractice-unsigned-encounters 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,6 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ - First version (Fairpractice wave 2, ver 1).
6
+ - Final pass (19 Nov 2026): provider names are masked before results reach the model, as the limits text says staff names are (they were sent as written).
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,155 @@
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 Unsigned Encounters (`fairpractice-unsigned-encounters`)
4
+
5
+ Lists unsigned and open encounters that hold claims, by provider: counts, dollars on hold and days open against your signing and escalation policy, encounters close to your filing limit, and encounters signed late. It reads encounter status and dates only and never opens or reads a note. Patient names are masked before results reach the model.
6
+
7
+ **Fairpractice Unsigned Encounters never opens or reads a clinical note. Fairpractice Unsigned Encounters never signs or closes an encounter; only the provider does.**
8
+
9
+ Fairpractice wave 2 ver 1 · Coding integrity (no reading of notes, no code suggestions) · 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-unsigned-encounters demo
13
+ npx -y fairpractice-unsigned-encounters 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 providers. The file has status and dates only, as the agent needs; there is no note text. Checked on 15 November 2026.
19
+
20
+ - [`encounters.csv`](fixtures/encounters.csv): eight encounters. Planted: E-6004 has been pending signature since 1 September (75 days, inside 30 days of the 90-day filing setting); E-6003 is unsigned after 26 days (past the 14-day escalation); E-6002 (5 days) and E-6008 (10 days, "In progress") are past the 3-day signing policy; E-6006 was signed 12 days after the visit. E-6005 is from yesterday and still inside the policy; E-6001 and E-6007 are clean.
21
+ - [`settings.json`](fixtures/settings.json): sign in 3 days, escalate at 14, a 90-day filing setting with a 30-day warning, and a 30-day look-back for late signatures. [`settings-typo.json`](fixtures/settings-typo.json) misspells a setting and is refused.
22
+
23
+ ## A demo run
24
+
25
+ `npx -y fairpractice-unsigned-encounters demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
26
+
27
+ ```text
28
+ Fairpractice Unsigned Encounters demo (fictional practice, patients, staff and payers)
29
+
30
+ ▶ Check open encounters and dollars on hold
31
+ status: executed decision: allow
32
+ 8 encounter(s), 5 still open, 1070 in charges on hold. 5 finding(s): filing_risk 1, unsigned_escalate 1, unsigned_over_policy 2, signed_late 1.
33
+ filing_risk Encounter E-6004 (PT-646d5861, 2026-09-01) has been open 75 days; 15 day(s) remain before your 90-day filing setting.
34
+ unsigned_escalate Encounter E-6003 (PT-698f6ac7, 2026-10-20) is still open after 26 days, past your 14-day escalation point.
35
+ unsigned_over_policy Encounter E-6008 (PT-c98e8004, 2026-11-05) is open 10 days, past your 3-day signing policy.
36
+ unsigned_over_policy Encounter E-6002 (PT-698f6ac7, 2026-11-10) is open 5 days, past your 3-day signing policy.
37
+ signed_late Encounter E-6006 (PT-646d5861) was signed 2026-11-09, 12 days after the visit.
38
+
39
+ ▶ Write the provider huddle list
40
+ status: executed decision: allow
41
+ Unsigned encounters holding claims written: 8 encounter(s), 5 still open, 1070 in charges on hold. 5 finding(s): filing_risk 1, unsigned_escalate 1, unsigned_over_policy 2, signed_late 1. Files: fairpractice-out/unsigned/unsigned-encounters.csv, fairpractice-out/unsigned/unsigned-encounters.html.
42
+
43
+ ▶ Agent tries to read a note
44
+ status: blocked decision: block
45
+ reason: Fairpractice Unsigned Encounters never opens or reads a clinical note.
46
+ ```
47
+
48
+ ## Tools
49
+
50
+ | Tool | What it does | Policy |
51
+ |---|---|---|
52
+ | `unsigned_check` | List open encounters near the filing limit, past escalation or past the signing policy, and encounters signed late, with dollars on hold by provider. | runs |
53
+ | `unsigned_write_report` | Write unsigned-encounters.csv (one row per item, with blank owner and decision columns) and unsigned-encounters.html into out_dir (default fairpractice-out/unsigned). | runs |
54
+ | `unsigned_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
55
+ | `unsigned_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
56
+ | `unsigned_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
57
+ | `unsigned_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
58
+ | `note_read` | Fairpractice Unsigned Encounters never opens or reads a clinical note. | refused |
59
+ | `note_sign` | Fairpractice Unsigned Encounters never signs or closes an encounter; only the provider does. | refused |
60
+
61
+ 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.
62
+
63
+ ### `unsigned_check` arguments
64
+
65
+ | Argument | What it is |
66
+ |---|---|
67
+ | `encounters` (required) | Encounter status export under --root: encounter, patient, provider, date of service, note status, signed date, charge amount and payer. Status and dates only; no note text |
68
+ | `settings` | Optional settings JSON: sign_days, escalate_days, filing_days, filing_warn_days, late_lookback_days |
69
+ | `as_of` | Date to measure deadlines and ages from (YYYY-MM-DD); default today |
70
+ | `status` | Only items with this status |
71
+ | `limit` | Most items to return to the model (the report file always has all of them) |
72
+
73
+ ## Columns it reads
74
+
75
+ 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.
76
+
77
+ 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-unsigned-encounters inspect <file>` (column names and shapes only, never values) and name any column it misses in `remedy-sources.json`.
78
+
79
+ ### Encounter status (`encounters`)
80
+
81
+ | Column | Type | Read from |
82
+ |---|---|---|
83
+ | `encounter_id` | text | Encounter, Encounter ID, Encounter #, Visit ID, Visit #, CSN |
84
+ | `patient_id` | text (masked) | Patient ID, Patient #, Patient Number, MRN, Medical Record Number, Chart #, Chart Number, Account # |
85
+ | `patient_name` | text (masked) | Patient, Patient Name, Name, Client, Client Name, Member, Member Name, Beneficiary |
86
+ | `provider` | text (masked) | Provider, Rendering Provider, Rendering, Clinician, Therapist, Physician, Doctor, Practitioner |
87
+ | `dos` (required) | date | Date of Service, DOS, Service Date, Visit Date, Date, From DOS, Session Date, Appointment Date |
88
+ | `status` | text | Status, Note Status, Encounter Status, Sign Status, Documentation Status |
89
+ | `signed_date` | date | Signed, Signed Date, Signed On, Closed Date, Finalized |
90
+ | `charge` | amount | Charge, Charges, Billed, Billed Amount, Amount, Fee, Total Charge |
91
+ | `payer` | text | Payer, Payer Name, Primary Payer, Insurance, Insurance Name, Plan, Plan Name, Payor |
92
+
93
+ ## Settings file (`unsigned_settings`)
94
+
95
+ 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.
96
+
97
+ | Setting | What it does |
98
+ |---|---|
99
+ | `sign_days` | Days your policy gives a provider to sign; default 3 |
100
+ | `escalate_days` | Days open before escalation; default 14 |
101
+ | `filing_days` | Your tightest payer filing limit in days from the visit; default 90 |
102
+ | `filing_warn_days` | Days before the filing limit to list an open encounter first; default 30 |
103
+ | `late_lookback_days` | Encounters signed late within this many days are listed for feedback; default 30 |
104
+
105
+ ## Memory
106
+
107
+ `unsigned_learn` only proposes a fact; nothing changes until a named person accepts it with `unsigned_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.
108
+
109
+ | Kind | What an accepted fact does |
110
+ |---|---|
111
+
112
+ ## Install
113
+
114
+ Node 20 or newer. No other runtime dependencies besides `fairpractice-core` and `fairclaim-core`.
115
+
116
+ ```json
117
+ {
118
+ "mcpServers": {
119
+ "fairpractice-unsigned-encounters": {
120
+ "command": "npx",
121
+ "args": [
122
+ "-y",
123
+ "fairpractice-unsigned-encounters",
124
+ "mcp",
125
+ "--root",
126
+ "/path/to/practice-files"
127
+ ]
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ Claude Code: `claude mcp add fairpractice-unsigned-encounters -- npx -y fairpractice-unsigned-encounters mcp --root .`, or use the plugin files in this folder.
134
+
135
+ ## CLI
136
+
137
+ ```bash
138
+ fairpractice-unsigned-encounters tools # every tool, its policy and arguments
139
+ fairpractice-unsigned-encounters sources # the columns each input is read from
140
+ fairpractice-unsigned-encounters inspect <file> # how a file would be read (names and shapes, never values)
141
+ fairpractice-unsigned-encounters call unsigned_check '{"encounters":"<encounters>"}'
142
+ fairpractice-unsigned-encounters eval # the private eval cases on the fictional fixtures
143
+ fairpractice-unsigned-encounters demo
144
+ ```
145
+
146
+ ## Patient and staff data
147
+
148
+ 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.
149
+
150
+ ## Limits
151
+
152
+ - 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.
153
+ - 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.
154
+ - 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.
155
+ - 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-unsigned-encounters', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,290 @@
1
+ {
2
+ "suite": "fairpractice-unsigned-encounters",
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": "unsigned_recall",
9
+ "args": {},
10
+ "expect": {
11
+ "status": "executed",
12
+ "contains": [
13
+ "memory is empty"
14
+ ]
15
+ }
16
+ },
17
+ {
18
+ "id": "refuses-note_read",
19
+ "tool": "note_read",
20
+ "args": {},
21
+ "expect": {
22
+ "status": "blocked"
23
+ }
24
+ },
25
+ {
26
+ "id": "refuses-note_sign",
27
+ "tool": "note_sign",
28
+ "args": {},
29
+ "expect": {
30
+ "status": "blocked"
31
+ }
32
+ },
33
+ {
34
+ "id": "report",
35
+ "tool": "unsigned_write_report",
36
+ "args": {
37
+ "encounters": "fixtures/encounters.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": "unsigned_check",
52
+ "args": {
53
+ "encounters": "fixtures/encounters.csv",
54
+ "settings": "fixtures/settings.json",
55
+ "as_of": "2026-11-15"
56
+ },
57
+ "expect": {
58
+ "status": "executed",
59
+ "equals": {
60
+ "result.encounters": 8,
61
+ "result.open": 5,
62
+ "result.on_hold": 1070
63
+ }
64
+ }
65
+ },
66
+ {
67
+ "id": "every-planted-status-in-order",
68
+ "tool": "unsigned_check",
69
+ "args": {
70
+ "encounters": "fixtures/encounters.csv",
71
+ "settings": "fixtures/settings.json",
72
+ "as_of": "2026-11-15"
73
+ },
74
+ "expect": {
75
+ "equals": {
76
+ "result.items.0.status": "filing_risk",
77
+ "result.items.1.status": "unsigned_escalate",
78
+ "result.items.2.status": "unsigned_over_policy",
79
+ "result.items.3.status": "unsigned_over_policy",
80
+ "result.items.4.status": "signed_late"
81
+ },
82
+ "length": {
83
+ "result.items": 5
84
+ }
85
+ }
86
+ },
87
+ {
88
+ "id": "status-filter",
89
+ "tool": "unsigned_check",
90
+ "args": {
91
+ "encounters": "fixtures/encounters.csv",
92
+ "settings": "fixtures/settings.json",
93
+ "as_of": "2026-11-15",
94
+ "status": "filing_risk"
95
+ },
96
+ "expect": {
97
+ "status": "executed",
98
+ "equals": {
99
+ "result.items.0.status": "filing_risk"
100
+ }
101
+ }
102
+ },
103
+ {
104
+ "id": "limit-one",
105
+ "tool": "unsigned_check",
106
+ "args": {
107
+ "encounters": "fixtures/encounters.csv",
108
+ "settings": "fixtures/settings.json",
109
+ "as_of": "2026-11-15",
110
+ "limit": 1
111
+ },
112
+ "expect": {
113
+ "status": "executed",
114
+ "length": {
115
+ "result.items": 1
116
+ }
117
+ }
118
+ },
119
+ {
120
+ "id": "report-spanish",
121
+ "tool": "unsigned_write_report",
122
+ "args": {
123
+ "encounters": "fixtures/encounters.csv",
124
+ "settings": "fixtures/settings.json",
125
+ "as_of": "2026-11-15",
126
+ "language": "es"
127
+ },
128
+ "expect": {
129
+ "status": "executed"
130
+ }
131
+ },
132
+ {
133
+ "id": "report-japanese",
134
+ "tool": "unsigned_write_report",
135
+ "args": {
136
+ "encounters": "fixtures/encounters.csv",
137
+ "settings": "fixtures/settings.json",
138
+ "as_of": "2026-11-15",
139
+ "language": "ja"
140
+ },
141
+ "expect": {
142
+ "status": "executed",
143
+ "matches": [
144
+ "\\.html"
145
+ ]
146
+ }
147
+ },
148
+ {
149
+ "id": "typo-setting-refused",
150
+ "tool": "unsigned_check",
151
+ "args": {
152
+ "encounters": "fixtures/encounters.csv",
153
+ "settings": "fixtures/settings-typo.json",
154
+ "as_of": "2026-11-15"
155
+ },
156
+ "expect": {
157
+ "status": "error"
158
+ }
159
+ },
160
+ {
161
+ "id": "null-settings-refused",
162
+ "tool": "unsigned_check",
163
+ "args": {
164
+ "encounters": "fixtures/encounters.csv",
165
+ "settings": null,
166
+ "as_of": "2026-11-15"
167
+ },
168
+ "expect": {
169
+ "status": "error"
170
+ }
171
+ },
172
+ {
173
+ "id": "file-outside-root-refused",
174
+ "tool": "unsigned_check",
175
+ "args": {
176
+ "encounters": "../../outside-root.csv",
177
+ "settings": "fixtures/settings.json",
178
+ "as_of": "2026-11-15"
179
+ },
180
+ "expect": {
181
+ "status": "error",
182
+ "contains": [
183
+ "outside the allowed root"
184
+ ]
185
+ }
186
+ },
187
+ {
188
+ "id": "missing-file-named",
189
+ "tool": "unsigned_check",
190
+ "args": {
191
+ "encounters": "fixtures/missing-export.csv",
192
+ "settings": "fixtures/settings.json",
193
+ "as_of": "2026-11-15"
194
+ },
195
+ "expect": {
196
+ "status": "error",
197
+ "contains": [
198
+ "not found",
199
+ "missing-export.csv"
200
+ ]
201
+ }
202
+ },
203
+ {
204
+ "id": "no-settings-defaults",
205
+ "tool": "unsigned_check",
206
+ "args": {
207
+ "encounters": "fixtures/encounters.csv",
208
+ "as_of": "2026-11-15"
209
+ },
210
+ "expect": {
211
+ "status": "executed",
212
+ "equals": {
213
+ "result.by_status.filing_risk": 1,
214
+ "result.by_status.unsigned_over_policy": 2
215
+ }
216
+ }
217
+ },
218
+ {
219
+ "id": "filing-days-left",
220
+ "tool": "unsigned_check",
221
+ "args": {
222
+ "encounters": "fixtures/encounters.csv",
223
+ "settings": "fixtures/settings.json",
224
+ "as_of": "2026-11-15",
225
+ "status": "filing_risk"
226
+ },
227
+ "expect": {
228
+ "equals": {
229
+ "result.items.0.encounter_id": "E-6004",
230
+ "result.items.0.days": 75,
231
+ "result.items.0.days_left": 15
232
+ }
233
+ }
234
+ },
235
+ {
236
+ "id": "provider-rollup",
237
+ "tool": "unsigned_check",
238
+ "args": {
239
+ "encounters": "fixtures/encounters.csv",
240
+ "settings": "fixtures/settings.json",
241
+ "as_of": "2026-11-15"
242
+ },
243
+ "expect": {
244
+ "equals": {
245
+ "result.by_provider.0.open": 3,
246
+ "result.by_provider.0.amount": 555
247
+ },
248
+ "matches": [
249
+ "\"by_provider\":..\"provider\":\"PT-[0-9a-f]{8}\""
250
+ ],
251
+ "not_contains": [
252
+ "Marcus Bello"
253
+ ]
254
+ },
255
+ "note": "Provider names reach the model as pseudonyms (masked like patient names); the report file keeps the real name."
256
+ },
257
+ {
258
+ "id": "inside-policy-not-listed",
259
+ "tool": "unsigned_check",
260
+ "args": {
261
+ "encounters": "fixtures/encounters.csv",
262
+ "settings": "fixtures/settings.json",
263
+ "as_of": "2026-11-15"
264
+ },
265
+ "expect": {
266
+ "not_contains": [
267
+ "E-6005",
268
+ "E-6001",
269
+ "E-6007"
270
+ ]
271
+ }
272
+ },
273
+ {
274
+ "id": "longest-open-first",
275
+ "tool": "unsigned_check",
276
+ "args": {
277
+ "encounters": "fixtures/encounters.csv",
278
+ "settings": "fixtures/settings.json",
279
+ "as_of": "2026-11-15",
280
+ "status": "unsigned_over_policy"
281
+ },
282
+ "expect": {
283
+ "equals": {
284
+ "result.items.0.encounter_id": "E-6008",
285
+ "result.items.1.encounter_id": "E-6002"
286
+ }
287
+ }
288
+ }
289
+ ]
290
+ }
@@ -0,0 +1,6 @@
1
+ # Fixtures
2
+
3
+ Fictional data only: Cedar Ridge Medical Group, made-up patients and providers. The file has status and dates only, as the agent needs; there is no note text. Checked on 15 November 2026.
4
+
5
+ - `encounters.csv`: eight encounters. Planted: E-6004 has been pending signature since 1 September (75 days, inside 30 days of the 90-day filing setting); E-6003 is unsigned after 26 days (past the 14-day escalation); E-6002 (5 days) and E-6008 (10 days, "In progress") are past the 3-day signing policy; E-6006 was signed 12 days after the visit. E-6005 is from yesterday and still inside the policy; E-6001 and E-6007 are clean.
6
+ - `settings.json`: sign in 3 days, escalate at 14, a 90-day filing setting with a 30-day warning, and a 30-day look-back for late signatures. `settings-typo.json` misspells a setting and is refused.
@@ -0,0 +1,105 @@
1
+ {
2
+ "case": "totals",
3
+ "id": [
4
+ [
5
+ "encounter_id"
6
+ ]
7
+ ],
8
+ "planted": [
9
+ ["E-6004", "filing_risk"],
10
+ ["E-6003", "unsigned_escalate"],
11
+ ["E-6008", "unsigned_over_policy"],
12
+ ["E-6002", "unsigned_over_policy"],
13
+ ["E-6006", "signed_late"]
14
+ ],
15
+ "clean": [
16
+ {
17
+ "arg": "encounters",
18
+ "set": [
19
+ {
20
+ "where": ["Encounter #", "E-6002"],
21
+ "column": "Note Status",
22
+ "value": "Signed"
23
+ },
24
+ {
25
+ "where": ["Encounter #", "E-6002"],
26
+ "column": "Signed Date",
27
+ "value": "2026-11-11"
28
+ },
29
+ {
30
+ "where": ["Encounter #", "E-6003"],
31
+ "column": "Note Status",
32
+ "value": "Signed"
33
+ },
34
+ {
35
+ "where": ["Encounter #", "E-6003"],
36
+ "column": "Signed Date",
37
+ "value": "2026-10-21"
38
+ },
39
+ {
40
+ "where": ["Encounter #", "E-6004"],
41
+ "column": "Note Status",
42
+ "value": "Signed"
43
+ },
44
+ {
45
+ "where": ["Encounter #", "E-6004"],
46
+ "column": "Signed Date",
47
+ "value": "2026-09-02"
48
+ },
49
+ {
50
+ "where": ["Encounter #", "E-6006"],
51
+ "column": "Signed Date",
52
+ "value": "2026-10-29"
53
+ },
54
+ {
55
+ "where": ["Encounter #", "E-6008"],
56
+ "column": "Note Status",
57
+ "value": "Signed"
58
+ },
59
+ {
60
+ "where": ["Encounter #", "E-6008"],
61
+ "column": "Signed Date",
62
+ "value": "2026-11-06"
63
+ }
64
+ ]
65
+ }
66
+ ],
67
+ "mutations": [
68
+ {
69
+ "name": "open note five days old",
70
+ "edits": [
71
+ {
72
+ "arg": "encounters",
73
+ "set": [
74
+ {
75
+ "where": ["Encounter #", "E-6005"],
76
+ "column": "Visit Date",
77
+ "value": "2026-11-10"
78
+ }
79
+ ]
80
+ }
81
+ ],
82
+ "expect": [
83
+ ["E-6005", "unsigned_over_policy"]
84
+ ]
85
+ },
86
+ {
87
+ "name": "note signed a week after the visit",
88
+ "edits": [
89
+ {
90
+ "arg": "encounters",
91
+ "set": [
92
+ {
93
+ "where": ["Encounter #", "E-6007"],
94
+ "column": "Signed Date",
95
+ "value": "2026-11-08"
96
+ }
97
+ ]
98
+ }
99
+ ],
100
+ "expect": [
101
+ ["E-6007", "signed_late"]
102
+ ]
103
+ }
104
+ ]
105
+ }
@@ -0,0 +1,9 @@
1
+ Encounter #,Patient #,Patient Name,Provider,Visit Date,Note Status,Signed Date,Charges,Payer
2
+ E-6001,P1401,Anya Brooks,Dana Whitfield,2026-11-13,Signed,2026-11-13,180.00,Goldfield Health
3
+ E-6002,P1402,Bennett Cho,Marcus Bello,2026-11-10,Open,,165.00,Medicare Part B
4
+ E-6003,P1403,Celia Marsh,Marcus Bello,2026-10-20,Unsigned,,240.00,Goldfield Health
5
+ E-6004,P1404,Desmond Rae,Priya Raman,2026-09-01,Pending signature,,310.00,Arbor Ridge Medicaid
6
+ E-6005,P1405,Elena Petrova,Marcus Bello,2026-11-14,Open,,150.00,Goldfield Health
7
+ E-6006,P1406,Farid Haddad,Priya Raman,2026-10-28,Signed,2026-11-09,175.00,Medicare Part B
8
+ E-6007,P1407,Gloria Funes,Dana Whitfield,2026-11-01,Closed,2026-11-02,190.00,Copperline Advantage
9
+ E-6008,P1408,Henrik Aas,Dana Whitfield,2026-11-05,In progress,,205.00,Copperline Advantage
@@ -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":["Desmond Rae","Celia Marsh","Bennett Cho","Henrik Aas","P1404","Marcus Bello","Priya Raman","Dana Whitfield"]}
@@ -0,0 +1 @@
1
+ { "signing_days": 3 }
@@ -0,0 +1 @@
1
+ { "sign_days": 3, "escalate_days": 14, "filing_days": 90, "filing_warn_days": 30, "late_lookback_days": 30 }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "fairpractice-unsigned-encounters",
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-unsigned-encounters",
5
+ "description": "Unsigned and open encounters holding claims, by provider: counts, dollars on hold and days old against your signing policy, and claims at risk of the filing limit. It reads encounter status only and never opens or reads a note.",
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-unsigned-encounters": "bin/fairpractice-unsigned-encounters.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-unsigned-encounters.js demo",
33
+ "eval": "node bin/fairpractice-unsigned-encounters.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-unsigned-encounters"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairpractice2-agents/tree/master/packages/fairpractice-unsigned-encounters#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
+ "unsigned-notes",
55
+ "charge-lag",
56
+ "encounters",
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-unsigned-encounters",
4
+ "title": "Fairpractice Unsigned Encounters",
5
+ "description": "Unsigned and open encounters holding claims, by provider",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairpractice2-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairpractice-unsigned-encounters"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairpractice.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairpractice-unsigned-encounters",
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 = { encounters: 'encounters.csv', settings: 'settings.json', as_of: '2026-11-15' };
5
+ export const demo = () => runDemo(manifest, new URL('../fixtures', import.meta.url), 'Fairpractice Unsigned Encounters', [
6
+ { label: 'Check open encounters and dollars on hold', tool: 'unsigned_check', args: f, list: (i) => `${i.status.padEnd(22)} ${i.message}` },
7
+ { label: 'Write the provider huddle list', tool: 'unsigned_write_report', args: f },
8
+ { label: 'Agent tries to read a note', tool: 'note_read', 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,39 @@
1
+ // Unsigned and open encounters holding claims: status, days and dollars only. It never reads a note. No I/O.
2
+ import { str, num, isoDate, daysBetween, round2, sortByStatus, countBy } from 'fairpractice-core';
3
+
4
+ const ORDER = { filing_risk: 0, unsigned_escalate: 1, unsigned_over_policy: 2, signed_late: 3 };
5
+ const OPEN = /unsign|open|pending|incomplete|draft|in progress|not signed|unfinal/i;
6
+ const DONE = /^(signed|closed|complete|completed|final|finalized|locked|billed)$/i;
7
+
8
+ /**
9
+ * encounters: [{ encounter_id, patient_id, patient_name, provider, dos, status, signed_date, charge, payer }]
10
+ * opts: { asOf, signDays = 3, escalateDays = 14, filingDays = 90, filingWarnDays = 30, lateLookbackDays = 30 }
11
+ */
12
+ export function checkUnsigned(encounters, { asOf, signDays = 3, escalateDays = 14, filingDays = 90, filingWarnDays = 30, lateLookbackDays = 30 } = {}) {
13
+ const items = []; const prov = new Map(); let open = 0;
14
+ for (const [i, e] of encounters.entries()) {
15
+ const dos = isoDate(e.dos); if (!dos) continue;
16
+ const signed = isoDate(e.signed_date); const status = str(e.status);
17
+ const isOpen = OPEN.test(status) || (!signed && !DONE.test(status));
18
+ const age = daysBetween(dos, asOf); const amt = round2(num(e.charge) || 0);
19
+ const base = { encounter_id: str(e.encounter_id) || `line ${i + 1}`, patient_id: str(e.patient_id) || null, patient_name: str(e.patient_name) || null, provider: str(e.provider) || '(no provider)', dos, payer: str(e.payer) || null, amount: amt };
20
+ if (isOpen) {
21
+ open++; const p = prov.get(base.provider) || { provider: base.provider, open: 0, amount: 0, oldest_days: 0 }; p.open++; p.amount = round2(p.amount + amt); p.oldest_days = Math.max(p.oldest_days, age); prov.set(base.provider, p);
22
+ if (age >= filingDays - filingWarnDays) items.push({ ...base, status: 'filing_risk', days: age, days_left: filingDays - age });
23
+ else if (age > escalateDays) items.push({ ...base, status: 'unsigned_escalate', days: age });
24
+ else if (age > signDays) items.push({ ...base, status: 'unsigned_over_policy', days: age });
25
+ continue;
26
+ }
27
+ if (signed && daysBetween(dos, signed) > signDays && daysBetween(signed, asOf) <= lateLookbackDays) items.push({ ...base, status: 'signed_late', days: daysBetween(dos, signed), signed_date: signed });
28
+ }
29
+ const T = {
30
+ filing_risk: (x) => [`Encounter ${x.encounter_id} (${x.provider}, ${x.dos}) has been open ${x.days} days; ${x.days_left} day(s) remain before your ${filingDays}-day filing setting.`, 'Ask the provider to finish it today; the claim cannot go out until it is signed.'],
31
+ unsigned_escalate: (x) => [`Encounter ${x.encounter_id} (${x.provider}, ${x.dos}) is still open after ${x.days} days, past your ${escalateDays}-day escalation point.`, 'Escalate to the medical director under your signing policy.'],
32
+ unsigned_over_policy: (x) => [`Encounter ${x.encounter_id} (${x.provider}, ${x.dos}) is open ${x.days} days, past your ${signDays}-day signing policy.`, 'Remind the provider to close it.'],
33
+ signed_late: (x) => [`Encounter ${x.encounter_id} (${x.provider}) was signed ${x.signed_date}, ${x.days} days after the visit.`, 'For the provider\'s monthly feedback; no action on the claim.'],
34
+ };
35
+ for (const it of items) { const [m, f] = T[it.status](it); it.message = m; it.fix = f; }
36
+ sortByStatus(items, ORDER, 'days');
37
+ const by_provider = [...prov.values()].sort((a, b) => b.amount - a.amount || b.open - a.open);
38
+ return { encounters: encounters.length, open, on_hold: round2(by_provider.reduce((s, p) => s + p.amount, 0)), by_provider, by_status: countBy(items, 'status'), items };
39
+ }
@@ -0,0 +1,64 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { medAgent, fileArg, AS_OF_ARG, PATIENT_ID, PATIENT_NAME, PROVIDER, DOS, CHARGE, PAYER, PRACTICE_LIMITS, today } from 'fairpractice-core';
3
+ import { checkUnsigned } 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 ENCOUNTER_FIELDS = Object.freeze({
9
+ encounter_id: t(['Encounter', 'Encounter ID', 'Encounter #', 'Visit ID', 'Visit #', 'CSN'], { translate: false }),
10
+ patient_id: PATIENT_ID, patient_name: PATIENT_NAME, provider: { ...PROVIDER, phi: 'name' },
11
+ dos: { ...DOS, required: true },
12
+ status: t(['Status', 'Note Status', 'Encounter Status', 'Sign Status', 'Documentation Status'], { translate: 'status' }),
13
+ signed_date: t(['Signed', 'Signed Date', 'Signed On', 'Closed Date', 'Finalized'], { type: 'date', translate: false }),
14
+ charge: CHARGE, payer: PAYER,
15
+ });
16
+
17
+ const SETTINGS = { type: 'object', additionalProperties: false, properties: {
18
+ sign_days: { type: 'integer', minimum: 0, maximum: 60, description: 'Days your policy gives a provider to sign; default 3' },
19
+ escalate_days: { type: 'integer', minimum: 1, maximum: 120, description: 'Days open before escalation; default 14' },
20
+ filing_days: { type: 'integer', minimum: 30, maximum: 730, description: 'Your tightest payer filing limit in days from the visit; default 90' },
21
+ filing_warn_days: { type: 'integer', minimum: 0, maximum: 180, description: 'Days before the filing limit to list an open encounter first; default 30' },
22
+ late_lookback_days: { type: 'integer', minimum: 0, maximum: 365, description: 'Encounters signed late within this many days are listed for feedback; default 30' },
23
+ } };
24
+
25
+ const args = {
26
+ encounters: fileArg('Encounter status export under --root: encounter, patient, provider, date of service, note status, signed date, charge amount and payer. Status and dates only; no note text'),
27
+ settings: fileArg('Optional settings JSON: sign_days, escalate_days, filing_days, filing_warn_days, late_lookback_days'),
28
+ as_of: AS_OF_ARG,
29
+ };
30
+ const run = (a, ctx) => {
31
+ const s = a.settings ? ctx.readJson(a.settings, 'unsigned_settings') : {};
32
+ return checkUnsigned(ctx.records(a.encounters, 'encounters'), { asOf: a.as_of || today(), signDays: s.sign_days ?? 3, escalateDays: s.escalate_days ?? 14, filingDays: s.filing_days ?? 90, filingWarnDays: s.filing_warn_days ?? 30, lateLookbackDays: s.late_lookback_days ?? 30 });
33
+ };
34
+ const summary = (o) => `${o.encounters} encounter(s), ${o.open} still open, ${o.on_hold} in charges on hold. ${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'}.`;
35
+
36
+ export const manifest = medAgent({
37
+ pkg, prefix: 'unsigned', title: 'Fairpractice Unsigned Encounters',
38
+ description: 'Lists unsigned and open encounters that hold claims, by provider: counts, dollars on hold and days open against your signing and escalation policy, encounters close to your filing limit, and encounters signed late. It reads encounter status and dates only and never opens or reads a note. Patient names are masked before results reach the model.',
39
+ args, required: ['encounters'],
40
+ sources: { encounters: { label: 'Encounter status', args: ['encounters'], fields: ENCOUNTER_FIELDS } },
41
+ configSchemas: { unsigned_settings: SETTINGS }, memoryKinds: {},
42
+ run, summary,
43
+ check: { title: 'Check unsigned encounters', description: 'List open encounters near the filing limit, past escalation or past the signing policy, and encounters signed late, with dollars on hold by provider.' },
44
+ report: {
45
+ title: { en: 'Unsigned encounters holding claims', es: 'Encuentros sin firmar que retienen reclamaciones', de: 'Nicht signierte Behandlungsfälle', fr: 'Consultations non signées bloquant la facturation', pt: 'Atendimentos não assinados retendo cobranças', it: 'Visite non firmate che bloccano la fatturazione', ja: '未署名で請求保留中の受診', zh: '未签署而暂停计费的就诊', ko: '서명되지 않아 청구가 보류된 진료' },
46
+ base: 'unsigned-encounters',
47
+ rows: (o) => o.items.map((i) => ({ status: i.status, encounter_id: i.encounter_id, patient_id: i.patient_id || '', patient_name: i.patient_name || '', provider: i.provider, dos: i.dos, days: i.days, amount: i.amount, message: i.message, fix: i.fix })),
48
+ htmlColumns: ['status', 'encounter_id', 'provider', 'dos', 'days', 'amount', 'message', 'fix'],
49
+ sections: (o) => [{ title: { en: 'Open encounters by provider' }, rows: o.by_provider, columns: ['provider', 'open', 'amount', 'oldest_days'] }],
50
+ limits: [PRACTICE_LIMITS.files, 'Status words differ between systems; the setup confirms which mean open. It never reads note text and does not judge documentation.', PRACTICE_LIMITS.advice, PRACTICE_LIMITS.phi],
51
+ },
52
+ refused: [
53
+ { name: 'note_read', category: 'binding_send', description: 'Fairpractice Unsigned Encounters never opens or reads a clinical note.' },
54
+ { name: 'note_sign', category: 'binding_send', description: 'Fairpractice Unsigned Encounters never signs or closes an encounter; only the provider does.' },
55
+ ],
56
+ prompt: { title: 'Unsigned encounter review', description: 'Walks the host model through a daily unsigned encounter review.', text: `You are helping a revenue cycle or practice manager with fairpractice-unsigned-encounters.
57
+
58
+ Rules: it reads encounter status and dates only, never notes. Patient names in results are pseudonyms.
59
+
60
+ 1. Call unsigned_check with the encounter export and as_of.
61
+ 2. Lead with filing_risk, then the providers with the most dollars on hold.
62
+ 3. Keep the tone factual: this is a reminder list, not a judgment of anyone's work.
63
+ 4. Call unsigned_write_report for the provider huddle.` },
64
+ });