opensrp / opensrp-client-goldsmith

0 stars 0 forks source link

Fix events with null obs #27

Closed ekigamba closed 3 years ago

ekigamba commented 3 years ago

The following kind of event causes a crash due to the null literal value in the obs.values when nothing is selected for the question and the org.smartregister.converters.EventConverter#convertEventToEncounterResource during plan evaluation

Family Member Registration Event

{
  "baseEntityId": "8dbc3015-abd8-401c-b662-274573f1ed92",
  "childLocationId": "Kenya",
  "duration": 0,
  "entityType": "ec_family_member",
  "eventDate": "2020-12-08T00:00:00.000Z",
  "eventType": "Family Member Registration",
  "formSubmissionId": "9616c316-05ee-437a-8e36-72389f9f2c75",
  "locationId": "ac7ba751-35e8-4b46-9e53-3cbaad193697",
  "obs": [
    {
      "fieldCode": "same_as_fam_name",
      "fieldDataType": "text",
      "fieldType": "formsubmissionField",
      "formSubmissionField": "same_as_fam_name",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "true"
      ]
    },
    {
      "fieldCode": "dob_unknown",
      "fieldDataType": "text",
      "fieldType": "formsubmissionField",
      "formSubmissionField": "dob_unknown",
      "humanReadableValues": [],
      "keyValPairs": {
        "dob_unknown": "DOB unknown?"
      },
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "DOB unknown?"
      ]
    },
    {
      "fieldCode": "1712AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "select one",
      "fieldType": "concept",
      "formSubmissionField": "highest_edu_level",
      "humanReadableValues": [
        "Highest education level"
      ],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        null
      ]
    },
    {
      "fieldCode": "last_interacted_with",
      "fieldDataType": "text",
      "fieldType": "formsubmissionField",
      "formSubmissionField": "last_interacted_with",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "1607422593965"
      ]
    },
    {
      "fieldCode": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "start",
      "fieldType": "concept",
      "formSubmissionField": "start",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "2020-12-08 13:15:21"
      ]
    },
    {
      "fieldCode": "163138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "end",
      "fieldType": "concept",
      "formSubmissionField": "end",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "2020-12-08 13:16:33"
      ]
    },
    {
      "fieldCode": "163149AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "deviceid",
      "fieldType": "concept",
      "formSubmissionField": "deviceid",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "358240051111110"
      ]
    },
    {
      "fieldCode": "163150AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "subscriberid",
      "fieldType": "concept",
      "formSubmissionField": "subscriberid",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "310260000000000"
      ]
    },
    {
      "fieldCode": "163151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "simserial",
      "fieldType": "concept",
      "formSubmissionField": "simserial",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "89014103211118510720"
      ]
    },
    {
      "fieldCode": "163152AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "fieldDataType": "phonenumber",
      "fieldType": "concept",
      "formSubmissionField": "phonenumber",
      "humanReadableValues": [],
      "parentCode": "",
      "saveObsAsArray": false,
      "values": [
        "+15555215554"
      ]
    }
  ],
  "providerId": "onatest",
  "team": "Dream Team Organisation",
  "teamId": "0c7fd90f-5b99-4ed9-b337-0b42d51eab97",
  "version": 1607422593972,
  "clientApplicationVersion": 1,
  "clientDatabaseVersion": 5,
  "dateCreated": "2020-12-08T13:16:33.972Z",
  "type": "Event",
  "details": {
    "planIdentifier": "d652d9ae-2ff9-41e4-9bb3-fd4cd2ea0e2e"
  }
}
ekigamba commented 3 years ago

Proposed solutions

  1. Update the processor to correct this on each event
  2. Circle back to previous discussions on this bug and apply the recommended fix
  3. Fix the conversion on core & other libraries(CHW, CHW-core, GS)