nus-yam/ex-repair huggingface dataset:
Program: 189646
Project: 189646
Buggy source:
private JMenu buildGameMenu(){
  JMenuItem pauseItem;
  JMenuItem newGameItem;
  JMenuItem autoReplayItem;
  pauseItem=new JCheckBoxMenuItem();
  pauseItem.setText("String_Node_Str");
  pauseItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,ActionEvent.CTRL_MASK));
  pauseItem.addActionListener((e) -> context.pause(((JMenuItem)e.getSource()).isSelected()));
  newGameItem=new JMenuItem();
  newGameItem.setText("String_Node_Str");
  newGameItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,ActionEvent.CTRL_MASK));
  newGameItem.addActionListener((e) -> context.newGame());
  autoReplayItem=new JCheckBoxMenuItem();
  autoReplayItem.setText("String_Node_Str");
  autoReplayItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,ActionEvent.CTRL_MASK));
  autoReplayItem.addActionListener((e) -> context.setAutoRestart(((JMenuItem)e.getSource()).isSelected()));
  context.registerNewGameListener(() -> {
    pauseItem.setEnabled(true);
    pauseItem.setSelected(false);
  }
);
  context.registerEndGameListener(() -> pauseItem.setEnabled(false));
  JMenu gameMenu=new JMenu("String_Node_Str");
  gameMenu.add(pauseItem);
  gameMenu.add(newGameItem);
  gameMenu.add(autoReplayItem);
  gameMenu.addSeparator();
  gameMenu.add(buildBoardSizeMenu());
  gameMenu.add(buildSequenceMenu());
  return gameMenu;
}

Fixed version (ground truth):
private JMenu buildGameMenu(){
  JMenuItem pauseItem;
  JMenuItem newGameItem;
  JMenuItem autoReplayItem;
  pauseItem=new JCheckBoxMenuItem();
  pauseItem.setText("String_Node_Str");
  pauseItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,InputEvent.CTRL_MASK));
  pauseItem.addActionListener((e) -> context.pause(((JMenuItem)e.getSource()).isSelected()));
  newGameItem=new JMenuItem();
  newGameItem.setText("String_Node_Str");
  newGameItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,InputEvent.CTRL_MASK));
  newGameItem.addActionListener((e) -> context.newGame());
  autoReplayItem=new JCheckBoxMenuItem();
  autoReplayItem.setText("String_Node_Str");
  autoReplayItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,InputEvent.CTRL_MASK));
  autoReplayItem.addActionListener((e) -> context.setAutoRestart(((JMenuItem)e.getSource()).isSelected()));
  context.registerNewGameListener(() -> {
    pauseItem.setEnabled(true);
    pauseItem.setSelected(false);
  }
);
  context.registerEndGameListener(() -> pauseItem.setEnabled(false));
  JMenu gameMenu=new JMenu("String_Node_Str");
  gameMenu.add(pauseItem);
  gameMenu.add(newGameItem);
  gameMenu.add(autoReplayItem);
  gameMenu.addSeparator();
  gameMenu.add(buildBoardSizeMenu());
  gameMenu.add(buildSequenceMenu());
  return gameMenu;
}
Program: 189647
Project: 189647
Buggy source:
/** 
 * Creates a new Board.
 * @param width The board width.
 * @param height The board height.
 */
public Board(int width,int height){
  this.width=width;
  this.height=height;
  board=new Shape[width * height];
  Arrays.fill(board,Shape.NoShape);
}

Fixed version (ground truth):
/** 
 * Creates a new Board.
 * @param width The board width.
 * @param height The board height.
 */
public Board(int width,int height){
  this.width=width;
  this.height=height;
  board=new Shape[width * height];
  clear();
}
Program: 189648
Project: 189648
Buggy source:
public void startNewGame(){
  data=new GameData(new Board(10,20),new PieceSequence(new ShufflePieceSelector()));
  new NewTetrominoCommand(data).execute();
}

Fixed version (ground truth):
public void startNewGame(){
  if (data.getBoard() == null) {
    data.setBoard(new Board(10,20));
  }
  if (data.getSequence() == null) {
    data.setSequence(new PieceSequence(new ShufflePieceSelector()));
  }
  data.clear();
  new NewTetrominoCommand(data).execute();
}
Program: 189649
Project: 189649
Buggy source:
public final void rewind(){
  current--;
  preview--;
}

Fixed version (ground truth):
public void rewind(){
  current--;
  preview--;
}
Program: 189650
Project: 189650
Buggy source:
public final Tetromino peekCurrent(){
  return pieces.get(current);
}

Fixed version (ground truth):
public Tetromino peekCurrent(){
  return pieces.get(current);
}
Program: 189651
Project: 189651
Buggy source:
public final Tetromino peekPreview(){
  return pieces.get(preview);
}

Fixed version (ground truth):
public Tetromino peekPreview(){
  return pieces.get(preview);
}
Program: 189652
Project: 189652
Buggy source:
public final void advance(){
  current++;
  preview++;
  while (pieces.size() <= preview) {
    pieces.add(selector.getNextPiece());
  }
}

Fixed version (ground truth):
public void advance(){
  current++;
  preview++;
  while (pieces.size() <= preview) {
    pieces.add(selector.getNextPiece());
  }
}
Program: 189653
Project: 189653
Buggy source:
@Override public Move getBestMove(Board board,Tetromino current,Tetromino preview,int x,int y){
  int bestRotationDelta=0;
  int bestTranslationDelta=0;
  double max=Double.NEGATIVE_INFINITY;
  for (int rotationDelta=0; rotationDelta < 4; rotationDelta++) {
    int minTranslationDelta=getMinTranslationDelta(board,current,x,y);
    int maxTranslationDelta=getMaxTranslationDelta(board,current,x,y);
    for (int translationDelta=minTranslationDelta; translationDelta <= maxTranslationDelta; translationDelta++) {
      dummy1=board.tryClone(dummy1);
      if (dummy1.tryMove(current,x + translationDelta,dummy1.dropHeight(current,x + translationDelta))) {
        double score=score(dummy1);
        if (score > max) {
          max=score;
          bestTranslationDelta=translationDelta;
          bestRotationDelta=rotationDelta;
        }
      }
    }
    current=Tetromino.rotateLeft(current);
  }
  return new Move(bestRotationDelta,bestTranslationDelta);
}

Fixed version (ground truth):
@Override public Move getBestMove(Board board,Tetromino current,Tetromino preview,int x,int y){
  int bestRotationDelta=0;
  int bestTranslationDelta=0;
  double max=Double.NEGATIVE_INFINITY;
  for (int rotationDelta=0; rotationDelta < 4; rotationDelta++) {
    int minTranslationDelta=getMaxTranslationDelta(board,current,x,y,-1);
    int maxTranslationDelta=getMaxTranslationDelta(board,current,x,y,+1);
    for (int translationDelta=minTranslationDelta; translationDelta <= maxTranslationDelta; translationDelta++) {
      dummy1=board.tryClone(dummy1);
      if (dummy1.tryMove(current,x + translationDelta,dummy1.dropHeight(current,x + translationDelta))) {
        double score=score(dummy1);
        if (score > max) {
          max=score;
          bestTranslationDelta=translationDelta;
          bestRotationDelta=rotationDelta;
        }
      }
    }
    current=Tetromino.rotateLeft(current);
  }
  return new Move(bestRotationDelta,bestTranslationDelta);
}
Program: 189654
Project: 189654
Buggy source:
private int getMaxTranslationDelta(Board board,Tetromino piece,int x,int y){
  int translation=0;
  while (board.canMove(piece,x + translation,y)) {
    translation++;
  }
  return translation;
}

Fixed version (ground truth):
private int getMaxTranslationDelta(Board board,Tetromino piece,int x,int y,int step){
  int translation=0;
  while (board.canMove(piece,x + translation + step,y)) {
    translation+=step;
  }
  return translation;
}
Program: 189655
Project: 189655
Buggy source:
/** 
 * bcc -- incase you need to be copied on emails
 * @return
 * @throws AddressException
 */
private InternetAddress[] getBCC() throws AddressException {
  if (bcc != null) {
    return bcc;
  }
  if (BCC_EMAIL_LIST.length > 0 && BCC_EMAIL_LIST[0].equals(DUMMY_EMAIL)) {
    bcc=new InternetAddress[BCC_EMAIL_LIST.length];
    for (    String email : BCC_EMAIL_LIST) {
      bcc[0]=new InternetAddress(email);
    }
  }
 else {
    bcc=new InternetAddress[0];
  }
  return bcc;
}

Fixed version (ground truth):
/** 
 * bcc -- incase you need to be copied on emails
 * @return
 * @throws AddressException
 */
private InternetAddress[] getBCC() throws AddressException {
  if (bcc != null) {
    return bcc;
  }
  if (BCC_EMAIL_LIST.length > 0 && !BCC_EMAIL_LIST[0].equals(DUMMY_EMAIL)) {
    bcc=new InternetAddress[BCC_EMAIL_LIST.length];
    int index=0;
    for (    String email : BCC_EMAIL_LIST) {
      bcc[index++]=new InternetAddress(email);
    }
  }
 else {
    bcc=new InternetAddress[0];
  }
  return bcc;
}
Program: 189656
Project: 189656
Buggy source:
/** 
 * Creates a drug reference from a drug UUID
 * @param drugUuid the drug UUID
 * @return the drug reference
 */
public static DrugReference fromDrugUuid(String drugUuid){
  Drug drug=Context.getConceptService().getDrugByUuid(drugUuid);
  return new DrugReference(drug.getConcept().getUuid(),drug.getUuid());
}

Fixed version (ground truth):
/** 
 * Creates a drug reference from a drug UUID
 * @param drugUuid the drug UUID
 * @return the drug reference
 */
public static DrugReference fromDrugUuid(String drugUuid){
  Drug drug=Context.getConceptService().getDrugByUuid(drugUuid);
  if (drug != null) {
    return new DrugReference(drug.getConcept().getUuid(),drug.getUuid());
  }
  return null;
}
Program: 189659
Project: 189659
Buggy source:
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Date date=(Date)parameterValues.get("String_Node_Str");
  if (date == null) {
    date=new Date();
  }
  Date startOfDay=DateUtil.getStartOfDay(date);
  Date endOfDay=DateUtil.getEndOfDay(date);
  Concept returnVisitDate=Dictionary.getConcept(Dictionary.RETURN_VISIT_DATE);
  EncounterType tbFollowup=MetadataUtils.existing(EncounterType.class,TbMetadata._EncounterType.TB_CONSULTATION);
  DateObsCohortDefinition cd=new DateObsCohortDefinition();
  cd.setTimeModifier(TimeModifier.ANY);
  cd.setQuestion(returnVisitDate);
  cd.setOperator1(RangeComparator.GREATER_EQUAL);
  cd.setValue1(startOfDay);
  cd.setOperator2(RangeComparator.LESS_EQUAL);
  cd.setValue2(endOfDay);
  cd.setEncounterTypeList(Collections.singletonList(tbFollowup));
  EvaluatedCohort withScheduledVisit=CalculationUtils.evaluateWithReporting(cd,cohort,null,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    ret.put(ptId,new BooleanResult(withScheduledVisit.contains(ptId),this));
  }
  return ret;
}

Fixed version (ground truth):
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  if (parameterValues != null) {
    logger.info("String_Node_Str");
    logger.info(parameterValues.toString());
  }
 else {
    logger.info("String_Node_Str");
  }
  Date date=new Date();
  Date startOfDay=DateUtil.getStartOfDay(date);
  Date endOfDay=DateUtil.getEndOfDay(date);
  Concept returnVisitDate=Dictionary.getConcept(Dictionary.RETURN_VISIT_DATE);
  DateObsCohortDefinition cd=new DateObsCohortDefinition();
  cd.setTimeModifier(TimeModifier.ANY);
  cd.setQuestion(returnVisitDate);
  cd.setOperator1(RangeComparator.GREATER_EQUAL);
  cd.setValue1(startOfDay);
  cd.setOperator2(RangeComparator.LESS_EQUAL);
  cd.setValue2(endOfDay);
  EvaluatedCohort withScheduledVisit=CalculationUtils.evaluateWithReporting(cd,cohort,null,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    ret.put(ptId,new BooleanResult(withScheduledVisit.contains(ptId),this));
  }
  return ret;
}
Program: 189660
Project: 189660
Buggy source:
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Boolean notOnIpt=false;
  Program iptProgram=MetadataUtils.existing(Program.class,IPTMetadata._Program.IPT);
  Program tbProgram=MetadataUtils.existing(Program.class,TbMetadata._Program.TB);
  EncounterType iptOutcome=MetadataUtils.existing(EncounterType.class,IPTMetadata._EncounterType.IPT_OUTCOME);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> onIptProgram=Filters.inProgram(iptProgram,alive,context);
  Set<Integer> inTbProgram=Filters.inProgram(tbProgram,alive,context);
  CalculationResultMap lastIptMap=Calculations.lastEncounter(iptOutcome,alive,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    if (alive.contains(ptId) && !inTbProgram.contains(ptId) && !onIptProgram.contains(ptId)) {
      Encounter lastIptEncounter=EmrCalculationUtils.encounterResultForPatient(lastIptMap,ptId);
      if (lastIptEncounter != null) {
        DateTime lastIptEncounterDate=new DateTime(lastIptEncounter.getEncounterDatetime());
        Years yearsSinceLastIpt=Years.yearsBetween(lastIptEncounterDate,new DateTime());
        if (yearsSinceLastIpt.getYears() > 2) {
          notOnIpt=true;
        }
      }
 else {
        notOnIpt=true;
      }
    }
    ret.put(ptId,new BooleanResult(notOnIpt,this));
  }
  return ret;
}

Fixed version (ground truth):
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program iptProgram=MetadataUtils.existing(Program.class,IPTMetadata._Program.IPT);
  Program tbProgram=MetadataUtils.existing(Program.class,TbMetadata._Program.TB);
  EncounterType iptOutcome=MetadataUtils.existing(EncounterType.class,IPTMetadata._EncounterType.IPT_OUTCOME);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> onIptProgram=Filters.inProgram(iptProgram,alive,context);
  Set<Integer> inTbProgram=Filters.inProgram(tbProgram,alive,context);
  CalculationResultMap lastIptMap=Calculations.lastEncounter(iptOutcome,alive,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    Boolean notOnIpt=false;
    if (alive.contains(ptId) && !inTbProgram.contains(ptId) && !onIptProgram.contains(ptId)) {
      Encounter lastIptEncounter=EmrCalculationUtils.encounterResultForPatient(lastIptMap,ptId);
      if (lastIptEncounter != null) {
        DateTime lastIptEncounterDate=new DateTime(lastIptEncounter.getEncounterDatetime());
        Years yearsSinceLastIpt=Years.yearsBetween(lastIptEncounterDate,new DateTime());
        if (yearsSinceLastIpt.getYears() > 2) {
          notOnIpt=true;
        }
      }
 else {
        notOnIpt=true;
      }
    }
    ret.put(ptId,new BooleanResult(notOnIpt,this,context));
  }
  return ret;
}
Program: 189661
Project: 189661
Buggy source:
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Boolean onIpt=false;
  Program iptProgram=MetadataUtils.existing(Program.class,IPTMetadata._Program.IPT);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> onIptProgram=Filters.inProgram(iptProgram,alive,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    if (onIptProgram.contains(ptId)) {
      onIpt=true;
    }
    ret.put(ptId,new BooleanResult(onIpt,this));
  }
  return ret;
}

Fixed version (ground truth):
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program iptProgram=MetadataUtils.existing(Program.class,IPTMetadata._Program.IPT);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> onIptProgram=Filters.inProgram(iptProgram,alive,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    Boolean onIpt=false;
    if (onIptProgram.contains(ptId)) {
      onIpt=true;
    }
    ret.put(ptId,new BooleanResult(onIpt,this,context));
  }
  return ret;
}
Program: 189662
Project: 189662
Buggy source:
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Boolean missingPyridoxine=false;
  Program tbProgram=MetadataUtils.existing(Program.class,TbMetadata._Program.TB);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> inTbProgram=Filters.inProgram(tbProgram,alive,context);
  CalculationResultMap nutritionSupportObs=Calculations.allObs(Dictionary.getConcept(Dictionary.NUTRITIONAL_SUPPORT),inTbProgram,context);
  Concept pyridoxine=Dictionary.getConcept(Dictionary.PYRIDOXINE);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    if (inTbProgram.contains(ptId)) {
      ListResult listResult=(ListResult)nutritionSupportObs.get(ptId);
      List<Obs> allNSObs=CalculationUtils.extractResultValues(listResult);
      for (      Obs obs : allNSObs) {
        if (obs.getValueCoded().equals(pyridoxine)) {
          missingPyridoxine=true;
        }
      }
    }
    ret.put(ptId,new BooleanResult(missingPyridoxine,this));
  }
  return ret;
}

Fixed version (ground truth):
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program tbProgram=MetadataUtils.existing(Program.class,TbMetadata._Program.TB);
  Set<Integer> alive=Filters.alive(cohort,context);
  Set<Integer> inTbProgram=Filters.inProgram(tbProgram,alive,context);
  Concept pyridoxine=Dictionary.getConcept(Dictionary.PYRIDOXINE);
  CalculationResultMap nutritionSupportObs=Calculations.allObs(Dictionary.getConcept(Dictionary.NUTRITIONAL_SUPPORT),inTbProgram,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    Boolean missingPyridoxine=false;
    if (inTbProgram.contains(ptId)) {
      ListResult listResult=(ListResult)nutritionSupportObs.get(ptId);
      List<Obs> allNSObs=CalculationUtils.extractResultValues(listResult);
      for (      Obs obs : allNSObs) {
        if (obs.getValueCoded().equals(pyridoxine)) {
          missingPyridoxine=true;
        }
      }
    }
    ret.put(ptId,new BooleanResult(missingPyridoxine,this,context));
  }
  return ret;
}
Program: 189666
Project: 189666
Buggy source:
public void controller(){
}

Fixed version (ground truth):
public void controller(FragmentModel model){
  model.put("String_Node_Str",Context.getAdministrationService().getGlobalProperty(EmrConstants.GP_EXTERNAL_HELP_URL,EmrConstants.DEFAULT_EXTERNAL_HELP_URL));
}
Program: 189668
Project: 189668
Buggy source:
/** 
 * Synchronizes an object
 * @param syncKey the sync key
 * @param incoming the object
 */
protected void synchronizeObject(MetadataDeployService deployService,Object syncKey,T incoming){
  Integer existingId=keyCache.get(syncKey);
  T existing=existingId != null ? fetchExistingById(existingId) : null;
  if (existing == null) {
    deployService.saveObject(incoming);
    keyCache.put(syncKey,incoming.getId());
    log.info("String_Node_Str" + incoming.getName() + "String_Node_Str"+ syncKey);
    created.add(incoming);
  }
 else {
    String incomingHash=getObjectHash(incoming);
    String existingHash=getObjectHash(existing);
    if (!incomingHash.equals(existingHash)) {
      incoming.setId(existing.getId());
      Context.evictFromSession(existing);
      deployService.saveObject(incoming);
      log.info("String_Node_Str" + incoming.getName() + "String_Node_Str"+ syncKey);
      updated.add(incoming);
    }
    notSyncedObjects.remove(existing.getId());
  }
}

Fixed version (ground truth):
/** 
 * Synchronizes an object
 * @param syncKey the sync key
 * @param incoming the object
 */
protected void synchronizeObject(MetadataDeployService deployService,Object syncKey,T incoming){
  Integer existingId=keyCache.get(syncKey);
  T existing=existingId != null ? fetchExistingById(existingId) : null;
  if (existing == null) {
    deployService.saveObject(incoming);
    keyCache.put(syncKey,incoming.getId());
    log.info("String_Node_Str" + incoming.getName() + "String_Node_Str"+ syncKey);
    created.add(incoming);
  }
 else {
    String incomingHash=getObjectHash(incoming);
    String existingHash=getObjectHash(existing);
    if (!incomingHash.equals(existingHash)) {
      mergeWithExisting(existing,incoming);
      deployService.saveObject(incoming);
      log.info("String_Node_Str" + incoming.getName() + "String_Node_Str"+ syncKey);
      updated.add(incoming);
    }
    notSyncedObjects.remove(existing.getId());
  }
}
Program: 189671
Project: 189671
Buggy source:
/** 
 * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(java.util.Collection,java.util.Map,org.openmrs.calculation.patient.PatientCalculationContext)
 */
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Concept currentWhoStage=getConcept(Dictionary.CURRENT_WHO_STAGE);
  CalculationResultMap artStartDates=calculate(new InitialArtStartDateCalculation(),cohort,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    SimpleResult result=null;
    Date artStartDate=EmrCalculationUtils.datetimeResultForPatient(artStartDates,ptId);
    if (artStartDate != null) {
      CalculationResultMap currentWhoStageObss=Calculations.lastObsOnOrBefore(currentWhoStage,artStartDate,Collections.singleton(ptId),context);
      Obs whoStageObs=EmrCalculationUtils.obsResultForPatient(currentWhoStageObss,ptId);
      if (whoStageObs != null) {
        result=new SimpleResult(EmrUtils.whoStage(whoStageObs.getValueCoded()),this);
      }
    }
    ret.put(ptId,result);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(java.util.Collection,java.util.Map,org.openmrs.calculation.patient.PatientCalculationContext)
 */
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Concept currentWhoStage=getConcept(Dictionary.CURRENT_WHO_STAGE);
  CalculationResultMap artStartDates=calculate(new InitialArtStartDateCalculation(),cohort,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    SimpleResult result=null;
    Date artStartDate=EmrCalculationUtils.datetimeResultForPatient(artStartDates,ptId);
    if (artStartDate != null) {
      CalculationResultMap currentWhoStageObss=Calculations.lastObsOnOrBefore(currentWhoStage,artStartDate,Collections.singleton(ptId),context);
      Obs whoStageObs=EmrCalculationUtils.obsResultForPatient(currentWhoStageObss,ptId);
      if (whoStageObs != null) {
        Integer whoStage=EmrUtils.whoStage(whoStageObs.getValueCoded());
        if (whoStage != null) {
          result=new SimpleResult(whoStage,this);
        }
      }
    }
    ret.put(ptId,result);
  }
  return ret;
}
Program: 189674
Project: 189674
Buggy source:
@Before public void setup() throws Exception {
  executeDataSet("String_Node_Str");
  executeDataSet("String_Node_Str");
  executeDataSet("String_Node_Str");
  reportManager.refresh();
}

Fixed version (ground truth):
@Before public void setup() throws Exception {
  executeDataSet("String_Node_Str");
  executeDataSet("String_Node_Str");
  executeDataSet("String_Node_Str");
  regimenManager.refresh();
  reportManager.refresh();
}
Program: 189675
Project: 189675
Buggy source:
public void controller(FragmentModel model,@SpringBean KenyaEmr emr){
  if (!emr.isRefreshed()) {
    model.put("String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
public void controller(FragmentModel model,@SpringBean KenyaEmr emr){
  String systemMessage=null;
  if (!emr.isRefreshed()) {
    systemMessage="String_Node_Str";
  }
  model.put("String_Node_Str",systemMessage);
}
Program: 189676
Project: 189676
Buggy source:
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
@Override public void validate(Object target,Errors errors){
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  boolean hasUser=false;
  if (StringUtils.isNotEmpty(username)) {
    hasUser=true;
    if (Context.getUserService().getUserByUsername(username) != null) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    if (StringUtils.isEmpty(password)) {
      require(errors,"String_Node_Str");
    }
 else {
      try {
        OpenmrsUtil.validatePassword(username,password,null);
      }
 catch (      PasswordException e) {
        errors.rejectValue("String_Node_Str",e.getMessage());
      }
    }
    if (StringUtils.isEmpty(confirmPassword)) {
      require(errors,"String_Node_Str");
    }
 else     if (!OpenmrsUtil.nullSafeEquals(password,confirmPassword)) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    require(errors,"String_Node_Str");
  }
  boolean hasProvider=false;
  if (StringUtils.isNotEmpty(providerIdentifier)) {
    hasProvider=true;
    Provider withId=Context.getProviderService().getProviderByIdentifier(providerIdentifier);
    if (withId != null) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
  }
  if (!hasUser && !hasProvider) {
    errors.reject("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
@Override public void validate(Object target,Errors errors){
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  boolean hasUser=false;
  if (StringUtils.isNotEmpty(username)) {
    hasUser=true;
    if (Context.getUserService().getUserByUsername(username) != null) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    if (StringUtils.isEmpty(password)) {
      require(errors,"String_Node_Str");
    }
 else {
      try {
        OpenmrsUtil.validatePassword(username,password,null);
      }
 catch (      PasswordException e) {
        errors.rejectValue("String_Node_Str",e.getMessage());
      }
    }
    if (StringUtils.isEmpty(confirmPassword)) {
      require(errors,"String_Node_Str");
    }
 else     if (!OpenmrsUtil.nullSafeEquals(password,confirmPassword)) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    require(errors,"String_Node_Str");
  }
  boolean hasProvider=false;
  if (StringUtils.isNotEmpty(providerIdentifier)) {
    hasProvider=true;
    Provider withId=Context.getProviderService().getProviderByIdentifier(providerIdentifier);
    if (withId != null) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
  }
  if (!hasUser && !hasProvider) {
    errors.reject("String_Node_Str");
  }
}
Program: 189677
Project: 189677
Buggy source:
/** 
 * @see org.openmrs.api.handler.ExistingVisitAssignmentHandler#beforeCreateEncounter(org.openmrs.Encounter)
 */
@Override public void beforeCreateEncounter(Encounter encounter){
  if (encounter.getVisit() != null) {
    return;
  }
  if (useExistingVisit(encounter)) {
    return;
  }
  if (encounter.getForm() != null) {
    FormDescriptor fd=KenyaEmr.getInstance().getFormManager().getFormDescriptor(encounter.getForm());
    if (fd != null && fd.getAutoCreateVisitType() != null) {
      useNewVisit(encounter,fd.getAutoCreateVisitType());
    }
  }
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.handler.ExistingVisitAssignmentHandler#beforeCreateEncounter(org.openmrs.Encounter)
 */
@Override public void beforeCreateEncounter(Encounter encounter){
  if (encounter.getVisit() != null) {
    return;
  }
  if (useExistingVisit(encounter)) {
    return;
  }
  if (encounter.getForm() != null) {
    FormDescriptor fd=KenyaEmr.getInstance().getFormManager().getFormDescriptor(encounter.getForm());
    if (fd != null && fd.getAutoCreateVisitTypeUuid() != null) {
      VisitType visitType=Metadata.getVisitType(fd.getAutoCreateVisitTypeUuid());
      useNewVisit(encounter,visitType);
    }
  }
}
Program: 189678
Project: 189678
Buggy source:
/** 
 * Simplifies a location
 * @param location the location
 * @param mfcAttrType the MFL code attribute type
 * @param ui the UI utils
 * @return the simple object
 */
public SimpleObject simpleLocation(Location location,LocationAttributeType mfcAttrType,UiUtils ui){
  List<LocationAttribute> attrs=location.getActiveAttributes(mfcAttrType);
  String facilityCode=attrs.size() > 0 ? (String)attrs.get(0).getValue() : null;
  String display=location.getName() + "String_Node_Str" + (facilityCode != null ? facilityCode : "String_Node_Str")+ "String_Node_Str";
  return SimpleObject.create("String_Node_Str",location.getLocationId(),"String_Node_Str",display);
}

Fixed version (ground truth):
/** 
 * Simplifies a location
 * @param location the location
 * @param mfcAttrType the MFL code attribute type
 * @param ui the UI utils
 * @return the simple object
 */
public SimpleObject simpleLocation(Location location,LocationAttributeType mfcAttrType,UiUtils ui){
  List<LocationAttribute> attrs=location.getActiveAttributes(mfcAttrType);
  String facilityCode=attrs.size() > 0 ? (String)attrs.get(0).getValue() : null;
  return SimpleObject.create("String_Node_Str",location.getId(),"String_Node_Str",location.getName(),"String_Node_Str",(facilityCode != null ? facilityCode : "String_Node_Str"));
}
Program: 189679
Project: 189679
Buggy source:
/** 
 * Searches for locations by name of MFL code
 * @param term the search term
 * @return the list of locations as simple objects
 */
public List<SimpleObject> locationSearch(@RequestParam(required=false,value="String_Node_Str") String term,UiUtils ui,@SpringBean KenyaEmrUiUtils kenyaUi){
  LocationService svc=Context.getLocationService();
  LocationAttributeType mflCodeAttrType=Metadata.getLocationAttributeType(Metadata.MASTER_FACILITY_CODE_LOCATION_ATTRIBUTE_TYPE);
  Set<Location> results=new TreeSet<Location>(new Comparator<Location>(){
    @Override public int compare(    Location location1,    Location location2){
      return location1.getName().compareTo(location2.getName());
    }
  }
);
  Location defaultLocation=Context.getService(KenyaEmrService.class).getDefaultLocation();
  if (defaultLocation != null) {
    results.add(defaultLocation);
    results.addAll(defaultLocation.getChildLocations(false));
  }
  if (StringUtils.isNumeric(term) && term.length() >= 5) {
    Location locationByMflCode=Context.getService(KenyaEmrService.class).getLocationByMflCode(term);
    if (locationByMflCode != null) {
      results.add(locationByMflCode);
    }
  }
  if (StringUtils.isNotBlank(term)) {
    results.addAll(svc.getLocations(term,true,0,20));
  }
  List<SimpleObject> ret=new ArrayList<SimpleObject>();
  for (  Location l : results) {
    ret.add(kenyaUi.simpleLocation(l,mflCodeAttrType,ui));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Searches for locations by name of MFL code
 * @param term the search term
 * @return the list of locations as simple objects
 */
public List<SimpleObject> locationSearch(@RequestParam(required=false,value="String_Node_Str") String term,UiUtils ui,@SpringBean KenyaEmrUiUtils kenyaUi){
  LocationService svc=Context.getLocationService();
  LocationAttributeType mflCodeAttrType=Metadata.getLocationAttributeType(Metadata.MASTER_FACILITY_CODE_LOCATION_ATTRIBUTE_TYPE);
  Set<Location> results=new TreeSet<Location>(new Comparator<Location>(){
    @Override public int compare(    Location location1,    Location location2){
      return location1.getName().compareTo(location2.getName());
    }
  }
);
  if (StringUtils.isNumeric(term) && term.length() >= 5) {
    Location locationByMflCode=Context.getService(KenyaEmrService.class).getLocationByMflCode(term);
    if (locationByMflCode != null) {
      results.add(locationByMflCode);
    }
  }
  if (StringUtils.isNotBlank(term)) {
    results.addAll(svc.getLocations(term,true,0,20));
  }
  List<SimpleObject> ret=new ArrayList<SimpleObject>();
  for (  Location l : results) {
    ret.add(kenyaUi.simpleLocation(l,mflCodeAttrType,ui));
  }
  return ret;
}
Program: 189680
Project: 189680
Buggy source:
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
@Override public void validate(Object target,Errors errors){
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  if (StringUtils.isBlank(patientClinicNumber.getIdentifier())) {
    patientClinicNumber=null;
  }
  if (StringUtils.isBlank(hivIdNumber.getIdentifier())) {
    hivIdNumber=null;
  }
  if (!(StringUtils.isBlank(telephoneContact.getValue()))) {
    validateTelephoneNumber(errors,"String_Node_Str",telephoneContact.getValue());
  }
 else {
    telephoneContact=null;
  }
  if (!(StringUtils.isBlank(nextOfKinContact.getValue()))) {
    validateTelephoneNumber(errors,"String_Node_Str",nextOfKinContact.getValue());
  }
 else {
    nextOfKinContact=null;
  }
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
@Override public void validate(Object target,Errors errors){
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  if (StringUtils.isBlank(patientClinicNumber.getIdentifier())) {
    patientClinicNumber=null;
  }
  if (StringUtils.isBlank(hivIdNumber.getIdentifier())) {
    hivIdNumber=null;
  }
  if (!(StringUtils.isBlank(telephoneContact.getValue()))) {
    validateTelephoneNumber(errors,"String_Node_Str",telephoneContact.getValue());
  }
 else {
    telephoneContact=null;
  }
  if (!(StringUtils.isBlank(nextOfKinContact.getValue()))) {
    validateTelephoneNumber(errors,"String_Node_Str",nextOfKinContact.getValue());
  }
 else {
    nextOfKinContact=null;
  }
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  if (birthdate != null) {
    if (birthdate.after(new Date()))     errors.rejectValue("String_Node_Str","String_Node_Str");
 else {
      Calendar c=Calendar.getInstance();
      c.setTime(new Date());
      c.add(Calendar.YEAR,-120);
      if (birthdate.before(c.getTime())) {
        errors.rejectValue("String_Node_Str","String_Node_Str");
      }
    }
  }
}
Program: 189681
Project: 189681
Buggy source:
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program hivProgram=Metadata.getProgram(Metadata.HIV_PROGRAM);
  Set<Integer> alive=alivePatients(cohort,context);
  Set<Integer> inHivProgram=CalculationUtils.patientsThatPass(activeEnrollment(hivProgram,alive,context));
  CalculationResultMap lastCD4Obss=lastObs(getConcept(Dictionary.CD4_COUNT),inHivProgram,context);
  CalculationResultMap oldCD4Obss=lastObsAtLeastDaysAgo(getConcept(Dictionary.CD4_COUNT),KenyaEmrConstants.DECLINING_CD4_COUNT_ACROSS_DAYS,inHivProgram,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    Double lastCD4Count=0.0;
    Double oldCD4Count=0.0;
    boolean declining=false;
    if (inHivProgram.contains(ptId)) {
      lastCD4Count=CalculationUtils.numericObsResultForPatient(lastCD4Obss,ptId);
      oldCD4Count=CalculationUtils.numericObsResultForPatient(oldCD4Obss,ptId);
      if (lastCD4Count != null && oldCD4Count != null) {
        declining=lastCD4Count < oldCD4Count;
      }
    }
    ret.put(ptId,new BooleanResult(declining,this,context));
  }
  return ret;
}

Fixed version (ground truth):
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> parameterValues,PatientCalculationContext context){
  Program hivProgram=Metadata.getProgram(Metadata.HIV_PROGRAM);
  Set<Integer> alive=alivePatients(cohort,context);
  Set<Integer> inHivProgram=CalculationUtils.patientsThatPass(activeEnrollment(hivProgram,alive,context));
  CalculationResultMap lastCD4Obss=lastObs(getConcept(Dictionary.CD4_COUNT),inHivProgram,context);
  CalculationResultMap oldCD4Obss=lastObsAtLeastDaysAgo(getConcept(Dictionary.CD4_COUNT),KenyaEmrConstants.DECLINING_CD4_COUNT_ACROSS_DAYS,inHivProgram,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    boolean declining=false;
    if (inHivProgram.contains(ptId)) {
      Double lastCD4Count=CalculationUtils.numericObsResultForPatient(lastCD4Obss,ptId);
      Double oldCD4Count=CalculationUtils.numericObsResultForPatient(oldCD4Obss,ptId);
      if (lastCD4Count != null && oldCD4Count != null) {
        declining=lastCD4Count < oldCD4Count;
      }
    }
    ret.put(ptId,new BooleanResult(declining,this,context));
  }
  return ret;
}
Program: 189682
Project: 189682
Buggy source:
/** 
 * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(java.util.Collection,java.util.Map,org.openmrs.calculation.patient.PatientCalculationContext)
 * @should return null for patients who have never started ARVs
 * @should return whether patients are currently taking a second-line regimen
 */
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> arg1,PatientCalculationContext context){
  CalculationResultMap currentArvs=calculate(new CurrentArtRegimenCalculation(),cohort,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    BooleanResult result=null;
    SimpleResult currentArvResult=(SimpleResult)currentArvs.get(ptId);
    if (currentArvResult != null) {
      RegimenOrder currentRegimen=(RegimenOrder)currentArvResult.getValue();
      boolean isSecondLine=CalculationUtils.regimenInGroup(currentRegimen,"String_Node_Str","String_Node_Str");
      ;
      result=new BooleanResult(isSecondLine,this,context);
    }
    ret.put(ptId,result);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(java.util.Collection,java.util.Map,org.openmrs.calculation.patient.PatientCalculationContext)
 * @should return null for patients who have never started ARVs
 * @should return whether patients are currently taking a second-line regimen
 */
@Override public CalculationResultMap evaluate(Collection<Integer> cohort,Map<String,Object> arg1,PatientCalculationContext context){
  CalculationResultMap currentArvs=calculate(new CurrentArtRegimenCalculation(),cohort,context);
  CalculationResultMap ret=new CalculationResultMap();
  for (  Integer ptId : cohort) {
    BooleanResult result=null;
    SimpleResult currentArvResult=(SimpleResult)currentArvs.get(ptId);
    if (currentArvResult != null) {
      RegimenOrder currentRegimen=(RegimenOrder)currentArvResult.getValue();
      boolean isSecondLine=CalculationUtils.regimenInGroup(currentRegimen,"String_Node_Str","String_Node_Str");
      result=new BooleanResult(isSecondLine,this,context);
    }
    ret.put(ptId,result);
  }
  return ret;
}
Program: 189683
Project: 189683
Buggy source:
public WithoutCTXOrDapsoneReport(){
  super(new WithoutCtxOrDapsoneCalculation());
}

Fixed version (ground truth):
public WithoutCTXOrDapsoneReport(){
  super(new NeverTakenCtxOrDapsoneCalculation());
}
Program: 189684
Project: 189684
Buggy source:
@Before public void setup() throws Exception {
  executeDataSet("String_Node_Str");
  executeDataSet("String_Node_Str");
  emr.getRegimenManager().clear();
  InputStream stream=getClass().getClassLoader().getResourceAsStream("String_Node_Str");
  emr.getRegimenManager().loadDefinitionsFromXML(stream);
  this.ui=new FragmentActionUiUtils(null,null,null);
  DrugOrder aspirin=new DrugOrder();
  aspirin.setConcept(Context.getConceptService().getConcept(71617));
  aspirin.setDose(100.0d);
  aspirin.setUnits("String_Node_Str");
  aspirin.setFrequency("String_Node_Str");
  DrugOrder stavudine=new DrugOrder();
  stavudine.setConcept(Context.getConceptService().getConcept(84309));
  stavudine.setDose(30.0d);
  stavudine.setUnits("String_Node_Str");
  stavudine.setFrequency("String_Node_Str");
  regimen=new RegimenOrder();
  regimen.addDrugOrder(aspirin);
  regimen.addDrugOrder(stavudine);
}

Fixed version (ground truth):
@Before public void setup() throws Exception {
  executeDataSet("String_Node_Str");
  executeDataSet("String_Node_Str");
  emr.getRegimenManager().clear();
  InputStream stream=getClass().getClassLoader().getResourceAsStream("String_Node_Str");
  emr.getRegimenManager().loadDefinitionsFromXML(stream);
  this.ui=new FragmentActionUiUtils(null,null,null);
  DrugOrder aspirin=new DrugOrder();
  aspirin.setConcept(Context.getConceptService().getConcept(71617));
  aspirin.setDose(100.0d);
  aspirin.setUnits("String_Node_Str");
  aspirin.setFrequency("String_Node_Str");
  DrugOrder stavudine=new DrugOrder();
  stavudine.setConcept(Context.getConceptService().getConcept(84309));
  stavudine.setDose(30.0d);
  stavudine.setUnits("String_Node_Str");
  stavudine.setFrequency("String_Node_Str");
  regimen=new RegimenOrder(new HashSet<DrugOrder>(Arrays.asList(aspirin,stavudine)));
}
Program: 189685
Project: 189685
Buggy source:
/** 
 * @see org.openmrs.module.kenyaemr.KenyaEmrUiUtils#simpleRegimen(org.openmrs.module.kenyaemr.regimen.RegimenOrder,org.openmrs.ui.framework.UiUtils)
 */
@Test public void simpleRegimen_shouldConvertToSimpleObject(){
  SimpleObject obj1=kenyaUi.simpleRegimen(null,ui);
  Assert.assertEquals("String_Node_Str",obj1.get("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",obj1.get("String_Node_Str"));
  SimpleObject obj2=kenyaUi.simpleRegimen(new RegimenOrder(),ui);
  Assert.assertEquals("String_Node_Str",obj2.get("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",obj2.get("String_Node_Str"));
  SimpleObject obj3=kenyaUi.simpleRegimen(regimen,ui);
  Assert.assertNotNull(obj3.get("String_Node_Str"));
  Assert.assertNotNull(obj3.get("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.module.kenyaemr.KenyaEmrUiUtils#simpleRegimen(org.openmrs.module.kenyaemr.regimen.RegimenOrder,org.openmrs.ui.framework.UiUtils)
 */
@Test public void simpleRegimen_shouldConvertToSimpleObject(){
  SimpleObject obj1=kenyaUi.simpleRegimen(null,ui);
  Assert.assertEquals("String_Node_Str",obj1.get("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",obj1.get("String_Node_Str"));
  SimpleObject obj3=kenyaUi.simpleRegimen(regimen,ui);
  Assert.assertNotNull(obj3.get("String_Node_Str"));
  Assert.assertNotNull(obj3.get("String_Node_Str"));
}
Program: 189686
Project: 189686
Buggy source:
/** 
 * @see RegimenManager#findDefinitions(String,RegimenOrder,boolean)
 */
@Test public void findDefinitions_shouldFindDefinitionsForRegimen(){
  DrugOrder lamivudine=new DrugOrder();
  lamivudine.setConcept(Context.getConceptService().getConcept(78643));
  lamivudine.setDose(150d);
  lamivudine.setUnits("String_Node_Str");
  lamivudine.setFrequency("String_Node_Str");
  DrugOrder stavudine=new DrugOrder();
  stavudine.setConcept(Context.getConceptService().getConcept(84309));
  stavudine.setDose(30d);
  stavudine.setUnits("String_Node_Str");
  stavudine.setFrequency("String_Node_Str");
  RegimenOrder regimen=new RegimenOrder();
  regimen.addDrugOrder(lamivudine);
  regimen.addDrugOrder(stavudine);
  List<RegimenDefinition> defsExact=regimenManager.findDefinitions("String_Node_Str",regimen,true);
  Assert.assertEquals(1,defsExact.size());
  Assert.assertEquals("String_Node_Str",defsExact.get(0).getName());
  List<RegimenDefinition> defsNonExact=regimenManager.findDefinitions("String_Node_Str",regimen,false);
  Assert.assertEquals(2,defsNonExact.size());
  Assert.assertEquals("String_Node_Str",defsNonExact.get(0).getName());
  Assert.assertEquals("String_Node_Str",defsNonExact.get(1).getName());
}

Fixed version (ground truth):
/** 
 * @see RegimenManager#findDefinitions(String,RegimenOrder,boolean)
 */
@Test public void findDefinitions_shouldFindDefinitionsForRegimen(){
  DrugOrder lamivudine=new DrugOrder();
  lamivudine.setConcept(Context.getConceptService().getConcept(78643));
  lamivudine.setDose(150d);
  lamivudine.setUnits("String_Node_Str");
  lamivudine.setFrequency("String_Node_Str");
  DrugOrder stavudine=new DrugOrder();
  stavudine.setConcept(Context.getConceptService().getConcept(84309));
  stavudine.setDose(30d);
  stavudine.setUnits("String_Node_Str");
  stavudine.setFrequency("String_Node_Str");
  RegimenOrder regimen=new RegimenOrder(new HashSet<DrugOrder>(Arrays.asList(lamivudine,stavudine)));
  List<RegimenDefinition> defsExact=regimenManager.findDefinitions("String_Node_Str",regimen,true);
  Assert.assertEquals(1,defsExact.size());
  Assert.assertEquals("String_Node_Str",defsExact.get(0).getName());
  List<RegimenDefinition> defsNonExact=regimenManager.findDefinitions("String_Node_Str",regimen,false);
  Assert.assertEquals(2,defsNonExact.size());
  Assert.assertEquals("String_Node_Str",defsNonExact.get(0).getName());
  Assert.assertEquals("String_Node_Str",defsNonExact.get(1).getName());
}
Program: 189687
Project: 189687
Buggy source:
public void controller(@FragmentParam("String_Node_Str") Patient patient,@FragmentParam("String_Node_Str") Boolean complete,FragmentModel model,@SpringBean KenyaEmr emr) throws InvalidCalculationException {
  Map<String,CalculationResult> calculationResults=new HashMap<String,CalculationResult>();
  if (complete != null && complete.booleanValue()) {
    calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(InitialArtRegimenCalculation.class,null,patient.getPatientId()));
  }
  calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(LastWHOStageCalculation.class,null,patient.getPatientId()));
  calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(LastCD4CountCalculation.class,null,patient.getPatientId()));
  calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(LastCD4PercentageCalculation.class,null,patient.getPatientId()));
  model.addAttribute("String_Node_Str",calculationResults);
  Concept medSet=emr.getRegimenManager().getMasterSetConcept("String_Node_Str");
  RegimenChangeHistory history=RegimenChangeHistory.forPatient(patient,medSet);
  model.addAttribute("String_Node_Str",history);
}

Fixed version (ground truth):
public void controller(@FragmentParam("String_Node_Str") Patient patient,@FragmentParam("String_Node_Str") Boolean complete,FragmentModel model,@SpringBean KenyaEmr emr) throws InvalidCalculationException {
  Map<String,CalculationResult> calculationResults=new HashMap<String,CalculationResult>();
  if (complete != null && complete.booleanValue()) {
    calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(InitialArtRegimenCalculation.class,null,patient.getPatientId()));
    calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(InitialArtStartDateCalculation.class,null,patient.getPatientId()));
  }
  calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(LastWHOStageCalculation.class,null,patient.getPatientId()));
  calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(LastCD4CountCalculation.class,null,patient.getPatientId()));
  calculationResults.put("String_Node_Str",CalculationUtils.evaluateForPatient(LastCD4PercentageCalculation.class,null,patient.getPatientId()));
  model.addAttribute("String_Node_Str",calculationResults);
  Concept medSet=emr.getRegimenManager().getMasterSetConcept("String_Node_Str");
  RegimenChangeHistory history=RegimenChangeHistory.forPatient(patient,medSet);
  model.addAttribute("String_Node_Str",history);
}