/** Gets all Genomic Data. */
  private ProfileDataSummary getGenomicData(
      String cancerStudyId,
      HashMap<String, GeneticProfile> defaultGeneticProfileSet,
      SampleList defaultSampleSet,
      String geneListStr,
      ArrayList<SampleList> sampleList,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException, DaoException {

    // parse geneList, written in the OncoPrintSpec language (except for changes by XSS clean)
    double zScore =
        ZScoreUtil.getZScore(
            new HashSet<String>(defaultGeneticProfileSet.keySet()),
            new ArrayList<GeneticProfile>(defaultGeneticProfileSet.values()),
            request);
    double rppaScore = ZScoreUtil.getRPPAScore(request);

    ParserOutput theOncoPrintSpecParserOutput =
        OncoPrintSpecificationDriver.callOncoPrintSpecParserDriver(
            geneListStr,
            new HashSet<String>(defaultGeneticProfileSet.keySet()),
            new ArrayList<GeneticProfile>(defaultGeneticProfileSet.values()),
            zScore,
            rppaScore);

    ArrayList<String> geneList = new ArrayList<String>();
    geneList.addAll(theOncoPrintSpecParserOutput.getTheOncoPrintSpecification().listOfGenes());

    ArrayList<ProfileData> profileDataList = new ArrayList<ProfileData>();
    Set<String> warningUnion = new HashSet<String>();

    for (GeneticProfile profile : defaultGeneticProfileSet.values()) {
      try {
        GetProfileData remoteCall =
            new GetProfileData(
                profile, geneList, StringUtils.join(defaultSampleSet.getSampleList(), " "));
        ProfileData pData = remoteCall.getProfileData();
        warningUnion.addAll(remoteCall.getWarnings());
        profileDataList.add(pData);
      } catch (IllegalArgumentException e) {
        e.getStackTrace();
      }
    }

    ProfileMerger merger = new ProfileMerger(profileDataList);
    ProfileData mergedProfile = merger.getMergedProfile();

    ProfileDataSummary dataSummary =
        new ProfileDataSummary(
            mergedProfile,
            theOncoPrintSpecParserOutput.getTheOncoPrintSpecification(),
            zScore,
            rppaScore);
    return dataSummary;
  }
  protected Person recalculatePersonBiodemInfo(
      final Person person,
      final SorPerson sorPerson,
      final RecalculationType recalculationType,
      boolean mistake) {
    final List<SorPerson> sorPersons = this.personRepository.getSoRRecordsForPerson(person);
    logger.info("recalculatePersonBiodemInfo: start");
    if (recalculationType == RecalculationType.ADD
        || (recalculationType == RecalculationType.DELETE && !mistake)) {
      sorPersons.add(sorPerson);
    }

    copySorNamesToPerson(person, sorPersons);

    final Date birthDate =
        this.birthDateFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final String gender =
        this.genderFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final SorName preferredName =
        this.preferredNameFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final SorName officialName =
        this.officialNameFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final EmailAddress emailAddress =
        this.preferredContactEmailAddressFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final Phone phone =
        this.preferredContactPhoneNumberFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final Map<String, String> attributes =
        this.attributesElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    final SorDisclosureSettings disclosure =
        this.disclosureFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);

    final String ssn =
        this.ssnFieldElector.elect(
            sorPerson, sorPersons, recalculationType == RecalculationType.DELETE);
    Identifier primarySSN = person.getPrimaryIdentifiersByType().get("SSN");
    // check if the elector elcted some ssn and person does have previous ssn assigned to it
    if (!org.apache.commons.lang.StringUtils.isEmpty(ssn) && primarySSN != null) {
      try {
        this.identifierChangeService.change(person.getPrimaryIdentifiersByType().get("SSN"), ssn);
      } catch (IllegalArgumentException e) {
        logger.debug(e.getStackTrace().toString());
      } // all other exception should be propogated
    }

    person.setDateOfBirth(birthDate);
    person.setGender(gender);
    person.getPreferredContactEmailAddress().update(emailAddress);
    person.getPreferredContactPhoneNumber().update(phone);
    person.calculateDisclosureSettings(disclosure);
    person.setAttributes(attributes);

    String affiliation = "";
    Type affiliationType = null;
    if (disclosure != null) {
      logger.info(
          "after person.calculateDisclosureSettings, disclosure code : "
              + disclosure.getDisclosureCode());
    } else {
      logger.info("Disclosure is null");
    }
    List<SorRole> sorroles = sorPerson.getRoles();
    for (SorRole role : sorroles) {
      if (role != null) {
        logger.info("Role = " + role.getTitle());
        if (role.getAffiliationType() != null) {
          logger.info("Role desc= " + role.getAffiliationType().getDescription());
          affiliation = role.getAffiliationType().getDescription();

          if (person.getDisclosureSettings() != null) {
            logger.info("recalculating disclosure setting 1...");
            // person.getDisclosureSettings().recalculate(this.strategyRepository.getDisclosureRecalculationStrategy());
            person
                .getDisclosureSettings()
                .recalculate(
                    this.strategyRepository.getDisclosureRecalculationStrategy(),
                    affiliation,
                    referenceRepository);
          }
        }
      }
    }

    // SSN election is happening in the ssn identifier assigner.

    boolean preferred = false;
    boolean official = false;

    for (final Name name : person.getNames()) {
      if (!preferred && name.sameAs(preferredName)) {
        name.setPreferredName(true);
        preferred = true;
      }

      if (!official && name.sameAs(officialName)) {
        name.setOfficialName(true);
        official = true;
      }

      if (official && preferred) {
        break;
      }
    }
    logger.info("recalculatePersonBiodemInfo: end");
    //        return this.personRepository.savePerson(person);
    return person;
  }