private static void UpdateEnrollmentTimestamp(Enrollment enrollment, DhisApi dhisApi)
      throws APIException {
    try {
      final Map<String, String> QUERY_PARAMS = new HashMap<>();
      QUERY_PARAMS.put("fields", "created,lastUpdated");
      Enrollment updatedEnrollment =
          dhisApi.getEnrollment(enrollment.getEnrollment(), QUERY_PARAMS);

      // merging updated timestamp to local enrollment model
      enrollment.setCreated(updatedEnrollment.getCreated());
      enrollment.setLastUpdated(updatedEnrollment.getLastUpdated());
      enrollment.save();
    } catch (APIException apiException) {
      NetworkUtils.handleApiException(apiException);
    }
  }
  static void sendEnrollmentChanges(DhisApi dhisApi, Enrollment enrollment, boolean sendEvents)
      throws APIException {
    if (enrollment == null) {
      return;
    }
    if (Utils.isLocal(
        enrollment.getTrackedEntityInstance())) { // don't send enrollment with locally made uid
      return;
    }

    if (enrollment.getCreated() == null) {
      postEnrollment(enrollment, dhisApi);
      if (sendEvents) {
        List<Event> events = TrackerController.getEventsByEnrollment(enrollment.getLocalId());
        sendEventChanges(dhisApi, events);
      }
    } else {
      if (sendEvents) {
        List<Event> events = TrackerController.getEventsByEnrollment(enrollment.getLocalId());
        sendEventChanges(dhisApi, events);
      }
      putEnrollment(enrollment, dhisApi);
    }
  }