| 1 | # Medora - Medical Records Management System
|
|---|
| 2 |
|
|---|
| 3 | Medora is a comprehensive healthcare management platform designed to streamline patient medical records, appointments, laboratory tests, prescriptions, and billing operations.
|
|---|
| 4 |
|
|---|
| 5 | ## Features
|
|---|
| 6 |
|
|---|
| 7 | - **Patient Management** - Create and manage patient profiles with EMBG (personal identification number)
|
|---|
| 8 | - **Medical Records** - Access comprehensive patient medical histories including diagnoses, symptoms, allergies, and prescriptions
|
|---|
| 9 | - **Appointments** - Schedule and manage doctor-patient appointments
|
|---|
| 10 | - **Lab Tests** - Request and track laboratory test results
|
|---|
| 11 | - **Prescriptions** - Manage medication prescriptions for patients
|
|---|
| 12 | - **Doctor Management** - Manage doctor profiles and specializations
|
|---|
| 13 | - **Billing** - Generate and track billing records for medical services
|
|---|
| 14 | - **User Authentication** - Secure JWT-based authentication with role-based access control (Admin, Doctor, Patient, Lab Technician, Billing Admin)
|
|---|
| 15 |
|
|---|
| 16 | ## Tech Stack
|
|---|
| 17 |
|
|---|
| 18 | ### Backend
|
|---|
| 19 | - **Framework:** Spring Boot (Java)
|
|---|
| 20 | - **Database:** PostgreSQL
|
|---|
| 21 | - **ORM:** Hibernate/JPA
|
|---|
| 22 | - **Security:** Spring Security + JWT
|
|---|
| 23 | - **Build Tool:** Maven
|
|---|
| 24 |
|
|---|
| 25 | ### Frontend
|
|---|
| 26 | - **Library:** React 18+
|
|---|
| 27 | - **Routing:** React Router
|
|---|
| 28 | - **HTTP Client:** Axios
|
|---|
| 29 | - **Styling:** TailwindCSS
|
|---|
| 30 | - **Build Tool:** npm/Create React App
|
|---|
| 31 |
|
|---|
| 32 | ## Prerequisites
|
|---|
| 33 |
|
|---|
| 34 | Before you start, make sure you have installed:
|
|---|
| 35 |
|
|---|
| 36 | - **Java JDK 21+** - [Download](https://www.oracle.com/java/technologies/downloads/)
|
|---|
| 37 | - **Maven 3.8+** - [Download](https://maven.apache.org/download.cgi)
|
|---|
| 38 | - **Node.js 22+** - [Download](https://nodejs.org/)
|
|---|
| 39 | - **PostgreSQL 14+** (if using local database) - [Download](https://www.postgresql.org/download/)
|
|---|
| 40 | - **SSH Client** (for remote database access) - Built-in on Windows 10+, Mac, Linux
|
|---|
| 41 |
|
|---|
| 42 | ## Configuration for Remote Database
|
|---|
| 43 |
|
|---|
| 44 | ### Step 1: Setup `.env.properties` File
|
|---|
| 45 |
|
|---|
| 46 | Create a `.env.properties` file in the project root directory with your remote database credentials:
|
|---|
| 47 |
|
|---|
| 48 | ```properties
|
|---|
| 49 | # Remote Database Credentials (provided by your professor or administrator)
|
|---|
| 50 | DB_REMOTE_NAME=your_database_name
|
|---|
| 51 | DB_REMOTE_USERNAME=your_database_username
|
|---|
| 52 | DB_REMOTE_PASSWORD=your_database_password
|
|---|
| 53 |
|
|---|
| 54 | # JWT Secret for authentication
|
|---|
| 55 | JWT_SECRET=your_jwt_secret_key_min_32_characters
|
|---|
| 56 |
|
|---|
| 57 | # Local database password (for local profile, default is 'postgres')
|
|---|
| 58 | DB_PASSWORD=postgres
|
|---|
| 59 | ```
|
|---|
| 60 |
|
|---|
| 61 | **Important Security Notes:**
|
|---|
| 62 | - ⚠️ This file is in `.gitignore` and must NEVER be committed to Git
|
|---|
| 63 | - ⚠️ Keep your credentials secure and do not share them
|
|---|
| 64 | - ⚠️ Never upload this file to any public repository
|
|---|
| 65 |
|
|---|
| 66 | ### Step 2: SSH Tunnel Setup (for Remote Database)
|
|---|
| 67 |
|
|---|
| 68 | Before starting the application, you must establish an SSH tunnel to access the remote database:
|
|---|
| 69 |
|
|---|
| 70 | ```bash
|
|---|
| 71 | # Windows (Command Prompt or PowerShell)
|
|---|
| 72 | ssh -L 9999:localhost:5432 your_ssh_username@remote_server_address
|
|---|
| 73 |
|
|---|
| 74 | # Example:
|
|---|
| 75 | ssh -L 9999:localhost:5432 t_medora@194.149.135.130
|
|---|
| 76 | ```
|
|---|
| 77 |
|
|---|
| 78 | **Important:** Keep this terminal window open while running the application. The tunnel will close if you close the terminal.
|
|---|
| 79 |
|
|---|
| 80 | **Expected Output:**
|
|---|
| 81 | ```
|
|---|
| 82 | Enter password: [enter your SSH password]
|
|---|
| 83 | Access granted. Press Return to begin session.
|
|---|
| 84 | Local port 9999 forwarding to localhost:5432
|
|---|
| 85 | ```
|
|---|
| 86 |
|
|---|
| 87 | ---
|
|---|
| 88 |
|
|---|
| 89 | ## Quick Start
|
|---|
| 90 |
|
|---|
| 91 | ### Prerequisites Checklist
|
|---|
| 92 |
|
|---|
| 93 | Before starting the application, ensure you have:
|
|---|
| 94 |
|
|---|
| 95 | - Created `.env.properties` file with your database credentials
|
|---|
| 96 | - SSH tunnel is running and connected (see Configuration section above)
|
|---|
| 97 | - Terminal window with SSH tunnel remains open
|
|---|
| 98 |
|
|---|
| 99 | ---
|
|---|
| 100 |
|
|---|
| 101 | ### Step 1: Start Backend (Terminal 1)
|
|---|
| 102 |
|
|---|
| 103 | Navigate to the project root and run:
|
|---|
| 104 |
|
|---|
| 105 | ```bash
|
|---|
| 106 | cd backend
|
|---|
| 107 | ./mvnw.cmd spring-boot:run
|
|---|
| 108 | ```
|
|---|
| 109 |
|
|---|
| 110 | **Expected Output:**
|
|---|
| 111 | ```
|
|---|
| 112 | Started MedoraApplication in X seconds
|
|---|
| 113 | ```
|
|---|
| 114 |
|
|---|
| 115 | **Port:** `http://localhost:8081`
|
|---|
| 116 |
|
|---|
| 117 | ---
|
|---|
| 118 |
|
|---|
| 119 | ### Step 2: Start Frontend (Terminal 2)
|
|---|
| 120 |
|
|---|
| 121 | In a new terminal, navigate to frontend directory and run:
|
|---|
| 122 |
|
|---|
| 123 | ```bash
|
|---|
| 124 | cd frontend
|
|---|
| 125 | npm install
|
|---|
| 126 | npm start
|
|---|
| 127 | ```
|
|---|
| 128 |
|
|---|
| 129 | **Expected Output:**
|
|---|
| 130 | ```
|
|---|
| 131 | Compiled successfully!
|
|---|
| 132 | You can now view medora-frontend in the browser.
|
|---|
| 133 | Local: http://localhost:3001
|
|---|
| 134 | ```
|
|---|
| 135 |
|
|---|
| 136 | **Port:** `http://localhost:3001`
|
|---|
| 137 |
|
|---|
| 138 | ---
|
|---|
| 139 |
|
|---|
| 140 | ### Step 3: Access the Application
|
|---|
| 141 |
|
|---|
| 142 | Open your browser and navigate to: **http://localhost:3001**
|
|---|
| 143 |
|
|---|
| 144 | You should see the Medora login screen.
|
|---|
| 145 |
|
|---|
| 146 | ---
|
|---|
| 147 |
|
|---|
| 148 | ### ⚠️ Important: Keep These Terminals Open
|
|---|
| 149 |
|
|---|
| 150 | - **Terminal 0:** SSH Tunnel (must remain open)
|
|---|
| 151 | - **Terminal 1:** Backend (Spring Boot)
|
|---|
| 152 | - **Terminal 2:** Frontend (React)
|
|---|
| 153 |
|
|---|
| 154 | Close any of these and the application will stop working.
|
|---|
| 155 |
|
|---|
| 156 | ## Default Credentials & User Roles
|
|---|
| 157 |
|
|---|
| 158 | ### Admin User
|
|---|
| 159 | - **Username:** `admin`
|
|---|
| 160 | - **Password:** `admin123`
|
|---|
| 161 | - **Role:** ADMIN
|
|---|
| 162 | - **Permissions:** Full system access, user management, system configuration
|
|---|
| 163 |
|
|---|
| 164 | ### Doctor Users
|
|---|
| 165 | - **Username:** Doctor's email address (from the database)
|
|---|
| 166 | - **Password:** `doctor123`
|
|---|
| 167 | - **Role:** DOCTOR
|
|---|
| 168 | - **Permissions:** View/manage patient medical records, create prescriptions, manage appointments, request lab tests
|
|---|
| 169 |
|
|---|
| 170 | **Example:**
|
|---|
| 171 | ```
|
|---|
| 172 | Username: ivan.stojanov@medora.com
|
|---|
| 173 | Password: doctor123
|
|---|
| 174 | ```
|
|---|
| 175 |
|
|---|
| 176 | ### Patient Users
|
|---|
| 177 | - **Username:** Patient's EMBG (personal identification number)
|
|---|
| 178 | - **Password:** `password123`
|
|---|
| 179 | - **Role:** PATIENT
|
|---|
| 180 | - **Permissions:** View own medical records, view appointments, view prescriptions
|
|---|
| 181 |
|
|---|
| 182 | **Example:**
|
|---|
| 183 | ```
|
|---|
| 184 | Username: 1505993123477
|
|---|
| 185 | Password: password123
|
|---|
| 186 | ```
|
|---|
| 187 |
|
|---|
| 188 | ### Lab Technician Users
|
|---|
| 189 | - **Username:** Lab technician's email address (from the database)
|
|---|
| 190 | - **Password:** `lab123`
|
|---|
| 191 | - **Role:** LAB_TECHNICIAN
|
|---|
| 192 | - **Permissions:** Create and update lab test results, view assigned lab tests
|
|---|
| 193 |
|
|---|
| 194 | **Example:**
|
|---|
| 195 | ```
|
|---|
| 196 | Username: lab_marina
|
|---|
| 197 | Password: lab123
|
|---|
| 198 | ```
|
|---|
| 199 |
|
|---|
| 200 | ### Billing Admin Users
|
|---|
| 201 | - **Username:** Billing admin's email address (from the database)
|
|---|
| 202 | - **Password:** `adminmedora123`
|
|---|
| 203 | - **Role:** BILLING_ADMIN
|
|---|
| 204 | - **Permissions:** View billing records, generate billing reports, manage billing operations
|
|---|
| 205 |
|
|---|
| 206 | **Example:**
|
|---|
| 207 | ```
|
|---|
| 208 | Username: admin_ilija
|
|---|
| 209 | Password: adminmedora123
|
|---|
| 210 | ```
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 | ## Configuration
|
|---|
| 214 |
|
|---|
| 215 | ### Backend Configuration
|
|---|
| 216 |
|
|---|
| 217 | The backend is configured to use a **remote PostgreSQL database** via SSH tunnel.
|
|---|
| 218 |
|
|---|
| 219 | **Main Configuration File:** `backend/src/main/resources/application.properties`
|
|---|
| 220 |
|
|---|
| 221 | ```properties
|
|---|
| 222 | # Application Setup
|
|---|
| 223 | spring.application.name=medora
|
|---|
| 224 | server.port=8081
|
|---|
| 225 | spring.profiles.active=remote
|
|---|
| 226 |
|
|---|
| 227 | # Load environment variables from .env.properties
|
|---|
| 228 | spring.config.import=optional:file:.env.properties
|
|---|
| 229 |
|
|---|
| 230 | # JWT Authentication
|
|---|
| 231 | jwt.secret=${JWT_SECRET}
|
|---|
| 232 | jwt.expiration=86400000
|
|---|
| 233 |
|
|---|
| 234 | # Hibernate/JPA Settings
|
|---|
| 235 | spring.jpa.hibernate.ddl-auto=none
|
|---|
| 236 | spring.jpa.open-in-view=true
|
|---|
| 237 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
|---|
| 238 | ```
|
|---|
| 239 |
|
|---|
| 240 | **Remote Database Configuration:** `backend/src/main/resources/application-remote.properties`
|
|---|
| 241 |
|
|---|
| 242 | ```properties
|
|---|
| 243 | # Remote PostgreSQL Database (via SSH tunnel on port 9999)
|
|---|
| 244 | spring.datasource.url=jdbc:postgresql://localhost:9999/${DB_REMOTE_NAME}
|
|---|
| 245 | spring.datasource.username=${DB_REMOTE_USERNAME}
|
|---|
| 246 | spring.datasource.password=${DB_REMOTE_PASSWORD}
|
|---|
| 247 | spring.datasource.driver-class-name=org.postgresql.Driver
|
|---|
| 248 | ```
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | ## Role-Based Features
|
|---|
| 252 |
|
|---|
| 253 | ### ADMIN
|
|---|
| 254 | - ✅ Manage all users (create, update, delete)
|
|---|
| 255 | - ✅ Create and manage patients
|
|---|
| 256 | - ✅ Create and manage doctors
|
|---|
| 257 | - ✅ View all medical records
|
|---|
| 258 | - ✅ System configuration
|
|---|
| 259 | - ✅ View all appointments
|
|---|
| 260 | - ✅ Access backfill operations
|
|---|
| 261 |
|
|---|
| 262 | ### DOCTOR
|
|---|
| 263 | - ✅ View patient list
|
|---|
| 264 | - ✅ View patient medical records (diagnoses, symptoms, allergies)
|
|---|
| 265 | - ✅ Create prescriptions
|
|---|
| 266 | - ✅ Request laboratory tests
|
|---|
| 267 | - ✅ Manage appointments
|
|---|
| 268 | - ✅ Create medical reports
|
|---|
| 269 | - ❌ Cannot create new patients (admin only)
|
|---|
| 270 | - ❌ Cannot access billing information
|
|---|
| 271 |
|
|---|
| 272 | ### PATIENT
|
|---|
| 273 | - ✅ View own medical records
|
|---|
| 274 | - ✅ View own appointments
|
|---|
| 275 | - ✅ View own prescriptions
|
|---|
| 276 | - ✅ View own lab test results
|
|---|
| 277 | - ❌ Cannot view other patients' data
|
|---|
| 278 | - ❌ Cannot modify medical records
|
|---|
| 279 |
|
|---|
| 280 | ### LAB_TECHNICIAN
|
|---|
| 281 | - ✅ View assigned lab tests
|
|---|
| 282 | - ✅ Create and update lab test results
|
|---|
| 283 | - ✅ View patient information for assigned tests
|
|---|
| 284 | - ❌ Cannot create new lab tests (doctor only)
|
|---|
| 285 | - ❌ Cannot access medical records
|
|---|
| 286 | - ❌ Cannot access billing
|
|---|
| 287 |
|
|---|
| 288 | ### BILLING_ADMIN
|
|---|
| 289 | - ✅ View all billing records
|
|---|
| 290 | - ✅ Generate billing reports
|
|---|
| 291 | - ✅ Track revenue and payments
|
|---|
| 292 | - ✅ View patient information for billing purposes
|
|---|
| 293 | - ❌ Cannot access medical records
|
|---|
| 294 | - ❌ Cannot manage appointments
|
|---|
| 295 | - ❌ Cannot create prescriptions
|
|---|
| 296 |
|
|---|
| 297 | ---
|
|---|
| 298 |
|
|---|
| 299 | ## Security Features
|
|---|
| 300 |
|
|---|
| 301 | - JWT-based authentication
|
|---|
| 302 | - Role-based access control (RBAC)
|
|---|
| 303 | - Password hashing with BCrypt
|
|---|
| 304 | - CORS configuration for frontend-backend communication
|
|---|
| 305 | - SQL injection protection via parameterized queries
|
|---|
| 306 | - Request validation and error handling
|
|---|
| 307 |
|
|---|
| 308 | ## Database Migrations
|
|---|
| 309 |
|
|---|
| 310 | Database migrations are located in `backend/src/main/resources/db/migration/` and are automatically applied by Flyway on startup.
|
|---|