🏥 Remote Medical Care Platform

Complete Developer Documentation - Set Up Guide for New Development Teams

Project Overview

The Remote Medical Care Platform is a comprehensive telemedicine solution that connects patients with healthcare professionals through a web application and mobile apps. The system enables virtual consultations, medical test management, patient monitoring, and comprehensive health record management.

Project Structure

Technology Stack

User Roles & Permissions

The platform supports five distinct user roles, each with specific functionalities and permissions. Below is a comprehensive overview of each role.

Role Primary Functions Key Capabilities
Super Admin Platform-wide management and oversight • Manage all clinics, doctors, and patients
• Manage user roles
• Assign permissions to roles
• View system-wide dashboards and statistics
• Manage specializations and health conditions
• Other system administration tasks
Clinic Admin Clinic-level management and operations • Manage clinic information and settings
• Oversee all doctors in the clinic
• Oversee all patients registered with the clinic
• Monitor clinic-specific appointments
• View clinic dashboards and analytics
• Manage clinic doctors, patients, and assistants
Doctor Patient care, appointments, and test management • View assigned patients
• Schedule and manage appointments
• Create examination plans with tests
• Assign tests to patients
• Review test results
• Provide assessments
• Manage it's assistants
• Access patient medical history and documents
• Create Examination Plan
• Setup his availability
• Enable/Disable Diabtest Diary for the Patient.
• Do video consulation with the patient.
• Setup his profile and specialization
Patient Personal health management and consultation • Book appointments with doctors
• Perform assigned tests via mobile app
• Perform Self Examination with devices via mobile app
• Upload and share documents
• Use AI Assistant for appointment booking
• Use AI for Meal Analysis
• Use Bolus Insulin Calultor in mobile app
• View test results
• Access medical history
• Manage health information (allergies, medications, etc.)
• Download and export documents
• Use mobile app for synchronization for medical data from Apple Health and Google Health
• Perform tests for the assigned examination plan.
• Receive reminders for tests and appointments.
• Other functions related health management
Doctor Assistant Support for doctor operations and patient care • Assist doctors with patient management
• Help with appointment scheduling
• Access specific permissions assigned by doctor

Mobile Application

Patients interact with the platform primarily through the mobile application, which is available for both iOS and Android platforms.

Mobile App Overview

Note: Patients have a dedicated mobile app for booking appointments, video consulation with doctor , use of medical devices for performing various tests, health data synchronization from Apple Health and Google Health. The mobile app communicates with the backend through RESTful APIs.

App Availability

Platform Status Server Details
Apple App Store Production Clinic Server Release for the purpose of testing of plateform for some specific clinics. Do not have latest developements.
Apple TestFlight Testing Care Server Latest features and updates
Android APK Available Both Servers Direct APK download from Login page for Android devices

Medical Devices & IoT Integration

The mobile app supports integration with various medical devices that can capture health metrics. Patients can use these devices to record health data, which is then submitted through the mobile app to the platform.

Supported Medical Devices

Health Data Synchronization

The mobile app supports synchronization with popular health platforms:

Device Data Flow

The system allows for the creation and management of devices through the Devices API. Each device can be linked to clinics through the DeviceClinic endpoint, enabling clinic-specific device configurations.

Device Management API Endpoints:
  • POST /api/add_new_device - Add new device
  • GET /api/devices/get_all - Get all available devices
  • GET /api/devices/{device_id} - Get device details
  • POST /api/device_clinics/register - Register device with clinic

System Architecture

The Remote Medical Care Platform follows a modern REST API architecture with separated concerns between the frontend and backend.

Architectural Overview

System Components:

  • Web Application (Browser): Built with HTML/CSS/JavaScript - Calls REST APIs
  • Mobile Application (iOS/Android): Native apps - Calls REST APIs
  • Backend API Server (CI4): RESTful API endpoints at /api/
  • Database Layer: MySQL database storing all application data
  • External Services: Agora (communication), PDF.co (PDF processing), OpenAI (AI features)

Request Flow

Mobile App / Web Browser
        ↓
    HTTP/HTTPS
        ↓
    REST API Layer (/api/*)
        ↓
    Controllers (app/Controllers/Api/)
        ↓
    Models (app/Models/)
        ↓
    MySQL Database
        ↓
    External Services (Agora, PDF.co, OpenAI)
            

CodeIgniter 4 Project Structure

Directory Purpose
app/Controllers/ Web application controllers (for web views)
app/Controllers/Api/ API controllers handling all REST endpoints
app/Models/ Data models managing database interactions
app/Views/ Web application views (HTML templates)
app/Config/ Configuration files (Routes, Database, Services, etc.)
app/Database/ Migrations and seeds for database schema
app/Traits/ Reusable trait classes
app/Helpers/ Helper functions and utilities
app/Enum/ Enumeration classes for constants
public/ Public assets, uploads, and entry point
writable/ Writable directories (logs, cache, uploads)

Key API Controllers

Multi-Language Support (Localization)

The platform supports 4 languages: English (en), German (de), Spanish (es), and Arabic (ar). Language files are organized in app/Language/ directory. Configure in app/Config/App.php:

public string $defaultLocale = 'en';
public array $supportedLocales = ['en', 'de', 'es', 'ar'];
            

Using Language Strings

Adding New Translations

Add new key-value pairs to language files in app/Language/{language}/app.php for each supported language and use my_lang('key') in views or controllers.

External APIs & Third-Party Services

The platform integrates with several external services to provide comprehensive features. Below is a complete guide to configuring these services in the .env file.

1. Agora.io - Real-Time Communication

Purpose:

Agora.io provides real-time video call capabilities for doctor-patient consultations and communication.

.env Configuration:

# Agora App Credentials
appID = "YOUR_AGORA_APP_ID"
appCertificate = "YOUR_AGORA_APP_CERTIFICATE"
agoraChatHost = "a71.chat.agora.io"
agoraChatAppName = "YOUR_AGORA_CHAT_APP_NAME"
agoraChatOrgName = "YOUR_AGORA_ORG_NAME"
                

API Endpoints:

  • POST /api/agora/get_token - Generate video meeting token
  • GET /api/agora/get_chat_app_token - Generate chat app token
  • POST /api/agora/register_user - Register user in Agora
  • GET /api/agora/get_chat_user_token/{user_id} - Get chat token for user
  • POST /api/agora/update_appointment_status/{appointment_id} - Update meeting status

2. PDF.co - Document Upload & Image Extraction

Purpose:

PDF.co is used for processing uploaded medical documents (PDF files) by converting them to images and extracting information. When patients upload medical documents or lab reports as PDFs, the system uses PDF.co to convert these files to images, which can then be processed for information extraction and display.

.env Configuration:

# PDF.co API Key
pdfCoKey = "YOUR_PDFCO_API_KEY"
                

API Endpoints:

  • POST /api/extract_file_info - Extract information from uploaded documents
  • POST /api/add_document - Upload and process medical documents

3. OpenAI (ChatGPT) - Symptom-Based Doctor Recommendation & Meal Analysis

Purpose:

ChatGPT powers the intelligent appointment booking system. When a patient wants to book an appointment, they enter their symptoms. These symptoms are sent to ChatGPT, which asks targeted diagnostic questions (max 10) to understand the patient's condition. Based on the answers to these questions, ChatGPT makes a diagnosis, and the system then shows appropriate doctors who are specialized in treating that diagnosed condition. The patient can then book an appointment with one of these recommended doctors.

Additionally, GPT Vision API analyzes meal images to extract nutritional information including dish name, ingredients, and carbohydrate content for dietary tracking.

.env Configuration:

openaiKey = "sk-YOUR_OPENAI_API_KEY"
                

Setup Requirements:

  • Create account at https://platform.openai.com
  • Generate API key and set up billing

Features:

  • Symptom collection during appointment booking
  • Ask diagnostic questions to determine patient condition
  • AI diagnosis based on symptom analysis
  • Specialist recommendations based on diagnosis
  • Doctor matching by specialization
  • Meal image analysis using GPT Vision API for nutritional extraction

API Endpoints:

  • POST /api/talk_to_ai_assistant - Send symptoms and receive diagnostic questions
  • POST /api/get_specializations_against_diagnosis - Get specializations for diagnosed condition
  • POST /api/get_doctors_by_specializations - Get doctors for recommended specialization
  • POST /api/extract_meal_information - Analyze meal image (uses GPT Vision)

Environment Configuration Summary

Service Configuration Key Documentation
Agora appID, appCertificate, agoraChatHost, agoraChatAppName, agoraChatOrgName Agora Docs
PDF.co pdfCoKey PDF.co Docs
OpenAI openaiKey OpenAI Docs
⚠️ Security Alert: Never commit API keys to version control. Always use environment variables and keep .env files out of repositories. Use different keys for development and production environments.

Production & Development Servers

The platform operates on two distinct servers to manage development cycles and production deployment separately.

Server URL Environment Purpose
Care Server http://care.remotemedtech.com/ Development/Testing ✓ Latest development features
✓ TestFlight iOS app uses this
✓ Internal testing environment
✓ New features developed here
Clinic Server https://clinic.remotemedtech.com/ Production ✓ Stable, production-ready code
✓ Public App Store iOS app uses this
✓ For specific clinic deployments
Key Point: All new developments are implemented on the Care server. The Clinic server was initially developed for specific clinic deployments. The Care server is where all cutting-edge features are tested before promotion to production.

Core Platform Features

The Remote Medical Care Platform provides a comprehensive suite of features for healthcare delivery and patient management.

1. User Management & Authentication

Features:
  • User registration with role assignment
  • Password authentication
  • Password reset and recovery
  • User profile management
  • Multi-clinic user support
  • User invitations and onboarding
  • Account deletion requests with approval workflow

2. Appointment Management

Features:
  • Book appointments with doctors
  • View available time slots
  • Reschedule appointments
  • Cancel appointments with deadline management
  • Appointment status
  • Follow-up appointment management
  • Guest invitations to appointments
  • Appointment reminders to patients and doctors
  • Test assignment during appointments
  • Assessment record saving

3. Medical Testing & Results

Features:
  • Create and manage medical tests
  • Assign tests to patients through examination plans
  • Patient self-test result submission via mobile app
  • Doctor review and comment on results
  • Test result history
  • Normal range configuration per test
  • Out-of-range alerts for critical values
  • Test plan timing and scheduling

4. Examination Plans

Features:
  • Create comprehensive examination plans for patients
  • Define test frequency and duration
  • Assign multiple tests to a single plan
  • Track plan status (active, completed, stopped)
  • Send test reminders to patients
  • View examination plan details
  • Stop plans

5. Patient Health Diary

Features:
  • Enable/disable diary for patients
  • Daily health measurements
  • Meal tracking and nutrition recording
  • Insulin administration
  • Glucose level monitoring
  • Diary statistics and analytics
  • Export diary to PDF
  • Email diary reports to patients
  • AI-powered meal information extraction
  • Graphical data visualization (glucose, meals, insulin)
  • Bolus calculator for insulin dosing

6. Patient Medical History

Features:
  • Personal health history
  • Height and weight
  • Medical conditions documentation
  • Medication history
  • Allergy information (food, medication, environmental)
  • Vaccination records
  • Surgical history
  • Family disease history
  • Trauma history
  • Genetic disorders tracking
  • Neurological conditions documentation
  • Lifestyle factors (stress, exercise, diet)

7. Doctor Management & Assistants

Features:
  • Doctor profile and specialization management
  • Doctor availability and timing configuration
  • Doctor assistant assignment and management
  • Granular permission assignment to assistants
  • Doctor-patient management
  • Patient list per doctor
  • Doctor dashboard with statistics

8. Video Consultations

Features:
  • Real-time video consultations via Agora
  • Meeting token generation
  • Appointment status updates
  • Guest access to consultations
  • Meeting link generation and sharing

9. Document Management

Features:
  • Upload and store medical documents
  • Document categorization
  • Share documents with doctors
  • Document visibility control (public/private)
  • AI-powered information extraction from documents
  • Document deletion

10. AI-Powered Health Assistant

Features:
  • Ask questions based on symptoms
  • Doctor matching based on diagnosis predicted by the AI.

11. Clinic Management

Features:
  • Multi-clinic support
  • Clinic information management
  • Doctor assignment to clinics
  • Patient clinic registration
  • Clinic admin management
  • Clinic-specific dashboards
  • Clinic-specific device configuration

12. Notifications & Communication

Features:
  • Appointment reminders
  • Test result notifications
  • Email notifications
  • Notification read/unread tracking

13. Role-Based Access Control

Features:
  • Role creation and management
  • Permission-based access control
  • Fine-grained permission assignment
  • Role hierarchy support
  • Custom permission combinations

14. System Administration

Features:
  • User management dashboard
  • Role and permission configuration
  • Test and health condition setup
  • Specialization management
  • System-wide analytics
  • Account deletion request handling

15. Automation & Scheduled Tasks

Features (via Cron Jobs):
  • Automatic appointment status updates
  • Test plan daily entry generation
  • Test reminder notifications
  • Appointment reminders to patients and doctors
  • Expired notification cleanup

Feature Summary Grid

Appointments
Booking, scheduling, rescheduling, cancellation
Tests
Assignment, submission, results, tracking
Medical History
Conditions, medications, allergies, surgeries
Diary
Daily tracking, meals, glucose, insulin
Video Calls
Real-time consultations via Agora
Documents
Upload, share, extract information
AI Assistant
Diagnosis, recommendations, guidance
Multi-Clinic
Support multiple clinics
Mobile Devices
IoT device integration for health tracking
Analytics
Dashboards for doctors, patients, admins

Development Setup & Environment Configuration

Prerequisites

Required PHP Extensions

.env File Configuration

Copy the provided env file to .env and configure the following sections:

Basic App Configuration

app.baseURL = 'http://localhost/rmc'  # Your local development URL
apiURL = 'http://localhost/rmc/api/'  # API base URL

# Mobile app download links
apkURL = "http://localhost/rmc/public/assets/files/REC.care.apk"
iosURL = "https://testflight.apple.com/join/cEYQsFL7"
            

Database Configuration

database.default.hostname = 'localhost'
database.default.database = 'rmc'
database.default.username = 'root'
database.default.password = ''
database.default.DBDriver = 'MySQLi'
database.default.port = 3306
            

External API Keys (CRITICAL)

# Agora Configuration
appID = "YOUR_AGORA_APP_ID"
appCertificate = "YOUR_AGORA_CERTIFICATE"
agoraChatHost = "a71.chat.agora.io"
agoraChatAppName = "YOUR_CHAT_APP_NAME"
agoraChatOrgName = "YOUR_ORG_NAME"

# PDF.co Configuration
pdfCoKey = "YOUR_PDF_CO_API_KEY"

# OpenAI Configuration
openaiKey = "YOUR_OPENAI_API_KEY"
            

Installation Steps

  1. Clone the repository: git clone [repository-url]
  2. Navigate to project: cd RemoteMedicalCare-Web
  3. Install dependencies: composer install
  4. Copy env file: cp env .env
  5. Configure .env with your database and API credentials
  6. Create database: CREATE DATABASE rmc;
  7. Run migrations: php spark migrate
  8. Seed initial data: php spark db:seed SeedName
  9. Start development server: php spark serve

Directory Permissions

Ensure the writable directory has proper permissions:

chmod -R 755 writable/
            

Deployment to Production (NetCup Server)

To deploy the website to production, you need server credentials from NetCup hosting provider.

Required Credentials:

Deployment Steps:

  1. Obtain FTP/SFTP credentials from your NetCup account dashboard
  2. Connect to the server using SFTP client (FileZilla, WinSCP, or command line)
  3. Upload all project files to the server (exclude vendor/, .env, and writable/)
  4. Create a production .env file on the server with production database and API credentials
  5. Run composer install --no-dev on the server to install dependencies
  6. Run database migrations: php spark migrate
  7. Set proper file permissions: chmod -R 755 writable/
  8. Test the application on the production server

Quick Links & Resources