/**
   * updates Participant registration in CaTissue
   *
   * @param participant - Participant to be registered
   * @return instance of Participant
   * @throws ApplicationException - ApplicationException
   */
  public Participant updateParticipantRegistration(Participant participant)
      throws ApplicationException {
    if (participant == null || StringUtils.isEmpty(participant.getLastName())) {
      LOG.error(
          "Participant does not contain the unique medical identifier "
              + participant.getLastName());
      throw new ApplicationException("Participant does not contain the unique medical identifier");
    }

    final Participant existingParticipant =
        getParticipantForPatientId(
            participant.getLastName(), getShortTitleForParticipant(participant));
    if (existingParticipant == null) {
      LOG.error(
          "CaTissue does not contain a participant with the unique identifier, "
              + participant.getLastName());
      throw new ApplicationException(
          "CaTissue does not contain a participant with the unique identifier, "
              + participant.getLastName());
    }

    // check if the collection protocol is different, if different then throw exception
    if (isCollectionProtocolChanged(participant, existingParticipant)) {
      LOG.error(
          "Update Participant Registration failed for "
              + participant.getLastName()
              + "and exception is Study can't be changed while updating the Participant.");
      throw new ApplicationException(
          "Update Participant Registration failed for "
              + participant.getLastName()
              + "and exception is Study can't be changed while updating the Participant.");
    }

    participant.setId(existingParticipant.getId());

    // Set the values in CPR only for Create Participant Flow and don't set it for UpdateParticipant
    participant.setCollectionProtocolRegistrationCollection(
        new HashSet<CollectionProtocolRegistration>());

    // code to handle the existing/new race collection
    updateParticipantRaceCollection(existingParticipant, participant);

    try {
      caTissueAPIClient.update(participant);
    } catch (ApplicationException ae) {
      LOG.error(
          "Update Registration Failed for Participant with Subject ID " + participant.getLastName(),
          ae);
      throw new ApplicationException(ae);
    }

    return copyFrom(existingParticipant);
  }