Skip to content

Architecture

System Overview

┌──────────────────────────────────────────────────────────────────┐
│                        BIOGRAPH HIS                              │
│                                                                  │
│  ┌─────────────────┐   ┌─────────────────┐   ┌──────────────┐  │
│  │  Frappe Desk UI  │   │  Patient Portal  │   │  REST API    │  │
│  │  (jQuery/Frappe)  │   │  (Vue 3 SPA)     │   │  (Clients)   │  │
│  └────────┬─────────┘   └────────┬─────────┘   └──────┬───────┘  │
│           │                      │                      │         │
│           ▼                      ▼                      ▼         │
│  ┌────────────────────────────────────────────────────────────┐  │
│  │              Frappe RPC Layer / REST API                    │  │
│  │  frappe.call() / POST /api/method/ / /api/resource/        │  │
│  └────────────────────────────┬───────────────────────────────┘  │
│                               │                                   │
│  ┌────────────────────────────▼───────────────────────────────┐  │
│  │                  Biograph Backend (Python)                  │  │
│  │                                                             │  │
│  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐  │  │
│  │  │ Patient  │ │ Clinical │ │   Lab    │ │  Inpatient   │  │  │
│  │  │ Mgmt     │ │ (OPD)    │ │          │ │  (IPD)       │  │  │
│  │  ├──────────┤ ├──────────┤ ├──────────┤ ├──────────────┤  │  │
│  │  │ Therapy  │ │Insurance │ │ Billing  │ │  ABDM (India)│  │  │
│  │  └──────────┘ └──────────┘ └──────────┘ └──────────────┘  │  │
│  └────────────────────────────┬───────────────────────────────┘  │
│                               │                                   │
│  ┌────────────────────────────▼───────────────────────────────┐  │
│  │                   ERPNext Integration                       │  │
│  │  Sales Invoice │ Payment Entry │ Stock Entry │ HR / Assets  │  │
│  └────────────────────────────────────────────────────────────┘  │
│                               │                                   │
│  ┌────────────────────────────▼───────────────────────────────┐  │
│  │          Frappe Framework (ORM, Auth, Queue, Files)         │  │
│  └────────────────┬────────────────────┬──────────────────────┘  │
│                   │                    │                          │
│              ┌────▼────┐          ┌────▼────┐                    │
│              │ MariaDB │          │  Redis  │                    │
│              └─────────┘          └─────────┘                    │
└──────────────────────────────────────────────────────────────────┘

Architecture Type

Modular monolith — single Frappe app with domain-organized DocTypes + a standalone Vue 3 SPA for the patient portal. Not microservices.

Components

Backend (Python / Frappe)

PropertyValue
Tech stackPython 3.10+, Frappe Framework, python-barcode
Locationhealthcare/
Entry pointhealthcare/hooks.py
PurposeAll clinical, administrative, and billing logic
Scale134 DocTypes, 120+ whitelisted methods, 1600-line utils module

Organized into domains: Patient Management, Appointments & Scheduling, Patient Encounters, Laboratory, Observations & Diagnostics, Clinical Procedures, Medications, Inpatient, Therapy & Rehabilitation, Insurance, Billing, Medical Coding, ABDM (India).

Patient Portal (Vue 3 SPA)

PropertyValue
Tech stackVue 3.2, Frappe UI, Tailwind CSS 3.4, Vite 4.4, Feather Icons
Locationpatient_portal/
Entry pointpatient_portal/src/patient_portal.js
PurposePatient self-service: appointments, diagnostics, payments
Scale7 components, 12 API calls, tab-based navigation
Served at/patient-portal (Frappe static files)

ERPNext Integration Layer

PropertyValue
Locationhealthcare/healthcare/custom_doctype/, document event hooks
PurposeBridge healthcare services to ERP billing, stock, and payments

Key integration points:

  • HealthcareSalesInvoice class overrides Sales Invoice for healthcare billing
  • Payment Entry hooks update paid amounts on healthcare documents
  • Stock Entry creation for clinical procedure / therapy consumables
  • Company hooks create Healthcare Service Unit tree roots

Component Communication

FromToMethodUse Case
Desk UIBackendfrappe.call() (RPC)All desk operations
Patient PortalBackendPOST /api/method/healthcare.healthcare.api.patient_portal.*Portal features
External clientsBackendREST API with token authIntegrations
BackendERPNextPython imports + hooksBilling, stock, payments
PortalBackendSocket.IORealtime updates

Shared Infrastructure

ComponentTechnologyPurpose
DatabaseMariaDBAll DocType data (via Frappe ORM)
CacheRedisSession cache, background job queue
File StorageFrappe file systemAttachments, images, print formats
Background JobsFrappe Scheduler (Redis Queue)Appointment reminders, daily tasks
EmailFrappe email queueNotifications, reminders

Authentication & Authorization

Auth Methods

MethodUsed ByMechanism
Session (cookie)Desk UI, Patient Portalfrappe.auth login → session cookie
TokenAPI clientsAuthorization: token api_key:api_secret header
Guest1 endpoint onlyget_context_for_dev() — dev mode only

Roles

RoleAccess Scope
Healthcare AdministratorFull access to all healthcare DocTypes and settings
PhysicianEncounters, prescriptions, service requests, referrals
Laboratory UserLab tests, sample collection, observations, diagnostic reports
Nursing UserNursing tasks, inpatient medication entries
PatientPortal only — filtered to own records + relations

Portal Security

  • All patient portal API methods require authentication
  • Data filtered by Patient.user_id == frappe.session.user
  • Patient Relations (dependents) are also accessible
  • Web form permissions use custom has_website_permission handlers
  • Print format access restricted to 3 DocTypes only

Data Flow

Appointment → Invoice

Patient books appointment (Portal or Desk)


Patient Appointment (status: Open)
    ├── Fee Validity checked (free follow-up?)


Practitioner creates Patient Encounter
    ├── Symptoms + Diagnoses recorded
    ├── Drug Prescriptions → Medication Request
    ├── Lab Prescriptions → Service Request → Lab Test
    ├── Procedure Orders → Service Request → Clinical Procedure
    └── Therapy Orders → Service Request → Therapy Session


    Lab: Sample Collection → Observation → Diagnostic Report


    get_healthcare_services_to_invoice() aggregates all billable items


    Sales Invoice (ERPNext) → Payment Entry (ERPNext)
    hooks update paid_amount on healthcare docs

Inpatient Flow

Treatment Counselling (pre-admission consent)


Inpatient Record created → admit(service_unit, check_in)

    ├── Inpatient Occupancy tracks bed assignment
    ├── IP Medication Order → IP Medication Entry → Stock Entry
    ├── Daily scheduler adds service unit rent to billables
    ├── transfer(new_service_unit) if bed change needed


discharge() → Discharge Summary


All billable items → Sales Invoice