Program: 93062
Project: 93062
Buggy source:
@Action public void finish(){
  if (!ensurePreUpdateConfirmation()) {
    return;
  }
  if (!hasSelectedButton(clientTypeButtonGroup)) {
    showWarningMessage("String_Node_Str",enrolledRadioButton);
    return;
  }
 else {
    if (enrolledRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.ENROLLED);
    }
 else     if (visitorRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.VISITOR);
    }
 else     if (newRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.NEW);
    }
 else     if (transferInRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.TRANSFER_IN);
    }
  }
  PersonWrapper mpiMatchPersonWrapper=mainViewHelper.getSession().getMpiMatchPersonWrapper();
  PersonWrapper lpiMatchPersonWrapper=mainViewHelper.getSession().getLpiMatchPersonWrapper();
  boolean mpiMatched=mpiMatchPersonWrapper != null;
  boolean lpiMatched=lpiMatchPersonWrapper != null;
  PersonWrapper mpiUpdatePersonWrapper=null;
  PersonWrapper lpiUpdatePersonWrapper=null;
  if (mpiMatched) {
    mpiUpdatePersonWrapper=new PersonWrapper(mpiMatchPersonWrapper.unwrap());
  }
 else {
    mpiUpdatePersonWrapper=new PersonWrapper(new Person());
  }
  if (lpiMatched) {
    lpiUpdatePersonWrapper=new PersonWrapper(lpiMatchPersonWrapper.unwrap());
  }
 else {
    lpiUpdatePersonWrapper=new PersonWrapper(new Person());
  }
  List<Fingerprint> updatedFingerprintList=getUpdatedFingerprintList();
  if (updatedFingerprintList != null) {
    if (updatedFingerprintList.isEmpty()) {
      showWarningMessage("String_Node_Str" + "String_Node_Str",this.getFrame(),takeButton);
      return;
    }
    int numberOfFingerprintsTaken=updatedFingerprintList.size();
    if (numberOfFingerprintsTaken < OECReception.MINIMUM_FINGERPRINTS_FOR_REGISTRATION) {
      showWarningMessage("String_Node_Str" + numberOfFingerprintsTaken + "String_Node_Str"+ "String_Node_Str"+ OECReception.MINIMUM_FINGERPRINTS_FOR_REGISTRATION+ "String_Node_Str"+ "String_Node_Str"+ (OECReception.MINIMUM_FINGERPRINTS_FOR_REGISTRATION - numberOfFingerprintsTaken)+ "String_Node_Str",this.getFrame(),takeButton);
      return;
    }
  }
  mpiUpdatePersonWrapper.setFingerprintList(updatedFingerprintList);
  lpiUpdatePersonWrapper.setFingerprintList(updatedFingerprintList);
  try {
    setUpUpdatePersonWrapper(mpiUpdatePersonWrapper);
    setUpUpdatePersonWrapper(lpiUpdatePersonWrapper);
  }
 catch (  MalformedCliniIdException ex) {
    showWarningMessage(ex.getMessage(),finishButton,clinicIdTextField);
    showCard("String_Node_Str");
    return;
  }
  if (!mainViewHelper.hasLastResortSearchDone() && (mainViewHelper.noMPIMatchWasFound() || mainViewHelper.noLPIMatchWasFound())) {
    SearchProcessResult searchProcessResult=null;
    if (mainViewHelper.noMPIMatchWasFound() && mainViewHelper.noLPIMatchWasFound()) {
      searchProcessResult=mainViewHelper.findPerson(Server.MPI_LPI,mpiUpdatePersonWrapper,true);
      if (searchProcessResult.getType() == SearchProcessResult.Type.LIST) {
        showSearchResults(new SearchServerResponse(Server.MPI_LPI,(List<Person>)searchProcessResult.getData().getPersonList()),true);
      }
    }
 else     if (mainViewHelper.noMPIMatchWasFound() && !mainViewHelper.noLPIMatchWasFound()) {
      searchProcessResult=mainViewHelper.findPerson(Server.MPI,mpiUpdatePersonWrapper,true);
      if (searchProcessResult.getType() == SearchProcessResult.Type.LIST) {
        showSearchResults((SearchServerResponse)searchProcessResult.getData(),true);
      }
    }
 else     if (!mainViewHelper.noMPIMatchWasFound() && mainViewHelper.noLPIMatchWasFound()) {
      searchProcessResult=mainViewHelper.findPerson(Server.LPI,lpiUpdatePersonWrapper,true);
      if (searchProcessResult.getType() == SearchProcessResult.Type.LIST) {
        showSearchResults(new SearchServerResponse(Server.LPI,searchProcessResult.getData().getPersonList()),true);
      }
    }
    mainViewHelper.setLastResortSearchDone(true);
  }
  if (lpiUpdatePersonWrapper.getKisumuHdssId().isEmpty() || !lpiUpdatePersonWrapper.getKisumuHdssId().equalsIgnoreCase(mpiUpdatePersonWrapper.getKisumuHdssId())) {
    lpiUpdatePersonWrapper.setKisumuHdssId(mpiUpdatePersonWrapper.getKisumuHdssId());
  }
  if (mpiUpdatePersonWrapper.getClinicId().isEmpty() || !mpiUpdatePersonWrapper.getClinicId().equalsIgnoreCase(lpiUpdatePersonWrapper.getClinicId())) {
    try {
      mpiUpdatePersonWrapper.setClinicId(mpiUpdatePersonWrapper.getClinicId());
    }
 catch (    MalformedCliniIdException ex) {
      Logger.getLogger(MainView.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
  if (!mpiMatched && !lpiMatched) {
    mainViewHelper.createPerson(Server.MPI,mpiUpdatePersonWrapper);
    mainViewHelper.createPerson(Server.LPI,lpiUpdatePersonWrapper);
  }
 else {
    if (!mpiMatched && lpiMatched) {
      mainViewHelper.createPerson(Server.MPI,mpiUpdatePersonWrapper);
      mainViewHelper.modifyPerson(Server.LPI,lpiUpdatePersonWrapper);
    }
 else     if (mpiMatched && !lpiMatched) {
      lpiUpdatePersonWrapper.setMPIIdentifier(mpiUpdatePersonWrapper.getPersonGuid());
      mainViewHelper.modifyPerson(Server.MPI,mpiUpdatePersonWrapper);
      mainViewHelper.createPerson(Server.LPI,lpiUpdatePersonWrapper);
    }
 else {
      if (lpiUpdatePersonWrapper.getMPIIdentifier().isEmpty()) {
        lpiUpdatePersonWrapper.setMPIIdentifier(mpiUpdatePersonWrapper.getPersonGuid());
      }
      mainViewHelper.modifyPerson(Server.MPI,mpiUpdatePersonWrapper);
      mainViewHelper.modifyPerson(Server.LPI,lpiUpdatePersonWrapper);
    }
  }
  showCard("String_Node_Str",true,false);
}

Fixed version (ground truth):
@Action public void finish(){
  if (!ensurePreUpdateConfirmation()) {
    return;
  }
  if (!hasSelectedButton(clientTypeButtonGroup)) {
    showWarningMessage("String_Node_Str",enrolledRadioButton);
    return;
  }
 else {
    if (enrolledRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.ENROLLED);
    }
 else     if (visitorRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.VISITOR);
    }
 else     if (newRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.NEW);
    }
 else     if (transferInRadioButton.isSelected()) {
      mainViewHelper.getSession().changeSessionClientType(Session.ClientType.TRANSFER_IN);
    }
  }
  PersonWrapper mpiMatchPersonWrapper=mainViewHelper.getSession().getMpiMatchPersonWrapper();
  PersonWrapper lpiMatchPersonWrapper=mainViewHelper.getSession().getLpiMatchPersonWrapper();
  boolean mpiMatched=mpiMatchPersonWrapper != null;
  boolean lpiMatched=lpiMatchPersonWrapper != null;
  PersonWrapper mpiUpdatePersonWrapper=null;
  PersonWrapper lpiUpdatePersonWrapper=null;
  if (mpiMatched) {
    mpiUpdatePersonWrapper=new PersonWrapper(mpiMatchPersonWrapper.unwrap());
  }
 else {
    mpiUpdatePersonWrapper=new PersonWrapper(new Person());
  }
  if (lpiMatched) {
    lpiUpdatePersonWrapper=new PersonWrapper(lpiMatchPersonWrapper.unwrap());
  }
 else {
    lpiUpdatePersonWrapper=new PersonWrapper(new Person());
  }
  List<Fingerprint> updatedFingerprintList=getUpdatedFingerprintList();
  if (updatedFingerprintList != null) {
    if (updatedFingerprintList.isEmpty()) {
      showWarningMessage("String_Node_Str" + "String_Node_Str",this.getFrame(),takeButton);
      return;
    }
    int numberOfFingerprintsTaken=updatedFingerprintList.size();
    if (numberOfFingerprintsTaken < OECReception.MINIMUM_FINGERPRINTS_FOR_REGISTRATION) {
      showWarningMessage("String_Node_Str" + numberOfFingerprintsTaken + "String_Node_Str"+ "String_Node_Str"+ OECReception.MINIMUM_FINGERPRINTS_FOR_REGISTRATION+ "String_Node_Str"+ "String_Node_Str"+ (OECReception.MINIMUM_FINGERPRINTS_FOR_REGISTRATION - numberOfFingerprintsTaken)+ "String_Node_Str",this.getFrame(),takeButton);
      return;
    }
  }
  mpiUpdatePersonWrapper.setFingerprintList(updatedFingerprintList);
  lpiUpdatePersonWrapper.setFingerprintList(updatedFingerprintList);
  try {
    setUpUpdatePersonWrapper(mpiUpdatePersonWrapper);
    setUpUpdatePersonWrapper(lpiUpdatePersonWrapper);
  }
 catch (  MalformedCliniIdException ex) {
    showWarningMessage(ex.getMessage(),finishButton,clinicIdTextField);
    showCard("String_Node_Str");
    return;
  }
  if (!mainViewHelper.hasLastResortSearchDone() && (mainViewHelper.noMPIMatchWasFound() || mainViewHelper.noLPIMatchWasFound())) {
    SearchProcessResult searchProcessResult=null;
    if (mainViewHelper.noMPIMatchWasFound() && mainViewHelper.noLPIMatchWasFound()) {
      searchProcessResult=mainViewHelper.findPerson(Server.MPI_LPI,mpiUpdatePersonWrapper,true);
      if (searchProcessResult.getType() == SearchProcessResult.Type.LIST) {
        showSearchResults(new SearchServerResponse(Server.MPI_LPI,(List<Person>)searchProcessResult.getData().getPersonList()),true);
        return;
      }
    }
 else     if (mainViewHelper.noMPIMatchWasFound() && !mainViewHelper.noLPIMatchWasFound()) {
      searchProcessResult=mainViewHelper.findPerson(Server.MPI,mpiUpdatePersonWrapper,true);
      if (searchProcessResult.getType() == SearchProcessResult.Type.LIST) {
        showSearchResults((SearchServerResponse)searchProcessResult.getData(),true);
        return;
      }
    }
 else     if (!mainViewHelper.noMPIMatchWasFound() && mainViewHelper.noLPIMatchWasFound()) {
      searchProcessResult=mainViewHelper.findPerson(Server.LPI,lpiUpdatePersonWrapper,true);
      if (searchProcessResult.getType() == SearchProcessResult.Type.LIST) {
        showSearchResults(new SearchServerResponse(Server.LPI,searchProcessResult.getData().getPersonList()),true);
        return;
      }
    }
    mainViewHelper.setLastResortSearchDone(true);
  }
  if (lpiUpdatePersonWrapper.getKisumuHdssId().isEmpty() || !lpiUpdatePersonWrapper.getKisumuHdssId().equalsIgnoreCase(mpiUpdatePersonWrapper.getKisumuHdssId())) {
    if (!mpiUpdatePersonWrapper.getKisumuHdssId().isEmpty()) {
      lpiUpdatePersonWrapper.setKisumuHdssId(mpiUpdatePersonWrapper.getKisumuHdssId());
    }
  }
  if (mpiUpdatePersonWrapper.getClinicId().isEmpty() || !mpiUpdatePersonWrapper.getClinicId().equalsIgnoreCase(lpiUpdatePersonWrapper.getClinicId())) {
    try {
      mpiUpdatePersonWrapper.setClinicId(mpiUpdatePersonWrapper.getClinicId());
    }
 catch (    MalformedCliniIdException ex) {
      Logger.getLogger(MainView.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
  if (!mpiMatched && !lpiMatched) {
    mainViewHelper.createPerson(Server.MPI,mpiUpdatePersonWrapper);
    mainViewHelper.createPerson(Server.LPI,lpiUpdatePersonWrapper);
  }
 else {
    if (!mpiMatched && lpiMatched) {
      mainViewHelper.createPerson(Server.MPI,mpiUpdatePersonWrapper);
      mainViewHelper.modifyPerson(Server.LPI,lpiUpdatePersonWrapper);
    }
 else     if (mpiMatched && !lpiMatched) {
      lpiUpdatePersonWrapper.setMPIIdentifier(mpiUpdatePersonWrapper.getPersonGuid());
      mainViewHelper.modifyPerson(Server.MPI,mpiUpdatePersonWrapper);
      mainViewHelper.createPerson(Server.LPI,lpiUpdatePersonWrapper);
    }
 else {
      if (lpiUpdatePersonWrapper.getMPIIdentifier().isEmpty()) {
        lpiUpdatePersonWrapper.setMPIIdentifier(mpiUpdatePersonWrapper.getPersonGuid());
      }
      mainViewHelper.modifyPerson(Server.MPI,mpiUpdatePersonWrapper);
      mainViewHelper.modifyPerson(Server.LPI,lpiUpdatePersonWrapper);
    }
  }
  showCard("String_Node_Str",true,false);
}