Program: 84577
Project: 84577
Buggy source:
/** 
 * @see org.openmrs.api.PatientService#checkPatientIdentifiers(org.openmrs.Patient)
 */
public void checkPatientIdentifiers(Patient patient) throws PatientIdentifierException {
  if (patient.getIdentifiers().size() < 1)   throw new InsufficientIdentifiersException("String_Node_Str");
  List<PatientIdentifier> identifiers=new Vector<PatientIdentifier>();
  identifiers.addAll(patient.getIdentifiers());
  List<String> identifiersUsed=new Vector<String>();
  List<PatientIdentifierType> requiredTypes=getPatientIdentifierTypes(null,null,true,null);
  if (requiredTypes == null)   requiredTypes=new ArrayList<PatientIdentifierType>();
  List<PatientIdentifierType> foundRequiredTypes=new ArrayList<PatientIdentifierType>();
  for (  PatientIdentifier pi : identifiers) {
    if (pi.isVoided())     continue;
    try {
      checkPatientIdentifier(pi);
    }
 catch (    BlankIdentifierException bie) {
      patient.removeIdentifier(pi);
      throw bie;
    }
    for (    PatientIdentifierType requiredType : requiredTypes) {
      if (pi.getIdentifierType().equals(requiredType)) {
        foundRequiredTypes.add(requiredType);
        requiredTypes.remove(requiredType);
        break;
      }
    }
    if (identifiersUsed.contains(pi.getIdentifier())) {
      patient.removeIdentifier(pi);
      throw new DuplicateIdentifierException("String_Node_Str" + pi.getIdentifierType().getName() + "String_Node_Str"+ pi.getIdentifier()+ "String_Node_Str",pi);
    }
 else     identifiersUsed.add(pi.getIdentifier());
  }
  if (requiredTypes.size() > 0) {
    String missingNames="String_Node_Str";
    for (    PatientIdentifierType pit : requiredTypes) {
      missingNames+=(missingNames.length() > 0) ? "String_Node_Str" + pit.getName() : pit.getName();
    }
    throw new MissingRequiredIdentifierException("String_Node_Str" + missingNames);
  }
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.PatientService#checkPatientIdentifiers(org.openmrs.Patient)
 */
public void checkPatientIdentifiers(Patient patient) throws PatientIdentifierException {
  if (patient.getIdentifiers().size() < 1)   throw new InsufficientIdentifiersException("String_Node_Str");
  List<PatientIdentifier> identifiers=new Vector<PatientIdentifier>();
  identifiers.addAll(patient.getIdentifiers());
  List<String> identifiersUsed=new Vector<String>();
  List<PatientIdentifierType> requiredTypes=getPatientIdentifierTypes(null,null,true,null);
  if (requiredTypes == null)   requiredTypes=new ArrayList<PatientIdentifierType>();
  List<PatientIdentifierType> foundRequiredTypes=new ArrayList<PatientIdentifierType>();
  for (  PatientIdentifier pi : identifiers) {
    if (pi.isVoided())     continue;
    try {
      checkPatientIdentifier(pi);
    }
 catch (    BlankIdentifierException bie) {
      patient.removeIdentifier(pi);
      throw bie;
    }
    for (    PatientIdentifierType requiredType : requiredTypes) {
      if (pi.getIdentifierType().equals(requiredType)) {
        foundRequiredTypes.add(requiredType);
        requiredTypes.remove(requiredType);
        break;
      }
    }
    if (identifiersUsed.contains(pi.getIdentifier() + "String_Node_Str" + pi.getIdentifierType().getPatientIdentifierTypeId())) {
      patient.removeIdentifier(pi);
      throw new DuplicateIdentifierException("String_Node_Str" + pi.getIdentifierType().getName() + "String_Node_Str"+ pi.getIdentifier()+ "String_Node_Str",pi);
    }
 else {
      identifiersUsed.add(pi.getIdentifier() + "String_Node_Str" + pi.getIdentifierType().getPatientIdentifierTypeId());
    }
  }
  if (requiredTypes.size() > 0) {
    String missingNames="String_Node_Str";
    for (    PatientIdentifierType pit : requiredTypes) {
      missingNames+=(missingNames.length() > 0) ? "String_Node_Str" + pit.getName() : pit.getName();
    }
    throw new MissingRequiredIdentifierException("String_Node_Str" + missingNames);
  }
}