
Export Validation Flags to MongoDB
export_validation_flags.RdExports validation flags to MongoDB, keeping the decisions reviewers made in
the Peskas Management Platform or in KoboToolbox (read beforehand with
coasts::review_decisions()).
Usage
export_validation_flags(
conf = NULL,
asset_id = c("v1", "v2"),
all_flags = NULL,
validation_statuses = NULL
)Arguments
- conf
Configuration object from
read_config()containing MongoDB connection parameters and survey-specific settings- asset_id
Character string specifying which survey to process. Must be one of "v1" or "v2". Determines which configuration to use from
conf$ingestion$kobo-{asset_id}. Default is "adnap".- all_flags
Data frame containing all validation flags with columns:
submission_id,submitted_by,submission_date,alert_flag- validation_statuses
Reviewers' decisions from
coasts::review_decisions(), with columnssubmission_id,validation_status,validated_at,validated_by
Details
The function performs the following steps:
Joins validation flags with KoboToolbox validation statuses
Identifies manual human approvals (excluding system username)
Preserves manual human decisions while updating system-generated statuses
Creates both wide and long format datasets for different reporting needs
Pushes results directly to MongoDB collections
Validation Status Logic:
If submission has flags AND validated_by is system username: set to "not_approved"
If submission has no flags AND validated_by is system username: set to "approved"
If validated_by is NOT system username: preserve existing status (a reviewer's approval or rejection)
Note
This function is called internally by validate_kefs_surveys_v2() and should not
typically be called directly. It requires:
Valid configuration with MongoDB connection string
Survey-specific configuration under
conf$ingestion$kobo-{asset_id}System username configured to identify automated vs. manual validations
MongoDB Collections
The function pushes to two MongoDB collections:
- flags-asset_id
Wide format with one row per submission including validation status and flags
- enumerators_stats-asset_id
Long format with one row per flag per submission for enumerator statistics
See also
validate_kefs_surveys_v2()for the main validation workflowcoasts::mdb_collection_push()for MongoDB operations