OpenSRP Connector- Common errors and solutions

OpenSRP connector is the backend service that pushes form submissions from client to OpenMRS via OpenMRS REST module. Being a REST backend service that pushes data to external system there is possibility that due to number of reasons it fails to push data to OpenMRS. In that case Form Submission is saved as it is and also logged as Failed Submission in error tracker module (under progress). Below are various errors thrown found in stacktrace and their possible solutions.

1) java.lang.NullPointerException at org.opensrp.connector.OpenmrsConnector......

Possible Reason:

  • If you find this error anywhere in stacktrace during a form submission or data sync between openmrs and opensrp, it shows that there has been some inconsistency between client code (or xls form) and the form submission sent was not in format expected by opensrp connector.
  • Another potential reason could be a bug that has skipped through the QA
  • Or the submitted form submission has any data that connector doesnot know to handle

Solutions:

  • Check your xls form and make sure that there is no row with missing openmrs_entity_id
  • Review xls form and make sure that no new person exists without mandatory openmrs attribute mappings (first_name, last_name, gender,birth_date, atleast one patient_identifier)
  • Encounter mappings encounter_location and encounter_date for form also exist and if form registers multiple entities encounter type for new entities is also specified in repeat group in column openmrs_entity_id.
  • If none of the above exist contact developers with full stacktrace and the steps to reproduce the problem.

2) java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 400 for URL: http://46.101.51.199:8080/openmrs/ws/rest/v1/patient
    at org.opensrp.connector.HttpUtil.post

 Possible Reason:

  • The FormSubmission is submitted to create / register a person in OpenMRS 2nd time.
  • Any property of person that is supposed to be unique like any of the identifier, entityId has been duplicated
  • Person is missing any important mapping in xlsform or in Json data being pushed to server like first_name, last_name, gender, birth_date, person_identifier, identifier_type etc.
  • If an identifier is supposed to be bind to location (this is done when creating identifier type) then missing location in identifier can also lead to this exception
  • If an identifier was marked as "required" when creating identifier type, it must be specified when creating patient

Solutions:

  • Check that The entityId in FormSubmission is not already registered in OpenMRS
  • Check that any identifier value (mapped by openmrs_entity=person_identifier) doesnot exists in OpenMRS
  • Check your xls form and make sure that there is no row with missing openmrs_entity_id
  • Check that xlsform has correct mappings of openmrs_entity and openmrs_entity_id for first_name, last_name, gender, birth_date, identifier which are also marked as "required=yes"
  • Check that your Json pushed to server has location mapped in identifier if a particular identifier is supposed to have associated location
  • Check that your Json pushed to data has all required identifiers properly specified