This guide walks through creating a Tracked Entity in DHIS2 to track water facilities, with integration to Sunbird RC for ID generation.
# DHIS2 Water Facility Registry - Liberia
Integration project for syncing Water Facility data between DHIS2 and Sunbird RC.
## Quick Start
### 1. Start Services
```bash
docker compose up -d
```
Services:
- **DHIS2**:
localhost (admin/district)
- **Sunbird RC**:
localhost
- **Keycloak**:
localhost
### 2. Configure Environment
```bash
cp .env.example .env
# Edit .env with your credentials
```
### 3. Setup DHIS2
```bash
python adapter/setup.py
```
This creates:
- Option sets (Water Point Type, Extraction Type, etc.)
- Tracked entity attributes
- Water Facility tracked entity type
- Water Facility Registry program
- Organisation units (from org_units_sample.csv)
- Test facility with syncStatus=PENDING
### 4. Run Sync
```bash
# Sync pending facilities to Sunbird RC
python adapter/sync.py
# Test connections
python adapter/sync.py --test-dhis2
python adapter/sync.py --test-sunbird
```
## Project Structure
```
.
├── adapter/
│ ├── config.json # Single source of truth for all config
│ ├── setup.py # DHIS2 setup script
│ ├── sync.py # DHIS2 ↔ Sunbird RC sync
│ └── create_facility.py # Create test TEI
├── docs/ # Documentation
├── docker-compose.yml
├── org_units_sample.csv # Sample org units
├── .env # Environment config
└── .env.example
```
## Configuration
All configuration is in `adapter/config.json`:
- **option_sets**: Dropdown options (Water Point Type, Pump Type, etc.)
- **attributes**: Tracked entity attributes with types and option set links
- **field_mapping**: DHIS2 → Sunbird RC field mapping
- **sync_status**: Status values (PENDING, SYNCED, FAILED)
- **program**: Program metadata
- **tracked_entity_type**: TE type metadata
Environment variables in `.env`:
```bash
DHIS2_URL=
localhost
DHIS2_USERNAME=admin
DHIS2_PASSWORD=district
SUNBIRD_URL=
localhost
KEYCLOAK_URL=
keycloak …