Patients Module

إدارة المرضى الشاملة - Complete Patient Management System

Ready Core Module 54+ Endpoints

جدول المحتويات

نظرة عامة - Overview

Patients Module يوفر نظام شامل لإدارة سجلات المرضى مع جميع البيانات الطبية والشخصية.

الميزات الرئيسية:

  • Complete Patient Profile: معلومات شخصية كاملة
  • Medical Records: Allergies, Medications, Conditions
  • Vital Signs: قراءات العلامات الحيوية
  • Insurance Management: إدارة التأمين الصحي
  • Family History: التاريخ المرضي للعائلة
  • Multiple Identifiers: رقم هوية، جواز سفر، رقم تأمين
  • Emergency Contacts: جهات الاتصال في الطوارئ
  • Advanced Search: بحث متقدم مع autocomplete
  • Bulk Operations: عمليات جماعية
  • Patient Merge: دمج السجلات المكررة
  • Media Management: إدارة الملفات والصور
  • Audit Trail: تتبع كامل للتغييرات
ملاحظة هامة: جميع العمليات محمية بـ Authentication و Authorization مع دعم Soft Deletes.

الكيانات - Database Entities (12)

1. Patient

Main Entity

الجدول الرئيسي لبيانات المرضى

الحقول الأساسية:

Field Type Description Required
first_name string الاسم الأول
last_name string الاسم الأخير
date_of_birth date تاريخ الميلاد
gender enum الجنس (male, female, other)
phone string رقم الهاتف
email string البريد الإلكتروني
medical_record_number string رقم السجل الطبي (auto-generated) Auto

Relations:

  • details() → PatientDetail (hasOne)
  • identifiers() → PatientIdentifier (hasMany)
  • contacts() → PatientContact (hasMany)
  • allergies() → PatientAllergy (hasMany)
  • medications() → PatientMedication (hasMany)
  • conditions() → PatientCondition (hasMany)
  • vitals() → PatientVital (hasMany)
  • insurances() → PatientInsurance (hasMany)
  • familyHistory() → PatientFamilyHistory (hasMany)

2. PatientDetail

Extended Info

معلومات تفصيلية إضافية عن المريض

الحقول:

  • nationality - الجنسية
  • marital_status - الحالة الاجتماعية (single, married, divorced, widowed)
  • occupation - المهنة
  • emergency_contact - جهة الاتصال في الطوارئ (JSON)
  • language_preference - اللغة المفضلة
  • blood_type - فصيلة الدم (A+, A-, B+, B-, AB+, AB-, O+, O-)
  • height - الطول (cm)
  • weight - الوزن (kg)

Other Entities (10)

Medical Records
  • PatientIdentifier: معرفات المريض (هوية، جواز، تأمين)
  • PatientContact: جهات الاتصال
  • PatientAllergy: الحساسيات
  • PatientMedication: الأدوية الحالية
  • PatientCondition: الحالات الطبية والأمراض المزمنة
  • PatientVital: قراءات العلامات الحيوية
  • PatientInsurance: بيانات التأمين الصحي
  • PatientFamilyHistory: التاريخ المرضي للعائلة
  • PatientNote: ملاحظات طبية
  • PatientAudit: سجل التدقيق والتغييرات

API Endpoints (54+ endpoint)

Authentication Required: جميع الـ endpoints تتطلب Bearer Token عبر Authorization: Bearer {token}

1. Patient CRUD APIs (8 endpoints)

GET
/api/patients
قائمة المرضى مع pagination وفلترة
📖 عرض التفاصيل الكاملة
Query Parameters:
Parameter Type Description Example
search string بحث في الاسم، الهاتف، البريد ?search=أحمد
gender string فلترة حسب الجنس ?gender=male
date_of_birth date فلترة حسب تاريخ الميلاد ?date_of_birth=1990-01-01
per_page integer عدد النتائج في الصفحة ?per_page=20
include string تضمين العلاقات ?include=details,allergies
Response Example:
{
  "status": true,
  "data": [
    {
      "id": 1,
      "first_name": "أحمد",
      "last_name": "محمد",
      "medical_record_number": "PAT-2025-00001",
      "date_of_birth": "1990-01-15",
      "gender": "male",
      "phone": "+966501234567",
      "email": "ahmad@example.com",
      "created_at": "2025-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 15,
    "total": 150,
    "last_page": 10
  }
}
cURL Example:
curl -X GET "https://api.example.com/api/patients?search=أحمد&per_page=20" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"
GET
/api/patients/{id}
تفاصيل مريض محدد
📖 عرض التفاصيل
Path Parameters:
  • id - Patient ID (integer, required)
Response Example:
{
  "status": true,
  "data": {
    "id": 1,
    "first_name": "أحمد",
    "last_name": "محمد",
    "medical_record_number": "PAT-2025-00001",
    "date_of_birth": "1990-01-15",
    "gender": "male",
    "phone": "+966501234567",
    "email": "ahmad@example.com",
    "details": {
      "nationality": "Saudi",
      "marital_status": "married",
      "blood_type": "O+",
      "occupation": "Engineer"
    },
    "allergies_count": 2,
    "medications_count": 1,
    "created_at": "2025-01-15T10:30:00Z"
  }
}
POST
/api/patients
إنشاء مريض جديد
📖 عرض التفاصيل
Request Body:
{
  "first_name": "أحمد",
  "last_name": "محمد",
  "date_of_birth": "1990-01-15",
  "gender": "male",
  "phone": "+966501234567",
  "email": "ahmad@example.com",
  "address": "الرياض، السعودية"
}
Validation Rules:
  • first_name - required, string, max:100
  • last_name - required, string, max:100
  • date_of_birth - required, date, before:today
  • gender - required, in:male,female,other
  • phone - nullable, string, unique:patients
  • email - nullable, email, unique:patients
Success Response (201 Created):
{
  "status": true,
  "message": "Patient created successfully",
  "data": {
    "id": 123,
    "medical_record_number": "PAT-2025-00123",
    "first_name": "أحمد",
    "last_name": "محمد",
    ...
  }
}
PUT
/api/patients/{id}
تحديث بيانات مريض
DELETE
/api/patients/{id}
أرشفة مريض (Soft Delete)
POST
/api/patients/{id}/restore
استعادة مريض من الأرشيف
GET
/api/patients-search
بحث متقدم في سجلات المرضى
GET
/api/patients-autocomplete
اقتراحات تلقائية للبحث السريع
📖 عرض التفاصيل

الوصف: يرجع قائمة مختصرة للاستخدام في autocomplete/typeahead

Query Parameters:
  • q - النص المراد البحث عنه (required, min:2)
  • limit - عدد النتائج (default: 10, max: 50)
Response Example:
{
  "status": true,
  "data": [
    {
      "id": 1,
      "label": "أحمد محمد - PAT-2025-00001",
      "mrn": "PAT-2025-00001",
      "phone": "+966501234567"
    },
    {
      "id": 2,
      "label": "أحمد علي - PAT-2025-00042",
      "mrn": "PAT-2025-00042",
      "phone": "+966509876543"
    }
  ]
}

2. Medical Records APIs (20 endpoints)

Allergies APIs:

GET
/api/patients/{patient}/allergies
قائمة الحساسيات
POST
/api/patients/{patient}/allergies
إضافة حساسية جديدة
📖 عرض التفاصيل
Request Body:
{
  "allergen": "Penicillin",
  "category": "medication",
  "reaction": "Skin rash",
  "severity": "moderate",
  "onset_date": "2023-06-15",
  "notes": "Developed after first dose"
}
Field Options:
  • category: medication, food, environmental, other
  • severity: mild, moderate, severe
PUT
/api/patients/{patient}/allergies/{id}
تحديث حساسية
DELETE
/api/patients/{patient}/allergies/{id}
حذف حساسية

Medications APIs:

GET
/api/patients/{patient}/medications
قائمة الأدوية الحالية
POST
/api/patients/{patient}/medications
إضافة دواء جديد

Vital Signs APIs:

GET
/api/patients/{patient}/vitals
قراءات العلامات الحيوية
POST
/api/patients/{patient}/vitals
إضافة قراءة جديدة
📖 عرض التفاصيل
Request Body:
{
  "blood_pressure": "120/80",
  "heart_rate": 72,
  "temperature": 36.8,
  "respiratory_rate": 16,
  "oxygen_saturation": 98,
  "weight": 75.5,
  "height": 175,
  "recorded_at": "2024-01-15 14:30:00"
}

3. Bulk Operations APIs (4 endpoints)

POST
/api/patients/bulk
إنشاء عدة مرضى دفعة واحدة
📖 عرض التفاصيل
Request Body:
{
  "patients": [
    {
      "first_name": "أحمد",
      "last_name": "محمد",
      "date_of_birth": "1990-01-15",
      "gender": "male"
    },
    {
      "first_name": "فاطمة",
      "last_name": "علي",
      "date_of_birth": "1992-05-20",
      "gender": "female"
    }
  ]
}
Response:
{
  "status": true,
  "message": "2 patients created successfully",
  "data": {
    "created": 2,
    "failed": 0,
    "patients": [...]
  }
}
PUT
/api/patients/bulk
تحديث عدة مرضى دفعة واحدة
POST
/api/patients/bulk-archive
أرشفة عدة مرضى دفعة واحدة
POST
/api/patients/bulk-restore
استعادة عدة مرضى من الأرشيف

4. Advanced APIs (8 endpoints)

POST
/api/patients/merge
دمج سجلات مرضى مكررة
📖 عرض التفاصيل
تحذير: هذه العملية لا يمكن التراجع عنها!
Request Body:
{
  "source_patient_id": 123,
  "target_patient_id": 456
}

الوصف: يتم دمج جميع السجلات والعلاقات من source إلى target ثم حذف source

GET
/api/patients/{patient}/audit
سجل التدقيق والتغييرات
GET
/api/patients/{patient}/media/{collection}
عرض ملفات مريض
POST
/api/patients/{patient}/media/{collection}
رفع ملف جديد
GET
/api/patients-export.csv
تصدير بيانات المرضى إلى CSV

التكامل مع Modules الأخرى

1. Care Module (Appointments & Encounters)

// عرض مواعيد مريض معين
$patient = Patient::find(1);
$appointments = $patient->appointments;

// عرض زيارات المريض
$encounters = $patient->encounters;

2. Pharmacy Module (Prescriptions)

// التحقق من الحساسيات قبل الصرف
$patient = Patient::with('allergies')->find(1);

foreach ($patient->allergies as $allergy) {
    if ($allergy->category === 'medication') {
        // تحذير: المريض لديه حساسية من دواء
    }
}

3. Lab Module (Test Orders)

// طلب فحص مخبري لمريض
$patient->labOrders()->create([
    'test_type' => 'Complete Blood Count',
    'ordered_at' => now()
]);

Best Practices

✅ التوصيات

  • استخدم Soft Deletes: دائماً استخدم archive بدلاً من الحذف النهائي
  • تحقق من الحساسيات: تأكد من فحص allergies قبل صرف الأدوية
  • استخدم Autocomplete: للتحقق من عدم تكرار السجلات
  • سجل Vital Signs: بشكل دوري للمرضى المنومين
  • Audit Trail: راجع audit logs بانتظام

❌ تجنب

  • إنشاء سجلات مكررة للمريض نفسه
  • تحديث medical_record_number يدوياً
  • حذف سجلات المرضى نهائياً
  • تجاهل emergency contacts

Statistics & Summary

12
Entities
54+
API Endpoints
100%
Authenticated
Ready
Status