diff --git a/app/jobs/dhis2/ethiopia_exporter_job.rb b/app/jobs/dhis2/ethiopia_exporter_job.rb index 3d9f09af08..d7062acdf4 100644 --- a/app/jobs/dhis2/ethiopia_exporter_job.rb +++ b/app/jobs/dhis2/ethiopia_exporter_job.rb @@ -86,5 +86,15 @@ def segregate_and_format_cohort_data(registered_patients) def format_cohort_registered_data(registered_patients) {"default" => registered_patients.count} end + + # DHIS2 library we use works for old versions of DHIS2. Since Ethiopia is on much advanced version, this is a hack to prevent + # false errors being raised from the client. + def export(data_values) + @client.data_value_sets.bulk_create(data_values: data_values) + rescue Dhis2::BulkCreationError => error + response = JSON.parse(error.import_summary.to_json)["hash"] + raise error if response["http_status_code"] != 200 + Rails.logger.info("Exported to Dhis2 with response: ", response) + end end end