/**
  * Gets the mRN score.
  *
  * @param mrn the mrn
  * @param siteId the site id
  * @param dbPatientInfo the db patient info
  * @return the mRN score
  */
 private int getMRNScore(String mrn, String siteId, PatientInformation dbPatientInfo) {
   int score = 0;
   if (dbPatientInfo.getParticipantMedicalIdentifierCollection() != null
       && dbPatientInfo.getParticipantMedicalIdentifierCollection().size() > 0) {
     Iterator<String> itr = dbPatientInfo.getParticipantMedicalIdentifierCollection().iterator();
     while (itr.hasNext()) {
       String dbMRN = (String) itr.next();
       String dbSiteId = (String) itr.next();
       String dbSiteName = (String) itr.next();
       // Only MRN is considered because eMPI patients hv no siteID.
       if (mrn.equals(dbMRN)) {
         score = Integer.valueOf(XMLPropertyHandler.getValue(Constants.PARTICIPANT_PMI_EXACT));
       } else {
         score = getMRNPartialScore(mrn, dbMRN);
         if (score == 0) {
           score = processMRNAndGetScore1(mrn, dbMRN);
         }
         if (score == 0) {
           score = processMRNAndGetScore2(mrn, dbMRN);
         }
       }
     }
   }
   return score;
 }
  /**
   * This method will calculate the score value each patients in the matched patient list by
   * comparing it with the user entered patient information.
   *
   * @param userPatientInfo : user entered PatientInformation object
   * @param dbPatientInfo : matched patient information object
   * @return score value
   */
  public int calculateScore(
      final PatientInformation userPatientInfo, PatientInformation dbPatientInfo) {
    score = 0;
    haveLname = 0;
    haveFname = 0;
    haveBonus = 0;
    haveNumber = 0;
    haveDob = 0;
    haveSSN = 0;

    if (userPatientInfo.getParticipantMedicalIdentifierCollection() != null
        && userPatientInfo.getParticipantMedicalIdentifierCollection().size() > 0) {
      Iterator itr = userPatientInfo.getParticipantMedicalIdentifierCollection().iterator();
      while (itr.hasNext()) {
        String mrn = (String) itr.next();
        String siteId = (String) itr.next();
        String siteName = (String) itr.next();
        score = getMRNScore(mrn, siteId, dbPatientInfo);
        if (score > 0) {
          break;
        }
      }
    }
    if ((userPatientInfo.getLastName() != null && userPatientInfo.getLastName().length() > 0)
        && (dbPatientInfo.getLastName() != null && dbPatientInfo.getLastName().length() > 0)) {
      haveLname = userPatientInfo.getLastName().length();
      score +=
          getLNameScore(
              userPatientInfo.getLastName().toUpperCase(),
              dbPatientInfo.getLastName().toUpperCase());
    }

    if ((userPatientInfo.getFirstName() != null && userPatientInfo.getFirstName().length() > 0)
        && (dbPatientInfo.getFirstName() != null && dbPatientInfo.getFirstName().length() > 0)) {
      haveFname = userPatientInfo.getFirstName().length();
      score +=
          getFNameScore(
              userPatientInfo.getFirstName().toUpperCase(),
              dbPatientInfo.getFirstName().toUpperCase());
    }
    if ((userPatientInfo.getMiddleName() != null && userPatientInfo.getMiddleName().length() > 0)
        && (dbPatientInfo.getMiddleName() != null && dbPatientInfo.getMiddleName().length() > 0)) {
      score +=
          getMNameScore(
              userPatientInfo.getMiddleName().toUpperCase(),
              dbPatientInfo.getMiddleName().toUpperCase());
    }

    if ((userPatientInfo.getSsn() != null && userPatientInfo.getSsn().length() > 0)
        && (dbPatientInfo.getSsn() != null && dbPatientInfo.getSsn().length() > 0)) {
      score += getSSNScore(userPatientInfo.getSsn(), dbPatientInfo.getSsn());
    }

    if ((userPatientInfo.getDob() != null && userPatientInfo.getDob().toString().length() > 0)
        && (dbPatientInfo.getDob() != null && dbPatientInfo.getDob().toString().length() > 0)) {
      score += getDOBScore(userPatientInfo.getDob(), dbPatientInfo.getDob());
    }

    if ((userPatientInfo.getGender() != null && userPatientInfo.getGender().length() > 0)
        && (dbPatientInfo.getGender() != null && dbPatientInfo.getGender().length() > 0)) {
      score +=
          getGenderScore(
              userPatientInfo.getGender().toUpperCase(), dbPatientInfo.getGender().toUpperCase());
    }

    if ((userPatientInfo.getRaceCollection() != null
            && userPatientInfo.getRaceCollection().size() > 0)
        && (dbPatientInfo.getRaceCollection() != null
            && dbPatientInfo.getRaceCollection().size() > 0)) {
      score += getRaceScore(userPatientInfo.getRaceCollection(), dbPatientInfo.getRaceCollection());
    }

    if (haveBonus >= 15
        && (haveBonus == (haveNumber - 1) || haveBonus == haveNumber)
        && score
            < Integer.valueOf(XMLPropertyHandler.getValue(Constants.PARTICIPANT_LOOKUP_CUTOFF))) {
      score = Integer.valueOf(XMLPropertyHandler.getValue(Constants.PARTICIPANT_LOOKUP_CUTOFF));
    }
    return score;
  }