Skip to main content

Survey Solutions Integration

This page documents the integration between PCH-SIG and Survey Solutions for field data collection.

Overview

Survey Solutions is a World Bank data collection tool. The integration allows you to:

  • Synchronize households collected in the field
  • Import survey data
  • Update existing household information

Architecture

┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ Survey │ Sync │ PCH-SIG │ Store │ Database │
│ Solutions │ ------> │ API │ ------> │ PostgreSQL │
│ (Tablets) │ │ │ │ │
└─────────────────┘ └─────────────────┘ └──────────────┘

Endpoints

EndpointMethodDescription
/api/collecte/syncPOSTSynchronize Survey Solutions data
/api/collecte/menagesPOSTImport a new household
/api/collecte/menages/{id}PUTUpdate a household
/api/collecte/statusGETLast synchronization status

Synchronization

Endpoint

POST /api/collecte/sync

Request Body

{
"source": "survey_solutions",
"questionnaireId": "abc123",
"data": [
{
"interview__id": "int-001",
"menage_code": "MEN-OIO-001",
"region": "Oio",
"secteur": "Farim",
"localite": "Farim Centro",
"chef_nom": "Mamadou Diallo",
"chef_sexe": "M",
"taille_menage": 5,
"nb_enfants_0_4": 1,
"nb_enfants_5_14": 2,
"latitude": 12.3456,
"longitude": -15.6789,
"distance_ecole": 1.5,
"distance_sante": 2.3
}
]
}

Response

{
"success": true,
"data": {
"processed": 150,
"created": 120,
"updated": 25,
"errors": 5,
"errorDetails": [
{
"interview__id": "int-045",
"error": "Region not found: Unknown"
}
]
}
}

Field Mapping

Household

Survey SolutionsPCH-SIGDescription
interview__idcollecteIdUnique interview ID
menage_codecodeHousehold code
regionregion.nomRegion name
secteursecteur.nomSector name
localitelocalite.nomLocality name
gps__LatitudelatitudeGPS latitude
gps__LongitudelongitudeGPS longitude
gps__AccuracyprecisionGpsAccuracy in meters
taille_menagetailleMenageHousehold size
nb_enfants_0_4nbEnfants04Children 0-4 years
nb_enfants_5_14nbEnfants514Children 5-14 years
distance_ecoledistanceEcoleDistance to school (km)
distance_santedistanceSanteDistance to health center (km)

Head of Household

Survey SolutionsPCH-SIGDescription
chef_nomchefMenage.nomCompletFull name
chef_sexechefMenage.sexeGender (M/F)
chef_agechefMenage.ageAge
chef_telephonechefMenage.telephonePhone
chef_educationchefMenage.niveauEducationEducation level

Housing

Survey SolutionsPCH-SIGDescription
type_logementlogement.typeLogementHousing type
statut_occupationlogement.statutOccupationOccupancy status
nb_pieceslogement.nbPiecesNumber of rooms
materiau_murlogement.materiauMurWall material
materiau_toitlogement.materiauToitRoof material
source_eaulogement.sourceEauWater source
type_toilettelogement.typeToiletteToilet type

New Fields

Distance to Services

Distance to social services fields have been added:

FieldTypeDescription
distanceEcoledecimalDistance to nearest school (km)
distanceSantedecimalDistance to health center (km)
distanceMarchedecimalDistance to market (km)
distanceEauPotabledecimalDistance to water point (km)

These fields are used for:

  • PMT score calculation
  • Vulnerability analysis
  • Geographic targeting

Conflict Management

Update Strategy

By default, synchronization uses the "last update wins" strategy:

  • If collecteId exists: update fields
  • If collecteId doesn't exist: create

Protected Fields

Some fields are not updated after initial collection:

  • code (household code)
  • dateEnregistrement
  • createdAt

Data Validation

Validation Rules

FieldRuleError Message
regionMust exist"Region not found"
tailleMenage> 0"Invalid household size"
latitude-90 to 90"Latitude out of bounds"
longitude-180 to 180"Longitude out of bounds"

Error Handling

Errors are returned in errorDetails:

{
"errorDetails": [
{
"interview__id": "int-045",
"field": "region",
"value": "Unknown",
"error": "Region not found"
}
]
}

Synchronization Status

Endpoint

GET /api/collecte/status

Response

{
"success": true,
"data": {
"lastSync": "2026-06-12T08:30:00+00:00",
"lastSyncStatus": "success",
"totalProcessed": 150,
"totalErrors": 0,
"pendingSync": 0,
"nextScheduledSync": "2026-06-12T20:00:00+00:00"
}
}

Configuration

Environment Variables

SURVEY_SOLUTIONS_URL=https://survey.example.com
SURVEY_SOLUTIONS_API_USER=api_user
SURVEY_SOLUTIONS_API_KEY=secret_key
SURVEY_SOLUTIONS_WORKSPACE=pch_gb

Scheduling

Synchronization can be scheduled via cron:

# Daily synchronization at 8pm
0 20 * * * /usr/bin/php /app/bin/console app:sync-survey-solutions

Permissions

ActionPermission
Synchronizeregistre.collecte_sync
View statusregistre.collecte_view

Best Practices

:::tip Recommendations

  1. Test in preprod: Validate the mapping before production
  2. Verify GPS: Check coordinate quality
  3. Monitoring: Monitor synchronization errors
  4. Backup: Export Survey Solutions data regularly :::