Django REST API for monitoring dementia patients with wearable devices.
- Health Monitoring: Track heart rate, SpO2, body temperature, steps, and sleep quality
- Device Management: Register devices and assign them to patients
- Alert System: Real-time alerts with SMS notifications
- Patient Management: Store patient profiles and medical information
- Firebase Authentication: Secure user authentication
- Admin Interface: Django admin with filtering and management tools
Heart rate calibration is supported via the HEART_BEAT_OFFSET setting:
# Set environment variable for heart rate offset
export HEART_BEAT_OFFSET=-10Example:
- Device sends: 90 BPM
- Offset: -10
- Stored in DB: 80 BPM
This helps calibrate heart rate readings from devices with systematic measurement errors.
SpO2 calibration is supported via the SPO2_OFFSET setting:
# Set environment variable for SpO2 offset
export SPO2_OFFSET=-2Example:
- Device sends: 98%
- Offset: -2
- Stored in DB: 96%
This helps calibrate SpO2 readings from devices with systematic measurement errors.
Health metric endpoints include both the stored value and the original device value:
Heart Rate:
{
"id": "uuid",
"value": 80,
"original_device_value": 90,
"patient": "patient-uuid",
"device": "device-uuid",
"timestamp": "2024-01-01T12:00:00Z",
"metadata": {}
}SpO2:
{
"id": "uuid",
"value": 96,
"original_device_value": 98,
"patient": "patient-uuid",
"device": "device-uuid",
"timestamp": "2024-01-01T12:00:00Z",
"metadata": {}
}-
Install dependencies:
pip install -r requirements.txt
-
Set environment variables:
export DJANGO_SECRET_KEY="your-secret-key" export HEART_BEAT_OFFSET=0 # Adjust as needed export SPO2_OFFSET=0 # Adjust as needed export FIREBASE_CREDENTIALS_PATH="path/to/firebase_auth.json"
-
Set up Firebase credentials:
- Copy
firebase_auth.json.templatetofirebase_auth.json - Fill in your Firebase service account credentials
- Copy
-
Run migrations:
python manage.py migrate --settings=api.settings_local
-
Create superuser:
python manage.py createsuperuser --settings=api.settings_local
-
Run the server:
python manage.py runserver --settings=api.settings_local
GET/POST /api/v1/heart-rate/- Heart rate dataGET/POST /api/v1/spo2/- SpO2 dataGET/POST /api/v1/steps/- Steps dataGET/POST /api/v1/body-temperature/- Body temperature dataGET/POST /api/v1/sleep-quality/- Sleep quality dataGET/POST /api/v1/alerts/- AlertsGET/POST /api/v1/patients/- Patient managementGET/POST /api/v1/devices/- Device management
Access the admin interface at /admin/ with features including:
- Filtering and searching
- Bulk actions for alerts and reminders
- Status indicators for health metrics
- Data management tools