# adiltruong/openemr-base-clean architecture

> Architecture diagram of the GitHub repository adiltruong/openemr-base-clean, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adiltruong/openemr-base-clean
- Repository: https://github.com/adiltruong/openemr-base-clean

## Overview

OpenEMR is an electronic health record and medical-practice management application. Its central workflow is practice staff working with patient records and encounters, then using those records for scheduling, clinical documentation, and billing. Separate capabilities expose health data through FHIR and CCDA exchange, provide clinical decision support, and support patient-portal access. The graph reflects README capabilities and the supplied tree; only the FHIR Coverage, authorization, and selected internal behaviors have sampled source excerpts, so other subsystem wiring is intentionally not asserted.

Main entry points: [`src/RestControllers/FHIR/FhirCoverageRestController.php`](https://github.com/adiltruong/openemr-base-clean/blob/main/src/RestControllers/FHIR/FhirCoverageRestController.php) (Coverage controller), [`index.php`](https://github.com/adiltruong/openemr-base-clean/blob/main/index.php) (OpenEMR web entry), [`interface/main/tabs/main.php`](https://github.com/adiltruong/openemr-base-clean/blob/main/interface/main/tabs/main.php) (Patient workspace), [`apis/dispatch.php`](https://github.com/adiltruong/openemr-base-clean/blob/main/apis/dispatch.php) (REST dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clinical["Clinical workflow"]
  node_web["OpenEMR web entry<br/>[index.php]"]
  node_chart["Patient workspace<br/>[main.php]"]
  node_clinical_forms["Clinical forms"]
  node_portal["Patient portal"]
end

subgraph group_practice["Practice operations"]
  node_calendar["Scheduling<br/>[index.php]"]
  node_billing["Billing"]
  node_insurance["Insurance records"]
end

subgraph group_interop["Health data exchange"]
  node_rest["REST dispatcher<br/>[dispatch.php]"]
  node_fhir_routes["FHIR routes"]
  node_coverage_controller["Coverage controller"]
  node_coverage_service["Coverage service"]
  node_oauth["Authorization server"]
  node_ccda_gateway["CCDA gateway<br/>[ccda_gateway.php]"]
  node_ccda_generator["CCDA generator<br/>[engine.js]"]
end

subgraph group_services["Clinical services"]
  node_database[("Application database<br/>[database.php]")]
  node_cdr["Clinical decision review"]
  node_session["Session storage"]
  node_query_helpers["Database query helpers"]
end

node_staff(("Practice staff"))
node_patient(("Patient"))

node_staff -->|"accesses"| node_web
node_patient -->|"accesses"| node_portal
node_web -->|"opens workspace"| node_chart
node_chart -->|"opens forms"| node_clinical_forms
node_staff -->|"schedules visits"| node_calendar
node_staff -->|"processes claims"| node_billing
node_rest -->|"dispatches routes"| node_fhir_routes
node_fhir_routes -->|"routes requests"| node_coverage_controller
node_coverage_controller -->|"queries coverage"| node_coverage_service
node_coverage_service -->|"uses records"| node_insurance
node_coverage_controller -->|"returns bundle"| node_rest
node_staff -->|"reviews rules"| node_cdr
node_ccda_gateway -->|"generates documents"| node_ccda_generator

click node_web "https://github.com/adiltruong/openemr-base-clean/blob/main/index.php"
click node_chart "https://github.com/adiltruong/openemr-base-clean/blob/main/interface/main/tabs/main.php"
click node_clinical_forms "https://github.com/adiltruong/openemr-base-clean/tree/main/interface/forms"
click node_calendar "https://github.com/adiltruong/openemr-base-clean/blob/main/interface/main/calendar/index.php"
click node_billing "https://github.com/adiltruong/openemr-base-clean/blob/main/interface/billing/billing_process.php"
click node_portal "https://github.com/adiltruong/openemr-base-clean/tree/main/portal/patient"
click node_database "https://github.com/adiltruong/openemr-base-clean/blob/main/config/database.php"
click node_rest "https://github.com/adiltruong/openemr-base-clean/blob/main/apis/dispatch.php"
click node_fhir_routes "https://github.com/adiltruong/openemr-base-clean/blob/main/apis/routes/_rest_routes_fhir_r4_us_core_3_1_0.inc.php"
click node_coverage_controller "https://github.com/adiltruong/openemr-base-clean/blob/main/src/RestControllers/FHIR/FhirCoverageRestController.php"
click node_coverage_service "https://github.com/adiltruong/openemr-base-clean/blob/main/src/Services/FHIR/FhirCoverageService.php"
click node_insurance "https://github.com/adiltruong/openemr-base-clean/tree/main/interface"
click node_oauth "https://github.com/adiltruong/openemr-base-clean/blob/main/src/RestControllers/AuthorizationController.php"
click node_ccda_gateway "https://github.com/adiltruong/openemr-base-clean/blob/main/ccdaservice/ccda_gateway.php"
click node_ccda_generator "https://github.com/adiltruong/openemr-base-clean/blob/main/ccdaservice/oe-blue-button-generate/lib/engine.js"
click node_cdr "https://github.com/adiltruong/openemr-base-clean/blob/main/src/ClinicalDecisionRules/Interface/Controller/ControllerReview.php"
click node_session "https://github.com/adiltruong/openemr-base-clean/blob/main/src/Common/Session/Storage/ReadAndCloseNativeSessionStorage.php"
click node_query_helpers "https://github.com/adiltruong/openemr-base-clean/blob/main/src/Common/Database/DatabaseQueryTrait.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_chart,node_clinical_forms,node_portal toneBlue
class node_calendar,node_billing,node_insurance toneAmber
class node_rest,node_fhir_routes,node_coverage_controller,node_coverage_service,node_oauth,node_ccda_gateway,node_ccda_generator toneMint
class node_database,node_cdr,node_session,node_query_helpers toneRose
class node_staff,node_patient toneIndigo
```

## Components

### Clinical workflow

- [OpenEMR web entry](https://github.com/adiltruong/openemr-base-clean/blob/main/index.php): `index.php`
- [Patient workspace](https://github.com/adiltruong/openemr-base-clean/blob/main/interface/main/tabs/main.php): `interface/main/tabs/main.php`
- [Clinical forms](https://github.com/adiltruong/openemr-base-clean/tree/main/interface/forms): `interface/forms`
- [Patient portal](https://github.com/adiltruong/openemr-base-clean/tree/main/portal/patient): `portal/patient`

### Practice operations

- [Scheduling](https://github.com/adiltruong/openemr-base-clean/blob/main/interface/main/calendar/index.php): `interface/main/calendar/index.php`
- [Billing](https://github.com/adiltruong/openemr-base-clean/blob/main/interface/billing/billing_process.php): `interface/billing/billing_process.php`
- [Insurance records](https://github.com/adiltruong/openemr-base-clean/tree/main/interface): `interface`

### Health data exchange

- [REST dispatcher](https://github.com/adiltruong/openemr-base-clean/blob/main/apis/dispatch.php): `apis/dispatch.php`
- [FHIR routes](https://github.com/adiltruong/openemr-base-clean/blob/main/apis/routes/_rest_routes_fhir_r4_us_core_3_1_0.inc.php): `apis/routes/_rest_routes_fhir_r4_us_core_3_1_0.inc.php`
- [Coverage controller](https://github.com/adiltruong/openemr-base-clean/blob/main/src/RestControllers/FHIR/FhirCoverageRestController.php): `src/RestControllers/FHIR/FhirCoverageRestController.php`
- [Coverage service](https://github.com/adiltruong/openemr-base-clean/blob/main/src/Services/FHIR/FhirCoverageService.php): `src/Services/FHIR/FhirCoverageService.php`
- [Authorization server](https://github.com/adiltruong/openemr-base-clean/blob/main/src/RestControllers/AuthorizationController.php): `src/RestControllers/AuthorizationController.php`
- [CCDA gateway](https://github.com/adiltruong/openemr-base-clean/blob/main/ccdaservice/ccda_gateway.php): `ccdaservice/ccda_gateway.php`
- [CCDA generator](https://github.com/adiltruong/openemr-base-clean/blob/main/ccdaservice/oe-blue-button-generate/lib/engine.js): `ccdaservice/oe-blue-button-generate/lib/engine.js`

### Clinical services

- [Application database](https://github.com/adiltruong/openemr-base-clean/blob/main/config/database.php): `config/database.php`
- [Clinical decision review](https://github.com/adiltruong/openemr-base-clean/blob/main/src/ClinicalDecisionRules/Interface/Controller/ControllerReview.php): `src/ClinicalDecisionRules/Interface/Controller/ControllerReview.php`
- [Session storage](https://github.com/adiltruong/openemr-base-clean/blob/main/src/Common/Session/Storage/ReadAndCloseNativeSessionStorage.php): `src/Common/Session/Storage/ReadAndCloseNativeSessionStorage.php`
- [Database query helpers](https://github.com/adiltruong/openemr-base-clean/blob/main/src/Common/Database/DatabaseQueryTrait.php): `src/Common/Database/DatabaseQueryTrait.php`

### Other components

- **Practice staff**
- **Patient**

## Connections

- Practice staff → OpenEMR web entry: accesses
- Patient → Patient portal: accesses
- OpenEMR web entry → Patient workspace: opens workspace
- Patient workspace → Clinical forms: opens forms
- Practice staff → Scheduling: schedules visits
- Practice staff → Billing: processes claims
- REST dispatcher → FHIR routes: dispatches routes
- FHIR routes → Coverage controller: routes requests
- Coverage controller → Coverage service: queries coverage
- Coverage service → Insurance records: uses records
- Coverage controller → REST dispatcher: returns bundle
- Practice staff → Clinical decision review: reviews rules
- CCDA gateway → CCDA generator: generates documents
