{"id":30750580,"url":"https://github.com/olubusade/emr-suite-backend","last_synced_at":"2026-04-02T03:12:05.993Z","repository":{"id":312399872,"uuid":"1047223552","full_name":"olubusade/emr-suite-backend","owner":"olubusade","description":"Production-ready backend for wiCare EMR demo built with Node.js, Express, Sequelize \u0026 PostgreSQL. Features JWT auth, RBAC, audit logging, Docker, and Jest tests. Secure, scalable, and cloud-ready to support multi-role workflows (Admin, Doctor, Nurse, Pharmacist, Biller, Lab Tech, Receptionist).","archived":false,"fork":false,"pushed_at":"2026-03-17T17:39:24.000Z","size":388,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-18T07:08:36.885Z","etag":null,"topics":["backend","cicd","docker","emr","express","healthcare","jwt","nodejs","postgresql","rbac","sequelize"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olubusade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-30T00:43:16.000Z","updated_at":"2026-03-17T17:39:29.000Z","dependencies_parsed_at":"2025-08-30T11:23:47.634Z","dependency_job_id":"ed503b9b-2ac4-41d2-a2a6-3f2c3dd82b3f","html_url":"https://github.com/olubusade/emr-suite-backend","commit_stats":null,"previous_names":["olubusade/emr-suite-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/olubusade/emr-suite-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olubusade%2Femr-suite-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olubusade%2Femr-suite-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olubusade%2Femr-suite-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olubusade%2Femr-suite-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olubusade","download_url":"https://codeload.github.com/olubusade/emr-suite-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olubusade%2Femr-suite-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","cicd","docker","emr","express","healthcare","jwt","nodejs","postgresql","rbac","sequelize"],"created_at":"2025-09-04T07:01:40.461Z","updated_at":"2026-04-02T03:12:05.981Z","avatar_url":"https://github.com/olubusade.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 🏥 EMR-Suite Backend\n\n**Production-Grade Electronic Medical Records (EMR) Backend (Demo)**\n\n![Node.js](https://img.shields.io/badge/Node.js-20.x-green?style=flat-square)\n![PostgreSQL](https://img.shields.io/badge/PostgreSQL-15-blue?style=flat-square)\n![Sequelize](https://img.shields.io/badge/ORM-Sequelize-lightblue?style=flat-square)\n![Jest](https://img.shields.io/badge/Testing-Jest-orange?style=flat-square)\n![Docker](https://img.shields.io/badge/Docker-Ready-blue?style=flat-square)\n![RBAC](https://img.shields.io/badge/Security-RBAC-red?style=flat-square)\n\n---\n\n## 📌 Overview\n\n**EMR-Suite Backend** is a **production-grade Node.js backend** designed to power a modern **Electronic Medical Records (EMR)** platform.\n\n\u003e ⚠️ **Recruiter / Reviewer Note**\n\u003e This repository is a **backend demo extracted from a real EMR system** (wiCare EMR).\n\u003e It intentionally focuses on **architecture, security, scalability, and healthcare workflows**, not UI polish.\n\u003e The frontend (Angular + Ionic) lives in a separate repository.\n\nThis project demonstrates how I design **secure, auditable, role-aware APIs** suitable for **regulated healthcare environments**.\n\n---\n\n## 🎯 What This Project Demonstrates\n\n✔ Clean backend architecture\n✔ Secure authentication \u0026 authorization\n✔ Real-world healthcare workflows\n✔ Auditability \u0026 compliance thinking\n✔ Production readiness (Docker, CI, tests, monitoring)\n\nThis is **not** a CRUD demo — it is a **system-level backend**.\n\n---\n\n## 🧠 Core Architectural Principles\n\n* **Security-first design** (JWT, RBAC, rate limits)\n* **Explicit role \u0026 permission modeling**\n* **Auditability for healthcare compliance**\n* **Separation of concerns** (controllers, services, middleware)\n* **Observable \u0026 testable** by default\n* **Container-ready** for modern deployments\n\n---\n\n## 🔐 Authentication \u0026 Security\n\n### Authentication\n\n* JWT **access \u0026 refresh tokens**\n* Token expiration \u0026 revocation\n* Secure password hashing\n* Password change enforcement\n\n### Security Hardening\n\n* Rate limiting (global + route-level)\n* Helmet security headers\n* CORS configuration\n* Centralized request logging\n\n---\n\n## 🧩 Role-Based Access Control (RBAC)\n\nRBAC is **first-class**, not an afterthought.\n\n### Roles\n\n* `super_admin`\n* `admin`\n* `doctor`\n* `nurse`\n* `receptionist`\n* `patient`\n\n### Permission Model\n\n* Fine-grained permissions (e.g. `appointment.create`, `vital.update`)\n* Many-to-many relationships:\n\n  * `Users ↔ Roles`\n  * `Roles ↔ Permissions`\n* Centralized `authorize()` middleware\n\n```ts\nrouter.post(\n  '/',\n  authRequired,\n  authorize(PERMISSIONS.CLINICALNOTE_CREATE),\n  clinicalController.create\n);\n```\n\n✔ Easily extensible\n✔ Prevents role leakage\n✔ Matches enterprise RBAC standards\n\n---\n\n## 🏥 Domain Modules\n\nEach module mirrors **real hospital workflows**:\n\n### 🧍 Patients\n\n* Registration \u0026 demographic management\n* Medical identifiers\n* Emergency contacts\n\n### 📅 Appointments\n\n* Reception-driven scheduling\n* Status lifecycle (today / past / upcoming)\n* Role-aware visibility\n\n### 🩺 Clinical Notes\n\n* Doctor-only creation\n* Immutable historical records\n* Full audit trail\n\n### 💉 Vitals\n\n* Nurse-driven vitals capture\n* Time-series friendly design\n\n### 💳 Billing\n\n* Paid vs pending bills\n* Financial audit readiness\n\n---\n\n## 🧾 Audit Logging\n\nEvery sensitive action is recorded.\n\n**Audit captures:**\n\n* Actor (who performed the action)\n* Entity affected\n* Action type\n* Before \u0026 after state\n* Timestamp\n\nThis is critical for:\n\n* Healthcare compliance\n* Internal investigations\n* Debugging production incidents\n\n---\n\n## 📊 Monitoring \u0026 Observability\n\n* **Prometheus metrics** exposed at `/metrics`\n* Tracks:\n\n  * Request count\n  * Latency\n  * Error rates\n  * Route-level performance\n\nReady for **Grafana integration**.\n\n---\n\n## 📐 System Architecture\n\n```mermaid\nflowchart TD\n    A[Client / Frontend] --\u003e B[Express Middleware]\n    B --\u003e|JWT Auth| C[Controllers]\n    B --\u003e|RBAC Check| C\n    B --\u003e|Audit Logging| C\n    C --\u003e D[Service Layer]\n    D --\u003e E[Sequelize ORM]\n    E --\u003e F[(PostgreSQL)]\n    B --\u003e G[Prometheus Metrics]\n\n    style A fill:#f9f\n    style B fill:#bbf\n    style C fill:#bfb\n    style D fill:#ffb\n    style E fill:#fbf\n    style F fill:#fbb\n    style G fill:#ccc\n```\n\n---\n🚀 Deployment\nZero-Cost Demo (Render)\nFor demo purposes, this backend is configured for Render.\n\nConnect this GitHub repo to Render.\n\nAdd DATABASE_URL and JWT_SECRET to environment variables.\n\nThe render.yaml (Blueprint) will automatically provision the Web Service and Database.\n\n## 📁 Project Structure\n\n```bash\nemr-suite-backend/\n├── src/\n│   ├── config/          # env, db, jwt, swagger\n│   ├── constants/       # roles, permissions, enums\n│   ├── controllers/    # HTTP layer\n│   ├── middlewares/    # auth, RBAC, audit, rateLimit\n│   ├── models/         # Sequelize models\n│   ├── routes/         # API definitions\n│   ├── seed/           # roles, users, permissions\n│   ├── services/       # SQL logic\n│   ├── utils/          # logger, validators\n│   ├── app.js\n│   └── server.js\n├── tests/              # Jest + Supertest\n├── docker/             # Docker \u0026 compose configs\n├── .env.*              # Environment configs\n└── README.md\n```\n\n---\n\n## 📚 API Documentation\n\n* **Swagger UI:**\n  👉 `http://localhost:5000/api-docs`\n\nIncludes:\n\n* Request/response schemas\n* Auth requirements\n* RBAC notes per endpoint\n\n---\n\n## 🧪 Testing Strategy\n\n* **Jest + Supertest**\n* Covers:\n\n  * Appointments\n  * Clinical Notes\n  * Vitals\n  * RBAC enforcement\n* Includes negative cases (permission denied, invalid input)\n\n```bash\nnpm test\nnpm run test:watch\n```\n\n---\n\n## 🚀 Local Development\n\n### Prerequisites\n\n* Node.js ≥ 20\n* PostgreSQL ≥ 15\n* npm ≥ 9\n\n```bash\ngit clone https://github.com/olubusade/emr-suite-backend.git\ncd emr-suite-backend\nnpm install\ncp .env.local.dev .env\nnpm run migrate\nnpm run seed\nnpm run dev\n```\n\nServer: `http://localhost:5000`\n\n---\n\n## 🐳 Docker Support\n\n### Development\n\n```bash\nnpm run docker:up:dev\nnpm run docker:seed:dev\n```\n\n### Production\n\n```bash\nnpm run docker:up:prod\nnpm run docker:seed:prod\n```\n\nMulti-stage builds ensure:\n\n* Small image size\n* Faster deployments\n* Production-only dependencies\n\n---\n\n## 🔁 CI/CD (GitHub Actions)\n\n* Runs on every **push \u0026 PR**\n* Pipeline:\n\n  1. Spin up PostgreSQL\n  2. Run migrations \u0026 seeds\n  3. Execute Jest test suite\n\n✔ Prevents broken deployments\n✔ Enforces discipline\n\n---\n\n## 👤 About the Author\n\n**Busade Adedayo**\nSenior Software Engineer (Healthcare Systems)\n\n* 5+ years building production EMR systems\n* Strong focus on backend architecture \u0026 security\n* Experience with real hospital workflows\n* Passionate about scalable, maintainable systems\n\n---\n\n## 📜 License\n\nMIT © 2025 — Busade Adedayo\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folubusade%2Femr-suite-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folubusade%2Femr-suite-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folubusade%2Femr-suite-backend/lists"}