private String getErrorDescription(TrackedEntityInstance trackedEntityInstance) {
    FailedItem failedItem =
        DataValueController.getFailedItem(
            FailedItem.TRACKEDENTITYINSTANCE, trackedEntityInstance.localId);
    // Select.byId(FailedItem.class, trackedEntityInstance.localId);

    if (failedItem != null) {
      if (failedItem.getHttpStatusCode() == 200) {
        if (failedItem.getImportSummary() != null)
          return failedItem.getImportSummary().getDescription();
      }
      if (failedItem.getHttpStatusCode() == 401) {
        return getString(R.string.error_401_description);
      }

      if (failedItem.getHttpStatusCode() == 408) {
        return getString(R.string.error_408_description);
      }

      if (failedItem.getHttpStatusCode() >= 400 && failedItem.getHttpStatusCode() < 500) {
        return getString(R.string.error_series_400_description);
      }

      if (failedItem.getHttpStatusCode() >= 500) {
        return failedItem.getErrorMessage();
      }
    }

    return getString(R.string.unknown_error);
  }
 public Map<Long, FailedItem> getFailedEvents() {
   Map<Long, FailedItem> failedItemMap = new HashMap<>();
   List<FailedItem> failedItems = DataValueController.getFailedItems();
   if (failedItems != null && failedItems.size() > 0) {
     for (FailedItem failedItem : failedItems) {
       if (failedItem.getItemType().equals(FailedItem.EVENT))
         failedItemMap.put(failedItem.getItemId(), failedItem);
     }
   }
   return failedItemMap;
 }
 static void clearFailedItem(String type, long id) {
   FailedItem item = TrackerController.getFailedItem(type, id);
   if (item != null) {
     item.async().delete();
   }
 }