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​

The SIG pulls interviews from the Survey Solutions server: there is no endpoint where Survey Solutions would push data.

Household import​

EndpointMethodPermissionDescription
/api/menages/survey-solutions/importPOSTregistre.importImports interviews of a questionnaire
/api/menages/survey-solutions/syncPOSTregistre.importSyncs one questionnaire, or all active household questionnaires
/api/menages/survey-solutions/questionnairesGETregistre.importHousehold questionnaires
/api/menages/survey-solutions/statsGETregistre.menages_viewImport statistics

Updating existing households​

EndpointMethodPermissionDescription
/api/menages/survey-solutions/updates/processPOSTregistre.menages_editApplies update interviews
/api/menages/survey-solutions/updates/syncPOSTregistre.menages_editManual update sync
/api/menages/survey-solutions/updates/questionnairesGETregistre.menages_viewUpdate questionnaires
/api/menages/survey-solutions/updates/statsGETregistre.menages_viewUpdate statistics

Synchronization​

POST /api/menages/survey-solutions/sync
{ "questionnaireId": "<uuid du questionnaire dans le SIG>" }

Without questionnaireId, all active household questionnaires are synced.

{
"success": true,
"message": "Synchronisation terminée: 120 ménage(s) importé(s), 25 doublon(s), 5 erreur(s)",
"resultats": {
"succes": 120,
"doublons": 25,
"erreurs": 5,
"questionnaires": [
{ "id": "…", "title": "Questionnaire ménage", "result": { "…": "détail par interview" } }
]
}
}

Errors: 404 Questionnaire non trouvé, 400 Aucun questionnaire de type ménage configuré.

Targeted import​

POST /api/menages/survey-solutions/import
{
"questionnaireId": "<uuid du questionnaire dans le SIG>",
"interviews": [{ "id": "…", "key": "12-34-56-78" }]
}

questionnaireId is required (400 ID du questionnaire requis) and the questionnaire must be of household type. Each interview's detail carries a success or duplicate status, or an error; a duplicate is not re-imported.


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​

Import never replaces an existing household: an interview already imported is counted as a duplicate and skipped. Updating an existing household goes through the /api/menages/survey-solutions/updates/* routes.

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​

Each interview in error appears in the result detail with its index and the error message; the other interviews of the batch are imported.


Configuration​

Environment Variables​

SUSO_API_URL=https://survey.example.org
SUSO_API_USER=<utilisateur API>
SUSO_API_PASSWORD=<voir gestionnaire de secrets>
SUSO_WORKSPACE=<workspace>

A project can have its own sync configuration (GET/PUT /api/projets/{id}/synchronisation); otherwise the global configuration applies.

Scheduling​

php bin/console app:survey-solutions:sync

Permissions​

ActionPermission
Synchronizeregistre.collecte_sync
View statusregistre.collecte_view

Best Practices​

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