Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
a7c8f36
add ARCHITECTURE.md, USERS.md and AUDIT.md for Week 1 PRD work.
Apr 28, 2026
0094593
updated week 1 assignment docs
Apr 28, 2026
e36e18f
feat(clinical-copilot): add AgentForge custom module and eval tests
Apr 29, 2026
f7c6128
AgentForge PRD1 new module created and manually visually tested. todo…
Apr 30, 2026
b39c7a8
updated Clinical Co-Pilot Module with polished code headers, sanitize…
Apr 30, 2026
d9817df
PRD 1 Module Clinical Co-pilot verified complete on local dev environ…
May 1, 2026
3db6509
Add from-source Docker build for Railway
May 1, 2026
4035ef2
Add tests and Clinical Co-Pilot minor updates
May 1, 2026
fa9ca65
Merge branch 'prd_1_agentforge_monigarr' into 'master'
May 1, 2026
3095a0c
fix(db): Fix SQL upgrade syntax (#11866)
Firehed Apr 27, 2026
e883b9e
chore(db): Fix typo (#11867)
Firehed Apr 27, 2026
cfb1f12
ci(e2e): capture diagnostics for InvalidSessionIdException flake (#11…
kojiromike Apr 27, 2026
0827e36
chore(deps): bump openemr/openemr from flex-3.17 to flex-3.17 in /doc…
dependabot[bot] Apr 28, 2026
3391b88
chore(phpstan): drain Carecoordination module class.notFound + method…
kojiromike Apr 28, 2026
6d509f6
fix(bootstrap): replace die() with exception for missing session site…
kojiromike Apr 28, 2026
4af7d3a
perf(ci): restore file timestamps to enable PHPStan caching (#10387)
kojiromike Apr 28, 2026
c141a72
chore(phpstan): drain edihistory baseline (method.notFound, variable.…
kojiromike Apr 28, 2026
f4fe65b
fix(portal): drain PHPStan class.notFound baseline for portal/patient…
kojiromike Apr 28, 2026
ed8b426
fix(encounter): handle missing row and null uuid in encounter view fo…
kojiromike Apr 28, 2026
1d8b893
fix(db): Log all "helpfuldie" sql errors (#11864)
Firehed Apr 28, 2026
550881b
refactor(edihistory): lift edih_x12_file to OpenEMR\Billing\EdiHistor…
kojiromike Apr 28, 2026
a9898fb
fix(db): convert declne_to_specfy in patient_data language and ethnic…
kojiromike Apr 28, 2026
d990b45
fix(csrf): stop rotating CSRF private key on every main_screen.php lo…
kojiromike Apr 28, 2026
579cb46
refactor: replace literal preg_match prefix/suffix checks with native…
kojiromike Apr 28, 2026
7ab6796
chore(phpstan): drain variable.undefined baseline (3064 → 2927) (#11887)
kojiromike Apr 28, 2026
a783e75
chore(deps): bump openemr/openemr from flex-3.17 to flex-3.17 in /doc…
dependabot[bot] Apr 29, 2026
5fddcd1
refactor(billing): drain variable.undefined PHPStan baseline entries …
kojiromike Apr 29, 2026
af7c7e2
chore(phpstan): drain variable.undefined baseline for edihistory, mod…
kojiromike Apr 29, 2026
c85dcf8
fix(ci): Inferno testsuite setup fixes (#11897)
Firehed Apr 29, 2026
9a236b4
fix(rx): set linkMethod for Ensora eRx prescription button (#11882)
kojiromike Apr 29, 2026
598912a
chore(phpstan): drain variable.undefined across interface/patient_fil…
kojiromike Apr 29, 2026
71d0803
fix(faxsms): catch up missed appointment-reminder ticks (#11907)
kojiromike Apr 29, 2026
30f8a58
fix(ci): Turn off redis persistence in inferno tests (#11909)
Firehed Apr 29, 2026
a1f1212
chore(phpstan): drain variable.undefined baseline in interface/main (…
kojiromike Apr 29, 2026
1227bd9
fix(sql): Allow sql_upgrade to work on the cli (#11906)
Firehed Apr 29, 2026
6aea5f4
fix(phpdoc): repair legacy parse errors across the codebase (#11904)
kojiromike Apr 29, 2026
33ace3c
chore(phpstan): cap phpDoc.parseError baseline at zero (#11914)
kojiromike Apr 29, 2026
a435d3a
fix(ci): add NPI to user to qualify as Practitioner in Inferno tests …
Firehed Apr 30, 2026
2394322
fix(test): correct Inferno test group IDs for body height/weight (#11…
Firehed Apr 30, 2026
a08e76d
chore(phpstan): drain variable.undefined baseline for interface/forms…
kojiromike Apr 30, 2026
edc7819
fix(faxsms): require appointments lib; log background-service errors …
kojiromike Apr 30, 2026
8b515c3
fix(clinical-notes): correct i18formatting asset name typo (#11937)
kojiromike Apr 30, 2026
b53622f
fix: guard undefined keys and legacy PHP warnings flagged in producti…
kojiromike Apr 30, 2026
6211ac4
fix(session): clean up callers that re-open read_and_close session (#…
kojiromike Apr 30, 2026
4a790f6
fix(background-services): resolve PHP CLI binary via PhpExecutableFin…
kojiromike May 1, 2026
b217634
fix(login): default login_page_layout when globals row is missing (#1…
kojiromike May 1, 2026
cae0b99
chore(deps): bump openemr/openemr from flex-3.17 to flex-3.17 in /doc…
dependabot[bot] May 1, 2026
db3f673
fix(main-tabs): restore default tab loading after login (#11947)
kojiromike May 1, 2026
fb50530
fix(security): validate db parameter in standard_tables_manage (#11951)
kojiromike May 1, 2026
88e3d15
fix(session): restore brief-lock pattern on long-running pages (#11953)
kojiromike May 1, 2026
a51e569
feat(crypto): add encryptForDatabase and decryptFromDatabase methods …
Firehed May 1, 2026
7308529
chore(phpstan): drain variable.undefined for canonical-globals form f…
kojiromike May 1, 2026
383e5d3
feat(auth): add audit logging for failed TOTP, U2F, and OAuth2 MFA at…
aanand-1706 May 1, 2026
d9fe008
fix(ci): Run additional web workers in API integration tests (#11959)
Firehed May 1, 2026
6ea7737
fix(portal): add CSRF protection to payment handler (#11958)
Firehed May 1, 2026
42b1e3e
fix(auth): remove unused redirect_token from OneTimeAuth (#11972)
Firehed May 1, 2026
434c1cc
fix(faxsms): tighten oe_faxsms_queue schema for utf8mb4 compatibility…
kojiromike May 1, 2026
9fa26df
added dockerfile for railway deployment
May 2, 2026
e6a07ec
updated docker image for railway
May 2, 2026
d9ca666
Dockerfile updates for railway staging
May 2, 2026
3833788
updated README for custom clinical copilot module
May 2, 2026
0e5ff53
updated docker image readme
May 2, 2026
777508b
updated .gitattributes for the railway staging environment to use my …
May 2, 2026
2d19f52
new updates for railway.com staging environment
May 3, 2026
b8a32a0
railway dockerfile updates for staging environment
May 3, 2026
216db1e
railway dockerfile for staging
May 3, 2026
2bd7355
railway dockerfile corrections regarding openemr.sh
May 3, 2026
fdb1c02
docker image sh error removed for railway staging deploy
May 3, 2026
81c059f
new dockerfile info and setup for railway staging
May 3, 2026
9400c4b
railway docker for staging edits
May 3, 2026
c5ab883
railway docker file updated for staging
May 3, 2026
0ea659c
fix: add cache mount ids and remove VOLUME in agentforge-railway Dock…
railway-app[bot] May 3, 2026
6fc2b28
Merge pull request #5 from monigarr/railway/code-change-kwUeRz
monigarr May 3, 2026
9e7e9ca
cleanup of old dockerfile work
May 3, 2026
4a0ee5c
UI font size edits
May 3, 2026
19b1464
UI updates : new color to make custom module card stand out from the …
May 3, 2026
da387d3
feat(clinical-copilot): deepen LangFuse traces and Railway LangFuse d…
May 4, 2026
aa727dc
fix: add cacheKey: prefix to composer and npm cache mount ids
railway-app[bot] May 4, 2026
bd409bd
Merge pull request #6 from monigarr/railway/code-change-C6k2kP
monigarr May 4, 2026
66e4a27
fix: remove BuildKit cache mount flags from Railway Dockerfile
railway-app[bot] May 4, 2026
fdf476e
Merge pull request #7 from monigarr/railway/code-change-lAUXBe
monigarr May 4, 2026
e2a74e1
build(agentforge-railway): trigger railway redeploy
May 4, 2026
cd903ba
chore(docker): sync vendored openemr-devops 8.1.1 for railway
May 5, 2026
233bc05
added PRD 2 Docs
May 5, 2026
4825116
chore(sync): merge upstream master into prd_1_agentforge_monigarr
May 8, 2026
76f0255
Merge branch 'openemr:master' into prd_1_agentforge_monigarr
monigarr May 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@
# Exclude dev-only infrastructure from release archives and Composer installs.
# GitHub uses these rules when generating source downloads for tagged releases.
# Keep anything needed to install, configure, or run OpenEMR.
# Hosts that build from a git export (e.g. Railway) honor export-ignore too.
.github/ export-ignore
.phpstan/ export-ignore
ci/ export-ignore
docker/ export-ignore
# docker/: do not export-ignore the whole tree — Git omits children from archives and
# never applies -export-ignore under an excluded parent. List sibling dirs only; keep
# docker/agentforge-railway/ in archives for Dockerfile-based deploys (e.g. Railway).
# If a new top-level directory is added under docker/, add export-ignore here unless it
# must appear in git-archive build contexts.
docker/README.md export-ignore
docker/development-easy/ export-ignore
docker/development-easy-light/ export-ignore
docker/development-easy-redis/ export-ignore
docker/development-insane/ export-ignore
docker/from-source/ export-ignore
docker/library/ export-ignore
docker/production/ export-ignore
tests/ export-ignore
tools/ export-ignore
.gitattributes export-ignore
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ ccdaservice/node_modules
.buildpath
.project
.settings
PRD_Week1_AgentForge.jpeg
PRD_Week1_AgentForge.md

# testing
.phpunit.result.cache
Expand Down
183 changes: 183 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# Clinical CoPilot — Week 2 ARCHITECTURE

## 0. Executive Summary

Week 2 extends the PRD 1 Clinical CoPilot into a multimodal, multi-agent system capable of ingesting clinical documents, extracting structured facts, retrieving guideline evidence, and producing fully grounded outputs.

This is an **extension of PRD 1 — not a replacement**.

The system preserves PRD 1 guarantees:
- Verification-first output
- Bounded tool access
- Session-based trust model
- Full observability via AgentTelemetry

New capabilities:
- Multimodal document ingestion (lab PDF, intake form)
- Supervisor + worker multi-agent routing
- Eval-driven CI gating

---

## 1. Architecture Position

- OpenEMR remains system of record
- PRD 1 orchestrator remains core authority
- PRD 2 multi-agent layer is an extension on top
- AI remains untrusted reasoning layer
- Verification remains mandatory gate
- Eval CI is production gate

---

## 2. Design Principles (M.O.M / M.I.L.E)

- Intelligence-led extraction (never blind OCR trust)
- Extraction is treated as **untrusted input**
- Minimal expansion of surface area
- Brownfield-safe (no OpenEMR core modification)
- Observability-first (trace everything)
- Eval-driven development (CI enforced)

---

## 3. System Overview

User → OpenEMR UI → Controller
→ PRD1 Orchestrator Core
→ Supervisor Agent (extension)
→ Worker 1 (Extractor)
→ Worker 2 (Evidence Retriever)
→ Verification Gate
→ UI Response

---

## 4. Multi-Agent Position (Critical Clarification)

PRD 2 multi-agent architecture is:

> A constrained, inspectable routing layer built on top of the PRD 1 orchestrator — not a replacement.

- Supervisor = routing logic only
- Workers = bounded responsibilities
- All actions remain observable and verifiable

No agent has:
- direct DB access
- write authority
- uncontrolled autonomy

---

## 5. Tool Layer (Updated)

| Tool | Role | Boundary |
|------|------|----------|
| attach_and_extract | document ingestion | server-controlled |
| retrieve_guidelines | RAG retrieval | read-only |
| get_patient_context | OpenEMR data | bounded |

### Write Boundary Clarification

`attach_and_extract`:
- executes server-side only
- persists data through controlled pipelines
- model does NOT write to DB
- model cannot modify records

---

## 6. Extraction Model (Critical Update)

Extraction pipeline:

Document → VLM → Structured JSON → Validation → Verification → Persist

### Rule:
> Extraction output is **not truth**. It is untrusted input until:
- schema validated
- citation linked to source
- verified by system

---

## 7. Verification (Extended)

Verification now applies to:
1. OpenEMR structured data
2. Extracted document data
3. Retrieved guideline evidence

Requirements:
- every claim must have citation
- patient facts ≠ guideline evidence
- unsupported claims removed

---

## 8. Observability (Reconciled)

PRD 1:
- AgentTelemetry (LangFuse)

PRD 2:
- adds LangChain

### Final Position:

> LangChain is orchestration
> AgentTelemetry remains the system of record for observability

All logs must include:
- tool sequence
- latency per step
- token usage
- cost estimate
- eval result

No PHI in logs

---

## 9. Eval Strategy (Critical)

- 50-case golden dataset
- boolean rubrics only
- CI blocks regression >5%

Eval is:
> not testing — it is a production gate

---

## 10. Failure Modes

| Failure | Behavior |
|--------|----------|
| OCR hallucination | drop or flag |
| missing data | explicit uncertainty |
| tool failure | partial response |
| verification failure | remove claim |

---

## 11. Brownfield Constraints

- OpenEMR is immutable source of truth
- No modification of core
- Module-only extension
- Follow CONTRIBUTING.md + README strictly

---

## 12. Forward Path

- critic agent
- additional document types
- improved retrieval

---

## Document Control
Version: 2.1
58 changes: 58 additions & 0 deletions ARCHITECTURE_RISKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# PRD 2 Architecture Risks

## 1. Multi-Agent Complexity

Risk:
- Supervisor becomes opaque

Mitigation:
- log all routing decisions
- limit agent scope
- enforce deterministic flow

---

## 2. Extraction Risk (Critical)

Risk:
- system generates false structured data

Mitigation:
- treat extraction as untrusted input
- require schema validation
- require citation linkage

---

## 3. Write Boundary Risk

Risk:
- ingestion tool writes incorrect data

Mitigation:
- server-controlled persistence only
- model cannot write directly
- validation before storage

---

## 4. Observability Drift

Risk:
- losing PRD 1 traceability

Mitigation:
- AgentTelemetry remains source of truth
- LangChain only for orchestration

---

## 5. Eval Failure Risk

Risk:
- regressions pass unnoticed

Mitigation:
- CI blocking gate
- 50-case dataset
- strict boolean scoring
55 changes: 55 additions & 0 deletions AUDIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Clinical CoPilot — AUDIT (Week 2 Addendum)

## New Risk Areas

### Document Processing
- OCR inaccuracies
- confabulated fields
- extracted data treated as truth (critical risk)

### Multi-Agent Complexity
- routing errors
- hidden reasoning
- supervisor becoming black box

### RAG Risks
- irrelevant evidence
- outdated guidelines

---

## New Mitigations

- extraction treated as untrusted input
- strict schema validation
- citation enforcement
- supervisor decisions logged
- reranking enforced
- verification extended to extracted data

---

## Compliance Notes
- documents = PHI
- no storage in logs
- no external leakage

---

## New Findings

| ID | Severity | Finding |
|----|----------|--------|
| W2-F1 | High | OCR hallucination risk |
| W2-F2 | High | missing citation in extraction |
| W2-F3 | Medium | RAG drift |
| W2-F2 | High | extraction treated as truth risk |
| W2-F4 | High | multi-agent opacity risk |

---

## Integration Impact

- extend verification layer to extracted data
- extend observability to multi-agent flows
- enforce auditability of routing decisions
Loading
Loading