예제 #1
0
  /**
   * 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);
  }
예제 #2
0
  private Participant copyFrom(Participant participant) {
    final Participant p = ParticipantFactory.getInstance().createObject();

    p.setId(participant.getId());
    p.setActivityStatus(participant.getActivityStatus());
    p.setBirthDate(participant.getBirthDate());
    p.setEthnicity(participant.getEthnicity());
    p.setFirstName(participant.getFirstName());
    p.setLastName(participant.getLastName());
    p.setGender(participant.getGender());
    p.setMetaPhoneCode(participant.getMetaPhoneCode());
    p.setSocialSecurityNumber(participant.getSocialSecurityNumber());
    p.setVitalStatus(participant.getVitalStatus());

    final Iterator<Race> iter = participant.getRaceCollection().iterator();
    while (iter.hasNext()) {
      final Race race = (Race) iter.next();
      final Race r = RaceFactory.getInstance().createObject();
      r.setParticipant(p);
      r.setRaceName(race.getRaceName());
      p.getRaceCollection().add(r);
    }

    final Iterator<CollectionProtocolRegistration> cprIter =
        participant.getCollectionProtocolRegistrationCollection().iterator();
    while (cprIter.hasNext()) {
      final CollectionProtocolRegistration collectionProtocolRegistration =
          (CollectionProtocolRegistration) cprIter.next();

      final CollectionProtocol collectionProtocol =
          collectionProtocolRegistration.getCollectionProtocol();
      final CollectionProtocol cp = CollectionProtocolFactory.getInstance().createObject();
      cp.setActivityStatus(collectionProtocol.getActivityStatus());
      cp.setTitle(collectionProtocol.getTitle());
      cp.setShortTitle(collectionProtocol.getShortTitle());

      final CollectionProtocolRegistration cpr =
          CollectionProtocolRegistrationFactory.getInstance().createObject();
      cpr.setParticipant(p);
      cpr.setConsentSignatureDate(collectionProtocolRegistration.getConsentSignatureDate());
      cpr.setRegistrationDate(collectionProtocolRegistration.getRegistrationDate());
      cpr.setProtocolParticipantIdentifier(
          collectionProtocolRegistration.getProtocolParticipantIdentifier());
      // setting empty consenttier status collection, as update flow will not update consent tier
      cpr.setConsentTierResponseCollection(
          (Collection<ConsentTierResponse>) new LinkedHashSet<ConsentTierResponse>());

      cpr.setCollectionProtocol(cp);
      p.getCollectionProtocolRegistrationCollection().add(cpr);
    }
    return p;
  }