diff --git a/coordinator/ProcessorSurveysnewODK.py b/coordinator/ProcessorSurveysnewODK.py index a290f7a2daf63c892fbc98799ec36d30b24a5805..b42947b65a50f7026ff3be2456f7f7ee22344cf5 100644 --- a/coordinator/ProcessorSurveysnewODK.py +++ b/coordinator/ProcessorSurveysnewODK.py @@ -20,6 +20,19 @@ from ProcessorUtils import ( logger = logging.getLogger('Processor.Surveys.kobotoolbox') add_filters_to_sublogger(logger) +# Cases to convert incident categories to expected short name category or value +cases_incident = { + '':'none', + 'N':'none', + 'L':'low', + 'M':'medium', + 'H':'high', + 'none':'none', + 'low':'low', + 'medium':'medium', + 'high':'high' + } + def get_from_kobotoolbox(url,form_id,form_token,**kwargs): '''Make the HTTP request, then checking the status code.''' @@ -95,7 +108,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s 'formhub/uuid' : 'None', 'imei' : 'imei', 'leaf_rust/leafrust_host_plant_reaction' : 'leaf_rust-leafrust_host_plant_reaction', - 'leaf_rust/leafrust_incidence' : 'leaf_rust-leafrust_incidence', + 'leaf_rust/leafrust_incidence' : ('parse_cases',(('name_out','leaf_rust-leafrust_incidence'),('cases', cases_incident))), 'leaf_rust/leafrust_severity' : 'leaf_rust-leafrust_severity', 'live_leafrust_samples' : 'SET-OF-live_leafrust_samples', 'live_leafrust_samples_count' : 'live_leafrust_samples_count', @@ -116,7 +129,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s 'start' : ('parse_date',(('name_out','start'),('fmt_in','%Y-%m-%dT%H:%M:%S.%f%z'))), 'stem_rust/Stemrust_severity' : 'stem_rust-Stemrust_severity', 'stem_rust/stemrust_host_plant_reaction' : 'stem_rust-stemrust_host_plant_reaction', - 'stem_rust/stemrust_incidence' : 'stem_rust-stemrust_incidence', + 'stem_rust/stemrust_incidence' : ('parse_cases',(('name_out','stem_rust-stemrust_incidence'),('cases', cases_incident))), 'survey_infromation/location' : ('parse_location_kobotoolbox',()), 'survey_infromation/location_name' : 'survey_infromation-location_name', 'survey_infromation/survey_date' : ('parse_date',(('name_out','survey_infromation-survey_date'),('fmt_in','%Y-%m-%d'))), @@ -126,7 +139,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s 'today' : ('parse_date',(('name_out','today'),('fmt_in','%Y-%m-%d'))), 'username' : 'username', 'yellow_rust/yellowrust_host_plant_reaction' : 'yellow_rust-yellowrust_host_plant_reaction', - 'yellow_rust/yellowrust_incidence' : 'yellow_rust-yellowrust_incidence', + 'yellow_rust/yellowrust_incidence' : ('parse_cases',(('name_out','leaf_rust-leafrust_incidence'),('cases', cases_incident))), 'yellow_rust/yellowrust_severity' : 'yellow_rust-yellowrust_severity', }