# opensource-emr/hospital-management-emr architecture

> Architecture diagram of the GitHub repository opensource-emr/hospital-management-emr, 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/opensource-emr/hospital-management-emr
- Repository: https://github.com/opensource-emr/hospital-management-emr

## Overview

Danphe EMR is a web-based hospital management system spanning patient care, hospital operations, and finance. Its principal user workflow begins with patient registration and appointment or visit handling, continues through clinical documentation, orders and diagnostics, and can lead to admission, discharge, and billing. Accounting, inventory, pharmacy, reporting, and administrative capabilities form important operational branches. The README documents the breadth of modules; the sampled controllers show direct database-context usage, but do not establish all cross-module calls, so uncertain wiring is omitted.

Main entry points: [`Code/Websites/DanpheEMR`](https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Websites/DanpheEMR) (EMR web app), [`Code/Websites/DanpheEMR/Controllers/Admission/AdmissionController.cs`](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Admission/AdmissionController.cs) (Admission discharge), [`Code/Websites/DanpheEMR/Controllers/Lab/LabController.cs`](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Lab/LabController.cs) (Laboratory), [`Code/Websites/DanpheEMR/Controllers/WardSupply/WardSupplyController.cs`](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/WardSupply/WardSupplyController.cs) (Ward supply)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_care["Patient Care"]
  node_patient[("Patient records")]
  node_appointments["Appointments visits<br/>[AppointmentModels]"]
  node_clinical["Clinical care<br/>[ClinicalModels]"]
  node_admission["Admission discharge"]
  node_emergency["Emergency care"]
  node_medicalrecords["Medical records"]
  node_lab["Laboratory<br/>[LabController.cs]"]
  node_radiology["Radiology imaging"]
end

subgraph group_operations["Hospital Operations"]
  node_inventory["Inventory procurement"]
  node_pharmacy["Pharmacy"]
  node_wardsupply["Ward supply"]
  node_reporting[("Reporting dashboards")]
end

subgraph group_finance["Billing Finance"]
  node_billing[("Billing")]
  node_billsettings["Billing configuration"]
  node_accounting["Accounting"]
  node_acctdb[("Accounting store")]
end

subgraph group_platform["Application Platform"]
  node_web["EMR web app"]
  node_security["Access control<br/>[RBAC]"]
  node_ird["IRD billing sync<br/>[PostToIRD.cs]"]
end

node_user(("Hospital user"))
node_external_ird(("IRD service"))

node_user -->|"uses"| node_web
node_web -->|"checks access"| node_security
node_web -->|"handles patient data"| node_patient
node_web -->|"supports visits"| node_appointments
node_web -->|"supports care"| node_clinical
node_web -->|"routes requests"| node_admission
node_web -->|"routes requests"| node_emergency
node_web -->|"routes requests"| node_medicalrecords
node_web -->|"routes requests"| node_lab
node_web -->|"routes requests"| node_radiology
node_web -->|"routes requests"| node_inventory
node_web -->|"routes requests"| node_pharmacy
node_web -->|"routes requests"| node_wardsupply
node_web -->|"handles billing data"| node_billing
node_web -->|"routes requests"| node_billsettings
node_web -->|"routes requests"| node_accounting
node_admission -->|"uses context"| node_billing
node_lab -->|"queries reports"| node_reporting
node_wardsupply -->|"transfers stock"| node_inventory
node_accounting -->|"uses context"| node_acctdb
node_ird -.->|"posts data"| node_external_ird

click node_web "https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Websites/DanpheEMR"
click node_security "https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Components/DanpheEMR.Security/RBAC"
click node_patient "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/PatientDbContext.cs"
click node_appointments "https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Components/DanpheEMR.ServerModel/AppointmentModels"
click node_clinical "https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Components/DanpheEMR.ServerModel/ClinicalModels"
click node_admission "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Admission/AdmissionController.cs"
click node_emergency "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Emergency/EmergencyController.cs"
click node_medicalrecords "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/MedicalRecords/MedicalRecordsController.cs"
click node_lab "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Lab/LabController.cs"
click node_radiology "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Radiology/RadiologyController.cs"
click node_inventory "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Inventory/InventoryController.cs"
click node_pharmacy "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Pharmacy/PharmacyController.cs"
click node_wardsupply "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/WardSupply/WardSupplyController.cs"
click node_billing "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/BillingDbContext.cs"
click node_billsettings "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Settings/BillSettingsController.cs"
click node_accounting "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Accounting/AccountingController.cs"
click node_acctdb "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/AccountingDbContext.cs"
click node_reporting "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/ReportingDbContext.cs"
click node_ird "https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.Jobs/IRDNepal/PostToIRD.cs"

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_patient,node_appointments,node_clinical,node_admission,node_emergency,node_medicalrecords,node_lab,node_radiology,node_user toneBlue
class node_inventory,node_pharmacy,node_wardsupply,node_reporting toneAmber
class node_billing,node_billsettings,node_accounting,node_acctdb toneMint
class node_web,node_security,node_ird toneRose
class node_external_ird toneIndigo
```

## Components

### Patient Care

- [Patient records](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/PatientDbContext.cs): `Code/Components/DanpheEMR.DalLayer/PatientDbContext.cs`
- [Appointments visits](https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Components/DanpheEMR.ServerModel/AppointmentModels): `Code/Components/DanpheEMR.ServerModel/AppointmentModels`
- [Clinical care](https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Components/DanpheEMR.ServerModel/ClinicalModels): `Code/Components/DanpheEMR.ServerModel/ClinicalModels`
- [Admission discharge](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Admission/AdmissionController.cs): `Code/Websites/DanpheEMR/Controllers/Admission/AdmissionController.cs`
- [Emergency care](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Emergency/EmergencyController.cs): `Code/Websites/DanpheEMR/Controllers/Emergency/EmergencyController.cs`
- [Medical records](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/MedicalRecords/MedicalRecordsController.cs): `Code/Websites/DanpheEMR/Controllers/MedicalRecords/MedicalRecordsController.cs`
- [Laboratory](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Lab/LabController.cs): `Code/Websites/DanpheEMR/Controllers/Lab/LabController.cs`
- [Radiology imaging](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Radiology/RadiologyController.cs): `Code/Websites/DanpheEMR/Controllers/Radiology/RadiologyController.cs`

### Hospital Operations

- [Inventory procurement](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Inventory/InventoryController.cs): `Code/Websites/DanpheEMR/Controllers/Inventory/InventoryController.cs`
- [Pharmacy](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Pharmacy/PharmacyController.cs): `Code/Websites/DanpheEMR/Controllers/Pharmacy/PharmacyController.cs`
- [Ward supply](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/WardSupply/WardSupplyController.cs): `Code/Websites/DanpheEMR/Controllers/WardSupply/WardSupplyController.cs`
- [Reporting dashboards](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/ReportingDbContext.cs): `Code/Components/DanpheEMR.DalLayer/ReportingDbContext.cs`

### Billing Finance

- [Billing](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/BillingDbContext.cs): `Code/Components/DanpheEMR.DalLayer/BillingDbContext.cs`
- [Billing configuration](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Settings/BillSettingsController.cs): `Code/Websites/DanpheEMR/Controllers/Settings/BillSettingsController.cs`
- [Accounting](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Websites/DanpheEMR/Controllers/Accounting/AccountingController.cs): `Code/Websites/DanpheEMR/Controllers/Accounting/AccountingController.cs`
- [Accounting store](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.DalLayer/AccountingDbContext.cs): `Code/Components/DanpheEMR.DalLayer/AccountingDbContext.cs`

### Application Platform

- [EMR web app](https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Websites/DanpheEMR): `Code/Websites/DanpheEMR`
- [Access control](https://github.com/opensource-emr/hospital-management-emr/tree/master/Code/Components/DanpheEMR.Security/RBAC): `Code/Components/DanpheEMR.Security/RBAC`
- [IRD billing sync](https://github.com/opensource-emr/hospital-management-emr/blob/master/Code/Components/DanpheEMR.Jobs/IRDNepal/PostToIRD.cs): `Code/Components/DanpheEMR.Jobs/IRDNepal/PostToIRD.cs`

### Other components

- **Hospital user**
- **IRD service**

## Connections

- Hospital user → EMR web app: uses
- EMR web app → Access control: checks access
- EMR web app → Patient records: handles patient data
- EMR web app → Appointments visits: supports visits
- EMR web app → Clinical care: supports care
- EMR web app → Admission discharge: routes requests
- EMR web app → Emergency care: routes requests
- EMR web app → Medical records: routes requests
- EMR web app → Laboratory: routes requests
- EMR web app → Radiology imaging: routes requests
- EMR web app → Inventory procurement: routes requests
- EMR web app → Pharmacy: routes requests
- EMR web app → Ward supply: routes requests
- EMR web app → Billing: handles billing data
- EMR web app → Billing configuration: routes requests
- EMR web app → Accounting: routes requests
- Admission discharge → Billing: uses context
- Laboratory → Reporting dashboards: queries reports
- Ward supply → Inventory procurement: transfers stock
- Accounting → Accounting store: uses context
- IRD billing sync → IRD service: posts data
